worker-javascript.js 337 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492
  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",[], function(require, exports, module) {
  193. "use strict";
  194. exports.inherits = function(ctor, superCtor) {
  195. ctor.super_ = superCtor;
  196. ctor.prototype = Object.create(superCtor.prototype, {
  197. constructor: {
  198. value: ctor,
  199. enumerable: false,
  200. writable: true,
  201. configurable: true
  202. }
  203. });
  204. };
  205. exports.mixin = function(obj, mixin) {
  206. for (var key in mixin) {
  207. obj[key] = mixin[key];
  208. }
  209. return obj;
  210. };
  211. exports.implement = function(proto, mixin) {
  212. exports.mixin(proto, mixin);
  213. };
  214. });
  215. ace.define("ace/range",[], function(require, exports, module) {
  216. "use strict";
  217. var comparePoints = function(p1, p2) {
  218. return p1.row - p2.row || p1.column - p2.column;
  219. };
  220. var Range = function(startRow, startColumn, endRow, endColumn) {
  221. this.start = {
  222. row: startRow,
  223. column: startColumn
  224. };
  225. this.end = {
  226. row: endRow,
  227. column: endColumn
  228. };
  229. };
  230. (function() {
  231. this.isEqual = function(range) {
  232. return this.start.row === range.start.row &&
  233. this.end.row === range.end.row &&
  234. this.start.column === range.start.column &&
  235. this.end.column === range.end.column;
  236. };
  237. this.toString = function() {
  238. return ("Range: [" + this.start.row + "/" + this.start.column +
  239. "] -> [" + this.end.row + "/" + this.end.column + "]");
  240. };
  241. this.contains = function(row, column) {
  242. return this.compare(row, column) == 0;
  243. };
  244. this.compareRange = function(range) {
  245. var cmp,
  246. end = range.end,
  247. start = range.start;
  248. cmp = this.compare(end.row, end.column);
  249. if (cmp == 1) {
  250. cmp = this.compare(start.row, start.column);
  251. if (cmp == 1) {
  252. return 2;
  253. } else if (cmp == 0) {
  254. return 1;
  255. } else {
  256. return 0;
  257. }
  258. } else if (cmp == -1) {
  259. return -2;
  260. } else {
  261. cmp = this.compare(start.row, start.column);
  262. if (cmp == -1) {
  263. return -1;
  264. } else if (cmp == 1) {
  265. return 42;
  266. } else {
  267. return 0;
  268. }
  269. }
  270. };
  271. this.comparePoint = function(p) {
  272. return this.compare(p.row, p.column);
  273. };
  274. this.containsRange = function(range) {
  275. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  276. };
  277. this.intersects = function(range) {
  278. var cmp = this.compareRange(range);
  279. return (cmp == -1 || cmp == 0 || cmp == 1);
  280. };
  281. this.isEnd = function(row, column) {
  282. return this.end.row == row && this.end.column == column;
  283. };
  284. this.isStart = function(row, column) {
  285. return this.start.row == row && this.start.column == column;
  286. };
  287. this.setStart = function(row, column) {
  288. if (typeof row == "object") {
  289. this.start.column = row.column;
  290. this.start.row = row.row;
  291. } else {
  292. this.start.row = row;
  293. this.start.column = column;
  294. }
  295. };
  296. this.setEnd = function(row, column) {
  297. if (typeof row == "object") {
  298. this.end.column = row.column;
  299. this.end.row = row.row;
  300. } else {
  301. this.end.row = row;
  302. this.end.column = column;
  303. }
  304. };
  305. this.inside = function(row, column) {
  306. if (this.compare(row, column) == 0) {
  307. if (this.isEnd(row, column) || this.isStart(row, column)) {
  308. return false;
  309. } else {
  310. return true;
  311. }
  312. }
  313. return false;
  314. };
  315. this.insideStart = function(row, column) {
  316. if (this.compare(row, column) == 0) {
  317. if (this.isEnd(row, column)) {
  318. return false;
  319. } else {
  320. return true;
  321. }
  322. }
  323. return false;
  324. };
  325. this.insideEnd = function(row, column) {
  326. if (this.compare(row, column) == 0) {
  327. if (this.isStart(row, column)) {
  328. return false;
  329. } else {
  330. return true;
  331. }
  332. }
  333. return false;
  334. };
  335. this.compare = function(row, column) {
  336. if (!this.isMultiLine()) {
  337. if (row === this.start.row) {
  338. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  339. }
  340. }
  341. if (row < this.start.row)
  342. return -1;
  343. if (row > this.end.row)
  344. return 1;
  345. if (this.start.row === row)
  346. return column >= this.start.column ? 0 : -1;
  347. if (this.end.row === row)
  348. return column <= this.end.column ? 0 : 1;
  349. return 0;
  350. };
  351. this.compareStart = function(row, column) {
  352. if (this.start.row == row && this.start.column == column) {
  353. return -1;
  354. } else {
  355. return this.compare(row, column);
  356. }
  357. };
  358. this.compareEnd = function(row, column) {
  359. if (this.end.row == row && this.end.column == column) {
  360. return 1;
  361. } else {
  362. return this.compare(row, column);
  363. }
  364. };
  365. this.compareInside = function(row, column) {
  366. if (this.end.row == row && this.end.column == column) {
  367. return 1;
  368. } else if (this.start.row == row && this.start.column == column) {
  369. return -1;
  370. } else {
  371. return this.compare(row, column);
  372. }
  373. };
  374. this.clipRows = function(firstRow, lastRow) {
  375. if (this.end.row > lastRow)
  376. var end = {row: lastRow + 1, column: 0};
  377. else if (this.end.row < firstRow)
  378. var end = {row: firstRow, column: 0};
  379. if (this.start.row > lastRow)
  380. var start = {row: lastRow + 1, column: 0};
  381. else if (this.start.row < firstRow)
  382. var start = {row: firstRow, column: 0};
  383. return Range.fromPoints(start || this.start, end || this.end);
  384. };
  385. this.extend = function(row, column) {
  386. var cmp = this.compare(row, column);
  387. if (cmp == 0)
  388. return this;
  389. else if (cmp == -1)
  390. var start = {row: row, column: column};
  391. else
  392. var end = {row: row, column: column};
  393. return Range.fromPoints(start || this.start, end || this.end);
  394. };
  395. this.isEmpty = function() {
  396. return (this.start.row === this.end.row && this.start.column === this.end.column);
  397. };
  398. this.isMultiLine = function() {
  399. return (this.start.row !== this.end.row);
  400. };
  401. this.clone = function() {
  402. return Range.fromPoints(this.start, this.end);
  403. };
  404. this.collapseRows = function() {
  405. if (this.end.column == 0)
  406. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
  407. else
  408. return new Range(this.start.row, 0, this.end.row, 0);
  409. };
  410. this.toScreenRange = function(session) {
  411. var screenPosStart = session.documentToScreenPosition(this.start);
  412. var screenPosEnd = session.documentToScreenPosition(this.end);
  413. return new Range(
  414. screenPosStart.row, screenPosStart.column,
  415. screenPosEnd.row, screenPosEnd.column
  416. );
  417. };
  418. this.moveBy = function(row, column) {
  419. this.start.row += row;
  420. this.start.column += column;
  421. this.end.row += row;
  422. this.end.column += column;
  423. };
  424. }).call(Range.prototype);
  425. Range.fromPoints = function(start, end) {
  426. return new Range(start.row, start.column, end.row, end.column);
  427. };
  428. Range.comparePoints = comparePoints;
  429. Range.comparePoints = function(p1, p2) {
  430. return p1.row - p2.row || p1.column - p2.column;
  431. };
  432. exports.Range = Range;
  433. });
  434. ace.define("ace/apply_delta",[], function(require, exports, module) {
  435. "use strict";
  436. function throwDeltaError(delta, errorText){
  437. console.log("Invalid Delta:", delta);
  438. throw "Invalid Delta: " + errorText;
  439. }
  440. function positionInDocument(docLines, position) {
  441. return position.row >= 0 && position.row < docLines.length &&
  442. position.column >= 0 && position.column <= docLines[position.row].length;
  443. }
  444. function validateDelta(docLines, delta) {
  445. if (delta.action != "insert" && delta.action != "remove")
  446. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  447. if (!(delta.lines instanceof Array))
  448. throwDeltaError(delta, "delta.lines must be an Array");
  449. if (!delta.start || !delta.end)
  450. throwDeltaError(delta, "delta.start/end must be an present");
  451. var start = delta.start;
  452. if (!positionInDocument(docLines, delta.start))
  453. throwDeltaError(delta, "delta.start must be contained in document");
  454. var end = delta.end;
  455. if (delta.action == "remove" && !positionInDocument(docLines, end))
  456. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  457. var numRangeRows = end.row - start.row;
  458. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  459. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  460. throwDeltaError(delta, "delta.range must match delta lines");
  461. }
  462. exports.applyDelta = function(docLines, delta, doNotValidate) {
  463. var row = delta.start.row;
  464. var startColumn = delta.start.column;
  465. var line = docLines[row] || "";
  466. switch (delta.action) {
  467. case "insert":
  468. var lines = delta.lines;
  469. if (lines.length === 1) {
  470. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  471. } else {
  472. var args = [row, 1].concat(delta.lines);
  473. docLines.splice.apply(docLines, args);
  474. docLines[row] = line.substring(0, startColumn) + docLines[row];
  475. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  476. }
  477. break;
  478. case "remove":
  479. var endColumn = delta.end.column;
  480. var endRow = delta.end.row;
  481. if (row === endRow) {
  482. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  483. } else {
  484. docLines.splice(
  485. row, endRow - row + 1,
  486. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  487. );
  488. }
  489. break;
  490. }
  491. };
  492. });
  493. ace.define("ace/lib/event_emitter",[], function(require, exports, module) {
  494. "use strict";
  495. var EventEmitter = {};
  496. var stopPropagation = function() { this.propagationStopped = true; };
  497. var preventDefault = function() { this.defaultPrevented = true; };
  498. EventEmitter._emit =
  499. EventEmitter._dispatchEvent = function(eventName, e) {
  500. this._eventRegistry || (this._eventRegistry = {});
  501. this._defaultHandlers || (this._defaultHandlers = {});
  502. var listeners = this._eventRegistry[eventName] || [];
  503. var defaultHandler = this._defaultHandlers[eventName];
  504. if (!listeners.length && !defaultHandler)
  505. return;
  506. if (typeof e != "object" || !e)
  507. e = {};
  508. if (!e.type)
  509. e.type = eventName;
  510. if (!e.stopPropagation)
  511. e.stopPropagation = stopPropagation;
  512. if (!e.preventDefault)
  513. e.preventDefault = preventDefault;
  514. listeners = listeners.slice();
  515. for (var i=0; i<listeners.length; i++) {
  516. listeners[i](e, this);
  517. if (e.propagationStopped)
  518. break;
  519. }
  520. if (defaultHandler && !e.defaultPrevented)
  521. return defaultHandler(e, this);
  522. };
  523. EventEmitter._signal = function(eventName, e) {
  524. var listeners = (this._eventRegistry || {})[eventName];
  525. if (!listeners)
  526. return;
  527. listeners = listeners.slice();
  528. for (var i=0; i<listeners.length; i++)
  529. listeners[i](e, this);
  530. };
  531. EventEmitter.once = function(eventName, callback) {
  532. var _self = this;
  533. 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",[], 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",[], 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. }
  972. else {
  973. applyDelta(this.$lines, delta, doNotValidate);
  974. this._signal("change", delta);
  975. }
  976. };
  977. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  978. var lines = delta.lines;
  979. var l = lines.length - MAX + 1;
  980. var row = delta.start.row;
  981. var column = delta.start.column;
  982. for (var from = 0, to = 0; from < l; from = to) {
  983. to += MAX - 1;
  984. var chunk = lines.slice(from, to);
  985. chunk.push("");
  986. this.applyDelta({
  987. start: this.pos(row + from, column),
  988. end: this.pos(row + to, column = 0),
  989. action: delta.action,
  990. lines: chunk
  991. }, true);
  992. }
  993. delta.lines = lines.slice(from);
  994. delta.start.row = row + from;
  995. delta.start.column = column;
  996. this.applyDelta(delta, true);
  997. };
  998. this.revertDelta = function(delta) {
  999. this.applyDelta({
  1000. start: this.clonePos(delta.start),
  1001. end: this.clonePos(delta.end),
  1002. action: (delta.action == "insert" ? "remove" : "insert"),
  1003. lines: delta.lines.slice()
  1004. });
  1005. };
  1006. this.indexToPosition = function(index, startRow) {
  1007. var lines = this.$lines || this.getAllLines();
  1008. var newlineLength = this.getNewLineCharacter().length;
  1009. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1010. index -= lines[i].length + newlineLength;
  1011. if (index < 0)
  1012. return {row: i, column: index + lines[i].length + newlineLength};
  1013. }
  1014. return {row: l-1, column: index + lines[l-1].length + newlineLength};
  1015. };
  1016. this.positionToIndex = function(pos, startRow) {
  1017. var lines = this.$lines || this.getAllLines();
  1018. var newlineLength = this.getNewLineCharacter().length;
  1019. var index = 0;
  1020. var row = Math.min(pos.row, lines.length);
  1021. for (var i = startRow || 0; i < row; ++i)
  1022. index += lines[i].length + newlineLength;
  1023. return index + pos.column;
  1024. };
  1025. }).call(Document.prototype);
  1026. exports.Document = Document;
  1027. });
  1028. ace.define("ace/lib/lang",[], function(require, exports, module) {
  1029. "use strict";
  1030. exports.last = function(a) {
  1031. return a[a.length - 1];
  1032. };
  1033. exports.stringReverse = function(string) {
  1034. return string.split("").reverse().join("");
  1035. };
  1036. exports.stringRepeat = function (string, count) {
  1037. var result = '';
  1038. while (count > 0) {
  1039. if (count & 1)
  1040. result += string;
  1041. if (count >>= 1)
  1042. string += string;
  1043. }
  1044. return result;
  1045. };
  1046. var trimBeginRegexp = /^\s\s*/;
  1047. var trimEndRegexp = /\s\s*$/;
  1048. exports.stringTrimLeft = function (string) {
  1049. return string.replace(trimBeginRegexp, '');
  1050. };
  1051. exports.stringTrimRight = function (string) {
  1052. return string.replace(trimEndRegexp, '');
  1053. };
  1054. exports.copyObject = function(obj) {
  1055. var copy = {};
  1056. for (var key in obj) {
  1057. copy[key] = obj[key];
  1058. }
  1059. return copy;
  1060. };
  1061. exports.copyArray = function(array){
  1062. var copy = [];
  1063. for (var i=0, l=array.length; i<l; i++) {
  1064. if (array[i] && typeof array[i] == "object")
  1065. copy[i] = this.copyObject(array[i]);
  1066. else
  1067. copy[i] = array[i];
  1068. }
  1069. return copy;
  1070. };
  1071. exports.deepCopy = function deepCopy(obj) {
  1072. if (typeof obj !== "object" || !obj)
  1073. return obj;
  1074. var copy;
  1075. if (Array.isArray(obj)) {
  1076. copy = [];
  1077. for (var key = 0; key < obj.length; key++) {
  1078. copy[key] = deepCopy(obj[key]);
  1079. }
  1080. return copy;
  1081. }
  1082. if (Object.prototype.toString.call(obj) !== "[object Object]")
  1083. return obj;
  1084. copy = {};
  1085. for (var key in obj)
  1086. copy[key] = deepCopy(obj[key]);
  1087. return copy;
  1088. };
  1089. exports.arrayToMap = function(arr) {
  1090. var map = {};
  1091. for (var i=0; i<arr.length; i++) {
  1092. map[arr[i]] = 1;
  1093. }
  1094. return map;
  1095. };
  1096. exports.createMap = function(props) {
  1097. var map = Object.create(null);
  1098. for (var i in props) {
  1099. map[i] = props[i];
  1100. }
  1101. return map;
  1102. };
  1103. exports.arrayRemove = function(array, value) {
  1104. for (var i = 0; i <= array.length; i++) {
  1105. if (value === array[i]) {
  1106. array.splice(i, 1);
  1107. }
  1108. }
  1109. };
  1110. exports.escapeRegExp = function(str) {
  1111. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1112. };
  1113. exports.escapeHTML = function(str) {
  1114. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1115. };
  1116. exports.getMatchOffsets = function(string, regExp) {
  1117. var matches = [];
  1118. string.replace(regExp, function(str) {
  1119. matches.push({
  1120. offset: arguments[arguments.length-2],
  1121. length: str.length
  1122. });
  1123. });
  1124. return matches;
  1125. };
  1126. exports.deferredCall = function(fcn) {
  1127. var timer = null;
  1128. var callback = function() {
  1129. timer = null;
  1130. fcn();
  1131. };
  1132. var deferred = function(timeout) {
  1133. deferred.cancel();
  1134. timer = setTimeout(callback, timeout || 0);
  1135. return deferred;
  1136. };
  1137. deferred.schedule = deferred;
  1138. deferred.call = function() {
  1139. this.cancel();
  1140. fcn();
  1141. return deferred;
  1142. };
  1143. deferred.cancel = function() {
  1144. clearTimeout(timer);
  1145. timer = null;
  1146. return deferred;
  1147. };
  1148. deferred.isPending = function() {
  1149. return timer;
  1150. };
  1151. return deferred;
  1152. };
  1153. exports.delayedCall = function(fcn, defaultTimeout) {
  1154. var timer = null;
  1155. var callback = function() {
  1156. timer = null;
  1157. fcn();
  1158. };
  1159. var _self = function(timeout) {
  1160. if (timer == null)
  1161. timer = setTimeout(callback, timeout || defaultTimeout);
  1162. };
  1163. _self.delay = function(timeout) {
  1164. timer && clearTimeout(timer);
  1165. timer = setTimeout(callback, timeout || defaultTimeout);
  1166. };
  1167. _self.schedule = _self;
  1168. _self.call = function() {
  1169. this.cancel();
  1170. fcn();
  1171. };
  1172. _self.cancel = function() {
  1173. timer && clearTimeout(timer);
  1174. timer = null;
  1175. };
  1176. _self.isPending = function() {
  1177. return timer;
  1178. };
  1179. return _self;
  1180. };
  1181. });
  1182. ace.define("ace/worker/mirror",[], function(require, exports, module) {
  1183. "use strict";
  1184. var Range = require("../range").Range;
  1185. var Document = require("../document").Document;
  1186. var lang = require("../lib/lang");
  1187. var Mirror = exports.Mirror = function(sender) {
  1188. this.sender = sender;
  1189. var doc = this.doc = new Document("");
  1190. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1191. var _self = this;
  1192. sender.on("change", function(e) {
  1193. var data = e.data;
  1194. if (data[0].start) {
  1195. doc.applyDeltas(data);
  1196. } else {
  1197. for (var i = 0; i < data.length; i += 2) {
  1198. if (Array.isArray(data[i+1])) {
  1199. var d = {action: "insert", start: data[i], lines: data[i+1]};
  1200. } else {
  1201. var d = {action: "remove", start: data[i], end: data[i+1]};
  1202. }
  1203. doc.applyDelta(d, true);
  1204. }
  1205. }
  1206. if (_self.$timeout)
  1207. return deferredUpdate.schedule(_self.$timeout);
  1208. _self.onUpdate();
  1209. });
  1210. };
  1211. (function() {
  1212. this.$timeout = 500;
  1213. this.setTimeout = function(timeout) {
  1214. this.$timeout = timeout;
  1215. };
  1216. this.setValue = function(value) {
  1217. this.doc.setValue(value);
  1218. this.deferredUpdate.schedule(this.$timeout);
  1219. };
  1220. this.getValue = function(callbackId) {
  1221. this.sender.callback(this.doc.getValue(), callbackId);
  1222. };
  1223. this.onUpdate = function() {
  1224. };
  1225. this.isPending = function() {
  1226. return this.deferredUpdate.isPending();
  1227. };
  1228. }).call(Mirror.prototype);
  1229. });
  1230. ace.define("ace/mode/javascript/jshint",[], function(require, exports, module) {
  1231. module.exports = (function outer (modules, cache, entry) {
  1232. var previousRequire = typeof require == "function" && require;
  1233. function newRequire(name, jumped){
  1234. if(!cache[name]) {
  1235. if(!modules[name]) {
  1236. var currentRequire = typeof require == "function" && require;
  1237. if (!jumped && currentRequire) return currentRequire(name, true);
  1238. if (previousRequire) return previousRequire(name, true);
  1239. var err = new Error('Cannot find module \'' + name + '\'');
  1240. err.code = 'MODULE_NOT_FOUND';
  1241. throw err;
  1242. }
  1243. var m = cache[name] = {exports:{}};
  1244. modules[name][0].call(m.exports, function(x){
  1245. var id = modules[name][1][x];
  1246. return newRequire(id ? id : x);
  1247. },m,m.exports,outer,modules,cache,entry);
  1248. }
  1249. return cache[name].exports;
  1250. }
  1251. for(var i=0;i<entry.length;i++) newRequire(entry[i]);
  1252. return newRequire(entry[0]);
  1253. })
  1254. ({"/node_modules/browserify/node_modules/events/events.js":[function(_dereq_,module,exports){
  1255. //
  1256. //
  1257. //
  1258. function EventEmitter() {
  1259. this._events = this._events || {};
  1260. this._maxListeners = this._maxListeners || undefined;
  1261. }
  1262. module.exports = EventEmitter;
  1263. EventEmitter.EventEmitter = EventEmitter;
  1264. EventEmitter.prototype._events = undefined;
  1265. EventEmitter.prototype._maxListeners = undefined;
  1266. EventEmitter.defaultMaxListeners = 10;
  1267. EventEmitter.prototype.setMaxListeners = function(n) {
  1268. if (!isNumber(n) || n < 0 || isNaN(n))
  1269. throw TypeError('n must be a positive number');
  1270. this._maxListeners = n;
  1271. return this;
  1272. };
  1273. EventEmitter.prototype.emit = function(type) {
  1274. var er, handler, len, args, i, listeners;
  1275. if (!this._events)
  1276. this._events = {};
  1277. if (type === 'error') {
  1278. if (!this._events.error ||
  1279. (isObject(this._events.error) && !this._events.error.length)) {
  1280. er = arguments[1];
  1281. if (er instanceof Error) {
  1282. throw er; // Unhandled 'error' event
  1283. }
  1284. throw TypeError('Uncaught, unspecified "error" event.');
  1285. }
  1286. }
  1287. handler = this._events[type];
  1288. if (isUndefined(handler))
  1289. return false;
  1290. if (isFunction(handler)) {
  1291. switch (arguments.length) {
  1292. case 1:
  1293. handler.call(this);
  1294. break;
  1295. case 2:
  1296. handler.call(this, arguments[1]);
  1297. break;
  1298. case 3:
  1299. handler.call(this, arguments[1], arguments[2]);
  1300. break;
  1301. default:
  1302. len = arguments.length;
  1303. args = new Array(len - 1);
  1304. for (i = 1; i < len; i++)
  1305. args[i - 1] = arguments[i];
  1306. handler.apply(this, args);
  1307. }
  1308. } else if (isObject(handler)) {
  1309. len = arguments.length;
  1310. args = new Array(len - 1);
  1311. for (i = 1; i < len; i++)
  1312. args[i - 1] = arguments[i];
  1313. listeners = handler.slice();
  1314. len = listeners.length;
  1315. for (i = 0; i < len; i++)
  1316. listeners[i].apply(this, args);
  1317. }
  1318. return true;
  1319. };
  1320. EventEmitter.prototype.addListener = function(type, listener) {
  1321. var m;
  1322. if (!isFunction(listener))
  1323. throw TypeError('listener must be a function');
  1324. if (!this._events)
  1325. this._events = {};
  1326. if (this._events.newListener)
  1327. this.emit('newListener', type,
  1328. isFunction(listener.listener) ?
  1329. listener.listener : listener);
  1330. if (!this._events[type])
  1331. this._events[type] = listener;
  1332. else if (isObject(this._events[type]))
  1333. this._events[type].push(listener);
  1334. else
  1335. this._events[type] = [this._events[type], listener];
  1336. if (isObject(this._events[type]) && !this._events[type].warned) {
  1337. var m;
  1338. if (!isUndefined(this._maxListeners)) {
  1339. m = this._maxListeners;
  1340. } else {
  1341. m = EventEmitter.defaultMaxListeners;
  1342. }
  1343. if (m && m > 0 && this._events[type].length > m) {
  1344. this._events[type].warned = true;
  1345. console.error('(node) warning: possible EventEmitter memory ' +
  1346. 'leak detected. %d listeners added. ' +
  1347. 'Use emitter.setMaxListeners() to increase limit.',
  1348. this._events[type].length);
  1349. if (typeof console.trace === 'function') {
  1350. console.trace();
  1351. }
  1352. }
  1353. }
  1354. return this;
  1355. };
  1356. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  1357. EventEmitter.prototype.once = function(type, listener) {
  1358. if (!isFunction(listener))
  1359. throw TypeError('listener must be a function');
  1360. var fired = false;
  1361. function g() {
  1362. this.removeListener(type, g);
  1363. if (!fired) {
  1364. fired = true;
  1365. listener.apply(this, arguments);
  1366. }
  1367. }
  1368. g.listener = listener;
  1369. this.on(type, g);
  1370. return this;
  1371. };
  1372. EventEmitter.prototype.removeListener = function(type, listener) {
  1373. var list, position, length, i;
  1374. if (!isFunction(listener))
  1375. throw TypeError('listener must be a function');
  1376. if (!this._events || !this._events[type])
  1377. return this;
  1378. list = this._events[type];
  1379. length = list.length;
  1380. position = -1;
  1381. if (list === listener ||
  1382. (isFunction(list.listener) && list.listener === listener)) {
  1383. delete this._events[type];
  1384. if (this._events.removeListener)
  1385. this.emit('removeListener', type, listener);
  1386. } else if (isObject(list)) {
  1387. for (i = length; i-- > 0;) {
  1388. if (list[i] === listener ||
  1389. (list[i].listener && list[i].listener === listener)) {
  1390. position = i;
  1391. break;
  1392. }
  1393. }
  1394. if (position < 0)
  1395. return this;
  1396. if (list.length === 1) {
  1397. list.length = 0;
  1398. delete this._events[type];
  1399. } else {
  1400. list.splice(position, 1);
  1401. }
  1402. if (this._events.removeListener)
  1403. this.emit('removeListener', type, listener);
  1404. }
  1405. return this;
  1406. };
  1407. EventEmitter.prototype.removeAllListeners = function(type) {
  1408. var key, listeners;
  1409. if (!this._events)
  1410. return this;
  1411. if (!this._events.removeListener) {
  1412. if (arguments.length === 0)
  1413. this._events = {};
  1414. else if (this._events[type])
  1415. delete this._events[type];
  1416. return this;
  1417. }
  1418. if (arguments.length === 0) {
  1419. for (key in this._events) {
  1420. if (key === 'removeListener') continue;
  1421. this.removeAllListeners(key);
  1422. }
  1423. this.removeAllListeners('removeListener');
  1424. this._events = {};
  1425. return this;
  1426. }
  1427. listeners = this._events[type];
  1428. if (isFunction(listeners)) {
  1429. this.removeListener(type, listeners);
  1430. } else {
  1431. while (listeners.length)
  1432. this.removeListener(type, listeners[listeners.length - 1]);
  1433. }
  1434. delete this._events[type];
  1435. return this;
  1436. };
  1437. EventEmitter.prototype.listeners = function(type) {
  1438. var ret;
  1439. if (!this._events || !this._events[type])
  1440. ret = [];
  1441. else if (isFunction(this._events[type]))
  1442. ret = [this._events[type]];
  1443. else
  1444. ret = this._events[type].slice();
  1445. return ret;
  1446. };
  1447. EventEmitter.listenerCount = function(emitter, type) {
  1448. var ret;
  1449. if (!emitter._events || !emitter._events[type])
  1450. ret = 0;
  1451. else if (isFunction(emitter._events[type]))
  1452. ret = 1;
  1453. else
  1454. ret = emitter._events[type].length;
  1455. return ret;
  1456. };
  1457. function isFunction(arg) {
  1458. return typeof arg === 'function';
  1459. }
  1460. function isNumber(arg) {
  1461. return typeof arg === 'number';
  1462. }
  1463. function isObject(arg) {
  1464. return typeof arg === 'object' && arg !== null;
  1465. }
  1466. function isUndefined(arg) {
  1467. return arg === void 0;
  1468. }
  1469. },{}],"/node_modules/jshint/data/ascii-identifier-data.js":[function(_dereq_,module,exports){
  1470. var identifierStartTable = [];
  1471. for (var i = 0; i < 128; i++) {
  1472. identifierStartTable[i] =
  1473. i === 36 || // $
  1474. i >= 65 && i <= 90 || // A-Z
  1475. i === 95 || // _
  1476. i >= 97 && i <= 122; // a-z
  1477. }
  1478. var identifierPartTable = [];
  1479. for (var i = 0; i < 128; i++) {
  1480. identifierPartTable[i] =
  1481. identifierStartTable[i] || // $, _, A-Z, a-z
  1482. i >= 48 && i <= 57; // 0-9
  1483. }
  1484. module.exports = {
  1485. asciiIdentifierStartTable: identifierStartTable,
  1486. asciiIdentifierPartTable: identifierPartTable
  1487. };
  1488. },{}],"/node_modules/jshint/lodash.js":[function(_dereq_,module,exports){
  1489. (function (global){
  1490. ;(function() {
  1491. var undefined;
  1492. var VERSION = '3.7.0';
  1493. var FUNC_ERROR_TEXT = 'Expected a function';
  1494. var argsTag = '[object Arguments]',
  1495. arrayTag = '[object Array]',
  1496. boolTag = '[object Boolean]',
  1497. dateTag = '[object Date]',
  1498. errorTag = '[object Error]',
  1499. funcTag = '[object Function]',
  1500. mapTag = '[object Map]',
  1501. numberTag = '[object Number]',
  1502. objectTag = '[object Object]',
  1503. regexpTag = '[object RegExp]',
  1504. setTag = '[object Set]',
  1505. stringTag = '[object String]',
  1506. weakMapTag = '[object WeakMap]';
  1507. var arrayBufferTag = '[object ArrayBuffer]',
  1508. float32Tag = '[object Float32Array]',
  1509. float64Tag = '[object Float64Array]',
  1510. int8Tag = '[object Int8Array]',
  1511. int16Tag = '[object Int16Array]',
  1512. int32Tag = '[object Int32Array]',
  1513. uint8Tag = '[object Uint8Array]',
  1514. uint8ClampedTag = '[object Uint8ClampedArray]',
  1515. uint16Tag = '[object Uint16Array]',
  1516. uint32Tag = '[object Uint32Array]';
  1517. var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
  1518. reIsPlainProp = /^\w*$/,
  1519. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  1520. var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
  1521. reHasRegExpChars = RegExp(reRegExpChars.source);
  1522. var reEscapeChar = /\\(\\)?/g;
  1523. var reFlags = /\w*$/;
  1524. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1525. var typedArrayTags = {};
  1526. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1527. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1528. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1529. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1530. typedArrayTags[uint32Tag] = true;
  1531. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1532. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1533. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  1534. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  1535. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  1536. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  1537. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  1538. var cloneableTags = {};
  1539. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1540. cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
  1541. cloneableTags[dateTag] = cloneableTags[float32Tag] =
  1542. cloneableTags[float64Tag] = cloneableTags[int8Tag] =
  1543. cloneableTags[int16Tag] = cloneableTags[int32Tag] =
  1544. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1545. cloneableTags[regexpTag] = cloneableTags[stringTag] =
  1546. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1547. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1548. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1549. cloneableTags[mapTag] = cloneableTags[setTag] =
  1550. cloneableTags[weakMapTag] = false;
  1551. var objectTypes = {
  1552. 'function': true,
  1553. 'object': true
  1554. };
  1555. var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
  1556. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  1557. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;
  1558. var freeSelf = objectTypes[typeof self] && self && self.Object && self;
  1559. var freeWindow = objectTypes[typeof window] && window && window.Object && window;
  1560. var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
  1561. var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
  1562. function baseFindIndex(array, predicate, fromRight) {
  1563. var length = array.length,
  1564. index = fromRight ? length : -1;
  1565. while ((fromRight ? index-- : ++index < length)) {
  1566. if (predicate(array[index], index, array)) {
  1567. return index;
  1568. }
  1569. }
  1570. return -1;
  1571. }
  1572. function baseIndexOf(array, value, fromIndex) {
  1573. if (value !== value) {
  1574. return indexOfNaN(array, fromIndex);
  1575. }
  1576. var index = fromIndex - 1,
  1577. length = array.length;
  1578. while (++index < length) {
  1579. if (array[index] === value) {
  1580. return index;
  1581. }
  1582. }
  1583. return -1;
  1584. }
  1585. function baseIsFunction(value) {
  1586. return typeof value == 'function' || false;
  1587. }
  1588. function baseToString(value) {
  1589. if (typeof value == 'string') {
  1590. return value;
  1591. }
  1592. return value == null ? '' : (value + '');
  1593. }
  1594. function indexOfNaN(array, fromIndex, fromRight) {
  1595. var length = array.length,
  1596. index = fromIndex + (fromRight ? 0 : -1);
  1597. while ((fromRight ? index-- : ++index < length)) {
  1598. var other = array[index];
  1599. if (other !== other) {
  1600. return index;
  1601. }
  1602. }
  1603. return -1;
  1604. }
  1605. function isObjectLike(value) {
  1606. return !!value && typeof value == 'object';
  1607. }
  1608. var arrayProto = Array.prototype,
  1609. objectProto = Object.prototype;
  1610. var fnToString = Function.prototype.toString;
  1611. var hasOwnProperty = objectProto.hasOwnProperty;
  1612. var objToString = objectProto.toString;
  1613. var reIsNative = RegExp('^' +
  1614. escapeRegExp(objToString)
  1615. .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1616. );
  1617. var ArrayBuffer = isNative(ArrayBuffer = root.ArrayBuffer) && ArrayBuffer,
  1618. bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
  1619. floor = Math.floor,
  1620. getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols,
  1621. getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
  1622. push = arrayProto.push,
  1623. preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions,
  1624. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1625. Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array;
  1626. var Float64Array = (function() {
  1627. try {
  1628. var func = isNative(func = root.Float64Array) && func,
  1629. result = new func(new ArrayBuffer(10), 0, 1) && func;
  1630. } catch(e) {}
  1631. return result;
  1632. }());
  1633. var nativeAssign = (function() {
  1634. var object = { '1': 0 },
  1635. func = preventExtensions && isNative(func = Object.assign) && func;
  1636. try { func(preventExtensions(object), 'xo'); } catch(e) {}
  1637. return !object[1] && func;
  1638. }());
  1639. var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
  1640. nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
  1641. nativeMax = Math.max,
  1642. nativeMin = Math.min;
  1643. var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
  1644. var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
  1645. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  1646. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  1647. var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
  1648. var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
  1649. function lodash() {
  1650. }
  1651. var support = lodash.support = {};
  1652. (function(x) {
  1653. var Ctor = function() { this.x = x; },
  1654. object = { '0': x, 'length': x },
  1655. props = [];
  1656. Ctor.prototype = { 'valueOf': x, 'y': x };
  1657. for (var key in new Ctor) { props.push(key); }
  1658. support.funcDecomp = /\bthis\b/.test(function() { return this; });
  1659. support.funcNames = typeof Function.name == 'string';
  1660. try {
  1661. support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
  1662. } catch(e) {
  1663. support.nonEnumArgs = true;
  1664. }
  1665. }(1, 0));
  1666. function arrayCopy(source, array) {
  1667. var index = -1,
  1668. length = source.length;
  1669. array || (array = Array(length));
  1670. while (++index < length) {
  1671. array[index] = source[index];
  1672. }
  1673. return array;
  1674. }
  1675. function arrayEach(array, iteratee) {
  1676. var index = -1,
  1677. length = array.length;
  1678. while (++index < length) {
  1679. if (iteratee(array[index], index, array) === false) {
  1680. break;
  1681. }
  1682. }
  1683. return array;
  1684. }
  1685. function arrayFilter(array, predicate) {
  1686. var index = -1,
  1687. length = array.length,
  1688. resIndex = -1,
  1689. result = [];
  1690. while (++index < length) {
  1691. var value = array[index];
  1692. if (predicate(value, index, array)) {
  1693. result[++resIndex] = value;
  1694. }
  1695. }
  1696. return result;
  1697. }
  1698. function arrayMap(array, iteratee) {
  1699. var index = -1,
  1700. length = array.length,
  1701. result = Array(length);
  1702. while (++index < length) {
  1703. result[index] = iteratee(array[index], index, array);
  1704. }
  1705. return result;
  1706. }
  1707. function arrayMax(array) {
  1708. var index = -1,
  1709. length = array.length,
  1710. result = NEGATIVE_INFINITY;
  1711. while (++index < length) {
  1712. var value = array[index];
  1713. if (value > result) {
  1714. result = value;
  1715. }
  1716. }
  1717. return result;
  1718. }
  1719. function arraySome(array, predicate) {
  1720. var index = -1,
  1721. length = array.length;
  1722. while (++index < length) {
  1723. if (predicate(array[index], index, array)) {
  1724. return true;
  1725. }
  1726. }
  1727. return false;
  1728. }
  1729. function assignWith(object, source, customizer) {
  1730. var props = keys(source);
  1731. push.apply(props, getSymbols(source));
  1732. var index = -1,
  1733. length = props.length;
  1734. while (++index < length) {
  1735. var key = props[index],
  1736. value = object[key],
  1737. result = customizer(value, source[key], key, object, source);
  1738. if ((result === result ? (result !== value) : (value === value)) ||
  1739. (value === undefined && !(key in object))) {
  1740. object[key] = result;
  1741. }
  1742. }
  1743. return object;
  1744. }
  1745. var baseAssign = nativeAssign || function(object, source) {
  1746. return source == null
  1747. ? object
  1748. : baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object));
  1749. };
  1750. function baseCopy(source, props, object) {
  1751. object || (object = {});
  1752. var index = -1,
  1753. length = props.length;
  1754. while (++index < length) {
  1755. var key = props[index];
  1756. object[key] = source[key];
  1757. }
  1758. return object;
  1759. }
  1760. function baseCallback(func, thisArg, argCount) {
  1761. var type = typeof func;
  1762. if (type == 'function') {
  1763. return thisArg === undefined
  1764. ? func
  1765. : bindCallback(func, thisArg, argCount);
  1766. }
  1767. if (func == null) {
  1768. return identity;
  1769. }
  1770. if (type == 'object') {
  1771. return baseMatches(func);
  1772. }
  1773. return thisArg === undefined
  1774. ? property(func)
  1775. : baseMatchesProperty(func, thisArg);
  1776. }
  1777. function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
  1778. var result;
  1779. if (customizer) {
  1780. result = object ? customizer(value, key, object) : customizer(value);
  1781. }
  1782. if (result !== undefined) {
  1783. return result;
  1784. }
  1785. if (!isObject(value)) {
  1786. return value;
  1787. }
  1788. var isArr = isArray(value);
  1789. if (isArr) {
  1790. result = initCloneArray(value);
  1791. if (!isDeep) {
  1792. return arrayCopy(value, result);
  1793. }
  1794. } else {
  1795. var tag = objToString.call(value),
  1796. isFunc = tag == funcTag;
  1797. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  1798. result = initCloneObject(isFunc ? {} : value);
  1799. if (!isDeep) {
  1800. return baseAssign(result, value);
  1801. }
  1802. } else {
  1803. return cloneableTags[tag]
  1804. ? initCloneByTag(value, tag, isDeep)
  1805. : (object ? value : {});
  1806. }
  1807. }
  1808. stackA || (stackA = []);
  1809. stackB || (stackB = []);
  1810. var length = stackA.length;
  1811. while (length--) {
  1812. if (stackA[length] == value) {
  1813. return stackB[length];
  1814. }
  1815. }
  1816. stackA.push(value);
  1817. stackB.push(result);
  1818. (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
  1819. result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
  1820. });
  1821. return result;
  1822. }
  1823. var baseEach = createBaseEach(baseForOwn);
  1824. function baseFilter(collection, predicate) {
  1825. var result = [];
  1826. baseEach(collection, function(value, index, collection) {
  1827. if (predicate(value, index, collection)) {
  1828. result.push(value);
  1829. }
  1830. });
  1831. return result;
  1832. }
  1833. var baseFor = createBaseFor();
  1834. function baseForIn(object, iteratee) {
  1835. return baseFor(object, iteratee, keysIn);
  1836. }
  1837. function baseForOwn(object, iteratee) {
  1838. return baseFor(object, iteratee, keys);
  1839. }
  1840. function baseGet(object, path, pathKey) {
  1841. if (object == null) {
  1842. return;
  1843. }
  1844. if (pathKey !== undefined && pathKey in toObject(object)) {
  1845. path = [pathKey];
  1846. }
  1847. var index = -1,
  1848. length = path.length;
  1849. while (object != null && ++index < length) {
  1850. var result = object = object[path[index]];
  1851. }
  1852. return result;
  1853. }
  1854. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  1855. if (value === other) {
  1856. return value !== 0 || (1 / value == 1 / other);
  1857. }
  1858. var valType = typeof value,
  1859. othType = typeof other;
  1860. if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
  1861. value == null || other == null) {
  1862. return value !== value && other !== other;
  1863. }
  1864. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  1865. }
  1866. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  1867. var objIsArr = isArray(object),
  1868. othIsArr = isArray(other),
  1869. objTag = arrayTag,
  1870. othTag = arrayTag;
  1871. if (!objIsArr) {
  1872. objTag = objToString.call(object);
  1873. if (objTag == argsTag) {
  1874. objTag = objectTag;
  1875. } else if (objTag != objectTag) {
  1876. objIsArr = isTypedArray(object);
  1877. }
  1878. }
  1879. if (!othIsArr) {
  1880. othTag = objToString.call(other);
  1881. if (othTag == argsTag) {
  1882. othTag = objectTag;
  1883. } else if (othTag != objectTag) {
  1884. othIsArr = isTypedArray(other);
  1885. }
  1886. }
  1887. var objIsObj = objTag == objectTag,
  1888. othIsObj = othTag == objectTag,
  1889. isSameTag = objTag == othTag;
  1890. if (isSameTag && !(objIsArr || objIsObj)) {
  1891. return equalByTag(object, other, objTag);
  1892. }
  1893. if (!isLoose) {
  1894. var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  1895. othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  1896. if (valWrapped || othWrapped) {
  1897. return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  1898. }
  1899. }
  1900. if (!isSameTag) {
  1901. return false;
  1902. }
  1903. stackA || (stackA = []);
  1904. stackB || (stackB = []);
  1905. var length = stackA.length;
  1906. while (length--) {
  1907. if (stackA[length] == object) {
  1908. return stackB[length] == other;
  1909. }
  1910. }
  1911. stackA.push(object);
  1912. stackB.push(other);
  1913. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  1914. stackA.pop();
  1915. stackB.pop();
  1916. return result;
  1917. }
  1918. function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
  1919. var index = -1,
  1920. length = props.length,
  1921. noCustomizer = !customizer;
  1922. while (++index < length) {
  1923. if ((noCustomizer && strictCompareFlags[index])
  1924. ? values[index] !== object[props[index]]
  1925. : !(props[index] in object)
  1926. ) {
  1927. return false;
  1928. }
  1929. }
  1930. index = -1;
  1931. while (++index < length) {
  1932. var key = props[index],
  1933. objValue = object[key],
  1934. srcValue = values[index];
  1935. if (noCustomizer && strictCompareFlags[index]) {
  1936. var result = objValue !== undefined || (key in object);
  1937. } else {
  1938. result = customizer ? customizer(objValue, srcValue, key) : undefined;
  1939. if (result === undefined) {
  1940. result = baseIsEqual(srcValue, objValue, customizer, true);
  1941. }
  1942. }
  1943. if (!result) {
  1944. return false;
  1945. }
  1946. }
  1947. return true;
  1948. }
  1949. function baseMatches(source) {
  1950. var props = keys(source),
  1951. length = props.length;
  1952. if (!length) {
  1953. return constant(true);
  1954. }
  1955. if (length == 1) {
  1956. var key = props[0],
  1957. value = source[key];
  1958. if (isStrictComparable(value)) {
  1959. return function(object) {
  1960. if (object == null) {
  1961. return false;
  1962. }
  1963. return object[key] === value && (value !== undefined || (key in toObject(object)));
  1964. };
  1965. }
  1966. }
  1967. var values = Array(length),
  1968. strictCompareFlags = Array(length);
  1969. while (length--) {
  1970. value = source[props[length]];
  1971. values[length] = value;
  1972. strictCompareFlags[length] = isStrictComparable(value);
  1973. }
  1974. return function(object) {
  1975. return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
  1976. };
  1977. }
  1978. function baseMatchesProperty(path, value) {
  1979. var isArr = isArray(path),
  1980. isCommon = isKey(path) && isStrictComparable(value),
  1981. pathKey = (path + '');
  1982. path = toPath(path);
  1983. return function(object) {
  1984. if (object == null) {
  1985. return false;
  1986. }
  1987. var key = pathKey;
  1988. object = toObject(object);
  1989. if ((isArr || !isCommon) && !(key in object)) {
  1990. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  1991. if (object == null) {
  1992. return false;
  1993. }
  1994. key = last(path);
  1995. object = toObject(object);
  1996. }
  1997. return object[key] === value
  1998. ? (value !== undefined || (key in object))
  1999. : baseIsEqual(value, object[key], null, true);
  2000. };
  2001. }
  2002. function baseMerge(object, source, customizer, stackA, stackB) {
  2003. if (!isObject(object)) {
  2004. return object;
  2005. }
  2006. var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
  2007. if (!isSrcArr) {
  2008. var props = keys(source);
  2009. push.apply(props, getSymbols(source));
  2010. }
  2011. arrayEach(props || source, function(srcValue, key) {
  2012. if (props) {
  2013. key = srcValue;
  2014. srcValue = source[key];
  2015. }
  2016. if (isObjectLike(srcValue)) {
  2017. stackA || (stackA = []);
  2018. stackB || (stackB = []);
  2019. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  2020. }
  2021. else {
  2022. var value = object[key],
  2023. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  2024. isCommon = result === undefined;
  2025. if (isCommon) {
  2026. result = srcValue;
  2027. }
  2028. if ((isSrcArr || result !== undefined) &&
  2029. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  2030. object[key] = result;
  2031. }
  2032. }
  2033. });
  2034. return object;
  2035. }
  2036. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  2037. var length = stackA.length,
  2038. srcValue = source[key];
  2039. while (length--) {
  2040. if (stackA[length] == srcValue) {
  2041. object[key] = stackB[length];
  2042. return;
  2043. }
  2044. }
  2045. var value = object[key],
  2046. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  2047. isCommon = result === undefined;
  2048. if (isCommon) {
  2049. result = srcValue;
  2050. if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
  2051. result = isArray(value)
  2052. ? value
  2053. : (getLength(value) ? arrayCopy(value) : []);
  2054. }
  2055. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  2056. result = isArguments(value)
  2057. ? toPlainObject(value)
  2058. : (isPlainObject(value) ? value : {});
  2059. }
  2060. else {
  2061. isCommon = false;
  2062. }
  2063. }
  2064. stackA.push(srcValue);
  2065. stackB.push(result);
  2066. if (isCommon) {
  2067. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  2068. } else if (result === result ? (result !== value) : (value === value)) {
  2069. object[key] = result;
  2070. }
  2071. }
  2072. function baseProperty(key) {
  2073. return function(object) {
  2074. return object == null ? undefined : object[key];
  2075. };
  2076. }
  2077. function basePropertyDeep(path) {
  2078. var pathKey = (path + '');
  2079. path = toPath(path);
  2080. return function(object) {
  2081. return baseGet(object, path, pathKey);
  2082. };
  2083. }
  2084. function baseSlice(array, start, end) {
  2085. var index = -1,
  2086. length = array.length;
  2087. start = start == null ? 0 : (+start || 0);
  2088. if (start < 0) {
  2089. start = -start > length ? 0 : (length + start);
  2090. }
  2091. end = (end === undefined || end > length) ? length : (+end || 0);
  2092. if (end < 0) {
  2093. end += length;
  2094. }
  2095. length = start > end ? 0 : ((end - start) >>> 0);
  2096. start >>>= 0;
  2097. var result = Array(length);
  2098. while (++index < length) {
  2099. result[index] = array[index + start];
  2100. }
  2101. return result;
  2102. }
  2103. function baseSome(collection, predicate) {
  2104. var result;
  2105. baseEach(collection, function(value, index, collection) {
  2106. result = predicate(value, index, collection);
  2107. return !result;
  2108. });
  2109. return !!result;
  2110. }
  2111. function baseValues(object, props) {
  2112. var index = -1,
  2113. length = props.length,
  2114. result = Array(length);
  2115. while (++index < length) {
  2116. result[index] = object[props[index]];
  2117. }
  2118. return result;
  2119. }
  2120. function binaryIndex(array, value, retHighest) {
  2121. var low = 0,
  2122. high = array ? array.length : low;
  2123. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  2124. while (low < high) {
  2125. var mid = (low + high) >>> 1,
  2126. computed = array[mid];
  2127. if (retHighest ? (computed <= value) : (computed < value)) {
  2128. low = mid + 1;
  2129. } else {
  2130. high = mid;
  2131. }
  2132. }
  2133. return high;
  2134. }
  2135. return binaryIndexBy(array, value, identity, retHighest);
  2136. }
  2137. function binaryIndexBy(array, value, iteratee, retHighest) {
  2138. value = iteratee(value);
  2139. var low = 0,
  2140. high = array ? array.length : 0,
  2141. valIsNaN = value !== value,
  2142. valIsUndef = value === undefined;
  2143. while (low < high) {
  2144. var mid = floor((low + high) / 2),
  2145. computed = iteratee(array[mid]),
  2146. isReflexive = computed === computed;
  2147. if (valIsNaN) {
  2148. var setLow = isReflexive || retHighest;
  2149. } else if (valIsUndef) {
  2150. setLow = isReflexive && (retHighest || computed !== undefined);
  2151. } else {
  2152. setLow = retHighest ? (computed <= value) : (computed < value);
  2153. }
  2154. if (setLow) {
  2155. low = mid + 1;
  2156. } else {
  2157. high = mid;
  2158. }
  2159. }
  2160. return nativeMin(high, MAX_ARRAY_INDEX);
  2161. }
  2162. function bindCallback(func, thisArg, argCount) {
  2163. if (typeof func != 'function') {
  2164. return identity;
  2165. }
  2166. if (thisArg === undefined) {
  2167. return func;
  2168. }
  2169. switch (argCount) {
  2170. case 1: return function(value) {
  2171. return func.call(thisArg, value);
  2172. };
  2173. case 3: return function(value, index, collection) {
  2174. return func.call(thisArg, value, index, collection);
  2175. };
  2176. case 4: return function(accumulator, value, index, collection) {
  2177. return func.call(thisArg, accumulator, value, index, collection);
  2178. };
  2179. case 5: return function(value, other, key, object, source) {
  2180. return func.call(thisArg, value, other, key, object, source);
  2181. };
  2182. }
  2183. return function() {
  2184. return func.apply(thisArg, arguments);
  2185. };
  2186. }
  2187. function bufferClone(buffer) {
  2188. return bufferSlice.call(buffer, 0);
  2189. }
  2190. if (!bufferSlice) {
  2191. bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
  2192. var byteLength = buffer.byteLength,
  2193. floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
  2194. offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
  2195. result = new ArrayBuffer(byteLength);
  2196. if (floatLength) {
  2197. var view = new Float64Array(result, 0, floatLength);
  2198. view.set(new Float64Array(buffer, 0, floatLength));
  2199. }
  2200. if (byteLength != offset) {
  2201. view = new Uint8Array(result, offset);
  2202. view.set(new Uint8Array(buffer, offset));
  2203. }
  2204. return result;
  2205. };
  2206. }
  2207. function createAssigner(assigner) {
  2208. return restParam(function(object, sources) {
  2209. var index = -1,
  2210. length = object == null ? 0 : sources.length,
  2211. customizer = length > 2 && sources[length - 2],
  2212. guard = length > 2 && sources[2],
  2213. thisArg = length > 1 && sources[length - 1];
  2214. if (typeof customizer == 'function') {
  2215. customizer = bindCallback(customizer, thisArg, 5);
  2216. length -= 2;
  2217. } else {
  2218. customizer = typeof thisArg == 'function' ? thisArg : null;
  2219. length -= (customizer ? 1 : 0);
  2220. }
  2221. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  2222. customizer = length < 3 ? null : customizer;
  2223. length = 1;
  2224. }
  2225. while (++index < length) {
  2226. var source = sources[index];
  2227. if (source) {
  2228. assigner(object, source, customizer);
  2229. }
  2230. }
  2231. return object;
  2232. });
  2233. }
  2234. function createBaseEach(eachFunc, fromRight) {
  2235. return function(collection, iteratee) {
  2236. var length = collection ? getLength(collection) : 0;
  2237. if (!isLength(length)) {
  2238. return eachFunc(collection, iteratee);
  2239. }
  2240. var index = fromRight ? length : -1,
  2241. iterable = toObject(collection);
  2242. while ((fromRight ? index-- : ++index < length)) {
  2243. if (iteratee(iterable[index], index, iterable) === false) {
  2244. break;
  2245. }
  2246. }
  2247. return collection;
  2248. };
  2249. }
  2250. function createBaseFor(fromRight) {
  2251. return function(object, iteratee, keysFunc) {
  2252. var iterable = toObject(object),
  2253. props = keysFunc(object),
  2254. length = props.length,
  2255. index = fromRight ? length : -1;
  2256. while ((fromRight ? index-- : ++index < length)) {
  2257. var key = props[index];
  2258. if (iteratee(iterable[key], key, iterable) === false) {
  2259. break;
  2260. }
  2261. }
  2262. return object;
  2263. };
  2264. }
  2265. function createFindIndex(fromRight) {
  2266. return function(array, predicate, thisArg) {
  2267. if (!(array && array.length)) {
  2268. return -1;
  2269. }
  2270. predicate = getCallback(predicate, thisArg, 3);
  2271. return baseFindIndex(array, predicate, fromRight);
  2272. };
  2273. }
  2274. function createForEach(arrayFunc, eachFunc) {
  2275. return function(collection, iteratee, thisArg) {
  2276. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  2277. ? arrayFunc(collection, iteratee)
  2278. : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
  2279. };
  2280. }
  2281. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2282. var index = -1,
  2283. arrLength = array.length,
  2284. othLength = other.length,
  2285. result = true;
  2286. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  2287. return false;
  2288. }
  2289. while (result && ++index < arrLength) {
  2290. var arrValue = array[index],
  2291. othValue = other[index];
  2292. result = undefined;
  2293. if (customizer) {
  2294. result = isLoose
  2295. ? customizer(othValue, arrValue, index)
  2296. : customizer(arrValue, othValue, index);
  2297. }
  2298. if (result === undefined) {
  2299. if (isLoose) {
  2300. var othIndex = othLength;
  2301. while (othIndex--) {
  2302. othValue = other[othIndex];
  2303. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  2304. if (result) {
  2305. break;
  2306. }
  2307. }
  2308. } else {
  2309. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  2310. }
  2311. }
  2312. }
  2313. return !!result;
  2314. }
  2315. function equalByTag(object, other, tag) {
  2316. switch (tag) {
  2317. case boolTag:
  2318. case dateTag:
  2319. return +object == +other;
  2320. case errorTag:
  2321. return object.name == other.name && object.message == other.message;
  2322. case numberTag:
  2323. return (object != +object)
  2324. ? other != +other
  2325. : (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
  2326. case regexpTag:
  2327. case stringTag:
  2328. return object == (other + '');
  2329. }
  2330. return false;
  2331. }
  2332. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2333. var objProps = keys(object),
  2334. objLength = objProps.length,
  2335. othProps = keys(other),
  2336. othLength = othProps.length;
  2337. if (objLength != othLength && !isLoose) {
  2338. return false;
  2339. }
  2340. var skipCtor = isLoose,
  2341. index = -1;
  2342. while (++index < objLength) {
  2343. var key = objProps[index],
  2344. result = isLoose ? key in other : hasOwnProperty.call(other, key);
  2345. if (result) {
  2346. var objValue = object[key],
  2347. othValue = other[key];
  2348. result = undefined;
  2349. if (customizer) {
  2350. result = isLoose
  2351. ? customizer(othValue, objValue, key)
  2352. : customizer(objValue, othValue, key);
  2353. }
  2354. if (result === undefined) {
  2355. result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
  2356. }
  2357. }
  2358. if (!result) {
  2359. return false;
  2360. }
  2361. skipCtor || (skipCtor = key == 'constructor');
  2362. }
  2363. if (!skipCtor) {
  2364. var objCtor = object.constructor,
  2365. othCtor = other.constructor;
  2366. if (objCtor != othCtor &&
  2367. ('constructor' in object && 'constructor' in other) &&
  2368. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  2369. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  2370. return false;
  2371. }
  2372. }
  2373. return true;
  2374. }
  2375. function getCallback(func, thisArg, argCount) {
  2376. var result = lodash.callback || callback;
  2377. result = result === callback ? baseCallback : result;
  2378. return argCount ? result(func, thisArg, argCount) : result;
  2379. }
  2380. function getIndexOf(collection, target, fromIndex) {
  2381. var result = lodash.indexOf || indexOf;
  2382. result = result === indexOf ? baseIndexOf : result;
  2383. return collection ? result(collection, target, fromIndex) : result;
  2384. }
  2385. var getLength = baseProperty('length');
  2386. var getSymbols = !getOwnPropertySymbols ? constant([]) : function(object) {
  2387. return getOwnPropertySymbols(toObject(object));
  2388. };
  2389. function initCloneArray(array) {
  2390. var length = array.length,
  2391. result = new array.constructor(length);
  2392. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  2393. result.index = array.index;
  2394. result.input = array.input;
  2395. }
  2396. return result;
  2397. }
  2398. function initCloneObject(object) {
  2399. var Ctor = object.constructor;
  2400. if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
  2401. Ctor = Object;
  2402. }
  2403. return new Ctor;
  2404. }
  2405. function initCloneByTag(object, tag, isDeep) {
  2406. var Ctor = object.constructor;
  2407. switch (tag) {
  2408. case arrayBufferTag:
  2409. return bufferClone(object);
  2410. case boolTag:
  2411. case dateTag:
  2412. return new Ctor(+object);
  2413. case float32Tag: case float64Tag:
  2414. case int8Tag: case int16Tag: case int32Tag:
  2415. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  2416. var buffer = object.buffer;
  2417. return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
  2418. case numberTag:
  2419. case stringTag:
  2420. return new Ctor(object);
  2421. case regexpTag:
  2422. var result = new Ctor(object.source, reFlags.exec(object));
  2423. result.lastIndex = object.lastIndex;
  2424. }
  2425. return result;
  2426. }
  2427. function isIndex(value, length) {
  2428. value = +value;
  2429. length = length == null ? MAX_SAFE_INTEGER : length;
  2430. return value > -1 && value % 1 == 0 && value < length;
  2431. }
  2432. function isIterateeCall(value, index, object) {
  2433. if (!isObject(object)) {
  2434. return false;
  2435. }
  2436. var type = typeof index;
  2437. if (type == 'number') {
  2438. var length = getLength(object),
  2439. prereq = isLength(length) && isIndex(index, length);
  2440. } else {
  2441. prereq = type == 'string' && index in object;
  2442. }
  2443. if (prereq) {
  2444. var other = object[index];
  2445. return value === value ? (value === other) : (other !== other);
  2446. }
  2447. return false;
  2448. }
  2449. function isKey(value, object) {
  2450. var type = typeof value;
  2451. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  2452. return true;
  2453. }
  2454. if (isArray(value)) {
  2455. return false;
  2456. }
  2457. var result = !reIsDeepProp.test(value);
  2458. return result || (object != null && value in toObject(object));
  2459. }
  2460. function isLength(value) {
  2461. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  2462. }
  2463. function isStrictComparable(value) {
  2464. return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
  2465. }
  2466. function shimIsPlainObject(value) {
  2467. var Ctor,
  2468. support = lodash.support;
  2469. if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
  2470. (!hasOwnProperty.call(value, 'constructor') &&
  2471. (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  2472. return false;
  2473. }
  2474. var result;
  2475. baseForIn(value, function(subValue, key) {
  2476. result = key;
  2477. });
  2478. return result === undefined || hasOwnProperty.call(value, result);
  2479. }
  2480. function shimKeys(object) {
  2481. var props = keysIn(object),
  2482. propsLength = props.length,
  2483. length = propsLength && object.length,
  2484. support = lodash.support;
  2485. var allowIndexes = length && isLength(length) &&
  2486. (isArray(object) || (support.nonEnumArgs && isArguments(object)));
  2487. var index = -1,
  2488. result = [];
  2489. while (++index < propsLength) {
  2490. var key = props[index];
  2491. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  2492. result.push(key);
  2493. }
  2494. }
  2495. return result;
  2496. }
  2497. function toObject(value) {
  2498. return isObject(value) ? value : Object(value);
  2499. }
  2500. function toPath(value) {
  2501. if (isArray(value)) {
  2502. return value;
  2503. }
  2504. var result = [];
  2505. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  2506. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  2507. });
  2508. return result;
  2509. }
  2510. var findLastIndex = createFindIndex(true);
  2511. function indexOf(array, value, fromIndex) {
  2512. var length = array ? array.length : 0;
  2513. if (!length) {
  2514. return -1;
  2515. }
  2516. if (typeof fromIndex == 'number') {
  2517. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
  2518. } else if (fromIndex) {
  2519. var index = binaryIndex(array, value),
  2520. other = array[index];
  2521. if (value === value ? (value === other) : (other !== other)) {
  2522. return index;
  2523. }
  2524. return -1;
  2525. }
  2526. return baseIndexOf(array, value, fromIndex || 0);
  2527. }
  2528. function last(array) {
  2529. var length = array ? array.length : 0;
  2530. return length ? array[length - 1] : undefined;
  2531. }
  2532. function slice(array, start, end) {
  2533. var length = array ? array.length : 0;
  2534. if (!length) {
  2535. return [];
  2536. }
  2537. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  2538. start = 0;
  2539. end = length;
  2540. }
  2541. return baseSlice(array, start, end);
  2542. }
  2543. function unzip(array) {
  2544. var index = -1,
  2545. length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
  2546. result = Array(length);
  2547. while (++index < length) {
  2548. result[index] = arrayMap(array, baseProperty(index));
  2549. }
  2550. return result;
  2551. }
  2552. var zip = restParam(unzip);
  2553. var forEach = createForEach(arrayEach, baseEach);
  2554. function includes(collection, target, fromIndex, guard) {
  2555. var length = collection ? getLength(collection) : 0;
  2556. if (!isLength(length)) {
  2557. collection = values(collection);
  2558. length = collection.length;
  2559. }
  2560. if (!length) {
  2561. return false;
  2562. }
  2563. if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
  2564. fromIndex = 0;
  2565. } else {
  2566. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
  2567. }
  2568. return (typeof collection == 'string' || !isArray(collection) && isString(collection))
  2569. ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
  2570. : (getIndexOf(collection, target, fromIndex) > -1);
  2571. }
  2572. function reject(collection, predicate, thisArg) {
  2573. var func = isArray(collection) ? arrayFilter : baseFilter;
  2574. predicate = getCallback(predicate, thisArg, 3);
  2575. return func(collection, function(value, index, collection) {
  2576. return !predicate(value, index, collection);
  2577. });
  2578. }
  2579. function some(collection, predicate, thisArg) {
  2580. var func = isArray(collection) ? arraySome : baseSome;
  2581. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  2582. predicate = null;
  2583. }
  2584. if (typeof predicate != 'function' || thisArg !== undefined) {
  2585. predicate = getCallback(predicate, thisArg, 3);
  2586. }
  2587. return func(collection, predicate);
  2588. }
  2589. function restParam(func, start) {
  2590. if (typeof func != 'function') {
  2591. throw new TypeError(FUNC_ERROR_TEXT);
  2592. }
  2593. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  2594. return function() {
  2595. var args = arguments,
  2596. index = -1,
  2597. length = nativeMax(args.length - start, 0),
  2598. rest = Array(length);
  2599. while (++index < length) {
  2600. rest[index] = args[start + index];
  2601. }
  2602. switch (start) {
  2603. case 0: return func.call(this, rest);
  2604. case 1: return func.call(this, args[0], rest);
  2605. case 2: return func.call(this, args[0], args[1], rest);
  2606. }
  2607. var otherArgs = Array(start + 1);
  2608. index = -1;
  2609. while (++index < start) {
  2610. otherArgs[index] = args[index];
  2611. }
  2612. otherArgs[start] = rest;
  2613. return func.apply(this, otherArgs);
  2614. };
  2615. }
  2616. function clone(value, isDeep, customizer, thisArg) {
  2617. if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
  2618. isDeep = false;
  2619. }
  2620. else if (typeof isDeep == 'function') {
  2621. thisArg = customizer;
  2622. customizer = isDeep;
  2623. isDeep = false;
  2624. }
  2625. customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
  2626. return baseClone(value, isDeep, customizer);
  2627. }
  2628. function isArguments(value) {
  2629. var length = isObjectLike(value) ? value.length : undefined;
  2630. return isLength(length) && objToString.call(value) == argsTag;
  2631. }
  2632. var isArray = nativeIsArray || function(value) {
  2633. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  2634. };
  2635. function isEmpty(value) {
  2636. if (value == null) {
  2637. return true;
  2638. }
  2639. var length = getLength(value);
  2640. if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
  2641. (isObjectLike(value) && isFunction(value.splice)))) {
  2642. return !length;
  2643. }
  2644. return !keys(value).length;
  2645. }
  2646. var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
  2647. return objToString.call(value) == funcTag;
  2648. };
  2649. function isObject(value) {
  2650. var type = typeof value;
  2651. return type == 'function' || (!!value && type == 'object');
  2652. }
  2653. function isNative(value) {
  2654. if (value == null) {
  2655. return false;
  2656. }
  2657. if (objToString.call(value) == funcTag) {
  2658. return reIsNative.test(fnToString.call(value));
  2659. }
  2660. return isObjectLike(value) && reIsHostCtor.test(value);
  2661. }
  2662. function isNumber(value) {
  2663. return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
  2664. }
  2665. var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
  2666. if (!(value && objToString.call(value) == objectTag)) {
  2667. return false;
  2668. }
  2669. var valueOf = value.valueOf,
  2670. objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
  2671. return objProto
  2672. ? (value == objProto || getPrototypeOf(value) == objProto)
  2673. : shimIsPlainObject(value);
  2674. };
  2675. function isString(value) {
  2676. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  2677. }
  2678. function isTypedArray(value) {
  2679. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  2680. }
  2681. function toPlainObject(value) {
  2682. return baseCopy(value, keysIn(value));
  2683. }
  2684. var assign = createAssigner(function(object, source, customizer) {
  2685. return customizer
  2686. ? assignWith(object, source, customizer)
  2687. : baseAssign(object, source);
  2688. });
  2689. function has(object, path) {
  2690. if (object == null) {
  2691. return false;
  2692. }
  2693. var result = hasOwnProperty.call(object, path);
  2694. if (!result && !isKey(path)) {
  2695. path = toPath(path);
  2696. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  2697. path = last(path);
  2698. result = object != null && hasOwnProperty.call(object, path);
  2699. }
  2700. return result;
  2701. }
  2702. var keys = !nativeKeys ? shimKeys : function(object) {
  2703. if (object) {
  2704. var Ctor = object.constructor,
  2705. length = object.length;
  2706. }
  2707. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  2708. (typeof object != 'function' && isLength(length))) {
  2709. return shimKeys(object);
  2710. }
  2711. return isObject(object) ? nativeKeys(object) : [];
  2712. };
  2713. function keysIn(object) {
  2714. if (object == null) {
  2715. return [];
  2716. }
  2717. if (!isObject(object)) {
  2718. object = Object(object);
  2719. }
  2720. var length = object.length;
  2721. length = (length && isLength(length) &&
  2722. (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
  2723. var Ctor = object.constructor,
  2724. index = -1,
  2725. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  2726. result = Array(length),
  2727. skipIndexes = length > 0;
  2728. while (++index < length) {
  2729. result[index] = (index + '');
  2730. }
  2731. for (var key in object) {
  2732. if (!(skipIndexes && isIndex(key, length)) &&
  2733. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  2734. result.push(key);
  2735. }
  2736. }
  2737. return result;
  2738. }
  2739. var merge = createAssigner(baseMerge);
  2740. function values(object) {
  2741. return baseValues(object, keys(object));
  2742. }
  2743. function escapeRegExp(string) {
  2744. string = baseToString(string);
  2745. return (string && reHasRegExpChars.test(string))
  2746. ? string.replace(reRegExpChars, '\\$&')
  2747. : string;
  2748. }
  2749. function callback(func, thisArg, guard) {
  2750. if (guard && isIterateeCall(func, thisArg, guard)) {
  2751. thisArg = null;
  2752. }
  2753. return baseCallback(func, thisArg);
  2754. }
  2755. function constant(value) {
  2756. return function() {
  2757. return value;
  2758. };
  2759. }
  2760. function identity(value) {
  2761. return value;
  2762. }
  2763. function property(path) {
  2764. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  2765. }
  2766. lodash.assign = assign;
  2767. lodash.callback = callback;
  2768. lodash.constant = constant;
  2769. lodash.forEach = forEach;
  2770. lodash.keys = keys;
  2771. lodash.keysIn = keysIn;
  2772. lodash.merge = merge;
  2773. lodash.property = property;
  2774. lodash.reject = reject;
  2775. lodash.restParam = restParam;
  2776. lodash.slice = slice;
  2777. lodash.toPlainObject = toPlainObject;
  2778. lodash.unzip = unzip;
  2779. lodash.values = values;
  2780. lodash.zip = zip;
  2781. lodash.each = forEach;
  2782. lodash.extend = assign;
  2783. lodash.iteratee = callback;
  2784. lodash.clone = clone;
  2785. lodash.escapeRegExp = escapeRegExp;
  2786. lodash.findLastIndex = findLastIndex;
  2787. lodash.has = has;
  2788. lodash.identity = identity;
  2789. lodash.includes = includes;
  2790. lodash.indexOf = indexOf;
  2791. lodash.isArguments = isArguments;
  2792. lodash.isArray = isArray;
  2793. lodash.isEmpty = isEmpty;
  2794. lodash.isFunction = isFunction;
  2795. lodash.isNative = isNative;
  2796. lodash.isNumber = isNumber;
  2797. lodash.isObject = isObject;
  2798. lodash.isPlainObject = isPlainObject;
  2799. lodash.isString = isString;
  2800. lodash.isTypedArray = isTypedArray;
  2801. lodash.last = last;
  2802. lodash.some = some;
  2803. lodash.any = some;
  2804. lodash.contains = includes;
  2805. lodash.include = includes;
  2806. lodash.VERSION = VERSION;
  2807. if (freeExports && freeModule) {
  2808. if (moduleExports) {
  2809. (freeModule.exports = lodash)._ = lodash;
  2810. }
  2811. else {
  2812. freeExports._ = lodash;
  2813. }
  2814. }
  2815. else {
  2816. root._ = lodash;
  2817. }
  2818. }.call(this));
  2819. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2820. },{}],"/node_modules/jshint/src/jshint.js":[function(_dereq_,module,exports){
  2821. var _ = _dereq_("../lodash");
  2822. var events = _dereq_("events");
  2823. var vars = _dereq_("./vars.js");
  2824. var messages = _dereq_("./messages.js");
  2825. var Lexer = _dereq_("./lex.js").Lexer;
  2826. var reg = _dereq_("./reg.js");
  2827. var state = _dereq_("./state.js").state;
  2828. var style = _dereq_("./style.js");
  2829. var options = _dereq_("./options.js");
  2830. var scopeManager = _dereq_("./scope-manager.js");
  2831. var JSHINT = (function() {
  2832. "use strict";
  2833. var api, // Extension API
  2834. bang = {
  2835. "<" : true,
  2836. "<=" : true,
  2837. "==" : true,
  2838. "===": true,
  2839. "!==": true,
  2840. "!=" : true,
  2841. ">" : true,
  2842. ">=" : true,
  2843. "+" : true,
  2844. "-" : true,
  2845. "*" : true,
  2846. "/" : true,
  2847. "%" : true
  2848. },
  2849. declared, // Globals that were declared using /*global ... */ syntax.
  2850. functionicity = [
  2851. "closure", "exception", "global", "label",
  2852. "outer", "unused", "var"
  2853. ],
  2854. functions, // All of the functions
  2855. inblock,
  2856. indent,
  2857. lookahead,
  2858. lex,
  2859. member,
  2860. membersOnly,
  2861. predefined, // Global variables defined by option
  2862. stack,
  2863. urls,
  2864. extraModules = [],
  2865. emitter = new events.EventEmitter();
  2866. function checkOption(name, t) {
  2867. name = name.trim();
  2868. if (/^[+-]W\d{3}$/g.test(name)) {
  2869. return true;
  2870. }
  2871. if (options.validNames.indexOf(name) === -1) {
  2872. if (t.type !== "jslint" && !_.has(options.removed, name)) {
  2873. error("E001", t, name);
  2874. return false;
  2875. }
  2876. }
  2877. return true;
  2878. }
  2879. function isString(obj) {
  2880. return Object.prototype.toString.call(obj) === "[object String]";
  2881. }
  2882. function isIdentifier(tkn, value) {
  2883. if (!tkn)
  2884. return false;
  2885. if (!tkn.identifier || tkn.value !== value)
  2886. return false;
  2887. return true;
  2888. }
  2889. function isReserved(token) {
  2890. if (!token.reserved) {
  2891. return false;
  2892. }
  2893. var meta = token.meta;
  2894. if (meta && meta.isFutureReservedWord && state.inES5()) {
  2895. if (!meta.es5) {
  2896. return false;
  2897. }
  2898. if (meta.strictOnly) {
  2899. if (!state.option.strict && !state.isStrict()) {
  2900. return false;
  2901. }
  2902. }
  2903. if (token.isProperty) {
  2904. return false;
  2905. }
  2906. }
  2907. return true;
  2908. }
  2909. function supplant(str, data) {
  2910. return str.replace(/\{([^{}]*)\}/g, function(a, b) {
  2911. var r = data[b];
  2912. return typeof r === "string" || typeof r === "number" ? r : a;
  2913. });
  2914. }
  2915. function combine(dest, src) {
  2916. Object.keys(src).forEach(function(name) {
  2917. if (_.has(JSHINT.blacklist, name)) return;
  2918. dest[name] = src[name];
  2919. });
  2920. }
  2921. function processenforceall() {
  2922. if (state.option.enforceall) {
  2923. for (var enforceopt in options.bool.enforcing) {
  2924. if (state.option[enforceopt] === undefined &&
  2925. !options.noenforceall[enforceopt]) {
  2926. state.option[enforceopt] = true;
  2927. }
  2928. }
  2929. for (var relaxopt in options.bool.relaxing) {
  2930. if (state.option[relaxopt] === undefined) {
  2931. state.option[relaxopt] = false;
  2932. }
  2933. }
  2934. }
  2935. }
  2936. function assume() {
  2937. processenforceall();
  2938. if (!state.option.esversion && !state.option.moz) {
  2939. if (state.option.es3) {
  2940. state.option.esversion = 3;
  2941. } else if (state.option.esnext) {
  2942. state.option.esversion = 6;
  2943. } else {
  2944. state.option.esversion = 5;
  2945. }
  2946. }
  2947. if (state.inES5()) {
  2948. combine(predefined, vars.ecmaIdentifiers[5]);
  2949. }
  2950. if (state.inES6()) {
  2951. combine(predefined, vars.ecmaIdentifiers[6]);
  2952. }
  2953. if (state.option.module) {
  2954. if (state.option.strict === true) {
  2955. state.option.strict = "global";
  2956. }
  2957. if (!state.inES6()) {
  2958. warning("W134", state.tokens.next, "module", 6);
  2959. }
  2960. }
  2961. if (state.option.couch) {
  2962. combine(predefined, vars.couch);
  2963. }
  2964. if (state.option.qunit) {
  2965. combine(predefined, vars.qunit);
  2966. }
  2967. if (state.option.rhino) {
  2968. combine(predefined, vars.rhino);
  2969. }
  2970. if (state.option.shelljs) {
  2971. combine(predefined, vars.shelljs);
  2972. combine(predefined, vars.node);
  2973. }
  2974. if (state.option.typed) {
  2975. combine(predefined, vars.typed);
  2976. }
  2977. if (state.option.phantom) {
  2978. combine(predefined, vars.phantom);
  2979. if (state.option.strict === true) {
  2980. state.option.strict = "global";
  2981. }
  2982. }
  2983. if (state.option.prototypejs) {
  2984. combine(predefined, vars.prototypejs);
  2985. }
  2986. if (state.option.node) {
  2987. combine(predefined, vars.node);
  2988. combine(predefined, vars.typed);
  2989. if (state.option.strict === true) {
  2990. state.option.strict = "global";
  2991. }
  2992. }
  2993. if (state.option.devel) {
  2994. combine(predefined, vars.devel);
  2995. }
  2996. if (state.option.dojo) {
  2997. combine(predefined, vars.dojo);
  2998. }
  2999. if (state.option.browser) {
  3000. combine(predefined, vars.browser);
  3001. combine(predefined, vars.typed);
  3002. }
  3003. if (state.option.browserify) {
  3004. combine(predefined, vars.browser);
  3005. combine(predefined, vars.typed);
  3006. combine(predefined, vars.browserify);
  3007. if (state.option.strict === true) {
  3008. state.option.strict = "global";
  3009. }
  3010. }
  3011. if (state.option.nonstandard) {
  3012. combine(predefined, vars.nonstandard);
  3013. }
  3014. if (state.option.jasmine) {
  3015. combine(predefined, vars.jasmine);
  3016. }
  3017. if (state.option.jquery) {
  3018. combine(predefined, vars.jquery);
  3019. }
  3020. if (state.option.mootools) {
  3021. combine(predefined, vars.mootools);
  3022. }
  3023. if (state.option.worker) {
  3024. combine(predefined, vars.worker);
  3025. }
  3026. if (state.option.wsh) {
  3027. combine(predefined, vars.wsh);
  3028. }
  3029. if (state.option.globalstrict && state.option.strict !== false) {
  3030. state.option.strict = "global";
  3031. }
  3032. if (state.option.yui) {
  3033. combine(predefined, vars.yui);
  3034. }
  3035. if (state.option.mocha) {
  3036. combine(predefined, vars.mocha);
  3037. }
  3038. }
  3039. function quit(code, line, chr) {
  3040. var percentage = Math.floor((line / state.lines.length) * 100);
  3041. var message = messages.errors[code].desc;
  3042. throw {
  3043. name: "JSHintError",
  3044. line: line,
  3045. character: chr,
  3046. message: message + " (" + percentage + "% scanned).",
  3047. raw: message,
  3048. code: code
  3049. };
  3050. }
  3051. function removeIgnoredMessages() {
  3052. var ignored = state.ignoredLines;
  3053. if (_.isEmpty(ignored)) return;
  3054. JSHINT.errors = _.reject(JSHINT.errors, function(err) { return ignored[err.line] });
  3055. }
  3056. function warning(code, t, a, b, c, d) {
  3057. var ch, l, w, msg;
  3058. if (/^W\d{3}$/.test(code)) {
  3059. if (state.ignored[code])
  3060. return;
  3061. msg = messages.warnings[code];
  3062. } else if (/E\d{3}/.test(code)) {
  3063. msg = messages.errors[code];
  3064. } else if (/I\d{3}/.test(code)) {
  3065. msg = messages.info[code];
  3066. }
  3067. t = t || state.tokens.next || {};
  3068. if (t.id === "(end)") { // `~
  3069. t = state.tokens.curr;
  3070. }
  3071. l = t.line || 0;
  3072. ch = t.from || 0;
  3073. w = {
  3074. id: "(error)",
  3075. raw: msg.desc,
  3076. code: msg.code,
  3077. evidence: state.lines[l - 1] || "",
  3078. line: l,
  3079. character: ch,
  3080. scope: JSHINT.scope,
  3081. a: a,
  3082. b: b,
  3083. c: c,
  3084. d: d
  3085. };
  3086. w.reason = supplant(msg.desc, w);
  3087. JSHINT.errors.push(w);
  3088. removeIgnoredMessages();
  3089. if (JSHINT.errors.length >= state.option.maxerr)
  3090. quit("E043", l, ch);
  3091. return w;
  3092. }
  3093. function warningAt(m, l, ch, a, b, c, d) {
  3094. return warning(m, {
  3095. line: l,
  3096. from: ch
  3097. }, a, b, c, d);
  3098. }
  3099. function error(m, t, a, b, c, d) {
  3100. warning(m, t, a, b, c, d);
  3101. }
  3102. function errorAt(m, l, ch, a, b, c, d) {
  3103. return error(m, {
  3104. line: l,
  3105. from: ch
  3106. }, a, b, c, d);
  3107. }
  3108. function addInternalSrc(elem, src) {
  3109. var i;
  3110. i = {
  3111. id: "(internal)",
  3112. elem: elem,
  3113. value: src
  3114. };
  3115. JSHINT.internals.push(i);
  3116. return i;
  3117. }
  3118. function doOption() {
  3119. var nt = state.tokens.next;
  3120. var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g) || [];
  3121. var predef = {};
  3122. if (nt.type === "globals") {
  3123. body.forEach(function(g, idx) {
  3124. g = g.split(":");
  3125. var key = (g[0] || "").trim();
  3126. var val = (g[1] || "").trim();
  3127. if (key === "-" || !key.length) {
  3128. if (idx > 0 && idx === body.length - 1) {
  3129. return;
  3130. }
  3131. error("E002", nt);
  3132. return;
  3133. }
  3134. if (key.charAt(0) === "-") {
  3135. key = key.slice(1);
  3136. val = false;
  3137. JSHINT.blacklist[key] = key;
  3138. delete predefined[key];
  3139. } else {
  3140. predef[key] = (val === "true");
  3141. }
  3142. });
  3143. combine(predefined, predef);
  3144. for (var key in predef) {
  3145. if (_.has(predef, key)) {
  3146. declared[key] = nt;
  3147. }
  3148. }
  3149. }
  3150. if (nt.type === "exported") {
  3151. body.forEach(function(e, idx) {
  3152. if (!e.length) {
  3153. if (idx > 0 && idx === body.length - 1) {
  3154. return;
  3155. }
  3156. error("E002", nt);
  3157. return;
  3158. }
  3159. state.funct["(scope)"].addExported(e);
  3160. });
  3161. }
  3162. if (nt.type === "members") {
  3163. membersOnly = membersOnly || {};
  3164. body.forEach(function(m) {
  3165. var ch1 = m.charAt(0);
  3166. var ch2 = m.charAt(m.length - 1);
  3167. if (ch1 === ch2 && (ch1 === "\"" || ch1 === "'")) {
  3168. m = m
  3169. .substr(1, m.length - 2)
  3170. .replace("\\\"", "\"");
  3171. }
  3172. membersOnly[m] = false;
  3173. });
  3174. }
  3175. var numvals = [
  3176. "maxstatements",
  3177. "maxparams",
  3178. "maxdepth",
  3179. "maxcomplexity",
  3180. "maxerr",
  3181. "maxlen",
  3182. "indent"
  3183. ];
  3184. if (nt.type === "jshint" || nt.type === "jslint") {
  3185. body.forEach(function(g) {
  3186. g = g.split(":");
  3187. var key = (g[0] || "").trim();
  3188. var val = (g[1] || "").trim();
  3189. if (!checkOption(key, nt)) {
  3190. return;
  3191. }
  3192. if (numvals.indexOf(key) >= 0) {
  3193. if (val !== "false") {
  3194. val = +val;
  3195. if (typeof val !== "number" || !isFinite(val) || val <= 0 || Math.floor(val) !== val) {
  3196. error("E032", nt, g[1].trim());
  3197. return;
  3198. }
  3199. state.option[key] = val;
  3200. } else {
  3201. state.option[key] = key === "indent" ? 4 : false;
  3202. }
  3203. return;
  3204. }
  3205. if (key === "validthis") {
  3206. if (state.funct["(global)"])
  3207. return void error("E009");
  3208. if (val !== "true" && val !== "false")
  3209. return void error("E002", nt);
  3210. state.option.validthis = (val === "true");
  3211. return;
  3212. }
  3213. if (key === "quotmark") {
  3214. switch (val) {
  3215. case "true":
  3216. case "false":
  3217. state.option.quotmark = (val === "true");
  3218. break;
  3219. case "double":
  3220. case "single":
  3221. state.option.quotmark = val;
  3222. break;
  3223. default:
  3224. error("E002", nt);
  3225. }
  3226. return;
  3227. }
  3228. if (key === "shadow") {
  3229. switch (val) {
  3230. case "true":
  3231. state.option.shadow = true;
  3232. break;
  3233. case "outer":
  3234. state.option.shadow = "outer";
  3235. break;
  3236. case "false":
  3237. case "inner":
  3238. state.option.shadow = "inner";
  3239. break;
  3240. default:
  3241. error("E002", nt);
  3242. }
  3243. return;
  3244. }
  3245. if (key === "unused") {
  3246. switch (val) {
  3247. case "true":
  3248. state.option.unused = true;
  3249. break;
  3250. case "false":
  3251. state.option.unused = false;
  3252. break;
  3253. case "vars":
  3254. case "strict":
  3255. state.option.unused = val;
  3256. break;
  3257. default:
  3258. error("E002", nt);
  3259. }
  3260. return;
  3261. }
  3262. if (key === "latedef") {
  3263. switch (val) {
  3264. case "true":
  3265. state.option.latedef = true;
  3266. break;
  3267. case "false":
  3268. state.option.latedef = false;
  3269. break;
  3270. case "nofunc":
  3271. state.option.latedef = "nofunc";
  3272. break;
  3273. default:
  3274. error("E002", nt);
  3275. }
  3276. return;
  3277. }
  3278. if (key === "ignore") {
  3279. switch (val) {
  3280. case "line":
  3281. state.ignoredLines[nt.line] = true;
  3282. removeIgnoredMessages();
  3283. break;
  3284. default:
  3285. error("E002", nt);
  3286. }
  3287. return;
  3288. }
  3289. if (key === "strict") {
  3290. switch (val) {
  3291. case "true":
  3292. state.option.strict = true;
  3293. break;
  3294. case "false":
  3295. state.option.strict = false;
  3296. break;
  3297. case "func":
  3298. case "global":
  3299. case "implied":
  3300. state.option.strict = val;
  3301. break;
  3302. default:
  3303. error("E002", nt);
  3304. }
  3305. return;
  3306. }
  3307. if (key === "module") {
  3308. if (!hasParsedCode(state.funct)) {
  3309. error("E055", state.tokens.next, "module");
  3310. }
  3311. }
  3312. var esversions = {
  3313. es3 : 3,
  3314. es5 : 5,
  3315. esnext: 6
  3316. };
  3317. if (_.has(esversions, key)) {
  3318. switch (val) {
  3319. case "true":
  3320. state.option.moz = false;
  3321. state.option.esversion = esversions[key];
  3322. break;
  3323. case "false":
  3324. if (!state.option.moz) {
  3325. state.option.esversion = 5;
  3326. }
  3327. break;
  3328. default:
  3329. error("E002", nt);
  3330. }
  3331. return;
  3332. }
  3333. if (key === "esversion") {
  3334. switch (val) {
  3335. case "5":
  3336. if (state.inES5(true)) {
  3337. warning("I003");
  3338. }
  3339. case "3":
  3340. case "6":
  3341. state.option.moz = false;
  3342. state.option.esversion = +val;
  3343. break;
  3344. case "2015":
  3345. state.option.moz = false;
  3346. state.option.esversion = 6;
  3347. break;
  3348. default:
  3349. error("E002", nt);
  3350. }
  3351. if (!hasParsedCode(state.funct)) {
  3352. error("E055", state.tokens.next, "esversion");
  3353. }
  3354. return;
  3355. }
  3356. var match = /^([+-])(W\d{3})$/g.exec(key);
  3357. if (match) {
  3358. state.ignored[match[2]] = (match[1] === "-");
  3359. return;
  3360. }
  3361. var tn;
  3362. if (val === "true" || val === "false") {
  3363. if (nt.type === "jslint") {
  3364. tn = options.renamed[key] || key;
  3365. state.option[tn] = (val === "true");
  3366. if (options.inverted[tn] !== undefined) {
  3367. state.option[tn] = !state.option[tn];
  3368. }
  3369. } else {
  3370. state.option[key] = (val === "true");
  3371. }
  3372. if (key === "newcap") {
  3373. state.option["(explicitNewcap)"] = true;
  3374. }
  3375. return;
  3376. }
  3377. error("E002", nt);
  3378. });
  3379. assume();
  3380. }
  3381. }
  3382. function peek(p) {
  3383. var i = p || 0, j = lookahead.length, t;
  3384. if (i < j) {
  3385. return lookahead[i];
  3386. }
  3387. while (j <= i) {
  3388. t = lookahead[j];
  3389. if (!t) {
  3390. t = lookahead[j] = lex.token();
  3391. }
  3392. j += 1;
  3393. }
  3394. if (!t && state.tokens.next.id === "(end)") {
  3395. return state.tokens.next;
  3396. }
  3397. return t;
  3398. }
  3399. function peekIgnoreEOL() {
  3400. var i = 0;
  3401. var t;
  3402. do {
  3403. t = peek(i++);
  3404. } while (t.id === "(endline)");
  3405. return t;
  3406. }
  3407. function advance(id, t) {
  3408. switch (state.tokens.curr.id) {
  3409. case "(number)":
  3410. if (state.tokens.next.id === ".") {
  3411. warning("W005", state.tokens.curr);
  3412. }
  3413. break;
  3414. case "-":
  3415. if (state.tokens.next.id === "-" || state.tokens.next.id === "--") {
  3416. warning("W006");
  3417. }
  3418. break;
  3419. case "+":
  3420. if (state.tokens.next.id === "+" || state.tokens.next.id === "++") {
  3421. warning("W007");
  3422. }
  3423. break;
  3424. }
  3425. if (id && state.tokens.next.id !== id) {
  3426. if (t) {
  3427. if (state.tokens.next.id === "(end)") {
  3428. error("E019", t, t.id);
  3429. } else {
  3430. error("E020", state.tokens.next, id, t.id, t.line, state.tokens.next.value);
  3431. }
  3432. } else if (state.tokens.next.type !== "(identifier)" || state.tokens.next.value !== id) {
  3433. warning("W116", state.tokens.next, id, state.tokens.next.value);
  3434. }
  3435. }
  3436. state.tokens.prev = state.tokens.curr;
  3437. state.tokens.curr = state.tokens.next;
  3438. for (;;) {
  3439. state.tokens.next = lookahead.shift() || lex.token();
  3440. if (!state.tokens.next) { // No more tokens left, give up
  3441. quit("E041", state.tokens.curr.line);
  3442. }
  3443. if (state.tokens.next.id === "(end)" || state.tokens.next.id === "(error)") {
  3444. return;
  3445. }
  3446. if (state.tokens.next.check) {
  3447. state.tokens.next.check();
  3448. }
  3449. if (state.tokens.next.isSpecial) {
  3450. if (state.tokens.next.type === "falls through") {
  3451. state.tokens.curr.caseFallsThrough = true;
  3452. } else {
  3453. doOption();
  3454. }
  3455. } else {
  3456. if (state.tokens.next.id !== "(endline)") {
  3457. break;
  3458. }
  3459. }
  3460. }
  3461. }
  3462. function isInfix(token) {
  3463. return token.infix || (!token.identifier && !token.template && !!token.led);
  3464. }
  3465. function isEndOfExpr() {
  3466. var curr = state.tokens.curr;
  3467. var next = state.tokens.next;
  3468. if (next.id === ";" || next.id === "}" || next.id === ":") {
  3469. return true;
  3470. }
  3471. if (isInfix(next) === isInfix(curr) || (curr.id === "yield" && state.inMoz())) {
  3472. return curr.line !== startLine(next);
  3473. }
  3474. return false;
  3475. }
  3476. function isBeginOfExpr(prev) {
  3477. return !prev.left && prev.arity !== "unary";
  3478. }
  3479. function expression(rbp, initial) {
  3480. var left, isArray = false, isObject = false, isLetExpr = false;
  3481. state.nameStack.push();
  3482. if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") {
  3483. if (!state.inMoz()) {
  3484. warning("W118", state.tokens.next, "let expressions");
  3485. }
  3486. isLetExpr = true;
  3487. state.funct["(scope)"].stack();
  3488. advance("let");
  3489. advance("(");
  3490. state.tokens.prev.fud();
  3491. advance(")");
  3492. }
  3493. if (state.tokens.next.id === "(end)")
  3494. error("E006", state.tokens.curr);
  3495. var isDangerous =
  3496. state.option.asi &&
  3497. state.tokens.prev.line !== startLine(state.tokens.curr) &&
  3498. _.contains(["]", ")"], state.tokens.prev.id) &&
  3499. _.contains(["[", "("], state.tokens.curr.id);
  3500. if (isDangerous)
  3501. warning("W014", state.tokens.curr, state.tokens.curr.id);
  3502. advance();
  3503. if (initial) {
  3504. state.funct["(verb)"] = state.tokens.curr.value;
  3505. state.tokens.curr.beginsStmt = true;
  3506. }
  3507. if (initial === true && state.tokens.curr.fud) {
  3508. left = state.tokens.curr.fud();
  3509. } else {
  3510. if (state.tokens.curr.nud) {
  3511. left = state.tokens.curr.nud();
  3512. } else {
  3513. error("E030", state.tokens.curr, state.tokens.curr.id);
  3514. }
  3515. while ((rbp < state.tokens.next.lbp || state.tokens.next.type === "(template)") &&
  3516. !isEndOfExpr()) {
  3517. isArray = state.tokens.curr.value === "Array";
  3518. isObject = state.tokens.curr.value === "Object";
  3519. if (left && (left.value || (left.first && left.first.value))) {
  3520. if (left.value !== "new" ||
  3521. (left.first && left.first.value && left.first.value === ".")) {
  3522. isArray = false;
  3523. if (left.value !== state.tokens.curr.value) {
  3524. isObject = false;
  3525. }
  3526. }
  3527. }
  3528. advance();
  3529. if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  3530. warning("W009", state.tokens.curr);
  3531. }
  3532. if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  3533. warning("W010", state.tokens.curr);
  3534. }
  3535. if (left && state.tokens.curr.led) {
  3536. left = state.tokens.curr.led(left);
  3537. } else {
  3538. error("E033", state.tokens.curr, state.tokens.curr.id);
  3539. }
  3540. }
  3541. }
  3542. if (isLetExpr) {
  3543. state.funct["(scope)"].unstack();
  3544. }
  3545. state.nameStack.pop();
  3546. return left;
  3547. }
  3548. function startLine(token) {
  3549. return token.startLine || token.line;
  3550. }
  3551. function nobreaknonadjacent(left, right) {
  3552. left = left || state.tokens.curr;
  3553. right = right || state.tokens.next;
  3554. if (!state.option.laxbreak && left.line !== startLine(right)) {
  3555. warning("W014", right, right.value);
  3556. }
  3557. }
  3558. function nolinebreak(t) {
  3559. t = t || state.tokens.curr;
  3560. if (t.line !== startLine(state.tokens.next)) {
  3561. warning("E022", t, t.value);
  3562. }
  3563. }
  3564. function nobreakcomma(left, right) {
  3565. if (left.line !== startLine(right)) {
  3566. if (!state.option.laxcomma) {
  3567. if (comma.first) {
  3568. warning("I001");
  3569. comma.first = false;
  3570. }
  3571. warning("W014", left, right.value);
  3572. }
  3573. }
  3574. }
  3575. function comma(opts) {
  3576. opts = opts || {};
  3577. if (!opts.peek) {
  3578. nobreakcomma(state.tokens.curr, state.tokens.next);
  3579. advance(",");
  3580. } else {
  3581. nobreakcomma(state.tokens.prev, state.tokens.curr);
  3582. }
  3583. if (state.tokens.next.identifier && !(opts.property && state.inES5())) {
  3584. switch (state.tokens.next.value) {
  3585. case "break":
  3586. case "case":
  3587. case "catch":
  3588. case "continue":
  3589. case "default":
  3590. case "do":
  3591. case "else":
  3592. case "finally":
  3593. case "for":
  3594. case "if":
  3595. case "in":
  3596. case "instanceof":
  3597. case "return":
  3598. case "switch":
  3599. case "throw":
  3600. case "try":
  3601. case "var":
  3602. case "let":
  3603. case "while":
  3604. case "with":
  3605. error("E024", state.tokens.next, state.tokens.next.value);
  3606. return false;
  3607. }
  3608. }
  3609. if (state.tokens.next.type === "(punctuator)") {
  3610. switch (state.tokens.next.value) {
  3611. case "}":
  3612. case "]":
  3613. case ",":
  3614. if (opts.allowTrailing) {
  3615. return true;
  3616. }
  3617. case ")":
  3618. error("E024", state.tokens.next, state.tokens.next.value);
  3619. return false;
  3620. }
  3621. }
  3622. return true;
  3623. }
  3624. function symbol(s, p) {
  3625. var x = state.syntax[s];
  3626. if (!x || typeof x !== "object") {
  3627. state.syntax[s] = x = {
  3628. id: s,
  3629. lbp: p,
  3630. value: s
  3631. };
  3632. }
  3633. return x;
  3634. }
  3635. function delim(s) {
  3636. var x = symbol(s, 0);
  3637. x.delim = true;
  3638. return x;
  3639. }
  3640. function stmt(s, f) {
  3641. var x = delim(s);
  3642. x.identifier = x.reserved = true;
  3643. x.fud = f;
  3644. return x;
  3645. }
  3646. function blockstmt(s, f) {
  3647. var x = stmt(s, f);
  3648. x.block = true;
  3649. return x;
  3650. }
  3651. function reserveName(x) {
  3652. var c = x.id.charAt(0);
  3653. if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) {
  3654. x.identifier = x.reserved = true;
  3655. }
  3656. return x;
  3657. }
  3658. function prefix(s, f) {
  3659. var x = symbol(s, 150);
  3660. reserveName(x);
  3661. x.nud = (typeof f === "function") ? f : function() {
  3662. this.arity = "unary";
  3663. this.right = expression(150);
  3664. if (this.id === "++" || this.id === "--") {
  3665. if (state.option.plusplus) {
  3666. warning("W016", this, this.id);
  3667. } else if (this.right && (!this.right.identifier || isReserved(this.right)) &&
  3668. this.right.id !== "." && this.right.id !== "[") {
  3669. warning("W017", this);
  3670. }
  3671. if (this.right && this.right.isMetaProperty) {
  3672. error("E031", this);
  3673. } else if (this.right && this.right.identifier) {
  3674. state.funct["(scope)"].block.modify(this.right.value, this);
  3675. }
  3676. }
  3677. return this;
  3678. };
  3679. return x;
  3680. }
  3681. function type(s, f) {
  3682. var x = delim(s);
  3683. x.type = s;
  3684. x.nud = f;
  3685. return x;
  3686. }
  3687. function reserve(name, func) {
  3688. var x = type(name, func);
  3689. x.identifier = true;
  3690. x.reserved = true;
  3691. return x;
  3692. }
  3693. function FutureReservedWord(name, meta) {
  3694. var x = type(name, (meta && meta.nud) || function() {
  3695. return this;
  3696. });
  3697. meta = meta || {};
  3698. meta.isFutureReservedWord = true;
  3699. x.value = name;
  3700. x.identifier = true;
  3701. x.reserved = true;
  3702. x.meta = meta;
  3703. return x;
  3704. }
  3705. function reservevar(s, v) {
  3706. return reserve(s, function() {
  3707. if (typeof v === "function") {
  3708. v(this);
  3709. }
  3710. return this;
  3711. });
  3712. }
  3713. function infix(s, f, p, w) {
  3714. var x = symbol(s, p);
  3715. reserveName(x);
  3716. x.infix = true;
  3717. x.led = function(left) {
  3718. if (!w) {
  3719. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3720. }
  3721. if ((s === "in" || s === "instanceof") && left.id === "!") {
  3722. warning("W018", left, "!");
  3723. }
  3724. if (typeof f === "function") {
  3725. return f(left, this);
  3726. } else {
  3727. this.left = left;
  3728. this.right = expression(p);
  3729. return this;
  3730. }
  3731. };
  3732. return x;
  3733. }
  3734. function application(s) {
  3735. var x = symbol(s, 42);
  3736. x.led = function(left) {
  3737. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3738. this.left = left;
  3739. this.right = doFunction({ type: "arrow", loneArg: left });
  3740. return this;
  3741. };
  3742. return x;
  3743. }
  3744. function relation(s, f) {
  3745. var x = symbol(s, 100);
  3746. x.led = function(left) {
  3747. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3748. this.left = left;
  3749. var right = this.right = expression(100);
  3750. if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) {
  3751. warning("W019", this);
  3752. } else if (f) {
  3753. f.apply(this, [left, right]);
  3754. }
  3755. if (!left || !right) {
  3756. quit("E041", state.tokens.curr.line);
  3757. }
  3758. if (left.id === "!") {
  3759. warning("W018", left, "!");
  3760. }
  3761. if (right.id === "!") {
  3762. warning("W018", right, "!");
  3763. }
  3764. return this;
  3765. };
  3766. return x;
  3767. }
  3768. function isPoorRelation(node) {
  3769. return node &&
  3770. ((node.type === "(number)" && +node.value === 0) ||
  3771. (node.type === "(string)" && node.value === "") ||
  3772. (node.type === "null" && !state.option.eqnull) ||
  3773. node.type === "true" ||
  3774. node.type === "false" ||
  3775. node.type === "undefined");
  3776. }
  3777. var typeofValues = {};
  3778. typeofValues.legacy = [
  3779. "xml",
  3780. "unknown"
  3781. ];
  3782. typeofValues.es3 = [
  3783. "undefined", "boolean", "number", "string", "function", "object",
  3784. ];
  3785. typeofValues.es3 = typeofValues.es3.concat(typeofValues.legacy);
  3786. typeofValues.es6 = typeofValues.es3.concat("symbol");
  3787. function isTypoTypeof(left, right, state) {
  3788. var values;
  3789. if (state.option.notypeof)
  3790. return false;
  3791. if (!left || !right)
  3792. return false;
  3793. values = state.inES6() ? typeofValues.es6 : typeofValues.es3;
  3794. if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)")
  3795. return !_.contains(values, left.value);
  3796. return false;
  3797. }
  3798. function isGlobalEval(left, state) {
  3799. var isGlobal = false;
  3800. if (left.type === "this" && state.funct["(context)"] === null) {
  3801. isGlobal = true;
  3802. }
  3803. else if (left.type === "(identifier)") {
  3804. if (state.option.node && left.value === "global") {
  3805. isGlobal = true;
  3806. }
  3807. else if (state.option.browser && (left.value === "window" || left.value === "document")) {
  3808. isGlobal = true;
  3809. }
  3810. }
  3811. return isGlobal;
  3812. }
  3813. function findNativePrototype(left) {
  3814. var natives = [
  3815. "Array", "ArrayBuffer", "Boolean", "Collator", "DataView", "Date",
  3816. "DateTimeFormat", "Error", "EvalError", "Float32Array", "Float64Array",
  3817. "Function", "Infinity", "Intl", "Int16Array", "Int32Array", "Int8Array",
  3818. "Iterator", "Number", "NumberFormat", "Object", "RangeError",
  3819. "ReferenceError", "RegExp", "StopIteration", "String", "SyntaxError",
  3820. "TypeError", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray",
  3821. "URIError"
  3822. ];
  3823. function walkPrototype(obj) {
  3824. if (typeof obj !== "object") return;
  3825. return obj.right === "prototype" ? obj : walkPrototype(obj.left);
  3826. }
  3827. function walkNative(obj) {
  3828. while (!obj.identifier && typeof obj.left === "object")
  3829. obj = obj.left;
  3830. if (obj.identifier && natives.indexOf(obj.value) >= 0)
  3831. return obj.value;
  3832. }
  3833. var prototype = walkPrototype(left);
  3834. if (prototype) return walkNative(prototype);
  3835. }
  3836. function checkLeftSideAssign(left, assignToken, options) {
  3837. var allowDestructuring = options && options.allowDestructuring;
  3838. assignToken = assignToken || left;
  3839. if (state.option.freeze) {
  3840. var nativeObject = findNativePrototype(left);
  3841. if (nativeObject)
  3842. warning("W121", left, nativeObject);
  3843. }
  3844. if (left.identifier && !left.isMetaProperty) {
  3845. state.funct["(scope)"].block.reassign(left.value, left);
  3846. }
  3847. if (left.id === ".") {
  3848. if (!left.left || left.left.value === "arguments" && !state.isStrict()) {
  3849. warning("E031", assignToken);
  3850. }
  3851. state.nameStack.set(state.tokens.prev);
  3852. return true;
  3853. } else if (left.id === "{" || left.id === "[") {
  3854. if (allowDestructuring && state.tokens.curr.left.destructAssign) {
  3855. state.tokens.curr.left.destructAssign.forEach(function(t) {
  3856. if (t.id) {
  3857. state.funct["(scope)"].block.modify(t.id, t.token);
  3858. }
  3859. });
  3860. } else {
  3861. if (left.id === "{" || !left.left) {
  3862. warning("E031", assignToken);
  3863. } else if (left.left.value === "arguments" && !state.isStrict()) {
  3864. warning("E031", assignToken);
  3865. }
  3866. }
  3867. if (left.id === "[") {
  3868. state.nameStack.set(left.right);
  3869. }
  3870. return true;
  3871. } else if (left.isMetaProperty) {
  3872. error("E031", assignToken);
  3873. return true;
  3874. } else if (left.identifier && !isReserved(left)) {
  3875. if (state.funct["(scope)"].labeltype(left.value) === "exception") {
  3876. warning("W022", left);
  3877. }
  3878. state.nameStack.set(left);
  3879. return true;
  3880. }
  3881. if (left === state.syntax["function"]) {
  3882. warning("W023", state.tokens.curr);
  3883. }
  3884. return false;
  3885. }
  3886. function assignop(s, f, p) {
  3887. var x = infix(s, typeof f === "function" ? f : function(left, that) {
  3888. that.left = left;
  3889. if (left && checkLeftSideAssign(left, that, { allowDestructuring: true })) {
  3890. that.right = expression(10);
  3891. return that;
  3892. }
  3893. error("E031", that);
  3894. }, p);
  3895. x.exps = true;
  3896. x.assign = true;
  3897. return x;
  3898. }
  3899. function bitwise(s, f, p) {
  3900. var x = symbol(s, p);
  3901. reserveName(x);
  3902. x.led = (typeof f === "function") ? f : function(left) {
  3903. if (state.option.bitwise) {
  3904. warning("W016", this, this.id);
  3905. }
  3906. this.left = left;
  3907. this.right = expression(p);
  3908. return this;
  3909. };
  3910. return x;
  3911. }
  3912. function bitwiseassignop(s) {
  3913. return assignop(s, function(left, that) {
  3914. if (state.option.bitwise) {
  3915. warning("W016", that, that.id);
  3916. }
  3917. if (left && checkLeftSideAssign(left, that)) {
  3918. that.right = expression(10);
  3919. return that;
  3920. }
  3921. error("E031", that);
  3922. }, 20);
  3923. }
  3924. function suffix(s) {
  3925. var x = symbol(s, 150);
  3926. x.led = function(left) {
  3927. if (state.option.plusplus) {
  3928. warning("W016", this, this.id);
  3929. } else if ((!left.identifier || isReserved(left)) && left.id !== "." && left.id !== "[") {
  3930. warning("W017", this);
  3931. }
  3932. if (left.isMetaProperty) {
  3933. error("E031", this);
  3934. } else if (left && left.identifier) {
  3935. state.funct["(scope)"].block.modify(left.value, left);
  3936. }
  3937. this.left = left;
  3938. return this;
  3939. };
  3940. return x;
  3941. }
  3942. function optionalidentifier(fnparam, prop, preserve) {
  3943. if (!state.tokens.next.identifier) {
  3944. return;
  3945. }
  3946. if (!preserve) {
  3947. advance();
  3948. }
  3949. var curr = state.tokens.curr;
  3950. var val = state.tokens.curr.value;
  3951. if (!isReserved(curr)) {
  3952. return val;
  3953. }
  3954. if (prop) {
  3955. if (state.inES5()) {
  3956. return val;
  3957. }
  3958. }
  3959. if (fnparam && val === "undefined") {
  3960. return val;
  3961. }
  3962. warning("W024", state.tokens.curr, state.tokens.curr.id);
  3963. return val;
  3964. }
  3965. function identifier(fnparam, prop) {
  3966. var i = optionalidentifier(fnparam, prop, false);
  3967. if (i) {
  3968. return i;
  3969. }
  3970. if (state.tokens.next.value === "...") {
  3971. if (!state.inES6(true)) {
  3972. warning("W119", state.tokens.next, "spread/rest operator", "6");
  3973. }
  3974. advance();
  3975. if (checkPunctuator(state.tokens.next, "...")) {
  3976. warning("E024", state.tokens.next, "...");
  3977. while (checkPunctuator(state.tokens.next, "...")) {
  3978. advance();
  3979. }
  3980. }
  3981. if (!state.tokens.next.identifier) {
  3982. warning("E024", state.tokens.curr, "...");
  3983. return;
  3984. }
  3985. return identifier(fnparam, prop);
  3986. } else {
  3987. error("E030", state.tokens.next, state.tokens.next.value);
  3988. if (state.tokens.next.id !== ";") {
  3989. advance();
  3990. }
  3991. }
  3992. }
  3993. function reachable(controlToken) {
  3994. var i = 0, t;
  3995. if (state.tokens.next.id !== ";" || controlToken.inBracelessBlock) {
  3996. return;
  3997. }
  3998. for (;;) {
  3999. do {
  4000. t = peek(i);
  4001. i += 1;
  4002. } while (t.id !== "(end)" && t.id === "(comment)");
  4003. if (t.reach) {
  4004. return;
  4005. }
  4006. if (t.id !== "(endline)") {
  4007. if (t.id === "function") {
  4008. if (state.option.latedef === true) {
  4009. warning("W026", t);
  4010. }
  4011. break;
  4012. }
  4013. warning("W027", t, t.value, controlToken.value);
  4014. break;
  4015. }
  4016. }
  4017. }
  4018. function parseFinalSemicolon() {
  4019. if (state.tokens.next.id !== ";") {
  4020. if (state.tokens.next.isUnclosed) return advance();
  4021. var sameLine = startLine(state.tokens.next) === state.tokens.curr.line &&
  4022. state.tokens.next.id !== "(end)";
  4023. var blockEnd = checkPunctuator(state.tokens.next, "}");
  4024. if (sameLine && !blockEnd) {
  4025. errorAt("E058", state.tokens.curr.line, state.tokens.curr.character);
  4026. } else if (!state.option.asi) {
  4027. if ((blockEnd && !state.option.lastsemic) || !sameLine) {
  4028. warningAt("W033", state.tokens.curr.line, state.tokens.curr.character);
  4029. }
  4030. }
  4031. } else {
  4032. advance(";");
  4033. }
  4034. }
  4035. function statement() {
  4036. var i = indent, r, t = state.tokens.next, hasOwnScope = false;
  4037. if (t.id === ";") {
  4038. advance(";");
  4039. return;
  4040. }
  4041. var res = isReserved(t);
  4042. if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") {
  4043. warning("W024", t, t.id);
  4044. res = false;
  4045. }
  4046. if (t.identifier && !res && peek().id === ":") {
  4047. advance();
  4048. advance(":");
  4049. hasOwnScope = true;
  4050. state.funct["(scope)"].stack();
  4051. state.funct["(scope)"].block.addBreakLabel(t.value, { token: state.tokens.curr });
  4052. if (!state.tokens.next.labelled && state.tokens.next.value !== "{") {
  4053. warning("W028", state.tokens.next, t.value, state.tokens.next.value);
  4054. }
  4055. state.tokens.next.label = t.value;
  4056. t = state.tokens.next;
  4057. }
  4058. if (t.id === "{") {
  4059. //
  4060. var iscase = (state.funct["(verb)"] === "case" && state.tokens.curr.value === ":");
  4061. block(true, true, false, false, iscase);
  4062. return;
  4063. }
  4064. r = expression(0, true);
  4065. if (r && !(r.identifier && r.value === "function") &&
  4066. !(r.type === "(punctuator)" && r.left &&
  4067. r.left.identifier && r.left.value === "function")) {
  4068. if (!state.isStrict() &&
  4069. state.option.strict === "global") {
  4070. warning("E007");
  4071. }
  4072. }
  4073. if (!t.block) {
  4074. if (!state.option.expr && (!r || !r.exps)) {
  4075. warning("W030", state.tokens.curr);
  4076. } else if (state.option.nonew && r && r.left && r.id === "(" && r.left.id === "new") {
  4077. warning("W031", t);
  4078. }
  4079. parseFinalSemicolon();
  4080. }
  4081. indent = i;
  4082. if (hasOwnScope) {
  4083. state.funct["(scope)"].unstack();
  4084. }
  4085. return r;
  4086. }
  4087. function statements() {
  4088. var a = [], p;
  4089. while (!state.tokens.next.reach && state.tokens.next.id !== "(end)") {
  4090. if (state.tokens.next.id === ";") {
  4091. p = peek();
  4092. if (!p || (p.id !== "(" && p.id !== "[")) {
  4093. warning("W032");
  4094. }
  4095. advance(";");
  4096. } else {
  4097. a.push(statement());
  4098. }
  4099. }
  4100. return a;
  4101. }
  4102. function directives() {
  4103. var i, p, pn;
  4104. while (state.tokens.next.id === "(string)") {
  4105. p = peek(0);
  4106. if (p.id === "(endline)") {
  4107. i = 1;
  4108. do {
  4109. pn = peek(i++);
  4110. } while (pn.id === "(endline)");
  4111. if (pn.id === ";") {
  4112. p = pn;
  4113. } else if (pn.value === "[" || pn.value === ".") {
  4114. break;
  4115. } else if (!state.option.asi || pn.value === "(") {
  4116. warning("W033", state.tokens.next);
  4117. }
  4118. } else if (p.id === "." || p.id === "[") {
  4119. break;
  4120. } else if (p.id !== ";") {
  4121. warning("W033", p);
  4122. }
  4123. advance();
  4124. var directive = state.tokens.curr.value;
  4125. if (state.directive[directive] ||
  4126. (directive === "use strict" && state.option.strict === "implied")) {
  4127. warning("W034", state.tokens.curr, directive);
  4128. }
  4129. state.directive[directive] = true;
  4130. if (p.id === ";") {
  4131. advance(";");
  4132. }
  4133. }
  4134. if (state.isStrict()) {
  4135. if (!state.option["(explicitNewcap)"]) {
  4136. state.option.newcap = true;
  4137. }
  4138. state.option.undef = true;
  4139. }
  4140. }
  4141. function block(ordinary, stmt, isfunc, isfatarrow, iscase) {
  4142. var a,
  4143. b = inblock,
  4144. old_indent = indent,
  4145. m,
  4146. t,
  4147. line,
  4148. d;
  4149. inblock = ordinary;
  4150. t = state.tokens.next;
  4151. var metrics = state.funct["(metrics)"];
  4152. metrics.nestedBlockDepth += 1;
  4153. metrics.verifyMaxNestedBlockDepthPerFunction();
  4154. if (state.tokens.next.id === "{") {
  4155. advance("{");
  4156. state.funct["(scope)"].stack();
  4157. line = state.tokens.curr.line;
  4158. if (state.tokens.next.id !== "}") {
  4159. indent += state.option.indent;
  4160. while (!ordinary && state.tokens.next.from > indent) {
  4161. indent += state.option.indent;
  4162. }
  4163. if (isfunc) {
  4164. m = {};
  4165. for (d in state.directive) {
  4166. if (_.has(state.directive, d)) {
  4167. m[d] = state.directive[d];
  4168. }
  4169. }
  4170. directives();
  4171. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  4172. if (!m["use strict"] && !state.isStrict()) {
  4173. warning("E007");
  4174. }
  4175. }
  4176. }
  4177. a = statements();
  4178. metrics.statementCount += a.length;
  4179. indent -= state.option.indent;
  4180. }
  4181. advance("}", t);
  4182. if (isfunc) {
  4183. state.funct["(scope)"].validateParams();
  4184. if (m) {
  4185. state.directive = m;
  4186. }
  4187. }
  4188. state.funct["(scope)"].unstack();
  4189. indent = old_indent;
  4190. } else if (!ordinary) {
  4191. if (isfunc) {
  4192. state.funct["(scope)"].stack();
  4193. m = {};
  4194. if (stmt && !isfatarrow && !state.inMoz()) {
  4195. error("W118", state.tokens.curr, "function closure expressions");
  4196. }
  4197. if (!stmt) {
  4198. for (d in state.directive) {
  4199. if (_.has(state.directive, d)) {
  4200. m[d] = state.directive[d];
  4201. }
  4202. }
  4203. }
  4204. expression(10);
  4205. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  4206. if (!m["use strict"] && !state.isStrict()) {
  4207. warning("E007");
  4208. }
  4209. }
  4210. state.funct["(scope)"].unstack();
  4211. } else {
  4212. error("E021", state.tokens.next, "{", state.tokens.next.value);
  4213. }
  4214. } else {
  4215. state.funct["(noblockscopedvar)"] = state.tokens.next.id !== "for";
  4216. state.funct["(scope)"].stack();
  4217. if (!stmt || state.option.curly) {
  4218. warning("W116", state.tokens.next, "{", state.tokens.next.value);
  4219. }
  4220. state.tokens.next.inBracelessBlock = true;
  4221. indent += state.option.indent;
  4222. a = [statement()];
  4223. indent -= state.option.indent;
  4224. state.funct["(scope)"].unstack();
  4225. delete state.funct["(noblockscopedvar)"];
  4226. }
  4227. switch (state.funct["(verb)"]) {
  4228. case "break":
  4229. case "continue":
  4230. case "return":
  4231. case "throw":
  4232. if (iscase) {
  4233. break;
  4234. }
  4235. default:
  4236. state.funct["(verb)"] = null;
  4237. }
  4238. inblock = b;
  4239. if (ordinary && state.option.noempty && (!a || a.length === 0)) {
  4240. warning("W035", state.tokens.prev);
  4241. }
  4242. metrics.nestedBlockDepth -= 1;
  4243. return a;
  4244. }
  4245. function countMember(m) {
  4246. if (membersOnly && typeof membersOnly[m] !== "boolean") {
  4247. warning("W036", state.tokens.curr, m);
  4248. }
  4249. if (typeof member[m] === "number") {
  4250. member[m] += 1;
  4251. } else {
  4252. member[m] = 1;
  4253. }
  4254. }
  4255. type("(number)", function() {
  4256. return this;
  4257. });
  4258. type("(string)", function() {
  4259. return this;
  4260. });
  4261. state.syntax["(identifier)"] = {
  4262. type: "(identifier)",
  4263. lbp: 0,
  4264. identifier: true,
  4265. nud: function() {
  4266. var v = this.value;
  4267. //
  4268. //
  4269. if (state.tokens.next.id === "=>") {
  4270. return this;
  4271. }
  4272. if (!state.funct["(comparray)"].check(v)) {
  4273. state.funct["(scope)"].block.use(v, state.tokens.curr);
  4274. }
  4275. return this;
  4276. },
  4277. led: function() {
  4278. error("E033", state.tokens.next, state.tokens.next.value);
  4279. }
  4280. };
  4281. var baseTemplateSyntax = {
  4282. lbp: 0,
  4283. identifier: false,
  4284. template: true,
  4285. };
  4286. state.syntax["(template)"] = _.extend({
  4287. type: "(template)",
  4288. nud: doTemplateLiteral,
  4289. led: doTemplateLiteral,
  4290. noSubst: false
  4291. }, baseTemplateSyntax);
  4292. state.syntax["(template middle)"] = _.extend({
  4293. type: "(template middle)",
  4294. middle: true,
  4295. noSubst: false
  4296. }, baseTemplateSyntax);
  4297. state.syntax["(template tail)"] = _.extend({
  4298. type: "(template tail)",
  4299. tail: true,
  4300. noSubst: false
  4301. }, baseTemplateSyntax);
  4302. state.syntax["(no subst template)"] = _.extend({
  4303. type: "(template)",
  4304. nud: doTemplateLiteral,
  4305. led: doTemplateLiteral,
  4306. noSubst: true,
  4307. tail: true // mark as tail, since it's always the last component
  4308. }, baseTemplateSyntax);
  4309. type("(regexp)", function() {
  4310. return this;
  4311. });
  4312. delim("(endline)");
  4313. delim("(begin)");
  4314. delim("(end)").reach = true;
  4315. delim("(error)").reach = true;
  4316. delim("}").reach = true;
  4317. delim(")");
  4318. delim("]");
  4319. delim("\"").reach = true;
  4320. delim("'").reach = true;
  4321. delim(";");
  4322. delim(":").reach = true;
  4323. delim("#");
  4324. reserve("else");
  4325. reserve("case").reach = true;
  4326. reserve("catch");
  4327. reserve("default").reach = true;
  4328. reserve("finally");
  4329. reservevar("arguments", function(x) {
  4330. if (state.isStrict() && state.funct["(global)"]) {
  4331. warning("E008", x);
  4332. }
  4333. });
  4334. reservevar("eval");
  4335. reservevar("false");
  4336. reservevar("Infinity");
  4337. reservevar("null");
  4338. reservevar("this", function(x) {
  4339. if (state.isStrict() && !isMethod() &&
  4340. !state.option.validthis && ((state.funct["(statement)"] &&
  4341. state.funct["(name)"].charAt(0) > "Z") || state.funct["(global)"])) {
  4342. warning("W040", x);
  4343. }
  4344. });
  4345. reservevar("true");
  4346. reservevar("undefined");
  4347. assignop("=", "assign", 20);
  4348. assignop("+=", "assignadd", 20);
  4349. assignop("-=", "assignsub", 20);
  4350. assignop("*=", "assignmult", 20);
  4351. assignop("/=", "assigndiv", 20).nud = function() {
  4352. error("E014");
  4353. };
  4354. assignop("%=", "assignmod", 20);
  4355. bitwiseassignop("&=");
  4356. bitwiseassignop("|=");
  4357. bitwiseassignop("^=");
  4358. bitwiseassignop("<<=");
  4359. bitwiseassignop(">>=");
  4360. bitwiseassignop(">>>=");
  4361. infix(",", function(left, that) {
  4362. var expr;
  4363. that.exprs = [left];
  4364. if (state.option.nocomma) {
  4365. warning("W127");
  4366. }
  4367. if (!comma({ peek: true })) {
  4368. return that;
  4369. }
  4370. while (true) {
  4371. if (!(expr = expression(10))) {
  4372. break;
  4373. }
  4374. that.exprs.push(expr);
  4375. if (state.tokens.next.value !== "," || !comma()) {
  4376. break;
  4377. }
  4378. }
  4379. return that;
  4380. }, 10, true);
  4381. infix("?", function(left, that) {
  4382. increaseComplexityCount();
  4383. that.left = left;
  4384. that.right = expression(10);
  4385. advance(":");
  4386. that["else"] = expression(10);
  4387. return that;
  4388. }, 30);
  4389. var orPrecendence = 40;
  4390. infix("||", function(left, that) {
  4391. increaseComplexityCount();
  4392. that.left = left;
  4393. that.right = expression(orPrecendence);
  4394. return that;
  4395. }, orPrecendence);
  4396. infix("&&", "and", 50);
  4397. bitwise("|", "bitor", 70);
  4398. bitwise("^", "bitxor", 80);
  4399. bitwise("&", "bitand", 90);
  4400. relation("==", function(left, right) {
  4401. var eqnull = state.option.eqnull &&
  4402. ((left && left.value) === "null" || (right && right.value) === "null");
  4403. switch (true) {
  4404. case !eqnull && state.option.eqeqeq:
  4405. this.from = this.character;
  4406. warning("W116", this, "===", "==");
  4407. break;
  4408. case isPoorRelation(left):
  4409. warning("W041", this, "===", left.value);
  4410. break;
  4411. case isPoorRelation(right):
  4412. warning("W041", this, "===", right.value);
  4413. break;
  4414. case isTypoTypeof(right, left, state):
  4415. warning("W122", this, right.value);
  4416. break;
  4417. case isTypoTypeof(left, right, state):
  4418. warning("W122", this, left.value);
  4419. break;
  4420. }
  4421. return this;
  4422. });
  4423. relation("===", function(left, right) {
  4424. if (isTypoTypeof(right, left, state)) {
  4425. warning("W122", this, right.value);
  4426. } else if (isTypoTypeof(left, right, state)) {
  4427. warning("W122", this, left.value);
  4428. }
  4429. return this;
  4430. });
  4431. relation("!=", function(left, right) {
  4432. var eqnull = state.option.eqnull &&
  4433. ((left && left.value) === "null" || (right && right.value) === "null");
  4434. if (!eqnull && state.option.eqeqeq) {
  4435. this.from = this.character;
  4436. warning("W116", this, "!==", "!=");
  4437. } else if (isPoorRelation(left)) {
  4438. warning("W041", this, "!==", left.value);
  4439. } else if (isPoorRelation(right)) {
  4440. warning("W041", this, "!==", right.value);
  4441. } else if (isTypoTypeof(right, left, state)) {
  4442. warning("W122", this, right.value);
  4443. } else if (isTypoTypeof(left, right, state)) {
  4444. warning("W122", this, left.value);
  4445. }
  4446. return this;
  4447. });
  4448. relation("!==", function(left, right) {
  4449. if (isTypoTypeof(right, left, state)) {
  4450. warning("W122", this, right.value);
  4451. } else if (isTypoTypeof(left, right, state)) {
  4452. warning("W122", this, left.value);
  4453. }
  4454. return this;
  4455. });
  4456. relation("<");
  4457. relation(">");
  4458. relation("<=");
  4459. relation(">=");
  4460. bitwise("<<", "shiftleft", 120);
  4461. bitwise(">>", "shiftright", 120);
  4462. bitwise(">>>", "shiftrightunsigned", 120);
  4463. infix("in", "in", 120);
  4464. infix("instanceof", "instanceof", 120);
  4465. infix("+", function(left, that) {
  4466. var right;
  4467. that.left = left;
  4468. that.right = right = expression(130);
  4469. if (left && right && left.id === "(string)" && right.id === "(string)") {
  4470. left.value += right.value;
  4471. left.character = right.character;
  4472. if (!state.option.scripturl && reg.javascriptURL.test(left.value)) {
  4473. warning("W050", left);
  4474. }
  4475. return left;
  4476. }
  4477. return that;
  4478. }, 130);
  4479. prefix("+", "num");
  4480. prefix("+++", function() {
  4481. warning("W007");
  4482. this.arity = "unary";
  4483. this.right = expression(150);
  4484. return this;
  4485. });
  4486. infix("+++", function(left) {
  4487. warning("W007");
  4488. this.left = left;
  4489. this.right = expression(130);
  4490. return this;
  4491. }, 130);
  4492. infix("-", "sub", 130);
  4493. prefix("-", "neg");
  4494. prefix("---", function() {
  4495. warning("W006");
  4496. this.arity = "unary";
  4497. this.right = expression(150);
  4498. return this;
  4499. });
  4500. infix("---", function(left) {
  4501. warning("W006");
  4502. this.left = left;
  4503. this.right = expression(130);
  4504. return this;
  4505. }, 130);
  4506. infix("*", "mult", 140);
  4507. infix("/", "div", 140);
  4508. infix("%", "mod", 140);
  4509. suffix("++");
  4510. prefix("++", "preinc");
  4511. state.syntax["++"].exps = true;
  4512. suffix("--");
  4513. prefix("--", "predec");
  4514. state.syntax["--"].exps = true;
  4515. prefix("delete", function() {
  4516. var p = expression(10);
  4517. if (!p) {
  4518. return this;
  4519. }
  4520. if (p.id !== "." && p.id !== "[") {
  4521. warning("W051");
  4522. }
  4523. this.first = p;
  4524. if (p.identifier && !state.isStrict()) {
  4525. p.forgiveUndef = true;
  4526. }
  4527. return this;
  4528. }).exps = true;
  4529. prefix("~", function() {
  4530. if (state.option.bitwise) {
  4531. warning("W016", this, "~");
  4532. }
  4533. this.arity = "unary";
  4534. this.right = expression(150);
  4535. return this;
  4536. });
  4537. prefix("...", function() {
  4538. if (!state.inES6(true)) {
  4539. warning("W119", this, "spread/rest operator", "6");
  4540. }
  4541. //
  4542. //
  4543. //
  4544. //
  4545. //
  4546. //
  4547. //
  4548. //
  4549. //
  4550. if (!state.tokens.next.identifier &&
  4551. state.tokens.next.type !== "(string)" &&
  4552. !checkPunctuators(state.tokens.next, ["[", "("])) {
  4553. error("E030", state.tokens.next, state.tokens.next.value);
  4554. }
  4555. expression(150);
  4556. return this;
  4557. });
  4558. prefix("!", function() {
  4559. this.arity = "unary";
  4560. this.right = expression(150);
  4561. if (!this.right) { // '!' followed by nothing? Give up.
  4562. quit("E041", this.line || 0);
  4563. }
  4564. if (bang[this.right.id] === true) {
  4565. warning("W018", this, "!");
  4566. }
  4567. return this;
  4568. });
  4569. prefix("typeof", (function() {
  4570. var p = expression(150);
  4571. this.first = this.right = p;
  4572. if (!p) { // 'typeof' followed by nothing? Give up.
  4573. quit("E041", this.line || 0, this.character || 0);
  4574. }
  4575. if (p.identifier) {
  4576. p.forgiveUndef = true;
  4577. }
  4578. return this;
  4579. }));
  4580. prefix("new", function() {
  4581. var mp = metaProperty("target", function() {
  4582. if (!state.inES6(true)) {
  4583. warning("W119", state.tokens.prev, "new.target", "6");
  4584. }
  4585. var inFunction, c = state.funct;
  4586. while (c) {
  4587. inFunction = !c["(global)"];
  4588. if (!c["(arrow)"]) { break; }
  4589. c = c["(context)"];
  4590. }
  4591. if (!inFunction) {
  4592. warning("W136", state.tokens.prev, "new.target");
  4593. }
  4594. });
  4595. if (mp) { return mp; }
  4596. var c = expression(155), i;
  4597. if (c && c.id !== "function") {
  4598. if (c.identifier) {
  4599. c["new"] = true;
  4600. switch (c.value) {
  4601. case "Number":
  4602. case "String":
  4603. case "Boolean":
  4604. case "Math":
  4605. case "JSON":
  4606. warning("W053", state.tokens.prev, c.value);
  4607. break;
  4608. case "Symbol":
  4609. if (state.inES6()) {
  4610. warning("W053", state.tokens.prev, c.value);
  4611. }
  4612. break;
  4613. case "Function":
  4614. if (!state.option.evil) {
  4615. warning("W054");
  4616. }
  4617. break;
  4618. case "Date":
  4619. case "RegExp":
  4620. case "this":
  4621. break;
  4622. default:
  4623. if (c.id !== "function") {
  4624. i = c.value.substr(0, 1);
  4625. if (state.option.newcap && (i < "A" || i > "Z") &&
  4626. !state.funct["(scope)"].isPredefined(c.value)) {
  4627. warning("W055", state.tokens.curr);
  4628. }
  4629. }
  4630. }
  4631. } else {
  4632. if (c.id !== "." && c.id !== "[" && c.id !== "(") {
  4633. warning("W056", state.tokens.curr);
  4634. }
  4635. }
  4636. } else {
  4637. if (!state.option.supernew)
  4638. warning("W057", this);
  4639. }
  4640. if (state.tokens.next.id !== "(" && !state.option.supernew) {
  4641. warning("W058", state.tokens.curr, state.tokens.curr.value);
  4642. }
  4643. this.first = this.right = c;
  4644. return this;
  4645. });
  4646. state.syntax["new"].exps = true;
  4647. prefix("void").exps = true;
  4648. infix(".", function(left, that) {
  4649. var m = identifier(false, true);
  4650. if (typeof m === "string") {
  4651. countMember(m);
  4652. }
  4653. that.left = left;
  4654. that.right = m;
  4655. if (m && m === "hasOwnProperty" && state.tokens.next.value === "=") {
  4656. warning("W001");
  4657. }
  4658. if (left && left.value === "arguments" && (m === "callee" || m === "caller")) {
  4659. if (state.option.noarg)
  4660. warning("W059", left, m);
  4661. else if (state.isStrict())
  4662. error("E008");
  4663. } else if (!state.option.evil && left && left.value === "document" &&
  4664. (m === "write" || m === "writeln")) {
  4665. warning("W060", left);
  4666. }
  4667. if (!state.option.evil && (m === "eval" || m === "execScript")) {
  4668. if (isGlobalEval(left, state)) {
  4669. warning("W061");
  4670. }
  4671. }
  4672. return that;
  4673. }, 160, true);
  4674. infix("(", function(left, that) {
  4675. if (state.option.immed && left && !left.immed && left.id === "function") {
  4676. warning("W062");
  4677. }
  4678. var n = 0;
  4679. var p = [];
  4680. if (left) {
  4681. if (left.type === "(identifier)") {
  4682. if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
  4683. if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) {
  4684. if (left.value === "Math") {
  4685. warning("W063", left);
  4686. } else if (state.option.newcap) {
  4687. warning("W064", left);
  4688. }
  4689. }
  4690. }
  4691. }
  4692. }
  4693. if (state.tokens.next.id !== ")") {
  4694. for (;;) {
  4695. p[p.length] = expression(10);
  4696. n += 1;
  4697. if (state.tokens.next.id !== ",") {
  4698. break;
  4699. }
  4700. comma();
  4701. }
  4702. }
  4703. advance(")");
  4704. if (typeof left === "object") {
  4705. if (!state.inES5() && left.value === "parseInt" && n === 1) {
  4706. warning("W065", state.tokens.curr);
  4707. }
  4708. if (!state.option.evil) {
  4709. if (left.value === "eval" || left.value === "Function" ||
  4710. left.value === "execScript") {
  4711. warning("W061", left);
  4712. if (p[0] && [0].id === "(string)") {
  4713. addInternalSrc(left, p[0].value);
  4714. }
  4715. } else if (p[0] && p[0].id === "(string)" &&
  4716. (left.value === "setTimeout" ||
  4717. left.value === "setInterval")) {
  4718. warning("W066", left);
  4719. addInternalSrc(left, p[0].value);
  4720. } else if (p[0] && p[0].id === "(string)" &&
  4721. left.value === "." &&
  4722. left.left.value === "window" &&
  4723. (left.right === "setTimeout" ||
  4724. left.right === "setInterval")) {
  4725. warning("W066", left);
  4726. addInternalSrc(left, p[0].value);
  4727. }
  4728. }
  4729. if (!left.identifier && left.id !== "." && left.id !== "[" && left.id !== "=>" &&
  4730. left.id !== "(" && left.id !== "&&" && left.id !== "||" && left.id !== "?" &&
  4731. !(state.inES6() && left["(name)"])) {
  4732. warning("W067", that);
  4733. }
  4734. }
  4735. that.left = left;
  4736. return that;
  4737. }, 155, true).exps = true;
  4738. prefix("(", function() {
  4739. var pn = state.tokens.next, pn1, i = -1;
  4740. var ret, triggerFnExpr, first, last;
  4741. var parens = 1;
  4742. var opening = state.tokens.curr;
  4743. var preceeding = state.tokens.prev;
  4744. var isNecessary = !state.option.singleGroups;
  4745. do {
  4746. if (pn.value === "(") {
  4747. parens += 1;
  4748. } else if (pn.value === ")") {
  4749. parens -= 1;
  4750. }
  4751. i += 1;
  4752. pn1 = pn;
  4753. pn = peek(i);
  4754. } while (!(parens === 0 && pn1.value === ")") && pn.value !== ";" && pn.type !== "(end)");
  4755. if (state.tokens.next.id === "function") {
  4756. triggerFnExpr = state.tokens.next.immed = true;
  4757. }
  4758. if (pn.value === "=>") {
  4759. return doFunction({ type: "arrow", parsedOpening: true });
  4760. }
  4761. var exprs = [];
  4762. if (state.tokens.next.id !== ")") {
  4763. for (;;) {
  4764. exprs.push(expression(10));
  4765. if (state.tokens.next.id !== ",") {
  4766. break;
  4767. }
  4768. if (state.option.nocomma) {
  4769. warning("W127");
  4770. }
  4771. comma();
  4772. }
  4773. }
  4774. advance(")", this);
  4775. if (state.option.immed && exprs[0] && exprs[0].id === "function") {
  4776. if (state.tokens.next.id !== "(" &&
  4777. state.tokens.next.id !== "." && state.tokens.next.id !== "[") {
  4778. warning("W068", this);
  4779. }
  4780. }
  4781. if (!exprs.length) {
  4782. return;
  4783. }
  4784. if (exprs.length > 1) {
  4785. ret = Object.create(state.syntax[","]);
  4786. ret.exprs = exprs;
  4787. first = exprs[0];
  4788. last = exprs[exprs.length - 1];
  4789. if (!isNecessary) {
  4790. isNecessary = preceeding.assign || preceeding.delim;
  4791. }
  4792. } else {
  4793. ret = first = last = exprs[0];
  4794. if (!isNecessary) {
  4795. isNecessary =
  4796. (opening.beginsStmt && (ret.id === "{" || triggerFnExpr || isFunctor(ret))) ||
  4797. (triggerFnExpr &&
  4798. (!isEndOfExpr() || state.tokens.prev.id !== "}")) ||
  4799. (isFunctor(ret) && !isEndOfExpr()) ||
  4800. (ret.id === "{" && preceeding.id === "=>") ||
  4801. (ret.type === "(number)" &&
  4802. checkPunctuator(pn, ".") && /^\d+$/.test(ret.value));
  4803. }
  4804. }
  4805. if (ret) {
  4806. if (!isNecessary && (first.left || first.right || ret.exprs)) {
  4807. isNecessary =
  4808. (!isBeginOfExpr(preceeding) && first.lbp <= preceeding.lbp) ||
  4809. (!isEndOfExpr() && last.lbp < state.tokens.next.lbp);
  4810. }
  4811. if (!isNecessary) {
  4812. warning("W126", opening);
  4813. }
  4814. ret.paren = true;
  4815. }
  4816. return ret;
  4817. });
  4818. application("=>");
  4819. infix("[", function(left, that) {
  4820. var e = expression(10), s;
  4821. if (e && e.type === "(string)") {
  4822. if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) {
  4823. if (isGlobalEval(left, state)) {
  4824. warning("W061");
  4825. }
  4826. }
  4827. countMember(e.value);
  4828. if (!state.option.sub && reg.identifier.test(e.value)) {
  4829. s = state.syntax[e.value];
  4830. if (!s || !isReserved(s)) {
  4831. warning("W069", state.tokens.prev, e.value);
  4832. }
  4833. }
  4834. }
  4835. advance("]", that);
  4836. if (e && e.value === "hasOwnProperty" && state.tokens.next.value === "=") {
  4837. warning("W001");
  4838. }
  4839. that.left = left;
  4840. that.right = e;
  4841. return that;
  4842. }, 160, true);
  4843. function comprehensiveArrayExpression() {
  4844. var res = {};
  4845. res.exps = true;
  4846. state.funct["(comparray)"].stack();
  4847. var reversed = false;
  4848. if (state.tokens.next.value !== "for") {
  4849. reversed = true;
  4850. if (!state.inMoz()) {
  4851. warning("W116", state.tokens.next, "for", state.tokens.next.value);
  4852. }
  4853. state.funct["(comparray)"].setState("use");
  4854. res.right = expression(10);
  4855. }
  4856. advance("for");
  4857. if (state.tokens.next.value === "each") {
  4858. advance("each");
  4859. if (!state.inMoz()) {
  4860. warning("W118", state.tokens.curr, "for each");
  4861. }
  4862. }
  4863. advance("(");
  4864. state.funct["(comparray)"].setState("define");
  4865. res.left = expression(130);
  4866. if (_.contains(["in", "of"], state.tokens.next.value)) {
  4867. advance();
  4868. } else {
  4869. error("E045", state.tokens.curr);
  4870. }
  4871. state.funct["(comparray)"].setState("generate");
  4872. expression(10);
  4873. advance(")");
  4874. if (state.tokens.next.value === "if") {
  4875. advance("if");
  4876. advance("(");
  4877. state.funct["(comparray)"].setState("filter");
  4878. res.filter = expression(10);
  4879. advance(")");
  4880. }
  4881. if (!reversed) {
  4882. state.funct["(comparray)"].setState("use");
  4883. res.right = expression(10);
  4884. }
  4885. advance("]");
  4886. state.funct["(comparray)"].unstack();
  4887. return res;
  4888. }
  4889. prefix("[", function() {
  4890. var blocktype = lookupBlockType();
  4891. if (blocktype.isCompArray) {
  4892. if (!state.option.esnext && !state.inMoz()) {
  4893. warning("W118", state.tokens.curr, "array comprehension");
  4894. }
  4895. return comprehensiveArrayExpression();
  4896. } else if (blocktype.isDestAssign) {
  4897. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  4898. return this;
  4899. }
  4900. var b = state.tokens.curr.line !== startLine(state.tokens.next);
  4901. this.first = [];
  4902. if (b) {
  4903. indent += state.option.indent;
  4904. if (state.tokens.next.from === indent + state.option.indent) {
  4905. indent += state.option.indent;
  4906. }
  4907. }
  4908. while (state.tokens.next.id !== "(end)") {
  4909. while (state.tokens.next.id === ",") {
  4910. if (!state.option.elision) {
  4911. if (!state.inES5()) {
  4912. warning("W070");
  4913. } else {
  4914. warning("W128");
  4915. do {
  4916. advance(",");
  4917. } while (state.tokens.next.id === ",");
  4918. continue;
  4919. }
  4920. }
  4921. advance(",");
  4922. }
  4923. if (state.tokens.next.id === "]") {
  4924. break;
  4925. }
  4926. this.first.push(expression(10));
  4927. if (state.tokens.next.id === ",") {
  4928. comma({ allowTrailing: true });
  4929. if (state.tokens.next.id === "]" && !state.inES5()) {
  4930. warning("W070", state.tokens.curr);
  4931. break;
  4932. }
  4933. } else {
  4934. break;
  4935. }
  4936. }
  4937. if (b) {
  4938. indent -= state.option.indent;
  4939. }
  4940. advance("]", this);
  4941. return this;
  4942. });
  4943. function isMethod() {
  4944. return state.funct["(statement)"] && state.funct["(statement)"].type === "class" ||
  4945. state.funct["(context)"] && state.funct["(context)"]["(verb)"] === "class";
  4946. }
  4947. function isPropertyName(token) {
  4948. return token.identifier || token.id === "(string)" || token.id === "(number)";
  4949. }
  4950. function propertyName(preserveOrToken) {
  4951. var id;
  4952. var preserve = true;
  4953. if (typeof preserveOrToken === "object") {
  4954. id = preserveOrToken;
  4955. } else {
  4956. preserve = preserveOrToken;
  4957. id = optionalidentifier(false, true, preserve);
  4958. }
  4959. if (!id) {
  4960. if (state.tokens.next.id === "(string)") {
  4961. id = state.tokens.next.value;
  4962. if (!preserve) {
  4963. advance();
  4964. }
  4965. } else if (state.tokens.next.id === "(number)") {
  4966. id = state.tokens.next.value.toString();
  4967. if (!preserve) {
  4968. advance();
  4969. }
  4970. }
  4971. } else if (typeof id === "object") {
  4972. if (id.id === "(string)" || id.id === "(identifier)") id = id.value;
  4973. else if (id.id === "(number)") id = id.value.toString();
  4974. }
  4975. if (id === "hasOwnProperty") {
  4976. warning("W001");
  4977. }
  4978. return id;
  4979. }
  4980. function functionparams(options) {
  4981. var next;
  4982. var paramsIds = [];
  4983. var ident;
  4984. var tokens = [];
  4985. var t;
  4986. var pastDefault = false;
  4987. var pastRest = false;
  4988. var arity = 0;
  4989. var loneArg = options && options.loneArg;
  4990. if (loneArg && loneArg.identifier === true) {
  4991. state.funct["(scope)"].addParam(loneArg.value, loneArg);
  4992. return { arity: 1, params: [ loneArg.value ] };
  4993. }
  4994. next = state.tokens.next;
  4995. if (!options || !options.parsedOpening) {
  4996. advance("(");
  4997. }
  4998. if (state.tokens.next.id === ")") {
  4999. advance(")");
  5000. return;
  5001. }
  5002. function addParam(addParamArgs) {
  5003. state.funct["(scope)"].addParam.apply(state.funct["(scope)"], addParamArgs);
  5004. }
  5005. for (;;) {
  5006. arity++;
  5007. var currentParams = [];
  5008. if (_.contains(["{", "["], state.tokens.next.id)) {
  5009. tokens = destructuringPattern();
  5010. for (t in tokens) {
  5011. t = tokens[t];
  5012. if (t.id) {
  5013. paramsIds.push(t.id);
  5014. currentParams.push([t.id, t.token]);
  5015. }
  5016. }
  5017. } else {
  5018. if (checkPunctuator(state.tokens.next, "...")) pastRest = true;
  5019. ident = identifier(true);
  5020. if (ident) {
  5021. paramsIds.push(ident);
  5022. currentParams.push([ident, state.tokens.curr]);
  5023. } else {
  5024. while (!checkPunctuators(state.tokens.next, [",", ")"])) advance();
  5025. }
  5026. }
  5027. if (pastDefault) {
  5028. if (state.tokens.next.id !== "=") {
  5029. error("W138", state.tokens.current);
  5030. }
  5031. }
  5032. if (state.tokens.next.id === "=") {
  5033. if (!state.inES6()) {
  5034. warning("W119", state.tokens.next, "default parameters", "6");
  5035. }
  5036. advance("=");
  5037. pastDefault = true;
  5038. expression(10);
  5039. }
  5040. currentParams.forEach(addParam);
  5041. if (state.tokens.next.id === ",") {
  5042. if (pastRest) {
  5043. warning("W131", state.tokens.next);
  5044. }
  5045. comma();
  5046. } else {
  5047. advance(")", next);
  5048. return { arity: arity, params: paramsIds };
  5049. }
  5050. }
  5051. }
  5052. function functor(name, token, overwrites) {
  5053. var funct = {
  5054. "(name)" : name,
  5055. "(breakage)" : 0,
  5056. "(loopage)" : 0,
  5057. "(tokens)" : {},
  5058. "(properties)": {},
  5059. "(catch)" : false,
  5060. "(global)" : false,
  5061. "(line)" : null,
  5062. "(character)" : null,
  5063. "(metrics)" : null,
  5064. "(statement)" : null,
  5065. "(context)" : null,
  5066. "(scope)" : null,
  5067. "(comparray)" : null,
  5068. "(generator)" : null,
  5069. "(arrow)" : null,
  5070. "(params)" : null
  5071. };
  5072. if (token) {
  5073. _.extend(funct, {
  5074. "(line)" : token.line,
  5075. "(character)": token.character,
  5076. "(metrics)" : createMetrics(token)
  5077. });
  5078. }
  5079. _.extend(funct, overwrites);
  5080. if (funct["(context)"]) {
  5081. funct["(scope)"] = funct["(context)"]["(scope)"];
  5082. funct["(comparray)"] = funct["(context)"]["(comparray)"];
  5083. }
  5084. return funct;
  5085. }
  5086. function isFunctor(token) {
  5087. return "(scope)" in token;
  5088. }
  5089. function hasParsedCode(funct) {
  5090. return funct["(global)"] && !funct["(verb)"];
  5091. }
  5092. function doTemplateLiteral(left) {
  5093. var ctx = this.context;
  5094. var noSubst = this.noSubst;
  5095. var depth = this.depth;
  5096. if (!noSubst) {
  5097. while (!end()) {
  5098. if (!state.tokens.next.template || state.tokens.next.depth > depth) {
  5099. expression(0); // should probably have different rbp?
  5100. } else {
  5101. advance();
  5102. }
  5103. }
  5104. }
  5105. return {
  5106. id: "(template)",
  5107. type: "(template)",
  5108. tag: left
  5109. };
  5110. function end() {
  5111. if (state.tokens.curr.template && state.tokens.curr.tail &&
  5112. state.tokens.curr.context === ctx) return true;
  5113. var complete = (state.tokens.next.template && state.tokens.next.tail &&
  5114. state.tokens.next.context === ctx);
  5115. if (complete) advance();
  5116. return complete || state.tokens.next.isUnclosed;
  5117. }
  5118. }
  5119. function doFunction(options) {
  5120. var f, token, name, statement, classExprBinding, isGenerator, isArrow, ignoreLoopFunc;
  5121. var oldOption = state.option;
  5122. var oldIgnored = state.ignored;
  5123. if (options) {
  5124. name = options.name;
  5125. statement = options.statement;
  5126. classExprBinding = options.classExprBinding;
  5127. isGenerator = options.type === "generator";
  5128. isArrow = options.type === "arrow";
  5129. ignoreLoopFunc = options.ignoreLoopFunc;
  5130. }
  5131. state.option = Object.create(state.option);
  5132. state.ignored = Object.create(state.ignored);
  5133. state.funct = functor(name || state.nameStack.infer(), state.tokens.next, {
  5134. "(statement)": statement,
  5135. "(context)": state.funct,
  5136. "(arrow)": isArrow,
  5137. "(generator)": isGenerator
  5138. });
  5139. f = state.funct;
  5140. token = state.tokens.curr;
  5141. token.funct = state.funct;
  5142. functions.push(state.funct);
  5143. state.funct["(scope)"].stack("functionouter");
  5144. var internallyAccessibleName = name || classExprBinding;
  5145. if (internallyAccessibleName) {
  5146. state.funct["(scope)"].block.add(internallyAccessibleName,
  5147. classExprBinding ? "class" : "function", state.tokens.curr, false);
  5148. }
  5149. state.funct["(scope)"].stack("functionparams");
  5150. var paramsInfo = functionparams(options);
  5151. if (paramsInfo) {
  5152. state.funct["(params)"] = paramsInfo.params;
  5153. state.funct["(metrics)"].arity = paramsInfo.arity;
  5154. state.funct["(metrics)"].verifyMaxParametersPerFunction();
  5155. } else {
  5156. state.funct["(metrics)"].arity = 0;
  5157. }
  5158. if (isArrow) {
  5159. if (!state.inES6(true)) {
  5160. warning("W119", state.tokens.curr, "arrow function syntax (=>)", "6");
  5161. }
  5162. if (!options.loneArg) {
  5163. advance("=>");
  5164. }
  5165. }
  5166. block(false, true, true, isArrow);
  5167. if (!state.option.noyield && isGenerator &&
  5168. state.funct["(generator)"] !== "yielded") {
  5169. warning("W124", state.tokens.curr);
  5170. }
  5171. state.funct["(metrics)"].verifyMaxStatementsPerFunction();
  5172. state.funct["(metrics)"].verifyMaxComplexityPerFunction();
  5173. state.funct["(unusedOption)"] = state.option.unused;
  5174. state.option = oldOption;
  5175. state.ignored = oldIgnored;
  5176. state.funct["(last)"] = state.tokens.curr.line;
  5177. state.funct["(lastcharacter)"] = state.tokens.curr.character;
  5178. state.funct["(scope)"].unstack(); // also does usage and label checks
  5179. state.funct["(scope)"].unstack();
  5180. state.funct = state.funct["(context)"];
  5181. if (!ignoreLoopFunc && !state.option.loopfunc && state.funct["(loopage)"]) {
  5182. if (f["(isCapturing)"]) {
  5183. warning("W083", token);
  5184. }
  5185. }
  5186. return f;
  5187. }
  5188. function createMetrics(functionStartToken) {
  5189. return {
  5190. statementCount: 0,
  5191. nestedBlockDepth: -1,
  5192. ComplexityCount: 1,
  5193. arity: 0,
  5194. verifyMaxStatementsPerFunction: function() {
  5195. if (state.option.maxstatements &&
  5196. this.statementCount > state.option.maxstatements) {
  5197. warning("W071", functionStartToken, this.statementCount);
  5198. }
  5199. },
  5200. verifyMaxParametersPerFunction: function() {
  5201. if (_.isNumber(state.option.maxparams) &&
  5202. this.arity > state.option.maxparams) {
  5203. warning("W072", functionStartToken, this.arity);
  5204. }
  5205. },
  5206. verifyMaxNestedBlockDepthPerFunction: function() {
  5207. if (state.option.maxdepth &&
  5208. this.nestedBlockDepth > 0 &&
  5209. this.nestedBlockDepth === state.option.maxdepth + 1) {
  5210. warning("W073", null, this.nestedBlockDepth);
  5211. }
  5212. },
  5213. verifyMaxComplexityPerFunction: function() {
  5214. var max = state.option.maxcomplexity;
  5215. var cc = this.ComplexityCount;
  5216. if (max && cc > max) {
  5217. warning("W074", functionStartToken, cc);
  5218. }
  5219. }
  5220. };
  5221. }
  5222. function increaseComplexityCount() {
  5223. state.funct["(metrics)"].ComplexityCount += 1;
  5224. }
  5225. function checkCondAssignment(expr) {
  5226. var id, paren;
  5227. if (expr) {
  5228. id = expr.id;
  5229. paren = expr.paren;
  5230. if (id === "," && (expr = expr.exprs[expr.exprs.length - 1])) {
  5231. id = expr.id;
  5232. paren = paren || expr.paren;
  5233. }
  5234. }
  5235. switch (id) {
  5236. case "=":
  5237. case "+=":
  5238. case "-=":
  5239. case "*=":
  5240. case "%=":
  5241. case "&=":
  5242. case "|=":
  5243. case "^=":
  5244. case "/=":
  5245. if (!paren && !state.option.boss) {
  5246. warning("W084");
  5247. }
  5248. }
  5249. }
  5250. function checkProperties(props) {
  5251. if (state.inES5()) {
  5252. for (var name in props) {
  5253. if (props[name] && props[name].setterToken && !props[name].getterToken) {
  5254. warning("W078", props[name].setterToken);
  5255. }
  5256. }
  5257. }
  5258. }
  5259. function metaProperty(name, c) {
  5260. if (checkPunctuator(state.tokens.next, ".")) {
  5261. var left = state.tokens.curr.id;
  5262. advance(".");
  5263. var id = identifier();
  5264. state.tokens.curr.isMetaProperty = true;
  5265. if (name !== id) {
  5266. error("E057", state.tokens.prev, left, id);
  5267. } else {
  5268. c();
  5269. }
  5270. return state.tokens.curr;
  5271. }
  5272. }
  5273. (function(x) {
  5274. x.nud = function() {
  5275. var b, f, i, p, t, isGeneratorMethod = false, nextVal;
  5276. var props = Object.create(null); // All properties, including accessors
  5277. b = state.tokens.curr.line !== startLine(state.tokens.next);
  5278. if (b) {
  5279. indent += state.option.indent;
  5280. if (state.tokens.next.from === indent + state.option.indent) {
  5281. indent += state.option.indent;
  5282. }
  5283. }
  5284. var blocktype = lookupBlockType();
  5285. if (blocktype.isDestAssign) {
  5286. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  5287. return this;
  5288. }
  5289. for (;;) {
  5290. if (state.tokens.next.id === "}") {
  5291. break;
  5292. }
  5293. nextVal = state.tokens.next.value;
  5294. if (state.tokens.next.identifier &&
  5295. (peekIgnoreEOL().id === "," || peekIgnoreEOL().id === "}")) {
  5296. if (!state.inES6()) {
  5297. warning("W104", state.tokens.next, "object short notation", "6");
  5298. }
  5299. i = propertyName(true);
  5300. saveProperty(props, i, state.tokens.next);
  5301. expression(10);
  5302. } else if (peek().id !== ":" && (nextVal === "get" || nextVal === "set")) {
  5303. advance(nextVal);
  5304. if (!state.inES5()) {
  5305. error("E034");
  5306. }
  5307. i = propertyName();
  5308. if (!i && !state.inES6()) {
  5309. error("E035");
  5310. }
  5311. if (i) {
  5312. saveAccessor(nextVal, props, i, state.tokens.curr);
  5313. }
  5314. t = state.tokens.next;
  5315. f = doFunction();
  5316. p = f["(params)"];
  5317. if (nextVal === "get" && i && p) {
  5318. warning("W076", t, p[0], i);
  5319. } else if (nextVal === "set" && i && (!p || p.length !== 1)) {
  5320. warning("W077", t, i);
  5321. }
  5322. } else {
  5323. if (state.tokens.next.value === "*" && state.tokens.next.type === "(punctuator)") {
  5324. if (!state.inES6()) {
  5325. warning("W104", state.tokens.next, "generator functions", "6");
  5326. }
  5327. advance("*");
  5328. isGeneratorMethod = true;
  5329. } else {
  5330. isGeneratorMethod = false;
  5331. }
  5332. if (state.tokens.next.id === "[") {
  5333. i = computedPropertyName();
  5334. state.nameStack.set(i);
  5335. } else {
  5336. state.nameStack.set(state.tokens.next);
  5337. i = propertyName();
  5338. saveProperty(props, i, state.tokens.next);
  5339. if (typeof i !== "string") {
  5340. break;
  5341. }
  5342. }
  5343. if (state.tokens.next.value === "(") {
  5344. if (!state.inES6()) {
  5345. warning("W104", state.tokens.curr, "concise methods", "6");
  5346. }
  5347. doFunction({ type: isGeneratorMethod ? "generator" : null });
  5348. } else {
  5349. advance(":");
  5350. expression(10);
  5351. }
  5352. }
  5353. countMember(i);
  5354. if (state.tokens.next.id === ",") {
  5355. comma({ allowTrailing: true, property: true });
  5356. if (state.tokens.next.id === ",") {
  5357. warning("W070", state.tokens.curr);
  5358. } else if (state.tokens.next.id === "}" && !state.inES5()) {
  5359. warning("W070", state.tokens.curr);
  5360. }
  5361. } else {
  5362. break;
  5363. }
  5364. }
  5365. if (b) {
  5366. indent -= state.option.indent;
  5367. }
  5368. advance("}", this);
  5369. checkProperties(props);
  5370. return this;
  5371. };
  5372. x.fud = function() {
  5373. error("E036", state.tokens.curr);
  5374. };
  5375. }(delim("{")));
  5376. function destructuringPattern(options) {
  5377. var isAssignment = options && options.assignment;
  5378. if (!state.inES6()) {
  5379. warning("W104", state.tokens.curr,
  5380. isAssignment ? "destructuring assignment" : "destructuring binding", "6");
  5381. }
  5382. return destructuringPatternRecursive(options);
  5383. }
  5384. function destructuringPatternRecursive(options) {
  5385. var ids;
  5386. var identifiers = [];
  5387. var openingParsed = options && options.openingParsed;
  5388. var isAssignment = options && options.assignment;
  5389. var recursiveOptions = isAssignment ? { assignment: isAssignment } : null;
  5390. var firstToken = openingParsed ? state.tokens.curr : state.tokens.next;
  5391. var nextInnerDE = function() {
  5392. var ident;
  5393. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  5394. ids = destructuringPatternRecursive(recursiveOptions);
  5395. for (var id in ids) {
  5396. id = ids[id];
  5397. identifiers.push({ id: id.id, token: id.token });
  5398. }
  5399. } else if (checkPunctuator(state.tokens.next, ",")) {
  5400. identifiers.push({ id: null, token: state.tokens.curr });
  5401. } else if (checkPunctuator(state.tokens.next, "(")) {
  5402. advance("(");
  5403. nextInnerDE();
  5404. advance(")");
  5405. } else {
  5406. var is_rest = checkPunctuator(state.tokens.next, "...");
  5407. if (isAssignment) {
  5408. var identifierToken = is_rest ? peek(0) : state.tokens.next;
  5409. if (!identifierToken.identifier) {
  5410. warning("E030", identifierToken, identifierToken.value);
  5411. }
  5412. var assignTarget = expression(155);
  5413. if (assignTarget) {
  5414. checkLeftSideAssign(assignTarget);
  5415. if (assignTarget.identifier) {
  5416. ident = assignTarget.value;
  5417. }
  5418. }
  5419. } else {
  5420. ident = identifier();
  5421. }
  5422. if (ident) {
  5423. identifiers.push({ id: ident, token: state.tokens.curr });
  5424. }
  5425. return is_rest;
  5426. }
  5427. return false;
  5428. };
  5429. var assignmentProperty = function() {
  5430. var id;
  5431. if (checkPunctuator(state.tokens.next, "[")) {
  5432. advance("[");
  5433. expression(10);
  5434. advance("]");
  5435. advance(":");
  5436. nextInnerDE();
  5437. } else if (state.tokens.next.id === "(string)" ||
  5438. state.tokens.next.id === "(number)") {
  5439. advance();
  5440. advance(":");
  5441. nextInnerDE();
  5442. } else {
  5443. id = identifier();
  5444. if (checkPunctuator(state.tokens.next, ":")) {
  5445. advance(":");
  5446. nextInnerDE();
  5447. } else if (id) {
  5448. if (isAssignment) {
  5449. checkLeftSideAssign(state.tokens.curr);
  5450. }
  5451. identifiers.push({ id: id, token: state.tokens.curr });
  5452. }
  5453. }
  5454. };
  5455. if (checkPunctuator(firstToken, "[")) {
  5456. if (!openingParsed) {
  5457. advance("[");
  5458. }
  5459. if (checkPunctuator(state.tokens.next, "]")) {
  5460. warning("W137", state.tokens.curr);
  5461. }
  5462. var element_after_rest = false;
  5463. while (!checkPunctuator(state.tokens.next, "]")) {
  5464. if (nextInnerDE() && !element_after_rest &&
  5465. checkPunctuator(state.tokens.next, ",")) {
  5466. warning("W130", state.tokens.next);
  5467. element_after_rest = true;
  5468. }
  5469. if (checkPunctuator(state.tokens.next, "=")) {
  5470. if (checkPunctuator(state.tokens.prev, "...")) {
  5471. advance("]");
  5472. } else {
  5473. advance("=");
  5474. }
  5475. if (state.tokens.next.id === "undefined") {
  5476. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5477. }
  5478. expression(10);
  5479. }
  5480. if (!checkPunctuator(state.tokens.next, "]")) {
  5481. advance(",");
  5482. }
  5483. }
  5484. advance("]");
  5485. } else if (checkPunctuator(firstToken, "{")) {
  5486. if (!openingParsed) {
  5487. advance("{");
  5488. }
  5489. if (checkPunctuator(state.tokens.next, "}")) {
  5490. warning("W137", state.tokens.curr);
  5491. }
  5492. while (!checkPunctuator(state.tokens.next, "}")) {
  5493. assignmentProperty();
  5494. if (checkPunctuator(state.tokens.next, "=")) {
  5495. advance("=");
  5496. if (state.tokens.next.id === "undefined") {
  5497. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5498. }
  5499. expression(10);
  5500. }
  5501. if (!checkPunctuator(state.tokens.next, "}")) {
  5502. advance(",");
  5503. if (checkPunctuator(state.tokens.next, "}")) {
  5504. break;
  5505. }
  5506. }
  5507. }
  5508. advance("}");
  5509. }
  5510. return identifiers;
  5511. }
  5512. function destructuringPatternMatch(tokens, value) {
  5513. var first = value.first;
  5514. if (!first)
  5515. return;
  5516. _.zip(tokens, Array.isArray(first) ? first : [ first ]).forEach(function(val) {
  5517. var token = val[0];
  5518. var value = val[1];
  5519. if (token && value)
  5520. token.first = value;
  5521. else if (token && token.first && !value)
  5522. warning("W080", token.first, token.first.value);
  5523. });
  5524. }
  5525. function blockVariableStatement(type, statement, context) {
  5526. var prefix = context && context.prefix;
  5527. var inexport = context && context.inexport;
  5528. var isLet = type === "let";
  5529. var isConst = type === "const";
  5530. var tokens, lone, value, letblock;
  5531. if (!state.inES6()) {
  5532. warning("W104", state.tokens.curr, type, "6");
  5533. }
  5534. if (isLet && state.tokens.next.value === "(") {
  5535. if (!state.inMoz()) {
  5536. warning("W118", state.tokens.next, "let block");
  5537. }
  5538. advance("(");
  5539. state.funct["(scope)"].stack();
  5540. letblock = true;
  5541. } else if (state.funct["(noblockscopedvar)"]) {
  5542. error("E048", state.tokens.curr, isConst ? "Const" : "Let");
  5543. }
  5544. statement.first = [];
  5545. for (;;) {
  5546. var names = [];
  5547. if (_.contains(["{", "["], state.tokens.next.value)) {
  5548. tokens = destructuringPattern();
  5549. lone = false;
  5550. } else {
  5551. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  5552. lone = true;
  5553. }
  5554. if (!prefix && isConst && state.tokens.next.id !== "=") {
  5555. warning("E012", state.tokens.curr, state.tokens.curr.value);
  5556. }
  5557. for (var t in tokens) {
  5558. if (tokens.hasOwnProperty(t)) {
  5559. t = tokens[t];
  5560. if (state.funct["(scope)"].block.isGlobal()) {
  5561. if (predefined[t.id] === false) {
  5562. warning("W079", t.token, t.id);
  5563. }
  5564. }
  5565. if (t.id && !state.funct["(noblockscopedvar)"]) {
  5566. state.funct["(scope)"].addlabel(t.id, {
  5567. type: type,
  5568. token: t.token });
  5569. names.push(t.token);
  5570. if (lone && inexport) {
  5571. state.funct["(scope)"].setExported(t.token.value, t.token);
  5572. }
  5573. }
  5574. }
  5575. }
  5576. if (state.tokens.next.id === "=") {
  5577. advance("=");
  5578. if (!prefix && state.tokens.next.id === "undefined") {
  5579. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5580. }
  5581. if (!prefix && peek(0).id === "=" && state.tokens.next.identifier) {
  5582. warning("W120", state.tokens.next, state.tokens.next.value);
  5583. }
  5584. value = expression(prefix ? 120 : 10);
  5585. if (lone) {
  5586. tokens[0].first = value;
  5587. } else {
  5588. destructuringPatternMatch(names, value);
  5589. }
  5590. }
  5591. statement.first = statement.first.concat(names);
  5592. if (state.tokens.next.id !== ",") {
  5593. break;
  5594. }
  5595. comma();
  5596. }
  5597. if (letblock) {
  5598. advance(")");
  5599. block(true, true);
  5600. statement.block = true;
  5601. state.funct["(scope)"].unstack();
  5602. }
  5603. return statement;
  5604. }
  5605. var conststatement = stmt("const", function(context) {
  5606. return blockVariableStatement("const", this, context);
  5607. });
  5608. conststatement.exps = true;
  5609. var letstatement = stmt("let", function(context) {
  5610. return blockVariableStatement("let", this, context);
  5611. });
  5612. letstatement.exps = true;
  5613. var varstatement = stmt("var", function(context) {
  5614. var prefix = context && context.prefix;
  5615. var inexport = context && context.inexport;
  5616. var tokens, lone, value;
  5617. var implied = context && context.implied;
  5618. var report = !(context && context.ignore);
  5619. this.first = [];
  5620. for (;;) {
  5621. var names = [];
  5622. if (_.contains(["{", "["], state.tokens.next.value)) {
  5623. tokens = destructuringPattern();
  5624. lone = false;
  5625. } else {
  5626. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  5627. lone = true;
  5628. }
  5629. if (!(prefix && implied) && report && state.option.varstmt) {
  5630. warning("W132", this);
  5631. }
  5632. this.first = this.first.concat(names);
  5633. for (var t in tokens) {
  5634. if (tokens.hasOwnProperty(t)) {
  5635. t = tokens[t];
  5636. if (!implied && state.funct["(global)"]) {
  5637. if (predefined[t.id] === false) {
  5638. warning("W079", t.token, t.id);
  5639. } else if (state.option.futurehostile === false) {
  5640. if ((!state.inES5() && vars.ecmaIdentifiers[5][t.id] === false) ||
  5641. (!state.inES6() && vars.ecmaIdentifiers[6][t.id] === false)) {
  5642. warning("W129", t.token, t.id);
  5643. }
  5644. }
  5645. }
  5646. if (t.id) {
  5647. if (implied === "for") {
  5648. if (!state.funct["(scope)"].has(t.id)) {
  5649. if (report) warning("W088", t.token, t.id);
  5650. }
  5651. state.funct["(scope)"].block.use(t.id, t.token);
  5652. } else {
  5653. state.funct["(scope)"].addlabel(t.id, {
  5654. type: "var",
  5655. token: t.token });
  5656. if (lone && inexport) {
  5657. state.funct["(scope)"].setExported(t.id, t.token);
  5658. }
  5659. }
  5660. names.push(t.token);
  5661. }
  5662. }
  5663. }
  5664. if (state.tokens.next.id === "=") {
  5665. state.nameStack.set(state.tokens.curr);
  5666. advance("=");
  5667. if (!prefix && report && !state.funct["(loopage)"] &&
  5668. state.tokens.next.id === "undefined") {
  5669. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5670. }
  5671. if (peek(0).id === "=" && state.tokens.next.identifier) {
  5672. if (!prefix && report &&
  5673. !state.funct["(params)"] ||
  5674. state.funct["(params)"].indexOf(state.tokens.next.value) === -1) {
  5675. warning("W120", state.tokens.next, state.tokens.next.value);
  5676. }
  5677. }
  5678. value = expression(prefix ? 120 : 10);
  5679. if (lone) {
  5680. tokens[0].first = value;
  5681. } else {
  5682. destructuringPatternMatch(names, value);
  5683. }
  5684. }
  5685. if (state.tokens.next.id !== ",") {
  5686. break;
  5687. }
  5688. comma();
  5689. }
  5690. return this;
  5691. });
  5692. varstatement.exps = true;
  5693. blockstmt("class", function() {
  5694. return classdef.call(this, true);
  5695. });
  5696. function classdef(isStatement) {
  5697. if (!state.inES6()) {
  5698. warning("W104", state.tokens.curr, "class", "6");
  5699. }
  5700. if (isStatement) {
  5701. this.name = identifier();
  5702. state.funct["(scope)"].addlabel(this.name, {
  5703. type: "class",
  5704. token: state.tokens.curr });
  5705. } else if (state.tokens.next.identifier && state.tokens.next.value !== "extends") {
  5706. this.name = identifier();
  5707. this.namedExpr = true;
  5708. } else {
  5709. this.name = state.nameStack.infer();
  5710. }
  5711. classtail(this);
  5712. return this;
  5713. }
  5714. function classtail(c) {
  5715. var wasInClassBody = state.inClassBody;
  5716. if (state.tokens.next.value === "extends") {
  5717. advance("extends");
  5718. c.heritage = expression(10);
  5719. }
  5720. state.inClassBody = true;
  5721. advance("{");
  5722. c.body = classbody(c);
  5723. advance("}");
  5724. state.inClassBody = wasInClassBody;
  5725. }
  5726. function classbody(c) {
  5727. var name;
  5728. var isStatic;
  5729. var isGenerator;
  5730. var getset;
  5731. var props = Object.create(null);
  5732. var staticProps = Object.create(null);
  5733. var computed;
  5734. for (var i = 0; state.tokens.next.id !== "}"; ++i) {
  5735. name = state.tokens.next;
  5736. isStatic = false;
  5737. isGenerator = false;
  5738. getset = null;
  5739. if (name.id === ";") {
  5740. warning("W032");
  5741. advance(";");
  5742. continue;
  5743. }
  5744. if (name.id === "*") {
  5745. isGenerator = true;
  5746. advance("*");
  5747. name = state.tokens.next;
  5748. }
  5749. if (name.id === "[") {
  5750. name = computedPropertyName();
  5751. computed = true;
  5752. } else if (isPropertyName(name)) {
  5753. advance();
  5754. computed = false;
  5755. if (name.identifier && name.value === "static") {
  5756. if (checkPunctuator(state.tokens.next, "*")) {
  5757. isGenerator = true;
  5758. advance("*");
  5759. }
  5760. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  5761. computed = state.tokens.next.id === "[";
  5762. isStatic = true;
  5763. name = state.tokens.next;
  5764. if (state.tokens.next.id === "[") {
  5765. name = computedPropertyName();
  5766. } else advance();
  5767. }
  5768. }
  5769. if (name.identifier && (name.value === "get" || name.value === "set")) {
  5770. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  5771. computed = state.tokens.next.id === "[";
  5772. getset = name;
  5773. name = state.tokens.next;
  5774. if (state.tokens.next.id === "[") {
  5775. name = computedPropertyName();
  5776. } else advance();
  5777. }
  5778. }
  5779. } else {
  5780. warning("W052", state.tokens.next, state.tokens.next.value || state.tokens.next.type);
  5781. advance();
  5782. continue;
  5783. }
  5784. if (!checkPunctuator(state.tokens.next, "(")) {
  5785. error("E054", state.tokens.next, state.tokens.next.value);
  5786. while (state.tokens.next.id !== "}" &&
  5787. !checkPunctuator(state.tokens.next, "(")) {
  5788. advance();
  5789. }
  5790. if (state.tokens.next.value !== "(") {
  5791. doFunction({ statement: c });
  5792. }
  5793. }
  5794. if (!computed) {
  5795. if (getset) {
  5796. saveAccessor(
  5797. getset.value, isStatic ? staticProps : props, name.value, name, true, isStatic);
  5798. } else {
  5799. if (name.value === "constructor") {
  5800. state.nameStack.set(c);
  5801. } else {
  5802. state.nameStack.set(name);
  5803. }
  5804. saveProperty(isStatic ? staticProps : props, name.value, name, true, isStatic);
  5805. }
  5806. }
  5807. if (getset && name.value === "constructor") {
  5808. var propDesc = getset.value === "get" ? "class getter method" : "class setter method";
  5809. error("E049", name, propDesc, "constructor");
  5810. } else if (name.value === "prototype") {
  5811. error("E049", name, "class method", "prototype");
  5812. }
  5813. propertyName(name);
  5814. doFunction({
  5815. statement: c,
  5816. type: isGenerator ? "generator" : null,
  5817. classExprBinding: c.namedExpr ? c.name : null
  5818. });
  5819. }
  5820. checkProperties(props);
  5821. }
  5822. blockstmt("function", function(context) {
  5823. var inexport = context && context.inexport;
  5824. var generator = false;
  5825. if (state.tokens.next.value === "*") {
  5826. advance("*");
  5827. if (state.inES6({ strict: true })) {
  5828. generator = true;
  5829. } else {
  5830. warning("W119", state.tokens.curr, "function*", "6");
  5831. }
  5832. }
  5833. if (inblock) {
  5834. warning("W082", state.tokens.curr);
  5835. }
  5836. var i = optionalidentifier();
  5837. state.funct["(scope)"].addlabel(i, {
  5838. type: "function",
  5839. token: state.tokens.curr });
  5840. if (i === undefined) {
  5841. warning("W025");
  5842. } else if (inexport) {
  5843. state.funct["(scope)"].setExported(i, state.tokens.prev);
  5844. }
  5845. doFunction({
  5846. name: i,
  5847. statement: this,
  5848. type: generator ? "generator" : null,
  5849. ignoreLoopFunc: inblock // a declaration may already have warned
  5850. });
  5851. if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) {
  5852. error("E039");
  5853. }
  5854. return this;
  5855. });
  5856. prefix("function", function() {
  5857. var generator = false;
  5858. if (state.tokens.next.value === "*") {
  5859. if (!state.inES6()) {
  5860. warning("W119", state.tokens.curr, "function*", "6");
  5861. }
  5862. advance("*");
  5863. generator = true;
  5864. }
  5865. var i = optionalidentifier();
  5866. doFunction({ name: i, type: generator ? "generator" : null });
  5867. return this;
  5868. });
  5869. blockstmt("if", function() {
  5870. var t = state.tokens.next;
  5871. increaseComplexityCount();
  5872. state.condition = true;
  5873. advance("(");
  5874. var expr = expression(0);
  5875. checkCondAssignment(expr);
  5876. var forinifcheck = null;
  5877. if (state.option.forin && state.forinifcheckneeded) {
  5878. state.forinifcheckneeded = false; // We only need to analyze the first if inside the loop
  5879. forinifcheck = state.forinifchecks[state.forinifchecks.length - 1];
  5880. if (expr.type === "(punctuator)" && expr.value === "!") {
  5881. forinifcheck.type = "(negative)";
  5882. } else {
  5883. forinifcheck.type = "(positive)";
  5884. }
  5885. }
  5886. advance(")", t);
  5887. state.condition = false;
  5888. var s = block(true, true);
  5889. if (forinifcheck && forinifcheck.type === "(negative)") {
  5890. if (s && s[0] && s[0].type === "(identifier)" && s[0].value === "continue") {
  5891. forinifcheck.type = "(negative-with-continue)";
  5892. }
  5893. }
  5894. if (state.tokens.next.id === "else") {
  5895. advance("else");
  5896. if (state.tokens.next.id === "if" || state.tokens.next.id === "switch") {
  5897. statement();
  5898. } else {
  5899. block(true, true);
  5900. }
  5901. }
  5902. return this;
  5903. });
  5904. blockstmt("try", function() {
  5905. var b;
  5906. function doCatch() {
  5907. advance("catch");
  5908. advance("(");
  5909. state.funct["(scope)"].stack("catchparams");
  5910. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  5911. var tokens = destructuringPattern();
  5912. _.each(tokens, function(token) {
  5913. if (token.id) {
  5914. state.funct["(scope)"].addParam(token.id, token, "exception");
  5915. }
  5916. });
  5917. } else if (state.tokens.next.type !== "(identifier)") {
  5918. warning("E030", state.tokens.next, state.tokens.next.value);
  5919. } else {
  5920. state.funct["(scope)"].addParam(identifier(), state.tokens.curr, "exception");
  5921. }
  5922. if (state.tokens.next.value === "if") {
  5923. if (!state.inMoz()) {
  5924. warning("W118", state.tokens.curr, "catch filter");
  5925. }
  5926. advance("if");
  5927. expression(0);
  5928. }
  5929. advance(")");
  5930. block(false);
  5931. state.funct["(scope)"].unstack();
  5932. }
  5933. block(true);
  5934. while (state.tokens.next.id === "catch") {
  5935. increaseComplexityCount();
  5936. if (b && (!state.inMoz())) {
  5937. warning("W118", state.tokens.next, "multiple catch blocks");
  5938. }
  5939. doCatch();
  5940. b = true;
  5941. }
  5942. if (state.tokens.next.id === "finally") {
  5943. advance("finally");
  5944. block(true);
  5945. return;
  5946. }
  5947. if (!b) {
  5948. error("E021", state.tokens.next, "catch", state.tokens.next.value);
  5949. }
  5950. return this;
  5951. });
  5952. blockstmt("while", function() {
  5953. var t = state.tokens.next;
  5954. state.funct["(breakage)"] += 1;
  5955. state.funct["(loopage)"] += 1;
  5956. increaseComplexityCount();
  5957. advance("(");
  5958. checkCondAssignment(expression(0));
  5959. advance(")", t);
  5960. block(true, true);
  5961. state.funct["(breakage)"] -= 1;
  5962. state.funct["(loopage)"] -= 1;
  5963. return this;
  5964. }).labelled = true;
  5965. blockstmt("with", function() {
  5966. var t = state.tokens.next;
  5967. if (state.isStrict()) {
  5968. error("E010", state.tokens.curr);
  5969. } else if (!state.option.withstmt) {
  5970. warning("W085", state.tokens.curr);
  5971. }
  5972. advance("(");
  5973. expression(0);
  5974. advance(")", t);
  5975. block(true, true);
  5976. return this;
  5977. });
  5978. blockstmt("switch", function() {
  5979. var t = state.tokens.next;
  5980. var g = false;
  5981. var noindent = false;
  5982. state.funct["(breakage)"] += 1;
  5983. advance("(");
  5984. checkCondAssignment(expression(0));
  5985. advance(")", t);
  5986. t = state.tokens.next;
  5987. advance("{");
  5988. if (state.tokens.next.from === indent)
  5989. noindent = true;
  5990. if (!noindent)
  5991. indent += state.option.indent;
  5992. this.cases = [];
  5993. for (;;) {
  5994. switch (state.tokens.next.id) {
  5995. case "case":
  5996. switch (state.funct["(verb)"]) {
  5997. case "yield":
  5998. case "break":
  5999. case "case":
  6000. case "continue":
  6001. case "return":
  6002. case "switch":
  6003. case "throw":
  6004. break;
  6005. default:
  6006. if (!state.tokens.curr.caseFallsThrough) {
  6007. warning("W086", state.tokens.curr, "case");
  6008. }
  6009. }
  6010. advance("case");
  6011. this.cases.push(expression(0));
  6012. increaseComplexityCount();
  6013. g = true;
  6014. advance(":");
  6015. state.funct["(verb)"] = "case";
  6016. break;
  6017. case "default":
  6018. switch (state.funct["(verb)"]) {
  6019. case "yield":
  6020. case "break":
  6021. case "continue":
  6022. case "return":
  6023. case "throw":
  6024. break;
  6025. default:
  6026. if (this.cases.length) {
  6027. if (!state.tokens.curr.caseFallsThrough) {
  6028. warning("W086", state.tokens.curr, "default");
  6029. }
  6030. }
  6031. }
  6032. advance("default");
  6033. g = true;
  6034. advance(":");
  6035. break;
  6036. case "}":
  6037. if (!noindent)
  6038. indent -= state.option.indent;
  6039. advance("}", t);
  6040. state.funct["(breakage)"] -= 1;
  6041. state.funct["(verb)"] = undefined;
  6042. return;
  6043. case "(end)":
  6044. error("E023", state.tokens.next, "}");
  6045. return;
  6046. default:
  6047. indent += state.option.indent;
  6048. if (g) {
  6049. switch (state.tokens.curr.id) {
  6050. case ",":
  6051. error("E040");
  6052. return;
  6053. case ":":
  6054. g = false;
  6055. statements();
  6056. break;
  6057. default:
  6058. error("E025", state.tokens.curr);
  6059. return;
  6060. }
  6061. } else {
  6062. if (state.tokens.curr.id === ":") {
  6063. advance(":");
  6064. error("E024", state.tokens.curr, ":");
  6065. statements();
  6066. } else {
  6067. error("E021", state.tokens.next, "case", state.tokens.next.value);
  6068. return;
  6069. }
  6070. }
  6071. indent -= state.option.indent;
  6072. }
  6073. }
  6074. return this;
  6075. }).labelled = true;
  6076. stmt("debugger", function() {
  6077. if (!state.option.debug) {
  6078. warning("W087", this);
  6079. }
  6080. return this;
  6081. }).exps = true;
  6082. (function() {
  6083. var x = stmt("do", function() {
  6084. state.funct["(breakage)"] += 1;
  6085. state.funct["(loopage)"] += 1;
  6086. increaseComplexityCount();
  6087. this.first = block(true, true);
  6088. advance("while");
  6089. var t = state.tokens.next;
  6090. advance("(");
  6091. checkCondAssignment(expression(0));
  6092. advance(")", t);
  6093. state.funct["(breakage)"] -= 1;
  6094. state.funct["(loopage)"] -= 1;
  6095. return this;
  6096. });
  6097. x.labelled = true;
  6098. x.exps = true;
  6099. }());
  6100. blockstmt("for", function() {
  6101. var s, t = state.tokens.next;
  6102. var letscope = false;
  6103. var foreachtok = null;
  6104. if (t.value === "each") {
  6105. foreachtok = t;
  6106. advance("each");
  6107. if (!state.inMoz()) {
  6108. warning("W118", state.tokens.curr, "for each");
  6109. }
  6110. }
  6111. increaseComplexityCount();
  6112. advance("(");
  6113. var nextop; // contains the token of the "in" or "of" operator
  6114. var i = 0;
  6115. var inof = ["in", "of"];
  6116. var level = 0; // BindingPattern "level" --- level 0 === no BindingPattern
  6117. var comma; // First comma punctuator at level 0
  6118. var initializer; // First initializer at level 0
  6119. if (checkPunctuators(state.tokens.next, ["{", "["])) ++level;
  6120. do {
  6121. nextop = peek(i);
  6122. ++i;
  6123. if (checkPunctuators(nextop, ["{", "["])) ++level;
  6124. else if (checkPunctuators(nextop, ["}", "]"])) --level;
  6125. if (level < 0) break;
  6126. if (level === 0) {
  6127. if (!comma && checkPunctuator(nextop, ",")) comma = nextop;
  6128. else if (!initializer && checkPunctuator(nextop, "=")) initializer = nextop;
  6129. }
  6130. } while (level > 0 || !_.contains(inof, nextop.value) && nextop.value !== ";" &&
  6131. nextop.type !== "(end)"); // Is this a JSCS bug? This looks really weird.
  6132. if (_.contains(inof, nextop.value)) {
  6133. if (!state.inES6() && nextop.value === "of") {
  6134. warning("W104", nextop, "for of", "6");
  6135. }
  6136. var ok = !(initializer || comma);
  6137. if (initializer) {
  6138. error("W133", comma, nextop.value, "initializer is forbidden");
  6139. }
  6140. if (comma) {
  6141. error("W133", comma, nextop.value, "more than one ForBinding");
  6142. }
  6143. if (state.tokens.next.id === "var") {
  6144. advance("var");
  6145. state.tokens.curr.fud({ prefix: true });
  6146. } else if (state.tokens.next.id === "let" || state.tokens.next.id === "const") {
  6147. advance(state.tokens.next.id);
  6148. letscope = true;
  6149. state.funct["(scope)"].stack();
  6150. state.tokens.curr.fud({ prefix: true });
  6151. } else {
  6152. Object.create(varstatement).fud({ prefix: true, implied: "for", ignore: !ok });
  6153. }
  6154. advance(nextop.value);
  6155. expression(20);
  6156. advance(")", t);
  6157. if (nextop.value === "in" && state.option.forin) {
  6158. state.forinifcheckneeded = true;
  6159. if (state.forinifchecks === undefined) {
  6160. state.forinifchecks = [];
  6161. }
  6162. state.forinifchecks.push({
  6163. type: "(none)"
  6164. });
  6165. }
  6166. state.funct["(breakage)"] += 1;
  6167. state.funct["(loopage)"] += 1;
  6168. s = block(true, true);
  6169. if (nextop.value === "in" && state.option.forin) {
  6170. if (state.forinifchecks && state.forinifchecks.length > 0) {
  6171. var check = state.forinifchecks.pop();
  6172. if (// No if statement or not the first statement in loop body
  6173. s && s.length > 0 && (typeof s[0] !== "object" || s[0].value !== "if") ||
  6174. check.type === "(positive)" && s.length > 1 ||
  6175. check.type === "(negative)") {
  6176. warning("W089", this);
  6177. }
  6178. }
  6179. state.forinifcheckneeded = false;
  6180. }
  6181. state.funct["(breakage)"] -= 1;
  6182. state.funct["(loopage)"] -= 1;
  6183. } else {
  6184. if (foreachtok) {
  6185. error("E045", foreachtok);
  6186. }
  6187. if (state.tokens.next.id !== ";") {
  6188. if (state.tokens.next.id === "var") {
  6189. advance("var");
  6190. state.tokens.curr.fud();
  6191. } else if (state.tokens.next.id === "let") {
  6192. advance("let");
  6193. letscope = true;
  6194. state.funct["(scope)"].stack();
  6195. state.tokens.curr.fud();
  6196. } else {
  6197. for (;;) {
  6198. expression(0, "for");
  6199. if (state.tokens.next.id !== ",") {
  6200. break;
  6201. }
  6202. comma();
  6203. }
  6204. }
  6205. }
  6206. nolinebreak(state.tokens.curr);
  6207. advance(";");
  6208. state.funct["(loopage)"] += 1;
  6209. if (state.tokens.next.id !== ";") {
  6210. checkCondAssignment(expression(0));
  6211. }
  6212. nolinebreak(state.tokens.curr);
  6213. advance(";");
  6214. if (state.tokens.next.id === ";") {
  6215. error("E021", state.tokens.next, ")", ";");
  6216. }
  6217. if (state.tokens.next.id !== ")") {
  6218. for (;;) {
  6219. expression(0, "for");
  6220. if (state.tokens.next.id !== ",") {
  6221. break;
  6222. }
  6223. comma();
  6224. }
  6225. }
  6226. advance(")", t);
  6227. state.funct["(breakage)"] += 1;
  6228. block(true, true);
  6229. state.funct["(breakage)"] -= 1;
  6230. state.funct["(loopage)"] -= 1;
  6231. }
  6232. if (letscope) {
  6233. state.funct["(scope)"].unstack();
  6234. }
  6235. return this;
  6236. }).labelled = true;
  6237. stmt("break", function() {
  6238. var v = state.tokens.next.value;
  6239. if (!state.option.asi)
  6240. nolinebreak(this);
  6241. if (state.tokens.next.id !== ";" && !state.tokens.next.reach &&
  6242. state.tokens.curr.line === startLine(state.tokens.next)) {
  6243. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  6244. warning("W090", state.tokens.next, v);
  6245. }
  6246. this.first = state.tokens.next;
  6247. advance();
  6248. } else {
  6249. if (state.funct["(breakage)"] === 0)
  6250. warning("W052", state.tokens.next, this.value);
  6251. }
  6252. reachable(this);
  6253. return this;
  6254. }).exps = true;
  6255. stmt("continue", function() {
  6256. var v = state.tokens.next.value;
  6257. if (state.funct["(breakage)"] === 0)
  6258. warning("W052", state.tokens.next, this.value);
  6259. if (!state.funct["(loopage)"])
  6260. warning("W052", state.tokens.next, this.value);
  6261. if (!state.option.asi)
  6262. nolinebreak(this);
  6263. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  6264. if (state.tokens.curr.line === startLine(state.tokens.next)) {
  6265. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  6266. warning("W090", state.tokens.next, v);
  6267. }
  6268. this.first = state.tokens.next;
  6269. advance();
  6270. }
  6271. }
  6272. reachable(this);
  6273. return this;
  6274. }).exps = true;
  6275. stmt("return", function() {
  6276. if (this.line === startLine(state.tokens.next)) {
  6277. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  6278. this.first = expression(0);
  6279. if (this.first &&
  6280. this.first.type === "(punctuator)" && this.first.value === "=" &&
  6281. !this.first.paren && !state.option.boss) {
  6282. warningAt("W093", this.first.line, this.first.character);
  6283. }
  6284. }
  6285. } else {
  6286. if (state.tokens.next.type === "(punctuator)" &&
  6287. ["[", "{", "+", "-"].indexOf(state.tokens.next.value) > -1) {
  6288. nolinebreak(this); // always warn (Line breaking error)
  6289. }
  6290. }
  6291. reachable(this);
  6292. return this;
  6293. }).exps = true;
  6294. (function(x) {
  6295. x.exps = true;
  6296. x.lbp = 25;
  6297. }(prefix("yield", function() {
  6298. var prev = state.tokens.prev;
  6299. if (state.inES6(true) && !state.funct["(generator)"]) {
  6300. if (!("(catch)" === state.funct["(name)"] && state.funct["(context)"]["(generator)"])) {
  6301. error("E046", state.tokens.curr, "yield");
  6302. }
  6303. } else if (!state.inES6()) {
  6304. warning("W104", state.tokens.curr, "yield", "6");
  6305. }
  6306. state.funct["(generator)"] = "yielded";
  6307. var delegatingYield = false;
  6308. if (state.tokens.next.value === "*") {
  6309. delegatingYield = true;
  6310. advance("*");
  6311. }
  6312. if (this.line === startLine(state.tokens.next) || !state.inMoz()) {
  6313. if (delegatingYield ||
  6314. (state.tokens.next.id !== ";" && !state.option.asi &&
  6315. !state.tokens.next.reach && state.tokens.next.nud)) {
  6316. nobreaknonadjacent(state.tokens.curr, state.tokens.next);
  6317. this.first = expression(10);
  6318. if (this.first.type === "(punctuator)" && this.first.value === "=" &&
  6319. !this.first.paren && !state.option.boss) {
  6320. warningAt("W093", this.first.line, this.first.character);
  6321. }
  6322. }
  6323. if (state.inMoz() && state.tokens.next.id !== ")" &&
  6324. (prev.lbp > 30 || (!prev.assign && !isEndOfExpr()) || prev.id === "yield")) {
  6325. error("E050", this);
  6326. }
  6327. } else if (!state.option.asi) {
  6328. nolinebreak(this); // always warn (Line breaking error)
  6329. }
  6330. return this;
  6331. })));
  6332. stmt("throw", function() {
  6333. nolinebreak(this);
  6334. this.first = expression(20);
  6335. reachable(this);
  6336. return this;
  6337. }).exps = true;
  6338. stmt("import", function() {
  6339. if (!state.inES6()) {
  6340. warning("W119", state.tokens.curr, "import", "6");
  6341. }
  6342. if (state.tokens.next.type === "(string)") {
  6343. advance("(string)");
  6344. return this;
  6345. }
  6346. if (state.tokens.next.identifier) {
  6347. this.name = identifier();
  6348. state.funct["(scope)"].addlabel(this.name, {
  6349. type: "const",
  6350. token: state.tokens.curr });
  6351. if (state.tokens.next.value === ",") {
  6352. advance(",");
  6353. } else {
  6354. advance("from");
  6355. advance("(string)");
  6356. return this;
  6357. }
  6358. }
  6359. if (state.tokens.next.id === "*") {
  6360. advance("*");
  6361. advance("as");
  6362. if (state.tokens.next.identifier) {
  6363. this.name = identifier();
  6364. state.funct["(scope)"].addlabel(this.name, {
  6365. type: "const",
  6366. token: state.tokens.curr });
  6367. }
  6368. } else {
  6369. advance("{");
  6370. for (;;) {
  6371. if (state.tokens.next.value === "}") {
  6372. advance("}");
  6373. break;
  6374. }
  6375. var importName;
  6376. if (state.tokens.next.type === "default") {
  6377. importName = "default";
  6378. advance("default");
  6379. } else {
  6380. importName = identifier();
  6381. }
  6382. if (state.tokens.next.value === "as") {
  6383. advance("as");
  6384. importName = identifier();
  6385. }
  6386. state.funct["(scope)"].addlabel(importName, {
  6387. type: "const",
  6388. token: state.tokens.curr });
  6389. if (state.tokens.next.value === ",") {
  6390. advance(",");
  6391. } else if (state.tokens.next.value === "}") {
  6392. advance("}");
  6393. break;
  6394. } else {
  6395. error("E024", state.tokens.next, state.tokens.next.value);
  6396. break;
  6397. }
  6398. }
  6399. }
  6400. advance("from");
  6401. advance("(string)");
  6402. return this;
  6403. }).exps = true;
  6404. stmt("export", function() {
  6405. var ok = true;
  6406. var token;
  6407. var identifier;
  6408. if (!state.inES6()) {
  6409. warning("W119", state.tokens.curr, "export", "6");
  6410. ok = false;
  6411. }
  6412. if (!state.funct["(scope)"].block.isGlobal()) {
  6413. error("E053", state.tokens.curr);
  6414. ok = false;
  6415. }
  6416. if (state.tokens.next.value === "*") {
  6417. advance("*");
  6418. advance("from");
  6419. advance("(string)");
  6420. return this;
  6421. }
  6422. if (state.tokens.next.type === "default") {
  6423. state.nameStack.set(state.tokens.next);
  6424. advance("default");
  6425. var exportType = state.tokens.next.id;
  6426. if (exportType === "function" || exportType === "class") {
  6427. this.block = true;
  6428. }
  6429. token = peek();
  6430. expression(10);
  6431. identifier = token.value;
  6432. if (this.block) {
  6433. state.funct["(scope)"].addlabel(identifier, {
  6434. type: exportType,
  6435. token: token });
  6436. state.funct["(scope)"].setExported(identifier, token);
  6437. }
  6438. return this;
  6439. }
  6440. if (state.tokens.next.value === "{") {
  6441. advance("{");
  6442. var exportedTokens = [];
  6443. for (;;) {
  6444. if (!state.tokens.next.identifier) {
  6445. error("E030", state.tokens.next, state.tokens.next.value);
  6446. }
  6447. advance();
  6448. exportedTokens.push(state.tokens.curr);
  6449. if (state.tokens.next.value === "as") {
  6450. advance("as");
  6451. if (!state.tokens.next.identifier) {
  6452. error("E030", state.tokens.next, state.tokens.next.value);
  6453. }
  6454. advance();
  6455. }
  6456. if (state.tokens.next.value === ",") {
  6457. advance(",");
  6458. } else if (state.tokens.next.value === "}") {
  6459. advance("}");
  6460. break;
  6461. } else {
  6462. error("E024", state.tokens.next, state.tokens.next.value);
  6463. break;
  6464. }
  6465. }
  6466. if (state.tokens.next.value === "from") {
  6467. advance("from");
  6468. advance("(string)");
  6469. } else if (ok) {
  6470. exportedTokens.forEach(function(token) {
  6471. state.funct["(scope)"].setExported(token.value, token);
  6472. });
  6473. }
  6474. return this;
  6475. }
  6476. if (state.tokens.next.id === "var") {
  6477. advance("var");
  6478. state.tokens.curr.fud({ inexport:true });
  6479. } else if (state.tokens.next.id === "let") {
  6480. advance("let");
  6481. state.tokens.curr.fud({ inexport:true });
  6482. } else if (state.tokens.next.id === "const") {
  6483. advance("const");
  6484. state.tokens.curr.fud({ inexport:true });
  6485. } else if (state.tokens.next.id === "function") {
  6486. this.block = true;
  6487. advance("function");
  6488. state.syntax["function"].fud({ inexport:true });
  6489. } else if (state.tokens.next.id === "class") {
  6490. this.block = true;
  6491. advance("class");
  6492. var classNameToken = state.tokens.next;
  6493. state.syntax["class"].fud();
  6494. state.funct["(scope)"].setExported(classNameToken.value, classNameToken);
  6495. } else {
  6496. error("E024", state.tokens.next, state.tokens.next.value);
  6497. }
  6498. return this;
  6499. }).exps = true;
  6500. FutureReservedWord("abstract");
  6501. FutureReservedWord("boolean");
  6502. FutureReservedWord("byte");
  6503. FutureReservedWord("char");
  6504. FutureReservedWord("class", { es5: true, nud: classdef });
  6505. FutureReservedWord("double");
  6506. FutureReservedWord("enum", { es5: true });
  6507. FutureReservedWord("export", { es5: true });
  6508. FutureReservedWord("extends", { es5: true });
  6509. FutureReservedWord("final");
  6510. FutureReservedWord("float");
  6511. FutureReservedWord("goto");
  6512. FutureReservedWord("implements", { es5: true, strictOnly: true });
  6513. FutureReservedWord("import", { es5: true });
  6514. FutureReservedWord("int");
  6515. FutureReservedWord("interface", { es5: true, strictOnly: true });
  6516. FutureReservedWord("long");
  6517. FutureReservedWord("native");
  6518. FutureReservedWord("package", { es5: true, strictOnly: true });
  6519. FutureReservedWord("private", { es5: true, strictOnly: true });
  6520. FutureReservedWord("protected", { es5: true, strictOnly: true });
  6521. FutureReservedWord("public", { es5: true, strictOnly: true });
  6522. FutureReservedWord("short");
  6523. FutureReservedWord("static", { es5: true, strictOnly: true });
  6524. FutureReservedWord("super", { es5: true });
  6525. FutureReservedWord("synchronized");
  6526. FutureReservedWord("transient");
  6527. FutureReservedWord("volatile");
  6528. var lookupBlockType = function() {
  6529. var pn, pn1, prev;
  6530. var i = -1;
  6531. var bracketStack = 0;
  6532. var ret = {};
  6533. if (checkPunctuators(state.tokens.curr, ["[", "{"])) {
  6534. bracketStack += 1;
  6535. }
  6536. do {
  6537. prev = i === -1 ? state.tokens.curr : pn;
  6538. pn = i === -1 ? state.tokens.next : peek(i);
  6539. pn1 = peek(i + 1);
  6540. i = i + 1;
  6541. if (checkPunctuators(pn, ["[", "{"])) {
  6542. bracketStack += 1;
  6543. } else if (checkPunctuators(pn, ["]", "}"])) {
  6544. bracketStack -= 1;
  6545. }
  6546. if (bracketStack === 1 && pn.identifier && pn.value === "for" &&
  6547. !checkPunctuator(prev, ".")) {
  6548. ret.isCompArray = true;
  6549. ret.notJson = true;
  6550. break;
  6551. }
  6552. if (bracketStack === 0 && checkPunctuators(pn, ["}", "]"])) {
  6553. if (pn1.value === "=") {
  6554. ret.isDestAssign = true;
  6555. ret.notJson = true;
  6556. break;
  6557. } else if (pn1.value === ".") {
  6558. ret.notJson = true;
  6559. break;
  6560. }
  6561. }
  6562. if (checkPunctuator(pn, ";")) {
  6563. ret.isBlock = true;
  6564. ret.notJson = true;
  6565. }
  6566. } while (bracketStack > 0 && pn.id !== "(end)");
  6567. return ret;
  6568. };
  6569. function saveProperty(props, name, tkn, isClass, isStatic) {
  6570. var msg = ["key", "class method", "static class method"];
  6571. msg = msg[(isClass || false) + (isStatic || false)];
  6572. if (tkn.identifier) {
  6573. name = tkn.value;
  6574. }
  6575. if (props[name] && name !== "__proto__") {
  6576. warning("W075", state.tokens.next, msg, name);
  6577. } else {
  6578. props[name] = Object.create(null);
  6579. }
  6580. props[name].basic = true;
  6581. props[name].basictkn = tkn;
  6582. }
  6583. function saveAccessor(accessorType, props, name, tkn, isClass, isStatic) {
  6584. var flagName = accessorType === "get" ? "getterToken" : "setterToken";
  6585. var msg = "";
  6586. if (isClass) {
  6587. if (isStatic) {
  6588. msg += "static ";
  6589. }
  6590. msg += accessorType + "ter method";
  6591. } else {
  6592. msg = "key";
  6593. }
  6594. state.tokens.curr.accessorType = accessorType;
  6595. state.nameStack.set(tkn);
  6596. if (props[name]) {
  6597. if ((props[name].basic || props[name][flagName]) && name !== "__proto__") {
  6598. warning("W075", state.tokens.next, msg, name);
  6599. }
  6600. } else {
  6601. props[name] = Object.create(null);
  6602. }
  6603. props[name][flagName] = tkn;
  6604. }
  6605. function computedPropertyName() {
  6606. advance("[");
  6607. if (!state.inES6()) {
  6608. warning("W119", state.tokens.curr, "computed property names", "6");
  6609. }
  6610. var value = expression(10);
  6611. advance("]");
  6612. return value;
  6613. }
  6614. function checkPunctuators(token, values) {
  6615. if (token.type === "(punctuator)") {
  6616. return _.contains(values, token.value);
  6617. }
  6618. return false;
  6619. }
  6620. function checkPunctuator(token, value) {
  6621. return token.type === "(punctuator)" && token.value === value;
  6622. }
  6623. function destructuringAssignOrJsonValue() {
  6624. var block = lookupBlockType();
  6625. if (block.notJson) {
  6626. if (!state.inES6() && block.isDestAssign) {
  6627. warning("W104", state.tokens.curr, "destructuring assignment", "6");
  6628. }
  6629. statements();
  6630. } else {
  6631. state.option.laxbreak = true;
  6632. state.jsonMode = true;
  6633. jsonValue();
  6634. }
  6635. }
  6636. var arrayComprehension = function() {
  6637. var CompArray = function() {
  6638. this.mode = "use";
  6639. this.variables = [];
  6640. };
  6641. var _carrays = [];
  6642. var _current;
  6643. function declare(v) {
  6644. var l = _current.variables.filter(function(elt) {
  6645. if (elt.value === v) {
  6646. elt.undef = false;
  6647. return v;
  6648. }
  6649. }).length;
  6650. return l !== 0;
  6651. }
  6652. function use(v) {
  6653. var l = _current.variables.filter(function(elt) {
  6654. if (elt.value === v && !elt.undef) {
  6655. if (elt.unused === true) {
  6656. elt.unused = false;
  6657. }
  6658. return v;
  6659. }
  6660. }).length;
  6661. return (l === 0);
  6662. }
  6663. return { stack: function() {
  6664. _current = new CompArray();
  6665. _carrays.push(_current);
  6666. },
  6667. unstack: function() {
  6668. _current.variables.filter(function(v) {
  6669. if (v.unused)
  6670. warning("W098", v.token, v.raw_text || v.value);
  6671. if (v.undef)
  6672. state.funct["(scope)"].block.use(v.value, v.token);
  6673. });
  6674. _carrays.splice(-1, 1);
  6675. _current = _carrays[_carrays.length - 1];
  6676. },
  6677. setState: function(s) {
  6678. if (_.contains(["use", "define", "generate", "filter"], s))
  6679. _current.mode = s;
  6680. },
  6681. check: function(v) {
  6682. if (!_current) {
  6683. return;
  6684. }
  6685. if (_current && _current.mode === "use") {
  6686. if (use(v)) {
  6687. _current.variables.push({
  6688. funct: state.funct,
  6689. token: state.tokens.curr,
  6690. value: v,
  6691. undef: true,
  6692. unused: false
  6693. });
  6694. }
  6695. return true;
  6696. } else if (_current && _current.mode === "define") {
  6697. if (!declare(v)) {
  6698. _current.variables.push({
  6699. funct: state.funct,
  6700. token: state.tokens.curr,
  6701. value: v,
  6702. undef: false,
  6703. unused: true
  6704. });
  6705. }
  6706. return true;
  6707. } else if (_current && _current.mode === "generate") {
  6708. state.funct["(scope)"].block.use(v, state.tokens.curr);
  6709. return true;
  6710. } else if (_current && _current.mode === "filter") {
  6711. if (use(v)) {
  6712. state.funct["(scope)"].block.use(v, state.tokens.curr);
  6713. }
  6714. return true;
  6715. }
  6716. return false;
  6717. }
  6718. };
  6719. };
  6720. function jsonValue() {
  6721. function jsonObject() {
  6722. var o = {}, t = state.tokens.next;
  6723. advance("{");
  6724. if (state.tokens.next.id !== "}") {
  6725. for (;;) {
  6726. if (state.tokens.next.id === "(end)") {
  6727. error("E026", state.tokens.next, t.line);
  6728. } else if (state.tokens.next.id === "}") {
  6729. warning("W094", state.tokens.curr);
  6730. break;
  6731. } else if (state.tokens.next.id === ",") {
  6732. error("E028", state.tokens.next);
  6733. } else if (state.tokens.next.id !== "(string)") {
  6734. warning("W095", state.tokens.next, state.tokens.next.value);
  6735. }
  6736. if (o[state.tokens.next.value] === true) {
  6737. warning("W075", state.tokens.next, "key", state.tokens.next.value);
  6738. } else if ((state.tokens.next.value === "__proto__" &&
  6739. !state.option.proto) || (state.tokens.next.value === "__iterator__" &&
  6740. !state.option.iterator)) {
  6741. warning("W096", state.tokens.next, state.tokens.next.value);
  6742. } else {
  6743. o[state.tokens.next.value] = true;
  6744. }
  6745. advance();
  6746. advance(":");
  6747. jsonValue();
  6748. if (state.tokens.next.id !== ",") {
  6749. break;
  6750. }
  6751. advance(",");
  6752. }
  6753. }
  6754. advance("}");
  6755. }
  6756. function jsonArray() {
  6757. var t = state.tokens.next;
  6758. advance("[");
  6759. if (state.tokens.next.id !== "]") {
  6760. for (;;) {
  6761. if (state.tokens.next.id === "(end)") {
  6762. error("E027", state.tokens.next, t.line);
  6763. } else if (state.tokens.next.id === "]") {
  6764. warning("W094", state.tokens.curr);
  6765. break;
  6766. } else if (state.tokens.next.id === ",") {
  6767. error("E028", state.tokens.next);
  6768. }
  6769. jsonValue();
  6770. if (state.tokens.next.id !== ",") {
  6771. break;
  6772. }
  6773. advance(",");
  6774. }
  6775. }
  6776. advance("]");
  6777. }
  6778. switch (state.tokens.next.id) {
  6779. case "{":
  6780. jsonObject();
  6781. break;
  6782. case "[":
  6783. jsonArray();
  6784. break;
  6785. case "true":
  6786. case "false":
  6787. case "null":
  6788. case "(number)":
  6789. case "(string)":
  6790. advance();
  6791. break;
  6792. case "-":
  6793. advance("-");
  6794. advance("(number)");
  6795. break;
  6796. default:
  6797. error("E003", state.tokens.next);
  6798. }
  6799. }
  6800. var escapeRegex = function(str) {
  6801. return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
  6802. };
  6803. var itself = function(s, o, g) {
  6804. var i, k, x, reIgnoreStr, reIgnore;
  6805. var optionKeys;
  6806. var newOptionObj = {};
  6807. var newIgnoredObj = {};
  6808. o = _.clone(o);
  6809. state.reset();
  6810. if (o && o.scope) {
  6811. JSHINT.scope = o.scope;
  6812. } else {
  6813. JSHINT.errors = [];
  6814. JSHINT.undefs = [];
  6815. JSHINT.internals = [];
  6816. JSHINT.blacklist = {};
  6817. JSHINT.scope = "(main)";
  6818. }
  6819. predefined = Object.create(null);
  6820. combine(predefined, vars.ecmaIdentifiers[3]);
  6821. combine(predefined, vars.reservedVars);
  6822. combine(predefined, g || {});
  6823. declared = Object.create(null);
  6824. var exported = Object.create(null); // Variables that live outside the current file
  6825. function each(obj, cb) {
  6826. if (!obj)
  6827. return;
  6828. if (!Array.isArray(obj) && typeof obj === "object")
  6829. obj = Object.keys(obj);
  6830. obj.forEach(cb);
  6831. }
  6832. if (o) {
  6833. each(o.predef || null, function(item) {
  6834. var slice, prop;
  6835. if (item[0] === "-") {
  6836. slice = item.slice(1);
  6837. JSHINT.blacklist[slice] = slice;
  6838. delete predefined[slice];
  6839. } else {
  6840. prop = Object.getOwnPropertyDescriptor(o.predef, item);
  6841. predefined[item] = prop ? prop.value : false;
  6842. }
  6843. });
  6844. each(o.exported || null, function(item) {
  6845. exported[item] = true;
  6846. });
  6847. delete o.predef;
  6848. delete o.exported;
  6849. optionKeys = Object.keys(o);
  6850. for (x = 0; x < optionKeys.length; x++) {
  6851. if (/^-W\d{3}$/g.test(optionKeys[x])) {
  6852. newIgnoredObj[optionKeys[x].slice(1)] = true;
  6853. } else {
  6854. var optionKey = optionKeys[x];
  6855. newOptionObj[optionKey] = o[optionKey];
  6856. if ((optionKey === "esversion" && o[optionKey] === 5) ||
  6857. (optionKey === "es5" && o[optionKey])) {
  6858. warning("I003");
  6859. }
  6860. if (optionKeys[x] === "newcap" && o[optionKey] === false)
  6861. newOptionObj["(explicitNewcap)"] = true;
  6862. }
  6863. }
  6864. }
  6865. state.option = newOptionObj;
  6866. state.ignored = newIgnoredObj;
  6867. state.option.indent = state.option.indent || 4;
  6868. state.option.maxerr = state.option.maxerr || 50;
  6869. indent = 1;
  6870. var scopeManagerInst = scopeManager(state, predefined, exported, declared);
  6871. scopeManagerInst.on("warning", function(ev) {
  6872. warning.apply(null, [ ev.code, ev.token].concat(ev.data));
  6873. });
  6874. scopeManagerInst.on("error", function(ev) {
  6875. error.apply(null, [ ev.code, ev.token ].concat(ev.data));
  6876. });
  6877. state.funct = functor("(global)", null, {
  6878. "(global)" : true,
  6879. "(scope)" : scopeManagerInst,
  6880. "(comparray)" : arrayComprehension(),
  6881. "(metrics)" : createMetrics(state.tokens.next)
  6882. });
  6883. functions = [state.funct];
  6884. urls = [];
  6885. stack = null;
  6886. member = {};
  6887. membersOnly = null;
  6888. inblock = false;
  6889. lookahead = [];
  6890. if (!isString(s) && !Array.isArray(s)) {
  6891. errorAt("E004", 0);
  6892. return false;
  6893. }
  6894. api = {
  6895. get isJSON() {
  6896. return state.jsonMode;
  6897. },
  6898. getOption: function(name) {
  6899. return state.option[name] || null;
  6900. },
  6901. getCache: function(name) {
  6902. return state.cache[name];
  6903. },
  6904. setCache: function(name, value) {
  6905. state.cache[name] = value;
  6906. },
  6907. warn: function(code, data) {
  6908. warningAt.apply(null, [ code, data.line, data.char ].concat(data.data));
  6909. },
  6910. on: function(names, listener) {
  6911. names.split(" ").forEach(function(name) {
  6912. emitter.on(name, listener);
  6913. }.bind(this));
  6914. }
  6915. };
  6916. emitter.removeAllListeners();
  6917. (extraModules || []).forEach(function(func) {
  6918. func(api);
  6919. });
  6920. state.tokens.prev = state.tokens.curr = state.tokens.next = state.syntax["(begin)"];
  6921. if (o && o.ignoreDelimiters) {
  6922. if (!Array.isArray(o.ignoreDelimiters)) {
  6923. o.ignoreDelimiters = [o.ignoreDelimiters];
  6924. }
  6925. o.ignoreDelimiters.forEach(function(delimiterPair) {
  6926. if (!delimiterPair.start || !delimiterPair.end)
  6927. return;
  6928. reIgnoreStr = escapeRegex(delimiterPair.start) +
  6929. "[\\s\\S]*?" +
  6930. escapeRegex(delimiterPair.end);
  6931. reIgnore = new RegExp(reIgnoreStr, "ig");
  6932. s = s.replace(reIgnore, function(match) {
  6933. return match.replace(/./g, " ");
  6934. });
  6935. });
  6936. }
  6937. lex = new Lexer(s);
  6938. lex.on("warning", function(ev) {
  6939. warningAt.apply(null, [ ev.code, ev.line, ev.character].concat(ev.data));
  6940. });
  6941. lex.on("error", function(ev) {
  6942. errorAt.apply(null, [ ev.code, ev.line, ev.character ].concat(ev.data));
  6943. });
  6944. lex.on("fatal", function(ev) {
  6945. quit("E041", ev.line, ev.from);
  6946. });
  6947. lex.on("Identifier", function(ev) {
  6948. emitter.emit("Identifier", ev);
  6949. });
  6950. lex.on("String", function(ev) {
  6951. emitter.emit("String", ev);
  6952. });
  6953. lex.on("Number", function(ev) {
  6954. emitter.emit("Number", ev);
  6955. });
  6956. lex.start();
  6957. for (var name in o) {
  6958. if (_.has(o, name)) {
  6959. checkOption(name, state.tokens.curr);
  6960. }
  6961. }
  6962. assume();
  6963. combine(predefined, g || {});
  6964. comma.first = true;
  6965. try {
  6966. advance();
  6967. switch (state.tokens.next.id) {
  6968. case "{":
  6969. case "[":
  6970. destructuringAssignOrJsonValue();
  6971. break;
  6972. default:
  6973. directives();
  6974. if (state.directive["use strict"]) {
  6975. if (state.option.strict !== "global") {
  6976. warning("W097", state.tokens.prev);
  6977. }
  6978. }
  6979. statements();
  6980. }
  6981. if (state.tokens.next.id !== "(end)") {
  6982. quit("E041", state.tokens.curr.line);
  6983. }
  6984. state.funct["(scope)"].unstack();
  6985. } catch (err) {
  6986. if (err && err.name === "JSHintError") {
  6987. var nt = state.tokens.next || {};
  6988. JSHINT.errors.push({
  6989. scope : "(main)",
  6990. raw : err.raw,
  6991. code : err.code,
  6992. reason : err.message,
  6993. line : err.line || nt.line,
  6994. character : err.character || nt.from
  6995. }, null);
  6996. } else {
  6997. throw err;
  6998. }
  6999. }
  7000. if (JSHINT.scope === "(main)") {
  7001. o = o || {};
  7002. for (i = 0; i < JSHINT.internals.length; i += 1) {
  7003. k = JSHINT.internals[i];
  7004. o.scope = k.elem;
  7005. itself(k.value, o, g);
  7006. }
  7007. }
  7008. return JSHINT.errors.length === 0;
  7009. };
  7010. itself.addModule = function(func) {
  7011. extraModules.push(func);
  7012. };
  7013. itself.addModule(style.register);
  7014. itself.data = function() {
  7015. var data = {
  7016. functions: [],
  7017. options: state.option
  7018. };
  7019. var fu, f, i, j, n, globals;
  7020. if (itself.errors.length) {
  7021. data.errors = itself.errors;
  7022. }
  7023. if (state.jsonMode) {
  7024. data.json = true;
  7025. }
  7026. var impliedGlobals = state.funct["(scope)"].getImpliedGlobals();
  7027. if (impliedGlobals.length > 0) {
  7028. data.implieds = impliedGlobals;
  7029. }
  7030. if (urls.length > 0) {
  7031. data.urls = urls;
  7032. }
  7033. globals = state.funct["(scope)"].getUsedOrDefinedGlobals();
  7034. if (globals.length > 0) {
  7035. data.globals = globals;
  7036. }
  7037. for (i = 1; i < functions.length; i += 1) {
  7038. f = functions[i];
  7039. fu = {};
  7040. for (j = 0; j < functionicity.length; j += 1) {
  7041. fu[functionicity[j]] = [];
  7042. }
  7043. for (j = 0; j < functionicity.length; j += 1) {
  7044. if (fu[functionicity[j]].length === 0) {
  7045. delete fu[functionicity[j]];
  7046. }
  7047. }
  7048. fu.name = f["(name)"];
  7049. fu.param = f["(params)"];
  7050. fu.line = f["(line)"];
  7051. fu.character = f["(character)"];
  7052. fu.last = f["(last)"];
  7053. fu.lastcharacter = f["(lastcharacter)"];
  7054. fu.metrics = {
  7055. complexity: f["(metrics)"].ComplexityCount,
  7056. parameters: f["(metrics)"].arity,
  7057. statements: f["(metrics)"].statementCount
  7058. };
  7059. data.functions.push(fu);
  7060. }
  7061. var unuseds = state.funct["(scope)"].getUnuseds();
  7062. if (unuseds.length > 0) {
  7063. data.unused = unuseds;
  7064. }
  7065. for (n in member) {
  7066. if (typeof member[n] === "number") {
  7067. data.member = member;
  7068. break;
  7069. }
  7070. }
  7071. return data;
  7072. };
  7073. itself.jshint = itself;
  7074. return itself;
  7075. }());
  7076. if (typeof exports === "object" && exports) {
  7077. exports.JSHINT = JSHINT;
  7078. }
  7079. },{"../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){
  7080. "use strict";
  7081. var _ = _dereq_("../lodash");
  7082. var events = _dereq_("events");
  7083. var reg = _dereq_("./reg.js");
  7084. var state = _dereq_("./state.js").state;
  7085. var unicodeData = _dereq_("../data/ascii-identifier-data.js");
  7086. var asciiIdentifierStartTable = unicodeData.asciiIdentifierStartTable;
  7087. var asciiIdentifierPartTable = unicodeData.asciiIdentifierPartTable;
  7088. var Token = {
  7089. Identifier: 1,
  7090. Punctuator: 2,
  7091. NumericLiteral: 3,
  7092. StringLiteral: 4,
  7093. Comment: 5,
  7094. Keyword: 6,
  7095. NullLiteral: 7,
  7096. BooleanLiteral: 8,
  7097. RegExp: 9,
  7098. TemplateHead: 10,
  7099. TemplateMiddle: 11,
  7100. TemplateTail: 12,
  7101. NoSubstTemplate: 13
  7102. };
  7103. var Context = {
  7104. Block: 1,
  7105. Template: 2
  7106. };
  7107. function asyncTrigger() {
  7108. var _checks = [];
  7109. return {
  7110. push: function(fn) {
  7111. _checks.push(fn);
  7112. },
  7113. check: function() {
  7114. for (var check = 0; check < _checks.length; ++check) {
  7115. _checks[check]();
  7116. }
  7117. _checks.splice(0, _checks.length);
  7118. }
  7119. };
  7120. }
  7121. function Lexer(source) {
  7122. var lines = source;
  7123. if (typeof lines === "string") {
  7124. lines = lines
  7125. .replace(/\r\n/g, "\n")
  7126. .replace(/\r/g, "\n")
  7127. .split("\n");
  7128. }
  7129. if (lines[0] && lines[0].substr(0, 2) === "#!") {
  7130. if (lines[0].indexOf("node") !== -1) {
  7131. state.option.node = true;
  7132. }
  7133. lines[0] = "";
  7134. }
  7135. this.emitter = new events.EventEmitter();
  7136. this.source = source;
  7137. this.setLines(lines);
  7138. this.prereg = true;
  7139. this.line = 0;
  7140. this.char = 1;
  7141. this.from = 1;
  7142. this.input = "";
  7143. this.inComment = false;
  7144. this.context = [];
  7145. this.templateStarts = [];
  7146. for (var i = 0; i < state.option.indent; i += 1) {
  7147. state.tab += " ";
  7148. }
  7149. this.ignoreLinterErrors = false;
  7150. }
  7151. Lexer.prototype = {
  7152. _lines: [],
  7153. inContext: function(ctxType) {
  7154. return this.context.length > 0 && this.context[this.context.length - 1].type === ctxType;
  7155. },
  7156. pushContext: function(ctxType) {
  7157. this.context.push({ type: ctxType });
  7158. },
  7159. popContext: function() {
  7160. return this.context.pop();
  7161. },
  7162. isContext: function(context) {
  7163. return this.context.length > 0 && this.context[this.context.length - 1] === context;
  7164. },
  7165. currentContext: function() {
  7166. return this.context.length > 0 && this.context[this.context.length - 1];
  7167. },
  7168. getLines: function() {
  7169. this._lines = state.lines;
  7170. return this._lines;
  7171. },
  7172. setLines: function(val) {
  7173. this._lines = val;
  7174. state.lines = this._lines;
  7175. },
  7176. peek: function(i) {
  7177. return this.input.charAt(i || 0);
  7178. },
  7179. skip: function(i) {
  7180. i = i || 1;
  7181. this.char += i;
  7182. this.input = this.input.slice(i);
  7183. },
  7184. on: function(names, listener) {
  7185. names.split(" ").forEach(function(name) {
  7186. this.emitter.on(name, listener);
  7187. }.bind(this));
  7188. },
  7189. trigger: function() {
  7190. this.emitter.emit.apply(this.emitter, Array.prototype.slice.call(arguments));
  7191. },
  7192. triggerAsync: function(type, args, checks, fn) {
  7193. checks.push(function() {
  7194. if (fn()) {
  7195. this.trigger(type, args);
  7196. }
  7197. }.bind(this));
  7198. },
  7199. scanPunctuator: function() {
  7200. var ch1 = this.peek();
  7201. var ch2, ch3, ch4;
  7202. switch (ch1) {
  7203. case ".":
  7204. if ((/^[0-9]$/).test(this.peek(1))) {
  7205. return null;
  7206. }
  7207. if (this.peek(1) === "." && this.peek(2) === ".") {
  7208. return {
  7209. type: Token.Punctuator,
  7210. value: "..."
  7211. };
  7212. }
  7213. case "(":
  7214. case ")":
  7215. case ";":
  7216. case ",":
  7217. case "[":
  7218. case "]":
  7219. case ":":
  7220. case "~":
  7221. case "?":
  7222. return {
  7223. type: Token.Punctuator,
  7224. value: ch1
  7225. };
  7226. case "{":
  7227. this.pushContext(Context.Block);
  7228. return {
  7229. type: Token.Punctuator,
  7230. value: ch1
  7231. };
  7232. case "}":
  7233. if (this.inContext(Context.Block)) {
  7234. this.popContext();
  7235. }
  7236. return {
  7237. type: Token.Punctuator,
  7238. value: ch1
  7239. };
  7240. case "#":
  7241. return {
  7242. type: Token.Punctuator,
  7243. value: ch1
  7244. };
  7245. case "":
  7246. return null;
  7247. }
  7248. ch2 = this.peek(1);
  7249. ch3 = this.peek(2);
  7250. ch4 = this.peek(3);
  7251. if (ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=") {
  7252. return {
  7253. type: Token.Punctuator,
  7254. value: ">>>="
  7255. };
  7256. }
  7257. if (ch1 === "=" && ch2 === "=" && ch3 === "=") {
  7258. return {
  7259. type: Token.Punctuator,
  7260. value: "==="
  7261. };
  7262. }
  7263. if (ch1 === "!" && ch2 === "=" && ch3 === "=") {
  7264. return {
  7265. type: Token.Punctuator,
  7266. value: "!=="
  7267. };
  7268. }
  7269. if (ch1 === ">" && ch2 === ">" && ch3 === ">") {
  7270. return {
  7271. type: Token.Punctuator,
  7272. value: ">>>"
  7273. };
  7274. }
  7275. if (ch1 === "<" && ch2 === "<" && ch3 === "=") {
  7276. return {
  7277. type: Token.Punctuator,
  7278. value: "<<="
  7279. };
  7280. }
  7281. if (ch1 === ">" && ch2 === ">" && ch3 === "=") {
  7282. return {
  7283. type: Token.Punctuator,
  7284. value: ">>="
  7285. };
  7286. }
  7287. if (ch1 === "=" && ch2 === ">") {
  7288. return {
  7289. type: Token.Punctuator,
  7290. value: ch1 + ch2
  7291. };
  7292. }
  7293. if (ch1 === ch2 && ("+-<>&|".indexOf(ch1) >= 0)) {
  7294. return {
  7295. type: Token.Punctuator,
  7296. value: ch1 + ch2
  7297. };
  7298. }
  7299. if ("<>=!+-*%&|^".indexOf(ch1) >= 0) {
  7300. if (ch2 === "=") {
  7301. return {
  7302. type: Token.Punctuator,
  7303. value: ch1 + ch2
  7304. };
  7305. }
  7306. return {
  7307. type: Token.Punctuator,
  7308. value: ch1
  7309. };
  7310. }
  7311. if (ch1 === "/") {
  7312. if (ch2 === "=") {
  7313. return {
  7314. type: Token.Punctuator,
  7315. value: "/="
  7316. };
  7317. }
  7318. return {
  7319. type: Token.Punctuator,
  7320. value: "/"
  7321. };
  7322. }
  7323. return null;
  7324. },
  7325. scanComments: function() {
  7326. var ch1 = this.peek();
  7327. var ch2 = this.peek(1);
  7328. var rest = this.input.substr(2);
  7329. var startLine = this.line;
  7330. var startChar = this.char;
  7331. var self = this;
  7332. function commentToken(label, body, opt) {
  7333. var special = ["jshint", "jslint", "members", "member", "globals", "global", "exported"];
  7334. var isSpecial = false;
  7335. var value = label + body;
  7336. var commentType = "plain";
  7337. opt = opt || {};
  7338. if (opt.isMultiline) {
  7339. value += "*/";
  7340. }
  7341. body = body.replace(/\n/g, " ");
  7342. if (label === "/*" && reg.fallsThrough.test(body)) {
  7343. isSpecial = true;
  7344. commentType = "falls through";
  7345. }
  7346. special.forEach(function(str) {
  7347. if (isSpecial) {
  7348. return;
  7349. }
  7350. if (label === "//" && str !== "jshint") {
  7351. return;
  7352. }
  7353. if (body.charAt(str.length) === " " && body.substr(0, str.length) === str) {
  7354. isSpecial = true;
  7355. label = label + str;
  7356. body = body.substr(str.length);
  7357. }
  7358. if (!isSpecial && body.charAt(0) === " " && body.charAt(str.length + 1) === " " &&
  7359. body.substr(1, str.length) === str) {
  7360. isSpecial = true;
  7361. label = label + " " + str;
  7362. body = body.substr(str.length + 1);
  7363. }
  7364. if (!isSpecial) {
  7365. return;
  7366. }
  7367. switch (str) {
  7368. case "member":
  7369. commentType = "members";
  7370. break;
  7371. case "global":
  7372. commentType = "globals";
  7373. break;
  7374. default:
  7375. var options = body.split(":").map(function(v) {
  7376. return v.replace(/^\s+/, "").replace(/\s+$/, "");
  7377. });
  7378. if (options.length === 2) {
  7379. switch (options[0]) {
  7380. case "ignore":
  7381. switch (options[1]) {
  7382. case "start":
  7383. self.ignoringLinterErrors = true;
  7384. isSpecial = false;
  7385. break;
  7386. case "end":
  7387. self.ignoringLinterErrors = false;
  7388. isSpecial = false;
  7389. break;
  7390. }
  7391. }
  7392. }
  7393. commentType = str;
  7394. }
  7395. });
  7396. return {
  7397. type: Token.Comment,
  7398. commentType: commentType,
  7399. value: value,
  7400. body: body,
  7401. isSpecial: isSpecial,
  7402. isMultiline: opt.isMultiline || false,
  7403. isMalformed: opt.isMalformed || false
  7404. };
  7405. }
  7406. if (ch1 === "*" && ch2 === "/") {
  7407. this.trigger("error", {
  7408. code: "E018",
  7409. line: startLine,
  7410. character: startChar
  7411. });
  7412. this.skip(2);
  7413. return null;
  7414. }
  7415. if (ch1 !== "/" || (ch2 !== "*" && ch2 !== "/")) {
  7416. return null;
  7417. }
  7418. if (ch2 === "/") {
  7419. this.skip(this.input.length); // Skip to the EOL.
  7420. return commentToken("//", rest);
  7421. }
  7422. var body = "";
  7423. if (ch2 === "*") {
  7424. this.inComment = true;
  7425. this.skip(2);
  7426. while (this.peek() !== "*" || this.peek(1) !== "/") {
  7427. if (this.peek() === "") { // End of Line
  7428. body += "\n";
  7429. if (!this.nextLine()) {
  7430. this.trigger("error", {
  7431. code: "E017",
  7432. line: startLine,
  7433. character: startChar
  7434. });
  7435. this.inComment = false;
  7436. return commentToken("/*", body, {
  7437. isMultiline: true,
  7438. isMalformed: true
  7439. });
  7440. }
  7441. } else {
  7442. body += this.peek();
  7443. this.skip();
  7444. }
  7445. }
  7446. this.skip(2);
  7447. this.inComment = false;
  7448. return commentToken("/*", body, { isMultiline: true });
  7449. }
  7450. },
  7451. scanKeyword: function() {
  7452. var result = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input);
  7453. var keywords = [
  7454. "if", "in", "do", "var", "for", "new",
  7455. "try", "let", "this", "else", "case",
  7456. "void", "with", "enum", "while", "break",
  7457. "catch", "throw", "const", "yield", "class",
  7458. "super", "return", "typeof", "delete",
  7459. "switch", "export", "import", "default",
  7460. "finally", "extends", "function", "continue",
  7461. "debugger", "instanceof"
  7462. ];
  7463. if (result && keywords.indexOf(result[0]) >= 0) {
  7464. return {
  7465. type: Token.Keyword,
  7466. value: result[0]
  7467. };
  7468. }
  7469. return null;
  7470. },
  7471. scanIdentifier: function() {
  7472. var id = "";
  7473. var index = 0;
  7474. var type, char;
  7475. function isNonAsciiIdentifierStart(code) {
  7476. return code > 256;
  7477. }
  7478. function isNonAsciiIdentifierPart(code) {
  7479. return code > 256;
  7480. }
  7481. function isHexDigit(str) {
  7482. return (/^[0-9a-fA-F]$/).test(str);
  7483. }
  7484. var readUnicodeEscapeSequence = function() {
  7485. index += 1;
  7486. if (this.peek(index) !== "u") {
  7487. return null;
  7488. }
  7489. var ch1 = this.peek(index + 1);
  7490. var ch2 = this.peek(index + 2);
  7491. var ch3 = this.peek(index + 3);
  7492. var ch4 = this.peek(index + 4);
  7493. var code;
  7494. if (isHexDigit(ch1) && isHexDigit(ch2) && isHexDigit(ch3) && isHexDigit(ch4)) {
  7495. code = parseInt(ch1 + ch2 + ch3 + ch4, 16);
  7496. if (asciiIdentifierPartTable[code] || isNonAsciiIdentifierPart(code)) {
  7497. index += 5;
  7498. return "\\u" + ch1 + ch2 + ch3 + ch4;
  7499. }
  7500. return null;
  7501. }
  7502. return null;
  7503. }.bind(this);
  7504. var getIdentifierStart = function() {
  7505. var chr = this.peek(index);
  7506. var code = chr.charCodeAt(0);
  7507. if (code === 92) {
  7508. return readUnicodeEscapeSequence();
  7509. }
  7510. if (code < 128) {
  7511. if (asciiIdentifierStartTable[code]) {
  7512. index += 1;
  7513. return chr;
  7514. }
  7515. return null;
  7516. }
  7517. if (isNonAsciiIdentifierStart(code)) {
  7518. index += 1;
  7519. return chr;
  7520. }
  7521. return null;
  7522. }.bind(this);
  7523. var getIdentifierPart = function() {
  7524. var chr = this.peek(index);
  7525. var code = chr.charCodeAt(0);
  7526. if (code === 92) {
  7527. return readUnicodeEscapeSequence();
  7528. }
  7529. if (code < 128) {
  7530. if (asciiIdentifierPartTable[code]) {
  7531. index += 1;
  7532. return chr;
  7533. }
  7534. return null;
  7535. }
  7536. if (isNonAsciiIdentifierPart(code)) {
  7537. index += 1;
  7538. return chr;
  7539. }
  7540. return null;
  7541. }.bind(this);
  7542. function removeEscapeSequences(id) {
  7543. return id.replace(/\\u([0-9a-fA-F]{4})/g, function(m0, codepoint) {
  7544. return String.fromCharCode(parseInt(codepoint, 16));
  7545. });
  7546. }
  7547. char = getIdentifierStart();
  7548. if (char === null) {
  7549. return null;
  7550. }
  7551. id = char;
  7552. for (;;) {
  7553. char = getIdentifierPart();
  7554. if (char === null) {
  7555. break;
  7556. }
  7557. id += char;
  7558. }
  7559. switch (id) {
  7560. case "true":
  7561. case "false":
  7562. type = Token.BooleanLiteral;
  7563. break;
  7564. case "null":
  7565. type = Token.NullLiteral;
  7566. break;
  7567. default:
  7568. type = Token.Identifier;
  7569. }
  7570. return {
  7571. type: type,
  7572. value: removeEscapeSequences(id),
  7573. text: id,
  7574. tokenLength: id.length
  7575. };
  7576. },
  7577. scanNumericLiteral: function() {
  7578. var index = 0;
  7579. var value = "";
  7580. var length = this.input.length;
  7581. var char = this.peek(index);
  7582. var bad;
  7583. var isAllowedDigit = isDecimalDigit;
  7584. var base = 10;
  7585. var isLegacy = false;
  7586. function isDecimalDigit(str) {
  7587. return (/^[0-9]$/).test(str);
  7588. }
  7589. function isOctalDigit(str) {
  7590. return (/^[0-7]$/).test(str);
  7591. }
  7592. function isBinaryDigit(str) {
  7593. return (/^[01]$/).test(str);
  7594. }
  7595. function isHexDigit(str) {
  7596. return (/^[0-9a-fA-F]$/).test(str);
  7597. }
  7598. function isIdentifierStart(ch) {
  7599. return (ch === "$") || (ch === "_") || (ch === "\\") ||
  7600. (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z");
  7601. }
  7602. if (char !== "." && !isDecimalDigit(char)) {
  7603. return null;
  7604. }
  7605. if (char !== ".") {
  7606. value = this.peek(index);
  7607. index += 1;
  7608. char = this.peek(index);
  7609. if (value === "0") {
  7610. if (char === "x" || char === "X") {
  7611. isAllowedDigit = isHexDigit;
  7612. base = 16;
  7613. index += 1;
  7614. value += char;
  7615. }
  7616. if (char === "o" || char === "O") {
  7617. isAllowedDigit = isOctalDigit;
  7618. base = 8;
  7619. if (!state.inES6(true)) {
  7620. this.trigger("warning", {
  7621. code: "W119",
  7622. line: this.line,
  7623. character: this.char,
  7624. data: [ "Octal integer literal", "6" ]
  7625. });
  7626. }
  7627. index += 1;
  7628. value += char;
  7629. }
  7630. if (char === "b" || char === "B") {
  7631. isAllowedDigit = isBinaryDigit;
  7632. base = 2;
  7633. if (!state.inES6(true)) {
  7634. this.trigger("warning", {
  7635. code: "W119",
  7636. line: this.line,
  7637. character: this.char,
  7638. data: [ "Binary integer literal", "6" ]
  7639. });
  7640. }
  7641. index += 1;
  7642. value += char;
  7643. }
  7644. if (isOctalDigit(char)) {
  7645. isAllowedDigit = isOctalDigit;
  7646. base = 8;
  7647. isLegacy = true;
  7648. bad = false;
  7649. index += 1;
  7650. value += char;
  7651. }
  7652. if (!isOctalDigit(char) && isDecimalDigit(char)) {
  7653. index += 1;
  7654. value += char;
  7655. }
  7656. }
  7657. while (index < length) {
  7658. char = this.peek(index);
  7659. if (isLegacy && isDecimalDigit(char)) {
  7660. bad = true;
  7661. } else if (!isAllowedDigit(char)) {
  7662. break;
  7663. }
  7664. value += char;
  7665. index += 1;
  7666. }
  7667. if (isAllowedDigit !== isDecimalDigit) {
  7668. if (!isLegacy && value.length <= 2) { // 0x
  7669. return {
  7670. type: Token.NumericLiteral,
  7671. value: value,
  7672. isMalformed: true
  7673. };
  7674. }
  7675. if (index < length) {
  7676. char = this.peek(index);
  7677. if (isIdentifierStart(char)) {
  7678. return null;
  7679. }
  7680. }
  7681. return {
  7682. type: Token.NumericLiteral,
  7683. value: value,
  7684. base: base,
  7685. isLegacy: isLegacy,
  7686. isMalformed: false
  7687. };
  7688. }
  7689. }
  7690. if (char === ".") {
  7691. value += char;
  7692. index += 1;
  7693. while (index < length) {
  7694. char = this.peek(index);
  7695. if (!isDecimalDigit(char)) {
  7696. break;
  7697. }
  7698. value += char;
  7699. index += 1;
  7700. }
  7701. }
  7702. if (char === "e" || char === "E") {
  7703. value += char;
  7704. index += 1;
  7705. char = this.peek(index);
  7706. if (char === "+" || char === "-") {
  7707. value += this.peek(index);
  7708. index += 1;
  7709. }
  7710. char = this.peek(index);
  7711. if (isDecimalDigit(char)) {
  7712. value += char;
  7713. index += 1;
  7714. while (index < length) {
  7715. char = this.peek(index);
  7716. if (!isDecimalDigit(char)) {
  7717. break;
  7718. }
  7719. value += char;
  7720. index += 1;
  7721. }
  7722. } else {
  7723. return null;
  7724. }
  7725. }
  7726. if (index < length) {
  7727. char = this.peek(index);
  7728. if (isIdentifierStart(char)) {
  7729. return null;
  7730. }
  7731. }
  7732. return {
  7733. type: Token.NumericLiteral,
  7734. value: value,
  7735. base: base,
  7736. isMalformed: !isFinite(value)
  7737. };
  7738. },
  7739. scanEscapeSequence: function(checks) {
  7740. var allowNewLine = false;
  7741. var jump = 1;
  7742. this.skip();
  7743. var char = this.peek();
  7744. switch (char) {
  7745. case "'":
  7746. this.triggerAsync("warning", {
  7747. code: "W114",
  7748. line: this.line,
  7749. character: this.char,
  7750. data: [ "\\'" ]
  7751. }, checks, function() {return state.jsonMode; });
  7752. break;
  7753. case "b":
  7754. char = "\\b";
  7755. break;
  7756. case "f":
  7757. char = "\\f";
  7758. break;
  7759. case "n":
  7760. char = "\\n";
  7761. break;
  7762. case "r":
  7763. char = "\\r";
  7764. break;
  7765. case "t":
  7766. char = "\\t";
  7767. break;
  7768. case "0":
  7769. char = "\\0";
  7770. var n = parseInt(this.peek(1), 10);
  7771. this.triggerAsync("warning", {
  7772. code: "W115",
  7773. line: this.line,
  7774. character: this.char
  7775. }, checks,
  7776. function() { return n >= 0 && n <= 7 && state.isStrict(); });
  7777. break;
  7778. case "u":
  7779. var hexCode = this.input.substr(1, 4);
  7780. var code = parseInt(hexCode, 16);
  7781. if (isNaN(code)) {
  7782. this.trigger("warning", {
  7783. code: "W052",
  7784. line: this.line,
  7785. character: this.char,
  7786. data: [ "u" + hexCode ]
  7787. });
  7788. }
  7789. char = String.fromCharCode(code);
  7790. jump = 5;
  7791. break;
  7792. case "v":
  7793. this.triggerAsync("warning", {
  7794. code: "W114",
  7795. line: this.line,
  7796. character: this.char,
  7797. data: [ "\\v" ]
  7798. }, checks, function() { return state.jsonMode; });
  7799. char = "\v";
  7800. break;
  7801. case "x":
  7802. var x = parseInt(this.input.substr(1, 2), 16);
  7803. this.triggerAsync("warning", {
  7804. code: "W114",
  7805. line: this.line,
  7806. character: this.char,
  7807. data: [ "\\x-" ]
  7808. }, checks, function() { return state.jsonMode; });
  7809. char = String.fromCharCode(x);
  7810. jump = 3;
  7811. break;
  7812. case "\\":
  7813. char = "\\\\";
  7814. break;
  7815. case "\"":
  7816. char = "\\\"";
  7817. break;
  7818. case "/":
  7819. break;
  7820. case "":
  7821. allowNewLine = true;
  7822. char = "";
  7823. break;
  7824. }
  7825. return { char: char, jump: jump, allowNewLine: allowNewLine };
  7826. },
  7827. scanTemplateLiteral: function(checks) {
  7828. var tokenType;
  7829. var value = "";
  7830. var ch;
  7831. var startLine = this.line;
  7832. var startChar = this.char;
  7833. var depth = this.templateStarts.length;
  7834. if (!state.inES6(true)) {
  7835. return null;
  7836. } else if (this.peek() === "`") {
  7837. tokenType = Token.TemplateHead;
  7838. this.templateStarts.push({ line: this.line, char: this.char });
  7839. depth = this.templateStarts.length;
  7840. this.skip(1);
  7841. this.pushContext(Context.Template);
  7842. } else if (this.inContext(Context.Template) && this.peek() === "}") {
  7843. tokenType = Token.TemplateMiddle;
  7844. } else {
  7845. return null;
  7846. }
  7847. while (this.peek() !== "`") {
  7848. while ((ch = this.peek()) === "") {
  7849. value += "\n";
  7850. if (!this.nextLine()) {
  7851. var startPos = this.templateStarts.pop();
  7852. this.trigger("error", {
  7853. code: "E052",
  7854. line: startPos.line,
  7855. character: startPos.char
  7856. });
  7857. return {
  7858. type: tokenType,
  7859. value: value,
  7860. startLine: startLine,
  7861. startChar: startChar,
  7862. isUnclosed: true,
  7863. depth: depth,
  7864. context: this.popContext()
  7865. };
  7866. }
  7867. }
  7868. if (ch === '$' && this.peek(1) === '{') {
  7869. value += '${';
  7870. this.skip(2);
  7871. return {
  7872. type: tokenType,
  7873. value: value,
  7874. startLine: startLine,
  7875. startChar: startChar,
  7876. isUnclosed: false,
  7877. depth: depth,
  7878. context: this.currentContext()
  7879. };
  7880. } else if (ch === '\\') {
  7881. var escape = this.scanEscapeSequence(checks);
  7882. value += escape.char;
  7883. this.skip(escape.jump);
  7884. } else if (ch !== '`') {
  7885. value += ch;
  7886. this.skip(1);
  7887. }
  7888. }
  7889. tokenType = tokenType === Token.TemplateHead ? Token.NoSubstTemplate : Token.TemplateTail;
  7890. this.skip(1);
  7891. this.templateStarts.pop();
  7892. return {
  7893. type: tokenType,
  7894. value: value,
  7895. startLine: startLine,
  7896. startChar: startChar,
  7897. isUnclosed: false,
  7898. depth: depth,
  7899. context: this.popContext()
  7900. };
  7901. },
  7902. scanStringLiteral: function(checks) {
  7903. var quote = this.peek();
  7904. if (quote !== "\"" && quote !== "'") {
  7905. return null;
  7906. }
  7907. this.triggerAsync("warning", {
  7908. code: "W108",
  7909. line: this.line,
  7910. character: this.char // +1?
  7911. }, checks, function() { return state.jsonMode && quote !== "\""; });
  7912. var value = "";
  7913. var startLine = this.line;
  7914. var startChar = this.char;
  7915. var allowNewLine = false;
  7916. this.skip();
  7917. while (this.peek() !== quote) {
  7918. if (this.peek() === "") { // End Of Line
  7919. //
  7920. if (!allowNewLine) {
  7921. this.trigger("warning", {
  7922. code: "W112",
  7923. line: this.line,
  7924. character: this.char
  7925. });
  7926. } else {
  7927. allowNewLine = false;
  7928. this.triggerAsync("warning", {
  7929. code: "W043",
  7930. line: this.line,
  7931. character: this.char
  7932. }, checks, function() { return !state.option.multistr; });
  7933. this.triggerAsync("warning", {
  7934. code: "W042",
  7935. line: this.line,
  7936. character: this.char
  7937. }, checks, function() { return state.jsonMode && state.option.multistr; });
  7938. }
  7939. if (!this.nextLine()) {
  7940. this.trigger("error", {
  7941. code: "E029",
  7942. line: startLine,
  7943. character: startChar
  7944. });
  7945. return {
  7946. type: Token.StringLiteral,
  7947. value: value,
  7948. startLine: startLine,
  7949. startChar: startChar,
  7950. isUnclosed: true,
  7951. quote: quote
  7952. };
  7953. }
  7954. } else { // Any character other than End Of Line
  7955. allowNewLine = false;
  7956. var char = this.peek();
  7957. var jump = 1; // A length of a jump, after we're done
  7958. if (char < " ") {
  7959. this.trigger("warning", {
  7960. code: "W113",
  7961. line: this.line,
  7962. character: this.char,
  7963. data: [ "<non-printable>" ]
  7964. });
  7965. }
  7966. if (char === "\\") {
  7967. var parsed = this.scanEscapeSequence(checks);
  7968. char = parsed.char;
  7969. jump = parsed.jump;
  7970. allowNewLine = parsed.allowNewLine;
  7971. }
  7972. value += char;
  7973. this.skip(jump);
  7974. }
  7975. }
  7976. this.skip();
  7977. return {
  7978. type: Token.StringLiteral,
  7979. value: value,
  7980. startLine: startLine,
  7981. startChar: startChar,
  7982. isUnclosed: false,
  7983. quote: quote
  7984. };
  7985. },
  7986. scanRegExp: function() {
  7987. var index = 0;
  7988. var length = this.input.length;
  7989. var char = this.peek();
  7990. var value = char;
  7991. var body = "";
  7992. var flags = [];
  7993. var malformed = false;
  7994. var isCharSet = false;
  7995. var terminated;
  7996. var scanUnexpectedChars = function() {
  7997. if (char < " ") {
  7998. malformed = true;
  7999. this.trigger("warning", {
  8000. code: "W048",
  8001. line: this.line,
  8002. character: this.char
  8003. });
  8004. }
  8005. if (char === "<") {
  8006. malformed = true;
  8007. this.trigger("warning", {
  8008. code: "W049",
  8009. line: this.line,
  8010. character: this.char,
  8011. data: [ char ]
  8012. });
  8013. }
  8014. }.bind(this);
  8015. if (!this.prereg || char !== "/") {
  8016. return null;
  8017. }
  8018. index += 1;
  8019. terminated = false;
  8020. while (index < length) {
  8021. char = this.peek(index);
  8022. value += char;
  8023. body += char;
  8024. if (isCharSet) {
  8025. if (char === "]") {
  8026. if (this.peek(index - 1) !== "\\" || this.peek(index - 2) === "\\") {
  8027. isCharSet = false;
  8028. }
  8029. }
  8030. if (char === "\\") {
  8031. index += 1;
  8032. char = this.peek(index);
  8033. body += char;
  8034. value += char;
  8035. scanUnexpectedChars();
  8036. }
  8037. index += 1;
  8038. continue;
  8039. }
  8040. if (char === "\\") {
  8041. index += 1;
  8042. char = this.peek(index);
  8043. body += char;
  8044. value += char;
  8045. scanUnexpectedChars();
  8046. if (char === "/") {
  8047. index += 1;
  8048. continue;
  8049. }
  8050. if (char === "[") {
  8051. index += 1;
  8052. continue;
  8053. }
  8054. }
  8055. if (char === "[") {
  8056. isCharSet = true;
  8057. index += 1;
  8058. continue;
  8059. }
  8060. if (char === "/") {
  8061. body = body.substr(0, body.length - 1);
  8062. terminated = true;
  8063. index += 1;
  8064. break;
  8065. }
  8066. index += 1;
  8067. }
  8068. if (!terminated) {
  8069. this.trigger("error", {
  8070. code: "E015",
  8071. line: this.line,
  8072. character: this.from
  8073. });
  8074. return void this.trigger("fatal", {
  8075. line: this.line,
  8076. from: this.from
  8077. });
  8078. }
  8079. while (index < length) {
  8080. char = this.peek(index);
  8081. if (!/[gim]/.test(char)) {
  8082. break;
  8083. }
  8084. flags.push(char);
  8085. value += char;
  8086. index += 1;
  8087. }
  8088. try {
  8089. new RegExp(body, flags.join(""));
  8090. } catch (err) {
  8091. malformed = true;
  8092. this.trigger("error", {
  8093. code: "E016",
  8094. line: this.line,
  8095. character: this.char,
  8096. data: [ err.message ] // Platform dependent!
  8097. });
  8098. }
  8099. return {
  8100. type: Token.RegExp,
  8101. value: value,
  8102. flags: flags,
  8103. isMalformed: malformed
  8104. };
  8105. },
  8106. scanNonBreakingSpaces: function() {
  8107. return state.option.nonbsp ?
  8108. this.input.search(/(\u00A0)/) : -1;
  8109. },
  8110. scanUnsafeChars: function() {
  8111. return this.input.search(reg.unsafeChars);
  8112. },
  8113. next: function(checks) {
  8114. this.from = this.char;
  8115. var start;
  8116. if (/\s/.test(this.peek())) {
  8117. start = this.char;
  8118. while (/\s/.test(this.peek())) {
  8119. this.from += 1;
  8120. this.skip();
  8121. }
  8122. }
  8123. var match = this.scanComments() ||
  8124. this.scanStringLiteral(checks) ||
  8125. this.scanTemplateLiteral(checks);
  8126. if (match) {
  8127. return match;
  8128. }
  8129. match =
  8130. this.scanRegExp() ||
  8131. this.scanPunctuator() ||
  8132. this.scanKeyword() ||
  8133. this.scanIdentifier() ||
  8134. this.scanNumericLiteral();
  8135. if (match) {
  8136. this.skip(match.tokenLength || match.value.length);
  8137. return match;
  8138. }
  8139. return null;
  8140. },
  8141. nextLine: function() {
  8142. var char;
  8143. if (this.line >= this.getLines().length) {
  8144. return false;
  8145. }
  8146. this.input = this.getLines()[this.line];
  8147. this.line += 1;
  8148. this.char = 1;
  8149. this.from = 1;
  8150. var inputTrimmed = this.input.trim();
  8151. var startsWith = function() {
  8152. return _.some(arguments, function(prefix) {
  8153. return inputTrimmed.indexOf(prefix) === 0;
  8154. });
  8155. };
  8156. var endsWith = function() {
  8157. return _.some(arguments, function(suffix) {
  8158. return inputTrimmed.indexOf(suffix, inputTrimmed.length - suffix.length) !== -1;
  8159. });
  8160. };
  8161. if (this.ignoringLinterErrors === true) {
  8162. if (!startsWith("/*", "//") && !(this.inComment && endsWith("*/"))) {
  8163. this.input = "";
  8164. }
  8165. }
  8166. char = this.scanNonBreakingSpaces();
  8167. if (char >= 0) {
  8168. this.trigger("warning", { code: "W125", line: this.line, character: char + 1 });
  8169. }
  8170. this.input = this.input.replace(/\t/g, state.tab);
  8171. char = this.scanUnsafeChars();
  8172. if (char >= 0) {
  8173. this.trigger("warning", { code: "W100", line: this.line, character: char });
  8174. }
  8175. if (!this.ignoringLinterErrors && state.option.maxlen &&
  8176. state.option.maxlen < this.input.length) {
  8177. var inComment = this.inComment ||
  8178. startsWith.call(inputTrimmed, "//") ||
  8179. startsWith.call(inputTrimmed, "/*");
  8180. var shouldTriggerError = !inComment || !reg.maxlenException.test(inputTrimmed);
  8181. if (shouldTriggerError) {
  8182. this.trigger("warning", { code: "W101", line: this.line, character: this.input.length });
  8183. }
  8184. }
  8185. return true;
  8186. },
  8187. start: function() {
  8188. this.nextLine();
  8189. },
  8190. token: function() {
  8191. var checks = asyncTrigger();
  8192. var token;
  8193. function isReserved(token, isProperty) {
  8194. if (!token.reserved) {
  8195. return false;
  8196. }
  8197. var meta = token.meta;
  8198. if (meta && meta.isFutureReservedWord && state.inES5()) {
  8199. if (!meta.es5) {
  8200. return false;
  8201. }
  8202. if (meta.strictOnly) {
  8203. if (!state.option.strict && !state.isStrict()) {
  8204. return false;
  8205. }
  8206. }
  8207. if (isProperty) {
  8208. return false;
  8209. }
  8210. }
  8211. return true;
  8212. }
  8213. var create = function(type, value, isProperty, token) {
  8214. var obj;
  8215. if (type !== "(endline)" && type !== "(end)") {
  8216. this.prereg = false;
  8217. }
  8218. if (type === "(punctuator)") {
  8219. switch (value) {
  8220. case ".":
  8221. case ")":
  8222. case "~":
  8223. case "#":
  8224. case "]":
  8225. case "++":
  8226. case "--":
  8227. this.prereg = false;
  8228. break;
  8229. default:
  8230. this.prereg = true;
  8231. }
  8232. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  8233. }
  8234. if (type === "(identifier)") {
  8235. if (value === "return" || value === "case" || value === "typeof") {
  8236. this.prereg = true;
  8237. }
  8238. if (_.has(state.syntax, value)) {
  8239. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  8240. if (!isReserved(obj, isProperty && type === "(identifier)")) {
  8241. obj = null;
  8242. }
  8243. }
  8244. }
  8245. if (!obj) {
  8246. obj = Object.create(state.syntax[type]);
  8247. }
  8248. obj.identifier = (type === "(identifier)");
  8249. obj.type = obj.type || type;
  8250. obj.value = value;
  8251. obj.line = this.line;
  8252. obj.character = this.char;
  8253. obj.from = this.from;
  8254. if (obj.identifier && token) obj.raw_text = token.text || token.value;
  8255. if (token && token.startLine && token.startLine !== this.line) {
  8256. obj.startLine = token.startLine;
  8257. }
  8258. if (token && token.context) {
  8259. obj.context = token.context;
  8260. }
  8261. if (token && token.depth) {
  8262. obj.depth = token.depth;
  8263. }
  8264. if (token && token.isUnclosed) {
  8265. obj.isUnclosed = token.isUnclosed;
  8266. }
  8267. if (isProperty && obj.identifier) {
  8268. obj.isProperty = isProperty;
  8269. }
  8270. obj.check = checks.check;
  8271. return obj;
  8272. }.bind(this);
  8273. for (;;) {
  8274. if (!this.input.length) {
  8275. if (this.nextLine()) {
  8276. return create("(endline)", "");
  8277. }
  8278. if (this.exhausted) {
  8279. return null;
  8280. }
  8281. this.exhausted = true;
  8282. return create("(end)", "");
  8283. }
  8284. token = this.next(checks);
  8285. if (!token) {
  8286. if (this.input.length) {
  8287. this.trigger("error", {
  8288. code: "E024",
  8289. line: this.line,
  8290. character: this.char,
  8291. data: [ this.peek() ]
  8292. });
  8293. this.input = "";
  8294. }
  8295. continue;
  8296. }
  8297. switch (token.type) {
  8298. case Token.StringLiteral:
  8299. this.triggerAsync("String", {
  8300. line: this.line,
  8301. char: this.char,
  8302. from: this.from,
  8303. startLine: token.startLine,
  8304. startChar: token.startChar,
  8305. value: token.value,
  8306. quote: token.quote
  8307. }, checks, function() { return true; });
  8308. return create("(string)", token.value, null, token);
  8309. case Token.TemplateHead:
  8310. this.trigger("TemplateHead", {
  8311. line: this.line,
  8312. char: this.char,
  8313. from: this.from,
  8314. startLine: token.startLine,
  8315. startChar: token.startChar,
  8316. value: token.value
  8317. });
  8318. return create("(template)", token.value, null, token);
  8319. case Token.TemplateMiddle:
  8320. this.trigger("TemplateMiddle", {
  8321. line: this.line,
  8322. char: this.char,
  8323. from: this.from,
  8324. startLine: token.startLine,
  8325. startChar: token.startChar,
  8326. value: token.value
  8327. });
  8328. return create("(template middle)", token.value, null, token);
  8329. case Token.TemplateTail:
  8330. this.trigger("TemplateTail", {
  8331. line: this.line,
  8332. char: this.char,
  8333. from: this.from,
  8334. startLine: token.startLine,
  8335. startChar: token.startChar,
  8336. value: token.value
  8337. });
  8338. return create("(template tail)", token.value, null, token);
  8339. case Token.NoSubstTemplate:
  8340. this.trigger("NoSubstTemplate", {
  8341. line: this.line,
  8342. char: this.char,
  8343. from: this.from,
  8344. startLine: token.startLine,
  8345. startChar: token.startChar,
  8346. value: token.value
  8347. });
  8348. return create("(no subst template)", token.value, null, token);
  8349. case Token.Identifier:
  8350. this.triggerAsync("Identifier", {
  8351. line: this.line,
  8352. char: this.char,
  8353. from: this.form,
  8354. name: token.value,
  8355. raw_name: token.text,
  8356. isProperty: state.tokens.curr.id === "."
  8357. }, checks, function() { return true; });
  8358. case Token.Keyword:
  8359. case Token.NullLiteral:
  8360. case Token.BooleanLiteral:
  8361. return create("(identifier)", token.value, state.tokens.curr.id === ".", token);
  8362. case Token.NumericLiteral:
  8363. if (token.isMalformed) {
  8364. this.trigger("warning", {
  8365. code: "W045",
  8366. line: this.line,
  8367. character: this.char,
  8368. data: [ token.value ]
  8369. });
  8370. }
  8371. this.triggerAsync("warning", {
  8372. code: "W114",
  8373. line: this.line,
  8374. character: this.char,
  8375. data: [ "0x-" ]
  8376. }, checks, function() { return token.base === 16 && state.jsonMode; });
  8377. this.triggerAsync("warning", {
  8378. code: "W115",
  8379. line: this.line,
  8380. character: this.char
  8381. }, checks, function() {
  8382. return state.isStrict() && token.base === 8 && token.isLegacy;
  8383. });
  8384. this.trigger("Number", {
  8385. line: this.line,
  8386. char: this.char,
  8387. from: this.from,
  8388. value: token.value,
  8389. base: token.base,
  8390. isMalformed: token.malformed
  8391. });
  8392. return create("(number)", token.value);
  8393. case Token.RegExp:
  8394. return create("(regexp)", token.value);
  8395. case Token.Comment:
  8396. state.tokens.curr.comment = true;
  8397. if (token.isSpecial) {
  8398. return {
  8399. id: '(comment)',
  8400. value: token.value,
  8401. body: token.body,
  8402. type: token.commentType,
  8403. isSpecial: token.isSpecial,
  8404. line: this.line,
  8405. character: this.char,
  8406. from: this.from
  8407. };
  8408. }
  8409. break;
  8410. case "":
  8411. break;
  8412. default:
  8413. return create("(punctuator)", token.value);
  8414. }
  8415. }
  8416. }
  8417. };
  8418. exports.Lexer = Lexer;
  8419. exports.Context = Context;
  8420. },{"../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){
  8421. "use strict";
  8422. var _ = _dereq_("../lodash");
  8423. var errors = {
  8424. E001: "Bad option: '{a}'.",
  8425. E002: "Bad option value.",
  8426. E003: "Expected a JSON value.",
  8427. E004: "Input is neither a string nor an array of strings.",
  8428. E005: "Input is empty.",
  8429. E006: "Unexpected early end of program.",
  8430. E007: "Missing \"use strict\" statement.",
  8431. E008: "Strict violation.",
  8432. E009: "Option 'validthis' can't be used in a global scope.",
  8433. E010: "'with' is not allowed in strict mode.",
  8434. E011: "'{a}' has already been declared.",
  8435. E012: "const '{a}' is initialized to 'undefined'.",
  8436. E013: "Attempting to override '{a}' which is a constant.",
  8437. E014: "A regular expression literal can be confused with '/='.",
  8438. E015: "Unclosed regular expression.",
  8439. E016: "Invalid regular expression.",
  8440. E017: "Unclosed comment.",
  8441. E018: "Unbegun comment.",
  8442. E019: "Unmatched '{a}'.",
  8443. E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
  8444. E021: "Expected '{a}' and instead saw '{b}'.",
  8445. E022: "Line breaking error '{a}'.",
  8446. E023: "Missing '{a}'.",
  8447. E024: "Unexpected '{a}'.",
  8448. E025: "Missing ':' on a case clause.",
  8449. E026: "Missing '}' to match '{' from line {a}.",
  8450. E027: "Missing ']' to match '[' from line {a}.",
  8451. E028: "Illegal comma.",
  8452. E029: "Unclosed string.",
  8453. E030: "Expected an identifier and instead saw '{a}'.",
  8454. E031: "Bad assignment.", // FIXME: Rephrase
  8455. E032: "Expected a small integer or 'false' and instead saw '{a}'.",
  8456. E033: "Expected an operator and instead saw '{a}'.",
  8457. E034: "get/set are ES5 features.",
  8458. E035: "Missing property name.",
  8459. E036: "Expected to see a statement and instead saw a block.",
  8460. E037: null,
  8461. E038: null,
  8462. E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.",
  8463. E040: "Each value should have its own case label.",
  8464. E041: "Unrecoverable syntax error.",
  8465. E042: "Stopping.",
  8466. E043: "Too many errors.",
  8467. E044: null,
  8468. E045: "Invalid for each loop.",
  8469. E046: "A yield statement shall be within a generator function (with syntax: `function*`)",
  8470. E047: null,
  8471. E048: "{a} declaration not directly within block.",
  8472. E049: "A {a} cannot be named '{b}'.",
  8473. E050: "Mozilla requires the yield expression to be parenthesized here.",
  8474. E051: null,
  8475. E052: "Unclosed template literal.",
  8476. E053: "Export declaration must be in global scope.",
  8477. E054: "Class properties must be methods. Expected '(' but instead saw '{a}'.",
  8478. E055: "The '{a}' option cannot be set after any executable code.",
  8479. E056: "'{a}' was used before it was declared, which is illegal for '{b}' variables.",
  8480. E057: "Invalid meta property: '{a}.{b}'.",
  8481. E058: "Missing semicolon."
  8482. };
  8483. var warnings = {
  8484. W001: "'hasOwnProperty' is a really bad name.",
  8485. W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
  8486. W003: "'{a}' was used before it was defined.",
  8487. W004: "'{a}' is already defined.",
  8488. W005: "A dot following a number can be confused with a decimal point.",
  8489. W006: "Confusing minuses.",
  8490. W007: "Confusing plusses.",
  8491. W008: "A leading decimal point can be confused with a dot: '{a}'.",
  8492. W009: "The array literal notation [] is preferable.",
  8493. W010: "The object literal notation {} is preferable.",
  8494. W011: null,
  8495. W012: null,
  8496. W013: null,
  8497. W014: "Bad line breaking before '{a}'.",
  8498. W015: null,
  8499. W016: "Unexpected use of '{a}'.",
  8500. W017: "Bad operand.",
  8501. W018: "Confusing use of '{a}'.",
  8502. W019: "Use the isNaN function to compare with NaN.",
  8503. W020: "Read only.",
  8504. W021: "Reassignment of '{a}', which is is a {b}. " +
  8505. "Use 'var' or 'let' to declare bindings that may change.",
  8506. W022: "Do not assign to the exception parameter.",
  8507. W023: "Expected an identifier in an assignment and instead saw a function invocation.",
  8508. W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
  8509. W025: "Missing name in function declaration.",
  8510. W026: "Inner functions should be listed at the top of the outer function.",
  8511. W027: "Unreachable '{a}' after '{b}'.",
  8512. W028: "Label '{a}' on {b} statement.",
  8513. W030: "Expected an assignment or function call and instead saw an expression.",
  8514. W031: "Do not use 'new' for side effects.",
  8515. W032: "Unnecessary semicolon.",
  8516. W033: "Missing semicolon.",
  8517. W034: "Unnecessary directive \"{a}\".",
  8518. W035: "Empty block.",
  8519. W036: "Unexpected /*member '{a}'.",
  8520. W037: "'{a}' is a statement label.",
  8521. W038: "'{a}' used out of scope.",
  8522. W039: "'{a}' is not allowed.",
  8523. W040: "Possible strict violation.",
  8524. W041: "Use '{a}' to compare with '{b}'.",
  8525. W042: "Avoid EOL escaping.",
  8526. W043: "Bad escaping of EOL. Use option multistr if needed.",
  8527. W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */
  8528. W045: "Bad number '{a}'.",
  8529. W046: "Don't use extra leading zeros '{a}'.",
  8530. W047: "A trailing decimal point can be confused with a dot: '{a}'.",
  8531. W048: "Unexpected control character in regular expression.",
  8532. W049: "Unexpected escaped character '{a}' in regular expression.",
  8533. W050: "JavaScript URL.",
  8534. W051: "Variables should not be deleted.",
  8535. W052: "Unexpected '{a}'.",
  8536. W053: "Do not use {a} as a constructor.",
  8537. W054: "The Function constructor is a form of eval.",
  8538. W055: "A constructor name should start with an uppercase letter.",
  8539. W056: "Bad constructor.",
  8540. W057: "Weird construction. Is 'new' necessary?",
  8541. W058: "Missing '()' invoking a constructor.",
  8542. W059: "Avoid arguments.{a}.",
  8543. W060: "document.write can be a form of eval.",
  8544. W061: "eval can be harmful.",
  8545. W062: "Wrap an immediate function invocation in parens " +
  8546. "to assist the reader in understanding that the expression " +
  8547. "is the result of a function, and not the function itself.",
  8548. W063: "Math is not a function.",
  8549. W064: "Missing 'new' prefix when invoking a constructor.",
  8550. W065: "Missing radix parameter.",
  8551. W066: "Implied eval. Consider passing a function instead of a string.",
  8552. W067: "Bad invocation.",
  8553. W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
  8554. W069: "['{a}'] is better written in dot notation.",
  8555. W070: "Extra comma. (it breaks older versions of IE)",
  8556. W071: "This function has too many statements. ({a})",
  8557. W072: "This function has too many parameters. ({a})",
  8558. W073: "Blocks are nested too deeply. ({a})",
  8559. W074: "This function's cyclomatic complexity is too high. ({a})",
  8560. W075: "Duplicate {a} '{b}'.",
  8561. W076: "Unexpected parameter '{a}' in get {b} function.",
  8562. W077: "Expected a single parameter in set {a} function.",
  8563. W078: "Setter is defined without getter.",
  8564. W079: "Redefinition of '{a}'.",
  8565. W080: "It's not necessary to initialize '{a}' to 'undefined'.",
  8566. W081: null,
  8567. W082: "Function declarations should not be placed in blocks. " +
  8568. "Use a function expression or move the statement to the top of " +
  8569. "the outer function.",
  8570. W083: "Don't make functions within a loop.",
  8571. W084: "Assignment in conditional expression",
  8572. W085: "Don't use 'with'.",
  8573. W086: "Expected a 'break' statement before '{a}'.",
  8574. W087: "Forgotten 'debugger' statement?",
  8575. W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.",
  8576. W089: "The body of a for in should be wrapped in an if statement to filter " +
  8577. "unwanted properties from the prototype.",
  8578. W090: "'{a}' is not a statement label.",
  8579. W091: null,
  8580. W093: "Did you mean to return a conditional instead of an assignment?",
  8581. W094: "Unexpected comma.",
  8582. W095: "Expected a string and instead saw {a}.",
  8583. W096: "The '{a}' key may produce unexpected results.",
  8584. W097: "Use the function form of \"use strict\".",
  8585. W098: "'{a}' is defined but never used.",
  8586. W099: null,
  8587. W100: "This character may get silently deleted by one or more browsers.",
  8588. W101: "Line is too long.",
  8589. W102: null,
  8590. W103: "The '{a}' property is deprecated.",
  8591. W104: "'{a}' is available in ES{b} (use 'esversion: {b}') or Mozilla JS extensions (use moz).",
  8592. W105: "Unexpected {a} in '{b}'.",
  8593. W106: "Identifier '{a}' is not in camel case.",
  8594. W107: "Script URL.",
  8595. W108: "Strings must use doublequote.",
  8596. W109: "Strings must use singlequote.",
  8597. W110: "Mixed double and single quotes.",
  8598. W112: "Unclosed string.",
  8599. W113: "Control character in string: {a}.",
  8600. W114: "Avoid {a}.",
  8601. W115: "Octal literals are not allowed in strict mode.",
  8602. W116: "Expected '{a}' and instead saw '{b}'.",
  8603. W117: "'{a}' is not defined.",
  8604. W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).",
  8605. W119: "'{a}' is only available in ES{b} (use 'esversion: {b}').",
  8606. W120: "You might be leaking a variable ({a}) here.",
  8607. W121: "Extending prototype of native object: '{a}'.",
  8608. W122: "Invalid typeof value '{a}'",
  8609. W123: "'{a}' is already defined in outer scope.",
  8610. W124: "A generator function shall contain a yield statement.",
  8611. W125: "This line contains non-breaking spaces: http://jshint.com/doc/options/#nonbsp",
  8612. W126: "Unnecessary grouping operator.",
  8613. W127: "Unexpected use of a comma operator.",
  8614. W128: "Empty array elements require elision=true.",
  8615. W129: "'{a}' is defined in a future version of JavaScript. Use a " +
  8616. "different variable name to avoid migration issues.",
  8617. W130: "Invalid element after rest element.",
  8618. W131: "Invalid parameter after rest parameter.",
  8619. W132: "`var` declarations are forbidden. Use `let` or `const` instead.",
  8620. W133: "Invalid for-{a} loop left-hand-side: {b}.",
  8621. W134: "The '{a}' option is only available when linting ECMAScript {b} code.",
  8622. W135: "{a} may not be supported by non-browser environments.",
  8623. W136: "'{a}' must be in function scope.",
  8624. W137: "Empty destructuring.",
  8625. W138: "Regular parameters should not come after default parameters."
  8626. };
  8627. var info = {
  8628. I001: "Comma warnings can be turned off with 'laxcomma'.",
  8629. I002: null,
  8630. I003: "ES5 option is now set per default"
  8631. };
  8632. exports.errors = {};
  8633. exports.warnings = {};
  8634. exports.info = {};
  8635. _.each(errors, function(desc, code) {
  8636. exports.errors[code] = { code: code, desc: desc };
  8637. });
  8638. _.each(warnings, function(desc, code) {
  8639. exports.warnings[code] = { code: code, desc: desc };
  8640. });
  8641. _.each(info, function(desc, code) {
  8642. exports.info[code] = { code: code, desc: desc };
  8643. });
  8644. },{"../lodash":"/node_modules/jshint/lodash.js"}],"/node_modules/jshint/src/name-stack.js":[function(_dereq_,module,exports){
  8645. "use strict";
  8646. function NameStack() {
  8647. this._stack = [];
  8648. }
  8649. Object.defineProperty(NameStack.prototype, "length", {
  8650. get: function() {
  8651. return this._stack.length;
  8652. }
  8653. });
  8654. NameStack.prototype.push = function() {
  8655. this._stack.push(null);
  8656. };
  8657. NameStack.prototype.pop = function() {
  8658. this._stack.pop();
  8659. };
  8660. NameStack.prototype.set = function(token) {
  8661. this._stack[this.length - 1] = token;
  8662. };
  8663. NameStack.prototype.infer = function() {
  8664. var nameToken = this._stack[this.length - 1];
  8665. var prefix = "";
  8666. var type;
  8667. if (!nameToken || nameToken.type === "class") {
  8668. nameToken = this._stack[this.length - 2];
  8669. }
  8670. if (!nameToken) {
  8671. return "(empty)";
  8672. }
  8673. type = nameToken.type;
  8674. if (type !== "(string)" && type !== "(number)" && type !== "(identifier)" && type !== "default") {
  8675. return "(expression)";
  8676. }
  8677. if (nameToken.accessorType) {
  8678. prefix = nameToken.accessorType + " ";
  8679. }
  8680. return prefix + nameToken.value;
  8681. };
  8682. module.exports = NameStack;
  8683. },{}],"/node_modules/jshint/src/options.js":[function(_dereq_,module,exports){
  8684. "use strict";
  8685. exports.bool = {
  8686. enforcing: {
  8687. bitwise : true,
  8688. freeze : true,
  8689. camelcase : true,
  8690. curly : true,
  8691. eqeqeq : true,
  8692. futurehostile: true,
  8693. notypeof : true,
  8694. es3 : true,
  8695. es5 : true,
  8696. forin : true,
  8697. funcscope : true,
  8698. immed : true,
  8699. iterator : true,
  8700. newcap : true,
  8701. noarg : true,
  8702. nocomma : true,
  8703. noempty : true,
  8704. nonbsp : true,
  8705. nonew : true,
  8706. undef : true,
  8707. singleGroups: false,
  8708. varstmt: false,
  8709. enforceall : false
  8710. },
  8711. relaxing: {
  8712. asi : true,
  8713. multistr : true,
  8714. debug : true,
  8715. boss : true,
  8716. evil : true,
  8717. globalstrict: true,
  8718. plusplus : true,
  8719. proto : true,
  8720. scripturl : true,
  8721. sub : true,
  8722. supernew : true,
  8723. laxbreak : true,
  8724. laxcomma : true,
  8725. validthis : true,
  8726. withstmt : true,
  8727. moz : true,
  8728. noyield : true,
  8729. eqnull : true,
  8730. lastsemic : true,
  8731. loopfunc : true,
  8732. expr : true,
  8733. esnext : true,
  8734. elision : true,
  8735. },
  8736. environments: {
  8737. mootools : true,
  8738. couch : true,
  8739. jasmine : true,
  8740. jquery : true,
  8741. node : true,
  8742. qunit : true,
  8743. rhino : true,
  8744. shelljs : true,
  8745. prototypejs : true,
  8746. yui : true,
  8747. mocha : true,
  8748. module : true,
  8749. wsh : true,
  8750. worker : true,
  8751. nonstandard : true,
  8752. browser : true,
  8753. browserify : true,
  8754. devel : true,
  8755. dojo : true,
  8756. typed : true,
  8757. phantom : true
  8758. },
  8759. obsolete: {
  8760. onecase : true, // if one case switch statements should be allowed
  8761. regexp : true, // if the . should not be allowed in regexp literals
  8762. regexdash : true // if unescaped first/last dash (-) inside brackets
  8763. }
  8764. };
  8765. exports.val = {
  8766. maxlen : false,
  8767. indent : false,
  8768. maxerr : false,
  8769. predef : false,
  8770. globals : false,
  8771. quotmark : false,
  8772. scope : false,
  8773. maxstatements: false,
  8774. maxdepth : false,
  8775. maxparams : false,
  8776. maxcomplexity: false,
  8777. shadow : false,
  8778. strict : true,
  8779. unused : true,
  8780. latedef : false,
  8781. ignore : false, // start/end ignoring lines of code, bypassing the lexer
  8782. ignoreDelimiters: false, // array of start/end delimiters used to ignore
  8783. esversion: 5
  8784. };
  8785. exports.inverted = {
  8786. bitwise : true,
  8787. forin : true,
  8788. newcap : true,
  8789. plusplus: true,
  8790. regexp : true,
  8791. undef : true,
  8792. eqeqeq : true,
  8793. strict : true
  8794. };
  8795. exports.validNames = Object.keys(exports.val)
  8796. .concat(Object.keys(exports.bool.relaxing))
  8797. .concat(Object.keys(exports.bool.enforcing))
  8798. .concat(Object.keys(exports.bool.obsolete))
  8799. .concat(Object.keys(exports.bool.environments));
  8800. exports.renamed = {
  8801. eqeq : "eqeqeq",
  8802. windows: "wsh",
  8803. sloppy : "strict"
  8804. };
  8805. exports.removed = {
  8806. nomen: true,
  8807. onevar: true,
  8808. passfail: true,
  8809. white: true,
  8810. gcl: true,
  8811. smarttabs: true,
  8812. trailing: true
  8813. };
  8814. exports.noenforceall = {
  8815. varstmt: true,
  8816. strict: true
  8817. };
  8818. },{}],"/node_modules/jshint/src/reg.js":[function(_dereq_,module,exports){
  8819. "use strict";
  8820. exports.unsafeString =
  8821. /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i;
  8822. exports.unsafeChars =
  8823. /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  8824. exports.needEsc =
  8825. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  8826. exports.needEscGlobal =
  8827. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
  8828. exports.starSlash = /\*\//;
  8829. exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
  8830. exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  8831. exports.fallsThrough = /^\s*falls?\sthrough\s*$/;
  8832. exports.maxlenException = /^(?:(?:\/\/|\/\*|\*) ?)?[^ ]+$/;
  8833. },{}],"/node_modules/jshint/src/scope-manager.js":[function(_dereq_,module,exports){
  8834. "use strict";
  8835. var _ = _dereq_("../lodash");
  8836. var events = _dereq_("events");
  8837. var marker = {};
  8838. var scopeManager = function(state, predefined, exported, declared) {
  8839. var _current;
  8840. var _scopeStack = [];
  8841. function _newScope(type) {
  8842. _current = {
  8843. "(labels)": Object.create(null),
  8844. "(usages)": Object.create(null),
  8845. "(breakLabels)": Object.create(null),
  8846. "(parent)": _current,
  8847. "(type)": type,
  8848. "(params)": (type === "functionparams" || type === "catchparams") ? [] : null
  8849. };
  8850. _scopeStack.push(_current);
  8851. }
  8852. _newScope("global");
  8853. _current["(predefined)"] = predefined;
  8854. var _currentFunctBody = _current; // this is the block after the params = function
  8855. var usedPredefinedAndGlobals = Object.create(null);
  8856. var impliedGlobals = Object.create(null);
  8857. var unuseds = [];
  8858. var emitter = new events.EventEmitter();
  8859. function warning(code, token) {
  8860. emitter.emit("warning", {
  8861. code: code,
  8862. token: token,
  8863. data: _.slice(arguments, 2)
  8864. });
  8865. }
  8866. function error(code, token) {
  8867. emitter.emit("warning", {
  8868. code: code,
  8869. token: token,
  8870. data: _.slice(arguments, 2)
  8871. });
  8872. }
  8873. function _setupUsages(labelName) {
  8874. if (!_current["(usages)"][labelName]) {
  8875. _current["(usages)"][labelName] = {
  8876. "(modified)": [],
  8877. "(reassigned)": [],
  8878. "(tokens)": []
  8879. };
  8880. }
  8881. }
  8882. var _getUnusedOption = function(unused_opt) {
  8883. if (unused_opt === undefined) {
  8884. unused_opt = state.option.unused;
  8885. }
  8886. if (unused_opt === true) {
  8887. unused_opt = "last-param";
  8888. }
  8889. return unused_opt;
  8890. };
  8891. var _warnUnused = function(name, tkn, type, unused_opt) {
  8892. var line = tkn.line;
  8893. var chr = tkn.from;
  8894. var raw_name = tkn.raw_text || name;
  8895. unused_opt = _getUnusedOption(unused_opt);
  8896. var warnable_types = {
  8897. "vars": ["var"],
  8898. "last-param": ["var", "param"],
  8899. "strict": ["var", "param", "last-param"]
  8900. };
  8901. if (unused_opt) {
  8902. if (warnable_types[unused_opt] && warnable_types[unused_opt].indexOf(type) !== -1) {
  8903. warning("W098", { line: line, from: chr }, raw_name);
  8904. }
  8905. }
  8906. if (unused_opt || type === "var") {
  8907. unuseds.push({
  8908. name: name,
  8909. line: line,
  8910. character: chr
  8911. });
  8912. }
  8913. };
  8914. function _checkForUnused() {
  8915. if (_current["(type)"] === "functionparams") {
  8916. _checkParams();
  8917. return;
  8918. }
  8919. var curentLabels = _current["(labels)"];
  8920. for (var labelName in curentLabels) {
  8921. if (curentLabels[labelName]) {
  8922. if (curentLabels[labelName]["(type)"] !== "exception" &&
  8923. curentLabels[labelName]["(unused)"]) {
  8924. _warnUnused(labelName, curentLabels[labelName]["(token)"], "var");
  8925. }
  8926. }
  8927. }
  8928. }
  8929. function _checkParams() {
  8930. var params = _current["(params)"];
  8931. if (!params) {
  8932. return;
  8933. }
  8934. var param = params.pop();
  8935. var unused_opt;
  8936. while (param) {
  8937. var label = _current["(labels)"][param];
  8938. unused_opt = _getUnusedOption(state.funct["(unusedOption)"]);
  8939. if (param === "undefined")
  8940. return;
  8941. if (label["(unused)"]) {
  8942. _warnUnused(param, label["(token)"], "param", state.funct["(unusedOption)"]);
  8943. } else if (unused_opt === "last-param") {
  8944. return;
  8945. }
  8946. param = params.pop();
  8947. }
  8948. }
  8949. function _getLabel(labelName) {
  8950. for (var i = _scopeStack.length - 1 ; i >= 0; --i) {
  8951. var scopeLabels = _scopeStack[i]["(labels)"];
  8952. if (scopeLabels[labelName]) {
  8953. return scopeLabels;
  8954. }
  8955. }
  8956. }
  8957. function usedSoFarInCurrentFunction(labelName) {
  8958. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  8959. var current = _scopeStack[i];
  8960. if (current["(usages)"][labelName]) {
  8961. return current["(usages)"][labelName];
  8962. }
  8963. if (current === _currentFunctBody) {
  8964. break;
  8965. }
  8966. }
  8967. return false;
  8968. }
  8969. function _checkOuterShadow(labelName, token) {
  8970. if (state.option.shadow !== "outer") {
  8971. return;
  8972. }
  8973. var isGlobal = _currentFunctBody["(type)"] === "global",
  8974. isNewFunction = _current["(type)"] === "functionparams";
  8975. var outsideCurrentFunction = !isGlobal;
  8976. for (var i = 0; i < _scopeStack.length; i++) {
  8977. var stackItem = _scopeStack[i];
  8978. if (!isNewFunction && _scopeStack[i + 1] === _currentFunctBody) {
  8979. outsideCurrentFunction = false;
  8980. }
  8981. if (outsideCurrentFunction && stackItem["(labels)"][labelName]) {
  8982. warning("W123", token, labelName);
  8983. }
  8984. if (stackItem["(breakLabels)"][labelName]) {
  8985. warning("W123", token, labelName);
  8986. }
  8987. }
  8988. }
  8989. function _latedefWarning(type, labelName, token) {
  8990. if (state.option.latedef) {
  8991. if ((state.option.latedef === true && type === "function") ||
  8992. type !== "function") {
  8993. warning("W003", token, labelName);
  8994. }
  8995. }
  8996. }
  8997. var scopeManagerInst = {
  8998. on: function(names, listener) {
  8999. names.split(" ").forEach(function(name) {
  9000. emitter.on(name, listener);
  9001. });
  9002. },
  9003. isPredefined: function(labelName) {
  9004. return !this.has(labelName) && _.has(_scopeStack[0]["(predefined)"], labelName);
  9005. },
  9006. stack: function(type) {
  9007. var previousScope = _current;
  9008. _newScope(type);
  9009. if (!type && previousScope["(type)"] === "functionparams") {
  9010. _current["(isFuncBody)"] = true;
  9011. _current["(context)"] = _currentFunctBody;
  9012. _currentFunctBody = _current;
  9013. }
  9014. },
  9015. unstack: function() {
  9016. var subScope = _scopeStack.length > 1 ? _scopeStack[_scopeStack.length - 2] : null;
  9017. var isUnstackingFunctionBody = _current === _currentFunctBody,
  9018. isUnstackingFunctionParams = _current["(type)"] === "functionparams",
  9019. isUnstackingFunctionOuter = _current["(type)"] === "functionouter";
  9020. var i, j;
  9021. var currentUsages = _current["(usages)"];
  9022. var currentLabels = _current["(labels)"];
  9023. var usedLabelNameList = Object.keys(currentUsages);
  9024. if (currentUsages.__proto__ && usedLabelNameList.indexOf("__proto__") === -1) {
  9025. usedLabelNameList.push("__proto__");
  9026. }
  9027. for (i = 0; i < usedLabelNameList.length; i++) {
  9028. var usedLabelName = usedLabelNameList[i];
  9029. var usage = currentUsages[usedLabelName];
  9030. var usedLabel = currentLabels[usedLabelName];
  9031. if (usedLabel) {
  9032. var usedLabelType = usedLabel["(type)"];
  9033. if (usedLabel["(useOutsideOfScope)"] && !state.option.funcscope) {
  9034. var usedTokens = usage["(tokens)"];
  9035. if (usedTokens) {
  9036. for (j = 0; j < usedTokens.length; j++) {
  9037. if (usedLabel["(function)"] === usedTokens[j]["(function)"]) {
  9038. error("W038", usedTokens[j], usedLabelName);
  9039. }
  9040. }
  9041. }
  9042. }
  9043. _current["(labels)"][usedLabelName]["(unused)"] = false;
  9044. if (usedLabelType === "const" && usage["(modified)"]) {
  9045. for (j = 0; j < usage["(modified)"].length; j++) {
  9046. error("E013", usage["(modified)"][j], usedLabelName);
  9047. }
  9048. }
  9049. if ((usedLabelType === "function" || usedLabelType === "class") &&
  9050. usage["(reassigned)"]) {
  9051. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9052. error("W021", usage["(reassigned)"][j], usedLabelName, usedLabelType);
  9053. }
  9054. }
  9055. continue;
  9056. }
  9057. if (isUnstackingFunctionOuter) {
  9058. state.funct["(isCapturing)"] = true;
  9059. }
  9060. if (subScope) {
  9061. if (!subScope["(usages)"][usedLabelName]) {
  9062. subScope["(usages)"][usedLabelName] = usage;
  9063. if (isUnstackingFunctionBody) {
  9064. subScope["(usages)"][usedLabelName]["(onlyUsedSubFunction)"] = true;
  9065. }
  9066. } else {
  9067. var subScopeUsage = subScope["(usages)"][usedLabelName];
  9068. subScopeUsage["(modified)"] = subScopeUsage["(modified)"].concat(usage["(modified)"]);
  9069. subScopeUsage["(tokens)"] = subScopeUsage["(tokens)"].concat(usage["(tokens)"]);
  9070. subScopeUsage["(reassigned)"] =
  9071. subScopeUsage["(reassigned)"].concat(usage["(reassigned)"]);
  9072. subScopeUsage["(onlyUsedSubFunction)"] = false;
  9073. }
  9074. } else {
  9075. if (typeof _current["(predefined)"][usedLabelName] === "boolean") {
  9076. delete declared[usedLabelName];
  9077. usedPredefinedAndGlobals[usedLabelName] = marker;
  9078. if (_current["(predefined)"][usedLabelName] === false && usage["(reassigned)"]) {
  9079. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9080. warning("W020", usage["(reassigned)"][j]);
  9081. }
  9082. }
  9083. }
  9084. else {
  9085. if (usage["(tokens)"]) {
  9086. for (j = 0; j < usage["(tokens)"].length; j++) {
  9087. var undefinedToken = usage["(tokens)"][j];
  9088. if (!undefinedToken.forgiveUndef) {
  9089. if (state.option.undef && !undefinedToken.ignoreUndef) {
  9090. warning("W117", undefinedToken, usedLabelName);
  9091. }
  9092. if (impliedGlobals[usedLabelName]) {
  9093. impliedGlobals[usedLabelName].line.push(undefinedToken.line);
  9094. } else {
  9095. impliedGlobals[usedLabelName] = {
  9096. name: usedLabelName,
  9097. line: [undefinedToken.line]
  9098. };
  9099. }
  9100. }
  9101. }
  9102. }
  9103. }
  9104. }
  9105. }
  9106. if (!subScope) {
  9107. Object.keys(declared)
  9108. .forEach(function(labelNotUsed) {
  9109. _warnUnused(labelNotUsed, declared[labelNotUsed], "var");
  9110. });
  9111. }
  9112. if (subScope && !isUnstackingFunctionBody &&
  9113. !isUnstackingFunctionParams && !isUnstackingFunctionOuter) {
  9114. var labelNames = Object.keys(currentLabels);
  9115. for (i = 0; i < labelNames.length; i++) {
  9116. var defLabelName = labelNames[i];
  9117. if (!currentLabels[defLabelName]["(blockscoped)"] &&
  9118. currentLabels[defLabelName]["(type)"] !== "exception" &&
  9119. !this.funct.has(defLabelName, { excludeCurrent: true })) {
  9120. subScope["(labels)"][defLabelName] = currentLabels[defLabelName];
  9121. if (_currentFunctBody["(type)"] !== "global") {
  9122. subScope["(labels)"][defLabelName]["(useOutsideOfScope)"] = true;
  9123. }
  9124. delete currentLabels[defLabelName];
  9125. }
  9126. }
  9127. }
  9128. _checkForUnused();
  9129. _scopeStack.pop();
  9130. if (isUnstackingFunctionBody) {
  9131. _currentFunctBody = _scopeStack[_.findLastIndex(_scopeStack, function(scope) {
  9132. return scope["(isFuncBody)"] || scope["(type)"] === "global";
  9133. })];
  9134. }
  9135. _current = subScope;
  9136. },
  9137. addParam: function(labelName, token, type) {
  9138. type = type || "param";
  9139. if (type === "exception") {
  9140. var previouslyDefinedLabelType = this.funct.labeltype(labelName);
  9141. if (previouslyDefinedLabelType && previouslyDefinedLabelType !== "exception") {
  9142. if (!state.option.node) {
  9143. warning("W002", state.tokens.next, labelName);
  9144. }
  9145. }
  9146. }
  9147. if (_.has(_current["(labels)"], labelName)) {
  9148. _current["(labels)"][labelName].duplicated = true;
  9149. } else {
  9150. _checkOuterShadow(labelName, token, type);
  9151. _current["(labels)"][labelName] = {
  9152. "(type)" : type,
  9153. "(token)": token,
  9154. "(unused)": true };
  9155. _current["(params)"].push(labelName);
  9156. }
  9157. if (_.has(_current["(usages)"], labelName)) {
  9158. var usage = _current["(usages)"][labelName];
  9159. if (usage["(onlyUsedSubFunction)"]) {
  9160. _latedefWarning(type, labelName, token);
  9161. } else {
  9162. warning("E056", token, labelName, type);
  9163. }
  9164. }
  9165. },
  9166. validateParams: function() {
  9167. if (_currentFunctBody["(type)"] === "global") {
  9168. return;
  9169. }
  9170. var isStrict = state.isStrict();
  9171. var currentFunctParamScope = _currentFunctBody["(parent)"];
  9172. if (!currentFunctParamScope["(params)"]) {
  9173. return;
  9174. }
  9175. currentFunctParamScope["(params)"].forEach(function(labelName) {
  9176. var label = currentFunctParamScope["(labels)"][labelName];
  9177. if (label && label.duplicated) {
  9178. if (isStrict) {
  9179. warning("E011", label["(token)"], labelName);
  9180. } else if (state.option.shadow !== true) {
  9181. warning("W004", label["(token)"], labelName);
  9182. }
  9183. }
  9184. });
  9185. },
  9186. getUsedOrDefinedGlobals: function() {
  9187. var list = Object.keys(usedPredefinedAndGlobals);
  9188. if (usedPredefinedAndGlobals.__proto__ === marker &&
  9189. list.indexOf("__proto__") === -1) {
  9190. list.push("__proto__");
  9191. }
  9192. return list;
  9193. },
  9194. getImpliedGlobals: function() {
  9195. var values = _.values(impliedGlobals);
  9196. var hasProto = false;
  9197. if (impliedGlobals.__proto__) {
  9198. hasProto = values.some(function(value) {
  9199. return value.name === "__proto__";
  9200. });
  9201. if (!hasProto) {
  9202. values.push(impliedGlobals.__proto__);
  9203. }
  9204. }
  9205. return values;
  9206. },
  9207. getUnuseds: function() {
  9208. return unuseds;
  9209. },
  9210. has: function(labelName) {
  9211. return Boolean(_getLabel(labelName));
  9212. },
  9213. labeltype: function(labelName) {
  9214. var scopeLabels = _getLabel(labelName);
  9215. if (scopeLabels) {
  9216. return scopeLabels[labelName]["(type)"];
  9217. }
  9218. return null;
  9219. },
  9220. addExported: function(labelName) {
  9221. var globalLabels = _scopeStack[0]["(labels)"];
  9222. if (_.has(declared, labelName)) {
  9223. delete declared[labelName];
  9224. } else if (_.has(globalLabels, labelName)) {
  9225. globalLabels[labelName]["(unused)"] = false;
  9226. } else {
  9227. for (var i = 1; i < _scopeStack.length; i++) {
  9228. var scope = _scopeStack[i];
  9229. if (!scope["(type)"]) {
  9230. if (_.has(scope["(labels)"], labelName) &&
  9231. !scope["(labels)"][labelName]["(blockscoped)"]) {
  9232. scope["(labels)"][labelName]["(unused)"] = false;
  9233. return;
  9234. }
  9235. } else {
  9236. break;
  9237. }
  9238. }
  9239. exported[labelName] = true;
  9240. }
  9241. },
  9242. setExported: function(labelName, token) {
  9243. this.block.use(labelName, token);
  9244. },
  9245. addlabel: function(labelName, opts) {
  9246. var type = opts.type;
  9247. var token = opts.token;
  9248. var isblockscoped = type === "let" || type === "const" || type === "class";
  9249. var isexported = (isblockscoped ? _current : _currentFunctBody)["(type)"] === "global" &&
  9250. _.has(exported, labelName);
  9251. _checkOuterShadow(labelName, token, type);
  9252. if (isblockscoped) {
  9253. var declaredInCurrentScope = _current["(labels)"][labelName];
  9254. if (!declaredInCurrentScope && _current === _currentFunctBody &&
  9255. _current["(type)"] !== "global") {
  9256. declaredInCurrentScope = !!_currentFunctBody["(parent)"]["(labels)"][labelName];
  9257. }
  9258. if (!declaredInCurrentScope && _current["(usages)"][labelName]) {
  9259. var usage = _current["(usages)"][labelName];
  9260. if (usage["(onlyUsedSubFunction)"]) {
  9261. _latedefWarning(type, labelName, token);
  9262. } else {
  9263. warning("E056", token, labelName, type);
  9264. }
  9265. }
  9266. if (declaredInCurrentScope) {
  9267. warning("E011", token, labelName);
  9268. }
  9269. else if (state.option.shadow === "outer") {
  9270. if (scopeManagerInst.funct.has(labelName)) {
  9271. warning("W004", token, labelName);
  9272. }
  9273. }
  9274. scopeManagerInst.block.add(labelName, type, token, !isexported);
  9275. } else {
  9276. var declaredInCurrentFunctionScope = scopeManagerInst.funct.has(labelName);
  9277. if (!declaredInCurrentFunctionScope && usedSoFarInCurrentFunction(labelName)) {
  9278. _latedefWarning(type, labelName, token);
  9279. }
  9280. if (scopeManagerInst.funct.has(labelName, { onlyBlockscoped: true })) {
  9281. warning("E011", token, labelName);
  9282. } else if (state.option.shadow !== true) {
  9283. if (declaredInCurrentFunctionScope && labelName !== "__proto__") {
  9284. if (_currentFunctBody["(type)"] !== "global") {
  9285. warning("W004", token, labelName);
  9286. }
  9287. }
  9288. }
  9289. scopeManagerInst.funct.add(labelName, type, token, !isexported);
  9290. if (_currentFunctBody["(type)"] === "global") {
  9291. usedPredefinedAndGlobals[labelName] = marker;
  9292. }
  9293. }
  9294. },
  9295. funct: {
  9296. labeltype: function(labelName, options) {
  9297. var onlyBlockscoped = options && options.onlyBlockscoped;
  9298. var excludeParams = options && options.excludeParams;
  9299. var currentScopeIndex = _scopeStack.length - (options && options.excludeCurrent ? 2 : 1);
  9300. for (var i = currentScopeIndex; i >= 0; i--) {
  9301. var current = _scopeStack[i];
  9302. if (current["(labels)"][labelName] &&
  9303. (!onlyBlockscoped || current["(labels)"][labelName]["(blockscoped)"])) {
  9304. return current["(labels)"][labelName]["(type)"];
  9305. }
  9306. var scopeCheck = excludeParams ? _scopeStack[ i - 1 ] : current;
  9307. if (scopeCheck && scopeCheck["(type)"] === "functionparams") {
  9308. return null;
  9309. }
  9310. }
  9311. return null;
  9312. },
  9313. hasBreakLabel: function(labelName) {
  9314. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  9315. var current = _scopeStack[i];
  9316. if (current["(breakLabels)"][labelName]) {
  9317. return true;
  9318. }
  9319. if (current["(type)"] === "functionparams") {
  9320. return false;
  9321. }
  9322. }
  9323. return false;
  9324. },
  9325. has: function(labelName, options) {
  9326. return Boolean(this.labeltype(labelName, options));
  9327. },
  9328. add: function(labelName, type, tok, unused) {
  9329. _current["(labels)"][labelName] = {
  9330. "(type)" : type,
  9331. "(token)": tok,
  9332. "(blockscoped)": false,
  9333. "(function)": _currentFunctBody,
  9334. "(unused)": unused };
  9335. }
  9336. },
  9337. block: {
  9338. isGlobal: function() {
  9339. return _current["(type)"] === "global";
  9340. },
  9341. use: function(labelName, token) {
  9342. var paramScope = _currentFunctBody["(parent)"];
  9343. if (paramScope && paramScope["(labels)"][labelName] &&
  9344. paramScope["(labels)"][labelName]["(type)"] === "param") {
  9345. if (!scopeManagerInst.funct.has(labelName,
  9346. { excludeParams: true, onlyBlockscoped: true })) {
  9347. paramScope["(labels)"][labelName]["(unused)"] = false;
  9348. }
  9349. }
  9350. if (token && (state.ignored.W117 || state.option.undef === false)) {
  9351. token.ignoreUndef = true;
  9352. }
  9353. _setupUsages(labelName);
  9354. if (token) {
  9355. token["(function)"] = _currentFunctBody;
  9356. _current["(usages)"][labelName]["(tokens)"].push(token);
  9357. }
  9358. },
  9359. reassign: function(labelName, token) {
  9360. this.modify(labelName, token);
  9361. _current["(usages)"][labelName]["(reassigned)"].push(token);
  9362. },
  9363. modify: function(labelName, token) {
  9364. _setupUsages(labelName);
  9365. _current["(usages)"][labelName]["(modified)"].push(token);
  9366. },
  9367. add: function(labelName, type, tok, unused) {
  9368. _current["(labels)"][labelName] = {
  9369. "(type)" : type,
  9370. "(token)": tok,
  9371. "(blockscoped)": true,
  9372. "(unused)": unused };
  9373. },
  9374. addBreakLabel: function(labelName, opts) {
  9375. var token = opts.token;
  9376. if (scopeManagerInst.funct.hasBreakLabel(labelName)) {
  9377. warning("E011", token, labelName);
  9378. }
  9379. else if (state.option.shadow === "outer") {
  9380. if (scopeManagerInst.funct.has(labelName)) {
  9381. warning("W004", token, labelName);
  9382. } else {
  9383. _checkOuterShadow(labelName, token);
  9384. }
  9385. }
  9386. _current["(breakLabels)"][labelName] = token;
  9387. }
  9388. }
  9389. };
  9390. return scopeManagerInst;
  9391. };
  9392. module.exports = scopeManager;
  9393. },{"../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){
  9394. "use strict";
  9395. var NameStack = _dereq_("./name-stack.js");
  9396. var state = {
  9397. syntax: {},
  9398. isStrict: function() {
  9399. return this.directive["use strict"] || this.inClassBody ||
  9400. this.option.module || this.option.strict === "implied";
  9401. },
  9402. inMoz: function() {
  9403. return this.option.moz;
  9404. },
  9405. inES6: function() {
  9406. return this.option.moz || this.option.esversion >= 6;
  9407. },
  9408. inES5: function(strict) {
  9409. if (strict) {
  9410. return (!this.option.esversion || this.option.esversion === 5) && !this.option.moz;
  9411. }
  9412. return !this.option.esversion || this.option.esversion >= 5 || this.option.moz;
  9413. },
  9414. reset: function() {
  9415. this.tokens = {
  9416. prev: null,
  9417. next: null,
  9418. curr: null
  9419. };
  9420. this.option = {};
  9421. this.funct = null;
  9422. this.ignored = {};
  9423. this.directive = {};
  9424. this.jsonMode = false;
  9425. this.jsonWarnings = [];
  9426. this.lines = [];
  9427. this.tab = "";
  9428. this.cache = {}; // Node.JS doesn't have Map. Sniff.
  9429. this.ignoredLines = {};
  9430. this.forinifcheckneeded = false;
  9431. this.nameStack = new NameStack();
  9432. this.inClassBody = false;
  9433. }
  9434. };
  9435. exports.state = state;
  9436. },{"./name-stack.js":"/node_modules/jshint/src/name-stack.js"}],"/node_modules/jshint/src/style.js":[function(_dereq_,module,exports){
  9437. "use strict";
  9438. exports.register = function(linter) {
  9439. linter.on("Identifier", function style_scanProto(data) {
  9440. if (linter.getOption("proto")) {
  9441. return;
  9442. }
  9443. if (data.name === "__proto__") {
  9444. linter.warn("W103", {
  9445. line: data.line,
  9446. char: data.char,
  9447. data: [ data.name, "6" ]
  9448. });
  9449. }
  9450. });
  9451. linter.on("Identifier", function style_scanIterator(data) {
  9452. if (linter.getOption("iterator")) {
  9453. return;
  9454. }
  9455. if (data.name === "__iterator__") {
  9456. linter.warn("W103", {
  9457. line: data.line,
  9458. char: data.char,
  9459. data: [ data.name ]
  9460. });
  9461. }
  9462. });
  9463. linter.on("Identifier", function style_scanCamelCase(data) {
  9464. if (!linter.getOption("camelcase")) {
  9465. return;
  9466. }
  9467. if (data.name.replace(/^_+|_+$/g, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) {
  9468. linter.warn("W106", {
  9469. line: data.line,
  9470. char: data.from,
  9471. data: [ data.name ]
  9472. });
  9473. }
  9474. });
  9475. linter.on("String", function style_scanQuotes(data) {
  9476. var quotmark = linter.getOption("quotmark");
  9477. var code;
  9478. if (!quotmark) {
  9479. return;
  9480. }
  9481. if (quotmark === "single" && data.quote !== "'") {
  9482. code = "W109";
  9483. }
  9484. if (quotmark === "double" && data.quote !== "\"") {
  9485. code = "W108";
  9486. }
  9487. if (quotmark === true) {
  9488. if (!linter.getCache("quotmark")) {
  9489. linter.setCache("quotmark", data.quote);
  9490. }
  9491. if (linter.getCache("quotmark") !== data.quote) {
  9492. code = "W110";
  9493. }
  9494. }
  9495. if (code) {
  9496. linter.warn(code, {
  9497. line: data.line,
  9498. char: data.char,
  9499. });
  9500. }
  9501. });
  9502. linter.on("Number", function style_scanNumbers(data) {
  9503. if (data.value.charAt(0) === ".") {
  9504. linter.warn("W008", {
  9505. line: data.line,
  9506. char: data.char,
  9507. data: [ data.value ]
  9508. });
  9509. }
  9510. if (data.value.substr(data.value.length - 1) === ".") {
  9511. linter.warn("W047", {
  9512. line: data.line,
  9513. char: data.char,
  9514. data: [ data.value ]
  9515. });
  9516. }
  9517. if (/^00+/.test(data.value)) {
  9518. linter.warn("W046", {
  9519. line: data.line,
  9520. char: data.char,
  9521. data: [ data.value ]
  9522. });
  9523. }
  9524. });
  9525. linter.on("String", function style_scanJavaScriptURLs(data) {
  9526. var re = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  9527. if (linter.getOption("scripturl")) {
  9528. return;
  9529. }
  9530. if (re.test(data.value)) {
  9531. linter.warn("W107", {
  9532. line: data.line,
  9533. char: data.char
  9534. });
  9535. }
  9536. });
  9537. };
  9538. },{}],"/node_modules/jshint/src/vars.js":[function(_dereq_,module,exports){
  9539. "use strict";
  9540. exports.reservedVars = {
  9541. arguments : false,
  9542. NaN : false
  9543. };
  9544. exports.ecmaIdentifiers = {
  9545. 3: {
  9546. Array : false,
  9547. Boolean : false,
  9548. Date : false,
  9549. decodeURI : false,
  9550. decodeURIComponent : false,
  9551. encodeURI : false,
  9552. encodeURIComponent : false,
  9553. Error : false,
  9554. "eval" : false,
  9555. EvalError : false,
  9556. Function : false,
  9557. hasOwnProperty : false,
  9558. isFinite : false,
  9559. isNaN : false,
  9560. Math : false,
  9561. Number : false,
  9562. Object : false,
  9563. parseInt : false,
  9564. parseFloat : false,
  9565. RangeError : false,
  9566. ReferenceError : false,
  9567. RegExp : false,
  9568. String : false,
  9569. SyntaxError : false,
  9570. TypeError : false,
  9571. URIError : false
  9572. },
  9573. 5: {
  9574. JSON : false
  9575. },
  9576. 6: {
  9577. Map : false,
  9578. Promise : false,
  9579. Proxy : false,
  9580. Reflect : false,
  9581. Set : false,
  9582. Symbol : false,
  9583. WeakMap : false,
  9584. WeakSet : false
  9585. }
  9586. };
  9587. exports.browser = {
  9588. Audio : false,
  9589. Blob : false,
  9590. addEventListener : false,
  9591. applicationCache : false,
  9592. atob : false,
  9593. blur : false,
  9594. btoa : false,
  9595. cancelAnimationFrame : false,
  9596. CanvasGradient : false,
  9597. CanvasPattern : false,
  9598. CanvasRenderingContext2D: false,
  9599. CSS : false,
  9600. clearInterval : false,
  9601. clearTimeout : false,
  9602. close : false,
  9603. closed : false,
  9604. Comment : false,
  9605. CustomEvent : false,
  9606. DOMParser : false,
  9607. defaultStatus : false,
  9608. Document : false,
  9609. document : false,
  9610. DocumentFragment : false,
  9611. Element : false,
  9612. ElementTimeControl : false,
  9613. Event : false,
  9614. event : false,
  9615. fetch : false,
  9616. FileReader : false,
  9617. FormData : false,
  9618. focus : false,
  9619. frames : false,
  9620. getComputedStyle : false,
  9621. HTMLElement : false,
  9622. HTMLAnchorElement : false,
  9623. HTMLBaseElement : false,
  9624. HTMLBlockquoteElement: false,
  9625. HTMLBodyElement : false,
  9626. HTMLBRElement : false,
  9627. HTMLButtonElement : false,
  9628. HTMLCanvasElement : false,
  9629. HTMLCollection : false,
  9630. HTMLDirectoryElement : false,
  9631. HTMLDivElement : false,
  9632. HTMLDListElement : false,
  9633. HTMLFieldSetElement : false,
  9634. HTMLFontElement : false,
  9635. HTMLFormElement : false,
  9636. HTMLFrameElement : false,
  9637. HTMLFrameSetElement : false,
  9638. HTMLHeadElement : false,
  9639. HTMLHeadingElement : false,
  9640. HTMLHRElement : false,
  9641. HTMLHtmlElement : false,
  9642. HTMLIFrameElement : false,
  9643. HTMLImageElement : false,
  9644. HTMLInputElement : false,
  9645. HTMLIsIndexElement : false,
  9646. HTMLLabelElement : false,
  9647. HTMLLayerElement : false,
  9648. HTMLLegendElement : false,
  9649. HTMLLIElement : false,
  9650. HTMLLinkElement : false,
  9651. HTMLMapElement : false,
  9652. HTMLMenuElement : false,
  9653. HTMLMetaElement : false,
  9654. HTMLModElement : false,
  9655. HTMLObjectElement : false,
  9656. HTMLOListElement : false,
  9657. HTMLOptGroupElement : false,
  9658. HTMLOptionElement : false,
  9659. HTMLParagraphElement : false,
  9660. HTMLParamElement : false,
  9661. HTMLPreElement : false,
  9662. HTMLQuoteElement : false,
  9663. HTMLScriptElement : false,
  9664. HTMLSelectElement : false,
  9665. HTMLStyleElement : false,
  9666. HTMLTableCaptionElement: false,
  9667. HTMLTableCellElement : false,
  9668. HTMLTableColElement : false,
  9669. HTMLTableElement : false,
  9670. HTMLTableRowElement : false,
  9671. HTMLTableSectionElement: false,
  9672. HTMLTemplateElement : false,
  9673. HTMLTextAreaElement : false,
  9674. HTMLTitleElement : false,
  9675. HTMLUListElement : false,
  9676. HTMLVideoElement : false,
  9677. history : false,
  9678. Image : false,
  9679. Intl : false,
  9680. length : false,
  9681. localStorage : false,
  9682. location : false,
  9683. matchMedia : false,
  9684. MessageChannel : false,
  9685. MessageEvent : false,
  9686. MessagePort : false,
  9687. MouseEvent : false,
  9688. moveBy : false,
  9689. moveTo : false,
  9690. MutationObserver : false,
  9691. name : false,
  9692. Node : false,
  9693. NodeFilter : false,
  9694. NodeList : false,
  9695. Notification : false,
  9696. navigator : false,
  9697. onbeforeunload : true,
  9698. onblur : true,
  9699. onerror : true,
  9700. onfocus : true,
  9701. onload : true,
  9702. onresize : true,
  9703. onunload : true,
  9704. open : false,
  9705. openDatabase : false,
  9706. opener : false,
  9707. Option : false,
  9708. parent : false,
  9709. performance : false,
  9710. print : false,
  9711. Range : false,
  9712. requestAnimationFrame : false,
  9713. removeEventListener : false,
  9714. resizeBy : false,
  9715. resizeTo : false,
  9716. screen : false,
  9717. scroll : false,
  9718. scrollBy : false,
  9719. scrollTo : false,
  9720. sessionStorage : false,
  9721. setInterval : false,
  9722. setTimeout : false,
  9723. SharedWorker : false,
  9724. status : false,
  9725. SVGAElement : false,
  9726. SVGAltGlyphDefElement: false,
  9727. SVGAltGlyphElement : false,
  9728. SVGAltGlyphItemElement: false,
  9729. SVGAngle : false,
  9730. SVGAnimateColorElement: false,
  9731. SVGAnimateElement : false,
  9732. SVGAnimateMotionElement: false,
  9733. SVGAnimateTransformElement: false,
  9734. SVGAnimatedAngle : false,
  9735. SVGAnimatedBoolean : false,
  9736. SVGAnimatedEnumeration: false,
  9737. SVGAnimatedInteger : false,
  9738. SVGAnimatedLength : false,
  9739. SVGAnimatedLengthList: false,
  9740. SVGAnimatedNumber : false,
  9741. SVGAnimatedNumberList: false,
  9742. SVGAnimatedPathData : false,
  9743. SVGAnimatedPoints : false,
  9744. SVGAnimatedPreserveAspectRatio: false,
  9745. SVGAnimatedRect : false,
  9746. SVGAnimatedString : false,
  9747. SVGAnimatedTransformList: false,
  9748. SVGAnimationElement : false,
  9749. SVGCSSRule : false,
  9750. SVGCircleElement : false,
  9751. SVGClipPathElement : false,
  9752. SVGColor : false,
  9753. SVGColorProfileElement: false,
  9754. SVGColorProfileRule : false,
  9755. SVGComponentTransferFunctionElement: false,
  9756. SVGCursorElement : false,
  9757. SVGDefsElement : false,
  9758. SVGDescElement : false,
  9759. SVGDocument : false,
  9760. SVGElement : false,
  9761. SVGElementInstance : false,
  9762. SVGElementInstanceList: false,
  9763. SVGEllipseElement : false,
  9764. SVGExternalResourcesRequired: false,
  9765. SVGFEBlendElement : false,
  9766. SVGFEColorMatrixElement: false,
  9767. SVGFEComponentTransferElement: false,
  9768. SVGFECompositeElement: false,
  9769. SVGFEConvolveMatrixElement: false,
  9770. SVGFEDiffuseLightingElement: false,
  9771. SVGFEDisplacementMapElement: false,
  9772. SVGFEDistantLightElement: false,
  9773. SVGFEFloodElement : false,
  9774. SVGFEFuncAElement : false,
  9775. SVGFEFuncBElement : false,
  9776. SVGFEFuncGElement : false,
  9777. SVGFEFuncRElement : false,
  9778. SVGFEGaussianBlurElement: false,
  9779. SVGFEImageElement : false,
  9780. SVGFEMergeElement : false,
  9781. SVGFEMergeNodeElement: false,
  9782. SVGFEMorphologyElement: false,
  9783. SVGFEOffsetElement : false,
  9784. SVGFEPointLightElement: false,
  9785. SVGFESpecularLightingElement: false,
  9786. SVGFESpotLightElement: false,
  9787. SVGFETileElement : false,
  9788. SVGFETurbulenceElement: false,
  9789. SVGFilterElement : false,
  9790. SVGFilterPrimitiveStandardAttributes: false,
  9791. SVGFitToViewBox : false,
  9792. SVGFontElement : false,
  9793. SVGFontFaceElement : false,
  9794. SVGFontFaceFormatElement: false,
  9795. SVGFontFaceNameElement: false,
  9796. SVGFontFaceSrcElement: false,
  9797. SVGFontFaceUriElement: false,
  9798. SVGForeignObjectElement: false,
  9799. SVGGElement : false,
  9800. SVGGlyphElement : false,
  9801. SVGGlyphRefElement : false,
  9802. SVGGradientElement : false,
  9803. SVGHKernElement : false,
  9804. SVGICCColor : false,
  9805. SVGImageElement : false,
  9806. SVGLangSpace : false,
  9807. SVGLength : false,
  9808. SVGLengthList : false,
  9809. SVGLineElement : false,
  9810. SVGLinearGradientElement: false,
  9811. SVGLocatable : false,
  9812. SVGMPathElement : false,
  9813. SVGMarkerElement : false,
  9814. SVGMaskElement : false,
  9815. SVGMatrix : false,
  9816. SVGMetadataElement : false,
  9817. SVGMissingGlyphElement: false,
  9818. SVGNumber : false,
  9819. SVGNumberList : false,
  9820. SVGPaint : false,
  9821. SVGPathElement : false,
  9822. SVGPathSeg : false,
  9823. SVGPathSegArcAbs : false,
  9824. SVGPathSegArcRel : false,
  9825. SVGPathSegClosePath : false,
  9826. SVGPathSegCurvetoCubicAbs: false,
  9827. SVGPathSegCurvetoCubicRel: false,
  9828. SVGPathSegCurvetoCubicSmoothAbs: false,
  9829. SVGPathSegCurvetoCubicSmoothRel: false,
  9830. SVGPathSegCurvetoQuadraticAbs: false,
  9831. SVGPathSegCurvetoQuadraticRel: false,
  9832. SVGPathSegCurvetoQuadraticSmoothAbs: false,
  9833. SVGPathSegCurvetoQuadraticSmoothRel: false,
  9834. SVGPathSegLinetoAbs : false,
  9835. SVGPathSegLinetoHorizontalAbs: false,
  9836. SVGPathSegLinetoHorizontalRel: false,
  9837. SVGPathSegLinetoRel : false,
  9838. SVGPathSegLinetoVerticalAbs: false,
  9839. SVGPathSegLinetoVerticalRel: false,
  9840. SVGPathSegList : false,
  9841. SVGPathSegMovetoAbs : false,
  9842. SVGPathSegMovetoRel : false,
  9843. SVGPatternElement : false,
  9844. SVGPoint : false,
  9845. SVGPointList : false,
  9846. SVGPolygonElement : false,
  9847. SVGPolylineElement : false,
  9848. SVGPreserveAspectRatio: false,
  9849. SVGRadialGradientElement: false,
  9850. SVGRect : false,
  9851. SVGRectElement : false,
  9852. SVGRenderingIntent : false,
  9853. SVGSVGElement : false,
  9854. SVGScriptElement : false,
  9855. SVGSetElement : false,
  9856. SVGStopElement : false,
  9857. SVGStringList : false,
  9858. SVGStylable : false,
  9859. SVGStyleElement : false,
  9860. SVGSwitchElement : false,
  9861. SVGSymbolElement : false,
  9862. SVGTRefElement : false,
  9863. SVGTSpanElement : false,
  9864. SVGTests : false,
  9865. SVGTextContentElement: false,
  9866. SVGTextElement : false,
  9867. SVGTextPathElement : false,
  9868. SVGTextPositioningElement: false,
  9869. SVGTitleElement : false,
  9870. SVGTransform : false,
  9871. SVGTransformList : false,
  9872. SVGTransformable : false,
  9873. SVGURIReference : false,
  9874. SVGUnitTypes : false,
  9875. SVGUseElement : false,
  9876. SVGVKernElement : false,
  9877. SVGViewElement : false,
  9878. SVGViewSpec : false,
  9879. SVGZoomAndPan : false,
  9880. Text : false,
  9881. TextDecoder : false,
  9882. TextEncoder : false,
  9883. TimeEvent : false,
  9884. top : false,
  9885. URL : false,
  9886. WebGLActiveInfo : false,
  9887. WebGLBuffer : false,
  9888. WebGLContextEvent : false,
  9889. WebGLFramebuffer : false,
  9890. WebGLProgram : false,
  9891. WebGLRenderbuffer : false,
  9892. WebGLRenderingContext: false,
  9893. WebGLShader : false,
  9894. WebGLShaderPrecisionFormat: false,
  9895. WebGLTexture : false,
  9896. WebGLUniformLocation : false,
  9897. WebSocket : false,
  9898. window : false,
  9899. Window : false,
  9900. Worker : false,
  9901. XDomainRequest : false,
  9902. XMLHttpRequest : false,
  9903. XMLSerializer : false,
  9904. XPathEvaluator : false,
  9905. XPathException : false,
  9906. XPathExpression : false,
  9907. XPathNamespace : false,
  9908. XPathNSResolver : false,
  9909. XPathResult : false
  9910. };
  9911. exports.devel = {
  9912. alert : false,
  9913. confirm: false,
  9914. console: false,
  9915. Debug : false,
  9916. opera : false,
  9917. prompt : false
  9918. };
  9919. exports.worker = {
  9920. importScripts : true,
  9921. postMessage : true,
  9922. self : true,
  9923. FileReaderSync : true
  9924. };
  9925. exports.nonstandard = {
  9926. escape : false,
  9927. unescape: false
  9928. };
  9929. exports.couch = {
  9930. "require" : false,
  9931. respond : false,
  9932. getRow : false,
  9933. emit : false,
  9934. send : false,
  9935. start : false,
  9936. sum : false,
  9937. log : false,
  9938. exports : false,
  9939. module : false,
  9940. provides : false
  9941. };
  9942. exports.node = {
  9943. __filename : false,
  9944. __dirname : false,
  9945. GLOBAL : false,
  9946. global : false,
  9947. module : false,
  9948. require : false,
  9949. Buffer : true,
  9950. console : true,
  9951. exports : true,
  9952. process : true,
  9953. setTimeout : true,
  9954. clearTimeout : true,
  9955. setInterval : true,
  9956. clearInterval : true,
  9957. setImmediate : true, // v0.9.1+
  9958. clearImmediate: true // v0.9.1+
  9959. };
  9960. exports.browserify = {
  9961. __filename : false,
  9962. __dirname : false,
  9963. global : false,
  9964. module : false,
  9965. require : false,
  9966. Buffer : true,
  9967. exports : true,
  9968. process : true
  9969. };
  9970. exports.phantom = {
  9971. phantom : true,
  9972. require : true,
  9973. WebPage : true,
  9974. console : true, // in examples, but undocumented
  9975. exports : true // v1.7+
  9976. };
  9977. exports.qunit = {
  9978. asyncTest : false,
  9979. deepEqual : false,
  9980. equal : false,
  9981. expect : false,
  9982. module : false,
  9983. notDeepEqual : false,
  9984. notEqual : false,
  9985. notPropEqual : false,
  9986. notStrictEqual : false,
  9987. ok : false,
  9988. propEqual : false,
  9989. QUnit : false,
  9990. raises : false,
  9991. start : false,
  9992. stop : false,
  9993. strictEqual : false,
  9994. test : false,
  9995. "throws" : false
  9996. };
  9997. exports.rhino = {
  9998. defineClass : false,
  9999. deserialize : false,
  10000. gc : false,
  10001. help : false,
  10002. importClass : false,
  10003. importPackage: false,
  10004. "java" : false,
  10005. load : false,
  10006. loadClass : false,
  10007. Packages : false,
  10008. print : false,
  10009. quit : false,
  10010. readFile : false,
  10011. readUrl : false,
  10012. runCommand : false,
  10013. seal : false,
  10014. serialize : false,
  10015. spawn : false,
  10016. sync : false,
  10017. toint32 : false,
  10018. version : false
  10019. };
  10020. exports.shelljs = {
  10021. target : false,
  10022. echo : false,
  10023. exit : false,
  10024. cd : false,
  10025. pwd : false,
  10026. ls : false,
  10027. find : false,
  10028. cp : false,
  10029. rm : false,
  10030. mv : false,
  10031. mkdir : false,
  10032. test : false,
  10033. cat : false,
  10034. sed : false,
  10035. grep : false,
  10036. which : false,
  10037. dirs : false,
  10038. pushd : false,
  10039. popd : false,
  10040. env : false,
  10041. exec : false,
  10042. chmod : false,
  10043. config : false,
  10044. error : false,
  10045. tempdir : false
  10046. };
  10047. exports.typed = {
  10048. ArrayBuffer : false,
  10049. ArrayBufferView : false,
  10050. DataView : false,
  10051. Float32Array : false,
  10052. Float64Array : false,
  10053. Int16Array : false,
  10054. Int32Array : false,
  10055. Int8Array : false,
  10056. Uint16Array : false,
  10057. Uint32Array : false,
  10058. Uint8Array : false,
  10059. Uint8ClampedArray : false
  10060. };
  10061. exports.wsh = {
  10062. ActiveXObject : true,
  10063. Enumerator : true,
  10064. GetObject : true,
  10065. ScriptEngine : true,
  10066. ScriptEngineBuildVersion : true,
  10067. ScriptEngineMajorVersion : true,
  10068. ScriptEngineMinorVersion : true,
  10069. VBArray : true,
  10070. WSH : true,
  10071. WScript : true,
  10072. XDomainRequest : true
  10073. };
  10074. exports.dojo = {
  10075. dojo : false,
  10076. dijit : false,
  10077. dojox : false,
  10078. define : false,
  10079. "require": false
  10080. };
  10081. exports.jquery = {
  10082. "$" : false,
  10083. jQuery : false
  10084. };
  10085. exports.mootools = {
  10086. "$" : false,
  10087. "$$" : false,
  10088. Asset : false,
  10089. Browser : false,
  10090. Chain : false,
  10091. Class : false,
  10092. Color : false,
  10093. Cookie : false,
  10094. Core : false,
  10095. Document : false,
  10096. DomReady : false,
  10097. DOMEvent : false,
  10098. DOMReady : false,
  10099. Drag : false,
  10100. Element : false,
  10101. Elements : false,
  10102. Event : false,
  10103. Events : false,
  10104. Fx : false,
  10105. Group : false,
  10106. Hash : false,
  10107. HtmlTable : false,
  10108. IFrame : false,
  10109. IframeShim : false,
  10110. InputValidator: false,
  10111. instanceOf : false,
  10112. Keyboard : false,
  10113. Locale : false,
  10114. Mask : false,
  10115. MooTools : false,
  10116. Native : false,
  10117. Options : false,
  10118. OverText : false,
  10119. Request : false,
  10120. Scroller : false,
  10121. Slick : false,
  10122. Slider : false,
  10123. Sortables : false,
  10124. Spinner : false,
  10125. Swiff : false,
  10126. Tips : false,
  10127. Type : false,
  10128. typeOf : false,
  10129. URI : false,
  10130. Window : false
  10131. };
  10132. exports.prototypejs = {
  10133. "$" : false,
  10134. "$$" : false,
  10135. "$A" : false,
  10136. "$F" : false,
  10137. "$H" : false,
  10138. "$R" : false,
  10139. "$break" : false,
  10140. "$continue" : false,
  10141. "$w" : false,
  10142. Abstract : false,
  10143. Ajax : false,
  10144. Class : false,
  10145. Enumerable : false,
  10146. Element : false,
  10147. Event : false,
  10148. Field : false,
  10149. Form : false,
  10150. Hash : false,
  10151. Insertion : false,
  10152. ObjectRange : false,
  10153. PeriodicalExecuter: false,
  10154. Position : false,
  10155. Prototype : false,
  10156. Selector : false,
  10157. Template : false,
  10158. Toggle : false,
  10159. Try : false,
  10160. Autocompleter : false,
  10161. Builder : false,
  10162. Control : false,
  10163. Draggable : false,
  10164. Draggables : false,
  10165. Droppables : false,
  10166. Effect : false,
  10167. Sortable : false,
  10168. SortableObserver : false,
  10169. Sound : false,
  10170. Scriptaculous : false
  10171. };
  10172. exports.yui = {
  10173. YUI : false,
  10174. Y : false,
  10175. YUI_config: false
  10176. };
  10177. exports.mocha = {
  10178. mocha : false,
  10179. describe : false,
  10180. xdescribe : false,
  10181. it : false,
  10182. xit : false,
  10183. context : false,
  10184. xcontext : false,
  10185. before : false,
  10186. after : false,
  10187. beforeEach : false,
  10188. afterEach : false,
  10189. suite : false,
  10190. test : false,
  10191. setup : false,
  10192. teardown : false,
  10193. suiteSetup : false,
  10194. suiteTeardown : false
  10195. };
  10196. exports.jasmine = {
  10197. jasmine : false,
  10198. describe : false,
  10199. xdescribe : false,
  10200. it : false,
  10201. xit : false,
  10202. beforeEach : false,
  10203. afterEach : false,
  10204. setFixtures : false,
  10205. loadFixtures: false,
  10206. spyOn : false,
  10207. expect : false,
  10208. runs : false,
  10209. waitsFor : false,
  10210. waits : false,
  10211. beforeAll : false,
  10212. afterAll : false,
  10213. fail : false,
  10214. fdescribe : false,
  10215. fit : false,
  10216. pending : false
  10217. };
  10218. },{}]},{},["/node_modules/jshint/src/jshint.js"]);
  10219. });
  10220. ace.define("ace/mode/javascript_worker",[], function(require, exports, module) {
  10221. "use strict";
  10222. var oop = require("../lib/oop");
  10223. var Mirror = require("../worker/mirror").Mirror;
  10224. var lint = require("./javascript/jshint").JSHINT;
  10225. function startRegex(arr) {
  10226. return RegExp("^(" + arr.join("|") + ")");
  10227. }
  10228. var disabledWarningsRe = startRegex([
  10229. "Bad for in variable '(.+)'.",
  10230. 'Missing "use strict"'
  10231. ]);
  10232. var errorsRe = startRegex([
  10233. "Unexpected",
  10234. "Expected ",
  10235. "Confusing (plus|minus)",
  10236. "\\{a\\} unterminated regular expression",
  10237. "Unclosed ",
  10238. "Unmatched ",
  10239. "Unbegun comment",
  10240. "Bad invocation",
  10241. "Missing space after",
  10242. "Missing operator at"
  10243. ]);
  10244. var infoRe = startRegex([
  10245. "Expected an assignment",
  10246. "Bad escapement of EOL",
  10247. "Unexpected comma",
  10248. "Unexpected space",
  10249. "Missing radix parameter.",
  10250. "A leading decimal point can",
  10251. "\\['{a}'\\] is better written in dot notation.",
  10252. "'{a}' used out of scope"
  10253. ]);
  10254. var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
  10255. Mirror.call(this, sender);
  10256. this.setTimeout(500);
  10257. this.setOptions();
  10258. };
  10259. oop.inherits(JavaScriptWorker, Mirror);
  10260. (function() {
  10261. this.setOptions = function(options) {
  10262. this.options = options || {
  10263. esnext: true,
  10264. moz: true,
  10265. devel: true,
  10266. browser: true,
  10267. node: true,
  10268. laxcomma: true,
  10269. laxbreak: true,
  10270. lastsemic: true,
  10271. onevar: false,
  10272. passfail: false,
  10273. maxerr: 100,
  10274. expr: true,
  10275. multistr: true,
  10276. globalstrict: true
  10277. };
  10278. this.doc.getValue() && this.deferredUpdate.schedule(100);
  10279. };
  10280. this.changeOptions = function(newOptions) {
  10281. oop.mixin(this.options, newOptions);
  10282. this.doc.getValue() && this.deferredUpdate.schedule(100);
  10283. };
  10284. this.isValidJS = function(str) {
  10285. try {
  10286. eval("throw 0;" + str);
  10287. } catch(e) {
  10288. if (e === 0)
  10289. return true;
  10290. }
  10291. return false;
  10292. };
  10293. this.onUpdate = function() {
  10294. var value = this.doc.getValue();
  10295. value = value.replace(/^#!.*\n/, "\n");
  10296. if (!value)
  10297. return this.sender.emit("annotate", []);
  10298. var errors = [];
  10299. var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
  10300. lint(value, this.options, this.options.globals);
  10301. var results = lint.errors;
  10302. var errorAdded = false;
  10303. for (var i = 0; i < results.length; i++) {
  10304. var error = results[i];
  10305. if (!error)
  10306. continue;
  10307. var raw = error.raw;
  10308. var type = "warning";
  10309. if (raw == "Missing semicolon.") {
  10310. var str = error.evidence.substr(error.character);
  10311. str = str.charAt(str.search(/\S/));
  10312. if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
  10313. error.reason = 'Missing ";" before statement';
  10314. type = "error";
  10315. } else {
  10316. type = "info";
  10317. }
  10318. }
  10319. else if (disabledWarningsRe.test(raw)) {
  10320. continue;
  10321. }
  10322. else if (infoRe.test(raw)) {
  10323. type = "info";
  10324. }
  10325. else if (errorsRe.test(raw)) {
  10326. errorAdded = true;
  10327. type = maxErrorLevel;
  10328. }
  10329. else if (raw == "'{a}' is not defined.") {
  10330. type = "warning";
  10331. }
  10332. else if (raw == "'{a}' is defined but never used.") {
  10333. type = "info";
  10334. }
  10335. errors.push({
  10336. row: error.line-1,
  10337. column: error.character-1,
  10338. text: error.reason,
  10339. type: type,
  10340. raw: raw
  10341. });
  10342. if (errorAdded) {
  10343. }
  10344. }
  10345. this.sender.emit("annotate", errors);
  10346. };
  10347. }).call(JavaScriptWorker.prototype);
  10348. });
  10349. ace.define("ace/lib/es5-shim",[], function(require, exports, module) {
  10350. //
  10351. //
  10352. function Empty() {}
  10353. if (!Function.prototype.bind) {
  10354. Function.prototype.bind = function bind(that) { // .length is 1
  10355. var target = this;
  10356. if (typeof target != "function") {
  10357. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  10358. }
  10359. var args = slice.call(arguments, 1); // for normal call
  10360. var bound = function () {
  10361. if (this instanceof bound) {
  10362. var result = target.apply(
  10363. this,
  10364. args.concat(slice.call(arguments))
  10365. );
  10366. if (Object(result) === result) {
  10367. return result;
  10368. }
  10369. return this;
  10370. } else {
  10371. return target.apply(
  10372. that,
  10373. args.concat(slice.call(arguments))
  10374. );
  10375. }
  10376. };
  10377. if(target.prototype) {
  10378. Empty.prototype = target.prototype;
  10379. bound.prototype = new Empty();
  10380. Empty.prototype = null;
  10381. }
  10382. //
  10383. return bound;
  10384. };
  10385. }
  10386. var call = Function.prototype.call;
  10387. var prototypeOfArray = Array.prototype;
  10388. var prototypeOfObject = Object.prototype;
  10389. var slice = prototypeOfArray.slice;
  10390. var _toString = call.bind(prototypeOfObject.toString);
  10391. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  10392. var defineGetter;
  10393. var defineSetter;
  10394. var lookupGetter;
  10395. var lookupSetter;
  10396. var supportsAccessors;
  10397. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  10398. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  10399. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  10400. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  10401. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  10402. }
  10403. //
  10404. //
  10405. if ([1,2].splice(0).length != 2) {
  10406. if(function() { // test IE < 9 to splice bug - see issue #138
  10407. function makeArray(l) {
  10408. var a = new Array(l+2);
  10409. a[0] = a[1] = 0;
  10410. return a;
  10411. }
  10412. var array = [], lengthBefore;
  10413. array.splice.apply(array, makeArray(20));
  10414. array.splice.apply(array, makeArray(26));
  10415. lengthBefore = array.length; //46
  10416. array.splice(5, 0, "XXX"); // add one element
  10417. lengthBefore + 1 == array.length
  10418. if (lengthBefore + 1 == array.length) {
  10419. return true;// has right splice implementation without bugs
  10420. }
  10421. }()) {//IE 6/7
  10422. var array_splice = Array.prototype.splice;
  10423. Array.prototype.splice = function(start, deleteCount) {
  10424. if (!arguments.length) {
  10425. return [];
  10426. } else {
  10427. return array_splice.apply(this, [
  10428. start === void 0 ? 0 : start,
  10429. deleteCount === void 0 ? (this.length - start) : deleteCount
  10430. ].concat(slice.call(arguments, 2)))
  10431. }
  10432. };
  10433. } else {//IE8
  10434. Array.prototype.splice = function(pos, removeCount){
  10435. var length = this.length;
  10436. if (pos > 0) {
  10437. if (pos > length)
  10438. pos = length;
  10439. } else if (pos == void 0) {
  10440. pos = 0;
  10441. } else if (pos < 0) {
  10442. pos = Math.max(length + pos, 0);
  10443. }
  10444. if (!(pos+removeCount < length))
  10445. removeCount = length - pos;
  10446. var removed = this.slice(pos, pos+removeCount);
  10447. var insert = slice.call(arguments, 2);
  10448. var add = insert.length;
  10449. if (pos === length) {
  10450. if (add) {
  10451. this.push.apply(this, insert);
  10452. }
  10453. } else {
  10454. var remove = Math.min(removeCount, length - pos);
  10455. var tailOldPos = pos + remove;
  10456. var tailNewPos = tailOldPos + add - remove;
  10457. var tailCount = length - tailOldPos;
  10458. var lengthAfterRemove = length - remove;
  10459. if (tailNewPos < tailOldPos) { // case A
  10460. for (var i = 0; i < tailCount; ++i) {
  10461. this[tailNewPos+i] = this[tailOldPos+i];
  10462. }
  10463. } else if (tailNewPos > tailOldPos) { // case B
  10464. for (i = tailCount; i--; ) {
  10465. this[tailNewPos+i] = this[tailOldPos+i];
  10466. }
  10467. } // else, add == remove (nothing to do)
  10468. if (add && pos === lengthAfterRemove) {
  10469. this.length = lengthAfterRemove; // truncate array
  10470. this.push.apply(this, insert);
  10471. } else {
  10472. this.length = lengthAfterRemove + add; // reserves space
  10473. for (i = 0; i < add; ++i) {
  10474. this[pos+i] = insert[i];
  10475. }
  10476. }
  10477. }
  10478. return removed;
  10479. };
  10480. }
  10481. }
  10482. if (!Array.isArray) {
  10483. Array.isArray = function isArray(obj) {
  10484. return _toString(obj) == "[object Array]";
  10485. };
  10486. }
  10487. var boxedString = Object("a"),
  10488. splitString = boxedString[0] != "a" || !(0 in boxedString);
  10489. if (!Array.prototype.forEach) {
  10490. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  10491. var object = toObject(this),
  10492. self = splitString && _toString(this) == "[object String]" ?
  10493. this.split("") :
  10494. object,
  10495. thisp = arguments[1],
  10496. i = -1,
  10497. length = self.length >>> 0;
  10498. if (_toString(fun) != "[object Function]") {
  10499. throw new TypeError(); // TODO message
  10500. }
  10501. while (++i < length) {
  10502. if (i in self) {
  10503. fun.call(thisp, self[i], i, object);
  10504. }
  10505. }
  10506. };
  10507. }
  10508. if (!Array.prototype.map) {
  10509. Array.prototype.map = function map(fun /*, thisp*/) {
  10510. var object = toObject(this),
  10511. self = splitString && _toString(this) == "[object String]" ?
  10512. this.split("") :
  10513. object,
  10514. length = self.length >>> 0,
  10515. result = Array(length),
  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. result[i] = fun.call(thisp, self[i], i, object);
  10523. }
  10524. return result;
  10525. };
  10526. }
  10527. if (!Array.prototype.filter) {
  10528. Array.prototype.filter = function filter(fun /*, thisp */) {
  10529. var object = toObject(this),
  10530. self = splitString && _toString(this) == "[object String]" ?
  10531. this.split("") :
  10532. object,
  10533. length = self.length >>> 0,
  10534. result = [],
  10535. value,
  10536. thisp = arguments[1];
  10537. if (_toString(fun) != "[object Function]") {
  10538. throw new TypeError(fun + " is not a function");
  10539. }
  10540. for (var i = 0; i < length; i++) {
  10541. if (i in self) {
  10542. value = self[i];
  10543. if (fun.call(thisp, value, i, object)) {
  10544. result.push(value);
  10545. }
  10546. }
  10547. }
  10548. return result;
  10549. };
  10550. }
  10551. if (!Array.prototype.every) {
  10552. Array.prototype.every = function every(fun /*, thisp */) {
  10553. var object = toObject(this),
  10554. self = splitString && _toString(this) == "[object String]" ?
  10555. this.split("") :
  10556. object,
  10557. length = self.length >>> 0,
  10558. thisp = arguments[1];
  10559. if (_toString(fun) != "[object Function]") {
  10560. throw new TypeError(fun + " is not a function");
  10561. }
  10562. for (var i = 0; i < length; i++) {
  10563. if (i in self && !fun.call(thisp, self[i], i, object)) {
  10564. return false;
  10565. }
  10566. }
  10567. return true;
  10568. };
  10569. }
  10570. if (!Array.prototype.some) {
  10571. Array.prototype.some = function some(fun /*, thisp */) {
  10572. var object = toObject(this),
  10573. self = splitString && _toString(this) == "[object String]" ?
  10574. this.split("") :
  10575. object,
  10576. length = self.length >>> 0,
  10577. thisp = arguments[1];
  10578. if (_toString(fun) != "[object Function]") {
  10579. throw new TypeError(fun + " is not a function");
  10580. }
  10581. for (var i = 0; i < length; i++) {
  10582. if (i in self && fun.call(thisp, self[i], i, object)) {
  10583. return true;
  10584. }
  10585. }
  10586. return false;
  10587. };
  10588. }
  10589. if (!Array.prototype.reduce) {
  10590. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  10591. var object = toObject(this),
  10592. self = splitString && _toString(this) == "[object String]" ?
  10593. this.split("") :
  10594. object,
  10595. length = self.length >>> 0;
  10596. if (_toString(fun) != "[object Function]") {
  10597. throw new TypeError(fun + " is not a function");
  10598. }
  10599. if (!length && arguments.length == 1) {
  10600. throw new TypeError("reduce of empty array with no initial value");
  10601. }
  10602. var i = 0;
  10603. var result;
  10604. if (arguments.length >= 2) {
  10605. result = arguments[1];
  10606. } else {
  10607. do {
  10608. if (i in self) {
  10609. result = self[i++];
  10610. break;
  10611. }
  10612. if (++i >= length) {
  10613. throw new TypeError("reduce of empty array with no initial value");
  10614. }
  10615. } while (true);
  10616. }
  10617. for (; i < length; i++) {
  10618. if (i in self) {
  10619. result = fun.call(void 0, result, self[i], i, object);
  10620. }
  10621. }
  10622. return result;
  10623. };
  10624. }
  10625. if (!Array.prototype.reduceRight) {
  10626. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  10627. var object = toObject(this),
  10628. self = splitString && _toString(this) == "[object String]" ?
  10629. this.split("") :
  10630. object,
  10631. length = self.length >>> 0;
  10632. if (_toString(fun) != "[object Function]") {
  10633. throw new TypeError(fun + " is not a function");
  10634. }
  10635. if (!length && arguments.length == 1) {
  10636. throw new TypeError("reduceRight of empty array with no initial value");
  10637. }
  10638. var result, i = length - 1;
  10639. if (arguments.length >= 2) {
  10640. result = arguments[1];
  10641. } else {
  10642. do {
  10643. if (i in self) {
  10644. result = self[i--];
  10645. break;
  10646. }
  10647. if (--i < 0) {
  10648. throw new TypeError("reduceRight of empty array with no initial value");
  10649. }
  10650. } while (true);
  10651. }
  10652. do {
  10653. if (i in this) {
  10654. result = fun.call(void 0, result, self[i], i, object);
  10655. }
  10656. } while (i--);
  10657. return result;
  10658. };
  10659. }
  10660. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  10661. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  10662. var self = splitString && _toString(this) == "[object String]" ?
  10663. this.split("") :
  10664. toObject(this),
  10665. length = self.length >>> 0;
  10666. if (!length) {
  10667. return -1;
  10668. }
  10669. var i = 0;
  10670. if (arguments.length > 1) {
  10671. i = toInteger(arguments[1]);
  10672. }
  10673. i = i >= 0 ? i : Math.max(0, length + i);
  10674. for (; i < length; i++) {
  10675. if (i in self && self[i] === sought) {
  10676. return i;
  10677. }
  10678. }
  10679. return -1;
  10680. };
  10681. }
  10682. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  10683. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  10684. var self = splitString && _toString(this) == "[object String]" ?
  10685. this.split("") :
  10686. toObject(this),
  10687. length = self.length >>> 0;
  10688. if (!length) {
  10689. return -1;
  10690. }
  10691. var i = length - 1;
  10692. if (arguments.length > 1) {
  10693. i = Math.min(i, toInteger(arguments[1]));
  10694. }
  10695. i = i >= 0 ? i : length - Math.abs(i);
  10696. for (; i >= 0; i--) {
  10697. if (i in self && sought === self[i]) {
  10698. return i;
  10699. }
  10700. }
  10701. return -1;
  10702. };
  10703. }
  10704. //
  10705. //
  10706. if (!Object.getPrototypeOf) {
  10707. Object.getPrototypeOf = function getPrototypeOf(object) {
  10708. return object.__proto__ || (
  10709. object.constructor ?
  10710. object.constructor.prototype :
  10711. prototypeOfObject
  10712. );
  10713. };
  10714. }
  10715. if (!Object.getOwnPropertyDescriptor) {
  10716. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  10717. "non-object: ";
  10718. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  10719. if ((typeof object != "object" && typeof object != "function") || object === null)
  10720. throw new TypeError(ERR_NON_OBJECT + object);
  10721. if (!owns(object, property))
  10722. return;
  10723. var descriptor, getter, setter;
  10724. descriptor = { enumerable: true, configurable: true };
  10725. if (supportsAccessors) {
  10726. var prototype = object.__proto__;
  10727. object.__proto__ = prototypeOfObject;
  10728. var getter = lookupGetter(object, property);
  10729. var setter = lookupSetter(object, property);
  10730. object.__proto__ = prototype;
  10731. if (getter || setter) {
  10732. if (getter) descriptor.get = getter;
  10733. if (setter) descriptor.set = setter;
  10734. return descriptor;
  10735. }
  10736. }
  10737. descriptor.value = object[property];
  10738. return descriptor;
  10739. };
  10740. }
  10741. if (!Object.getOwnPropertyNames) {
  10742. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  10743. return Object.keys(object);
  10744. };
  10745. }
  10746. if (!Object.create) {
  10747. var createEmpty;
  10748. if (Object.prototype.__proto__ === null) {
  10749. createEmpty = function () {
  10750. return { "__proto__": null };
  10751. };
  10752. } else {
  10753. createEmpty = function () {
  10754. var empty = {};
  10755. for (var i in empty)
  10756. empty[i] = null;
  10757. empty.constructor =
  10758. empty.hasOwnProperty =
  10759. empty.propertyIsEnumerable =
  10760. empty.isPrototypeOf =
  10761. empty.toLocaleString =
  10762. empty.toString =
  10763. empty.valueOf =
  10764. empty.__proto__ = null;
  10765. return empty;
  10766. }
  10767. }
  10768. Object.create = function create(prototype, properties) {
  10769. var object;
  10770. if (prototype === null) {
  10771. object = createEmpty();
  10772. } else {
  10773. if (typeof prototype != "object")
  10774. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  10775. var Type = function () {};
  10776. Type.prototype = prototype;
  10777. object = new Type();
  10778. object.__proto__ = prototype;
  10779. }
  10780. if (properties !== void 0)
  10781. Object.defineProperties(object, properties);
  10782. return object;
  10783. };
  10784. }
  10785. function doesDefinePropertyWork(object) {
  10786. try {
  10787. Object.defineProperty(object, "sentinel", {});
  10788. return "sentinel" in object;
  10789. } catch (exception) {
  10790. }
  10791. }
  10792. if (Object.defineProperty) {
  10793. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  10794. var definePropertyWorksOnDom = typeof document == "undefined" ||
  10795. doesDefinePropertyWork(document.createElement("div"));
  10796. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  10797. var definePropertyFallback = Object.defineProperty;
  10798. }
  10799. }
  10800. if (!Object.defineProperty || definePropertyFallback) {
  10801. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  10802. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  10803. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  10804. "on this javascript engine";
  10805. Object.defineProperty = function defineProperty(object, property, descriptor) {
  10806. if ((typeof object != "object" && typeof object != "function") || object === null)
  10807. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  10808. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  10809. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  10810. if (definePropertyFallback) {
  10811. try {
  10812. return definePropertyFallback.call(Object, object, property, descriptor);
  10813. } catch (exception) {
  10814. }
  10815. }
  10816. if (owns(descriptor, "value")) {
  10817. if (supportsAccessors && (lookupGetter(object, property) ||
  10818. lookupSetter(object, property)))
  10819. {
  10820. var prototype = object.__proto__;
  10821. object.__proto__ = prototypeOfObject;
  10822. delete object[property];
  10823. object[property] = descriptor.value;
  10824. object.__proto__ = prototype;
  10825. } else {
  10826. object[property] = descriptor.value;
  10827. }
  10828. } else {
  10829. if (!supportsAccessors)
  10830. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  10831. if (owns(descriptor, "get"))
  10832. defineGetter(object, property, descriptor.get);
  10833. if (owns(descriptor, "set"))
  10834. defineSetter(object, property, descriptor.set);
  10835. }
  10836. return object;
  10837. };
  10838. }
  10839. if (!Object.defineProperties) {
  10840. Object.defineProperties = function defineProperties(object, properties) {
  10841. for (var property in properties) {
  10842. if (owns(properties, property))
  10843. Object.defineProperty(object, property, properties[property]);
  10844. }
  10845. return object;
  10846. };
  10847. }
  10848. if (!Object.seal) {
  10849. Object.seal = function seal(object) {
  10850. return object;
  10851. };
  10852. }
  10853. if (!Object.freeze) {
  10854. Object.freeze = function freeze(object) {
  10855. return object;
  10856. };
  10857. }
  10858. try {
  10859. Object.freeze(function () {});
  10860. } catch (exception) {
  10861. Object.freeze = (function freeze(freezeObject) {
  10862. return function freeze(object) {
  10863. if (typeof object == "function") {
  10864. return object;
  10865. } else {
  10866. return freezeObject(object);
  10867. }
  10868. };
  10869. })(Object.freeze);
  10870. }
  10871. if (!Object.preventExtensions) {
  10872. Object.preventExtensions = function preventExtensions(object) {
  10873. return object;
  10874. };
  10875. }
  10876. if (!Object.isSealed) {
  10877. Object.isSealed = function isSealed(object) {
  10878. return false;
  10879. };
  10880. }
  10881. if (!Object.isFrozen) {
  10882. Object.isFrozen = function isFrozen(object) {
  10883. return false;
  10884. };
  10885. }
  10886. if (!Object.isExtensible) {
  10887. Object.isExtensible = function isExtensible(object) {
  10888. if (Object(object) === object) {
  10889. throw new TypeError(); // TODO message
  10890. }
  10891. var name = '';
  10892. while (owns(object, name)) {
  10893. name += '?';
  10894. }
  10895. object[name] = true;
  10896. var returnValue = owns(object, name);
  10897. delete object[name];
  10898. return returnValue;
  10899. };
  10900. }
  10901. if (!Object.keys) {
  10902. var hasDontEnumBug = true,
  10903. dontEnums = [
  10904. "toString",
  10905. "toLocaleString",
  10906. "valueOf",
  10907. "hasOwnProperty",
  10908. "isPrototypeOf",
  10909. "propertyIsEnumerable",
  10910. "constructor"
  10911. ],
  10912. dontEnumsLength = dontEnums.length;
  10913. for (var key in {"toString": null}) {
  10914. hasDontEnumBug = false;
  10915. }
  10916. Object.keys = function keys(object) {
  10917. if (
  10918. (typeof object != "object" && typeof object != "function") ||
  10919. object === null
  10920. ) {
  10921. throw new TypeError("Object.keys called on a non-object");
  10922. }
  10923. var keys = [];
  10924. for (var name in object) {
  10925. if (owns(object, name)) {
  10926. keys.push(name);
  10927. }
  10928. }
  10929. if (hasDontEnumBug) {
  10930. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  10931. var dontEnum = dontEnums[i];
  10932. if (owns(object, dontEnum)) {
  10933. keys.push(dontEnum);
  10934. }
  10935. }
  10936. }
  10937. return keys;
  10938. };
  10939. }
  10940. //
  10941. //
  10942. if (!Date.now) {
  10943. Date.now = function now() {
  10944. return new Date().getTime();
  10945. };
  10946. }
  10947. //
  10948. //
  10949. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  10950. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  10951. "\u2029\uFEFF";
  10952. if (!String.prototype.trim || ws.trim()) {
  10953. ws = "[" + ws + "]";
  10954. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  10955. trimEndRegexp = new RegExp(ws + ws + "*$");
  10956. String.prototype.trim = function trim() {
  10957. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  10958. };
  10959. }
  10960. //
  10961. //
  10962. function toInteger(n) {
  10963. n = +n;
  10964. if (n !== n) { // isNaN
  10965. n = 0;
  10966. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  10967. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  10968. }
  10969. return n;
  10970. }
  10971. function isPrimitive(input) {
  10972. var type = typeof input;
  10973. return (
  10974. input === null ||
  10975. type === "undefined" ||
  10976. type === "boolean" ||
  10977. type === "number" ||
  10978. type === "string"
  10979. );
  10980. }
  10981. function toPrimitive(input) {
  10982. var val, valueOf, toString;
  10983. if (isPrimitive(input)) {
  10984. return input;
  10985. }
  10986. valueOf = input.valueOf;
  10987. if (typeof valueOf === "function") {
  10988. val = valueOf.call(input);
  10989. if (isPrimitive(val)) {
  10990. return val;
  10991. }
  10992. }
  10993. toString = input.toString;
  10994. if (typeof toString === "function") {
  10995. val = toString.call(input);
  10996. if (isPrimitive(val)) {
  10997. return val;
  10998. }
  10999. }
  11000. throw new TypeError();
  11001. }
  11002. var toObject = function (o) {
  11003. if (o == null) { // this matches both null and undefined
  11004. throw new TypeError("can't convert "+o+" to object");
  11005. }
  11006. return Object(o);
  11007. };
  11008. });