| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773 |
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.babel = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- require("./plugins/flow");
- var _acornJsxInject = require("acorn-jsx/inject");
- var _acornJsxInject2 = _interopRequireDefault(_acornJsxInject);
- var _srcIndex = require("./src/index");
- var acorn = _interopRequireWildcard(_srcIndex);
- _defaults(exports, _interopRequireWildcard(_srcIndex));
- (0, _acornJsxInject2["default"])(acorn);
- },{"./plugins/flow":2,"./src/index":5,"acorn-jsx/inject":174}],2:[function(require,module,exports){
- "use strict";
- var acorn = require("../src/index");
- var pp = acorn.Parser.prototype;
- var tt = acorn.tokTypes;
- pp.isRelational = function (op) {
- return this.type === tt.relational && this.value === op;
- };
- pp.expectRelational = function (op) {
- if (this.isRelational(op)) {
- this.next();
- } else {
- this.unexpected();
- }
- };
- pp.flow_parseDeclareClass = function (node) {
- this.next();
- this.flow_parseInterfaceish(node, true);
- return this.finishNode(node, "DeclareClass");
- };
- pp.flow_parseDeclareFunction = function (node) {
- this.next();
- var id = node.id = this.parseIdent();
- var typeNode = this.startNode();
- var typeContainer = this.startNode();
- if (this.isRelational("<")) {
- typeNode.typeParameters = this.flow_parseTypeParameterDeclaration();
- } else {
- typeNode.typeParameters = null;
- }
- this.expect(tt.parenL);
- var tmp = this.flow_parseFunctionTypeParams();
- typeNode.params = tmp.params;
- typeNode.rest = tmp.rest;
- this.expect(tt.parenR);
- this.expect(tt.colon);
- typeNode.returnType = this.flow_parseType();
- typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
- id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
- this.finishNode(id, id.type);
- this.semicolon();
- return this.finishNode(node, "DeclareFunction");
- };
- pp.flow_parseDeclare = function (node) {
- if (this.type === tt._class) {
- return this.flow_parseDeclareClass(node);
- } else if (this.type === tt._function) {
- return this.flow_parseDeclareFunction(node);
- } else if (this.type === tt._var) {
- return this.flow_parseDeclareVariable(node);
- } else if (this.isContextual("module")) {
- return this.flow_parseDeclareModule(node);
- } else {
- this.unexpected();
- }
- };
- pp.flow_parseDeclareVariable = function (node) {
- this.next();
- node.id = this.flow_parseTypeAnnotatableIdentifier();
- this.semicolon();
- return this.finishNode(node, "DeclareVariable");
- };
- pp.flow_parseDeclareModule = function (node) {
- this.next();
- if (this.type === tt.string) {
- node.id = this.parseExprAtom();
- } else {
- node.id = this.parseIdent();
- }
- var bodyNode = node.body = this.startNode();
- var body = bodyNode.body = [];
- this.expect(tt.braceL);
- while (this.type !== tt.braceR) {
- var node2 = this.startNode();
- // todo: declare check
- this.next();
- body.push(this.flow_parseDeclare(node2));
- }
- this.expect(tt.braceR);
- this.finishNode(bodyNode, "BlockStatement");
- return this.finishNode(node, "DeclareModule");
- };
- // Interfaces
- pp.flow_parseInterfaceish = function (node, allowStatic) {
- node.id = this.parseIdent();
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterDeclaration();
- } else {
- node.typeParameters = null;
- }
- node["extends"] = [];
- if (this.eat(tt._extends)) {
- do {
- node["extends"].push(this.flow_parseInterfaceExtends());
- } while (this.eat(tt.comma));
- }
- node.body = this.flow_parseObjectType(allowStatic);
- };
- pp.flow_parseInterfaceExtends = function () {
- var node = this.startNode();
- node.id = this.parseIdent();
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterInstantiation();
- } else {
- node.typeParameters = null;
- }
- return this.finishNode(node, "InterfaceExtends");
- };
- pp.flow_parseInterface = function (node) {
- this.flow_parseInterfaceish(node, false);
- return this.finishNode(node, "InterfaceDeclaration");
- };
- // Type aliases
- pp.flow_parseTypeAlias = function (node) {
- node.id = this.parseIdent();
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterDeclaration();
- } else {
- node.typeParameters = null;
- }
- var oldInType = this.inType;
- this.inType = true;
- this.expect(tt.eq);
- node.right = this.flow_parseType();
- this.inType = oldInType;
- this.semicolon();
- return this.finishNode(node, "TypeAlias");
- };
- // Type annotations
- pp.flow_parseTypeParameterDeclaration = function () {
- var node = this.startNode();
- node.params = [];
- this.expectRelational("<");
- while (!this.isRelational(">")) {
- node.params.push(this.flow_parseTypeAnnotatableIdentifier());
- if (!this.isRelational(">")) {
- this.expect(tt.comma);
- }
- }
- this.expectRelational(">");
- return this.finishNode(node, "TypeParameterDeclaration");
- };
- pp.flow_parseTypeParameterInstantiation = function () {
- var node = this.startNode(),
- oldInType = this.inType;
- node.params = [];
- this.inType = true;
- this.expectRelational("<");
- while (!this.isRelational(">")) {
- node.params.push(this.flow_parseType());
- if (!this.isRelational(">")) {
- this.expect(tt.comma);
- }
- }
- this.expectRelational(">");
- this.inType = oldInType;
- return this.finishNode(node, "TypeParameterInstantiation");
- };
- pp.flow_parseObjectPropertyKey = function () {
- return this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true);
- };
- pp.flow_parseObjectTypeIndexer = function (node, isStatic) {
- node["static"] = isStatic;
- this.expect(tt.bracketL);
- node.id = this.flow_parseObjectPropertyKey();
- this.expect(tt.colon);
- node.key = this.flow_parseType();
- this.expect(tt.bracketR);
- this.expect(tt.colon);
- node.value = this.flow_parseType();
- this.flow_objectTypeSemicolon();
- return this.finishNode(node, "ObjectTypeIndexer");
- };
- pp.flow_parseObjectTypeMethodish = function (node) {
- node.params = [];
- node.rest = null;
- node.typeParameters = null;
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterDeclaration();
- }
- this.expect(tt.parenL);
- while (this.type === tt.name) {
- node.params.push(this.flow_parseFunctionTypeParam());
- if (this.type !== tt.parenR) {
- this.expect(tt.comma);
- }
- }
- if (this.eat(tt.ellipsis)) {
- node.rest = this.flow_parseFunctionTypeParam();
- }
- this.expect(tt.parenR);
- this.expect(tt.colon);
- node.returnType = this.flow_parseType();
- return this.finishNode(node, "FunctionTypeAnnotation");
- };
- pp.flow_parseObjectTypeMethod = function (start, isStatic, key) {
- var node = this.startNodeAt(start);
- node.value = this.flow_parseObjectTypeMethodish(this.startNodeAt(start));
- node["static"] = isStatic;
- node.key = key;
- node.optional = false;
- this.flow_objectTypeSemicolon();
- return this.finishNode(node, "ObjectTypeProperty");
- };
- pp.flow_parseObjectTypeCallProperty = function (node, isStatic) {
- var valueNode = this.startNode();
- node["static"] = isStatic;
- node.value = this.flow_parseObjectTypeMethodish(valueNode);
- this.flow_objectTypeSemicolon();
- return this.finishNode(node, "ObjectTypeCallProperty");
- };
- pp.flow_parseObjectType = function (allowStatic) {
- var nodeStart = this.startNode();
- var node;
- var optional = false;
- var property;
- var propertyKey;
- var propertyTypeAnnotation;
- var token;
- var isStatic;
- nodeStart.callProperties = [];
- nodeStart.properties = [];
- nodeStart.indexers = [];
- this.expect(tt.braceL);
- while (this.type !== tt.braceR) {
- var start = this.markPosition();
- node = this.startNode();
- if (allowStatic && this.isContextual("static")) {
- this.next();
- isStatic = true;
- }
- if (this.type === tt.bracketL) {
- nodeStart.indexers.push(this.flow_parseObjectTypeIndexer(node, isStatic));
- } else if (this.type === tt.parenL || this.isRelational("<")) {
- nodeStart.callProperties.push(this.flow_parseObjectTypeCallProperty(node, allowStatic));
- } else {
- if (isStatic && this.type === tt.colon) {
- propertyKey = this.parseIdent();
- } else {
- propertyKey = this.flow_parseObjectPropertyKey();
- }
- if (this.isRelational("<") || this.type === tt.parenL) {
- // This is a method property
- nodeStart.properties.push(this.flow_parseObjectTypeMethod(start, isStatic, propertyKey));
- } else {
- if (this.eat(tt.question)) {
- optional = true;
- }
- this.expect(tt.colon);
- node.key = propertyKey;
- node.value = this.flow_parseType();
- node.optional = optional;
- node["static"] = isStatic;
- this.flow_objectTypeSemicolon();
- nodeStart.properties.push(this.finishNode(node, "ObjectTypeProperty"));
- }
- }
- }
- this.expect(tt.braceR);
- return this.finishNode(nodeStart, "ObjectTypeAnnotation");
- };
- pp.flow_objectTypeSemicolon = function () {
- if (!this.eat(tt.semi) && !this.eat(tt.comma) && this.type !== tt.braceR) {
- this.unexpected();
- }
- };
- pp.flow_parseGenericType = function (start, id) {
- var node = this.startNodeAt(start);
- node.typeParameters = null;
- node.id = id;
- while (this.eat(tt.dot)) {
- var node2 = this.startNodeAt(start);
- node2.qualification = node.id;
- node2.id = this.parseIdent();
- node.id = this.finishNode(node2, "QualifiedTypeIdentifier");
- }
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterInstantiation();
- }
- return this.finishNode(node, "GenericTypeAnnotation");
- };
- pp.flow_parseVoidType = function () {
- var node = this.startNode();
- this.expect(tt._void);
- return this.finishNode(node, "VoidTypeAnnotation");
- };
- pp.flow_parseTypeofType = function () {
- var node = this.startNode();
- this.expect(tt._typeof);
- node.argument = this.flow_parsePrimaryType();
- return this.finishNode(node, "TypeofTypeAnnotation");
- };
- pp.flow_parseTupleType = function () {
- var node = this.startNode();
- node.types = [];
- this.expect(tt.bracketL);
- // We allow trailing commas
- while (this.pos < this.input.length && this.type !== tt.bracketR) {
- node.types.push(this.flow_parseType());
- if (this.type === tt.bracketR) break;
- this.expect(tt.comma);
- }
- this.expect(tt.bracketR);
- return this.finishNode(node, "TupleTypeAnnotation");
- };
- pp.flow_parseFunctionTypeParam = function () {
- var optional = false;
- var node = this.startNode();
- node.name = this.parseIdent();
- if (this.eat(tt.question)) {
- optional = true;
- }
- this.expect(tt.colon);
- node.optional = optional;
- node.typeAnnotation = this.flow_parseType();
- return this.finishNode(node, "FunctionTypeParam");
- };
- pp.flow_parseFunctionTypeParams = function () {
- var ret = { params: [], rest: null };
- while (this.type === tt.name) {
- ret.params.push(this.flow_parseFunctionTypeParam());
- if (this.type !== tt.parenR) {
- this.expect(tt.comma);
- }
- }
- if (this.eat(tt.ellipsis)) {
- ret.rest = this.flow_parseFunctionTypeParam();
- }
- return ret;
- };
- pp.flow_identToTypeAnnotation = function (start, node, id) {
- switch (id.name) {
- case "any":
- return this.finishNode(node, "AnyTypeAnnotation");
- case "bool":
- case "boolean":
- return this.finishNode(node, "BooleanTypeAnnotation");
- case "number":
- return this.finishNode(node, "NumberTypeAnnotation");
- case "string":
- return this.finishNode(node, "StringTypeAnnotation");
- default:
- return this.flow_parseGenericType(start, id);
- }
- };
- // The parsing of types roughly parallels the parsing of expressions, and
- // primary types are kind of like primary expressions...they're the
- // primitives with which other types are constructed.
- pp.flow_parsePrimaryType = function () {
- var typeIdentifier = null;
- var params = null;
- var returnType = null;
- var start = this.markPosition();
- var node = this.startNode();
- var rest = null;
- var tmp;
- var typeParameters;
- var token;
- var type;
- var isGroupedType = false;
- switch (this.type) {
- case tt.name:
- return this.flow_identToTypeAnnotation(start, node, this.parseIdent());
- case tt.braceL:
- return this.flow_parseObjectType();
- case tt.bracketL:
- return this.flow_parseTupleType();
- case tt.relational:
- if (this.value === "<") {
- node.typeParameters = this.flow_parseTypeParameterDeclaration();
- this.expect(tt.parenL);
- tmp = this.flow_parseFunctionTypeParams();
- node.params = tmp.params;
- node.rest = tmp.rest;
- this.expect(tt.parenR);
- this.expect(tt.arrow);
- node.returnType = this.flow_parseType();
- return this.finishNode(node, "FunctionTypeAnnotation");
- }
- case tt.parenL:
- this.next();
- // Check to see if this is actually a grouped type
- if (this.type !== tt.parenR && this.type !== tt.ellipsis) {
- if (this.type === tt.name) {
- var token = this.lookahead().type;
- isGroupedType = token !== tt.question && token !== tt.colon;
- } else {
- isGroupedType = true;
- }
- }
- if (isGroupedType) {
- type = this.flow_parseType();
- this.expect(tt.parenR);
- // If we see a => next then someone was probably confused about
- // function types, so we can provide a better error message
- if (this.eat(tt.arrow)) {
- this.raise(node, "Unexpected token =>. It looks like " + "you are trying to write a function type, but you ended up " + "writing a grouped type followed by an =>, which is a syntax " + "error. Remember, function type parameters are named so function " + "types look like (name1: type1, name2: type2) => returnType. You " + "probably wrote (type1) => returnType");
- }
- return type;
- }
- tmp = this.flow_parseFunctionTypeParams();
- node.params = tmp.params;
- node.rest = tmp.rest;
- this.expect(tt.parenR);
- this.expect(tt.arrow);
- node.returnType = this.flow_parseType();
- node.typeParameters = null;
- return this.finishNode(node, "FunctionTypeAnnotation");
- case tt.string:
- node.value = this.value;
- node.raw = this.input.slice(this.start, this.end);
- this.next();
- return this.finishNode(node, "StringLiteralTypeAnnotation");
- default:
- if (this.type.keyword) {
- switch (this.type.keyword) {
- case "void":
- return this.flow_parseVoidType();
- case "typeof":
- return this.flow_parseTypeofType();
- }
- }
- }
- this.unexpected();
- };
- pp.flow_parsePostfixType = function () {
- var node = this.startNode();
- var type = node.elementType = this.flow_parsePrimaryType();
- if (this.type === tt.bracketL) {
- this.expect(tt.bracketL);
- this.expect(tt.bracketR);
- return this.finishNode(node, "ArrayTypeAnnotation");
- }
- return type;
- };
- pp.flow_parsePrefixType = function () {
- var node = this.startNode();
- if (this.eat(tt.question)) {
- node.typeAnnotation = this.flow_parsePrefixType();
- return this.finishNode(node, "NullableTypeAnnotation");
- }
- return this.flow_parsePostfixType();
- };
- pp.flow_parseIntersectionType = function () {
- var node = this.startNode();
- var type = this.flow_parsePrefixType();
- node.types = [type];
- while (this.eat(tt.bitwiseAND)) {
- node.types.push(this.flow_parsePrefixType());
- }
- return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
- };
- pp.flow_parseUnionType = function () {
- var node = this.startNode();
- var type = this.flow_parseIntersectionType();
- node.types = [type];
- while (this.eat(tt.bitwiseOR)) {
- node.types.push(this.flow_parseIntersectionType());
- }
- return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
- };
- pp.flow_parseType = function () {
- var oldInType = this.inType;
- this.inType = true;
- var type = this.flow_parseUnionType();
- this.inType = oldInType;
- return type;
- };
- pp.flow_parseTypeAnnotation = function () {
- var node = this.startNode();
- var oldInType = this.inType;
- this.inType = true;
- this.expect(tt.colon);
- node.typeAnnotation = this.flow_parseType();
- this.inType = oldInType;
- return this.finishNode(node, "TypeAnnotation");
- };
- pp.flow_parseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOptionalParam) {
- var node = this.startNode();
- var ident = this.parseIdent();
- var isOptionalParam = false;
- if (canBeOptionalParam && this.eat(tt.question)) {
- this.expect(tt.question);
- isOptionalParam = true;
- }
- if (requireTypeAnnotation || this.type === tt.colon) {
- ident.typeAnnotation = this.flow_parseTypeAnnotation();
- this.finishNode(ident, ident.type);
- }
- if (isOptionalParam) {
- ident.optional = true;
- this.finishNode(ident, ident.type);
- }
- return ident;
- };
- acorn.plugins.flow = function (instance) {
- // function name(): string {}
- instance.extend("parseFunctionBody", function (inner) {
- return function (node, allowExpression) {
- if (this.type === tt.colon) {
- node.returnType = this.flow_parseTypeAnnotation();
- }
- return inner.call(this, node, allowExpression);
- };
- });
- instance.extend("parseStatement", function (inner) {
- return function (declaration, topLevel) {
- // strict mode handling of `interface` since it's a reserved word
- if (this.strict && this.type === tt.name && this.value === "interface") {
- var node = this.startNode();
- this.next();
- return this.flow_parseInterface(node);
- } else {
- return inner.call(this, declaration, topLevel);
- }
- };
- });
- instance.extend("parseExpressionStatement", function (inner) {
- return function (node, expr) {
- if (expr.type === "Identifier") {
- if (expr.name === "declare") {
- if (this.type === tt._class || this.type === tt.name || this.type === tt._function || this.type === tt._var) {
- return this.flow_parseDeclare(node);
- }
- } else if (this.type === tt.name) {
- if (expr.name === "interface") {
- return this.flow_parseInterface(node);
- } else if (expr.name === "type") {
- return this.flow_parseTypeAlias(node);
- }
- }
- }
- return inner.call(this, node, expr);
- };
- });
- instance.extend("shouldParseExportDeclaration", function (inner) {
- return function () {
- return this.isContextual("type") || inner.call(this);
- };
- });
- instance.extend("parseParenItem", function (inner) {
- return function (node, start) {
- if (this.type === tt.colon) {
- var typeCastNode = this.startNodeAt(start);
- typeCastNode.expression = node;
- typeCastNode.typeAnnotation = this.flow_parseTypeAnnotation();
- return this.finishNode(typeCastNode, "TypeCastExpression");
- } else {
- return node;
- }
- };
- });
- instance.extend("parseClassId", function (inner) {
- return function (node, isStatement) {
- inner.call(this, node, isStatement);
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterDeclaration();
- }
- };
- });
- instance.extend("readToken", function (inner) {
- return function (code) {
- if (this.inType && (code === 62 || code === 60)) {
- return this.finishOp(tt.relational, 1);
- } else {
- return inner.call(this, code);
- }
- };
- });
- instance.extend("jsx_readToken", function (inner) {
- return function () {
- if (!this.inType) return inner.call(this);
- };
- });
- instance.extend("parseParenArrowList", function (inner) {
- return function (start, exprList, isAsync) {
- for (var i = 0; i < exprList.length; i++) {
- var listItem = exprList[i];
- if (listItem.type === "TypeCastExpression") {
- var expr = listItem.expression;
- expr.typeAnnotation = listItem.typeAnnotation;
- exprList[i] = expr;
- }
- }
- return inner.call(this, start, exprList, isAsync);
- };
- });
- instance.extend("parseClassProperty", function (inner) {
- return function (node) {
- if (this.type === tt.colon) {
- node.typeAnnotation = this.flow_parseTypeAnnotation();
- }
- return inner.call(this, node);
- };
- });
- instance.extend("isClassProperty", function (inner) {
- return function () {
- return this.type === tt.colon || inner.call(this);
- };
- });
- instance.extend("parseClassMethod", function (inner) {
- return function (classBody, method, isGenerator, isAsync) {
- var typeParameters;
- if (this.isRelational("<")) {
- typeParameters = this.flow_parseTypeParameterDeclaration();
- }
- method.value = this.parseMethod(isGenerator, isAsync);
- method.value.typeParameters = typeParameters;
- classBody.body.push(this.finishNode(method, "MethodDefinition"));
- };
- });
- instance.extend("parseClassSuper", function (inner) {
- return function (node, isStatement) {
- inner.call(this, node, isStatement);
- if (node.superClass && this.isRelational("<")) {
- node.superTypeParameters = this.flow_parseTypeParameterInstantiation();
- }
- if (this.isContextual("implements")) {
- this.next();
- var implemented = node["implements"] = [];
- do {
- var node = this.startNode();
- node.id = this.parseIdent();
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterInstantiation();
- } else {
- node.typeParameters = null;
- }
- implemented.push(this.finishNode(node, "ClassImplements"));
- } while (this.eat(tt.comma));
- }
- };
- });
- instance.extend("parseObjPropValue", function (inner) {
- return function (prop) {
- var typeParameters;
- if (this.isRelational("<")) {
- typeParameters = this.flow_parseTypeParameterDeclaration();
- if (this.type !== tt.parenL) this.unexpected();
- }
- inner.apply(this, arguments);
- prop.value.typeParameters = typeParameters;
- };
- });
- instance.extend("parseAssignableListItemTypes", function (inner) {
- return function (param) {
- if (this.eat(tt.question)) {
- param.optional = true;
- }
- if (this.type === tt.colon) {
- param.typeAnnotation = this.flow_parseTypeAnnotation();
- }
- this.finishNode(param, param.type);
- return param;
- };
- });
- instance.extend("parseImportSpecifiers", function (inner) {
- return function (node) {
- node.isType = false;
- if (this.isContextual("type")) {
- var start = this.markPosition();
- var typeId = this.parseIdent();
- if (this.type === tt.name && this.value !== "from" || this.type === tt.braceL || this.type === tt.star) {
- node.isType = true;
- } else {
- node.specifiers.push(this.parseImportSpecifierDefault(typeId, start));
- if (this.isContextual("from")) return;
- this.eat(tt.comma);
- }
- }
- inner.call(this, node);
- };
- });
- // function foo<T>() {}
- instance.extend("parseFunctionParams", function (inner) {
- return function (node) {
- if (this.isRelational("<")) {
- node.typeParameters = this.flow_parseTypeParameterDeclaration();
- }
- inner.call(this, node);
- };
- });
- // var foo: string = bar
- instance.extend("parseVarHead", function (inner) {
- return function (decl) {
- inner.call(this, decl);
- if (this.type === tt.colon) {
- decl.id.typeAnnotation = this.flow_parseTypeAnnotation();
- this.finishNode(decl.id, decl.id.type);
- }
- };
- });
- };
- },{"../src/index":5}],3:[function(require,module,exports){
- // A recursive descent parser operates by defining functions for all
- // syntactic elements, and recursively calling those, each function
- // advancing the input stream and returning an AST node. Precedence
- // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
- // instead of `(!x)[1]` is handled by the fact that the parser
- // function that parses unary prefix operators is called first, and
- // in turn calls the function that parses `[]` subscripts — that
- // way, it'll receive the node for `x[1]` already parsed, and wraps
- // *that* in the unary operator node.
- //
- // Acorn uses an [operator precedence parser][opp] to handle binary
- // operator precedence, because it is much more compact than using
- // the technique outlined above, which uses different, nesting
- // functions to specify precedence, for all of the ten binary
- // precedence levels that JavaScript defines.
- //
- // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
- "use strict";
- var _tokentype = require("./tokentype");
- var _state = require("./state");
- var _identifier = require("./identifier");
- var _util = require("./util");
- var pp = _state.Parser.prototype;
- // Check if property name clashes with already added.
- // Object/class getters and setters are not allowed to clash —
- // either with each other or with an init property — and in
- // strict mode, init properties are also not allowed to be repeated.
- pp.checkPropClash = function (prop, propHash) {
- if (this.options.ecmaVersion >= 6) return;
- var key = prop.key,
- name = undefined;
- switch (key.type) {
- case "Identifier":
- name = key.name;break;
- case "Literal":
- name = String(key.value);break;
- default:
- return;
- }
- var kind = prop.kind || "init",
- other = undefined;
- if ((0, _util.has)(propHash, name)) {
- other = propHash[name];
- var isGetSet = kind !== "init";
- if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) this.raise(key.start, "Redefinition of property");
- } else {
- other = propHash[name] = {
- init: false,
- get: false,
- set: false
- };
- }
- other[kind] = true;
- };
- // ### Expression parsing
- // These nest, from the most general expression type at the top to
- // 'atomic', nondivisible expression types at the bottom. Most of
- // the functions will simply let the function(s) below them parse,
- // and, *if* the syntactic construct they handle is present, wrap
- // the AST node that the inner parser gave them in another node.
- // Parse a full expression. The optional arguments are used to
- // forbid the `in` operator (in for loops initalization expressions)
- // and provide reference for storing '=' operator inside shorthand
- // property assignment in contexts where both object expression
- // and object pattern might appear (so it's possible to raise
- // delayed syntax error at correct position).
- pp.parseExpression = function (noIn, refShorthandDefaultPos) {
- var start = this.markPosition();
- var expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos);
- if (this.type === _tokentype.types.comma) {
- var node = this.startNodeAt(start);
- node.expressions = [expr];
- while (this.eat(_tokentype.types.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos));
- return this.finishNode(node, "SequenceExpression");
- }
- return expr;
- };
- // Parse an assignment expression. This includes applications of
- // operators like `+=`.
- pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse) {
- if (this.type == _tokentype.types._yield && this.inGenerator) return this.parseYield();
- var failOnShorthandAssign = undefined;
- if (!refShorthandDefaultPos) {
- refShorthandDefaultPos = { start: 0 };
- failOnShorthandAssign = true;
- } else {
- failOnShorthandAssign = false;
- }
- var start = this.markPosition();
- if (this.type == _tokentype.types.parenL || this.type == _tokentype.types.name) this.potentialArrowAt = this.start;
- var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos);
- if (afterLeftParse) left = afterLeftParse.call(this, left, start);
- if (this.type.isAssign) {
- var node = this.startNodeAt(start);
- node.operator = this.value;
- node.left = this.type === _tokentype.types.eq ? this.toAssignable(left) : left;
- refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly
- this.checkLVal(left);
- if (left.parenthesizedExpression) {
- var errorMsg = undefined;
- if (left.type === "ObjectPattern") {
- errorMsg = "`({a}) = 0` use `({a} = 0)`";
- } else if (left.type === "ArrayPattern") {
- errorMsg = "`([a]) = 0` use `([a] = 0)`";
- }
- if (errorMsg) {
- this.raise(left.start, "You're trying to assign to a parenthesized expression, eg. instead of " + errorMsg);
- }
- }
- this.next();
- node.right = this.parseMaybeAssign(noIn);
- return this.finishNode(node, "AssignmentExpression");
- } else if (failOnShorthandAssign && refShorthandDefaultPos.start) {
- this.unexpected(refShorthandDefaultPos.start);
- }
- return left;
- };
- // Parse a ternary conditional (`?:`) operator.
- pp.parseMaybeConditional = function (noIn, refShorthandDefaultPos) {
- var start = this.markPosition();
- var expr = this.parseExprOps(noIn, refShorthandDefaultPos);
- if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
- if (this.eat(_tokentype.types.question)) {
- var node = this.startNodeAt(start);
- node.test = expr;
- node.consequent = this.parseMaybeAssign();
- this.expect(_tokentype.types.colon);
- node.alternate = this.parseMaybeAssign(noIn);
- return this.finishNode(node, "ConditionalExpression");
- }
- return expr;
- };
- // Start the precedence parser.
- pp.parseExprOps = function (noIn, refShorthandDefaultPos) {
- var start = this.markPosition();
- var expr = this.parseMaybeUnary(refShorthandDefaultPos);
- if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
- return this.parseExprOp(expr, start, -1, noIn);
- };
- // Parse binary operators with the operator precedence parsing
- // algorithm. `left` is the left-hand side of the operator.
- // `minPrec` provides context that allows the function to stop and
- // defer further parser to one of its callers when it encounters an
- // operator that has a lower precedence than the set it is parsing.
- pp.parseExprOp = function (left, leftStart, minPrec, noIn) {
- var prec = this.type.binop;
- if (prec != null && (!noIn || this.type !== _tokentype.types._in)) {
- if (prec > minPrec) {
- var node = this.startNodeAt(leftStart);
- node.left = left;
- node.operator = this.value;
- var op = this.type;
- this.next();
- var _start = this.markPosition();
- node.right = this.parseExprOp(this.parseMaybeUnary(), _start, op.rightAssociative ? prec - 1 : prec, noIn);
- this.finishNode(node, op === _tokentype.types.logicalOR || op === _tokentype.types.logicalAND ? "LogicalExpression" : "BinaryExpression");
- return this.parseExprOp(node, leftStart, minPrec, noIn);
- }
- }
- return left;
- };
- // Parse unary operators, both prefix and postfix.
- pp.parseMaybeUnary = function (refShorthandDefaultPos) {
- if (this.type.prefix) {
- var node = this.startNode(),
- update = this.type === _tokentype.types.incDec;
- node.operator = this.value;
- node.prefix = true;
- this.next();
- node.argument = this.parseMaybeUnary();
- if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
- if (update) this.checkLVal(node.argument);else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") this.raise(node.start, "Deleting local variable in strict mode");
- return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
- }
- var start = this.markPosition();
- var expr = this.parseExprSubscripts(refShorthandDefaultPos);
- if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
- while (this.type.postfix && !this.canInsertSemicolon()) {
- var node = this.startNodeAt(start);
- node.operator = this.value;
- node.prefix = false;
- node.argument = expr;
- this.checkLVal(expr);
- this.next();
- expr = this.finishNode(node, "UpdateExpression");
- }
- return expr;
- };
- // Parse call, dot, and `[]`-subscript expressions.
- pp.parseExprSubscripts = function (refShorthandDefaultPos) {
- var start = this.markPosition();
- var expr = this.parseExprAtom(refShorthandDefaultPos);
- if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;
- return this.parseSubscripts(expr, start);
- };
- pp.parseSubscripts = function (base, start, noCalls) {
- if (!noCalls && this.eat(_tokentype.types.doubleColon)) {
- var node = this.startNodeAt(start);
- node.object = base;
- node.callee = this.parseNoCallExpr();
- return this.parseSubscripts(this.finishNode(node, "BindExpression"), start, noCalls);
- } else if (this.eat(_tokentype.types.dot)) {
- var node = this.startNodeAt(start);
- node.object = base;
- node.property = this.parseIdent(true);
- node.computed = false;
- return this.parseSubscripts(this.finishNode(node, "MemberExpression"), start, noCalls);
- } else if (this.eat(_tokentype.types.bracketL)) {
- var node = this.startNodeAt(start);
- node.object = base;
- node.property = this.parseExpression();
- node.computed = true;
- this.expect(_tokentype.types.bracketR);
- return this.parseSubscripts(this.finishNode(node, "MemberExpression"), start, noCalls);
- } else if (!noCalls && this.eat(_tokentype.types.parenL)) {
- var node = this.startNodeAt(start);
- node.callee = base;
- node.arguments = this.parseExprList(_tokentype.types.parenR, this.options.features["es7.trailingFunctionCommas"]);
- return this.parseSubscripts(this.finishNode(node, "CallExpression"), start, noCalls);
- } else if (this.type === _tokentype.types.backQuote) {
- var node = this.startNodeAt(start);
- node.tag = base;
- node.quasi = this.parseTemplate();
- return this.parseSubscripts(this.finishNode(node, "TaggedTemplateExpression"), start, noCalls);
- }return base;
- };
- // Parse a no-call expression (like argument of `new` or `::` operators).
- pp.parseNoCallExpr = function () {
- var start = this.markPosition();
- return this.parseSubscripts(this.parseExprAtom(), start, true);
- };
- // Parse an atomic expression — either a single token that is an
- // expression, an expression started by a keyword like `function` or
- // `new`, or an expression wrapped in punctuation like `()`, `[]`,
- // or `{}`.
- pp.parseExprAtom = function (refShorthandDefaultPos) {
- var node = undefined,
- canBeArrow = this.potentialArrowAt == this.start;
- switch (this.type) {
- case _tokentype.types._this:
- case _tokentype.types._super:
- var type = this.type === _tokentype.types._this ? "ThisExpression" : "Super";
- node = this.startNode();
- this.next();
- return this.finishNode(node, type);
- case _tokentype.types._yield:
- if (this.inGenerator) this.unexpected();
- case _tokentype.types._do:
- if (this.options.features["es7.doExpressions"]) {
- var _node = this.startNode();
- this.next();
- _node.body = this.parseBlock();
- return this.finishNode(_node, "DoExpression");
- }
- case _tokentype.types.name:
- var start = this.markPosition();
- node = this.startNode();
- var id = this.parseIdent(this.type !== _tokentype.types.name);
- //
- if (this.options.features["es7.asyncFunctions"]) {
- // async functions!
- if (id.name === "async") {
- // arrow functions
- if (this.type === _tokentype.types.parenL) {
- var expr = this.parseParenAndDistinguishExpression(start, true, true);
- if (expr && expr.type === "ArrowFunctionExpression") {
- return expr;
- } else {
- node.callee = id;
- if (!expr) {
- node.arguments = [];
- } else if (expr.type === "SequenceExpression") {
- node.arguments = expr.expressions;
- } else {
- node.arguments = [expr];
- }
- return this.parseSubscripts(this.finishNode(node, "CallExpression"), start);
- }
- } else if (this.type === _tokentype.types.name) {
- id = this.parseIdent();
- this.expect(_tokentype.types.arrow);
- return this.parseArrowExpression(node, [id], true);
- }
- // normal functions
- if (this.type === _tokentype.types._function && !this.canInsertSemicolon()) {
- this.next();
- return this.parseFunction(node, false, false, true);
- }
- } else if (id.name === "await") {
- if (this.inAsync) return this.parseAwait(node);
- }
- }
- //
- if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) return this.parseArrowExpression(this.startNodeAt(start), [id]);
- return id;
- case _tokentype.types.regexp:
- var value = this.value;
- node = this.parseLiteral(value.value);
- node.regex = { pattern: value.pattern, flags: value.flags };
- return node;
- case _tokentype.types.num:case _tokentype.types.string:
- return this.parseLiteral(this.value);
- case _tokentype.types._null:case _tokentype.types._true:case _tokentype.types._false:
- node = this.startNode();
- node.value = this.type === _tokentype.types._null ? null : this.type === _tokentype.types._true;
- node.raw = this.type.keyword;
- this.next();
- return this.finishNode(node, "Literal");
- case _tokentype.types.parenL:
- return this.parseParenAndDistinguishExpression(null, null, canBeArrow);
- case _tokentype.types.bracketL:
- node = this.startNode();
- this.next();
- // check whether this is array comprehension or regular array
- if ((this.options.ecmaVersion >= 7 || this.options.features["es7.comprehensions"]) && this.type === _tokentype.types._for) {
- return this.parseComprehension(node, false);
- }
- node.elements = this.parseExprList(_tokentype.types.bracketR, true, true, refShorthandDefaultPos);
- return this.finishNode(node, "ArrayExpression");
- case _tokentype.types.braceL:
- return this.parseObj(false, refShorthandDefaultPos);
- case _tokentype.types._function:
- node = this.startNode();
- this.next();
- return this.parseFunction(node, false);
- case _tokentype.types.at:
- this.parseDecorators();
- case _tokentype.types._class:
- node = this.startNode();
- this.takeDecorators(node);
- return this.parseClass(node, false);
- case _tokentype.types._new:
- return this.parseNew();
- case _tokentype.types.backQuote:
- return this.parseTemplate();
- case _tokentype.types.doubleColon:
- node = this.startNode();
- this.next();
- node.object = null;
- var callee = node.callee = this.parseNoCallExpr();
- if (callee.type !== "MemberExpression") this.raise(callee.start, "Binding should be performed on object property.");
- return this.finishNode(node, "BindExpression");
- default:
- this.unexpected();
- }
- };
- pp.parseLiteral = function (value) {
- var node = this.startNode();
- node.value = value;
- node.raw = this.input.slice(this.start, this.end);
- this.next();
- return this.finishNode(node, "Literal");
- };
- pp.parseParenExpression = function () {
- this.expect(_tokentype.types.parenL);
- var val = this.parseExpression();
- this.expect(_tokentype.types.parenR);
- return val;
- };
- pp.parseParenAndDistinguishExpression = function (start, isAsync, canBeArrow) {
- start = start || this.markPosition();
- var val = undefined;
- if (this.options.ecmaVersion >= 6) {
- this.next();
- if ((this.options.features["es7.comprehensions"] || this.options.ecmaVersion >= 7) && this.type === _tokentype.types._for) {
- return this.parseComprehension(this.startNodeAt(start), true);
- }
- var innerStart = this.markPosition(),
- exprList = [],
- first = true;
- var refShorthandDefaultPos = { start: 0 },
- spreadStart = undefined,
- innerParenStart = undefined;
- while (this.type !== _tokentype.types.parenR) {
- first ? first = false : this.expect(_tokentype.types.comma);
- if (this.type === _tokentype.types.ellipsis) {
- var spreadNodeStart = this.markPosition();
- spreadStart = this.start;
- exprList.push(this.parseParenItem(this.parseRest(), spreadNodeStart));
- break;
- } else {
- if (this.type === _tokentype.types.parenL && !innerParenStart) {
- innerParenStart = this.start;
- }
- exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem));
- }
- }
- var innerEnd = this.markPosition();
- this.expect(_tokentype.types.parenR);
- if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) {
- if (innerParenStart) this.unexpected(innerParenStart);
- return this.parseParenArrowList(start, exprList, isAsync);
- }
- if (!exprList.length) {
- if (isAsync) {
- return;
- } else {
- this.unexpected(this.lastTokStart);
- }
- }
- if (spreadStart) this.unexpected(spreadStart);
- if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
- if (exprList.length > 1) {
- val = this.startNodeAt(innerStart);
- val.expressions = exprList;
- this.finishNodeAt(val, "SequenceExpression", innerEnd);
- } else {
- val = exprList[0];
- }
- } else {
- val = this.parseParenExpression();
- }
- if (this.options.preserveParens) {
- var par = this.startNodeAt(start);
- par.expression = val;
- return this.finishNode(par, "ParenthesizedExpression");
- } else {
- val.parenthesizedExpression = true;
- return val;
- }
- };
- pp.parseParenArrowList = function (start, exprList, isAsync) {
- return this.parseArrowExpression(this.startNodeAt(start), exprList, isAsync);
- };
- pp.parseParenItem = function (node, start) {
- return node;
- };
- // New's precedence is slightly tricky. It must allow its argument
- // to be a `[]` or dot subscript expression, but not a call — at
- // least, not without wrapping it in parentheses. Thus, it uses the
- var empty = [];
- pp.parseNew = function () {
- var node = this.startNode();
- var meta = this.parseIdent(true);
- if (this.options.ecmaVersion >= 6 && this.eat(_tokentype.types.dot)) {
- node.meta = meta;
- node.property = this.parseIdent(true);
- if (node.property.name !== "target") this.raise(node.property.start, "The only valid meta property for new is new.target");
- return this.finishNode(node, "MetaProperty");
- }
- node.callee = this.parseNoCallExpr();
- if (this.eat(_tokentype.types.parenL)) node.arguments = this.parseExprList(_tokentype.types.parenR, this.options.features["es7.trailingFunctionCommas"]);else node.arguments = empty;
- return this.finishNode(node, "NewExpression");
- };
- // Parse template expression.
- pp.parseTemplateElement = function () {
- var elem = this.startNode();
- elem.value = {
- raw: this.input.slice(this.start, this.end),
- cooked: this.value
- };
- this.next();
- elem.tail = this.type === _tokentype.types.backQuote;
- return this.finishNode(elem, "TemplateElement");
- };
- pp.parseTemplate = function () {
- var node = this.startNode();
- this.next();
- node.expressions = [];
- var curElt = this.parseTemplateElement();
- node.quasis = [curElt];
- while (!curElt.tail) {
- this.expect(_tokentype.types.dollarBraceL);
- node.expressions.push(this.parseExpression());
- this.expect(_tokentype.types.braceR);
- node.quasis.push(curElt = this.parseTemplateElement());
- }
- this.next();
- return this.finishNode(node, "TemplateLiteral");
- };
- // Parse an object literal or binding pattern.
- pp.parseObj = function (isPattern, refShorthandDefaultPos) {
- var node = this.startNode(),
- first = true,
- propHash = {};
- node.properties = [];
- var decorators = [];
- this.next();
- while (!this.eat(_tokentype.types.braceR)) {
- if (!first) {
- this.expect(_tokentype.types.comma);
- if (this.afterTrailingComma(_tokentype.types.braceR)) break;
- } else first = false;
- while (this.type === _tokentype.types.at) {
- decorators.push(this.parseDecorator());
- }
- var prop = this.startNode(),
- isGenerator = false,
- isAsync = false,
- _start2 = undefined;
- if (decorators.length) {
- prop.decorators = decorators;
- decorators = [];
- }
- if (this.options.features["es7.objectRestSpread"] && this.type === _tokentype.types.ellipsis) {
- prop = this.parseSpread();
- prop.type = "SpreadProperty";
- node.properties.push(prop);
- continue;
- }
- if (this.options.ecmaVersion >= 6) {
- prop.method = false;
- prop.shorthand = false;
- if (isPattern || refShorthandDefaultPos) _start2 = this.markPosition();
- if (!isPattern) isGenerator = this.eat(_tokentype.types.star);
- }
- if (this.options.features["es7.asyncFunctions"] && this.isContextual("async")) {
- if (isGenerator || isPattern) this.unexpected();
- var asyncId = this.parseIdent();
- if (this.type === _tokentype.types.colon || this.type === _tokentype.types.parenL) {
- prop.key = asyncId;
- } else {
- isAsync = true;
- this.parsePropertyName(prop);
- }
- } else {
- this.parsePropertyName(prop);
- }
- this.parseObjPropValue(prop, _start2, isGenerator, isAsync, isPattern, refShorthandDefaultPos);
- this.checkPropClash(prop, propHash);
- node.properties.push(this.finishNode(prop, "Property"));
- }
- if (decorators.length) {
- this.raise(this.start, "You have trailing decorators with no property");
- }
- return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
- };
- pp.parseObjPropValue = function (prop, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos) {
- if (this.eat(_tokentype.types.colon)) {
- prop.value = isPattern ? this.parseMaybeDefault() : this.parseMaybeAssign(false, refShorthandDefaultPos);
- prop.kind = "init";
- } else if (this.options.ecmaVersion >= 6 && this.type === _tokentype.types.parenL) {
- if (isPattern) this.unexpected();
- prop.kind = "init";
- prop.method = true;
- prop.value = this.parseMethod(isGenerator, isAsync);
- } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type != _tokentype.types.comma && this.type != _tokentype.types.braceR)) {
- if (isGenerator || isAsync || isPattern) this.unexpected();
- prop.kind = prop.key.name;
- this.parsePropertyName(prop);
- prop.value = this.parseMethod(false);
- } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
- prop.kind = "init";
- if (isPattern) {
- if (this.isKeyword(prop.key.name) || this.strict && (_identifier.reservedWords.strictBind(prop.key.name) || _identifier.reservedWords.strict(prop.key.name)) || !this.options.allowReserved && this.isReservedWord(prop.key.name)) this.raise(prop.key.start, "Binding " + prop.key.name);
- prop.value = this.parseMaybeDefault(start, prop.key);
- } else if (this.type === _tokentype.types.eq && refShorthandDefaultPos) {
- if (!refShorthandDefaultPos.start) refShorthandDefaultPos.start = this.start;
- prop.value = this.parseMaybeDefault(start, prop.key);
- } else {
- prop.value = prop.key;
- }
- prop.shorthand = true;
- } else this.unexpected();
- };
- pp.parsePropertyName = function (prop) {
- if (this.options.ecmaVersion >= 6) {
- if (this.eat(_tokentype.types.bracketL)) {
- prop.computed = true;
- prop.key = this.parseMaybeAssign();
- this.expect(_tokentype.types.bracketR);
- return;
- } else {
- prop.computed = false;
- }
- }
- prop.key = this.type === _tokentype.types.num || this.type === _tokentype.types.string ? this.parseExprAtom() : this.parseIdent(true);
- };
- // Initialize empty function node.
- pp.initFunction = function (node, isAsync) {
- node.id = null;
- if (this.options.ecmaVersion >= 6) {
- node.generator = false;
- node.expression = false;
- }
- if (this.options.features["es7.asyncFunctions"]) {
- node.async = !!isAsync;
- }
- };
- // Parse object or class method.
- pp.parseMethod = function (isGenerator, isAsync) {
- var node = this.startNode();
- this.initFunction(node, isAsync);
- this.expect(_tokentype.types.parenL);
- node.params = this.parseBindingList(_tokentype.types.parenR, false, this.options.features["es7.trailingFunctionCommas"]);
- if (this.options.ecmaVersion >= 6) {
- node.generator = isGenerator;
- }
- this.parseFunctionBody(node);
- return this.finishNode(node, "FunctionExpression");
- };
- // Parse arrow function expression with given parameters.
- pp.parseArrowExpression = function (node, params, isAsync) {
- this.initFunction(node, isAsync);
- node.params = this.toAssignableList(params, true);
- this.parseFunctionBody(node, true);
- return this.finishNode(node, "ArrowFunctionExpression");
- };
- // Parse function body and check parameters.
- pp.parseFunctionBody = function (node, allowExpression) {
- var isExpression = allowExpression && this.type !== _tokentype.types.braceL;
- var oldInAsync = this.inAsync;
- this.inAsync = node.async;
- if (isExpression) {
- node.body = this.parseMaybeAssign();
- node.expression = true;
- } else {
- // Start a new scope with regard to labels and the `inFunction`
- // flag (restore them to their old value afterwards).
- var oldInFunc = this.inFunction,
- oldInGen = this.inGenerator,
- oldLabels = this.labels;
- this.inFunction = true;this.inGenerator = node.generator;this.labels = [];
- node.body = this.parseBlock(true);
- node.expression = false;
- this.inFunction = oldInFunc;this.inGenerator = oldInGen;this.labels = oldLabels;
- }
- this.inAsync = oldInAsync;
- // If this is a strict mode function, verify that argument names
- // are not repeated, and it does not try to bind the words `eval`
- // or `arguments`.
- if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {
- var nameHash = {},
- oldStrict = this.strict;
- this.strict = true;
- if (node.id) this.checkLVal(node.id, true);
- for (var i = 0; i < node.params.length; i++) {
- this.checkLVal(node.params[i], true, nameHash);
- }this.strict = oldStrict;
- }
- };
- // Parses a comma-separated list of expressions, and returns them as
- // an array. `close` is the token type that ends the list, and
- // `allowEmpty` can be turned on to allow subsequent commas with
- // nothing in between them to be parsed as `null` (which is needed
- // for array literals).
- pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) {
- var elts = [],
- first = true;
- while (!this.eat(close)) {
- if (!first) {
- this.expect(_tokentype.types.comma);
- if (allowTrailingComma && this.afterTrailingComma(close)) break;
- } else first = false;
- if (allowEmpty && this.type === _tokentype.types.comma) {
- elts.push(null);
- } else {
- if (this.type === _tokentype.types.ellipsis) elts.push(this.parseSpread(refShorthandDefaultPos));else elts.push(this.parseMaybeAssign(false, refShorthandDefaultPos));
- }
- }
- return elts;
- };
- // Parse the next token as an identifier. If `liberal` is true (used
- // when parsing properties), it will also convert keywords into
- // identifiers.
- pp.parseIdent = function (liberal) {
- var node = this.startNode();
- if (liberal && this.options.allowReserved == "never") liberal = false;
- if (this.type === _tokentype.types.name) {
- if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.value) || this.strict && _identifier.reservedWords.strict(this.value) && (this.options.ecmaVersion >= 6 || this.input.slice(this.start, this.end).indexOf("\\") == -1))) this.raise(this.start, "The keyword '" + this.value + "' is reserved");
- node.name = this.value;
- } else if (liberal && this.type.keyword) {
- node.name = this.type.keyword;
- } else {
- this.unexpected();
- }
- this.next();
- return this.finishNode(node, "Identifier");
- };
- // Parses await expression inside async function.
- pp.parseAwait = function (node) {
- if (this.eat(_tokentype.types.semi) || this.canInsertSemicolon()) {
- this.unexpected();
- }
- node.all = this.eat(_tokentype.types.star);
- node.argument = this.parseMaybeUnary();
- return this.finishNode(node, "AwaitExpression");
- };
- // Parses yield expression inside generator.
- pp.parseYield = function () {
- var node = this.startNode();
- this.next();
- if (this.type == _tokentype.types.semi || this.canInsertSemicolon() || this.type != _tokentype.types.star && !this.type.startsExpr) {
- node.delegate = false;
- node.argument = null;
- } else {
- node.delegate = this.eat(_tokentype.types.star);
- node.argument = this.parseMaybeAssign();
- }
- return this.finishNode(node, "YieldExpression");
- };
- // Parses array and generator comprehensions.
- pp.parseComprehension = function (node, isGenerator) {
- node.blocks = [];
- while (this.type === _tokentype.types._for) {
- var block = this.startNode();
- this.next();
- this.expect(_tokentype.types.parenL);
- block.left = this.parseBindingAtom();
- this.checkLVal(block.left, true);
- this.expectContextual("of");
- block.right = this.parseExpression();
- this.expect(_tokentype.types.parenR);
- node.blocks.push(this.finishNode(block, "ComprehensionBlock"));
- }
- node.filter = this.eat(_tokentype.types._if) ? this.parseParenExpression() : null;
- node.body = this.parseExpression();
- this.expect(isGenerator ? _tokentype.types.parenR : _tokentype.types.bracketR);
- node.generator = isGenerator;
- return this.finishNode(node, "ComprehensionExpression");
- };
- },{"./identifier":4,"./state":12,"./tokentype":16,"./util":17}],4:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- // Test whether a given character code starts an identifier.
- exports.isIdentifierStart = isIdentifierStart;
- // Test whether a given character is part of an identifier.
- exports.isIdentifierChar = isIdentifierChar;
- // This is a trick taken from Esprima. It turns out that, on
- // non-Chrome browsers, to check whether a string is in a set, a
- // predicate containing a big ugly `switch` statement is faster than
- // a regular expression, and on Chrome the two are about on par.
- // This function uses `eval` (non-lexical) to produce such a
- // predicate from a space-separated string of words.
- //
- // It starts by sorting the words by length.
- function makePredicate(words) {
- words = words.split(" ");
- return function (str) {
- return words.indexOf(str) >= 0;
- };
- }
- // Reserved word lists for various dialects of the language
- var reservedWords = {
- 3: makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),
- 5: makePredicate("class enum extends super const export import"),
- 6: makePredicate("enum await"),
- strict: makePredicate("implements interface let package private protected public static yield"),
- strictBind: makePredicate("eval arguments")
- };
- exports.reservedWords = reservedWords;
- // And the keywords
- var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
- var keywords = {
- 5: makePredicate(ecma5AndLessKeywords),
- 6: makePredicate(ecma5AndLessKeywords + " let const class extends export import yield super")
- };
- exports.keywords = keywords;
- // ## Character categories
- // Big ugly regular expressions that match characters in the
- // whitespace, identifier, and identifier-start categories. These
- // are only applied when a character is found to actually have a
- // code point above 128.
- // Generated by `tools/generate-identifier-regex.js`.
- var nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";
- var nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏ᦰ-ᧀᧈᧉ᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷼-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︭︳︴﹍-﹏0-9_";
- var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
- var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
- nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
- // These are a run-length and offset encoded representation of the
- // >0xffff code points that are a valid part of identifiers. The
- // offset starts at 0x10000, and each pair of numbers represents an
- // offset to the next range, and then a size of the range. They were
- // generated by tools/generate-identifier-regex.js
- var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 17, 26, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 99, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 98, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 26, 45, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 955, 52, 76, 44, 33, 24, 27, 35, 42, 34, 4, 0, 13, 47, 15, 3, 22, 0, 38, 17, 2, 24, 133, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 32, 4, 287, 47, 21, 1, 2, 0, 185, 46, 82, 47, 21, 0, 60, 42, 502, 63, 32, 0, 449, 56, 1288, 920, 104, 110, 2962, 1070, 13266, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 881, 68, 12, 0, 67, 12, 16481, 1, 3071, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 4149, 196, 1340, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 16355, 541];
- var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 1306, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 52, 0, 13, 2, 49, 13, 16, 9, 83, 11, 168, 11, 6, 9, 8, 2, 57, 0, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 316, 19, 13, 9, 214, 6, 3, 8, 112, 16, 16, 9, 82, 12, 9, 9, 535, 9, 20855, 9, 135, 4, 60, 6, 26, 9, 1016, 45, 17, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 4305, 6, 792618, 239];
- // This has a complexity linear to the value of the code. The
- // assumption is that looking up astral identifier characters is
- // rare.
- function isInAstralSet(code, set) {
- var pos = 65536;
- for (var i = 0; i < set.length; i += 2) {
- pos += set[i];
- if (pos > code) return false;
- pos += set[i + 1];
- if (pos >= code) return true;
- }
- }
- function isIdentifierStart(code, astral) {
- if (code < 65) return code === 36;
- if (code < 91) return true;
- if (code < 97) return code === 95;
- if (code < 123) return true;
- if (code <= 65535) return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
- if (astral === false) return false;
- return isInAstralSet(code, astralIdentifierStartCodes);
- }
- function isIdentifierChar(code, astral) {
- if (code < 48) return code === 36;
- if (code < 58) return true;
- if (code < 65) return false;
- if (code < 91) return true;
- if (code < 97) return code === 95;
- if (code < 123) return true;
- if (code <= 65535) return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
- if (astral === false) return false;
- return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
- }
- },{}],5:[function(require,module,exports){
- // Acorn is a tiny, fast JavaScript parser written in JavaScript.
- //
- // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
- // various contributors and released under an MIT license.
- //
- // Git repositories for Acorn are available at
- //
- // http://marijnhaverbeke.nl/git/acorn
- // https://github.com/marijnh/acorn.git
- //
- // Please use the [github bug tracker][ghbt] to report issues.
- //
- // [ghbt]: https://github.com/marijnh/acorn/issues
- //
- // This file defines the main parser interface. The library also comes
- // with a [error-tolerant parser][dammit] and an
- // [abstract syntax tree walker][walk], defined in other files.
- //
- // [dammit]: acorn_loose.js
- // [walk]: util/walk.js
- "use strict";
- exports.__esModule = true;
- // The main exported interface (under `self.acorn` when in the
- // browser) is a `parse` function that takes a code string and
- // returns an abstract syntax tree as specified by [Mozilla parser
- // API][api].
- //
- // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
- exports.parse = parse;
- // This function tries to parse a single expression at a given
- // offset in a string. Useful for parsing mixed-language formats
- // that embed JavaScript expressions.
- exports.parseExpressionAt = parseExpressionAt;
- // Acorn is organized as a tokenizer and a recursive-descent parser.
- // The `tokenize` export provides an interface to the tokenizer.
- // Because the tokenizer is optimized for being efficiently used by
- // the Acorn parser itself, this interface is somewhat crude and not
- // very modular.
- exports.tokenizer = tokenizer;
- var _state = require("./state");
- var _options = require("./options");
- require("./parseutil");
- require("./statement");
- require("./lval");
- require("./expression");
- require("./lookahead");
- exports.Parser = _state.Parser;
- exports.plugins = _state.plugins;
- exports.defaultOptions = _options.defaultOptions;
- var _location = require("./location");
- exports.SourceLocation = _location.SourceLocation;
- exports.getLineInfo = _location.getLineInfo;
- var _node = require("./node");
- exports.Node = _node.Node;
- var _tokentype = require("./tokentype");
- exports.TokenType = _tokentype.TokenType;
- exports.tokTypes = _tokentype.types;
- var _tokencontext = require("./tokencontext");
- exports.TokContext = _tokencontext.TokContext;
- exports.tokContexts = _tokencontext.types;
- var _identifier = require("./identifier");
- exports.isIdentifierChar = _identifier.isIdentifierChar;
- exports.isIdentifierStart = _identifier.isIdentifierStart;
- var _tokenize = require("./tokenize");
- exports.Token = _tokenize.Token;
- var _whitespace = require("./whitespace");
- exports.isNewLine = _whitespace.isNewLine;
- exports.lineBreak = _whitespace.lineBreak;
- exports.lineBreakG = _whitespace.lineBreakG;
- var version = "1.0.0";exports.version = version;
- function parse(input, options) {
- var p = parser(options, input);
- var startPos = p.options.locations ? [p.pos, p.curPosition()] : p.pos;
- p.nextToken();
- return p.parseTopLevel(p.options.program || p.startNodeAt(startPos));
- }
- function parseExpressionAt(input, pos, options) {
- var p = parser(options, input, pos);
- p.nextToken();
- return p.parseExpression();
- }
- function tokenizer(input, options) {
- return parser(options, input);
- }
- function parser(options, input) {
- return new _state.Parser((0, _options.getOptions)(options), String(input));
- }
- },{"./expression":3,"./identifier":4,"./location":6,"./lookahead":7,"./lval":8,"./node":9,"./options":10,"./parseutil":11,"./state":12,"./statement":13,"./tokencontext":14,"./tokenize":15,"./tokentype":16,"./whitespace":18}],6:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- // The `getLineInfo` function is mostly useful when the
- // `locations` option is off (for performance reasons) and you
- // want to find the line/column position for a given character
- // offset. `input` should be the code string that the offset refers
- // into.
- exports.getLineInfo = getLineInfo;
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _state = require("./state");
- var _whitespace = require("./whitespace");
- // These are used when `options.locations` is on, for the
- // `startLoc` and `endLoc` properties.
- var Position = (function () {
- function Position(line, col) {
- _classCallCheck(this, Position);
- this.line = line;
- this.column = col;
- }
- Position.prototype.offset = function offset(n) {
- return new Position(this.line, this.column + n);
- };
- return Position;
- })();
- exports.Position = Position;
- var SourceLocation = function SourceLocation(p, start, end) {
- _classCallCheck(this, SourceLocation);
- this.start = start;
- this.end = end;
- if (p.sourceFile !== null) this.source = p.sourceFile;
- };
- exports.SourceLocation = SourceLocation;
- function getLineInfo(input, offset) {
- for (var line = 1, cur = 0;;) {
- _whitespace.lineBreakG.lastIndex = cur;
- var match = _whitespace.lineBreakG.exec(input);
- if (match && match.index < offset) {
- ++line;
- cur = match.index + match[0].length;
- } else {
- return new Position(line, offset - cur);
- }
- }
- }
- var pp = _state.Parser.prototype;
- // This function is used to raise exceptions on parse errors. It
- // takes an offset integer (into the current `input`) to indicate
- // the location of the error, attaches the position to the end
- // of the error message, and then raises a `SyntaxError` with that
- // message.
- pp.raise = function (pos, message) {
- var loc = getLineInfo(this.input, pos);
- message += " (" + loc.line + ":" + loc.column + ")";
- var err = new SyntaxError(message);
- err.pos = pos;err.loc = loc;err.raisedAt = this.pos;
- throw err;
- };
- pp.curPosition = function () {
- return new Position(this.curLine, this.pos - this.lineStart);
- };
- pp.markPosition = function () {
- return this.options.locations ? [this.start, this.startLoc] : this.start;
- };
- },{"./state":12,"./whitespace":18}],7:[function(require,module,exports){
- "use strict";
- var _state = require("./state");
- var pp = _state.Parser.prototype;
- var STATE_KEYS = ["lastTokStartLoc", "lastTokEndLoc", "lastTokStart", "lastTokEnd", "lineStart", "startLoc", "endLoc", "start", "pos", "end", "type", "value", "exprAllowed", "potentialArrowAt", "currLine", "input"];
- pp.getState = function () {
- var state = {};
- for (var i = 0; i < STATE_KEYS.length; i++) {
- var key = STATE_KEYS[i];
- state[key] = this[key];
- }
- state.context = this.context.slice();
- return state;
- };
- pp.lookahead = function () {
- var old = this.getState();
- this.isLookahead = true;
- this.next();
- this.isLookahead = false;
- var curr = this.getState();
- for (var key in old) this[key] = old[key];
- return curr;
- };
- },{"./state":12}],8:[function(require,module,exports){
- "use strict";
- var _tokentype = require("./tokentype");
- var _state = require("./state");
- var _identifier = require("./identifier");
- var _util = require("./util");
- var pp = _state.Parser.prototype;
- // Convert existing expression atom to assignable pattern
- // if possible.
- pp.toAssignable = function (node, isBinding) {
- if (this.options.ecmaVersion >= 6 && node) {
- switch (node.type) {
- case "Identifier":
- case "ObjectPattern":
- case "ArrayPattern":
- case "AssignmentPattern":
- break;
- case "ObjectExpression":
- node.type = "ObjectPattern";
- for (var i = 0; i < node.properties.length; i++) {
- var prop = node.properties[i];
- if (prop.type === "SpreadProperty") continue;
- if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter");
- this.toAssignable(prop.value, isBinding);
- }
- break;
- case "ArrayExpression":
- node.type = "ArrayPattern";
- this.toAssignableList(node.elements, isBinding);
- break;
- case "AssignmentExpression":
- if (node.operator === "=") {
- node.type = "AssignmentPattern";
- } else {
- this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
- }
- break;
- case "MemberExpression":
- if (!isBinding) break;
- default:
- this.raise(node.start, "Assigning to rvalue");
- }
- }
- return node;
- };
- // Convert list of expression atoms to binding list.
- pp.toAssignableList = function (exprList, isBinding) {
- var end = exprList.length;
- if (end) {
- var last = exprList[end - 1];
- if (last && last.type == "RestElement") {
- --end;
- } else if (last && last.type == "SpreadElement") {
- last.type = "RestElement";
- var arg = last.argument;
- this.toAssignable(arg, isBinding);
- if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") this.unexpected(arg.start);
- --end;
- }
- }
- for (var i = 0; i < end; i++) {
- var elt = exprList[i];
- if (elt) this.toAssignable(elt, isBinding);
- }
- return exprList;
- };
- // Parses spread element.
- pp.parseSpread = function (refShorthandDefaultPos) {
- var node = this.startNode();
- this.next();
- node.argument = this.parseMaybeAssign(refShorthandDefaultPos);
- return this.finishNode(node, "SpreadElement");
- };
- pp.parseRest = function () {
- var node = this.startNode();
- this.next();
- node.argument = this.type === _tokentype.types.name || this.type === _tokentype.types.bracketL ? this.parseBindingAtom() : this.unexpected();
- return this.finishNode(node, "RestElement");
- };
- // Parses lvalue (assignable) atom.
- pp.parseBindingAtom = function () {
- if (this.options.ecmaVersion < 6) return this.parseIdent();
- switch (this.type) {
- case _tokentype.types.name:
- return this.parseIdent();
- case _tokentype.types.bracketL:
- var node = this.startNode();
- this.next();
- node.elements = this.parseBindingList(_tokentype.types.bracketR, true, true);
- return this.finishNode(node, "ArrayPattern");
- case _tokentype.types.braceL:
- return this.parseObj(true);
- default:
- this.unexpected();
- }
- };
- pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
- var elts = [],
- first = true;
- while (!this.eat(close)) {
- if (first) first = false;else this.expect(_tokentype.types.comma);
- if (allowEmpty && this.type === _tokentype.types.comma) {
- elts.push(null);
- } else if (allowTrailingComma && this.afterTrailingComma(close)) {
- break;
- } else if (this.type === _tokentype.types.ellipsis) {
- elts.push(this.parseAssignableListItemTypes(this.parseRest()));
- this.expect(close);
- break;
- } else {
- var left = this.parseMaybeDefault();
- this.parseAssignableListItemTypes(left);
- elts.push(this.parseMaybeDefault(null, left));
- }
- }
- return elts;
- };
- pp.parseAssignableListItemTypes = function (param) {
- return param;
- };
- // Parses assignment pattern around given atom if possible.
- pp.parseMaybeDefault = function (startPos, left) {
- startPos = startPos || this.markPosition();
- left = left || this.parseBindingAtom();
- if (!this.eat(_tokentype.types.eq)) return left;
- var node = this.startNodeAt(startPos);
- node.operator = "=";
- node.left = left;
- node.right = this.parseMaybeAssign();
- return this.finishNode(node, "AssignmentPattern");
- };
- // Verify that a node is an lval — something that can be assigned
- // to.
- pp.checkLVal = function (expr, isBinding, checkClashes) {
- switch (expr.type) {
- case "Identifier":
- if (this.strict && (_identifier.reservedWords.strictBind(expr.name) || _identifier.reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
- if (checkClashes) {
- if ((0, _util.has)(checkClashes, expr.name)) this.raise(expr.start, "Argument name clash in strict mode");
- checkClashes[expr.name] = true;
- }
- break;
- case "MemberExpression":
- if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");
- break;
- case "ObjectPattern":
- for (var i = 0; i < expr.properties.length; i++) {
- var prop = expr.properties[i];
- if (prop.type === "Property") prop = prop.value;
- this.checkLVal(prop, isBinding, checkClashes);
- }
- break;
- case "ArrayPattern":
- for (var i = 0; i < expr.elements.length; i++) {
- var elem = expr.elements[i];
- if (elem) this.checkLVal(elem, isBinding, checkClashes);
- }
- break;
- case "AssignmentPattern":
- this.checkLVal(expr.left, isBinding, checkClashes);
- break;
- case "SpreadProperty":
- case "RestElement":
- this.checkLVal(expr.argument, isBinding, checkClashes);
- break;
- default:
- this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");
- }
- };
- },{"./identifier":4,"./state":12,"./tokentype":16,"./util":17}],9:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _state = require("./state");
- var _location = require("./location");
- // Start an AST node, attaching a start offset.
- var pp = _state.Parser.prototype;
- var Node = function Node() {
- _classCallCheck(this, Node);
- };
- exports.Node = Node;
- pp.startNode = function () {
- var node = new Node();
- node.start = this.start;
- if (this.options.locations) node.loc = new _location.SourceLocation(this, this.startLoc);
- if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
- if (this.options.ranges) node.range = [this.start, 0];
- return node;
- };
- pp.startNodeAt = function (pos) {
- var node = new Node(),
- start = pos;
- if (this.options.locations) {
- node.loc = new _location.SourceLocation(this, start[1]);
- start = pos[0];
- }
- node.start = start;
- if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;
- if (this.options.ranges) node.range = [start, 0];
- return node;
- };
- // Finish an AST node, adding `type` and `end` properties.
- pp.finishNode = function (node, type) {
- node.type = type;
- node.end = this.lastTokEnd;
- if (this.options.locations) node.loc.end = this.lastTokEndLoc;
- if (this.options.ranges) node.range[1] = this.lastTokEnd;
- return node;
- };
- // Finish node at given position
- pp.finishNodeAt = function (node, type, pos) {
- if (this.options.locations) {
- node.loc.end = pos[1];pos = pos[0];
- }
- node.type = type;
- node.end = pos;
- if (this.options.ranges) node.range[1] = pos;
- return node;
- };
- },{"./location":6,"./state":12}],10:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- // Interpret and default an options object
- exports.getOptions = getOptions;
- var _util = require("./util");
- var _location = require("./location");
- // A second optional argument can be given to further configure
- // the parser process. These options are recognized:
- var defaultOptions = {
- // `ecmaVersion` indicates the ECMAScript version to parse. Must
- // be either 3, or 5, or 6. This influences support for strict
- // mode, the set of reserved words, support for getters and
- // setters and other features.
- ecmaVersion: 5,
- // Source type ("script" or "module") for different semantics
- sourceType: "script",
- // `onInsertedSemicolon` can be a callback that will be called
- // when a semicolon is automatically inserted. It will be passed
- // th position of the comma as an offset, and if `locations` is
- // enabled, it is given the location as a `{line, column}` object
- // as second argument.
- onInsertedSemicolon: null,
- // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
- // trailing commas.
- onTrailingComma: null,
- // By default, reserved words are not enforced. Disable
- // `allowReserved` to enforce them. When this option has the
- // value "never", reserved words and keywords can also not be
- // used as property names.
- allowReserved: true,
- // When enabled, a return at the top level is not considered an
- // error.
- allowReturnOutsideFunction: false,
- // When enabled, import/export statements are not constrained to
- // appearing at the top of the program.
- allowImportExportEverywhere: false,
- // When enabled, hashbang directive in the beginning of file
- // is allowed and treated as a line comment.
- allowHashBang: false,
- // When `locations` is on, `loc` properties holding objects with
- // `start` and `end` properties in `{line, column}` form (with
- // line being 1-based and column 0-based) will be attached to the
- // nodes.
- locations: false,
- // A function can be passed as `onToken` option, which will
- // cause Acorn to call that function with object in the same
- // format as tokenize() returns. Note that you are not
- // allowed to call the parser from the callback—that will
- // corrupt its internal state.
- onToken: null,
- // A function can be passed as `onComment` option, which will
- // cause Acorn to call that function with `(block, text, start,
- // end)` parameters whenever a comment is skipped. `block` is a
- // boolean indicating whether this is a block (`/* */`) comment,
- // `text` is the content of the comment, and `start` and `end` are
- // character offsets that denote the start and end of the comment.
- // When the `locations` option is on, two more parameters are
- // passed, the full `{line, column}` locations of the start and
- // end of the comments. Note that you are not allowed to call the
- // parser from the callback—that will corrupt its internal state.
- onComment: null,
- // Nodes have their start and end characters offsets recorded in
- // `start` and `end` properties (directly on the node, rather than
- // the `loc` object, which holds line/column data. To also add a
- // [semi-standardized][range] `range` property holding a `[start,
- // end]` array with the same numbers, set the `ranges` option to
- // `true`.
- //
- // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
- ranges: false,
- // It is possible to parse multiple files into a single AST by
- // passing the tree produced by parsing the first file as
- // `program` option in subsequent parses. This will add the
- // toplevel forms of the parsed file to the `Program` (top) node
- // of an existing parse tree.
- program: null,
- // When `locations` is on, you can pass this to record the source
- // file in every node's `loc` object.
- sourceFile: null,
- // This value, if given, is stored in every node, whether
- // `locations` is on or off.
- directSourceFile: null,
- // When enabled, parenthesized expressions are represented by
- // (non-standard) ParenthesizedExpression nodes
- preserveParens: false,
- plugins: {},
- // Babel-specific options
- features: {},
- strictMode: null
- };exports.defaultOptions = defaultOptions;
- function getOptions(opts) {
- var options = {};
- for (var opt in defaultOptions) {
- options[opt] = opts && (0, _util.has)(opts, opt) ? opts[opt] : defaultOptions[opt];
- }if ((0, _util.isArray)(options.onToken)) {
- (function () {
- var tokens = options.onToken;
- options.onToken = function (token) {
- return tokens.push(token);
- };
- })();
- }
- if ((0, _util.isArray)(options.onComment)) options.onComment = pushComment(options, options.onComment);
- return options;
- }
- function pushComment(options, array) {
- return function (block, text, start, end, startLoc, endLoc) {
- var comment = {
- type: block ? "Block" : "Line",
- value: text,
- start: start,
- end: end
- };
- if (options.locations) comment.loc = new _location.SourceLocation(this, startLoc, endLoc);
- if (options.ranges) comment.range = [start, end];
- array.push(comment);
- };
- }
- },{"./location":6,"./util":17}],11:[function(require,module,exports){
- "use strict";
- var _tokentype = require("./tokentype");
- var _state = require("./state");
- var _whitespace = require("./whitespace");
- var pp = _state.Parser.prototype;
- // ## Parser utilities
- // Test whether a statement node is the string literal `"use strict"`.
- pp.isUseStrict = function (stmt) {
- return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
- };
- // Predicate that tests whether the next token is of the given
- // type, and if yes, consumes it as a side effect.
- pp.eat = function (type) {
- if (this.type === type) {
- this.next();
- return true;
- } else {
- return false;
- }
- };
- // Tests whether parsed token is a contextual keyword.
- pp.isContextual = function (name) {
- return this.type === _tokentype.types.name && this.value === name;
- };
- // Consumes contextual keyword if possible.
- pp.eatContextual = function (name) {
- return this.value === name && this.eat(_tokentype.types.name);
- };
- // Asserts that following token is given contextual keyword.
- pp.expectContextual = function (name) {
- if (!this.eatContextual(name)) this.unexpected();
- };
- // Test whether a semicolon can be inserted at the current position.
- pp.canInsertSemicolon = function () {
- return this.type === _tokentype.types.eof || this.type === _tokentype.types.braceR || _whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
- };
- pp.insertSemicolon = function () {
- if (this.canInsertSemicolon()) {
- if (this.options.onInsertedSemicolon) this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
- return true;
- }
- };
- // Consume a semicolon, or, failing that, see if we are allowed to
- // pretend that there is a semicolon at this position.
- pp.semicolon = function () {
- if (!this.eat(_tokentype.types.semi) && !this.insertSemicolon()) this.unexpected();
- };
- pp.afterTrailingComma = function (tokType) {
- if (this.type == tokType) {
- if (this.options.onTrailingComma) this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
- this.next();
- return true;
- }
- };
- // Expect a token of a given type. If found, consume it, otherwise,
- // raise an unexpected token error.
- pp.expect = function (type) {
- this.eat(type) || this.unexpected();
- };
- // Raise an unexpected token error.
- pp.unexpected = function (pos) {
- this.raise(pos != null ? pos : this.start, "Unexpected token");
- };
- },{"./state":12,"./tokentype":16,"./whitespace":18}],12:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Parser = Parser;
- var _identifier = require("./identifier");
- var _tokentype = require("./tokentype");
- function Parser(options, input, startPos) {
- this.options = options;
- this.loadPlugins(this.options.plugins);
- this.sourceFile = this.options.sourceFile || null;
- this.isKeyword = _identifier.keywords[this.options.ecmaVersion >= 6 ? 6 : 5];
- this.isReservedWord = _identifier.reservedWords[this.options.ecmaVersion];
- this.input = input;
- // Set up token state
- // The current position of the tokenizer in the input.
- if (startPos) {
- this.pos = startPos;
- this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));
- this.curLine = this.input.slice(0, this.lineStart).split(_tokentype.lineBreak).length;
- } else {
- this.pos = this.lineStart = 0;
- this.curLine = 1;
- }
- // Properties of the current token:
- // Its type
- this.type = _tokentype.types.eof;
- // For tokens that include more information than their type, the value
- this.value = null;
- // Its start and end offset
- this.start = this.end = this.pos;
- // And, if locations are used, the {line, column} object
- // corresponding to those offsets
- this.startLoc = this.endLoc = null;
- // Position information for the previous token
- this.lastTokEndLoc = this.lastTokStartLoc = null;
- this.lastTokStart = this.lastTokEnd = this.pos;
- // The context stack is used to superficially track syntactic
- // context to predict whether a regular expression is allowed in a
- // given position.
- this.context = this.initialContext();
- this.exprAllowed = true;
- // Figure out if it's a module code.
- this.inModule = this.options.sourceType === "module";
- this.strict = this.options.strictMode === false ? false : this.inModule;
- // Used to signify the start of a potential arrow function
- this.potentialArrowAt = -1;
- // Flags to track whether we are in a function, a generator.
- this.inFunction = this.inGenerator = false;
- // Labels in scope.
- this.labels = [];
- this.decorators = [];
- // If enabled, skip leading hashbang line.
- if (this.pos === 0 && this.options.allowHashBang && this.input.slice(0, 2) === "#!") this.skipLineComment(2);
- }
- Parser.prototype.extend = function (name, f) {
- this[name] = f(this[name]);
- };
- // Registered plugins
- var plugins = {};
- exports.plugins = plugins;
- Parser.prototype.loadPlugins = function (plugins) {
- for (var _name in plugins) {
- var plugin = exports.plugins[_name];
- if (!plugin) throw new Error("Plugin '" + _name + "' not found");
- plugin(this, plugins[_name]);
- }
- };
- },{"./identifier":4,"./tokentype":16}],13:[function(require,module,exports){
- "use strict";
- var _tokentype = require("./tokentype");
- var _state = require("./state");
- var _whitespace = require("./whitespace");
- var pp = _state.Parser.prototype;
- // ### Statement parsing
- // Parse a program. Initializes the parser, reads any number of
- // statements, and wraps them in a Program node. Optionally takes a
- // `program` argument. If present, the statements will be appended
- // to its body instead of creating a new node.
- pp.parseTopLevel = function (node) {
- var first = true;
- if (!node.body) node.body = [];
- while (this.type !== _tokentype.types.eof) {
- var stmt = this.parseStatement(true, true);
- node.body.push(stmt);
- if (first && this.isUseStrict(stmt)) this.setStrict(true);
- first = false;
- }
- this.next();
- if (this.options.ecmaVersion >= 6) {
- node.sourceType = this.options.sourceType;
- }
- return this.finishNode(node, "Program");
- };
- var loopLabel = { kind: "loop" },
- switchLabel = { kind: "switch" };
- // Parse a single statement.
- //
- // If expecting a statement and finding a slash operator, parse a
- // regular expression literal. This is to handle cases like
- // `if (foo) /blah/.exec(foo)`, where looking at the previous token
- // does not help.
- pp.parseStatement = function (declaration, topLevel) {
- if (this.type === _tokentype.types.at) {
- this.parseDecorators(true);
- }
- var starttype = this.type,
- node = this.startNode();
- // Most types of statements are recognized by the keyword they
- // start with. Many are trivial to parse, some require a bit of
- // complexity.
- switch (starttype) {
- case _tokentype.types._break:case _tokentype.types._continue:
- return this.parseBreakContinueStatement(node, starttype.keyword);
- case _tokentype.types._debugger:
- return this.parseDebuggerStatement(node);
- case _tokentype.types._do:
- return this.parseDoStatement(node);
- case _tokentype.types._for:
- return this.parseForStatement(node);
- case _tokentype.types._function:
- if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();
- return this.parseFunctionStatement(node);
- case _tokentype.types._class:
- if (!declaration) this.unexpected();
- this.takeDecorators(node);
- return this.parseClass(node, true);
- case _tokentype.types._if:
- return this.parseIfStatement(node);
- case _tokentype.types._return:
- return this.parseReturnStatement(node);
- case _tokentype.types._switch:
- return this.parseSwitchStatement(node);
- case _tokentype.types._throw:
- return this.parseThrowStatement(node);
- case _tokentype.types._try:
- return this.parseTryStatement(node);
- case _tokentype.types._let:case _tokentype.types._const:
- if (!declaration) this.unexpected(); // NOTE: falls through to _var
- case _tokentype.types._var:
- return this.parseVarStatement(node, starttype);
- case _tokentype.types._while:
- return this.parseWhileStatement(node);
- case _tokentype.types._with:
- return this.parseWithStatement(node);
- case _tokentype.types.braceL:
- return this.parseBlock();
- case _tokentype.types.semi:
- return this.parseEmptyStatement(node);
- case _tokentype.types._export:
- case _tokentype.types._import:
- if (!this.options.allowImportExportEverywhere) {
- if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");
- if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
- }
- return starttype === _tokentype.types._import ? this.parseImport(node) : this.parseExport(node);
- case _tokentype.types.name:
- if (this.options.features["es7.asyncFunctions"] && this.value === "async" && this.lookahead().type === _tokentype.types._function) {
- this.next();
- this.expect(_tokentype.types._function);
- return this.parseFunction(node, true, false, true);
- }
- // If the statement does not start with a statement keyword or a
- // brace, it's an ExpressionStatement or LabeledStatement. We
- // simply start parsing an expression, and afterwards, if the
- // next token is a colon and the expression was a simple
- // Identifier node, we switch to interpreting it as a label.
- default:
- var maybeName = this.value,
- expr = this.parseExpression();
- if (starttype === _tokentype.types.name && expr.type === "Identifier" && this.eat(_tokentype.types.colon)) return this.parseLabeledStatement(node, maybeName, expr);else return this.parseExpressionStatement(node, expr);
- }
- };
- pp.takeDecorators = function (node) {
- if (this.decorators.length) {
- node.decorators = this.decorators;
- this.decorators = [];
- }
- };
- pp.parseDecorators = function (allowExport) {
- while (this.type === _tokentype.types.at) {
- this.decorators.push(this.parseDecorator());
- }
- if (allowExport && this.type === _tokentype.types._export) {
- return;
- }
- if (this.type !== _tokentype.types._class) {
- this.raise(this.start, "Leading decorators must be attached to a class declaration");
- }
- };
- pp.parseDecorator = function (allowExport) {
- if (!this.options.features["es7.decorators"]) {
- this.unexpected();
- }
- var node = this.startNode();
- this.next();
- node.expression = this.parseMaybeAssign();
- return this.finishNode(node, "Decorator");
- };
- pp.parseBreakContinueStatement = function (node, keyword) {
- var isBreak = keyword == "break";
- this.next();
- if (this.eat(_tokentype.types.semi) || this.insertSemicolon()) node.label = null;else if (this.type !== _tokentype.types.name) this.unexpected();else {
- node.label = this.parseIdent();
- this.semicolon();
- }
- // Verify that there is an actual destination to break or
- // continue to.
- for (var i = 0; i < this.labels.length; ++i) {
- var lab = this.labels[i];
- if (node.label == null || lab.name === node.label.name) {
- if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
- if (node.label && isBreak) break;
- }
- }
- if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);
- return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
- };
- pp.parseDebuggerStatement = function (node) {
- this.next();
- this.semicolon();
- return this.finishNode(node, "DebuggerStatement");
- };
- pp.parseDoStatement = function (node) {
- var start = this.markPosition();
- this.next();
- this.labels.push(loopLabel);
- node.body = this.parseStatement(false);
- this.labels.pop();
- if (this.options.features["es7.doExpressions"] && this.type !== _tokentype.types._while) {
- var container = this.startNodeAt(start);
- container.expression = this.finishNode(node, "DoExpression");
- this.semicolon();
- return this.finishNode(container, "ExpressionStatement");
- }
- this.expect(_tokentype.types._while);
- node.test = this.parseParenExpression();
- if (this.options.ecmaVersion >= 6) this.eat(_tokentype.types.semi);else this.semicolon();
- return this.finishNode(node, "DoWhileStatement");
- };
- // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
- // loop is non-trivial. Basically, we have to parse the init `var`
- // statement or expression, disallowing the `in` operator (see
- // the second parameter to `parseExpression`), and then check
- // whether the next token is `in` or `of`. When there is no init
- // part (semicolon immediately after the opening parenthesis), it
- // is a regular `for` loop.
- pp.parseForStatement = function (node) {
- this.next();
- this.labels.push(loopLabel);
- this.expect(_tokentype.types.parenL);
- if (this.type === _tokentype.types.semi) return this.parseFor(node, null);
- if (this.type === _tokentype.types._var || this.type === _tokentype.types._let || this.type === _tokentype.types._const) {
- var _init = this.startNode(),
- varKind = this.type;
- this.next();
- this.parseVar(_init, true, varKind);
- this.finishNode(_init, "VariableDeclaration");
- if ((this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== _tokentype.types._var && _init.declarations[0].init)) return this.parseForIn(node, _init);
- return this.parseFor(node, _init);
- }
- var refShorthandDefaultPos = { start: 0 };
- var init = this.parseExpression(true, refShorthandDefaultPos);
- if (this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {
- this.toAssignable(init);
- this.checkLVal(init);
- return this.parseForIn(node, init);
- } else if (refShorthandDefaultPos.start) {
- this.unexpected(refShorthandDefaultPos.start);
- }
- return this.parseFor(node, init);
- };
- pp.parseFunctionStatement = function (node) {
- this.next();
- return this.parseFunction(node, true);
- };
- pp.parseIfStatement = function (node) {
- this.next();
- node.test = this.parseParenExpression();
- node.consequent = this.parseStatement(false);
- node.alternate = this.eat(_tokentype.types._else) ? this.parseStatement(false) : null;
- return this.finishNode(node, "IfStatement");
- };
- pp.parseReturnStatement = function (node) {
- if (!this.inFunction && !this.options.allowReturnOutsideFunction) this.raise(this.start, "'return' outside of function");
- this.next();
- // In `return` (and `break`/`continue`), the keywords with
- // optional arguments, we eagerly look for a semicolon or the
- // possibility to insert one.
- if (this.eat(_tokentype.types.semi) || this.insertSemicolon()) node.argument = null;else {
- node.argument = this.parseExpression();this.semicolon();
- }
- return this.finishNode(node, "ReturnStatement");
- };
- pp.parseSwitchStatement = function (node) {
- this.next();
- node.discriminant = this.parseParenExpression();
- node.cases = [];
- this.expect(_tokentype.types.braceL);
- this.labels.push(switchLabel);
- // Statements under must be grouped (by label) in SwitchCase
- // nodes. `cur` is used to keep the node that we are currently
- // adding statements to.
- for (var cur, sawDefault; this.type != _tokentype.types.braceR;) {
- if (this.type === _tokentype.types._case || this.type === _tokentype.types._default) {
- var isCase = this.type === _tokentype.types._case;
- if (cur) this.finishNode(cur, "SwitchCase");
- node.cases.push(cur = this.startNode());
- cur.consequent = [];
- this.next();
- if (isCase) {
- cur.test = this.parseExpression();
- } else {
- if (sawDefault) this.raise(this.lastTokStart, "Multiple default clauses");
- sawDefault = true;
- cur.test = null;
- }
- this.expect(_tokentype.types.colon);
- } else {
- if (!cur) this.unexpected();
- cur.consequent.push(this.parseStatement(true));
- }
- }
- if (cur) this.finishNode(cur, "SwitchCase");
- this.next(); // Closing brace
- this.labels.pop();
- return this.finishNode(node, "SwitchStatement");
- };
- pp.parseThrowStatement = function (node) {
- this.next();
- if (_whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) this.raise(this.lastTokEnd, "Illegal newline after throw");
- node.argument = this.parseExpression();
- this.semicolon();
- return this.finishNode(node, "ThrowStatement");
- };
- // Reused empty array added for node fields that are always empty.
- var empty = [];
- pp.parseTryStatement = function (node) {
- this.next();
- node.block = this.parseBlock();
- node.handler = null;
- if (this.type === _tokentype.types._catch) {
- var clause = this.startNode();
- this.next();
- this.expect(_tokentype.types.parenL);
- clause.param = this.parseBindingAtom();
- this.checkLVal(clause.param, true);
- this.expect(_tokentype.types.parenR);
- clause.guard = null;
- clause.body = this.parseBlock();
- node.handler = this.finishNode(clause, "CatchClause");
- }
- node.guardedHandlers = empty;
- node.finalizer = this.eat(_tokentype.types._finally) ? this.parseBlock() : null;
- if (!node.handler && !node.finalizer) this.raise(node.start, "Missing catch or finally clause");
- return this.finishNode(node, "TryStatement");
- };
- pp.parseVarStatement = function (node, kind) {
- this.next();
- this.parseVar(node, false, kind);
- this.semicolon();
- return this.finishNode(node, "VariableDeclaration");
- };
- pp.parseWhileStatement = function (node) {
- this.next();
- node.test = this.parseParenExpression();
- this.labels.push(loopLabel);
- node.body = this.parseStatement(false);
- this.labels.pop();
- return this.finishNode(node, "WhileStatement");
- };
- pp.parseWithStatement = function (node) {
- if (this.strict) this.raise(this.start, "'with' in strict mode");
- this.next();
- node.object = this.parseParenExpression();
- node.body = this.parseStatement(false);
- return this.finishNode(node, "WithStatement");
- };
- pp.parseEmptyStatement = function (node) {
- this.next();
- return this.finishNode(node, "EmptyStatement");
- };
- pp.parseLabeledStatement = function (node, maybeName, expr) {
- for (var i = 0; i < this.labels.length; ++i) {
- if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is already declared");
- }var kind = this.type.isLoop ? "loop" : this.type === _tokentype.types._switch ? "switch" : null;
- this.labels.push({ name: maybeName, kind: kind });
- node.body = this.parseStatement(true);
- this.labels.pop();
- node.label = expr;
- return this.finishNode(node, "LabeledStatement");
- };
- pp.parseExpressionStatement = function (node, expr) {
- node.expression = expr;
- this.semicolon();
- return this.finishNode(node, "ExpressionStatement");
- };
- // Parse a semicolon-enclosed block of statements, handling `"use
- // strict"` declarations when `allowStrict` is true (used for
- // function bodies).
- pp.parseBlock = function (allowStrict) {
- var node = this.startNode(),
- first = true,
- oldStrict = undefined;
- node.body = [];
- this.expect(_tokentype.types.braceL);
- while (!this.eat(_tokentype.types.braceR)) {
- var stmt = this.parseStatement(true);
- node.body.push(stmt);
- if (first && allowStrict && this.isUseStrict(stmt)) {
- oldStrict = this.strict;
- this.setStrict(this.strict = true);
- }
- first = false;
- }
- if (oldStrict === false) this.setStrict(false);
- return this.finishNode(node, "BlockStatement");
- };
- // Parse a regular `for` loop. The disambiguation code in
- // `parseStatement` will already have parsed the init statement or
- // expression.
- pp.parseFor = function (node, init) {
- node.init = init;
- this.expect(_tokentype.types.semi);
- node.test = this.type === _tokentype.types.semi ? null : this.parseExpression();
- this.expect(_tokentype.types.semi);
- node.update = this.type === _tokentype.types.parenR ? null : this.parseExpression();
- this.expect(_tokentype.types.parenR);
- node.body = this.parseStatement(false);
- this.labels.pop();
- return this.finishNode(node, "ForStatement");
- };
- // Parse a `for`/`in` and `for`/`of` loop, which are almost
- // same from parser's perspective.
- pp.parseForIn = function (node, init) {
- var type = this.type === _tokentype.types._in ? "ForInStatement" : "ForOfStatement";
- this.next();
- node.left = init;
- node.right = this.parseExpression();
- this.expect(_tokentype.types.parenR);
- node.body = this.parseStatement(false);
- this.labels.pop();
- return this.finishNode(node, type);
- };
- // Parse a list of variable declarations.
- pp.parseVar = function (node, isFor, kind) {
- node.declarations = [];
- node.kind = kind.keyword;
- for (;;) {
- var decl = this.startNode();
- this.parseVarHead(decl);
- if (this.eat(_tokentype.types.eq)) {
- decl.init = this.parseMaybeAssign(isFor);
- } else if (kind === _tokentype.types._const && !(this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
- this.unexpected();
- } else if (decl.id.type != "Identifier" && !(isFor && (this.type === _tokentype.types._in || this.isContextual("of")))) {
- this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
- } else {
- decl.init = null;
- }
- node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
- if (!this.eat(_tokentype.types.comma)) break;
- }
- return node;
- };
- pp.parseVarHead = function (decl) {
- decl.id = this.parseBindingAtom();
- this.checkLVal(decl.id, true);
- };
- // Parse a function declaration or literal (depending on the
- // `isStatement` parameter).
- pp.parseFunction = function (node, isStatement, allowExpressionBody, isAsync) {
- this.initFunction(node, isAsync);
- if (this.options.ecmaVersion >= 6) node.generator = this.eat(_tokentype.types.star);
- if (isStatement || this.type === _tokentype.types.name) node.id = this.parseIdent();
- this.parseFunctionParams(node);
- this.parseFunctionBody(node, allowExpressionBody);
- return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
- };
- pp.parseFunctionParams = function (node) {
- this.expect(_tokentype.types.parenL);
- node.params = this.parseBindingList(_tokentype.types.parenR, false, this.options.features["es7.trailingFunctionCommas"]);
- };
- // Parse a class declaration or literal (depending on the
- // `isStatement` parameter).
- pp.parseClass = function (node, isStatement) {
- this.next();
- this.parseClassId(node, isStatement);
- this.parseClassSuper(node);
- var classBody = this.startNode();
- classBody.body = [];
- this.expect(_tokentype.types.braceL);
- var decorators = [];
- while (!this.eat(_tokentype.types.braceR)) {
- if (this.eat(_tokentype.types.semi)) continue;
- if (this.type === _tokentype.types.at) {
- decorators.push(this.parseDecorator());
- continue;
- }
- var method = this.startNode();
- if (decorators.length) {
- method.decorators = decorators;
- decorators = [];
- }
- var isGenerator = this.eat(_tokentype.types.star),
- isAsync = false;
- this.parsePropertyName(method);
- if (this.type !== _tokentype.types.parenL && !method.computed && method.key.type === "Identifier" && method.key.name === "static") {
- if (isGenerator) this.unexpected();
- method["static"] = true;
- isGenerator = this.eat(_tokentype.types.star);
- this.parsePropertyName(method);
- } else {
- method["static"] = false;
- }
- if (!isGenerator && method.key.type === "Identifier" && !method.computed && this.isClassProperty()) {
- classBody.body.push(this.parseClassProperty(method));
- continue;
- }
- if (this.options.features["es7.asyncFunctions"] && this.type !== _tokentype.types.parenL && !method.computed && method.key.type === "Identifier" && method.key.name === "async") {
- isAsync = true;
- this.parsePropertyName(method);
- }
- method.kind = "method";
- if (!method.computed && !isGenerator && !isAsync) {
- if (method.key.type === "Identifier") {
- if (this.type !== _tokentype.types.parenL && (method.key.name === "get" || method.key.name === "set")) {
- method.kind = method.key.name;
- this.parsePropertyName(method);
- } else if (!method["static"] && method.key.name === "constructor") {
- method.kind = "constructor";
- }
- } else if (!method["static"] && method.key.type === "Literal" && method.key.value === "constructor") {
- method.kind = "constructor";
- }
- }
- if (method.kind === "constructor" && method.decorators) {
- this.raise(method.start, "You can't attach decorators to a class constructor");
- }
- this.parseClassMethod(classBody, method, isGenerator, isAsync);
- }
- if (decorators.length) {
- this.raise(this.start, "You have trailing decorators with no method");
- }
- node.body = this.finishNode(classBody, "ClassBody");
- return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
- };
- pp.isClassProperty = function () {
- return this.type === _tokentype.types.eq || (this.type === _tokentype.types.semi || this.canInsertSemicolon());
- };
- pp.parseClassProperty = function (node) {
- if (this.type === _tokentype.types.eq) {
- if (!this.options.features["es7.classProperties"]) this.unexpected();
- this.next();
- node.value = this.parseMaybeAssign();
- } else {
- node.value = null;
- }
- this.semicolon();
- return this.finishNode(node, "ClassProperty");
- };
- pp.parseClassMethod = function (classBody, method, isGenerator, isAsync) {
- method.value = this.parseMethod(isGenerator, isAsync);
- classBody.body.push(this.finishNode(method, "MethodDefinition"));
- };
- pp.parseClassId = function (node, isStatement) {
- node.id = this.type === _tokentype.types.name ? this.parseIdent() : isStatement ? this.unexpected() : null;
- };
- pp.parseClassSuper = function (node) {
- node.superClass = this.eat(_tokentype.types._extends) ? this.parseExprSubscripts() : null;
- };
- // Parses module export declaration.
- pp.parseExport = function (node) {
- this.next();
- // export * from '...'
- if (this.type === _tokentype.types.star) {
- var specifier = this.startNode();
- this.next();
- if (this.options.features["es7.exportExtensions"] && this.eatContextual("as")) {
- specifier.exported = this.parseIdent();
- node.specifiers = [this.finishNode(specifier, "ExportNamespaceSpecifier")];
- this.parseExportSpecifiersMaybe(node);
- this.parseExportFrom(node);
- } else {
- this.parseExportFrom(node);
- return this.finishNode(node, "ExportAllDeclaration");
- }
- } else if (this.isExportDefaultSpecifier()) {
- var specifier = this.startNode();
- specifier.exported = this.parseIdent(true);
- node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
- if (this.type === _tokentype.types.comma && this.lookahead().type === _tokentype.types.star) {
- this.expect(_tokentype.types.comma);
- var _specifier = this.startNode();
- this.expect(_tokentype.types.star);
- this.expectContextual("as");
- _specifier.exported = this.parseIdent();
- node.specifiers.push(this.finishNode(_specifier, "ExportNamespaceSpecifier"));
- } else {
- this.parseExportSpecifiersMaybe(node);
- }
- this.parseExportFrom(node);
- } else if (this.eat(_tokentype.types._default)) {
- // export default ...
- var _expr = this.parseMaybeAssign();
- var needsSemi = true;
- if (_expr.type == "FunctionExpression" || _expr.type == "ClassExpression") {
- needsSemi = false;
- if (_expr.id) {
- _expr.type = _expr.type == "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";
- }
- }
- node.declaration = _expr;
- if (needsSemi) this.semicolon();
- this.checkExport(node);
- return this.finishNode(node, "ExportDefaultDeclaration");
- } else if (this.type.keyword || this.shouldParseExportDeclaration()) {
- node.declaration = this.parseStatement(true);
- node.specifiers = [];
- node.source = null;
- } else {
- // export { x, y as z } [from '...']
- node.declaration = null;
- node.specifiers = this.parseExportSpecifiers();
- if (this.eatContextual("from")) {
- node.source = this.type === _tokentype.types.string ? this.parseExprAtom() : this.unexpected();
- } else {
- node.source = null;
- }
- this.semicolon();
- }
- this.checkExport(node);
- return this.finishNode(node, "ExportNamedDeclaration");
- };
- pp.isExportDefaultSpecifier = function () {
- if (this.type === _tokentype.types.name) {
- return this.value !== "type" && this.value !== "async";
- }
- if (this.type !== _tokentype.types._default) {
- return false;
- }
- var lookahead = this.lookahead();
- return lookahead.type === _tokentype.types.comma || lookahead.type === _tokentype.types.name && lookahead.value === "from";
- };
- pp.parseExportSpecifiersMaybe = function (node) {
- if (this.eat(_tokentype.types.comma)) {
- node.specifiers = node.specifiers.concat(this.parseExportSpecifiers());
- }
- };
- pp.parseExportFrom = function (node) {
- this.expectContextual("from");
- node.source = this.type === _tokentype.types.string ? this.parseExprAtom() : this.unexpected();
- this.semicolon();
- this.checkExport(node);
- };
- pp.shouldParseExportDeclaration = function () {
- return this.options.features["es7.asyncFunctions"] && this.isContextual("async");
- };
- pp.checkExport = function (node) {
- if (this.decorators.length) {
- var isClass = node.declaration && (node.declaration.type === "ClassDeclaration" || node.declaration.type === "ClassExpression");
- if (!node.declaration || !isClass) {
- this.raise(node.start, "You can only use decorators on an export when exporting a class");
- }
- this.takeDecorators(node.declaration);
- }
- };
- // Parses a comma-separated list of module exports.
- pp.parseExportSpecifiers = function () {
- var nodes = [],
- first = true;
- // export { x, y as z } [from '...']
- this.expect(_tokentype.types.braceL);
- while (!this.eat(_tokentype.types.braceR)) {
- if (!first) {
- this.expect(_tokentype.types.comma);
- if (this.afterTrailingComma(_tokentype.types.braceR)) break;
- } else first = false;
- var node = this.startNode();
- node.local = this.parseIdent(this.type === _tokentype.types._default);
- node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
- nodes.push(this.finishNode(node, "ExportSpecifier"));
- }
- return nodes;
- };
- // Parses import declaration.
- pp.parseImport = function (node) {
- this.next();
- // import '...'
- if (this.type === _tokentype.types.string) {
- node.specifiers = empty;
- node.source = this.parseExprAtom();
- } else {
- node.specifiers = [];
- this.parseImportSpecifiers(node);
- this.expectContextual("from");
- node.source = this.type === _tokentype.types.string ? this.parseExprAtom() : this.unexpected();
- }
- this.semicolon();
- return this.finishNode(node, "ImportDeclaration");
- };
- // Parses a comma-separated list of module imports.
- pp.parseImportSpecifiers = function (node) {
- var first = true;
- if (this.type === _tokentype.types.name) {
- // import defaultObj, { x, y as z } from '...'
- var start = this.markPosition();
- node.specifiers.push(this.parseImportSpecifierDefault(this.parseIdent(), start));
- if (!this.eat(_tokentype.types.comma)) return;
- }
- if (this.type === _tokentype.types.star) {
- var specifier = this.startNode();
- this.next();
- this.expectContextual("as");
- specifier.local = this.parseIdent();
- this.checkLVal(specifier.local, true);
- node.specifiers.push(this.finishNode(specifier, "ImportNamespaceSpecifier"));
- return;
- }
- this.expect(_tokentype.types.braceL);
- while (!this.eat(_tokentype.types.braceR)) {
- if (!first) {
- this.expect(_tokentype.types.comma);
- if (this.afterTrailingComma(_tokentype.types.braceR)) break;
- } else first = false;
- var specifier = this.startNode();
- specifier.imported = this.parseIdent(true);
- specifier.local = this.eatContextual("as") ? this.parseIdent() : specifier.imported;
- this.checkLVal(specifier.local, true);
- node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
- }
- };
- pp.parseImportSpecifierDefault = function (id, start) {
- var node = this.startNodeAt(start);
- node.local = id;
- this.checkLVal(node.local, true);
- return this.finishNode(node, "ImportDefaultSpecifier");
- };
- },{"./state":12,"./tokentype":16,"./whitespace":18}],14:[function(require,module,exports){
- // The algorithm used to determine whether a regexp can appear at a
- // given point in the program is loosely based on sweet.js' approach.
- // See https://github.com/mozilla/sweet.js/wiki/design
- "use strict";
- exports.__esModule = true;
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _state = require("./state");
- var _tokentype = require("./tokentype");
- var _whitespace = require("./whitespace");
- var TokContext = function TokContext(token, isExpr, preserveSpace, override) {
- _classCallCheck(this, TokContext);
- this.token = token;
- this.isExpr = isExpr;
- this.preserveSpace = preserveSpace;
- this.override = override;
- };
- exports.TokContext = TokContext;
- var types = {
- b_stat: new TokContext("{", false),
- b_expr: new TokContext("{", true),
- b_tmpl: new TokContext("${", true),
- p_stat: new TokContext("(", false),
- p_expr: new TokContext("(", true),
- q_tmpl: new TokContext("`", true, true, function (p) {
- return p.readTmplToken();
- }),
- f_expr: new TokContext("function", true)
- };
- exports.types = types;
- var pp = _state.Parser.prototype;
- pp.initialContext = function () {
- return [types.b_stat];
- };
- pp.braceIsBlock = function (prevType) {
- var parent = undefined;
- if (prevType === _tokentype.types.colon && (parent = this.curContext()).token == "{") return !parent.isExpr;
- if (prevType === _tokentype.types._return) return _whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
- if (prevType === _tokentype.types._else || prevType === _tokentype.types.semi || prevType === _tokentype.types.eof) return true;
- if (prevType == _tokentype.types.braceL) return this.curContext() === types.b_stat;
- return !this.exprAllowed;
- };
- pp.updateContext = function (prevType) {
- var update = undefined,
- type = this.type;
- if (type.keyword && prevType == _tokentype.types.dot) this.exprAllowed = false;else if (update = type.updateContext) update.call(this, prevType);else this.exprAllowed = type.beforeExpr;
- };
- // Token-specific context update code
- _tokentype.types.parenR.updateContext = _tokentype.types.braceR.updateContext = function () {
- if (this.context.length == 1) {
- this.exprAllowed = true;
- return;
- }
- var out = this.context.pop();
- if (out === types.b_stat && this.curContext() === types.f_expr) {
- this.context.pop();
- this.exprAllowed = false;
- } else if (out === types.b_tmpl) {
- this.exprAllowed = true;
- } else {
- this.exprAllowed = !out.isExpr;
- }
- };
- _tokentype.types.braceL.updateContext = function (prevType) {
- this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
- this.exprAllowed = true;
- };
- _tokentype.types.dollarBraceL.updateContext = function () {
- this.context.push(types.b_tmpl);
- this.exprAllowed = true;
- };
- _tokentype.types.parenL.updateContext = function (prevType) {
- var statementParens = prevType === _tokentype.types._if || prevType === _tokentype.types._for || prevType === _tokentype.types._with || prevType === _tokentype.types._while;
- this.context.push(statementParens ? types.p_stat : types.p_expr);
- this.exprAllowed = true;
- };
- _tokentype.types.incDec.updateContext = function () {};
- _tokentype.types._function.updateContext = function () {
- if (this.curContext() !== types.b_stat) this.context.push(types.f_expr);
- this.exprAllowed = false;
- };
- _tokentype.types.backQuote.updateContext = function () {
- if (this.curContext() === types.q_tmpl) this.context.pop();else this.context.push(types.q_tmpl);
- this.exprAllowed = false;
- };
- // tokExprAllowed stays unchanged
- },{"./state":12,"./tokentype":16,"./whitespace":18}],15:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _identifier = require("./identifier");
- var _tokentype = require("./tokentype");
- var _state = require("./state");
- var _location = require("./location");
- var _whitespace = require("./whitespace");
- // Object type used to represent tokens. Note that normally, tokens
- // simply exist as properties on the parser object. This is only
- // used for the onToken callback and the external tokenizer.
- var Token = function Token(p) {
- _classCallCheck(this, Token);
- this.type = p.type;
- this.value = p.value;
- this.start = p.start;
- this.end = p.end;
- if (p.options.locations) this.loc = new _location.SourceLocation(p, p.startLoc, p.endLoc);
- if (p.options.ranges) this.range = [p.start, p.end];
- };
- exports.Token = Token;
- // ## Tokenizer
- var pp = _state.Parser.prototype;
- // Move to the next token
- pp.next = function () {
- if (this.options.onToken && !this.isLookahead) this.options.onToken(new Token(this));
- this.lastTokEnd = this.end;
- this.lastTokStart = this.start;
- this.lastTokEndLoc = this.endLoc;
- this.lastTokStartLoc = this.startLoc;
- this.nextToken();
- };
- pp.getToken = function () {
- this.next();
- return new Token(this);
- };
- // If we're in an ES6 environment, make parsers iterable
- if (typeof Symbol !== "undefined") pp[Symbol.iterator] = function () {
- var self = this;
- return { next: function next() {
- var token = self.getToken();
- return {
- done: token.type === _tokentype.types.eof,
- value: token
- };
- } };
- };
- // Toggle strict mode. Re-reads the next number or string to please
- // pedantic tests (`"use strict"; 010;` should fail).
- pp.setStrict = function (strict) {
- this.strict = strict;
- if (this.type !== _tokentype.types.num && this.type !== _tokentype.types.string) return;
- this.pos = this.start;
- if (this.options.locations) {
- while (this.pos < this.lineStart) {
- this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
- --this.curLine;
- }
- }
- this.nextToken();
- };
- pp.curContext = function () {
- return this.context[this.context.length - 1];
- };
- // Read a single token, updating the parser object's token-related
- // properties.
- pp.nextToken = function () {
- var curContext = this.curContext();
- if (!curContext || !curContext.preserveSpace) this.skipSpace();
- this.start = this.pos;
- if (this.options.locations) this.startLoc = this.curPosition();
- if (this.pos >= this.input.length) return this.finishToken(_tokentype.types.eof);
- if (curContext.override) return curContext.override(this);else this.readToken(this.fullCharCodeAtPos());
- };
- pp.readToken = function (code) {
- // Identifier or keyword. '\uXXXX' sequences are allowed in
- // identifiers, so '\' also dispatches to that.
- if ((0, _identifier.isIdentifierStart)(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) return this.readWord();
- return this.getTokenFromCode(code);
- };
- pp.fullCharCodeAtPos = function () {
- var code = this.input.charCodeAt(this.pos);
- if (code <= 55295 || code >= 57344) return code;
- var next = this.input.charCodeAt(this.pos + 1);
- return (code << 10) + next - 56613888;
- };
- pp.skipBlockComment = function () {
- var startLoc = this.options.onComment && this.options.locations && this.curPosition();
- var start = this.pos,
- end = this.input.indexOf("*/", this.pos += 2);
- if (end === -1) this.raise(this.pos - 2, "Unterminated comment");
- this.pos = end + 2;
- if (this.options.locations) {
- _whitespace.lineBreakG.lastIndex = start;
- var match = undefined;
- while ((match = _whitespace.lineBreakG.exec(this.input)) && match.index < this.pos) {
- ++this.curLine;
- this.lineStart = match.index + match[0].length;
- }
- }
- if (this.options.onComment) this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.options.locations && this.curPosition());
- };
- pp.skipLineComment = function (startSkip) {
- var start = this.pos;
- var startLoc = this.options.onComment && this.options.locations && this.curPosition();
- var ch = this.input.charCodeAt(this.pos += startSkip);
- while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
- ++this.pos;
- ch = this.input.charCodeAt(this.pos);
- }
- if (this.options.onComment) this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.options.locations && this.curPosition());
- };
- // Called at the start of the parse and after every token. Skips
- // whitespace and comments, and.
- pp.skipSpace = function () {
- while (this.pos < this.input.length) {
- var ch = this.input.charCodeAt(this.pos);
- if (ch === 32) {
- // ' '
- ++this.pos;
- } else if (ch === 13) {
- ++this.pos;
- var _next = this.input.charCodeAt(this.pos);
- if (_next === 10) {
- ++this.pos;
- }
- if (this.options.locations) {
- ++this.curLine;
- this.lineStart = this.pos;
- }
- } else if (ch === 10 || ch === 8232 || ch === 8233) {
- ++this.pos;
- if (this.options.locations) {
- ++this.curLine;
- this.lineStart = this.pos;
- }
- } else if (ch > 8 && ch < 14) {
- ++this.pos;
- } else if (ch === 47) {
- // '/'
- var _next2 = this.input.charCodeAt(this.pos + 1);
- if (_next2 === 42) {
- // '*'
- this.skipBlockComment();
- } else if (_next2 === 47) {
- // '/'
- this.skipLineComment(2);
- } else break;
- } else if (ch === 160) {
- // '\xa0'
- ++this.pos;
- } else if (ch >= 5760 && _whitespace.nonASCIIwhitespace.test(String.fromCharCode(ch))) {
- ++this.pos;
- } else {
- break;
- }
- }
- };
- // Called at the end of every token. Sets `end`, `val`, and
- // maintains `context` and `exprAllowed`, and skips the space after
- // the token, so that the next one's `start` will point at the
- // right position.
- pp.finishToken = function (type, val) {
- this.end = this.pos;
- if (this.options.locations) this.endLoc = this.curPosition();
- var prevType = this.type;
- this.type = type;
- this.value = val;
- this.updateContext(prevType);
- };
- // ### Token reading
- // This is the function that is called to fetch the next token. It
- // is somewhat obscure, because it works in character codes rather
- // than characters, and because operator parsing has been inlined
- // into it.
- //
- // All in the name of speed.
- //
- pp.readToken_dot = function () {
- var next = this.input.charCodeAt(this.pos + 1);
- if (next >= 48 && next <= 57) return this.readNumber(true);
- var next2 = this.input.charCodeAt(this.pos + 2);
- if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
- // 46 = dot '.'
- this.pos += 3;
- return this.finishToken(_tokentype.types.ellipsis);
- } else {
- ++this.pos;
- return this.finishToken(_tokentype.types.dot);
- }
- };
- pp.readToken_slash = function () {
- // '/'
- var next = this.input.charCodeAt(this.pos + 1);
- if (this.exprAllowed) {
- ++this.pos;return this.readRegexp();
- }
- if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
- return this.finishOp(_tokentype.types.slash, 1);
- };
- pp.readToken_mult_modulo = function (code) {
- // '%*'
- var type = code === 42 ? _tokentype.types.star : _tokentype.types.modulo;
- var width = 1;
- var next = this.input.charCodeAt(this.pos + 1);
- if (next === 42) {
- // '*'
- width++;
- next = this.input.charCodeAt(this.pos + 2);
- type = _tokentype.types.exponent;
- }
- if (next === 61) {
- width++;
- type = _tokentype.types.assign;
- }
- return this.finishOp(type, width);
- };
- pp.readToken_pipe_amp = function (code) {
- // '|&'
- var next = this.input.charCodeAt(this.pos + 1);
- if (next === code) return this.finishOp(code === 124 ? _tokentype.types.logicalOR : _tokentype.types.logicalAND, 2);
- if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
- return this.finishOp(code === 124 ? _tokentype.types.bitwiseOR : _tokentype.types.bitwiseAND, 1);
- };
- pp.readToken_caret = function () {
- // '^'
- var next = this.input.charCodeAt(this.pos + 1);
- if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
- return this.finishOp(_tokentype.types.bitwiseXOR, 1);
- };
- pp.readToken_plus_min = function (code) {
- // '+-'
- var next = this.input.charCodeAt(this.pos + 1);
- if (next === code) {
- if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && _whitespace.lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
- // A `-->` line comment
- this.skipLineComment(3);
- this.skipSpace();
- return this.nextToken();
- }
- return this.finishOp(_tokentype.types.incDec, 2);
- }
- if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
- return this.finishOp(_tokentype.types.plusMin, 1);
- };
- pp.readToken_lt_gt = function (code) {
- // '<>'
- var next = this.input.charCodeAt(this.pos + 1);
- var size = 1;
- if (next === code) {
- size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
- if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(_tokentype.types.assign, size + 1);
- return this.finishOp(_tokentype.types.bitShift, size);
- }
- if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {
- if (this.inModule) this.unexpected();
- // `<!--`, an XML-style comment that should be interpreted as a line comment
- this.skipLineComment(4);
- this.skipSpace();
- return this.nextToken();
- }
- if (next === 61) size = this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2;
- return this.finishOp(_tokentype.types.relational, size);
- };
- pp.readToken_eq_excl = function (code) {
- // '=!'
- var next = this.input.charCodeAt(this.pos + 1);
- if (next === 61) return this.finishOp(_tokentype.types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
- if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
- // '=>'
- this.pos += 2;
- return this.finishToken(_tokentype.types.arrow);
- }
- return this.finishOp(code === 61 ? _tokentype.types.eq : _tokentype.types.prefix, 1);
- };
- pp.getTokenFromCode = function (code) {
- switch (code) {
- // The interpretation of a dot depends on whether it is followed
- // by a digit or another two dots.
- case 46:
- // '.'
- return this.readToken_dot();
- // Punctuation tokens.
- case 40:
- ++this.pos;return this.finishToken(_tokentype.types.parenL);
- case 41:
- ++this.pos;return this.finishToken(_tokentype.types.parenR);
- case 59:
- ++this.pos;return this.finishToken(_tokentype.types.semi);
- case 44:
- ++this.pos;return this.finishToken(_tokentype.types.comma);
- case 91:
- ++this.pos;return this.finishToken(_tokentype.types.bracketL);
- case 93:
- ++this.pos;return this.finishToken(_tokentype.types.bracketR);
- case 123:
- ++this.pos;return this.finishToken(_tokentype.types.braceL);
- case 125:
- ++this.pos;return this.finishToken(_tokentype.types.braceR);
- case 58:
- if (this.options.features["es7.functionBind"] && this.input.charCodeAt(this.pos + 1) === 58) return this.finishOp(_tokentype.types.doubleColon, 2);
- ++this.pos;
- return this.finishToken(_tokentype.types.colon);
- case 63:
- ++this.pos;return this.finishToken(_tokentype.types.question);
- case 64:
- ++this.pos;return this.finishToken(_tokentype.types.at);
- case 96:
- // '`'
- if (this.options.ecmaVersion < 6) break;
- ++this.pos;
- return this.finishToken(_tokentype.types.backQuote);
- case 48:
- // '0'
- var next = this.input.charCodeAt(this.pos + 1);
- if (next === 120 || next === 88) return this.readRadixNumber(16); // '0x', '0X' - hex number
- if (this.options.ecmaVersion >= 6) {
- if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number
- if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number
- }
- // Anything else beginning with a digit is an integer, octal
- // number, or float.
- case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:
- // 1-9
- return this.readNumber(false);
- // Quotes produce strings.
- case 34:case 39:
- // '"', "'"
- return this.readString(code);
- // Operators are parsed inline in tiny state machines. '=' (61) is
- // often referred to. `finishOp` simply skips the amount of
- // characters it is given as second argument, and returns a token
- // of the type given by its first argument.
- case 47:
- // '/'
- return this.readToken_slash();
- case 37:case 42:
- // '%*'
- return this.readToken_mult_modulo(code);
- case 124:case 38:
- // '|&'
- return this.readToken_pipe_amp(code);
- case 94:
- // '^'
- return this.readToken_caret();
- case 43:case 45:
- // '+-'
- return this.readToken_plus_min(code);
- case 60:case 62:
- // '<>'
- return this.readToken_lt_gt(code);
- case 61:case 33:
- // '=!'
- return this.readToken_eq_excl(code);
- case 126:
- // '~'
- return this.finishOp(_tokentype.types.prefix, 1);
- }
- this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
- };
- pp.finishOp = function (type, size) {
- var str = this.input.slice(this.pos, this.pos + size);
- this.pos += size;
- return this.finishToken(type, str);
- };
- var regexpUnicodeSupport = false;
- try {
- new RegExp("", "u");regexpUnicodeSupport = true;
- } catch (e) {}
- // Parse a regular expression. Some context-awareness is necessary,
- // since a '/' inside a '[]' set does not end the expression.
- pp.readRegexp = function () {
- var escaped = undefined,
- inClass = undefined,
- start = this.pos;
- for (;;) {
- if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression");
- var ch = this.input.charAt(this.pos);
- if (_whitespace.lineBreak.test(ch)) this.raise(start, "Unterminated regular expression");
- if (!escaped) {
- if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;
- escaped = ch === "\\";
- } else escaped = false;
- ++this.pos;
- }
- var content = this.input.slice(start, this.pos);
- ++this.pos;
- // Need to use `readWord1` because '\uXXXX' sequences are allowed
- // here (don't ask).
- var mods = this.readWord1();
- var tmp = content;
- if (mods) {
- var validFlags = /^[gmsiy]*$/;
- if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;
- if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");
- if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) {
- // Replace each astral symbol and every Unicode escape sequence that
- // possibly represents an astral symbol or a paired surrogate with a
- // single ASCII symbol to avoid throwing on regular expressions that
- // are only valid in combination with the `/u` flag.
- // Note: replacing with the ASCII symbol `x` might cause false
- // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
- // perfectly valid pattern that is equivalent to `[a-b]`, but it would
- // be replaced by `[x-b]` which throws an error.
- tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");
- }
- }
- // Detect invalid regular expressions.
- try {
- new RegExp(tmp);
- } catch (e) {
- if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message);
- this.raise(e);
- }
- // Get a regular expression object for this pattern-flag pair, or `null` in
- // case the current environment doesn't support the flags it uses.
- var value = undefined;
- try {
- value = new RegExp(content, mods);
- } catch (err) {
- value = null;
- }
- return this.finishToken(_tokentype.types.regexp, { pattern: content, flags: mods, value: value });
- };
- // Read an integer in the given radix. Return null if zero digits
- // were read, the integer value otherwise. When `len` is given, this
- // will return `null` unless the integer has exactly `len` digits.
- pp.readInt = function (radix, len) {
- var start = this.pos,
- total = 0;
- for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
- var code = this.input.charCodeAt(this.pos),
- val = undefined;
- if (code >= 97) val = code - 97 + 10; // a
- else if (code >= 65) val = code - 65 + 10; // A
- else if (code >= 48 && code <= 57) val = code - 48; // 0-9
- else val = Infinity;
- if (val >= radix) break;
- ++this.pos;
- total = total * radix + val;
- }
- if (this.pos === start || len != null && this.pos - start !== len) return null;
- return total;
- };
- pp.readRadixNumber = function (radix) {
- this.pos += 2; // 0x
- var val = this.readInt(radix);
- if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);
- if ((0, _identifier.isIdentifierStart)(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
- return this.finishToken(_tokentype.types.num, val);
- };
- // Read an integer, octal integer, or floating-point number.
- pp.readNumber = function (startsWithDot) {
- var start = this.pos,
- isFloat = false,
- octal = this.input.charCodeAt(this.pos) === 48;
- if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");
- if (this.input.charCodeAt(this.pos) === 46) {
- ++this.pos;
- this.readInt(10);
- isFloat = true;
- }
- var next = this.input.charCodeAt(this.pos);
- if (next === 69 || next === 101) {
- // 'eE'
- next = this.input.charCodeAt(++this.pos);
- if (next === 43 || next === 45) ++this.pos; // '+-'
- if (this.readInt(10) === null) this.raise(start, "Invalid number");
- isFloat = true;
- }
- if ((0, _identifier.isIdentifierStart)(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
- var str = this.input.slice(start, this.pos),
- val = undefined;
- if (isFloat) val = parseFloat(str);else if (!octal || str.length === 1) val = parseInt(str, 10);else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number");else val = parseInt(str, 8);
- return this.finishToken(_tokentype.types.num, val);
- };
- // Read a string value, interpreting backslash-escapes.
- pp.readCodePoint = function () {
- var ch = this.input.charCodeAt(this.pos),
- code = undefined;
- if (ch === 123) {
- if (this.options.ecmaVersion < 6) this.unexpected();
- ++this.pos;
- code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
- ++this.pos;
- if (code > 1114111) this.unexpected();
- } else {
- code = this.readHexChar(4);
- }
- return code;
- };
- function codePointToString(code) {
- // UTF-16 Decoding
- if (code <= 65535) return String.fromCharCode(code);
- return String.fromCharCode((code - 65536 >> 10) + 55296, (code - 65536 & 1023) + 56320);
- }
- pp.readString = function (quote) {
- var out = "",
- chunkStart = ++this.pos;
- for (;;) {
- if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant");
- var ch = this.input.charCodeAt(this.pos);
- if (ch === quote) break;
- if (ch === 92) {
- // '\'
- out += this.input.slice(chunkStart, this.pos);
- out += this.readEscapedChar();
- chunkStart = this.pos;
- } else {
- if ((0, _whitespace.isNewLine)(ch)) this.raise(this.start, "Unterminated string constant");
- ++this.pos;
- }
- }
- out += this.input.slice(chunkStart, this.pos++);
- return this.finishToken(_tokentype.types.string, out);
- };
- // Reads template string tokens.
- pp.readTmplToken = function () {
- var out = "",
- chunkStart = this.pos;
- for (;;) {
- if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");
- var ch = this.input.charCodeAt(this.pos);
- if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
- // '`', '${'
- if (this.pos === this.start && this.type === _tokentype.types.template) {
- if (ch === 36) {
- this.pos += 2;
- return this.finishToken(_tokentype.types.dollarBraceL);
- } else {
- ++this.pos;
- return this.finishToken(_tokentype.types.backQuote);
- }
- }
- out += this.input.slice(chunkStart, this.pos);
- return this.finishToken(_tokentype.types.template, out);
- }
- if (ch === 92) {
- // '\'
- out += this.input.slice(chunkStart, this.pos);
- out += this.readEscapedChar();
- chunkStart = this.pos;
- } else if ((0, _whitespace.isNewLine)(ch)) {
- out += this.input.slice(chunkStart, this.pos);
- ++this.pos;
- if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
- ++this.pos;
- out += "\n";
- } else {
- out += String.fromCharCode(ch);
- }
- if (this.options.locations) {
- ++this.curLine;
- this.lineStart = this.pos;
- }
- chunkStart = this.pos;
- } else {
- ++this.pos;
- }
- }
- };
- // Used to read escaped characters
- pp.readEscapedChar = function () {
- var ch = this.input.charCodeAt(++this.pos);
- var octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3));
- if (octal) octal = octal[0];
- while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);
- if (octal === "0") octal = null;
- ++this.pos;
- if (octal) {
- if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode");
- this.pos += octal.length - 1;
- return String.fromCharCode(parseInt(octal, 8));
- } else {
- switch (ch) {
- case 110:
- return "\n"; // 'n' -> '\n'
- case 114:
- return "\r"; // 'r' -> '\r'
- case 120:
- return String.fromCharCode(this.readHexChar(2)); // 'x'
- case 117:
- return codePointToString(this.readCodePoint()); // 'u'
- case 116:
- return "\t"; // 't' -> '\t'
- case 98:
- return "\b"; // 'b' -> '\b'
- case 118:
- return "\u000b"; // 'v' -> '\u000b'
- case 102:
- return "\f"; // 'f' -> '\f'
- case 48:
- return "\u0000"; // 0 -> '\0'
- case 13:
- if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n'
- case 10:
- // ' \n'
- if (this.options.locations) {
- this.lineStart = this.pos;++this.curLine;
- }
- return "";
- default:
- return String.fromCharCode(ch);
- }
- }
- };
- // Used to read character escape sequences ('\x', '\u', '\U').
- pp.readHexChar = function (len) {
- var n = this.readInt(16, len);
- if (n === null) this.raise(this.start, "Bad character escape sequence");
- return n;
- };
- // Used to signal to callers of `readWord1` whether the word
- // contained any escape sequences. This is needed because words with
- // escape sequences must not be interpreted as keywords.
- var containsEsc;
- // Read an identifier, and return it as a string. Sets `containsEsc`
- // to whether the word contained a '\u' escape.
- //
- // Incrementally adds only escaped chars, adding other chunks as-is
- // as a micro-optimization.
- pp.readWord1 = function () {
- containsEsc = false;
- var word = "",
- first = true,
- chunkStart = this.pos;
- var astral = this.options.ecmaVersion >= 6;
- while (this.pos < this.input.length) {
- var ch = this.fullCharCodeAtPos();
- if ((0, _identifier.isIdentifierChar)(ch, astral)) {
- this.pos += ch <= 65535 ? 1 : 2;
- } else if (ch === 92) {
- // "\"
- containsEsc = true;
- word += this.input.slice(chunkStart, this.pos);
- var escStart = this.pos;
- if (this.input.charCodeAt(++this.pos) != 117) // "u"
- this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX");
- ++this.pos;
- var esc = this.readCodePoint();
- if (!(first ? _identifier.isIdentifierStart : _identifier.isIdentifierChar)(esc, astral)) this.raise(escStart, "Invalid Unicode escape");
- word += codePointToString(esc);
- chunkStart = this.pos;
- } else {
- break;
- }
- first = false;
- }
- return word + this.input.slice(chunkStart, this.pos);
- };
- // Read an identifier or keyword token. Will check for reserved
- // words when necessary.
- pp.readWord = function () {
- var word = this.readWord1();
- var type = _tokentype.types.name;
- if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = _tokentype.keywords[word];
- return this.finishToken(type, word);
- };
- },{"./identifier":4,"./location":6,"./state":12,"./tokentype":16,"./whitespace":18}],16:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- // ## Token types
- // The assignment of fine-grained, information-carrying type objects
- // allows the tokenizer to store the information it has about a
- // token in a way that is very cheap for the parser to look up.
- // All token type variables start with an underscore, to make them
- // easy to recognize.
- // The `beforeExpr` property is used to disambiguate between regular
- // expressions and divisions. It is set on all token types that can
- // be followed by an expression (thus, a slash after them would be a
- // regular expression).
- //
- // `isLoop` marks a keyword as starting a loop, which is important
- // to know when parsing a label, in order to allow or disallow
- // continue jumps to that label.
- var TokenType = function TokenType(label) {
- var conf = arguments[1] === undefined ? {} : arguments[1];
- _classCallCheck(this, TokenType);
- this.label = label;
- this.keyword = conf.keyword;
- this.beforeExpr = !!conf.beforeExpr;
- this.startsExpr = !!conf.startsExpr;
- this.rightAssociative = !!conf.rightAssociative;
- this.isLoop = !!conf.isLoop;
- this.isAssign = !!conf.isAssign;
- this.prefix = !!conf.prefix;
- this.postfix = !!conf.postfix;
- this.binop = conf.binop || null;
- this.updateContext = null;
- };
- exports.TokenType = TokenType;
- function binop(name, prec) {
- return new TokenType(name, { beforeExpr: true, binop: prec });
- }
- var beforeExpr = { beforeExpr: true },
- startsExpr = { startsExpr: true };
- var types = {
- num: new TokenType("num", startsExpr),
- regexp: new TokenType("regexp", startsExpr),
- string: new TokenType("string", startsExpr),
- name: new TokenType("name", startsExpr),
- eof: new TokenType("eof"),
- // Punctuation token types.
- bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),
- bracketR: new TokenType("]"),
- braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),
- braceR: new TokenType("}"),
- parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),
- parenR: new TokenType(")"),
- comma: new TokenType(",", beforeExpr),
- semi: new TokenType(";", beforeExpr),
- colon: new TokenType(":", beforeExpr),
- doubleColon: new TokenType("::", beforeExpr),
- dot: new TokenType("."),
- question: new TokenType("?", beforeExpr),
- arrow: new TokenType("=>", beforeExpr),
- template: new TokenType("template"),
- ellipsis: new TokenType("...", beforeExpr),
- backQuote: new TokenType("`", startsExpr),
- dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),
- at: new TokenType("@"),
- // Operators. These carry several kinds of properties to help the
- // parser use them properly (the presence of these properties is
- // what categorizes them as operators).
- //
- // `binop`, when present, specifies that this operator is a binary
- // operator, and will refer to its precedence.
- //
- // `prefix` and `postfix` mark the operator as a prefix or postfix
- // unary operator.
- //
- // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
- // binary operators with a very low precedence, that should result
- // in AssignmentExpression nodes.
- eq: new TokenType("=", { beforeExpr: true, isAssign: true }),
- assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),
- incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),
- prefix: new TokenType("prefix", { beforeExpr: true, prefix: true, startsExpr: true }),
- logicalOR: binop("||", 1),
- logicalAND: binop("&&", 2),
- bitwiseOR: binop("|", 3),
- bitwiseXOR: binop("^", 4),
- bitwiseAND: binop("&", 5),
- equality: binop("==/!=", 6),
- relational: binop("</>", 7),
- bitShift: binop("<</>>", 8),
- plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),
- modulo: binop("%", 10),
- star: binop("*", 10),
- slash: binop("/", 10),
- exponent: new TokenType("**", { beforeExpr: true, binop: 11, rightAssociative: true })
- };
- exports.types = types;
- // Map keyword names to token types.
- var keywords = {};
- exports.keywords = keywords;
- // Succinct definitions of keyword token types
- function kw(name) {
- var options = arguments[1] === undefined ? {} : arguments[1];
- options.keyword = name;
- keywords[name] = types["_" + name] = new TokenType(name, options);
- }
- kw("break");
- kw("case", beforeExpr);
- kw("catch");
- kw("continue");
- kw("debugger");
- kw("default");
- kw("do", { isLoop: true });
- kw("else", beforeExpr);
- kw("finally");
- kw("for", { isLoop: true });
- kw("function", startsExpr);
- kw("if");
- kw("return", beforeExpr);
- kw("switch");
- kw("throw", beforeExpr);
- kw("try");
- kw("var");
- kw("let");
- kw("const");
- kw("while", { isLoop: true });
- kw("with");
- kw("new", { beforeExpr: true, startsExpr: true });
- kw("this", startsExpr);
- kw("super", startsExpr);
- kw("class");
- kw("extends", beforeExpr);
- kw("export");
- kw("import");
- kw("yield", { beforeExpr: true, startsExpr: true });
- kw("null", startsExpr);
- kw("true", startsExpr);
- kw("false", startsExpr);
- kw("in", { beforeExpr: true, binop: 7 });
- kw("instanceof", { beforeExpr: true, binop: 7 });
- kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true });
- kw("void", { beforeExpr: true, prefix: true, startsExpr: true });
- kw("delete", { beforeExpr: true, prefix: true, startsExpr: true });
- },{}],17:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.isArray = isArray;
- // Checks if an object has a property.
- exports.has = has;
- function isArray(obj) {
- return Object.prototype.toString.call(obj) === "[object Array]";
- }
- function has(obj, propName) {
- return Object.prototype.hasOwnProperty.call(obj, propName);
- }
- },{}],18:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.isNewLine = isNewLine;
- // Matches a whole line break (where CRLF is considered a single
- // line break). Used to count lines.
- var lineBreak = /\r\n?|\n|\u2028|\u2029/;
- exports.lineBreak = lineBreak;
- var lineBreakG = new RegExp(lineBreak.source, "g");
- exports.lineBreakG = lineBreakG;
- function isNewLine(code) {
- return code === 10 || code === 13 || code === 8232 || code == 8233;
- }
- var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
- exports.nonASCIIwhitespace = nonASCIIwhitespace;
- },{}],19:[function(require,module,exports){
- (function (global){
- "use strict";
- require("./node");
- var transform = module.exports = require("../transformation");
- transform.options = require("../transformation/file/options");
- transform.version = require("../../../package").version;
- transform.transform = transform;
- transform.run = function (code) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- opts.sourceMaps = "inline";
- return new Function(transform(code, opts).code)();
- };
- transform.load = function (url, callback, _x2, hold) {
- var opts = arguments[2] === undefined ? {} : arguments[2];
- opts.filename = opts.filename || url;
- var xhr = global.ActiveXObject ? new global.ActiveXObject("Microsoft.XMLHTTP") : new global.XMLHttpRequest();
- xhr.open("GET", url, true);
- if ("overrideMimeType" in xhr) xhr.overrideMimeType("text/plain");
- xhr.onreadystatechange = function () {
- if (xhr.readyState !== 4) return;
- var status = xhr.status;
- if (status === 0 || status === 200) {
- var param = [xhr.responseText, opts];
- if (!hold) transform.run.apply(transform, param);
- if (callback) callback(param);
- } else {
- throw new Error("Could not load " + url);
- }
- };
- xhr.send(null);
- };
- var runScripts = function runScripts() {
- var scripts = [];
- var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"];
- var index = 0;
- var exec = function exec() {
- var param = scripts[index];
- if (param instanceof Array) {
- transform.run.apply(transform, param);
- index++;
- exec();
- }
- };
- var run = function run(script, i) {
- var opts = {};
- if (script.src) {
- transform.load(script.src, function (param) {
- scripts[i] = param;
- exec();
- }, opts, true);
- } else {
- opts.filename = "embedded";
- scripts[i] = [script.innerHTML, opts];
- }
- };
- var _scripts = global.document.getElementsByTagName("script");
- for (var i = 0; i < _scripts.length; ++i) {
- var _script = _scripts[i];
- if (types.indexOf(_script.type) >= 0) scripts.push(_script);
- }
- for (i in scripts) {
- run(scripts[i], i);
- }
- exec();
- };
- if (global.addEventListener) {
- global.addEventListener("DOMContentLoaded", runScripts, false);
- } else if (global.attachEvent) {
- global.attachEvent("onload", runScripts);
- }
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"../../../package":497,"../transformation":71,"../transformation/file/options":55,"./node":20}],20:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.register = register;
- exports.polyfill = polyfill;
- exports.transformFile = transformFile;
- exports.transformFileSync = transformFileSync;
- exports.parse = parse;
- function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; }
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangIsFunction = require("lodash/lang/isFunction");
- var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
- var _transformation = require("../transformation");
- var _transformation2 = _interopRequireDefault(_transformation);
- var _acorn = require("../../acorn");
- var acorn = _interopRequireWildcard(_acorn);
- var _util = require("../util");
- var util = _interopRequireWildcard(_util);
- var _fs = require("fs");
- var _fs2 = _interopRequireDefault(_fs);
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- exports.util = util;
- exports.acorn = acorn;
- exports.transform = _transformation2["default"];
- exports.pipeline = _transformation.pipeline;
- exports.canCompile = _util.canCompile;
- var _transformationFileOptions = require("../transformation/file/options");
- exports.options = _interopRequire(_transformationFileOptions);
- var _transformationTransformer = require("../transformation/transformer");
- exports.Transformer = _interopRequire(_transformationTransformer);
- var _transformationTransformerPipeline = require("../transformation/transformer-pipeline");
- exports.TransformerPipeline = _interopRequire(_transformationTransformerPipeline);
- var _traversal = require("../traversal");
- exports.traverse = _interopRequire(_traversal);
- var _toolsBuildExternalHelpers = require("../tools/build-external-helpers");
- exports.buildExternalHelpers = _interopRequire(_toolsBuildExternalHelpers);
- var _package = require("../../../package");
- exports.version = _package.version;
- exports.types = t;
- function register(opts) {
- var callback = require("./register/node-polyfill");
- if (opts != null) callback(opts);
- return callback;
- }
- function polyfill() {
- require("../polyfill");
- }
- function transformFile(filename, opts, callback) {
- if ((0, _lodashLangIsFunction2["default"])(opts)) {
- callback = opts;
- opts = {};
- }
- opts.filename = filename;
- _fs2["default"].readFile(filename, function (err, code) {
- if (err) return callback(err);
- var result;
- try {
- result = (0, _transformation2["default"])(code, opts);
- } catch (err) {
- return callback(err);
- }
- callback(null, result);
- });
- }
- function transformFileSync(filename) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- opts.filename = filename;
- return (0, _transformation2["default"])(_fs2["default"].readFileSync(filename, "utf8"), opts);
- }
- function parse(code) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- opts.allowHashBang = true;
- opts.sourceType = "module";
- opts.ecmaVersion = Infinity;
- opts.plugins = {
- flow: true,
- jsx: true
- };
- opts.features = {};
- for (var key in _transformation2["default"].pipeline.transformers) {
- opts.features[key] = true;
- }
- return acorn.parse(code, opts);
- }
- },{"../../../package":497,"../../acorn":1,"../polyfill":49,"../tools/build-external-helpers":50,"../transformation":71,"../transformation/file/options":55,"../transformation/transformer":85,"../transformation/transformer-pipeline":84,"../traversal":157,"../types":169,"../util":173,"./register/node-polyfill":22,"fs":189,"lodash/lang/isFunction":408}],21:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- require("../../polyfill");
- // required to safely use babel/register within a browserify codebase
- exports["default"] = function () {};
- ;
- module.exports = exports["default"];
- },{"../../polyfill":49}],22:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; }
- require("../../polyfill");
- var _node = require("./node");
- exports["default"] = _interopRequire(_node);
- module.exports = exports["default"];
- },{"../../polyfill":49,"./node":21}],23:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _repeating = require("repeating");
- var _repeating2 = _interopRequireDefault(_repeating);
- var _trimRight = require("trim-right");
- var _trimRight2 = _interopRequireDefault(_trimRight);
- var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
- var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _lodashLangIsNumber = require("lodash/lang/isNumber");
- var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
- var Buffer = (function () {
- function Buffer(position, format) {
- _classCallCheck(this, Buffer);
- this.position = position;
- this._indent = format.indent.base;
- this.format = format;
- this.buf = "";
- }
- Buffer.prototype.get = function get() {
- return (0, _trimRight2["default"])(this.buf);
- };
- Buffer.prototype.getIndent = function getIndent() {
- if (this.format.compact || this.format.concise) {
- return "";
- } else {
- return (0, _repeating2["default"])(this.format.indent.style, this._indent);
- }
- };
- Buffer.prototype.indentSize = function indentSize() {
- return this.getIndent().length;
- };
- Buffer.prototype.indent = function indent() {
- this._indent++;
- };
- Buffer.prototype.dedent = function dedent() {
- this._indent--;
- };
- Buffer.prototype.semicolon = function semicolon() {
- this.push(";");
- };
- Buffer.prototype.ensureSemicolon = function ensureSemicolon() {
- if (!this.isLast(";")) this.semicolon();
- };
- Buffer.prototype.rightBrace = function rightBrace() {
- this.newline(true);
- this.push("}");
- };
- Buffer.prototype.keyword = function keyword(name) {
- this.push(name);
- this.space();
- };
- Buffer.prototype.space = function space() {
- if (this.format.compact) return;
- if (this.buf && !this.isLast(" ") && !this.isLast("\n")) {
- this.push(" ");
- }
- };
- Buffer.prototype.removeLast = function removeLast(cha) {
- if (this.format.compact) return;
- if (!this.isLast(cha)) return;
- this.buf = this.buf.substr(0, this.buf.length - 1);
- this.position.unshift(cha);
- };
- Buffer.prototype.newline = function newline(i, removeLast) {
- if (this.format.compact || this.format.retainLines) return;
- if (this.format.concise) {
- this.space();
- return;
- }
- removeLast = removeLast || false;
- if ((0, _lodashLangIsNumber2["default"])(i)) {
- i = Math.min(2, i);
- if (this.endsWith("{\n") || this.endsWith(":\n")) i--;
- if (i <= 0) return;
- while (i > 0) {
- this._newline(removeLast);
- i--;
- }
- return;
- }
- if ((0, _lodashLangIsBoolean2["default"])(i)) {
- removeLast = i;
- }
- this._newline(removeLast);
- };
- Buffer.prototype._newline = function _newline(removeLast) {
- // never allow more than two lines
- if (this.endsWith("\n\n")) return;
- // remove the last newline
- if (removeLast && this.isLast("\n")) this.removeLast("\n");
- this.removeLast(" ");
- this._removeSpacesAfterLastNewline();
- this._push("\n");
- };
- /**
- * If buffer ends with a newline and some spaces after it, trim those spaces.
- */
- Buffer.prototype._removeSpacesAfterLastNewline = function _removeSpacesAfterLastNewline() {
- var lastNewlineIndex = this.buf.lastIndexOf("\n");
- if (lastNewlineIndex === -1) {
- return;
- }
- var index = this.buf.length - 1;
- while (index > lastNewlineIndex) {
- if (this.buf[index] !== " ") {
- break;
- }
- index--;
- }
- if (index === lastNewlineIndex) {
- this.buf = this.buf.substring(0, index + 1);
- }
- };
- Buffer.prototype.push = function push(str, noIndent) {
- if (!this.format.compact && this._indent && !noIndent && str !== "\n") {
- // we have an indent level and we aren't pushing a newline
- var indent = this.getIndent();
- // replace all newlines with newlines with the indentation
- str = str.replace(/\n/g, "\n" + indent);
- // we've got a newline before us so prepend on the indentation
- if (this.isLast("\n")) this._push(indent);
- }
- this._push(str);
- };
- Buffer.prototype._push = function _push(str) {
- this.position.push(str);
- this.buf += str;
- };
- Buffer.prototype.endsWith = function endsWith(str) {
- return this.buf.slice(-str.length) === str;
- };
- Buffer.prototype.isLast = function isLast(cha) {
- if (this.format.compact) return false;
- var buf = this.buf;
- var last = buf[buf.length - 1];
- if (Array.isArray(cha)) {
- return (0, _lodashCollectionIncludes2["default"])(cha, last);
- } else {
- return cha === last;
- }
- };
- return Buffer;
- })();
- exports["default"] = Buffer;
- module.exports = exports["default"];
- },{"lodash/collection/includes":332,"lodash/lang/isBoolean":406,"lodash/lang/isNumber":410,"repeating":479,"trim-right":496}],24:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.File = File;
- exports.Program = Program;
- exports.BlockStatement = BlockStatement;
- function File(node, print) {
- print(node.program);
- }
- function Program(node, print) {
- print.sequence(node.body);
- }
- function BlockStatement(node, print) {
- if (node.body.length === 0) {
- this.push("{}");
- } else {
- this.push("{");
- this.newline();
- print.sequence(node.body, { indent: true });
- if (!this.format.retainLines) this.removeLast("\n");
- this.rightBrace();
- }
- }
- },{}],25:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ClassDeclaration = ClassDeclaration;
- exports.ClassBody = ClassBody;
- exports.ClassProperty = ClassProperty;
- exports.MethodDefinition = MethodDefinition;
- function ClassDeclaration(node, print) {
- print.list(node.decorators);
- this.push("class");
- if (node.id) {
- this.space();
- print(node.id);
- }
- print(node.typeParameters);
- if (node.superClass) {
- this.push(" extends ");
- print(node.superClass);
- print(node.superTypeParameters);
- }
- if (node["implements"]) {
- this.push(" implements ");
- print.join(node["implements"], { separator: ", " });
- }
- this.space();
- print(node.body);
- }
- exports.ClassExpression = ClassDeclaration;
- function ClassBody(node, print) {
- if (node.body.length === 0) {
- this.push("{}");
- } else {
- this.push("{");
- this.newline();
- this.indent();
- print.sequence(node.body);
- this.dedent();
- this.rightBrace();
- }
- }
- function ClassProperty(node, print) {
- print.list(node.decorators);
- if (node["static"]) this.push("static ");
- print(node.key);
- print(node.typeAnnotation);
- if (node.value) {
- this.space();
- this.push("=");
- this.space();
- print(node.value);
- }
- this.semicolon();
- }
- function MethodDefinition(node, print) {
- print.list(node.decorators);
- if (node["static"]) {
- this.push("static ");
- }
- this._method(node, print);
- }
- },{}],26:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ComprehensionBlock = ComprehensionBlock;
- exports.ComprehensionExpression = ComprehensionExpression;
- function ComprehensionBlock(node, print) {
- this.keyword("for");
- this.push("(");
- print(node.left);
- this.push(" of ");
- print(node.right);
- this.push(")");
- }
- function ComprehensionExpression(node, print) {
- this.push(node.generator ? "(" : "[");
- print.join(node.blocks, { separator: " " });
- this.space();
- if (node.filter) {
- this.keyword("if");
- this.push("(");
- print(node.filter);
- this.push(")");
- this.space();
- }
- print(node.body);
- this.push(node.generator ? ")" : "]");
- }
- },{}],27:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.UnaryExpression = UnaryExpression;
- exports.DoExpression = DoExpression;
- exports.UpdateExpression = UpdateExpression;
- exports.ConditionalExpression = ConditionalExpression;
- exports.NewExpression = NewExpression;
- exports.SequenceExpression = SequenceExpression;
- exports.ThisExpression = ThisExpression;
- exports.Super = Super;
- exports.Decorator = Decorator;
- exports.CallExpression = CallExpression;
- exports.EmptyStatement = EmptyStatement;
- exports.ExpressionStatement = ExpressionStatement;
- exports.AssignmentExpression = AssignmentExpression;
- exports.BindExpression = BindExpression;
- exports.MemberExpression = MemberExpression;
- exports.MetaProperty = MetaProperty;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _isInteger = require("is-integer");
- var _isInteger2 = _interopRequireDefault(_isInteger);
- var _lodashLangIsNumber = require("lodash/lang/isNumber");
- var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function UnaryExpression(node, print) {
- var hasSpace = /[a-z]$/.test(node.operator);
- var arg = node.argument;
- if (t.isUpdateExpression(arg) || t.isUnaryExpression(arg)) {
- hasSpace = true;
- }
- if (t.isUnaryExpression(arg) && arg.operator === "!") {
- hasSpace = false;
- }
- this.push(node.operator);
- if (hasSpace) this.push(" ");
- print(node.argument);
- }
- function DoExpression(node, print) {
- this.push("do");
- this.space();
- print(node.body);
- }
- function UpdateExpression(node, print) {
- if (node.prefix) {
- this.push(node.operator);
- print(node.argument);
- } else {
- print(node.argument);
- this.push(node.operator);
- }
- }
- function ConditionalExpression(node, print) {
- print(node.test);
- this.space();
- this.push("?");
- this.space();
- print(node.consequent);
- this.space();
- this.push(":");
- this.space();
- print(node.alternate);
- }
- function NewExpression(node, print) {
- this.push("new ");
- print(node.callee);
- this.push("(");
- print.list(node.arguments);
- this.push(")");
- }
- function SequenceExpression(node, print) {
- print.list(node.expressions);
- }
- function ThisExpression() {
- this.push("this");
- }
- function Super() {
- this.push("super");
- }
- function Decorator(node, print) {
- this.push("@");
- print(node.expression);
- }
- function CallExpression(node, print) {
- print(node.callee);
- this.push("(");
- var separator = ",";
- if (node._prettyCall) {
- separator += "\n";
- this.newline();
- this.indent();
- } else {
- separator += " ";
- }
- print.list(node.arguments, { separator: separator });
- if (node._prettyCall) {
- this.newline();
- this.dedent();
- }
- this.push(")");
- }
- var buildYieldAwait = function buildYieldAwait(keyword) {
- return function (node, print) {
- this.push(keyword);
- if (node.delegate || node.all) {
- this.push("*");
- }
- if (node.argument) {
- this.space();
- print(node.argument);
- }
- };
- };
- var YieldExpression = buildYieldAwait("yield");
- exports.YieldExpression = YieldExpression;
- var AwaitExpression = buildYieldAwait("await");
- exports.AwaitExpression = AwaitExpression;
- function EmptyStatement() {
- this.semicolon();
- }
- function ExpressionStatement(node, print) {
- print(node.expression);
- this.semicolon();
- }
- function AssignmentExpression(node, print) {
- // todo: add cases where the spaces can be dropped when in compact mode
- print(node.left);
- this.push(" ");
- this.push(node.operator);
- this.push(" ");
- print(node.right);
- }
- function BindExpression(node, print) {
- print(node.object);
- this.push("::");
- print(node.callee);
- }
- exports.BinaryExpression = AssignmentExpression;
- exports.LogicalExpression = AssignmentExpression;
- exports.AssignmentPattern = AssignmentExpression;
- var SCIENTIFIC_NOTATION = /e/i;
- function MemberExpression(node, print) {
- var obj = node.object;
- print(obj);
- if (!node.computed && t.isMemberExpression(node.property)) {
- throw new TypeError("Got a MemberExpression for MemberExpression property");
- }
- var computed = node.computed;
- if (t.isLiteral(node.property) && (0, _lodashLangIsNumber2["default"])(node.property.value)) {
- computed = true;
- }
- if (computed) {
- this.push("[");
- print(node.property);
- this.push("]");
- } else {
- // 5..toFixed(2);
- if (t.isLiteral(obj) && (0, _isInteger2["default"])(obj.value) && !SCIENTIFIC_NOTATION.test(obj.value.toString())) {
- this.push(".");
- }
- this.push(".");
- print(node.property);
- }
- }
- function MetaProperty(node, print) {
- print(node.meta);
- this.push(".");
- print(node.property);
- }
- },{"../../types":169,"is-integer":317,"lodash/lang/isNumber":410}],28:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.AnyTypeAnnotation = AnyTypeAnnotation;
- exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
- exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
- exports.DeclareClass = DeclareClass;
- exports.DeclareFunction = DeclareFunction;
- exports.DeclareModule = DeclareModule;
- exports.DeclareVariable = DeclareVariable;
- exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
- exports.FunctionTypeParam = FunctionTypeParam;
- exports.InterfaceExtends = InterfaceExtends;
- exports._interfaceish = _interfaceish;
- exports.InterfaceDeclaration = InterfaceDeclaration;
- exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
- exports.NullableTypeAnnotation = NullableTypeAnnotation;
- exports.NumberTypeAnnotation = NumberTypeAnnotation;
- exports.StringLiteralTypeAnnotation = StringLiteralTypeAnnotation;
- exports.StringTypeAnnotation = StringTypeAnnotation;
- exports.TupleTypeAnnotation = TupleTypeAnnotation;
- exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
- exports.TypeAlias = TypeAlias;
- exports.TypeAnnotation = TypeAnnotation;
- exports.TypeParameterInstantiation = TypeParameterInstantiation;
- exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
- exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
- exports.ObjectTypeIndexer = ObjectTypeIndexer;
- exports.ObjectTypeProperty = ObjectTypeProperty;
- exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
- exports.UnionTypeAnnotation = UnionTypeAnnotation;
- exports.TypeCastExpression = TypeCastExpression;
- exports.VoidTypeAnnotation = VoidTypeAnnotation;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function AnyTypeAnnotation() {
- this.push("any");
- }
- function ArrayTypeAnnotation(node, print) {
- print(node.elementType);
- this.push("[");
- this.push("]");
- }
- function BooleanTypeAnnotation(node) {
- this.push("bool");
- }
- function DeclareClass(node, print) {
- this.push("declare class ");
- this._interfaceish(node, print);
- }
- function DeclareFunction(node, print) {
- this.push("declare function ");
- print(node.id);
- print(node.id.typeAnnotation.typeAnnotation);
- this.semicolon();
- }
- function DeclareModule(node, print) {
- this.push("declare module ");
- print(node.id);
- this.space();
- print(node.body);
- }
- function DeclareVariable(node, print) {
- this.push("declare var ");
- print(node.id);
- print(node.id.typeAnnotation);
- this.semicolon();
- }
- function FunctionTypeAnnotation(node, print, parent) {
- print(node.typeParameters);
- this.push("(");
- print.list(node.params);
- if (node.rest) {
- if (node.params.length) {
- this.push(",");
- this.space();
- }
- this.push("...");
- print(node.rest);
- }
- this.push(")");
- // this node type is overloaded, not sure why but it makes it EXTREMELY annoying
- if (parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction") {
- this.push(":");
- } else {
- this.space();
- this.push("=>");
- }
- this.space();
- print(node.returnType);
- }
- function FunctionTypeParam(node, print) {
- print(node.name);
- if (node.optional) this.push("?");
- this.push(":");
- this.space();
- print(node.typeAnnotation);
- }
- function InterfaceExtends(node, print) {
- print(node.id);
- print(node.typeParameters);
- }
- exports.ClassImplements = InterfaceExtends;
- exports.GenericTypeAnnotation = InterfaceExtends;
- function _interfaceish(node, print) {
- print(node.id);
- print(node.typeParameters);
- if (node["extends"].length) {
- this.push(" extends ");
- print.join(node["extends"], { separator: ", " });
- }
- this.space();
- print(node.body);
- }
- function InterfaceDeclaration(node, print) {
- this.push("interface ");
- this._interfaceish(node, print);
- }
- function IntersectionTypeAnnotation(node, print) {
- print.join(node.types, { separator: " & " });
- }
- function NullableTypeAnnotation(node, print) {
- this.push("?");
- print(node.typeAnnotation);
- }
- function NumberTypeAnnotation() {
- this.push("number");
- }
- function StringLiteralTypeAnnotation(node) {
- this._stringLiteral(node.value);
- }
- function StringTypeAnnotation() {
- this.push("string");
- }
- function TupleTypeAnnotation(node, print) {
- this.push("[");
- print.join(node.types, { separator: ", " });
- this.push("]");
- }
- function TypeofTypeAnnotation(node, print) {
- this.push("typeof ");
- print(node.argument);
- }
- function TypeAlias(node, print) {
- this.push("type ");
- print(node.id);
- print(node.typeParameters);
- this.space();
- this.push("=");
- this.space();
- print(node.right);
- this.semicolon();
- }
- function TypeAnnotation(node, print) {
- this.push(":");
- this.space();
- if (node.optional) this.push("?");
- print(node.typeAnnotation);
- }
- function TypeParameterInstantiation(node, print) {
- this.push("<");
- print.join(node.params, { separator: ", " });
- this.push(">");
- }
- exports.TypeParameterDeclaration = TypeParameterInstantiation;
- function ObjectTypeAnnotation(node, print) {
- var _this = this;
- this.push("{");
- var props = node.properties.concat(node.callProperties, node.indexers);
- if (props.length) {
- this.space();
- print.list(props, {
- separator: false,
- indent: true,
- iterator: function iterator() {
- if (props.length !== 1) {
- _this.semicolon();
- _this.space();
- }
- }
- });
- this.space();
- }
- this.push("}");
- }
- function ObjectTypeCallProperty(node, print) {
- if (node["static"]) this.push("static ");
- print(node.value);
- }
- function ObjectTypeIndexer(node, print) {
- if (node["static"]) this.push("static ");
- this.push("[");
- print(node.id);
- this.push(":");
- this.space();
- print(node.key);
- this.push("]");
- this.push(":");
- this.space();
- print(node.value);
- }
- function ObjectTypeProperty(node, print) {
- if (node["static"]) this.push("static ");
- print(node.key);
- if (node.optional) this.push("?");
- if (!t.isFunctionTypeAnnotation(node.value)) {
- this.push(":");
- this.space();
- }
- print(node.value);
- }
- function QualifiedTypeIdentifier(node, print) {
- print(node.qualification);
- this.push(".");
- print(node.id);
- }
- function UnionTypeAnnotation(node, print) {
- print.join(node.types, { separator: " | " });
- }
- function TypeCastExpression(node, print) {
- this.push("(");
- print(node.expression);
- print(node.typeAnnotation);
- this.push(")");
- }
- function VoidTypeAnnotation(node) {
- this.push("void");
- }
- },{"../../types":169}],29:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.JSXAttribute = JSXAttribute;
- exports.JSXIdentifier = JSXIdentifier;
- exports.JSXNamespacedName = JSXNamespacedName;
- exports.JSXMemberExpression = JSXMemberExpression;
- exports.JSXSpreadAttribute = JSXSpreadAttribute;
- exports.JSXExpressionContainer = JSXExpressionContainer;
- exports.JSXElement = JSXElement;
- exports.JSXOpeningElement = JSXOpeningElement;
- exports.JSXClosingElement = JSXClosingElement;
- exports.JSXEmptyExpression = JSXEmptyExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function JSXAttribute(node, print) {
- print(node.name);
- if (node.value) {
- this.push("=");
- print(node.value);
- }
- }
- function JSXIdentifier(node) {
- this.push(node.name);
- }
- function JSXNamespacedName(node, print) {
- print(node.namespace);
- this.push(":");
- print(node.name);
- }
- function JSXMemberExpression(node, print) {
- print(node.object);
- this.push(".");
- print(node.property);
- }
- function JSXSpreadAttribute(node, print) {
- this.push("{...");
- print(node.argument);
- this.push("}");
- }
- function JSXExpressionContainer(node, print) {
- this.push("{");
- print(node.expression);
- this.push("}");
- }
- function JSXElement(node, print) {
- var open = node.openingElement;
- print(open);
- if (open.selfClosing) return;
- this.indent();
- var _arr = node.children;
- for (var _i = 0; _i < _arr.length; _i++) {
- var child = _arr[_i];
- if (t.isLiteral(child)) {
- this.push(child.value, true);
- } else {
- print(child);
- }
- }
- this.dedent();
- print(node.closingElement);
- }
- function JSXOpeningElement(node, print) {
- this.push("<");
- print(node.name);
- if (node.attributes.length > 0) {
- this.push(" ");
- print.join(node.attributes, { separator: " " });
- }
- this.push(node.selfClosing ? " />" : ">");
- }
- function JSXClosingElement(node, print) {
- this.push("</");
- print(node.name);
- this.push(">");
- }
- function JSXEmptyExpression() {}
- },{"../../types":169,"lodash/collection/each":330}],30:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports._params = _params;
- exports._method = _method;
- exports.FunctionExpression = FunctionExpression;
- exports.ArrowFunctionExpression = ArrowFunctionExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function _params(node, print) {
- var _this = this;
- print(node.typeParameters);
- this.push("(");
- print.list(node.params, {
- iterator: function iterator(node) {
- if (node.optional) _this.push("?");
- print(node.typeAnnotation);
- }
- });
- this.push(")");
- if (node.returnType) {
- print(node.returnType);
- }
- }
- function _method(node, print) {
- var value = node.value;
- var kind = node.kind;
- var key = node.key;
- if (kind === "method" || kind === "init") {
- if (value.generator) {
- this.push("*");
- }
- }
- if (kind === "get" || kind === "set") {
- this.push(kind + " ");
- }
- if (value.async) this.push("async ");
- if (node.computed) {
- this.push("[");
- print(key);
- this.push("]");
- } else {
- print(key);
- }
- this._params(value, print);
- this.push(" ");
- print(value.body);
- }
- function FunctionExpression(node, print) {
- if (node.async) this.push("async ");
- this.push("function");
- if (node.generator) this.push("*");
- if (node.id) {
- this.push(" ");
- print(node.id);
- } else {
- this.space();
- }
- this._params(node, print);
- this.space();
- print(node.body);
- }
- exports.FunctionDeclaration = FunctionExpression;
- function ArrowFunctionExpression(node, print) {
- if (node.async) this.push("async ");
- if (node.params.length === 1 && t.isIdentifier(node.params[0])) {
- print(node.params[0]);
- } else {
- this._params(node, print);
- }
- this.push(" => ");
- var bodyNeedsParens = t.isObjectExpression(node.body);
- if (bodyNeedsParens) {
- this.push("(");
- }
- print(node.body);
- if (bodyNeedsParens) {
- this.push(")");
- }
- }
- },{"../../types":169}],31:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ImportSpecifier = ImportSpecifier;
- exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
- exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
- exports.ExportSpecifier = ExportSpecifier;
- exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
- exports.ExportAllDeclaration = ExportAllDeclaration;
- exports.ExportNamedDeclaration = ExportNamedDeclaration;
- exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
- exports.ImportDeclaration = ImportDeclaration;
- exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function ImportSpecifier(node, print) {
- print(node.imported);
- if (node.local && node.local.name !== node.imported.name) {
- this.push(" as ");
- print(node.local);
- }
- }
- function ImportDefaultSpecifier(node, print) {
- print(node.local);
- }
- function ExportDefaultSpecifier(node, print) {
- print(node.exported);
- }
- function ExportSpecifier(node, print) {
- print(node.local);
- if (node.exported && node.local.name !== node.exported.name) {
- this.push(" as ");
- print(node.exported);
- }
- }
- function ExportNamespaceSpecifier(node, print) {
- this.push("* as ");
- print(node.exported);
- }
- function ExportAllDeclaration(node, print) {
- this.push("export *");
- if (node.exported) {
- this.push(" as ");
- print(node.exported);
- }
- this.push(" from ");
- print(node.source);
- this.semicolon();
- }
- function ExportNamedDeclaration(node, print) {
- this.push("export ");
- ExportDeclaration.call(this, node, print);
- }
- function ExportDefaultDeclaration(node, print) {
- this.push("export default ");
- ExportDeclaration.call(this, node, print);
- }
- function ExportDeclaration(node, print) {
- var specifiers = node.specifiers;
- if (node.declaration) {
- var declar = node.declaration;
- print(declar);
- if (t.isStatement(declar) || t.isFunction(declar) || t.isClass(declar)) return;
- } else {
- var first = specifiers[0];
- var hasSpecial = false;
- if (t.isExportDefaultSpecifier(first) || t.isExportNamespaceSpecifier(first)) {
- hasSpecial = true;
- print(specifiers.shift());
- if (specifiers.length) {
- this.push(", ");
- }
- }
- if (specifiers.length || !specifiers.length && !hasSpecial) {
- this.push("{");
- if (specifiers.length) {
- this.space();
- print.join(specifiers, { separator: ", " });
- this.space();
- }
- this.push("}");
- }
- if (node.source) {
- this.push(" from ");
- print(node.source);
- }
- }
- this.ensureSemicolon();
- }
- function ImportDeclaration(node, print) {
- this.push("import ");
- if (node.isType) {
- this.push("type ");
- }
- var specfiers = node.specifiers;
- if (specfiers && specfiers.length) {
- var first = node.specifiers[0];
- if (t.isImportDefaultSpecifier(first) || t.isImportNamespaceSpecifier(first)) {
- print(node.specifiers.shift());
- if (node.specifiers.length) {
- this.push(", ");
- }
- }
- if (node.specifiers.length) {
- this.push("{");
- this.space();
- print.join(node.specifiers, { separator: ", " });
- this.space();
- this.push("}");
- }
- this.push(" from ");
- }
- print(node.source);
- this.semicolon();
- }
- function ImportNamespaceSpecifier(node, print) {
- this.push("* as ");
- print(node.local);
- }
- },{"../../types":169,"lodash/collection/each":330}],32:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.WithStatement = WithStatement;
- exports.IfStatement = IfStatement;
- exports.ForStatement = ForStatement;
- exports.WhileStatement = WhileStatement;
- exports.DoWhileStatement = DoWhileStatement;
- exports.LabeledStatement = LabeledStatement;
- exports.TryStatement = TryStatement;
- exports.CatchClause = CatchClause;
- exports.ThrowStatement = ThrowStatement;
- exports.SwitchStatement = SwitchStatement;
- exports.SwitchCase = SwitchCase;
- exports.DebuggerStatement = DebuggerStatement;
- exports.VariableDeclaration = VariableDeclaration;
- exports.VariableDeclarator = VariableDeclarator;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _repeating = require("repeating");
- var _repeating2 = _interopRequireDefault(_repeating);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function WithStatement(node, print) {
- this.keyword("with");
- this.push("(");
- print(node.object);
- this.push(")");
- print.block(node.body);
- }
- function IfStatement(node, print) {
- this.keyword("if");
- this.push("(");
- print(node.test);
- this.push(")");
- this.space();
- print.indentOnComments(node.consequent);
- if (node.alternate) {
- if (this.isLast("}")) this.space();
- this.push("else ");
- print.indentOnComments(node.alternate);
- }
- }
- function ForStatement(node, print) {
- this.keyword("for");
- this.push("(");
- print(node.init);
- this.push(";");
- if (node.test) {
- this.push(" ");
- print(node.test);
- }
- this.push(";");
- if (node.update) {
- this.push(" ");
- print(node.update);
- }
- this.push(")");
- print.block(node.body);
- }
- function WhileStatement(node, print) {
- this.keyword("while");
- this.push("(");
- print(node.test);
- this.push(")");
- print.block(node.body);
- }
- var buildForXStatement = function buildForXStatement(op) {
- return function (node, print) {
- this.keyword("for");
- this.push("(");
- print(node.left);
- this.push(" " + op + " ");
- print(node.right);
- this.push(")");
- print.block(node.body);
- };
- };
- var ForInStatement = buildForXStatement("in");
- exports.ForInStatement = ForInStatement;
- var ForOfStatement = buildForXStatement("of");
- exports.ForOfStatement = ForOfStatement;
- function DoWhileStatement(node, print) {
- this.push("do ");
- print(node.body);
- this.space();
- this.keyword("while");
- this.push("(");
- print(node.test);
- this.push(");");
- }
- var buildLabelStatement = function buildLabelStatement(prefix, key) {
- return function (node, print) {
- this.push(prefix);
- var label = node[key || "label"];
- if (label) {
- this.push(" ");
- print(label);
- }
- this.semicolon();
- };
- };
- var ContinueStatement = buildLabelStatement("continue");
- exports.ContinueStatement = ContinueStatement;
- var ReturnStatement = buildLabelStatement("return", "argument");
- exports.ReturnStatement = ReturnStatement;
- var BreakStatement = buildLabelStatement("break");
- exports.BreakStatement = BreakStatement;
- function LabeledStatement(node, print) {
- print(node.label);
- this.push(": ");
- print(node.body);
- }
- function TryStatement(node, print) {
- this.keyword("try");
- print(node.block);
- this.space();
- // Esprima bug puts the catch clause in a `handlers` array.
- // see https://code.google.com/p/esprima/issues/detail?id=433
- // We run into this from regenerator generated ast.
- if (node.handlers) {
- print(node.handlers[0]);
- } else {
- print(node.handler);
- }
- if (node.finalizer) {
- this.space();
- this.push("finally ");
- print(node.finalizer);
- }
- }
- function CatchClause(node, print) {
- this.keyword("catch");
- this.push("(");
- print(node.param);
- this.push(") ");
- print(node.body);
- }
- function ThrowStatement(node, print) {
- this.push("throw ");
- print(node.argument);
- this.semicolon();
- }
- function SwitchStatement(node, print) {
- this.keyword("switch");
- this.push("(");
- print(node.discriminant);
- this.push(")");
- this.space();
- this.push("{");
- print.sequence(node.cases, {
- indent: true,
- addNewlines: function addNewlines(leading, cas) {
- if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
- }
- });
- this.push("}");
- }
- function SwitchCase(node, print) {
- if (node.test) {
- this.push("case ");
- print(node.test);
- this.push(":");
- } else {
- this.push("default:");
- }
- if (node.consequent.length) {
- this.newline();
- print.sequence(node.consequent, { indent: true });
- }
- }
- function DebuggerStatement() {
- this.push("debugger;");
- }
- function VariableDeclaration(node, print, parent) {
- this.push(node.kind + " ");
- var hasInits = false;
- // don't add whitespace to loop heads
- if (!t.isFor(parent)) {
- var _arr = node.declarations;
- for (var _i = 0; _i < _arr.length; _i++) {
- var declar = _arr[_i];
- if (declar.init) {
- // has an init so let's split it up over multiple lines
- hasInits = true;
- }
- }
- }
- var sep = ",";
- if (!this.format.compact && !this.format.concise && hasInits && !this.format.retainLines) {
- sep += "\n" + (0, _repeating2["default"])(" ", node.kind.length + 1);
- } else {
- sep += " ";
- }
- print.list(node.declarations, { separator: sep });
- if (t.isFor(parent)) {
- if (parent.left === node || parent.init === node) return;
- }
- this.semicolon();
- }
- function VariableDeclarator(node, print) {
- print(node.id);
- print(node.id.typeAnnotation);
- if (node.init) {
- this.space();
- this.push("=");
- this.space();
- print(node.init);
- }
- }
- },{"../../types":169,"repeating":479}],33:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.TaggedTemplateExpression = TaggedTemplateExpression;
- exports.TemplateElement = TemplateElement;
- exports.TemplateLiteral = TemplateLiteral;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- function TaggedTemplateExpression(node, print) {
- print(node.tag);
- print(node.quasi);
- }
- function TemplateElement(node) {
- this._push(node.value.raw);
- }
- function TemplateLiteral(node, print) {
- this.push("`");
- var quasis = node.quasis;
- var len = quasis.length;
- for (var i = 0; i < len; i++) {
- print(quasis[i]);
- if (i + 1 < len) {
- this.push("${ ");
- print(node.expressions[i]);
- this.push(" }");
- }
- }
- this._push("`");
- }
- },{"lodash/collection/each":330}],34:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Identifier = Identifier;
- exports.RestElement = RestElement;
- exports.ObjectExpression = ObjectExpression;
- exports.Property = Property;
- exports.ArrayExpression = ArrayExpression;
- exports.Literal = Literal;
- exports._stringLiteral = _stringLiteral;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function Identifier(node) {
- this.push(node.name);
- }
- function RestElement(node, print) {
- this.push("...");
- print(node.argument);
- }
- exports.SpreadElement = RestElement;
- exports.SpreadProperty = RestElement;
- function ObjectExpression(node, print) {
- var props = node.properties;
- if (props.length) {
- this.push("{");
- this.space();
- print.list(props, { indent: true });
- this.space();
- this.push("}");
- } else {
- this.push("{}");
- }
- }
- exports.ObjectPattern = ObjectExpression;
- function Property(node, print) {
- if (node.method || node.kind === "get" || node.kind === "set") {
- this._method(node, print);
- } else {
- if (node.computed) {
- this.push("[");
- print(node.key);
- this.push("]");
- } else {
- print(node.key);
- // shorthand!
- if (node.shorthand && (t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name)) {
- return;
- }
- }
- this.push(":");
- this.space();
- print(node.value);
- }
- }
- function ArrayExpression(node, print) {
- var elems = node.elements;
- var len = elems.length;
- this.push("[");
- for (var i = 0; i < elems.length; i++) {
- var elem = elems[i];
- if (!elem) {
- // If the array expression ends with a hole, that hole
- // will be ignored by the interpreter, but if it ends with
- // two (or more) holes, we need to write out two (or more)
- // commas so that the resulting code is interpreted with
- // both (all) of the holes.
- this.push(",");
- } else {
- if (i > 0) this.push(" ");
- print(elem);
- if (i < len - 1) this.push(",");
- }
- }
- this.push("]");
- }
- exports.ArrayPattern = ArrayExpression;
- function Literal(node) {
- var val = node.value;
- var type = typeof val;
- if (type === "string") {
- this._stringLiteral(val);
- } else if (type === "number") {
- this.push(val + "");
- } else if (type === "boolean") {
- this.push(val ? "true" : "false");
- } else if (node.regex) {
- this.push("/" + node.regex.pattern + "/" + node.regex.flags);
- } else if (val === null) {
- this.push("null");
- }
- }
- function _stringLiteral(val) {
- val = JSON.stringify(val);
- // escape illegal js but valid json unicode characters
- val = val.replace(/[\u000A\u000D\u2028\u2029]/g, function (c) {
- return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
- });
- if (this.format.quotes === "single") {
- val = val.slice(1, -1);
- val = val.replace(/\\"/g, "\"");
- val = val.replace(/'/g, "\\'");
- val = "'" + val + "'";
- }
- this.push(val);
- }
- },{"../../types":169,"lodash/collection/each":330}],35:[function(require,module,exports){
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _detectIndent = require("detect-indent");
- var _detectIndent2 = _interopRequireDefault(_detectIndent);
- var _whitespace = require("./whitespace");
- var _whitespace2 = _interopRequireDefault(_whitespace);
- var _repeating = require("repeating");
- var _repeating2 = _interopRequireDefault(_repeating);
- var _sourceMap = require("./source-map");
- var _sourceMap2 = _interopRequireDefault(_sourceMap);
- var _position = require("./position");
- var _position2 = _interopRequireDefault(_position);
- var _messages = require("../messages");
- var messages = _interopRequireWildcard(_messages);
- var _buffer = require("./buffer");
- var _buffer2 = _interopRequireDefault(_buffer);
- var _lodashObjectExtend = require("lodash/object/extend");
- var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _node = require("./node");
- var _node2 = _interopRequireDefault(_node);
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- var CodeGenerator = (function () {
- function CodeGenerator(ast, opts, code) {
- _classCallCheck(this, CodeGenerator);
- opts = opts || {};
- this.comments = ast.comments || [];
- this.tokens = ast.tokens || [];
- this.format = CodeGenerator.normalizeOptions(code, opts, this.tokens);
- this.opts = opts;
- this.ast = ast;
- this.whitespace = new _whitespace2["default"](this.tokens, this.comments, this.format);
- this.position = new _position2["default"]();
- this.map = new _sourceMap2["default"](this.position, opts, code);
- this.buffer = new _buffer2["default"](this.position, this.format);
- }
- CodeGenerator.normalizeOptions = function normalizeOptions(code, opts, tokens) {
- var style = " ";
- if (code) {
- var indent = (0, _detectIndent2["default"])(code).indent;
- if (indent && indent !== " ") style = indent;
- }
- var format = {
- retainLines: opts.retainLines,
- comments: opts.comments == null || opts.comments,
- compact: opts.compact,
- quotes: CodeGenerator.findCommonStringDelimiter(code, tokens),
- indent: {
- adjustMultilineComment: true,
- style: style,
- base: 0
- }
- };
- if (format.compact === "auto") {
- format.compact = code.length > 100000; // 100KB
- if (format.compact) {
- console.error("[BABEL] " + messages.get("codeGeneratorDeopt", opts.filename, "100KB"));
- }
- }
- return format;
- };
- CodeGenerator.findCommonStringDelimiter = function findCommonStringDelimiter(code, tokens) {
- var occurences = {
- single: 0,
- double: 0
- };
- var checked = 0;
- for (var i = 0; i < tokens.length; i++) {
- var token = tokens[i];
- if (token.type.label !== "string") continue;
- if (checked >= 3) continue;
- var raw = code.slice(token.start, token.end);
- if (raw[0] === "'") {
- occurences.single++;
- } else {
- occurences.double++;
- }
- checked++;
- }
- if (occurences.single > occurences.double) {
- return "single";
- } else {
- return "double";
- }
- };
- CodeGenerator.prototype.generate = function generate() {
- var ast = this.ast;
- this.print(ast);
- if (ast.comments) {
- var comments = [];
- var _arr = ast.comments;
- for (var _i = 0; _i < _arr.length; _i++) {
- var comment = _arr[_i];
- if (!comment._displayed) comments.push(comment);
- }
- this._printComments(comments);
- }
- return {
- map: this.map.get(),
- code: this.buffer.get()
- };
- };
- CodeGenerator.prototype.buildPrint = function buildPrint(parent) {
- var _this = this;
- var print = function print(node, opts) {
- return _this.print(node, parent, opts);
- };
- print.sequence = function (nodes) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- opts.statement = true;
- return _this.printJoin(print, nodes, opts);
- };
- print.join = function (nodes, opts) {
- return _this.printJoin(print, nodes, opts);
- };
- print.list = function (items) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- if (opts.separator == null) opts.separator = ", ";
- print.join(items, opts);
- };
- print.block = function (node) {
- return _this.printBlock(print, node);
- };
- print.indentOnComments = function (node) {
- return _this.printAndIndentOnComments(print, node);
- };
- return print;
- };
- CodeGenerator.prototype.catchUp = function catchUp(node, parent, leftParenPrinted) {
- // catch up to this nodes newline if we're behind
- if (node.loc && this.format.retainLines && this.buffer.buf) {
- var needsParens = false;
- if (!leftParenPrinted && parent && this.position.line < node.loc.start.line && t.isTerminatorless(parent)) {
- needsParens = true;
- this._push("(");
- }
- while (this.position.line < node.loc.start.line) {
- this._push("\n");
- }
- return needsParens;
- }
- return false;
- };
- CodeGenerator.prototype.print = function print(node, parent) {
- var _this2 = this;
- var opts = arguments[2] === undefined ? {} : arguments[2];
- if (!node) return;
- if (parent && parent._compact) {
- node._compact = true;
- }
- var oldConcise = this.format.concise;
- if (node._compact) {
- this.format.concise = true;
- }
- var newline = function newline(leading) {
- if (!opts.statement && !_node2["default"].isUserWhitespacable(node, parent)) {
- return;
- }
- var lines = 0;
- if (node.start != null && !node._ignoreUserWhitespace) {
- // user node
- if (leading) {
- lines = _this2.whitespace.getNewlinesBefore(node);
- } else {
- lines = _this2.whitespace.getNewlinesAfter(node);
- }
- } else {
- // generated node
- if (!leading) lines++; // always include at least a single line after
- if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
- var needs = _node2["default"].needsWhitespaceAfter;
- if (leading) needs = _node2["default"].needsWhitespaceBefore;
- if (needs(node, parent)) lines++;
- // generated nodes can't add starting file whitespace
- if (!_this2.buffer.buf) lines = 0;
- }
- _this2.newline(lines);
- };
- if (this[node.type]) {
- var needsNoLineTermParens = _node2["default"].needsParensNoLineTerminator(node, parent);
- var needsParens = needsNoLineTermParens || _node2["default"].needsParens(node, parent);
- if (needsParens) this.push("(");
- if (needsNoLineTermParens) this.indent();
- this.printLeadingComments(node, parent);
- var needsParensFromCatchup = this.catchUp(node, parent, needsParens);
- newline(true);
- if (opts.before) opts.before();
- this.map.mark(node, "start");
- this[node.type](node, this.buildPrint(node), parent);
- if (needsNoLineTermParens) {
- this.newline();
- this.dedent();
- }
- if (needsParens || needsParensFromCatchup) this.push(")");
- this.map.mark(node, "end");
- if (opts.after) opts.after();
- this.format.concise = oldConcise;
- newline(false);
- this.printTrailingComments(node, parent);
- } else {
- throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
- }
- };
- CodeGenerator.prototype.printJoin = function printJoin(print, nodes) {
- var _this3 = this;
- var opts = arguments[2] === undefined ? {} : arguments[2];
- if (!nodes || !nodes.length) return;
- var len = nodes.length;
- if (opts.indent) this.indent();
- for (var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- print(node, {
- statement: opts.statement,
- addNewlines: opts.addNewlines,
- after: function after() {
- if (opts.iterator) {
- opts.iterator(node, i);
- }
- if (opts.separator && i < len - 1) {
- _this3.push(opts.separator);
- }
- }
- });
- }
- if (opts.indent) this.dedent();
- };
- CodeGenerator.prototype.printAndIndentOnComments = function printAndIndentOnComments(print, node) {
- var indent = !!node.leadingComments;
- if (indent) this.indent();
- print(node);
- if (indent) this.dedent();
- };
- CodeGenerator.prototype.printBlock = function printBlock(print, node) {
- if (t.isEmptyStatement(node)) {
- this.semicolon();
- } else {
- this.push(" ");
- print(node);
- }
- };
- CodeGenerator.prototype.generateComment = function generateComment(comment) {
- var val = comment.value;
- if (comment.type === "Line") {
- val = "//" + val;
- } else {
- val = "/*" + val + "*/";
- }
- return val;
- };
- CodeGenerator.prototype.printTrailingComments = function printTrailingComments(node, parent) {
- this._printComments(this.getComments("trailingComments", node, parent));
- };
- CodeGenerator.prototype.printLeadingComments = function printLeadingComments(node, parent) {
- this._printComments(this.getComments("leadingComments", node, parent));
- };
- CodeGenerator.prototype.getComments = function getComments(key, node, parent) {
- if (t.isExpressionStatement(parent)) {
- return [];
- }
- var comments = [];
- var nodes = [node];
- if (t.isExpressionStatement(node)) {
- nodes.push(node.argument);
- }
- var _arr2 = nodes;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var node = _arr2[_i2];
- comments = comments.concat(this._getComments(key, node));
- }
- return comments;
- };
- CodeGenerator.prototype._getComments = function _getComments(key, node) {
- return node && node[key] || [];
- };
- CodeGenerator.prototype._printComments = function _printComments(comments) {
- if (this.format.compact) return;
- if (!this.format.comments) return;
- if (!comments || !comments.length) return;
- var _arr3 = comments;
- for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
- var comment = _arr3[_i3];
- var skip = false;
- if (this.ast.comments) {
- // find the original comment in the ast and set it as displayed
- var _arr4 = this.ast.comments;
- for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
- var origComment = _arr4[_i4];
- if (origComment.start === comment.start) {
- // comment has already been output
- if (origComment._displayed) skip = true;
- origComment._displayed = true;
- break;
- }
- }
- }
- if (skip) return;
- this.catchUp(comment);
- // whitespace before
- this.newline(this.whitespace.getNewlinesBefore(comment));
- var column = this.position.column;
- var val = this.generateComment(comment);
- if (column && !this.isLast(["\n", " ", "[", "{"])) {
- this._push(" ");
- column++;
- }
- //
- if (comment.type === "Block" && this.format.indent.adjustMultilineComment) {
- var offset = comment.loc.start.column;
- if (offset) {
- var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
- val = val.replace(newlineRegex, "\n");
- }
- var indent = Math.max(this.indentSize(), column);
- val = val.replace(/\n/g, "\n" + (0, _repeating2["default"])(" ", indent));
- }
- if (column === 0) {
- val = this.getIndent() + val;
- }
- // force a newline for line comments when retainLines is set in case the next printed node
- // doesn't catch up
- if (this.format.retainLines && comment.type === "Line") {
- val += "\n";
- }
- //
- this._push(val);
- // whitespace after
- this.newline(this.whitespace.getNewlinesAfter(comment));
- }
- };
- _createClass(CodeGenerator, null, [{
- key: "generators",
- value: {
- templateLiterals: require("./generators/template-literals"),
- comprehensions: require("./generators/comprehensions"),
- expressions: require("./generators/expressions"),
- statements: require("./generators/statements"),
- classes: require("./generators/classes"),
- methods: require("./generators/methods"),
- modules: require("./generators/modules"),
- types: require("./generators/types"),
- flow: require("./generators/flow"),
- base: require("./generators/base"),
- jsx: require("./generators/jsx")
- },
- enumerable: true
- }]);
- return CodeGenerator;
- })();
- (0, _lodashCollectionEach2["default"])(_buffer2["default"].prototype, function (fn, key) {
- CodeGenerator.prototype[key] = function () {
- return fn.apply(this.buffer, arguments);
- };
- });
- (0, _lodashCollectionEach2["default"])(CodeGenerator.generators, function (generator) {
- (0, _lodashObjectExtend2["default"])(CodeGenerator.prototype, generator);
- });
- module.exports = function (ast, opts, code) {
- var gen = new CodeGenerator(ast, opts, code);
- return gen.generate();
- };
- module.exports.CodeGenerator = CodeGenerator;
- },{"../messages":47,"../types":169,"./buffer":23,"./generators/base":24,"./generators/classes":25,"./generators/comprehensions":26,"./generators/expressions":27,"./generators/flow":28,"./generators/jsx":29,"./generators/methods":30,"./generators/modules":31,"./generators/statements":32,"./generators/template-literals":33,"./generators/types":34,"./node":36,"./position":39,"./source-map":40,"./whitespace":41,"detect-indent":306,"lodash/collection/each":330,"lodash/object/extend":419,"repeating":479}],36:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _whitespace = require("./whitespace");
- var _whitespace2 = _interopRequireDefault(_whitespace);
- var _parentheses = require("./parentheses");
- var parens = _interopRequireWildcard(_parentheses);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _lodashCollectionSome = require("lodash/collection/some");
- var _lodashCollectionSome2 = _interopRequireDefault(_lodashCollectionSome);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var find = function find(obj, node, parent) {
- if (!obj) return;
- var result;
- var types = Object.keys(obj);
- for (var i = 0; i < types.length; i++) {
- var type = types[i];
- if (t.is(type, node)) {
- var fn = obj[type];
- result = fn(node, parent);
- if (result != null) break;
- }
- }
- return result;
- };
- var Node = (function () {
- function Node(node, parent) {
- _classCallCheck(this, Node);
- this.parent = parent;
- this.node = node;
- }
- Node.isUserWhitespacable = function isUserWhitespacable(node) {
- return t.isUserWhitespacable(node);
- };
- Node.needsWhitespace = function needsWhitespace(node, parent, type) {
- if (!node) return 0;
- if (t.isExpressionStatement(node)) {
- node = node.expression;
- }
- var linesInfo = find(_whitespace2["default"].nodes, node, parent);
- if (!linesInfo) {
- var items = find(_whitespace2["default"].list, node, parent);
- if (items) {
- for (var i = 0; i < items.length; i++) {
- linesInfo = Node.needsWhitespace(items[i], node, type);
- if (linesInfo) break;
- }
- }
- }
- return linesInfo && linesInfo[type] || 0;
- };
- Node.needsWhitespaceBefore = function needsWhitespaceBefore(node, parent) {
- return Node.needsWhitespace(node, parent, "before");
- };
- Node.needsWhitespaceAfter = function needsWhitespaceAfter(node, parent) {
- return Node.needsWhitespace(node, parent, "after");
- };
- Node.needsParens = function needsParens(node, parent) {
- if (!parent) return false;
- if (t.isNewExpression(parent) && parent.callee === node) {
- if (t.isCallExpression(node)) return true;
- var hasCall = (0, _lodashCollectionSome2["default"])(node, function (val) {
- return t.isCallExpression(val);
- });
- if (hasCall) return true;
- }
- return find(parens, node, parent);
- };
- Node.needsParensNoLineTerminator = function needsParensNoLineTerminator(node, parent) {
- if (!parent) return false;
- // no comments
- if (!node.leadingComments || !node.leadingComments.length) {
- return false;
- }
- return t.isTerminatorless(parent);
- };
- return Node;
- })();
- exports["default"] = Node;
- (0, _lodashCollectionEach2["default"])(Node, function (fn, key) {
- Node.prototype[key] = function () {
- // Avoid leaking arguments to prevent deoptimization
- var args = new Array(arguments.length + 2);
- args[0] = this.node;
- args[1] = this.parent;
- for (var i = 0; i < args.length; i++) {
- args[i + 2] = arguments[i];
- }
- return Node[key].apply(null, args);
- };
- });
- module.exports = exports["default"];
- },{"../../types":169,"./parentheses":37,"./whitespace":38,"lodash/collection/each":330,"lodash/collection/some":335}],37:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.NullableTypeAnnotation = NullableTypeAnnotation;
- exports.UpdateExpression = UpdateExpression;
- exports.ObjectExpression = ObjectExpression;
- exports.Binary = Binary;
- exports.BinaryExpression = BinaryExpression;
- exports.SequenceExpression = SequenceExpression;
- exports.YieldExpression = YieldExpression;
- exports.ClassExpression = ClassExpression;
- exports.UnaryLike = UnaryLike;
- exports.FunctionExpression = FunctionExpression;
- exports.ConditionalExpression = ConditionalExpression;
- exports.AssignmentExpression = AssignmentExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var PRECEDENCE = {};
- (0, _lodashCollectionEach2["default"])([["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]], function (tier, i) {
- (0, _lodashCollectionEach2["default"])(tier, function (op) {
- PRECEDENCE[op] = i;
- });
- });
- function NullableTypeAnnotation(node, parent) {
- return t.isArrayTypeAnnotation(parent);
- }
- exports.FunctionTypeAnnotation = NullableTypeAnnotation;
- function UpdateExpression(node, parent) {
- if (t.isMemberExpression(parent) && parent.object === node) {
- // (foo++).test()
- return true;
- }
- }
- function ObjectExpression(node, parent) {
- if (t.isExpressionStatement(parent)) {
- // ({ foo: "bar" });
- return true;
- }
- if (t.isMemberExpression(parent) && parent.object === node) {
- // ({ foo: "bar" }).foo
- return true;
- }
- return false;
- }
- function Binary(node, parent) {
- if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
- return true;
- }
- if (t.isUnaryLike(parent)) {
- return true;
- }
- if (t.isMemberExpression(parent) && parent.object === node) {
- return true;
- }
- if (t.isBinary(parent)) {
- var parentOp = parent.operator;
- var parentPos = PRECEDENCE[parentOp];
- var nodeOp = node.operator;
- var nodePos = PRECEDENCE[nodeOp];
- if (parentPos > nodePos) {
- return true;
- }
- if (parentPos === nodePos && parent.right === node) {
- return true;
- }
- }
- }
- function BinaryExpression(node, parent) {
- if (node.operator === "in") {
- // var i = (1 in []);
- if (t.isVariableDeclarator(parent)) {
- return true;
- }
- // for ((1 in []);;);
- if (t.isFor(parent)) {
- return true;
- }
- }
- }
- function SequenceExpression(node, parent) {
- if (t.isForStatement(parent)) {
- // Although parentheses wouldn't hurt around sequence
- // expressions in the head of for loops, traditional style
- // dictates that e.g. i++, j++ should not be wrapped with
- // parentheses.
- return false;
- }
- if (t.isExpressionStatement(parent) && parent.expression === node) {
- return false;
- }
- // Otherwise err on the side of overparenthesization, adding
- // explicit exceptions above if this proves overzealous.
- return true;
- }
- function YieldExpression(node, parent) {
- return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isConditionalExpression(parent) || t.isYieldExpression(parent);
- }
- function ClassExpression(node, parent) {
- return t.isExpressionStatement(parent);
- }
- function UnaryLike(node, parent) {
- return t.isMemberExpression(parent) && parent.object === node;
- }
- function FunctionExpression(node, parent) {
- // function () {};
- if (t.isExpressionStatement(parent)) {
- return true;
- }
- // (function test() {}).name;
- if (t.isMemberExpression(parent) && parent.object === node) {
- return true;
- }
- // (function () {})();
- if (t.isCallExpression(parent) && parent.callee === node) {
- return true;
- }
- }
- function ConditionalExpression(node, parent) {
- if (t.isUnaryLike(parent)) {
- return true;
- }
- if (t.isBinary(parent)) {
- return true;
- }
- if (t.isCallExpression(parent) || t.isNewExpression(parent)) {
- if (parent.callee === node) {
- return true;
- }
- }
- if (t.isConditionalExpression(parent) && parent.test === node) {
- return true;
- }
- if (t.isMemberExpression(parent) && parent.object === node) {
- return true;
- }
- return false;
- }
- function AssignmentExpression(node) {
- if (t.isObjectPattern(node.left)) {
- return true;
- } else {
- return ConditionalExpression.apply(undefined, arguments);
- }
- }
- },{"../../types":169,"lodash/collection/each":330}],38:[function(require,module,exports){
- "use strict";
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
- var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _lodashCollectionMap = require("lodash/collection/map");
- var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function crawl(node) {
- var state = arguments[1] === undefined ? {} : arguments[1];
- if (t.isMemberExpression(node)) {
- crawl(node.object, state);
- if (node.computed) crawl(node.property, state);
- } else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
- crawl(node.left, state);
- crawl(node.right, state);
- } else if (t.isCallExpression(node)) {
- state.hasCall = true;
- crawl(node.callee, state);
- } else if (t.isFunction(node)) {
- state.hasFunction = true;
- } else if (t.isIdentifier(node)) {
- state.hasHelper = state.hasHelper || isHelper(node.callee);
- }
- return state;
- }
- function isHelper(node) {
- if (t.isMemberExpression(node)) {
- return isHelper(node.object) || isHelper(node.property);
- } else if (t.isIdentifier(node)) {
- return node.name === "require" || node.name[0] === "_";
- } else if (t.isCallExpression(node)) {
- return isHelper(node.callee);
- } else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
- return t.isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
- } else {
- return false;
- }
- }
- function isType(node) {
- return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node);
- }
- exports.nodes = {
- AssignmentExpression: function AssignmentExpression(node) {
- var state = crawl(node.right);
- if (state.hasCall && state.hasHelper || state.hasFunction) {
- return {
- before: state.hasFunction,
- after: true
- };
- }
- },
- SwitchCase: function SwitchCase(node, parent) {
- return {
- before: node.consequent.length || parent.cases[0] === node
- };
- },
- LogicalExpression: function LogicalExpression(node) {
- if (t.isFunction(node.left) || t.isFunction(node.right)) {
- return {
- after: true
- };
- }
- },
- Literal: function Literal(node) {
- if (node.value === "use strict") {
- return {
- after: true
- };
- }
- },
- CallExpression: function CallExpression(node) {
- if (t.isFunction(node.callee) || isHelper(node)) {
- return {
- before: true,
- after: true
- };
- }
- },
- VariableDeclaration: function VariableDeclaration(node) {
- for (var i = 0; i < node.declarations.length; i++) {
- var declar = node.declarations[i];
- var enabled = isHelper(declar.id) && !isType(declar.init);
- if (!enabled) {
- var state = crawl(declar.init);
- enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
- }
- if (enabled) {
- return {
- before: true,
- after: true
- };
- }
- }
- },
- IfStatement: function IfStatement(node) {
- if (t.isBlockStatement(node.consequent)) {
- return {
- before: true,
- after: true
- };
- }
- }
- };
- exports.nodes.Property = exports.nodes.SpreadProperty = function (node, parent) {
- if (parent.properties[0] === node) {
- return {
- before: true
- };
- }
- };
- exports.list = {
- VariableDeclaration: function VariableDeclaration(node) {
- return (0, _lodashCollectionMap2["default"])(node.declarations, "init");
- },
- ArrayExpression: function ArrayExpression(node) {
- return node.elements;
- },
- ObjectExpression: function ObjectExpression(node) {
- return node.properties;
- }
- };
- (0, _lodashCollectionEach2["default"])({
- Function: true,
- Class: true,
- Loop: true,
- LabeledStatement: true,
- SwitchStatement: true,
- TryStatement: true
- }, function (amounts, type) {
- if ((0, _lodashLangIsBoolean2["default"])(amounts)) {
- amounts = { after: amounts, before: amounts };
- }
- (0, _lodashCollectionEach2["default"])([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
- exports.nodes[type] = function () {
- return amounts;
- };
- });
- });
- },{"../../types":169,"lodash/collection/each":330,"lodash/collection/map":333,"lodash/lang/isBoolean":406}],39:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var Position = (function () {
- function Position() {
- _classCallCheck(this, Position);
- this.line = 1;
- this.column = 0;
- }
- Position.prototype.push = function push(str) {
- for (var i = 0; i < str.length; i++) {
- if (str[i] === "\n") {
- this.line++;
- this.column = 0;
- } else {
- this.column++;
- }
- }
- };
- Position.prototype.unshift = function unshift(str) {
- for (var i = 0; i < str.length; i++) {
- if (str[i] === "\n") {
- this.line--;
- } else {
- this.column--;
- }
- }
- };
- return Position;
- })();
- exports["default"] = Position;
- module.exports = exports["default"];
- },{}],40:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _sourceMap = require("source-map");
- var _sourceMap2 = _interopRequireDefault(_sourceMap);
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- var SourceMap = (function () {
- function SourceMap(position, opts, code) {
- _classCallCheck(this, SourceMap);
- this.position = position;
- this.opts = opts;
- if (opts.sourceMaps) {
- this.map = new _sourceMap2["default"].SourceMapGenerator({
- file: opts.sourceMapName,
- sourceRoot: opts.sourceRoot
- });
- this.map.setSourceContent(opts.sourceFileName, code);
- } else {
- this.map = null;
- }
- }
- SourceMap.prototype.get = function get() {
- var map = this.map;
- if (map) {
- return map.toJSON();
- } else {
- return map;
- }
- };
- SourceMap.prototype.mark = function mark(node, type) {
- var loc = node.loc;
- if (!loc) return; // no location info
- var map = this.map;
- if (!map) return; // no source map
- if (t.isProgram(node) || t.isFile(node)) return; // illegal mapping nodes
- var position = this.position;
- var generated = {
- line: position.line,
- column: position.column
- };
- var original = loc[type];
- map.addMapping({
- source: this.opts.sourceFileName,
- generated: generated,
- original: original
- });
- };
- return SourceMap;
- })();
- exports["default"] = SourceMap;
- module.exports = exports["default"];
- },{"../types":169,"source-map":483}],41:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _lodashCollectionSortBy = require("lodash/collection/sortBy");
- var _lodashCollectionSortBy2 = _interopRequireDefault(_lodashCollectionSortBy);
- /**
- * Returns `i`th number from `base`, continuing from 0 when `max` is reached.
- * Useful for shifting `for` loop by a fixed number but going over all items.
- *
- * @param {Number} i Current index in the loop
- * @param {Number} base Start index for which to return 0
- * @param {Number} max Array length
- * @returns {Number} shiftedIndex
- */
- function getLookupIndex(i, base, max) {
- i += base;
- if (i >= max) {
- i -= max;
- }
- return i;
- }
- var Whitespace = (function () {
- function Whitespace(tokens, comments) {
- _classCallCheck(this, Whitespace);
- this.tokens = (0, _lodashCollectionSortBy2["default"])(tokens.concat(comments), "start");
- this.used = {};
- // Profiling this code shows that while generator passes over it, indexes
- // returned by `getNewlinesBefore` and `getNewlinesAfter` are always increasing.
- // We use this implementation detail for an optimization: instead of always
- // starting to look from `this.tokens[0]`, we will start `for` loops from the
- // previous successful match. We will enumerate all tokens—but the common
- // case will be much faster.
- this._lastFoundIndex = 0;
- }
- Whitespace.prototype.getNewlinesBefore = function getNewlinesBefore(node) {
- var startToken;
- var endToken;
- var tokens = this.tokens;
- var token;
- for (var j = 0; j < tokens.length; j++) {
- // optimize for forward traversal by shifting for loop index
- var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
- token = tokens[i];
- // this is the token this node starts with
- if (node.start === token.start) {
- startToken = tokens[i - 1];
- endToken = token;
- this._lastFoundIndex = i;
- break;
- }
- }
- return this.getNewlinesBetween(startToken, endToken);
- };
- Whitespace.prototype.getNewlinesAfter = function getNewlinesAfter(node) {
- var startToken;
- var endToken;
- var tokens = this.tokens;
- var token;
- for (var j = 0; j < tokens.length; j++) {
- // optimize for forward traversal by shifting for loop index
- var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
- token = tokens[i];
- // this is the token this node ends with
- if (node.end === token.end) {
- startToken = token;
- endToken = tokens[i + 1];
- this._lastFoundIndex = i;
- break;
- }
- }
- if (endToken && endToken.type.label === "eof") {
- return 1;
- } else {
- var lines = this.getNewlinesBetween(startToken, endToken);
- if (node.type === "Line" && !lines) {
- // line comment
- return 1;
- } else {
- return lines;
- }
- }
- };
- Whitespace.prototype.getNewlinesBetween = function getNewlinesBetween(startToken, endToken) {
- if (!endToken || !endToken.loc) return 0;
- var start = startToken ? startToken.loc.end.line : 1;
- var end = endToken.loc.start.line;
- var lines = 0;
- for (var line = start; line < end; line++) {
- if (typeof this.used[line] === "undefined") {
- this.used[line] = true;
- lines++;
- }
- }
- return lines;
- };
- return Whitespace;
- })();
- exports["default"] = Whitespace;
- module.exports = exports["default"];
- },{"lodash/collection/sortBy":336}],42:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lineNumbers = require("line-numbers");
- var _lineNumbers2 = _interopRequireDefault(_lineNumbers);
- var _repeating = require("repeating");
- var _repeating2 = _interopRequireDefault(_repeating);
- var _jsTokens = require("js-tokens");
- var _jsTokens2 = _interopRequireDefault(_jsTokens);
- var _esutils = require("esutils");
- var _esutils2 = _interopRequireDefault(_esutils);
- var _chalk = require("chalk");
- var _chalk2 = _interopRequireDefault(_chalk);
- var defs = {
- string: _chalk2["default"].red,
- punctuator: _chalk2["default"].bold,
- curly: _chalk2["default"].green,
- parens: _chalk2["default"].blue.bold,
- square: _chalk2["default"].yellow,
- keyword: _chalk2["default"].cyan,
- number: _chalk2["default"].magenta,
- regex: _chalk2["default"].magenta,
- comment: _chalk2["default"].grey,
- invalid: _chalk2["default"].inverse
- };
- var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
- function getTokenType(match) {
- var token = _jsTokens2["default"].matchToToken(match);
- if (token.type === "name" && _esutils2["default"].keyword.isReservedWordES6(token.value)) {
- return "keyword";
- }
- if (token.type === "punctuator") {
- switch (token.value) {
- case "{":
- case "}":
- return "curly";
- case "(":
- case ")":
- return "parens";
- case "[":
- case "]":
- return "square";
- }
- }
- return token.type;
- }
- function highlight(text) {
- return text.replace(_jsTokens2["default"], function () {
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- var type = getTokenType(args);
- var colorize = defs[type];
- if (colorize) {
- return args[0].split(NEWLINE).map(function (str) {
- return colorize(str);
- }).join("\n");
- } else {
- return args[0];
- }
- });
- }
- exports["default"] = function (lines, lineNumber, colNumber) {
- var opts = arguments[3] === undefined ? {} : arguments[3];
- colNumber = Math.max(colNumber, 0);
- if (opts.highlightCode && _chalk2["default"].supportsColor) {
- lines = highlight(lines);
- }
- lines = lines.split(NEWLINE);
- var start = Math.max(lineNumber - 3, 0);
- var end = Math.min(lines.length, lineNumber + 3);
- if (!lineNumber && !colNumber) {
- start = 0;
- end = lines.length;
- }
- return (0, _lineNumbers2["default"])(lines.slice(start, end), {
- start: start + 1,
- before: " ",
- after: " | ",
- transform: function transform(params) {
- if (params.number !== lineNumber) {
- return;
- }
- if (colNumber) {
- params.line += "\n" + params.before + "" + (0, _repeating2["default"])(" ", params.width) + "" + params.after + "" + (0, _repeating2["default"])(" ", colNumber - 1) + "^";
- }
- params.before = params.before.replace(/^./, ">");
- }
- }).join("\n");
- };
- ;
- module.exports = exports["default"];
- },{"chalk":217,"esutils":314,"js-tokens":320,"line-numbers":322,"repeating":479}],43:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashObjectMerge = require("lodash/object/merge");
- var _lodashObjectMerge2 = _interopRequireDefault(_lodashObjectMerge);
- exports["default"] = function (dest, src) {
- if (!dest || !src) return;
- return (0, _lodashObjectMerge2["default"])(dest, src, function (a, b) {
- if (Array.isArray(a)) {
- var c = a.slice(0);
- for (var _iterator = b, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
- var _ref;
- if (_isArray) {
- if (_i >= _iterator.length) break;
- _ref = _iterator[_i++];
- } else {
- _i = _iterator.next();
- if (_i.done) break;
- _ref = _i.value;
- }
- var v = _ref;
- if (a.indexOf(v) < 0) {
- c.push(v);
- }
- }
- return c;
- }
- });
- };
- module.exports = exports["default"];
- },{"lodash/object/merge":423}],44:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- exports["default"] = function (ast, comments, tokens) {
- if (ast && ast.type === "Program") {
- return t.file(ast, comments || [], tokens || []);
- } else {
- throw new Error("Not a valid ast?");
- }
- };
- ;
- module.exports = exports["default"];
- },{"../types":169}],45:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports["default"] = function () {
- return Object.create(null);
- };
- ;
- module.exports = exports["default"];
- },{}],46:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _normalizeAst = require("./normalize-ast");
- var _normalizeAst2 = _interopRequireDefault(_normalizeAst);
- var _estraverse = require("estraverse");
- var _estraverse2 = _interopRequireDefault(_estraverse);
- var _acorn = require("../../acorn");
- var acorn = _interopRequireWildcard(_acorn);
- exports["default"] = function (code) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- var comments = [];
- var tokens = [];
- var parseOpts = {
- allowImportExportEverywhere: opts.looseModules,
- allowReturnOutsideFunction: opts.looseModules,
- allowHashBang: true,
- ecmaVersion: 6,
- strictMode: opts.strictMode,
- sourceType: opts.sourceType,
- locations: true,
- onComment: comments,
- features: opts.features || {},
- plugins: opts.plugins || {},
- onToken: tokens,
- ranges: true
- };
- if (opts.nonStandard) {
- parseOpts.plugins.jsx = true;
- parseOpts.plugins.flow = true;
- }
- var ast = acorn.parse(code, parseOpts);
- _estraverse2["default"].attachComments(ast, comments, tokens);
- ast = (0, _normalizeAst2["default"])(ast, comments, tokens);
- return ast;
- };
- module.exports = exports["default"];
- },{"../../acorn":1,"./normalize-ast":44,"estraverse":309}],47:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.get = get;
- exports.parseArgs = parseArgs;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _util = require("util");
- var util = _interopRequireWildcard(_util);
- var MESSAGES = {
- tailCallReassignmentDeopt: "Function reference has been reassigned so it's probably be dereferenced so we can't optimise this with confidence",
- JSXNamespacedTags: "Namespace tags are not supported. ReactJSX is not XML.",
- classesIllegalBareSuper: "Illegal use of bare super",
- classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead",
- classesIllegalConstructorKind: "Illegal kind for constructor method",
- scopeDuplicateDeclaration: "Duplicate declaration $1",
- undeclaredVariable: "Reference to undeclared variable $1",
- undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?",
- settersInvalidParamLength: "Setters must have exactly one parameter",
- settersNoRest: "Setters aren't allowed to have a rest",
- noAssignmentsInForHead: "No assignments allowed in for-in/of head",
- expectedMemberExpressionOrIdentifier: "Expected type MemeberExpression or Identifier",
- invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
- readOnly: "$1 is read-only",
- modulesIllegalExportName: "Illegal export $1",
- unknownForHead: "Unknown node type $1 in ForStatement",
- didYouMean: "Did you mean $1?",
- codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",
- missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",
- unsupportedOutputType: "Unsupported output type $1",
- illegalMethodName: "Illegal method name $1",
- lostTrackNodePath: "We lost track of this nodes position, likely because the AST was directly manipulated",
- traverseNeedsParent: "Must pass a scope and parentPath unless traversing a Program/File got a $1 node",
- traverseVerifyRootFunction: "You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",
- traverseVerifyVisitorProperty: "You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",
- traverseVerifyNodeType: "You gave us a visitor for the node type $1 but it's not a valid type",
- pluginIllegalKind: "Illegal kind $1 for plugin $2",
- pluginIllegalPosition: "Illegal position $1 for plugin $2",
- pluginKeyCollision: "The plugin $1 collides with another of the same name",
- pluginNotTransformer: "The plugin $1 didn't export a Transformer instance",
- pluginUnknown: "Unknown plugin $1",
- transformerNotFile: "Transformer $1 is resolving to a different Babel version to what is doing the actual transformation..."
- };
- exports.MESSAGES = MESSAGES;
- function get(key) {
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
- var msg = MESSAGES[key];
- if (!msg) throw new ReferenceError("Unknown message " + JSON.stringify(key));
- args = parseArgs(args);
- return msg.replace(/\$(\d+)/g, function (str, i) {
- return args[--i];
- });
- }
- function parseArgs(args) {
- return args.map(function (val) {
- if (val != null && val.inspect) {
- return val.inspect();
- } else {
- try {
- return JSON.stringify(val) || val + "";
- } catch (e) {
- return util.inspect(val);
- }
- }
- });
- }
- },{"util":216}],48:[function(require,module,exports){
- "use strict";
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _estraverse = require("estraverse");
- var _estraverse2 = _interopRequireDefault(_estraverse);
- var _lodashObjectExtend = require("lodash/object/extend");
- var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
- var _astTypes = require("ast-types");
- var _astTypes2 = _interopRequireDefault(_astTypes);
- var _types = require("./types");
- var t = _interopRequireWildcard(_types);
- // estraverse
- (0, _lodashObjectExtend2["default"])(_estraverse2["default"].VisitorKeys, t.VISITOR_KEYS);
- // regenerator/ast-types
- var def = _astTypes2["default"].Type.def;
- var or = _astTypes2["default"].Type.or;
- //def("File")
- // .bases("Node")
- // .build("program")
- // .field("program", def("Program"));
- def("AssignmentPattern").bases("Pattern").build("left", "right").field("left", def("Pattern")).field("right", def("Expression"));
- def("RestElement").bases("Pattern").build("argument").field("argument", def("expression"));
- def("DoExpression").bases("Expression").build("body").field("body", [def("Statement")]);
- def("Super").bases("Expression");
- def("ExportDefaultDeclaration").bases("Declaration").build("declaration").field("declaration", or(def("Declaration"), def("Expression"), null));
- def("ExportNamedDeclaration").bases("Declaration").build("declaration").field("declaration", or(def("Declaration"), def("Expression"), null)).field("specifiers", [or(def("ExportSpecifier"))]).field("source", or(def("ModuleSpecifier"), null));
- def("ExportNamespaceSpecifier").bases("Specifier").field("exported", def("Identifier"));
- def("ExportDefaultSpecifier").bases("Specifier").field("exported", def("Identifier"));
- def("ExportAllDeclaration").bases("Declaration").build("exported", "source").field("exported", def("Identifier")).field("source", def("Literal"));
- def("BindExpression").bases("Expression").build("object", "callee").field("object", or(def("Expression"), null)).field("callee", def("Expression"));
- _astTypes2["default"].finalize();
- },{"./types":169,"ast-types":188,"estraverse":309,"lodash/object/extend":419}],49:[function(require,module,exports){
- (function (global){
- "use strict";
- require("core-js/shim");
- require("regenerator/runtime");
- if (global._babelPolyfill) {
- throw new Error("only one instance of babel/polyfill is allowed");
- }
- global._babelPolyfill = true;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"core-js/shim":302,"regenerator/runtime":472}],50:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _generation = require("../generation");
- var _generation2 = _interopRequireDefault(_generation);
- var _messages = require("../messages");
- var messages = _interopRequireWildcard(_messages);
- var _util = require("../util");
- var util = _interopRequireWildcard(_util);
- var _transformationFile = require("../transformation/file");
- var _transformationFile2 = _interopRequireDefault(_transformationFile);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- function buildGlobal(namespace, builder) {
- var body = [];
- var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
- var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("helper-self-global")]))]);
- body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([])))]));
- builder(body);
- return tree;
- }
- function buildUmd(namespace, builder) {
- var body = [];
- body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.identifier("global"))]));
- builder(body);
- var container = util.template("umd-commonjs-strict", {
- FACTORY_PARAMETERS: t.identifier("global"),
- BROWSER_ARGUMENTS: t.assignmentExpression("=", t.memberExpression(t.identifier("root"), namespace), t.objectExpression({})),
- COMMON_ARGUMENTS: t.identifier("exports"),
- AMD_ARGUMENTS: t.arrayExpression([t.literal("exports")]),
- FACTORY_BODY: body,
- UMD_ROOT: t.identifier("this")
- });
- return t.program([container]);
- }
- function buildVar(namespace, builder) {
- var body = [];
- body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.objectExpression({}))]));
- builder(body);
- return t.program(body);
- }
- function buildHelpers(body, namespace, whitelist) {
- (0, _lodashCollectionEach2["default"])(_transformationFile2["default"].helpers, function (name) {
- if (whitelist && whitelist.indexOf(name) === -1) return;
- var key = t.identifier(t.toIdentifier(name));
- body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(namespace, key), util.template("helper-" + name))));
- });
- }
- exports["default"] = function (whitelist) {
- var outputType = arguments[1] === undefined ? "global" : arguments[1];
- var namespace = t.identifier("babelHelpers");
- var builder = function builder(body) {
- return buildHelpers(body, namespace, whitelist);
- };
- var tree;
- var build = ({
- global: buildGlobal,
- umd: buildUmd,
- "var": buildVar
- })[outputType];
- if (build) {
- tree = build(namespace, builder);
- } else {
- throw new Error(messages.get("unsupportedOutputType", outputType));
- }
- return (0, _generation2["default"])(tree).code;
- };
- ;
- module.exports = exports["default"];
- },{"../generation":35,"../messages":47,"../transformation/file":52,"../types":169,"../util":173,"lodash/collection/each":330}],51:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _stripJsonComments = require("strip-json-comments");
- var _stripJsonComments2 = _interopRequireDefault(_stripJsonComments);
- var _helpersMerge = require("../helpers/merge");
- var _helpersMerge2 = _interopRequireDefault(_helpersMerge);
- var _path = require("path");
- var _path2 = _interopRequireDefault(_path);
- var _fs = require("fs");
- var _fs2 = _interopRequireDefault(_fs);
- var cache = {};
- var jsons = {};
- function exists(filename) {
- if (!_fs2["default"].existsSync) return false;
- var cached = cache[filename];
- if (cached != null) return cached;
- return cache[filename] = _fs2["default"].existsSync(filename);
- }
- exports["default"] = function (loc) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- var rel = ".babelrc";
- if (!opts.babelrc) {
- opts.babelrc = [];
- }
- function find(start, rel) {
- var file = _path2["default"].join(start, rel);
- if (opts.babelrc.indexOf(file) >= 0) {
- return;
- }
- if (exists(file)) {
- var content = _fs2["default"].readFileSync(file, "utf8");
- var json;
- try {
- json = jsons[content] = jsons[content] || JSON.parse((0, _stripJsonComments2["default"])(content));
- } catch (err) {
- err.message = "" + file + ": " + err.message;
- throw err;
- }
- opts.babelrc.push(file);
- if (json.breakConfig) return;
- (0, _helpersMerge2["default"])(opts, json);
- }
- var up = _path2["default"].dirname(start);
- if (up !== start) {
- // root
- find(up, rel);
- }
- }
- if (opts.babelrc.indexOf(loc) < 0 && opts.breakConfig !== true) {
- find(loc, rel);
- }
- return opts;
- };
- ;
- module.exports = exports["default"];
- },{"../helpers/merge":43,"fs":189,"path":199,"strip-json-comments":494}],52:[function(require,module,exports){
- (function (process){
- "use strict";
- exports.__esModule = true;
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _convertSourceMap = require("convert-source-map");
- var _convertSourceMap2 = _interopRequireDefault(_convertSourceMap);
- var _optionParsers = require("./option-parsers");
- var optionParsers = _interopRequireWildcard(_optionParsers);
- var _modules = require("../modules");
- var _modules2 = _interopRequireDefault(_modules);
- var _pluginManager = require("./plugin-manager");
- var _pluginManager2 = _interopRequireDefault(_pluginManager);
- var _shebangRegex = require("shebang-regex");
- var _shebangRegex2 = _interopRequireDefault(_shebangRegex);
- var _traversalPath = require("../../traversal/path");
- var _traversalPath2 = _interopRequireDefault(_traversalPath);
- var _transformer = require("../transformer");
- var _transformer2 = _interopRequireDefault(_transformer);
- var _lodashLangIsFunction = require("lodash/lang/isFunction");
- var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
- var _pathIsAbsolute = require("path-is-absolute");
- var _pathIsAbsolute2 = _interopRequireDefault(_pathIsAbsolute);
- var _toolsResolveRc = require("../../tools/resolve-rc");
- var _toolsResolveRc2 = _interopRequireDefault(_toolsResolveRc);
- var _sourceMap = require("source-map");
- var _sourceMap2 = _interopRequireDefault(_sourceMap);
- var _index = require("./../index");
- var _index2 = _interopRequireDefault(_index);
- var _generation = require("../../generation");
- var _generation2 = _interopRequireDefault(_generation);
- var _helpersCodeFrame = require("../../helpers/code-frame");
- var _helpersCodeFrame2 = _interopRequireDefault(_helpersCodeFrame);
- var _lodashObjectDefaults = require("lodash/object/defaults");
- var _lodashObjectDefaults2 = _interopRequireDefault(_lodashObjectDefaults);
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _traversal = require("../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _lodashObjectAssign = require("lodash/object/assign");
- var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
- var _logger = require("./logger");
- var _logger2 = _interopRequireDefault(_logger);
- var _helpersParse = require("../../helpers/parse");
- var _helpersParse2 = _interopRequireDefault(_helpersParse);
- var _traversalScope = require("../../traversal/scope");
- var _traversalScope2 = _interopRequireDefault(_traversalScope);
- var _helpersMerge = require("../../helpers/merge");
- var _helpersMerge2 = _interopRequireDefault(_helpersMerge);
- var _slash = require("slash");
- var _slash2 = _interopRequireDefault(_slash);
- var _lodashLangClone = require("lodash/lang/clone");
- var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var _apiNode = require("../../api/node");
- var api = _interopRequireWildcard(_apiNode);
- var _path = require("path");
- var _path2 = _interopRequireDefault(_path);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var File = (function () {
- function File(_x, pipeline) {
- var opts = arguments[0] === undefined ? {} : arguments[0];
- _classCallCheck(this, File);
- this.transformerDependencies = {};
- this.dynamicImportTypes = {};
- this.dynamicImportIds = {};
- this.dynamicImports = [];
- this.declarations = {};
- this.usedHelpers = {};
- this.dynamicData = {};
- this.metadata = {};
- this.data = {};
- this.pipeline = pipeline;
- this.log = new _logger2["default"](this, opts.filename || "unknown");
- this.opts = this.normalizeOptions(opts);
- this.ast = {};
- this.buildTransformers();
- }
- File.prototype.normalizeOptions = function normalizeOptions(opts) {
- opts = (0, _lodashObjectAssign2["default"])({}, opts);
- if (opts.filename) {
- var rcFilename = opts.filename;
- if (!(0, _pathIsAbsolute2["default"])(rcFilename)) rcFilename = _path2["default"].join(process.cwd(), rcFilename);
- opts = (0, _toolsResolveRc2["default"])(rcFilename, opts);
- }
- //
- for (var key in opts) {
- if (key[0] === "_") continue;
- var option = File.options[key];
- if (!option) this.log.error("Unknown option: " + key, ReferenceError);
- }
- var envKey = process.env.BABEL_ENV || process.env.NODE_ENV || "development";
- if (opts.env) (0, _helpersMerge2["default"])(opts, opts.env[envKey]);
- for (var key in File.options) {
- var option = File.options[key];
- var val = opts[key];
- if (!val && option.optional) continue;
- if (val && option.deprecated) {
- throw new Error("Deprecated option " + key + ": " + option.deprecated);
- }
- if (val == null) {
- val = (0, _lodashLangClone2["default"])(option["default"]);
- }
- var optionParser = optionParsers[option.type];
- if (optionParser) val = optionParser(key, val, this.pipeline);
- if (option.alias) {
- opts[option.alias] = opts[option.alias] || val;
- } else {
- opts[key] = val;
- }
- }
- if (opts.inputSourceMap) {
- opts.sourceMaps = true;
- }
- // normalize windows path separators to unix
- opts.filename = (0, _slash2["default"])(opts.filename);
- if (opts.sourceRoot) {
- opts.sourceRoot = (0, _slash2["default"])(opts.sourceRoot);
- }
- if (opts.moduleId) {
- opts.moduleIds = true;
- }
- opts.basename = _path2["default"].basename(opts.filename, _path2["default"].extname(opts.filename));
- opts.ignore = util.arrayify(opts.ignore, util.regexify);
- opts.only = util.arrayify(opts.only, util.regexify);
- (0, _lodashObjectDefaults2["default"])(opts, {
- moduleRoot: opts.sourceRoot
- });
- (0, _lodashObjectDefaults2["default"])(opts, {
- sourceRoot: opts.moduleRoot
- });
- (0, _lodashObjectDefaults2["default"])(opts, {
- filenameRelative: opts.filename
- });
- (0, _lodashObjectDefaults2["default"])(opts, {
- sourceFileName: opts.filenameRelative,
- sourceMapName: opts.filenameRelative
- });
- //
- if (opts.externalHelpers) {
- this.set("helpersNamespace", t.identifier("babelHelpers"));
- }
- return opts;
- };
- File.prototype.isLoose = function isLoose(key) {
- return (0, _lodashCollectionIncludes2["default"])(this.opts.loose, key);
- };
- File.prototype.buildTransformers = function buildTransformers() {
- var file = this;
- var transformers = this.transformers = {};
- var secondaryStack = [];
- var stack = [];
- // build internal transformers
- for (var key in this.pipeline.transformers) {
- var transformer = this.pipeline.transformers[key];
- var pass = transformers[key] = transformer.buildPass(file);
- if (pass.canTransform()) {
- stack.push(pass);
- if (transformer.metadata.secondPass) {
- secondaryStack.push(pass);
- }
- if (transformer.manipulateOptions) {
- transformer.manipulateOptions(file.opts, file);
- }
- }
- }
- // init plugins!
- var beforePlugins = [];
- var afterPlugins = [];
- var pluginManager = new _pluginManager2["default"]({
- file: this,
- transformers: this.transformers,
- before: beforePlugins,
- after: afterPlugins
- });
- for (var i = 0; i < file.opts.plugins.length; i++) {
- pluginManager.add(file.opts.plugins[i]);
- }
- stack = beforePlugins.concat(stack, afterPlugins);
- // build transformer stack
- this.uncollapsedTransformerStack = stack = stack.concat(secondaryStack);
- // build dependency graph
- var _arr = stack;
- for (var _i = 0; _i < _arr.length; _i++) {
- var pass = _arr[_i];var _arr2 = pass.transformer.dependencies;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var dep = _arr2[_i2];
- this.transformerDependencies[dep] = pass.key;
- }
- }
- // collapse stack categories
- this.transformerStack = this.collapseStack(stack);
- };
- File.prototype.collapseStack = function collapseStack(_stack) {
- var stack = [];
- var ignore = [];
- var _arr3 = _stack;
- for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
- var pass = _arr3[_i3];
- // been merged
- if (ignore.indexOf(pass) >= 0) continue;
- var group = pass.transformer.metadata.group;
- // can't merge
- if (!pass.canTransform() || !group) {
- stack.push(pass);
- continue;
- }
- var mergeStack = [];
- var _arr4 = _stack;
- for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
- var _pass = _arr4[_i4];
- if (_pass.transformer.metadata.group === group) {
- mergeStack.push(_pass);
- ignore.push(_pass);
- }
- }
- var visitors = [];
- var _arr5 = mergeStack;
- for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
- var _pass2 = _arr5[_i5];
- visitors.push(_pass2.handlers);
- }
- var visitor = _traversal2["default"].visitors.merge(visitors);
- var mergeTransformer = new _transformer2["default"](group, visitor);
- //console.log(mergeTransformer);
- stack.push(mergeTransformer.buildPass(this));
- }
- return stack;
- };
- File.prototype.set = function set(key, val) {
- return this.data[key] = val;
- };
- File.prototype.setDynamic = function setDynamic(key, fn) {
- this.dynamicData[key] = fn;
- };
- File.prototype.get = function get(key) {
- var data = this.data[key];
- if (data) {
- return data;
- } else {
- var dynamic = this.dynamicData[key];
- if (dynamic) {
- return this.set(key, dynamic());
- }
- }
- };
- File.prototype.resolveModuleSource = function resolveModuleSource(source) {
- var resolveModuleSource = this.opts.resolveModuleSource;
- if (resolveModuleSource) source = resolveModuleSource(source, this.opts.filename);
- return source;
- };
- File.prototype.addImport = function addImport(source, name, type) {
- name = name || source;
- var id = this.dynamicImportIds[name];
- if (!id) {
- source = this.resolveModuleSource(source);
- id = this.dynamicImportIds[name] = this.scope.generateUidIdentifier(name);
- var specifiers = [t.importDefaultSpecifier(id)];
- var declar = t.importDeclaration(specifiers, t.literal(source));
- declar._blockHoist = 3;
- if (type) {
- var modules = this.dynamicImportTypes[type] = this.dynamicImportTypes[type] || [];
- modules.push(declar);
- }
- if (this.transformers["es6.modules"].canTransform()) {
- this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
- this.moduleFormatter.hasLocalImports = true;
- } else {
- this.dynamicImports.push(declar);
- }
- }
- return id;
- };
- File.prototype.attachAuxiliaryComment = function attachAuxiliaryComment(node) {
- var comment = this.opts.auxiliaryComment;
- if (comment) {
- node.leadingComments = node.leadingComments || [];
- node.leadingComments.push({
- type: "Line",
- value: " " + comment
- });
- }
- return node;
- };
- File.prototype.addHelper = function addHelper(name) {
- var isSolo = (0, _lodashCollectionIncludes2["default"])(File.soloHelpers, name);
- if (!isSolo && !(0, _lodashCollectionIncludes2["default"])(File.helpers, name)) {
- throw new ReferenceError("Unknown helper " + name);
- }
- var program = this.ast.program;
- var declar = this.declarations[name];
- if (declar) return declar;
- this.usedHelpers[name] = true;
- if (!isSolo) {
- var generator = this.get("helperGenerator");
- var runtime = this.get("helpersNamespace");
- if (generator) {
- return generator(name);
- } else if (runtime) {
- var id = t.identifier(t.toIdentifier(name));
- return t.memberExpression(runtime, id);
- }
- }
- var ref = util.template("helper-" + name);
- var uid = this.declarations[name] = this.scope.generateUidIdentifier(name);
- if (t.isFunctionExpression(ref) && !ref.id) {
- ref.body._compact = true;
- ref._generated = true;
- ref.id = uid;
- ref.type = "FunctionDeclaration";
- this.attachAuxiliaryComment(ref);
- this.path.unshiftContainer("body", ref);
- } else {
- ref._compact = true;
- this.scope.push({
- id: uid,
- init: ref,
- unique: true
- });
- }
- return uid;
- };
- File.prototype.errorWithNode = function errorWithNode(node, msg) {
- var Error = arguments[2] === undefined ? SyntaxError : arguments[2];
- var loc = node.loc.start;
- var err = new Error("Line " + loc.line + ": " + msg);
- err.loc = loc;
- return err;
- };
- File.prototype.mergeSourceMap = function mergeSourceMap(map) {
- var opts = this.opts;
- var inputMap = opts.inputSourceMap;
- if (inputMap) {
- map.sources[0] = inputMap.file;
- var inputMapConsumer = new _sourceMap2["default"].SourceMapConsumer(inputMap);
- var outputMapConsumer = new _sourceMap2["default"].SourceMapConsumer(map);
- var outputMapGenerator = _sourceMap2["default"].SourceMapGenerator.fromSourceMap(outputMapConsumer);
- outputMapGenerator.applySourceMap(inputMapConsumer);
- var mergedMap = outputMapGenerator.toJSON();
- mergedMap.sources = inputMap.sources;
- mergedMap.file = inputMap.file;
- return mergedMap;
- }
- return map;
- };
- File.prototype.getModuleFormatter = function getModuleFormatter(type) {
- var ModuleFormatter = (0, _lodashLangIsFunction2["default"])(type) ? type : _modules2["default"][type];
- if (!ModuleFormatter) {
- var loc = util.resolveRelative(type);
- if (loc) ModuleFormatter = require(loc);
- }
- if (!ModuleFormatter) {
- throw new ReferenceError("Unknown module formatter type " + JSON.stringify(type));
- }
- return new ModuleFormatter(this);
- };
- File.prototype.parse = function parse(code) {
- var opts = this.opts;
- //
- var parseOpts = {
- highlightCode: opts.highlightCode,
- nonStandard: opts.nonStandard,
- filename: opts.filename,
- plugins: {}
- };
- var features = parseOpts.features = {};
- for (var key in this.transformers) {
- var transformer = this.transformers[key];
- features[key] = transformer.canTransform();
- }
- parseOpts.looseModules = this.isLoose("es6.modules");
- parseOpts.strictMode = features.strict;
- parseOpts.sourceType = "module";
- this.log.debug("Parse start");
- var tree = (0, _helpersParse2["default"])(code, parseOpts);
- this.log.debug("Parse stop");
- return tree;
- };
- File.prototype._addAst = function _addAst(ast) {
- this.path = _traversalPath2["default"].get(null, ast, ast, "program", this).setContext(null, this);
- this.scope = this.path.scope;
- this.ast = ast;
- };
- File.prototype.addAst = function addAst(ast) {
- this.log.debug("Start set AST");
- this._addAst(ast);
- this.log.debug("End set AST");
- this.log.debug("Start module formatter init");
- var modFormatter = this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
- if (modFormatter.init && this.transformers["es6.modules"].canTransform()) {
- modFormatter.init();
- }
- this.log.debug("End module formatter init");
- this.call("pre");
- var _arr6 = this.transformerStack;
- for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
- var pass = _arr6[_i6];
- pass.transform();
- }
- this.call("post");
- };
- File.prototype.wrap = function wrap(code, callback) {
- code = code + "";
- try {
- if (this.shouldIgnore()) {
- return {
- metadata: this.metadata,
- ignored: true,
- code: code,
- map: null,
- ast: null
- };
- }
- callback();
- return this.generate();
- } catch (err) {
- if (err._babel) {
- throw err;
- } else {
- err._babel = true;
- }
- var message = err.message = "" + this.opts.filename + ": " + err.message;
- var loc = err.loc;
- if (loc) {
- err.codeFrame = (0, _helpersCodeFrame2["default"])(code, loc.line, loc.column + 1, this.opts);
- message += "\n" + err.codeFrame;
- }
- if (err.stack) {
- var newStack = err.stack.replace(err.message, message);
- try {
- err.stack = newStack;
- } catch (e) {}
- }
- throw err;
- }
- };
- File.prototype.addCode = function addCode(code, parseCode) {
- code = (code || "") + "";
- code = this.parseInputSourceMap(code);
- this.code = code;
- if (parseCode) {
- this.parseShebang();
- this.addAst(this.parse(this.code));
- }
- };
- File.prototype.shouldIgnore = function shouldIgnore() {
- var opts = this.opts;
- return util.shouldIgnore(opts.filename, opts.ignore, opts.only);
- };
- File.prototype.call = function call(key) {
- var _arr7 = this.uncollapsedTransformerStack;
- for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
- var pass = _arr7[_i7];
- var fn = pass.transformer[key];
- if (fn) fn(this);
- }
- };
- File.prototype.parseInputSourceMap = function parseInputSourceMap(code) {
- var opts = this.opts;
- if (opts.inputSourceMap !== false) {
- var inputMap = _convertSourceMap2["default"].fromSource(code);
- if (inputMap) {
- opts.inputSourceMap = inputMap.toObject();
- code = _convertSourceMap2["default"].removeComments(code);
- }
- }
- return code;
- };
- File.prototype.parseShebang = function parseShebang() {
- var shebangMatch = _shebangRegex2["default"].exec(this.code);
- if (shebangMatch) {
- this.shebang = shebangMatch[0];
- this.code = this.code.replace(_shebangRegex2["default"], "");
- }
- };
- File.prototype.generate = function generate() {
- var opts = this.opts;
- var ast = this.ast;
- var result = {
- metadata: this.metadata,
- code: "",
- map: null,
- ast: null
- };
- if (this.opts.metadataUsedHelpers) {
- result.metadata.usedHelpers = Object.keys(this.usedHelpers);
- }
- if (opts.ast) result.ast = ast;
- if (!opts.code) return result;
- this.log.debug("Generation start");
- var _result = (0, _generation2["default"])(ast, opts, this.code);
- result.code = _result.code;
- result.map = _result.map;
- this.log.debug("Generation end");
- if (this.shebang) {
- // add back shebang
- result.code = "" + this.shebang + "\n" + result.code;
- }
- if (result.map) {
- result.map = this.mergeSourceMap(result.map);
- }
- if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") {
- result.code += "\n" + _convertSourceMap2["default"].fromObject(result.map).toComment();
- }
- if (opts.sourceMaps === "inline") {
- result.map = null;
- }
- return result;
- };
- _createClass(File, null, [{
- key: "helpers",
- value: ["inherits", "defaults", "create-class", "create-decorated-class", "create-decorated-object", "define-decorated-property-descriptor", "tagged-template-literal", "tagged-template-literal-loose", "to-array", "to-consumable-array", "sliced-to-array", "sliced-to-array-loose", "object-without-properties", "has-own", "slice", "bind", "define-property", "async-to-generator", "interop-require-wildcard", "interop-require-default", "typeof", "extends", "get", "set", "class-call-check", "object-destructuring-empty", "temporal-undefined", "temporal-assert-defined", "self-global", "default-props", "instanceof",
- // legacy
- "interop-require"],
- enumerable: true
- }, {
- key: "soloHelpers",
- value: [],
- enumerable: true
- }, {
- key: "options",
- value: require("./options"),
- enumerable: true
- }]);
- return File;
- })();
- exports["default"] = File;
- module.exports = exports["default"];
- // `err.stack` may be a readonly property in some environments
- }).call(this,require('_process'))
- },{"../../api/node":20,"../../generation":35,"../../helpers/code-frame":42,"../../helpers/merge":43,"../../helpers/parse":46,"../../tools/resolve-rc":51,"../../traversal":157,"../../traversal/path":161,"../../traversal/scope":164,"../../types":169,"../../util":173,"../modules":79,"../transformer":85,"./../index":71,"./logger":53,"./option-parsers":54,"./options":55,"./plugin-manager":56,"_process":200,"convert-source-map":225,"lodash/collection/includes":332,"lodash/lang/clone":402,"lodash/lang/isFunction":408,"lodash/object/assign":417,"lodash/object/defaults":418,"path":199,"path-is-absolute":434,"shebang-regex":481,"slash":482,"source-map":483}],53:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _debugNode = require("debug/node");
- var _debugNode2 = _interopRequireDefault(_debugNode);
- var verboseDebug = (0, _debugNode2["default"])("babel:verbose");
- var generalDebug = (0, _debugNode2["default"])("babel");
- var Logger = (function () {
- function Logger(file, filename) {
- _classCallCheck(this, Logger);
- this.filename = filename;
- this.file = file;
- }
- Logger.prototype._buildMessage = function _buildMessage(msg) {
- var parts = "[BABEL] " + this.filename;
- if (msg) parts += ": " + msg;
- return parts;
- };
- Logger.prototype.error = function error(msg) {
- var Constructor = arguments[1] === undefined ? Error : arguments[1];
- throw new Constructor(this._buildMessage(msg));
- };
- Logger.prototype.deprecate = function deprecate(msg) {
- if (!this.file.opts.suppressDeprecationMessages) {
- console.error(this._buildMessage(msg));
- }
- };
- Logger.prototype.verbose = function verbose(msg) {
- if (verboseDebug.enabled) verboseDebug(this._buildMessage(msg));
- };
- Logger.prototype.debug = function debug(msg) {
- if (generalDebug.enabled) generalDebug(this._buildMessage(msg));
- };
- Logger.prototype.deopt = function deopt(node, msg) {
- this.debug(msg);
- };
- return Logger;
- })();
- exports["default"] = Logger;
- module.exports = exports["default"];
- },{"debug/node":304}],54:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.transformerList = transformerList;
- exports.number = number;
- exports.boolean = boolean;
- exports.booleanString = booleanString;
- exports.list = list;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- function transformerList(key, val, pipeline) {
- val = util.arrayify(val);
- if (val.indexOf("all") >= 0 || val.indexOf(true) >= 0) {
- val = Object.keys(pipeline.transformers);
- }
- return pipeline._ensureTransformerNames(key, val);
- }
- function number(key, val) {
- return +val;
- }
- function boolean(key, val) {
- return !!val;
- }
- function booleanString(key, val) {
- return util.booleanify(val);
- }
- function list(key, val) {
- return util.list(val);
- }
- },{"../../util":173}],55:[function(require,module,exports){
- module.exports={
- "filename": {
- "type": "string",
- "description": "filename to use when reading from stdin - this will be used in source-maps, errors etc",
- "default": "unknown",
- "shorthand": "f"
- },
- "filenameRelative": {
- "hidden": true,
- "type": "string"
- },
- "inputSourceMap": {
- "hidden": true
- },
- "extra": {
- "hidden": true,
- "default": {}
- },
- "env": {
- "hidden": true,
- "default": {}
- },
- "moduleId": {
- "description": "specify a custom name for module ids",
- "type": "string"
- },
- "getModuleId": {
- "hidden": true
- },
- "retainLines": {
- "type": "boolean",
- "default": false,
- "description": "retain line numbers - will result in really ugly code"
- },
- "nonStandard": {
- "type": "boolean",
- "default": true,
- "description": "enable support for JSX and Flow"
- },
- "experimental": {
- "deprecated": "use `--stage 0`/`{ stage: 0 }` instead"
- },
- "highlightCode": {
- "description": "ANSI syntax highlight code frames",
- "type": "boolean",
- "default": true
- },
- "suppressDeprecationMessages": {
- "type": "boolean",
- "default": false,
- "hidden": true
- },
- "resolveModuleSource": {
- "hidden": true
- },
- "stage": {
- "description": "ECMAScript proposal stage version to allow [0-4]",
- "shorthand": "e",
- "type": "number",
- "default": 2
- },
- "blacklist": {
- "type": "transformerList",
- "description": "blacklist of transformers to NOT use",
- "shorthand": "b"
- },
- "whitelist": {
- "type": "transformerList",
- "optional": true,
- "description": "whitelist of transformers to ONLY use",
- "shorthand": "l"
- },
- "optional": {
- "type": "transformerList",
- "description": "list of optional transformers to enable"
- },
- "modules": {
- "type": "string",
- "description": "module formatter type to use [common]",
- "default": "common",
- "shorthand": "m"
- },
- "moduleIds": {
- "type": "boolean",
- "default": false,
- "shorthand": "M",
- "description": "insert an explicit id for modules"
- },
- "loose": {
- "type": "transformerList",
- "description": "list of transformers to enable loose mode ON",
- "shorthand": "L"
- },
- "jsxPragma": {
- "type": "string",
- "description": "custom pragma to use with JSX (same functionality as @jsx comments)",
- "default": "React.createElement",
- "shorthand": "P"
- },
- "plugins": {
- "type": "list",
- "description": ""
- },
- "ignore": {
- "type": "list",
- "description": "list of glob paths to **not** compile"
- },
- "only": {
- "type": "list",
- "description": "list of glob paths to **only** compile"
- },
- "code": {
- "hidden": true,
- "default": true,
- "type": "boolean"
- },
- "ast": {
- "hidden": true,
- "default": true,
- "type": "boolean"
- },
- "comments": {
- "type": "boolean",
- "default": true,
- "description": "output comments in generated output"
- },
- "compact": {
- "type": "booleanString",
- "default": "auto",
- "description": "do not include superfluous whitespace characters and line terminators [true|false|auto]"
- },
- "keepModuleIdExtensions": {
- "type": "boolean",
- "description": "keep extensions when generating module ids",
- "default": false,
- "shorthand": "k"
- },
- "auxiliaryComment": {
- "type": "string",
- "default": "",
- "shorthand": "a",
- "description": "attach a comment before all helper declarations and auxiliary code"
- },
- "externalHelpers": {
- "type": "boolean",
- "default": false,
- "shorthand": "r",
- "description": "uses a reference to `babelHelpers` instead of placing helpers at the top of your code."
- },
- "metadataUsedHelpers": {
- "type": "boolean",
- "default": false,
- "hidden": true
- },
- "sourceMap": {
- "alias": "sourceMaps",
- "hidden": true
- },
- "sourceMaps": {
- "type": "booleanString",
- "description": "[true|false|inline]",
- "default": false,
- "shorthand": "s"
- },
- "sourceMapName": {
- "type": "string",
- "description": "set `file` on returned source map"
- },
- "sourceFileName": {
- "type": "string",
- "description": "set `sources[0]` on returned source map"
- },
- "sourceRoot": {
- "type": "string",
- "description": "the root from which all sources are relative"
- },
- "moduleRoot": {
- "type": "string",
- "description": "optional prefix for the AMD module formatter that will be prepend to the filename on module definitions"
- },
- "breakConfig": {
- "type": "boolean",
- "default": false,
- "hidden": true,
- "description": "stop trying to load .babelrc files"
- },
- "babelrc": {
- "hidden": true,
- "description": "do not load the same .babelrc file twice"
- }
- }
- },{}],56:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _apiNode = require("../../api/node");
- var node = _interopRequireWildcard(_apiNode);
- var _messages = require("../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var PluginManager = (function () {
- function PluginManager() {
- var _ref = arguments[0] === undefined ? { transformers: {}, before: [], after: [] } : arguments[0];
- var file = _ref.file;
- var transformers = _ref.transformers;
- var before = _ref.before;
- var after = _ref.after;
- _classCallCheck(this, PluginManager);
- this.transformers = transformers;
- this.file = file;
- this.before = before;
- this.after = after;
- }
- PluginManager.memoisePluginContainer = function memoisePluginContainer(fn) {
- for (var i = 0; i < PluginManager.memoisedPlugins.length; i++) {
- var plugin = PluginManager.memoisedPlugins[i];
- if (plugin.container === fn) return plugin.transformer;
- }
- var transformer = fn(node);
- PluginManager.memoisedPlugins.push({
- container: fn,
- transformer: transformer
- });
- return transformer;
- };
- PluginManager.prototype.subnormaliseString = function subnormaliseString(name, position) {
- // this is a plugin in the form of "foobar" or "foobar:after"
- // where the optional colon is the delimiter for plugin position in the transformer stack
- var match = name.match(/^(.*?):(after|before)$/);
- if (match) {
- ;
- var _temp = match;
- name = _temp[1];
- position = _temp[2];
- _temp;
- }var loc = util.resolveRelative(name) || util.resolveRelative("babel-plugin-" + name);
- if (loc) {
- return {
- position: position,
- plugin: require(loc)
- };
- } else {
- throw new ReferenceError(messages.get("pluginUnknown", name));
- }
- };
- PluginManager.prototype.validate = function validate(name, plugin) {
- // validate transformer key
- var key = plugin.key;
- if (this.transformers[key]) {
- throw new ReferenceError(messages.get("pluginKeyCollision", key));
- }
- // validate Transformer instance
- if (!plugin.buildPass || plugin.constructor.name !== "Transformer") {
- throw new TypeError(messages.get("pluginNotTransformer", name));
- }
- // register as a plugin
- plugin.metadata.plugin = true;
- };
- PluginManager.prototype.add = function add(name) {
- var position;
- var plugin;
- if (name) {
- if (typeof name === "object" && name.transformer) {
- var _temp2 = name;
- plugin = _temp2.transformer;
- position = _temp2.position;
- _temp2;
- } else if (typeof name !== "string") {
- // not a string so we'll just assume that it's a direct Transformer instance, if not then
- // the checks later on will complain
- plugin = name;
- }
- if (typeof name === "string") {
- var _temp3 = this.subnormaliseString(name, position);
- plugin = _temp3.plugin;
- position = _temp3.position;
- _temp3;
- }
- } else {
- throw new TypeError(messages.get("pluginIllegalKind", typeof name, name));
- }
- // default position
- position = position || "before";
- // validate position
- if (PluginManager.positions.indexOf(position) < 0) {
- throw new TypeError(messages.get("pluginIllegalPosition", position, name));
- }
- // allow plugin containers to be specified so they don't have to manually require
- if (typeof plugin === "function") {
- plugin = PluginManager.memoisePluginContainer(plugin);
- }
- //
- this.validate(name, plugin);
- // build!
- var pass = this.transformers[plugin.key] = plugin.buildPass(this.file);
- if (pass.canTransform()) {
- var stack = position === "before" ? this.before : this.after;
- stack.push(pass);
- }
- };
- _createClass(PluginManager, null, [{
- key: "memoisedPlugins",
- value: [],
- enumerable: true
- }, {
- key: "positions",
- value: ["before", "after"],
- enumerable: true
- }]);
- return PluginManager;
- })();
- exports["default"] = PluginManager;
- module.exports = exports["default"];
- },{"../../api/node":20,"../../messages":47,"../../util":173}],57:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _explodeAssignableExpression = require("./explode-assignable-expression");
- var _explodeAssignableExpression2 = _interopRequireDefault(_explodeAssignableExpression);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- exports["default"] = function (opts) {
- var exports = {};
- var isAssignment = function isAssignment(node) {
- return node.operator === opts.operator + "=";
- };
- var buildAssignment = function buildAssignment(left, right) {
- return t.assignmentExpression("=", left, right);
- };
- exports.ExpressionStatement = function (node, parent, scope, file) {
- // hit the `AssignmentExpression` one below
- if (this.isCompletionRecord()) return;
- var expr = node.expression;
- if (!isAssignment(expr)) return;
- var nodes = [];
- var exploded = (0, _explodeAssignableExpression2["default"])(expr.left, nodes, file, scope, true);
- nodes.push(t.expressionStatement(buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right))));
- return nodes;
- };
- exports.AssignmentExpression = function (node, parent, scope, file) {
- if (!isAssignment(node)) return;
- var nodes = [];
- var exploded = (0, _explodeAssignableExpression2["default"])(node.left, nodes, file, scope);
- nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));
- return nodes;
- };
- exports.BinaryExpression = function (node) {
- if (node.operator !== opts.operator) return;
- return opts.build(node.left, node.right);
- };
- return exports;
- };
- ;
- module.exports = exports["default"];
- },{"../../types":169,"./explode-assignable-expression":62}],58:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports["default"] = build;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function build(node, buildBody) {
- var self = node.blocks.shift();
- if (!self) return;
- var child = build(node, buildBody);
- if (!child) {
- // last item
- child = buildBody();
- // add a filter as this is our final stop
- if (node.filter) {
- child = t.ifStatement(node.filter, t.blockStatement([child]));
- }
- }
- return t.forOfStatement(t.variableDeclaration("let", [t.variableDeclarator(self.left)]), self.right, t.blockStatement([child]));
- }
- module.exports = exports["default"];
- },{"../../types":169}],59:[function(require,module,exports){
- // Based upon the excellent jsx-transpiler by Ingvar Stepanyan (RReverser)
- // https://github.com/RReverser/jsx-transpiler
- // jsx
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangIsString = require("lodash/lang/isString");
- var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
- var _messages = require("../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _esutils = require("esutils");
- var _esutils2 = _interopRequireDefault(_esutils);
- var _react = require("./react");
- var react = _interopRequireWildcard(_react);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- exports["default"] = function (exports, opts) {
- exports.JSXIdentifier = function (node, parent) {
- if (node.name === "this" && this.isReferenced()) {
- return t.thisExpression();
- } else if (_esutils2["default"].keyword.isIdentifierNameES6(node.name)) {
- node.type = "Identifier";
- } else {
- return t.literal(node.name);
- }
- };
- exports.JSXNamespacedName = function (node, parent, scope, file) {
- throw this.errorWithNode(messages.get("JSXNamespacedTags"));
- };
- exports.JSXMemberExpression = {
- exit: function exit(node) {
- node.computed = t.isLiteral(node.property);
- node.type = "MemberExpression";
- }
- };
- exports.JSXExpressionContainer = function (node) {
- return node.expression;
- };
- exports.JSXAttribute = {
- enter: function enter(node) {
- var value = node.value;
- if (t.isLiteral(value) && (0, _lodashLangIsString2["default"])(value.value)) {
- value.value = value.value.replace(/\n\s+/g, " ");
- }
- },
- exit: function exit(node) {
- var value = node.value || t.literal(true);
- return t.inherits(t.property("init", node.name, value), node);
- }
- };
- exports.JSXOpeningElement = {
- exit: function exit(node, parent, scope, file) {
- parent.children = react.buildChildren(parent);
- var tagExpr = node.name;
- var args = [];
- var tagName;
- if (t.isIdentifier(tagExpr)) {
- tagName = tagExpr.name;
- } else if (t.isLiteral(tagExpr)) {
- tagName = tagExpr.value;
- }
- var state = {
- tagExpr: tagExpr,
- tagName: tagName,
- args: args
- };
- if (opts.pre) {
- opts.pre(state, file);
- }
- var attribs = node.attributes;
- if (attribs.length) {
- attribs = buildJSXOpeningElementAttributes(attribs, file);
- } else {
- attribs = t.literal(null);
- }
- args.push(attribs);
- if (opts.post) {
- opts.post(state, file);
- }
- return state.call || t.callExpression(state.callee, args);
- }
- };
- /**
- * The logic for this is quite terse. It's because we need to
- * support spread elements. We loop over all attributes,
- * breaking on spreads, we then push a new object containg
- * all prior attributes to an array for later processing.
- */
- var buildJSXOpeningElementAttributes = function buildJSXOpeningElementAttributes(attribs, file) {
- var _props = [];
- var objs = [];
- var pushProps = function pushProps() {
- if (!_props.length) return;
- objs.push(t.objectExpression(_props));
- _props = [];
- };
- while (attribs.length) {
- var prop = attribs.shift();
- if (t.isJSXSpreadAttribute(prop)) {
- pushProps();
- objs.push(prop.argument);
- } else {
- _props.push(prop);
- }
- }
- pushProps();
- if (objs.length === 1) {
- // only one object
- attribs = objs[0];
- } else {
- // looks like we have multiple objects
- if (!t.isObjectExpression(objs[0])) {
- objs.unshift(t.objectExpression([]));
- }
- // spread it
- attribs = t.callExpression(file.addHelper("extends"), objs);
- }
- return attribs;
- };
- exports.JSXElement = {
- exit: function exit(node) {
- var callExpr = node.openingElement;
- callExpr.arguments = callExpr.arguments.concat(node.children);
- if (callExpr.arguments.length >= 3) {
- callExpr._prettyCall = true;
- }
- return t.inherits(callExpr, node);
- }
- };
- // display names
- var addDisplayName = function addDisplayName(id, call) {
- var props = call.arguments[0].properties;
- var safe = true;
- for (var i = 0; i < props.length; i++) {
- var prop = props[i];
- if (t.isIdentifier(prop.key, { name: "displayName" })) {
- safe = false;
- break;
- }
- }
- if (safe) {
- props.unshift(t.property("init", t.identifier("displayName"), t.literal(id)));
- }
- };
- exports.ExportDefaultDeclaration = function (node, parent, scope, file) {
- if (react.isCreateClass(node.declaration)) {
- addDisplayName(file.opts.basename, node.declaration);
- }
- };
- exports.AssignmentExpression = exports.Property = exports.VariableDeclarator = function (node) {
- var left, right;
- if (t.isAssignmentExpression(node)) {
- left = node.left;
- right = node.right;
- } else if (t.isProperty(node)) {
- left = node.key;
- right = node.value;
- } else if (t.isVariableDeclarator(node)) {
- left = node.id;
- right = node.init;
- }
- if (t.isMemberExpression(left)) {
- left = left.property;
- }
- if (t.isIdentifier(left) && react.isCreateClass(right)) {
- addDisplayName(left.name, right);
- }
- };
- };
- ;
- module.exports = exports["default"];
- },{"../../messages":47,"../../types":169,"./react":66,"esutils":314,"lodash/lang/isString":414}],60:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _traversal = require("../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var visitor = {
- enter: function enter(node, parent, scope, state) {
- if (this.isThisExpression() || this.isReferencedIdentifier({ name: "arguments" })) {
- state.found = true;
- this.stop();
- }
- if (this.isFunction()) {
- this.skip();
- }
- }
- };
- exports["default"] = function (node, scope) {
- var container = t.functionExpression(null, [], node.body, node.generator, node.async);
- var callee = container;
- var args = [];
- var state = { found: false };
- scope.traverse(node, visitor, state);
- if (state.found) {
- callee = t.memberExpression(container, t.identifier("apply"));
- args = [t.thisExpression(), t.identifier("arguments")];
- }
- var call = t.callExpression(callee, args);
- if (node.generator) call = t.yieldExpression(call, true);
- return t.returnStatement(call);
- };
- module.exports = exports["default"];
- },{"../../traversal":157,"../../types":169}],61:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.push = push;
- exports.hasComputed = hasComputed;
- exports.toComputedObjectFromClass = toComputedObjectFromClass;
- exports.toClassObject = toClassObject;
- exports.toDefineObject = toDefineObject;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangCloneDeep = require("lodash/lang/cloneDeep");
- var _lodashLangCloneDeep2 = _interopRequireDefault(_lodashLangCloneDeep);
- var _traversal = require("../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _lodashObjectHas = require("lodash/object/has");
- var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function push(mutatorMap, node, kind, file) {
- var alias = t.toKeyAlias(node);
- //
- var map = {};
- if ((0, _lodashObjectHas2["default"])(mutatorMap, alias)) map = mutatorMap[alias];
- mutatorMap[alias] = map;
- //
- map._inherits = map._inherits || [];
- map._inherits.push(node);
- map._key = node.key;
- if (node.computed) {
- map._computed = true;
- }
- if (node.decorators) {
- var decorators = map.decorators = map.decorators || t.arrayExpression([]);
- decorators.elements = decorators.elements.concat(node.decorators.map(function (dec) {
- return dec.expression;
- }).reverse());
- }
- if (map.value || map.initializer) {
- throw file.errorWithNode(node, "Key conflict with sibling node");
- }
- if (node.value) {
- if (node.kind === "init") kind = "value";
- if (node.kind === "get") kind = "get";
- if (node.kind === "set") kind = "set";
- t.inheritsComments(node.value, node);
- map[kind] = node.value;
- }
- return map;
- }
- function hasComputed(mutatorMap) {
- for (var key in mutatorMap) {
- if (mutatorMap[key]._computed) {
- return true;
- }
- }
- return false;
- }
- function toComputedObjectFromClass(obj) {
- var objExpr = t.arrayExpression([]);
- for (var i = 0; i < obj.properties.length; i++) {
- var prop = obj.properties[i];
- var val = prop.value;
- val.properties.unshift(t.property("init", t.identifier("key"), t.toComputedKey(prop)));
- objExpr.elements.push(val);
- }
- return objExpr;
- }
- function toClassObject(mutatorMap) {
- var objExpr = t.objectExpression([]);
- (0, _lodashCollectionEach2["default"])(mutatorMap, function (map) {
- var mapNode = t.objectExpression([]);
- var propNode = t.property("init", map._key, mapNode, map._computed);
- (0, _lodashCollectionEach2["default"])(map, function (node, key) {
- if (key[0] === "_") return;
- var inheritNode = node;
- if (t.isMethodDefinition(node) || t.isClassProperty(node)) node = node.value;
- var prop = t.property("init", t.identifier(key), node);
- t.inheritsComments(prop, inheritNode);
- t.removeComments(inheritNode);
- mapNode.properties.push(prop);
- });
- objExpr.properties.push(propNode);
- });
- return objExpr;
- }
- function toDefineObject(mutatorMap) {
- (0, _lodashCollectionEach2["default"])(mutatorMap, function (map) {
- if (map.value) map.writable = t.literal(true);
- map.configurable = t.literal(true);
- map.enumerable = t.literal(true);
- });
- return toClassObject(mutatorMap);
- }
- },{"../../traversal":157,"../../types":169,"lodash/collection/each":330,"lodash/lang/cloneDeep":403,"lodash/object/has":420}],62:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var getObjRef = function getObjRef(node, nodes, file, scope) {
- var ref;
- if (t.isIdentifier(node)) {
- if (scope.hasBinding(node.name)) {
- // this variable is declared in scope so we can be 100% sure
- // that evaluating it multiple times wont trigger a getter
- // or something else
- return node;
- } else {
- // could possibly trigger a getter so we need to only evaluate
- // it once
- ref = node;
- }
- } else if (t.isMemberExpression(node)) {
- ref = node.object;
- if (t.isIdentifier(ref) && scope.hasGlobal(ref.name)) {
- // the object reference that we need to save is locally declared
- // so as per the previous comment we can be 100% sure evaluating
- // it multiple times will be safe
- return ref;
- }
- } else {
- throw new Error("We can't explode this node type " + node.type);
- }
- var temp = scope.generateUidIdentifierBasedOnNode(ref);
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, ref)]));
- return temp;
- };
- var getPropRef = function getPropRef(node, nodes, file, scope) {
- var prop = node.property;
- var key = t.toComputedKey(node, prop);
- if (t.isLiteral(key)) return key;
- var temp = scope.generateUidIdentifierBasedOnNode(prop);
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, prop)]));
- return temp;
- };
- exports["default"] = function (node, nodes, file, scope, allowedSingleIdent) {
- var obj;
- if (t.isIdentifier(node) && allowedSingleIdent) {
- obj = node;
- } else {
- obj = getObjRef(node, nodes, file, scope);
- }
- var ref, uid;
- if (t.isIdentifier(node)) {
- ref = node;
- uid = obj;
- } else {
- var prop = getPropRef(node, nodes, file, scope);
- var computed = node.computed || t.isLiteral(prop);
- uid = ref = t.memberExpression(obj, prop, computed);
- }
- return {
- uid: uid,
- ref: ref
- };
- };
- ;
- module.exports = exports["default"];
- },{"../../types":169}],63:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- exports["default"] = function (node) {
- var lastNonDefault = 0;
- for (var i = 0; i < node.params.length; i++) {
- if (!t.isAssignmentPattern(node.params[i])) lastNonDefault = i + 1;
- }
- return lastNonDefault;
- };
- ;
- module.exports = exports["default"];
- },{"../../types":169}],64:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- exports["default"] = function (decorators, scope) {
- for (var i = 0; i < decorators.length; i++) {
- var decorator = decorators[i];
- var expression = decorator.expression;
- if (!t.isMemberExpression(expression)) continue;
- var temp = scope.maybeGenerateMemoised(expression.object);
- var ref;
- var nodes = [];
- if (temp) {
- ref = temp;
- nodes.push(t.assignmentExpression("=", temp, expression.object));
- } else {
- ref = expression.object;
- }
- nodes.push(t.callExpression(t.memberExpression(t.memberExpression(ref, expression.property, expression.computed), t.identifier("bind")), [ref]));
- if (nodes.length === 1) {
- decorator.expression = nodes[0];
- } else {
- decorator.expression = t.sequenceExpression(nodes);
- }
- }
- return decorators;
- };
- module.exports = exports["default"];
- },{"../../types":169}],65:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.custom = custom;
- exports.property = property;
- exports.bare = bare;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _getFunctionArity = require("./get-function-arity");
- var _getFunctionArity2 = _interopRequireDefault(_getFunctionArity);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var visitor = {
- enter: function enter(node, parent, scope, state) {
- // check if this node is a referenced identifier that matches the same as our
- // function id
- if (!this.isReferencedIdentifier({ name: state.name })) return;
- // check that we don't have a local variable declared as that removes the need
- // for the wrapper
- var localDeclar = scope.getBindingIdentifier(state.name);
- if (localDeclar !== state.outerDeclar) return;
- state.selfReference = true;
- this.stop();
- }
- };
- var wrap = function wrap(state, method, id, scope) {
- if (state.selfReference) {
- if (scope.hasBinding(id.name)) {
- // we can just munge the local binding
- scope.rename(id.name);
- } else {
- // need to add a wrapper since we can't change the references
- var templateName = "property-method-assignment-wrapper";
- if (method.generator) templateName += "-generator";
- var template = util.template(templateName, {
- FUNCTION: method,
- FUNCTION_ID: id,
- FUNCTION_KEY: scope.generateUidIdentifier(id.name)
- });
- template.callee._skipModulesRemap = true;
- // shim in dummy params to retain function arity, if you try to read the
- // source then you'll get the original since it's proxied so it's all good
- var params = template.callee.body.body[0].params;
- for (var i = 0, len = (0, _getFunctionArity2["default"])(method); i < len; i++) {
- params.push(scope.generateUidIdentifier("x"));
- }
- return template;
- }
- }
- method.id = id;
- };
- var visit = function visit(node, name, scope) {
- var state = {
- selfAssignment: false,
- selfReference: false,
- outerDeclar: scope.getBindingIdentifier(name),
- references: [],
- name: name
- };
- // check to see if we have a local binding of the id we're setting inside of
- // the function, this is important as there are caveats associated
- var bindingInfo = scope.getOwnBindingInfo(name);
- if (bindingInfo) {
- if (bindingInfo.kind === "param") {
- // safari will blow up in strict mode with code like:
- //
- // var t = function t(t) {};
- //
- // with the error:
- //
- // Cannot declare a parameter named 't' as it shadows the name of a
- // strict mode function.
- //
- // this isn't to the spec and they've invented this behaviour which is
- // **extremely** annoying so we avoid setting the name if it has a param
- // with the same id
- state.selfReference = true;
- } else {}
- } else if (state.outerDeclar || scope.hasGlobal(name)) {
- scope.traverse(node, visitor, state);
- }
- return state;
- };
- function custom(node, id, scope) {
- var state = visit(node, id.name, scope);
- return wrap(state, node, id, scope);
- }
- function property(node, file, scope) {
- var key = t.toComputedKey(node, node.key);
- if (!t.isLiteral(key)) return; // we can't set a function id with this
- var name = t.toIdentifier(key.value);
- if (name === "eval" || name === "arguments") name = "_" + name;
- var id = t.identifier(name);
- var method = node.value;
- var state = visit(method, name, scope);
- node.value = wrap(state, method, id, scope) || method;
- }
- function bare(node, parent, scope) {
- // has an `id` so we don't need to infer one
- if (node.id) return;
- var id;
- if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
- // { foo() {} };
- id = parent.key;
- } else if (t.isVariableDeclarator(parent)) {
- // var foo = function () {};
- id = parent.id;
- if (t.isIdentifier(id)) {
- var bindingInfo = scope.parent.getBinding(id.name);
- if (bindingInfo && bindingInfo.constant && scope.getBinding(id.name) === bindingInfo) {
- // always going to reference this method
- node.id = id;
- return;
- }
- }
- } else {
- return;
- }
- var name;
- if (t.isLiteral(id)) {
- name = id.value;
- } else if (t.isIdentifier(id)) {
- name = id.name;
- } else {
- return;
- }
- name = t.toIdentifier(name);
- id = t.identifier(name);
- var state = visit(node, name, scope);
- return wrap(state, node, id, scope);
- }
- // otherwise it's defined somewhere in scope like:
- //
- // var t = function () {
- // var t = 2;
- // };
- //
- // so we can safely just set the id and move along as it shadows the
- // bound function id
- },{"../../types":169,"../../util":173,"./get-function-arity":63}],66:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.isCreateClass = isCreateClass;
- exports.isCompatTag = isCompatTag;
- exports.buildChildren = buildChildren;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangIsString = require("lodash/lang/isString");
- var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
- function isCreateClass(node) {
- if (!node || !t.isCallExpression(node)) return false;
- // not React.createClass call member object
- if (!isCreateClassCallExpression(node.callee)) return false;
- // no call arguments
- var args = node.arguments;
- if (args.length !== 1) return false;
- // first node arg is not an object
- var first = args[0];
- if (!t.isObjectExpression(first)) return false;
- return true;
- }
- var isReactComponent = t.buildMatchMemberExpression("React.Component");
- exports.isReactComponent = isReactComponent;
- function isCompatTag(tagName) {
- return tagName && /^[a-z]|\-/.test(tagName);
- }
- function isStringLiteral(node) {
- return t.isLiteral(node) && (0, _lodashLangIsString2["default"])(node.value);
- }
- function cleanJSXElementLiteralChild(child, args) {
- var lines = child.value.split(/\r\n|\n|\r/);
- var lastNonEmptyLine = 0;
- for (var i = 0; i < lines.length; i++) {
- if (lines[i].match(/[^ \t]/)) {
- lastNonEmptyLine = i;
- }
- }
- var str = "";
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i];
- var isFirstLine = i === 0;
- var isLastLine = i === lines.length - 1;
- var isLastNonEmptyLine = i === lastNonEmptyLine;
- // replace rendered whitespace tabs with spaces
- var trimmedLine = line.replace(/\t/g, " ");
- // trim whitespace touching a newline
- if (!isFirstLine) {
- trimmedLine = trimmedLine.replace(/^[ ]+/, "");
- }
- // trim whitespace touching an endline
- if (!isLastLine) {
- trimmedLine = trimmedLine.replace(/[ ]+$/, "");
- }
- if (trimmedLine) {
- if (!isLastNonEmptyLine) {
- trimmedLine += " ";
- }
- str += trimmedLine;
- }
- }
- if (str) args.push(t.literal(str));
- }
- function buildChildren(node) {
- var elems = [];
- for (var i = 0; i < node.children.length; i++) {
- var child = node.children[i];
- if (t.isLiteral(child) && typeof child.value === "string") {
- cleanJSXElementLiteralChild(child, elems);
- continue;
- }
- if (t.isJSXExpressionContainer(child)) child = child.expression;
- if (t.isJSXEmptyExpression(child)) continue;
- elems.push(child);
- }
- return elems;
- }
- },{"../../types":169,"lodash/lang/isString":414}],67:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.is = is;
- exports.pullFlag = pullFlag;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashArrayPull = require("lodash/array/pull");
- var _lodashArrayPull2 = _interopRequireDefault(_lodashArrayPull);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function is(node, flag) {
- return t.isLiteral(node) && node.regex && node.regex.flags.indexOf(flag) >= 0;
- }
- function pullFlag(node, flag) {
- var flags = node.regex.flags.split("");
- if (node.regex.flags.indexOf(flag) < 0) return;
- (0, _lodashArrayPull2["default"])(flags, flag);
- node.regex.flags = flags.join("");
- }
- },{"../../types":169,"lodash/array/pull":327}],68:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var awaitVisitor = {
- enter: function enter(node, parent, scope, state) {
- if (t.isFunction(node)) this.skip();
- if (t.isAwaitExpression(node)) {
- node.type = "YieldExpression";
- if (node.all) {
- // await* foo; -> yield Promise.all(foo);
- node.all = false;
- node.argument = t.callExpression(t.memberExpression(t.identifier("Promise"), t.identifier("all")), [node.argument]);
- }
- }
- }
- };
- var referenceVisitor = {
- enter: function enter(node, parent, scope, state) {
- var name = state.id.name;
- if (this.isReferencedIdentifier({ name: name }) && scope.bindingIdentifierEquals(name, state.id)) {
- return state.ref = state.ref || scope.generateUidIdentifier(name);
- }
- }
- };
- exports["default"] = function (node, callId, scope) {
- node.async = false;
- node.generator = true;
- scope.traverse(node, awaitVisitor, state);
- var call = t.callExpression(callId, [node]);
- var id = node.id;
- node.id = null;
- if (t.isFunctionDeclaration(node)) {
- var declar = t.variableDeclaration("let", [t.variableDeclarator(id, call)]);
- declar._blockHoist = true;
- return declar;
- } else {
- if (id) {
- var state = { id: id };
- scope.traverse(node, referenceVisitor, state);
- if (state.ref) {
- scope.parent.push({ id: state.ref });
- return t.assignmentExpression("=", state.ref, call);
- }
- }
- return call;
- }
- };
- ;
- module.exports = exports["default"];
- },{"../../types":169}],69:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _messages = require("../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function isIllegalBareSuper(node, parent) {
- if (!t.isSuper(node)) return false;
- if (t.isMemberExpression(parent, { computed: false })) return false;
- if (t.isCallExpression(parent, { callee: node })) return false;
- return true;
- }
- function isMemberExpressionSuper(node) {
- return t.isMemberExpression(node) && t.isSuper(node.object);
- }
- var visitor = {
- enter: function enter(node, parent, scope, state) {
- var topLevel = state.topLevel;
- var self = state.self;
- if (t.isFunction(node) && !t.isArrowFunctionExpression(node)) {
- // we need to call traverseLevel again so we're context aware
- self.traverseLevel(this, false);
- return this.skip();
- }
- if (t.isProperty(node, { method: true }) || t.isMethodDefinition(node)) {
- // break on object methods
- return this.skip();
- }
- var getThisReference = topLevel ?
- // top level so `this` is the instance
- t.thisExpression :
- // not in the top level so we need to create a reference
- self.getThisReference.bind(self);
- var callback = self.specHandle;
- if (self.isLoose) callback = self.looseHandle;
- var result = callback.call(self, this, getThisReference);
- if (result) this.hasSuper = true;
- if (result === true) return;
- return result;
- }
- };
- var ReplaceSupers = (function () {
- /**
- * Description
- */
- function ReplaceSupers(opts) {
- var inClass = arguments[1] === undefined ? false : arguments[1];
- _classCallCheck(this, ReplaceSupers);
- this.topLevelThisReference = opts.topLevelThisReference;
- this.methodPath = opts.methodPath;
- this.methodNode = opts.methodNode;
- this.superRef = opts.superRef;
- this.isStatic = opts.isStatic;
- this.hasSuper = false;
- this.inClass = inClass;
- this.isLoose = opts.isLoose;
- this.scope = opts.scope;
- this.file = opts.file;
- this.opts = opts;
- }
- ReplaceSupers.prototype.getObjectRef = function getObjectRef() {
- return this.opts.objectRef || this.opts.getObjectRef();
- };
- /**
- * Sets a super class value of the named property.
- *
- * @example
- *
- * _set(Object.getPrototypeOf(CLASS.prototype), "METHOD", "VALUE", this)
- *
- */
- ReplaceSupers.prototype.setSuperProperty = function setSuperProperty(property, value, isComputed, thisExpression) {
- return t.callExpression(this.file.addHelper("set"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.getObjectRef() : t.memberExpression(this.getObjectRef(), t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), value, thisExpression]);
- };
- /**
- * Gets a node representing the super class value of the named property.
- *
- * @example
- *
- * _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
- *
- */
- ReplaceSupers.prototype.getSuperProperty = function getSuperProperty(property, isComputed, thisExpression) {
- return t.callExpression(this.file.addHelper("get"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.getObjectRef() : t.memberExpression(this.getObjectRef(), t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), thisExpression]);
- };
- /**
- * Description
- */
- ReplaceSupers.prototype.replace = function replace() {
- this.traverseLevel(this.methodPath.get("value"), true);
- };
- /**
- * Description
- */
- ReplaceSupers.prototype.traverseLevel = function traverseLevel(path, topLevel) {
- var state = { self: this, topLevel: topLevel };
- path.traverse(visitor, state);
- };
- /**
- * Description
- */
- ReplaceSupers.prototype.getThisReference = function getThisReference() {
- if (this.topLevelThisReference) {
- return this.topLevelThisReference;
- } else {
- var ref = this.topLevelThisReference = this.scope.generateUidIdentifier("this");
- this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(this.topLevelThisReference, t.thisExpression())]));
- return ref;
- }
- };
- /**
- * Description
- */
- ReplaceSupers.prototype.getLooseSuperProperty = function getLooseSuperProperty(id, parent) {
- var methodNode = this.methodNode;
- var methodName = methodNode.key;
- var superRef = this.superRef || t.identifier("Function");
- if (parent.property === id) {
- return;
- } else if (t.isCallExpression(parent, { callee: id })) {
- // super(); -> objectRef.prototype.MethodName.call(this);
- parent.arguments.unshift(t.thisExpression());
- if (methodName.name === "constructor") {
- // constructor() { super(); }
- return t.memberExpression(superRef, t.identifier("call"));
- } else {
- id = superRef;
- // foo() { super(); }
- if (!methodNode["static"]) {
- id = t.memberExpression(id, t.identifier("prototype"));
- }
- id = t.memberExpression(id, methodName, methodNode.computed);
- return t.memberExpression(id, t.identifier("call"));
- }
- } else if (t.isMemberExpression(parent) && !methodNode["static"]) {
- // super.test -> objectRef.prototype.test
- return t.memberExpression(superRef, t.identifier("prototype"));
- } else {
- return superRef;
- }
- };
- /**
- * Description
- */
- ReplaceSupers.prototype.looseHandle = function looseHandle(path, getThisReference) {
- var node = path.node;
- if (path.isSuper()) {
- return this.getLooseSuperProperty(node, path.parent);
- } else if (path.isCallExpression()) {
- var callee = node.callee;
- if (!t.isMemberExpression(callee)) return;
- if (!t.isSuper(callee.object)) return;
- // super.test(); -> objectRef.prototype.MethodName.call(this);
- t.appendToMemberExpression(callee, t.identifier("call"));
- node.arguments.unshift(getThisReference());
- return true;
- }
- };
- /**
- * Description
- */
- ReplaceSupers.prototype.specHandleAssignmentExpression = function specHandleAssignmentExpression(ref, path, node, getThisReference) {
- if (node.operator === "=") {
- // super.name = "val"; -> _set(Object.getPrototypeOf(objectRef.prototype), "name", this);
- return this.setSuperProperty(node.left.property, node.right, node.left.computed, getThisReference());
- } else {
- // super.age += 2; -> var _ref = super.age; super.age = _ref + 2;
- ref = ref || path.scope.generateUidIdentifier("ref");
- return [t.variableDeclaration("var", [t.variableDeclarator(ref, node.left)]), t.expressionStatement(t.assignmentExpression("=", node.left, t.binaryExpression(node.operator[0], ref, node.right)))];
- }
- };
- /**
- * Description
- */
- ReplaceSupers.prototype.specHandle = function specHandle(path, getThisReference) {
- var methodNode = this.methodNode;
- var property;
- var computed;
- var args;
- var thisReference;
- var parent = path.parent;
- var node = path.node;
- if (isIllegalBareSuper(node, parent)) {
- throw path.errorWithNode(messages.get("classesIllegalBareSuper"));
- }
- if (t.isCallExpression(node)) {
- var callee = node.callee;
- if (t.isSuper(callee)) {
- // super(); -> _get(Object.getPrototypeOf(objectRef), "MethodName", this).call(this);
- property = methodNode.key;
- computed = methodNode.computed;
- args = node.arguments;
- // bare `super` call is illegal inside non-constructors
- // - https://esdiscuss.org/topic/super-call-in-methods
- // - https://twitter.com/wycats/status/544553184396836864
- if (methodNode.key.name !== "constructor" || !this.inClass) {
- var methodName = methodNode.key.name || "METHOD_NAME";
- throw this.file.errorWithNode(node, messages.get("classesIllegalSuperCall", methodName));
- }
- } else if (isMemberExpressionSuper(callee)) {
- // super.test(); -> _get(Object.getPrototypeOf(objectRef.prototype), "test", this).call(this);
- property = callee.property;
- computed = callee.computed;
- args = node.arguments;
- }
- } else if (t.isMemberExpression(node) && t.isSuper(node.object)) {
- // super.name; -> _get(Object.getPrototypeOf(objectRef.prototype), "name", this);
- property = node.property;
- computed = node.computed;
- } else if (t.isUpdateExpression(node) && isMemberExpressionSuper(node.argument)) {
- var binary = t.binaryExpression(node.operator[0], node.argument, t.literal(1));
- if (node.prefix) {
- // ++super.foo; -> super.foo += 1;
- return this.specHandleAssignmentExpression(null, path, binary, getThisReference);
- } else {
- // super.foo++; -> var _ref = super.foo; super.foo = _ref + 1;
- var ref = path.scope.generateUidIdentifier("ref");
- return this.specHandleAssignmentExpression(ref, path, binary, getThisReference).concat(t.expressionStatement(ref));
- }
- } else if (t.isAssignmentExpression(node) && isMemberExpressionSuper(node.left)) {
- return this.specHandleAssignmentExpression(null, path, node, getThisReference);
- }
- if (!property) return;
- thisReference = getThisReference();
- var superProperty = this.getSuperProperty(property, computed, thisReference);
- if (args) {
- if (args.length === 1 && t.isSpreadElement(args[0])) {
- // super(...arguments);
- return t.callExpression(t.memberExpression(superProperty, t.identifier("apply")), [thisReference, args[0].argument]);
- } else {
- return t.callExpression(t.memberExpression(superProperty, t.identifier("call")), [thisReference].concat(args));
- }
- } else {
- return superProperty;
- }
- };
- return ReplaceSupers;
- })();
- exports["default"] = ReplaceSupers;
- module.exports = exports["default"];
- },{"../../messages":47,"../../types":169}],70:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.has = has;
- exports.wrap = wrap;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function has(node) {
- var first = node.body[0];
- return t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" });
- }
- function wrap(node, callback) {
- var useStrictNode;
- if (has(node)) {
- useStrictNode = node.body.shift();
- }
- callback();
- if (useStrictNode) {
- node.body.unshift(useStrictNode);
- }
- }
- },{"../../types":169}],71:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _transformerPipeline = require("./transformer-pipeline");
- var _transformerPipeline2 = _interopRequireDefault(_transformerPipeline);
- //
- var _transformers = require("./transformers");
- var _transformers2 = _interopRequireDefault(_transformers);
- //
- var _transformersDeprecated = require("./transformers/deprecated");
- var _transformersDeprecated2 = _interopRequireDefault(_transformersDeprecated);
- //
- var _transformersAliases = require("./transformers/aliases");
- var _transformersAliases2 = _interopRequireDefault(_transformersAliases);
- //
- var _transformersFilters = require("./transformers/filters");
- var filters = _interopRequireWildcard(_transformersFilters);
- var pipeline = new _transformerPipeline2["default"]();
- for (var key in _transformers2["default"]) {
- var transformer = _transformers2["default"][key];
- var metadata = transformer.metadata = transformer.metadata || {};
- metadata.group = metadata.group || "builtin-basic";
- }
- pipeline.addTransformers(_transformers2["default"]);
- pipeline.addDeprecated(_transformersDeprecated2["default"]);
- pipeline.addAliases(_transformersAliases2["default"]);
- pipeline.addFilter(filters.internal);
- pipeline.addFilter(filters.blacklist);
- pipeline.addFilter(filters.whitelist);
- pipeline.addFilter(filters.stage);
- pipeline.addFilter(filters.optional);
- //
- var transform = pipeline.transform.bind(pipeline);
- transform.fromAst = pipeline.transformFromAst.bind(pipeline);
- transform.pipeline = pipeline;
- exports["default"] = transform;
- module.exports = exports["default"];
- },{"./transformer-pipeline":84,"./transformers":122,"./transformers/aliases":86,"./transformers/deprecated":87,"./transformers/filters":121}],72:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _messages = require("../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _traversal = require("../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _lodashObjectExtend = require("lodash/object/extend");
- var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
- var _helpersObject = require("../../helpers/object");
- var _helpersObject2 = _interopRequireDefault(_helpersObject);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var remapVisitor = {
- enter: function enter(node, parent, scope, formatter) {
- if (node._skipModulesRemap) {
- return this.skip();
- }
- },
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, formatter) {
- var remap = formatter.internalRemap[node.name];
- if (remap && node !== remap) {
- if (!scope.hasBinding(node.name) || scope.bindingIdentifierEquals(node.name, formatter.localImports[node.name])) {
- if (this.key === "callee" && this.parentPath.isCallExpression()) {
- return t.sequenceExpression([t.literal(0), remap]);
- } else {
- return remap;
- }
- }
- }
- },
- AssignmentExpression: {
- exit: function exit(node, parent, scope, formatter) {
- if (!node._ignoreModulesRemap) {
- var exported = formatter.getExport(node.left, scope);
- if (exported) {
- return formatter.remapExportAssignment(node, exported);
- }
- }
- }
- },
- UpdateExpression: function UpdateExpression(node, parent, scope, formatter) {
- var exported = formatter.getExport(node.argument, scope);
- if (!exported) return;
- this.skip();
- // expand to long file assignment expression
- var assign = t.assignmentExpression(node.operator[0] + "=", node.argument, t.literal(1));
- // remap this assignment expression
- var remapped = formatter.remapExportAssignment(assign, exported);
- // we don't need to change the result
- if (t.isExpressionStatement(parent) || node.prefix) {
- return remapped;
- }
- var nodes = [];
- nodes.push(remapped);
- var operator;
- if (node.operator === "--") {
- operator = "+";
- } else {
- // "++"
- operator = "-";
- }
- nodes.push(t.binaryExpression(operator, node.argument, t.literal(1)));
- return t.sequenceExpression(nodes);
- }
- };
- var importsVisitor = {
- ImportDeclaration: {
- enter: function enter(node, parent, scope, formatter) {
- formatter.hasLocalImports = true;
- (0, _lodashObjectExtend2["default"])(formatter.localImports, this.getBindingIdentifiers());
- }
- }
- };
- var exportsVisitor = {
- ExportDeclaration: {
- enter: function enter(node, parent, scope, formatter) {
- formatter.hasLocalExports = true;
- var declar = this.get("declaration");
- if (declar.isStatement()) {
- var bindings = declar.getBindingIdentifiers();
- for (var name in bindings) {
- var binding = bindings[name];
- formatter._addExport(name, binding);
- }
- }
- if (this.isExportNamedDeclaration() && node.specifiers) {
- for (var i = 0; i < node.specifiers.length; i++) {
- var specifier = node.specifiers[i];
- var local = specifier.local;
- if (!local) continue;
- formatter._addExport(local.name, specifier.exported);
- }
- }
- if (!t.isExportDefaultDeclaration(node)) {
- var onlyDefault = node.specifiers && node.specifiers.length === 1 && t.isSpecifierDefault(node.specifiers[0]);
- if (!onlyDefault) {
- formatter.hasNonDefaultExports = true;
- }
- }
- }
- }
- };
- var DefaultFormatter = (function () {
- function DefaultFormatter(file) {
- _classCallCheck(this, DefaultFormatter);
- this.internalRemap = (0, _helpersObject2["default"])();
- this.defaultIds = (0, _helpersObject2["default"])();
- this.scope = file.scope;
- this.file = file;
- this.ids = (0, _helpersObject2["default"])();
- this.hasNonDefaultExports = false;
- this.hasLocalExports = false;
- this.hasLocalImports = false;
- this.localExports = (0, _helpersObject2["default"])();
- this.localImports = (0, _helpersObject2["default"])();
- this.getLocalExports();
- this.getLocalImports();
- }
- DefaultFormatter.prototype.isModuleType = function isModuleType(node, type) {
- var modules = this.file.dynamicImportTypes[type];
- return modules && modules.indexOf(node) >= 0;
- };
- DefaultFormatter.prototype.transform = function transform() {
- this.remapAssignments();
- };
- DefaultFormatter.prototype.doDefaultExportInterop = function doDefaultExportInterop(node) {
- return (t.isExportDefaultDeclaration(node) || t.isSpecifierDefault(node)) && !this.noInteropRequireExport && !this.hasNonDefaultExports;
- };
- DefaultFormatter.prototype.getLocalExports = function getLocalExports() {
- this.file.path.traverse(exportsVisitor, this);
- };
- DefaultFormatter.prototype.getLocalImports = function getLocalImports() {
- this.file.path.traverse(importsVisitor, this);
- };
- DefaultFormatter.prototype.remapAssignments = function remapAssignments() {
- if (this.hasLocalExports || this.hasLocalImports) {
- this.file.path.traverse(remapVisitor, this);
- }
- };
- DefaultFormatter.prototype.remapExportAssignment = function remapExportAssignment(node, exported) {
- var assign = node;
- for (var i = 0; i < exported.length; i++) {
- assign = t.assignmentExpression("=", t.memberExpression(t.identifier("exports"), exported[i]), assign);
- }
- return assign;
- };
- DefaultFormatter.prototype._addExport = function _addExport(name, exported) {
- var info = this.localExports[name] = this.localExports[name] || {
- binding: this.scope.getBindingIdentifier(name),
- exported: []
- };
- info.exported.push(exported);
- };
- DefaultFormatter.prototype.getExport = function getExport(node, scope) {
- if (!t.isIdentifier(node)) return;
- var local = this.localExports[node.name];
- if (local && local.binding === scope.getBindingIdentifier(node.name)) {
- return local.exported;
- }
- };
- DefaultFormatter.prototype.getModuleName = function getModuleName() {
- var opts = this.file.opts;
- // moduleId is n/a if a `getModuleId()` is provided
- if (opts.moduleId && !opts.getModuleId) {
- return opts.moduleId;
- }
- var filenameRelative = opts.filenameRelative;
- var moduleName = "";
- if (opts.moduleRoot) {
- moduleName = opts.moduleRoot + "/";
- }
- if (!opts.filenameRelative) {
- return moduleName + opts.filename.replace(/^\//, "");
- }
- if (opts.sourceRoot) {
- // remove sourceRoot from filename
- var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "/?");
- filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
- }
- if (!opts.keepModuleIdExtensions) {
- // remove extension
- filenameRelative = filenameRelative.replace(/\.(\w*?)$/, "");
- }
- moduleName += filenameRelative;
- // normalize path separators
- moduleName = moduleName.replace(/\\/g, "/");
- if (opts.getModuleId) {
- // If return is falsy, assume they want us to use our generated default name
- return opts.getModuleId(moduleName) || moduleName;
- } else {
- return moduleName;
- }
- };
- DefaultFormatter.prototype._pushStatement = function _pushStatement(ref, nodes) {
- if (t.isClass(ref) || t.isFunction(ref)) {
- if (ref.id) {
- nodes.push(t.toStatement(ref));
- ref = ref.id;
- }
- }
- return ref;
- };
- DefaultFormatter.prototype._hoistExport = function _hoistExport(declar, assign, priority) {
- if (t.isFunctionDeclaration(declar)) {
- assign._blockHoist = priority || 2;
- }
- return assign;
- };
- DefaultFormatter.prototype.getExternalReference = function getExternalReference(node, nodes) {
- var ids = this.ids;
- var id = node.source.value;
- if (ids[id]) {
- return ids[id];
- } else {
- return this.ids[id] = this._getExternalReference(node, nodes);
- }
- };
- DefaultFormatter.prototype.checkExportIdentifier = function checkExportIdentifier(node) {
- if (t.isIdentifier(node, { name: "__esModule" })) {
- throw this.file.errorWithNode(node, messages.get("modulesIllegalExportName", node.name));
- }
- };
- DefaultFormatter.prototype.exportAllDeclaration = function exportAllDeclaration(node, nodes) {
- var ref = this.getExternalReference(node, nodes);
- nodes.push(this.buildExportsWildcard(ref, node));
- };
- DefaultFormatter.prototype.isLoose = function isLoose() {
- return this.file.isLoose("es6.modules");
- };
- DefaultFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
- if (node.source) {
- var ref = this.getExternalReference(node, nodes);
- if (specifier.local.name === "default" && !this.noInteropRequireExport) {
- // importing a default so we need to normalize it
- ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
- } else {
- ref = t.memberExpression(ref, specifier.local);
- if (!this.isLoose()) {
- nodes.push(this.buildExportsFromAssignment(specifier.exported, ref, node));
- return;
- }
- }
- // export { foo } from "test";
- nodes.push(this.buildExportsAssignment(specifier.exported, ref, node));
- } else {
- // export { foo };
- nodes.push(this.buildExportsAssignment(specifier.exported, specifier.local, node));
- }
- };
- DefaultFormatter.prototype.buildExportsWildcard = function buildExportsWildcard(objectIdentifier) {
- return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [t.identifier("exports"), t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])]));
- };
- DefaultFormatter.prototype.buildExportsFromAssignment = function buildExportsFromAssignment(id, init) {
- this.checkExportIdentifier(id);
- return util.template("exports-from-assign", {
- INIT: init,
- ID: t.literal(id.name)
- }, true);
- };
- DefaultFormatter.prototype.buildExportsAssignment = function buildExportsAssignment(id, init) {
- this.checkExportIdentifier(id);
- return util.template("exports-assign", {
- VALUE: init,
- KEY: id
- }, true);
- };
- DefaultFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
- var declar = node.declaration;
- var id = declar.id;
- if (t.isExportDefaultDeclaration(node)) {
- id = t.identifier("default");
- }
- var assign;
- if (t.isVariableDeclaration(declar)) {
- for (var i = 0; i < declar.declarations.length; i++) {
- var decl = declar.declarations[i];
- decl.init = this.buildExportsAssignment(decl.id, decl.init, node).expression;
- var newDeclar = t.variableDeclaration(declar.kind, [decl]);
- if (i === 0) t.inherits(newDeclar, declar);
- nodes.push(newDeclar);
- }
- } else {
- var ref = declar;
- if (t.isFunctionDeclaration(declar) || t.isClassDeclaration(declar)) {
- ref = declar.id;
- nodes.push(declar);
- }
- assign = this.buildExportsAssignment(id, ref, node);
- nodes.push(assign);
- this._hoistExport(declar, assign);
- }
- };
- return DefaultFormatter;
- })();
- exports["default"] = DefaultFormatter;
- module.exports = exports["default"];
- },{"../../helpers/object":45,"../../messages":47,"../../traversal":157,"../../types":169,"../../util":173,"lodash/object/extend":419}],73:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- exports["default"] = function (Parent) {
- var Constructor = function Constructor() {
- this.noInteropRequireImport = true;
- this.noInteropRequireExport = true;
- Parent.apply(this, arguments);
- };
- util.inherits(Constructor, Parent);
- return Constructor;
- };
- ;
- module.exports = exports["default"];
- },{"../../util":173}],74:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _amd = require("./amd");
- var _amd2 = _interopRequireDefault(_amd);
- var _strict = require("./_strict");
- var _strict2 = _interopRequireDefault(_strict);
- exports["default"] = (0, _strict2["default"])(_amd2["default"]);
- module.exports = exports["default"];
- },{"./_strict":73,"./amd":75}],75:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
- var _default = require("./_default");
- var _default2 = _interopRequireDefault(_default);
- var _common = require("./common");
- var _common2 = _interopRequireDefault(_common);
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _lodashObjectValues = require("lodash/object/values");
- var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var AMDFormatter = (function (_DefaultFormatter) {
- function AMDFormatter() {
- _classCallCheck(this, AMDFormatter);
- if (_DefaultFormatter != null) {
- _DefaultFormatter.apply(this, arguments);
- }
- }
- _inherits(AMDFormatter, _DefaultFormatter);
- AMDFormatter.prototype.setup = function setup() {
- _common2["default"].prototype._setup.call(this, this.hasNonDefaultExports);
- };
- AMDFormatter.prototype.buildDependencyLiterals = function buildDependencyLiterals() {
- var names = [];
- for (var name in this.ids) {
- names.push(t.literal(name));
- }
- return names;
- };
- /**
- * Wrap the entire body in a `define` wrapper.
- */
- AMDFormatter.prototype.transform = function transform(program) {
- _common2["default"].prototype.transform.apply(this, arguments);
- var body = program.body;
- // build an array of module names
- var names = [t.literal("exports")];
- if (this.passModuleArg) names.push(t.literal("module"));
- names = names.concat(this.buildDependencyLiterals());
- names = t.arrayExpression(names);
- // build up define container
- var params = (0, _lodashObjectValues2["default"])(this.ids);
- if (this.passModuleArg) params.unshift(t.identifier("module"));
- params.unshift(t.identifier("exports"));
- var container = t.functionExpression(null, params, t.blockStatement(body));
- var defineArgs = [names, container];
- var moduleName = this.getModuleName();
- if (moduleName) defineArgs.unshift(t.literal(moduleName));
- var call = t.callExpression(t.identifier("define"), defineArgs);
- program.body = [t.expressionStatement(call)];
- };
- /**
- * Get the AMD module name that we'll prepend to the wrapper
- * to define this module
- */
- AMDFormatter.prototype.getModuleName = function getModuleName() {
- if (this.file.opts.moduleIds) {
- return _default2["default"].prototype.getModuleName.apply(this, arguments);
- } else {
- return null;
- }
- };
- AMDFormatter.prototype._getExternalReference = function _getExternalReference(node) {
- return this.scope.generateUidIdentifier(node.source.value);
- };
- AMDFormatter.prototype.importDeclaration = function importDeclaration(node) {
- this.getExternalReference(node);
- };
- AMDFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
- var key = node.source.value;
- var ref = this.getExternalReference(node);
- if (t.isImportNamespaceSpecifier(specifier) || t.isImportDefaultSpecifier(specifier)) {
- this.defaultIds[key] = specifier.local;
- }
- if (this.isModuleType(node, "absolute")) {} else if (this.isModuleType(node, "absoluteDefault")) {
- // prevent unnecessary renaming of dynamic imports
- this.ids[node.source.value] = ref;
- ref = t.memberExpression(ref, t.identifier("default"));
- } else if (t.isImportNamespaceSpecifier(specifier)) {} else if (!(0, _lodashCollectionIncludes2["default"])(this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
- // import foo from "foo";
- var uid = this.scope.generateUidIdentifier(specifier.local.name);
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require"), [ref]))]));
- ref = uid;
- } else {
- // import { foo } from "foo";
- var imported = specifier.imported;
- if (t.isSpecifierDefault(specifier)) imported = t.identifier("default");
- ref = t.memberExpression(ref, imported);
- }
- this.internalRemap[specifier.local.name] = ref;
- };
- AMDFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
- if (this.doDefaultExportInterop(specifier)) {
- this.passModuleArg = true;
- if (specifier.exported !== specifier.local && !node.source) {
- nodes.push(util.template("exports-default-assign", {
- VALUE: specifier.local
- }, true));
- return;
- }
- }
- _common2["default"].prototype.exportSpecifier.apply(this, arguments);
- };
- AMDFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
- if (this.doDefaultExportInterop(node)) {
- this.passModuleArg = true;
- var declar = node.declaration;
- var assign = util.template("exports-default-assign", {
- VALUE: this._pushStatement(declar, nodes)
- }, true);
- if (t.isFunctionDeclaration(declar)) {
- // we can hoist this assignment to the top of the file
- assign._blockHoist = 3;
- }
- nodes.push(assign);
- return;
- }
- _default2["default"].prototype.exportDeclaration.apply(this, arguments);
- };
- return AMDFormatter;
- })(_default2["default"]);
- exports["default"] = AMDFormatter;
- module.exports = exports["default"];
- // absolute module reference
- // import * as bar from "foo";
- },{"../../types":169,"../../util":173,"./_default":72,"./common":77,"lodash/collection/includes":332,"lodash/object/values":424}],76:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _common = require("./common");
- var _common2 = _interopRequireDefault(_common);
- var _strict = require("./_strict");
- var _strict2 = _interopRequireDefault(_strict);
- exports["default"] = (0, _strict2["default"])(_common2["default"]);
- module.exports = exports["default"];
- },{"./_strict":73,"./common":77}],77:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
- var _default = require("./_default");
- var _default2 = _interopRequireDefault(_default);
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var CommonJSFormatter = (function (_DefaultFormatter) {
- function CommonJSFormatter() {
- _classCallCheck(this, CommonJSFormatter);
- if (_DefaultFormatter != null) {
- _DefaultFormatter.apply(this, arguments);
- }
- }
- _inherits(CommonJSFormatter, _DefaultFormatter);
- CommonJSFormatter.prototype.setup = function setup() {
- this._setup(this.hasLocalExports);
- };
- CommonJSFormatter.prototype._setup = function _setup(conditional) {
- var file = this.file;
- var scope = file.scope;
- scope.rename("module");
- scope.rename("exports");
- if (!this.noInteropRequireImport && conditional) {
- var templateName = "exports-module-declaration";
- if (this.file.isLoose("es6.modules")) templateName += "-loose";
- var declar = util.template(templateName, true);
- declar._blockHoist = 3;
- file.path.unshiftContainer("body", [declar]);
- }
- };
- CommonJSFormatter.prototype.transform = function transform(program) {
- _default2["default"].prototype.transform.apply(this, arguments);
- if (this.hasDefaultOnlyExport) {
- program.body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("module"), t.identifier("exports")), t.memberExpression(t.identifier("exports"), t.identifier("default")))));
- }
- };
- CommonJSFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
- var variableName = specifier.local;
- var ref = this.getExternalReference(node, nodes);
- // import foo from "foo";
- if (t.isSpecifierDefault(specifier)) {
- if (this.isModuleType(node, "absolute")) {} else if (this.isModuleType(node, "absoluteDefault")) {
- this.internalRemap[variableName.name] = ref;
- } else if (this.noInteropRequireImport) {
- this.internalRemap[variableName.name] = t.memberExpression(ref, t.identifier("default"));
- } else {
- var uid = this.scope.generateUidIdentifierBasedOnNode(node, "import");
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require-default"), [ref]))]));
- this.internalRemap[variableName.name] = t.memberExpression(uid, t.identifier("default"));
- }
- } else {
- if (t.isImportNamespaceSpecifier(specifier)) {
- if (!this.noInteropRequireImport) {
- ref = t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]);
- }
- // import * as bar from "foo";
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, ref)]));
- } else {
- // import { foo } from "foo";
- this.internalRemap[variableName.name] = t.memberExpression(ref, specifier.imported);
- }
- }
- };
- CommonJSFormatter.prototype.importDeclaration = function importDeclaration(node, nodes) {
- // import "foo";
- nodes.push(util.template("require", {
- MODULE_NAME: node.source
- }, true));
- };
- CommonJSFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
- if (this.doDefaultExportInterop(specifier)) {
- this.hasDefaultOnlyExport = true;
- }
- _default2["default"].prototype.exportSpecifier.apply(this, arguments);
- };
- CommonJSFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
- if (this.doDefaultExportInterop(node)) {
- this.hasDefaultOnlyExport = true;
- }
- _default2["default"].prototype.exportDeclaration.apply(this, arguments);
- };
- CommonJSFormatter.prototype._getExternalReference = function _getExternalReference(node, nodes) {
- var source = node.source.value;
- var call = t.callExpression(t.identifier("require"), [node.source]);
- var uid;
- if (this.isModuleType(node, "absolute")) {} else if (this.isModuleType(node, "absoluteDefault")) {
- call = t.memberExpression(call, t.identifier("default"));
- } else {
- uid = this.scope.generateUidIdentifierBasedOnNode(node, "import");
- }
- uid = uid || node.specifiers[0].local;
- var declar = t.variableDeclaration("var", [t.variableDeclarator(uid, call)]);
- nodes.push(declar);
- return uid;
- };
- return CommonJSFormatter;
- })(_default2["default"]);
- exports["default"] = CommonJSFormatter;
- module.exports = exports["default"];
- // absolute module reference
- // absolute module reference
- },{"../../types":169,"../../util":173,"./_default":72,"lodash/collection/includes":332}],78:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var IgnoreFormatter = (function () {
- function IgnoreFormatter() {
- _classCallCheck(this, IgnoreFormatter);
- }
- IgnoreFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
- var declar = t.toStatement(node.declaration, true);
- if (declar) nodes.push(t.inherits(declar, node));
- };
- IgnoreFormatter.prototype.exportAllDeclaration = function exportAllDeclaration() {};
- IgnoreFormatter.prototype.importDeclaration = function importDeclaration() {};
- IgnoreFormatter.prototype.importSpecifier = function importSpecifier() {};
- IgnoreFormatter.prototype.exportSpecifier = function exportSpecifier() {};
- return IgnoreFormatter;
- })();
- exports["default"] = IgnoreFormatter;
- module.exports = exports["default"];
- },{"../../types":169}],79:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports["default"] = {
- commonStrict: require("./common-strict"),
- amdStrict: require("./amd-strict"),
- umdStrict: require("./umd-strict"),
- common: require("./common"),
- system: require("./system"),
- ignore: require("./ignore"),
- amd: require("./amd"),
- umd: require("./umd")
- };
- module.exports = exports["default"];
- },{"./amd":75,"./amd-strict":74,"./common":77,"./common-strict":76,"./ignore":78,"./system":80,"./umd":82,"./umd-strict":81}],80:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
- var _default = require("./_default");
- var _default2 = _interopRequireDefault(_default);
- var _amd = require("./amd");
- var _amd2 = _interopRequireDefault(_amd);
- var _helpersObject = require("../../helpers/object");
- var _helpersObject2 = _interopRequireDefault(_helpersObject);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var _lodashArrayLast = require("lodash/array/last");
- var _lodashArrayLast2 = _interopRequireDefault(_lodashArrayLast);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _lodashCollectionMap = require("lodash/collection/map");
- var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var hoistVariablesVisitor = {
- enter: function enter(node, parent, scope, state) {
- if (t.isFunction(node)) {
- // nothing inside is accessible
- return this.skip();
- }
- if (t.isVariableDeclaration(node)) {
- if (node.kind !== "var" && !t.isProgram(parent)) {
- // let, const
- // can't be accessed
- return;
- }
- // ignore block hoisted nodes as these can be left in
- if (state.formatter._canHoist(node)) return;
- var nodes = [];
- for (var i = 0; i < node.declarations.length; i++) {
- var declar = node.declarations[i];
- state.hoistDeclarators.push(t.variableDeclarator(declar.id));
- if (declar.init) {
- // no initializer so we can just hoist it as-is
- var assign = t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init));
- nodes.push(assign);
- }
- }
- // for (var i in test)
- // for (var i = 0;;)
- if (t.isFor(parent) && parent.left === node) {
- return node.declarations[0].id;
- }
- return nodes;
- }
- }
- };
- var hoistFunctionsVisitor = {
- enter: function enter(node, parent, scope, state) {
- if (t.isFunction(node)) this.skip();
- if (t.isFunctionDeclaration(node) || state.formatter._canHoist(node)) {
- state.handlerBody.push(node);
- this.remove();
- }
- }
- };
- var runnerSettersVisitor = {
- enter: function enter(node, parent, scope, state) {
- if (node._importSource === state.source) {
- if (t.isVariableDeclaration(node)) {
- var _arr = node.declarations;
- for (var _i = 0; _i < _arr.length; _i++) {
- var declar = _arr[_i];
- state.hoistDeclarators.push(t.variableDeclarator(declar.id));
- state.nodes.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
- }
- } else {
- state.nodes.push(node);
- }
- this.remove();
- }
- }
- };
- var SystemFormatter = (function (_AMDFormatter) {
- function SystemFormatter(file) {
- _classCallCheck(this, SystemFormatter);
- _AMDFormatter.call(this, file);
- this.exportIdentifier = file.scope.generateUidIdentifier("export");
- this.noInteropRequireExport = true;
- this.noInteropRequireImport = true;
- }
- _inherits(SystemFormatter, _AMDFormatter);
- SystemFormatter.prototype._addImportSource = function _addImportSource(node, exportNode) {
- if (node) node._importSource = exportNode.source && exportNode.source.value;
- return node;
- };
- SystemFormatter.prototype.buildExportsWildcard = function buildExportsWildcard(objectIdentifier, node) {
- var leftIdentifier = this.scope.generateUidIdentifier("key");
- var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
- var left = t.variableDeclaration("var", [t.variableDeclarator(leftIdentifier)]);
- var right = objectIdentifier;
- var block = t.blockStatement([t.expressionStatement(this._buildExportCall(leftIdentifier, valIdentifier))]);
- return this._addImportSource(t.forInStatement(left, right, block), node);
- };
- SystemFormatter.prototype.buildExportsAssignment = function buildExportsAssignment(id, init, node) {
- var call = this._buildExportCall(t.literal(id.name), init, true);
- return this._addImportSource(call, node);
- };
- SystemFormatter.prototype.buildExportsFromAssignment = function buildExportsFromAssignment() {
- return this.buildExportsAssignment.apply(this, arguments);
- };
- SystemFormatter.prototype.remapExportAssignment = function remapExportAssignment(node, exported) {
- var assign = node;
- for (var i = 0; i < exported.length; i++) {
- assign = this._buildExportCall(t.literal(exported[i].name), assign);
- }
- return assign;
- };
- SystemFormatter.prototype._buildExportCall = function _buildExportCall(id, init, isStatement) {
- var call = t.callExpression(this.exportIdentifier, [id, init]);
- if (isStatement) {
- return t.expressionStatement(call);
- } else {
- return call;
- }
- };
- SystemFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
- _amd2["default"].prototype.importSpecifier.apply(this, arguments);
- for (var name in this.internalRemap) {
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(t.identifier(name), this.internalRemap[name])]));
- }
- this.internalRemap = (0, _helpersObject2["default"])();
- this._addImportSource((0, _lodashArrayLast2["default"])(nodes), node);
- };
- SystemFormatter.prototype._buildRunnerSetters = function _buildRunnerSetters(block, hoistDeclarators) {
- var scope = this.file.scope;
- return t.arrayExpression((0, _lodashCollectionMap2["default"])(this.ids, function (uid, source) {
- var state = {
- hoistDeclarators: hoistDeclarators,
- source: source,
- nodes: []
- };
- scope.traverse(block, runnerSettersVisitor, state);
- return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
- }));
- };
- SystemFormatter.prototype._canHoist = function _canHoist(node) {
- return node._blockHoist && !this.file.dynamicImports.length;
- };
- SystemFormatter.prototype.transform = function transform(program) {
- _default2["default"].prototype.transform.apply(this, arguments);
- var hoistDeclarators = [];
- var moduleName = this.getModuleName();
- var moduleNameLiteral = t.literal(moduleName);
- var block = t.blockStatement(program.body);
- var runner = util.template("system", {
- MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
- EXPORT_IDENTIFIER: this.exportIdentifier,
- MODULE_NAME: moduleNameLiteral,
- SETTERS: this._buildRunnerSetters(block, hoistDeclarators),
- EXECUTE: t.functionExpression(null, [], block)
- }, true);
- var handlerBody = runner.expression.arguments[2].body.body;
- if (!moduleName) runner.expression.arguments.shift();
- var returnStatement = handlerBody.pop();
- // hoist up all variable declarations
- this.file.scope.traverse(block, hoistVariablesVisitor, {
- formatter: this,
- hoistDeclarators: hoistDeclarators
- });
- if (hoistDeclarators.length) {
- var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
- hoistDeclar._blockHoist = true;
- handlerBody.unshift(hoistDeclar);
- }
- // hoist up function declarations for circular references
- this.file.scope.traverse(block, hoistFunctionsVisitor, {
- formatter: this,
- handlerBody: handlerBody
- });
- handlerBody.push(returnStatement);
- program.body = [runner];
- };
- return SystemFormatter;
- })(_amd2["default"]);
- exports["default"] = SystemFormatter;
- module.exports = exports["default"];
- },{"../../helpers/object":45,"../../types":169,"../../util":173,"./_default":72,"./amd":75,"lodash/array/last":326,"lodash/collection/each":330,"lodash/collection/map":333}],81:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _umd = require("./umd");
- var _umd2 = _interopRequireDefault(_umd);
- var _strict = require("./_strict");
- var _strict2 = _interopRequireDefault(_strict);
- exports["default"] = (0, _strict2["default"])(_umd2["default"]);
- module.exports = exports["default"];
- },{"./_strict":73,"./umd":82}],82:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
- var _default = require("./_default");
- var _default2 = _interopRequireDefault(_default);
- var _amd = require("./amd");
- var _amd2 = _interopRequireDefault(_amd);
- var _lodashObjectValues = require("lodash/object/values");
- var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
- var _path = require("path");
- var _path2 = _interopRequireDefault(_path);
- var _util = require("../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var UMDFormatter = (function (_AMDFormatter) {
- function UMDFormatter() {
- _classCallCheck(this, UMDFormatter);
- if (_AMDFormatter != null) {
- _AMDFormatter.apply(this, arguments);
- }
- }
- _inherits(UMDFormatter, _AMDFormatter);
- UMDFormatter.prototype.transform = function transform(program) {
- _default2["default"].prototype.transform.apply(this, arguments);
- var body = program.body;
- // build an array of module names
- var names = [];
- for (var _name in this.ids) {
- names.push(t.literal(_name));
- }
- // factory
- var ids = (0, _lodashObjectValues2["default"])(this.ids);
- var args = [t.identifier("exports")];
- if (this.passModuleArg) args.push(t.identifier("module"));
- args = args.concat(ids);
- var factory = t.functionExpression(null, args, t.blockStatement(body));
- // amd
- var defineArgs = [t.literal("exports")];
- if (this.passModuleArg) defineArgs.push(t.literal("module"));
- defineArgs = defineArgs.concat(names);
- defineArgs = [t.arrayExpression(defineArgs)];
- // common
- var testExports = util.template("test-exports");
- var testModule = util.template("test-module");
- var commonTests = this.passModuleArg ? t.logicalExpression("&&", testExports, testModule) : testExports;
- var commonArgs = [t.identifier("exports")];
- if (this.passModuleArg) commonArgs.push(t.identifier("module"));
- commonArgs = commonArgs.concat(names.map(function (name) {
- return t.callExpression(t.identifier("require"), [name]);
- }));
- // globals
- var browserArgs = [];
- if (this.passModuleArg) browserArgs.push(t.identifier("mod"));
- for (var _name2 in this.ids) {
- var id = this.defaultIds[_name2] || t.identifier(t.toIdentifier(_path2["default"].basename(_name2, _path2["default"].extname(_name2))));
- browserArgs.push(t.memberExpression(t.identifier("global"), id));
- }
- //
- var moduleName = this.getModuleName();
- if (moduleName) defineArgs.unshift(t.literal(moduleName));
- //
- var globalArg = this.file.opts.basename;
- if (moduleName) globalArg = moduleName;
- globalArg = t.identifier(t.toIdentifier(globalArg));
- var runner = util.template("umd-runner-body", {
- AMD_ARGUMENTS: defineArgs,
- COMMON_TEST: commonTests,
- COMMON_ARGUMENTS: commonArgs,
- BROWSER_ARGUMENTS: browserArgs,
- GLOBAL_ARG: globalArg
- });
- //
- program.body = [t.expressionStatement(t.callExpression(runner, [t.thisExpression(), factory]))];
- };
- return UMDFormatter;
- })(_amd2["default"]);
- exports["default"] = UMDFormatter;
- module.exports = exports["default"];
- },{"../../types":169,"../../util":173,"./_default":72,"./amd":75,"lodash/object/values":424,"path":199}],83:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _traversal = require("../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- /**
- * This class is responsible for traversing over the provided `File`s
- * AST and running it's parent transformers handlers over it.
- */
- var TransformerPass = (function () {
- function TransformerPass(file, transformer) {
- _classCallCheck(this, TransformerPass);
- this.transformer = transformer;
- this.handlers = transformer.handlers;
- this.file = file;
- this.ran = false;
- this.key = transformer.key;
- }
- TransformerPass.prototype.canTransform = function canTransform() {
- return this.file.transformerDependencies[this.key] || this.file.pipeline.canTransform(this.transformer, this.file.opts);
- };
- TransformerPass.prototype.transform = function transform() {
- var file = this.file;
- file.log.debug("Start transformer " + this.key);
- (0, _traversal2["default"])(file.ast, this.handlers, file.scope, file);
- file.log.debug("Finish transformer " + this.key);
- this.ran = true;
- };
- return TransformerPass;
- })();
- exports["default"] = TransformerPass;
- module.exports = exports["default"];
- },{"../traversal":157,"lodash/collection/includes":332}],84:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _transformer = require("./transformer");
- var _transformer2 = _interopRequireDefault(_transformer);
- var _helpersNormalizeAst = require("../helpers/normalize-ast");
- var _helpersNormalizeAst2 = _interopRequireDefault(_helpersNormalizeAst);
- var _lodashObjectAssign = require("lodash/object/assign");
- var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
- var _helpersObject = require("../helpers/object");
- var _helpersObject2 = _interopRequireDefault(_helpersObject);
- var _file = require("./file");
- var _file2 = _interopRequireDefault(_file);
- var TransformerPipeline = (function () {
- function TransformerPipeline() {
- _classCallCheck(this, TransformerPipeline);
- this.transformers = (0, _helpersObject2["default"])();
- this.namespaces = (0, _helpersObject2["default"])();
- this.deprecated = (0, _helpersObject2["default"])();
- this.aliases = (0, _helpersObject2["default"])();
- this.filters = [];
- }
- TransformerPipeline.prototype.addTransformers = function addTransformers(transformers) {
- for (var key in transformers) {
- this.addTransformer(key, transformers[key]);
- }
- return this;
- };
- TransformerPipeline.prototype.addTransformer = function addTransformer(key, transformer) {
- if (this.transformers[key]) throw new Error(); // todo: error
- var namespace = key.split(".")[0];
- this.namespaces[namespace] = this.namespaces[namespace] || [];
- this.namespaces[namespace].push(key);
- this.namespaces[key] = namespace;
- this.transformers[key] = new _transformer2["default"](key, transformer);
- };
- TransformerPipeline.prototype.addAliases = function addAliases(names) {
- (0, _lodashObjectAssign2["default"])(this.aliases, names);
- return this;
- };
- TransformerPipeline.prototype.addDeprecated = function addDeprecated(names) {
- (0, _lodashObjectAssign2["default"])(this.deprecated, names);
- return this;
- };
- TransformerPipeline.prototype.addFilter = function addFilter(filter) {
- this.filters.push(filter);
- return this;
- };
- TransformerPipeline.prototype.canTransform = function canTransform(transformer, fileOpts) {
- if (transformer.metadata.plugin) return true;
- var _arr = this.filters;
- for (var _i = 0; _i < _arr.length; _i++) {
- var filter = _arr[_i];
- var result = filter(transformer, fileOpts);
- if (result != null) return result;
- }
- return true;
- };
- TransformerPipeline.prototype.transform = function transform(code, opts) {
- var file = new _file2["default"](opts, this);
- return file.wrap(code, function () {
- file.addCode(code, true);
- });
- };
- TransformerPipeline.prototype.transformFromAst = function transformFromAst(ast, code, opts) {
- ast = (0, _helpersNormalizeAst2["default"])(ast);
- var file = new _file2["default"](opts, this);
- return file.wrap(code, function () {
- file.addCode(code);
- file.addAst(ast);
- });
- };
- TransformerPipeline.prototype._ensureTransformerNames = function _ensureTransformerNames(type, rawKeys) {
- var keys = [];
- for (var i = 0; i < rawKeys.length; i++) {
- var key = rawKeys[i];
- var deprecatedKey = this.deprecated[key];
- var aliasKey = this.aliases[key];
- if (aliasKey) {
- keys.push(aliasKey);
- } else if (deprecatedKey) {
- // deprecated key, remap it to the new one
- console.error("[BABEL] The transformer " + key + " has been renamed to " + deprecatedKey);
- rawKeys.push(deprecatedKey);
- } else if (this.transformers[key]) {
- // valid key
- keys.push(key);
- } else if (this.namespaces[key]) {
- // namespace, append all transformers within this namespace
- keys = keys.concat(this.namespaces[key]);
- } else {
- // invalid key
- throw new ReferenceError("Unknown transformer " + key + " specified in " + type);
- }
- }
- return keys;
- };
- return TransformerPipeline;
- })();
- exports["default"] = TransformerPipeline;
- module.exports = exports["default"];
- },{"../helpers/normalize-ast":44,"../helpers/object":45,"./file":52,"./transformer":85,"lodash/object/assign":417}],85:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _transformerPass = require("./transformer-pass");
- var _transformerPass2 = _interopRequireDefault(_transformerPass);
- var _messages = require("../messages");
- var messages = _interopRequireWildcard(_messages);
- var _lodashLangIsFunction = require("lodash/lang/isFunction");
- var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
- var _traversal = require("../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _lodashLangIsObject = require("lodash/lang/isObject");
- var _lodashLangIsObject2 = _interopRequireDefault(_lodashLangIsObject);
- var _lodashObjectAssign = require("lodash/object/assign");
- var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
- var _acorn = require("../../acorn");
- var acorn = _interopRequireWildcard(_acorn);
- var _file = require("./file");
- var _file2 = _interopRequireDefault(_file);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- /**
- * This is the class responsible for normalising a transformers handlers
- * as well as constructing a `TransformerPass` that is responsible for
- * actually running the transformer over the provided `File`.
- */
- var Transformer = (function () {
- function Transformer(transformerKey, transformer) {
- _classCallCheck(this, Transformer);
- transformer = (0, _lodashObjectAssign2["default"])({}, transformer);
- var take = function take(key) {
- var val = transformer[key];
- delete transformer[key];
- return val;
- };
- this.manipulateOptions = take("manipulateOptions");
- this.metadata = take("metadata") || {};
- this.dependencies = this.metadata.dependencies || [];
- this.parser = take("parser");
- this.post = take("post");
- this.pre = take("pre");
- //
- if (this.metadata.stage != null) {
- this.metadata.optional = true;
- }
- //
- this.handlers = this.normalize(transformer);
- this.key = transformerKey;
- }
- Transformer.prototype.normalize = function normalize(transformer) {
- var _this = this;
- if ((0, _lodashLangIsFunction2["default"])(transformer)) {
- transformer = { ast: transformer };
- }
- _traversal2["default"].explode(transformer);
- (0, _lodashCollectionEach2["default"])(transformer, function (fns, type) {
- // hidden property
- if (type[0] === "_") {
- _this[type] = fns;
- return;
- }
- if (type === "enter" || type === "exit") return;
- if ((0, _lodashLangIsFunction2["default"])(fns)) fns = { enter: fns };
- if (!(0, _lodashLangIsObject2["default"])(fns)) return;
- if (!fns.enter) fns.enter = function () {};
- if (!fns.exit) fns.exit = function () {};
- transformer[type] = fns;
- });
- return transformer;
- };
- Transformer.prototype.buildPass = function buildPass(file) {
- // validate Transformer instance
- if (!(file instanceof _file2["default"])) {
- throw new TypeError(messages.get("transformerNotFile", this.key));
- }
- return new _transformerPass2["default"](file, this);
- };
- return Transformer;
- })();
- exports["default"] = Transformer;
- module.exports = exports["default"];
- },{"../../acorn":1,"../messages":47,"../traversal":157,"./file":52,"./transformer-pass":83,"lodash/collection/each":330,"lodash/lang/isFunction":408,"lodash/lang/isObject":411,"lodash/object/assign":417}],86:[function(require,module,exports){
- module.exports={
- "useStrict": "strict",
- "es5.runtime": "runtime",
- "es6.runtime": "runtime"
- }
- },{}],87:[function(require,module,exports){
- module.exports={
- "selfContained": "runtime",
- "unicode-regex": "regex.unicode",
- "spec.typeofSymbol": "es6.spec.symbols",
- "es6.symbols": "es6.spec.symbols",
- "es6.blockScopingTDZ": "es6.spec.blockScoping",
- "utility.inlineExpressions": "minification.inlineExpressions",
- "utility.deadCodeElimination": "minification.deadCodeElimination",
- "utility.removeConsoleCalls": "minification.removeConsole",
- "utility.removeDebugger": "minification.removeDebugger"
- }
- },{}],88:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-trailing"
- };
- exports.metadata = metadata;
- var MemberExpression = {
- exit: function exit(node) {
- var prop = node.property;
- if (!node.computed && t.isIdentifier(prop) && !t.isValidIdentifier(prop.name)) {
- // foo.default -> foo["default"]
- node.property = t.literal(prop.name);
- node.computed = true;
- }
- }
- };
- exports.MemberExpression = MemberExpression;
- },{"../../../types":169}],89:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-trailing"
- };
- exports.metadata = metadata;
- var Property = {
- exit: function exit(node) {
- var key = node.key;
- if (!node.computed && t.isIdentifier(key) && !t.isValidIdentifier(key.name)) {
- // default: "bar" -> "default": "bar"
- node.key = t.literal(key.name);
- }
- }
- };
- exports.Property = Property;
- },{"../../../types":169}],90:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ObjectExpression = ObjectExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _helpersDefineMap = require("../../helpers/define-map");
- var defineMap = _interopRequireWildcard(_helpersDefineMap);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function ObjectExpression(node, parent, scope, file) {
- var mutatorMap = {};
- var hasAny = false;
- node.properties = node.properties.filter(function (prop) {
- if (prop.kind === "get" || prop.kind === "set") {
- hasAny = true;
- defineMap.push(mutatorMap, prop, prop.kind, file);
- return false;
- } else {
- return true;
- }
- });
- if (!hasAny) return;
- return t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")), [node, defineMap.toDefineObject(mutatorMap)]);
- }
- },{"../../../types":169,"../../helpers/define-map":61}],91:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ArrowFunctionExpression = ArrowFunctionExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function ArrowFunctionExpression(node) {
- t.ensureBlock(node);
- node.expression = false;
- node.type = "FunctionExpression";
- node.shadow = true;
- }
- },{"../../../types":169}],92:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.VariableDeclaration = VariableDeclaration;
- exports.Loop = Loop;
- exports.BlockStatement = BlockStatement;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _traversal = require("../../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _helpersObject = require("../../../helpers/object");
- var _helpersObject2 = _interopRequireDefault(_helpersObject);
- var _util = require("../../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var _lodashObjectValues = require("lodash/object/values");
- var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
- var _lodashObjectExtend = require("lodash/object/extend");
- var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
- function isLet(node, parent) {
- if (!t.isVariableDeclaration(node)) return false;
- if (node._let) return true;
- if (node.kind !== "let") return false;
- // https://github.com/babel/babel/issues/255
- if (isLetInitable(node, parent)) {
- for (var i = 0; i < node.declarations.length; i++) {
- var declar = node.declarations[i];
- declar.init = declar.init || t.identifier("undefined");
- }
- }
- node._let = true;
- node.kind = "var";
- return true;
- }
- function isLetInitable(node, parent) {
- return !t.isFor(parent) || !t.isFor(parent, { left: node });
- }
- function isVar(node, parent) {
- return t.isVariableDeclaration(node, { kind: "var" }) && !isLet(node, parent);
- }
- function standardizeLets(declars) {
- var _arr = declars;
- for (var _i = 0; _i < _arr.length; _i++) {
- var declar = _arr[_i];
- delete declar._let;
- }
- }
- var metadata = {
- group: "builtin-advanced"
- };
- exports.metadata = metadata;
- function VariableDeclaration(node, parent, scope, file) {
- if (!isLet(node, parent)) return;
- if (isLetInitable(node) && file.transformers["es6.spec.blockScoping"].canTransform()) {
- var nodes = [node];
- for (var i = 0; i < node.declarations.length; i++) {
- var decl = node.declarations[i];
- if (decl.init) {
- var assign = t.assignmentExpression("=", decl.id, decl.init);
- assign._ignoreBlockScopingTDZ = true;
- nodes.push(t.expressionStatement(assign));
- }
- decl.init = file.addHelper("temporal-undefined");
- }
- node._blockHoist = 2;
- return nodes;
- }
- }
- function Loop(node, parent, scope, file) {
- var init = node.left || node.init;
- if (isLet(init, node)) {
- t.ensureBlock(node);
- node.body._letDeclarators = [init];
- }
- var blockScoping = new BlockScoping(this, this.get("body"), parent, scope, file);
- return blockScoping.run();
- }
- function BlockStatement(block, parent, scope, file) {
- if (!t.isLoop(parent)) {
- var blockScoping = new BlockScoping(null, this, parent, scope, file);
- blockScoping.run();
- }
- }
- exports.Program = BlockStatement;
- function replace(node, parent, scope, remaps) {
- if (!t.isReferencedIdentifier(node, parent)) return;
- var remap = remaps[node.name];
- if (!remap) return;
- var ownBinding = scope.getBindingIdentifier(node.name);
- if (ownBinding === remap.binding) {
- node.name = remap.uid;
- } else {
- // scope already has it's own binding that doesn't
- // match the one we have a stored replacement for
- if (this) this.skip();
- }
- }
- var replaceVisitor = {
- enter: replace
- };
- function traverseReplace(node, parent, scope, remaps) {
- replace(node, parent, scope, remaps);
- scope.traverse(node, replaceVisitor, remaps);
- }
- var letReferenceBlockVisitor = {
- Function: function Function(node, parent, scope, state) {
- this.traverse(letReferenceFunctionVisitor, state);
- return this.skip();
- }
- };
- var letReferenceFunctionVisitor = {
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
- var ref = state.letReferences[node.name];
- // not a part of our scope
- if (!ref) return;
- // this scope has a variable with the same name so it couldn't belong
- // to our let scope
- if (scope.getBindingIdentifier(node.name) !== ref) return;
- state.closurify = true;
- }
- };
- var hoistVarDeclarationsVisitor = {
- enter: function enter(node, parent, scope, self) {
- if (this.isForStatement()) {
- if (isVar(node.init, node)) {
- var nodes = self.pushDeclar(node.init);
- if (nodes.length === 1) {
- node.init = nodes[0];
- } else {
- node.init = t.sequenceExpression(nodes);
- }
- }
- } else if (this.isFor()) {
- if (isVar(node.left, node)) {
- node.left = node.left.declarations[0].id;
- }
- } else if (isVar(node, parent)) {
- return self.pushDeclar(node).map(t.expressionStatement);
- } else if (this.isFunction()) {
- return this.skip();
- }
- }
- };
- var loopLabelVisitor = {
- LabeledStatement: function LabeledStatement(node, parent, scope, state) {
- state.innerLabels.push(node.label.name);
- }
- };
- var continuationVisitor = {
- enter: function enter(node, parent, scope, state) {
- if (this.isAssignmentExpression() || this.isUpdateExpression()) {
- var bindings = this.getBindingIdentifiers();
- for (var name in bindings) {
- if (state.outsideReferences[name] !== scope.getBindingIdentifier(name)) continue;
- state.reassignments[name] = true;
- }
- }
- }
- };
- var loopNodeTo = function loopNodeTo(node) {
- if (t.isBreakStatement(node)) {
- return "break";
- } else if (t.isContinueStatement(node)) {
- return "continue";
- }
- };
- var loopVisitor = {
- Loop: function Loop(node, parent, scope, state) {
- var oldIgnoreLabeless = state.ignoreLabeless;
- state.ignoreLabeless = true;
- this.traverse(loopVisitor, state);
- state.ignoreLabeless = oldIgnoreLabeless;
- this.skip();
- },
- Function: function Function() {
- this.skip();
- },
- SwitchCase: function SwitchCase(node, parent, scope, state) {
- var oldInSwitchCase = state.inSwitchCase;
- state.inSwitchCase = true;
- this.traverse(loopVisitor, state);
- state.inSwitchCase = oldInSwitchCase;
- this.skip();
- },
- enter: function enter(node, parent, scope, state) {
- var replace;
- var loopText = loopNodeTo(node);
- if (loopText) {
- if (node.label) {
- // we shouldn't be transforming this because it exists somewhere inside
- if (state.innerLabels.indexOf(node.label.name) >= 0) {
- return;
- }
- loopText = "" + loopText + "|" + node.label.name;
- } else {
- // we shouldn't be transforming these statements because
- // they don't refer to the actual loop we're scopifying
- if (state.ignoreLabeless) return;
- //
- if (state.inSwitchCase) return;
- // break statements mean something different in this context
- if (t.isBreakStatement(node) && t.isSwitchCase(parent)) return;
- }
- state.hasBreakContinue = true;
- state.map[loopText] = node;
- replace = t.literal(loopText);
- }
- if (this.isReturnStatement()) {
- state.hasReturn = true;
- replace = t.objectExpression([t.property("init", t.identifier("v"), node.argument || t.identifier("undefined"))]);
- }
- if (replace) {
- replace = t.returnStatement(replace);
- this.skip();
- return t.inherits(replace, node);
- }
- }
- };
- var BlockScoping = (function () {
- /**
- * Description
- */
- function BlockScoping(loopPath, blockPath, parent, scope, file) {
- _classCallCheck(this, BlockScoping);
- this.parent = parent;
- this.scope = scope;
- this.file = file;
- this.blockPath = blockPath;
- this.block = blockPath.node;
- this.outsideLetReferences = (0, _helpersObject2["default"])();
- this.hasLetReferences = false;
- this.letReferences = this.block._letReferences = (0, _helpersObject2["default"])();
- this.body = [];
- if (loopPath) {
- this.loopParent = loopPath.parent;
- this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
- this.loopPath = loopPath;
- this.loop = loopPath.node;
- }
- }
- /**
- * Start the ball rolling.
- */
- BlockScoping.prototype.run = function run() {
- var block = this.block;
- if (block._letDone) return;
- block._letDone = true;
- var needsClosure = this.getLetReferences();
- // this is a block within a `Function/Program` so we can safely leave it be
- if (t.isFunction(this.parent) || t.isProgram(this.block)) return;
- // we can skip everything
- if (!this.hasLetReferences) return;
- if (needsClosure) {
- this.wrapClosure();
- } else {
- this.remap();
- }
- if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
- return t.labeledStatement(this.loopLabel, this.loop);
- }
- };
- /**
- * Description
- */
- BlockScoping.prototype.remap = function remap() {
- var hasRemaps = false;
- var letRefs = this.letReferences;
- var scope = this.scope;
- // alright, so since we aren't wrapping this block in a closure
- // we have to check if any of our let variables collide with
- // those in upper scopes and then if they do, generate a uid
- // for them and replace all references with it
- var remaps = (0, _helpersObject2["default"])();
- for (var key in letRefs) {
- // just an Identifier node we collected in `getLetReferences`
- // this is the defining identifier of a declaration
- var ref = letRefs[key];
- if (scope.parentHasBinding(key) || scope.hasGlobal(key)) {
- var uid = scope.generateUidIdentifier(ref.name).name;
- ref.name = uid;
- hasRemaps = true;
- remaps[key] = remaps[uid] = {
- binding: ref,
- uid: uid
- };
- }
- }
- if (!hasRemaps) return;
- //
- var loop = this.loop;
- if (loop) {
- traverseReplace(loop.right, loop, scope, remaps);
- traverseReplace(loop.test, loop, scope, remaps);
- traverseReplace(loop.update, loop, scope, remaps);
- }
- this.blockPath.traverse(replaceVisitor, remaps);
- };
- /**
- * Description
- */
- BlockScoping.prototype.wrapClosure = function wrapClosure() {
- var block = this.block;
- var outsideRefs = this.outsideLetReferences;
- // remap loop heads with colliding variables
- if (this.loop) {
- for (var name in outsideRefs) {
- var id = outsideRefs[name];
- if (this.scope.hasGlobal(id.name) || this.scope.parentHasBinding(id.name)) {
- delete outsideRefs[id.name];
- delete this.letReferences[id.name];
- this.scope.rename(id.name);
- this.letReferences[id.name] = id;
- outsideRefs[id.name] = id;
- }
- }
- }
- // if we're inside of a for loop then we search to see if there are any
- // `break`s, `continue`s, `return`s etc
- this.has = this.checkLoop();
- // hoist var references to retain scope
- this.hoistVarDeclarations();
- // turn outsideLetReferences into an array
- var params = (0, _lodashObjectValues2["default"])(outsideRefs);
- var args = (0, _lodashObjectValues2["default"])(outsideRefs);
- // build the closure that we're going to wrap the block with
- var fn = t.functionExpression(null, params, t.blockStatement(block.body));
- fn.shadow = true;
- // continuation
- this.addContinuations(fn);
- // replace the current block body with the one we're going to build
- block.body = this.body;
- var ref = fn;
- if (this.loop) {
- ref = this.scope.generateUidIdentifier("loop");
- this.loopPath.insertBefore(t.variableDeclaration("var", [t.variableDeclarator(ref, fn)]));
- }
- // build a call and a unique id that we can assign the return value to
- var call = t.callExpression(ref, args);
- var ret = this.scope.generateUidIdentifier("ret");
- // handle generators
- var hasYield = _traversal2["default"].hasType(fn.body, this.scope, "YieldExpression", t.FUNCTION_TYPES);
- if (hasYield) {
- fn.generator = true;
- call = t.yieldExpression(call, true);
- }
- // handlers async functions
- var hasAsync = _traversal2["default"].hasType(fn.body, this.scope, "AwaitExpression", t.FUNCTION_TYPES);
- if (hasAsync) {
- fn.async = true;
- call = t.awaitExpression(call);
- }
- this.buildClosure(ret, call);
- };
- /**
- * Push the closure to the body.
- */
- BlockScoping.prototype.buildClosure = function buildClosure(ret, call) {
- var has = this.has;
- if (has.hasReturn || has.hasBreakContinue) {
- this.buildHas(ret, call);
- } else {
- this.body.push(t.expressionStatement(call));
- }
- };
- /**
- * If any of the outer let variables are reassigned then we need to rename them in
- * the closure so we can get direct access to the outer variable to continue the
- * iteration with bindings based on each iteration.
- *
- * Reference: https://github.com/babel/babel/issues/1078
- */
- BlockScoping.prototype.addContinuations = function addContinuations(fn) {
- var state = {
- reassignments: {},
- outsideReferences: this.outsideLetReferences
- };
- this.scope.traverse(fn, continuationVisitor, state);
- for (var i = 0; i < fn.params.length; i++) {
- var param = fn.params[i];
- if (!state.reassignments[param.name]) continue;
- var newParam = this.scope.generateUidIdentifier(param.name);
- fn.params[i] = newParam;
- this.scope.rename(param.name, newParam.name, fn);
- // assign outer reference as it's been modified internally and needs to be retained
- fn.body.body.push(t.expressionStatement(t.assignmentExpression("=", param, newParam)));
- }
- };
- /**
- * Description
- */
- BlockScoping.prototype.getLetReferences = function getLetReferences() {
- var block = this.block;
- var declarators = block._letDeclarators || [];
- //
- for (var i = 0; i < declarators.length; i++) {
- var declar = declarators[i];
- (0, _lodashObjectExtend2["default"])(this.outsideLetReferences, t.getBindingIdentifiers(declar));
- }
- //
- if (block.body) {
- for (var i = 0; i < block.body.length; i++) {
- var declar = block.body[i];
- if (isLet(declar, block)) {
- declarators = declarators.concat(declar.declarations);
- }
- }
- }
- //
- for (var i = 0; i < declarators.length; i++) {
- var declar = declarators[i];
- var keys = t.getBindingIdentifiers(declar);
- (0, _lodashObjectExtend2["default"])(this.letReferences, keys);
- this.hasLetReferences = true;
- }
- // no let references so we can just quit
- if (!this.hasLetReferences) return;
- // set let references to plain var references
- standardizeLets(declarators);
- var state = {
- letReferences: this.letReferences,
- closurify: false
- };
- // traverse through this block, stopping on functions and checking if they
- // contain any local let references
- this.blockPath.traverse(letReferenceBlockVisitor, state);
- return state.closurify;
- };
- /**
- * If we're inside of a loop then traverse it and check if it has one of
- * the following node types `ReturnStatement`, `BreakStatement`,
- * `ContinueStatement` and replace it with a return value that we can track
- * later on.
- *
- * @returns {Object}
- */
- BlockScoping.prototype.checkLoop = function checkLoop() {
- var state = {
- hasBreakContinue: false,
- ignoreLabeless: false,
- inSwitchCase: false,
- innerLabels: [],
- hasReturn: false,
- isLoop: !!this.loop,
- map: {}
- };
- this.blockPath.traverse(loopLabelVisitor, state);
- this.blockPath.traverse(loopVisitor, state);
- return state;
- };
- /**
- * Hoist all var declarations in this block to before it so they retain scope
- * once we wrap everything in a closure.
- */
- BlockScoping.prototype.hoistVarDeclarations = function hoistVarDeclarations() {
- this.blockPath.traverse(hoistVarDeclarationsVisitor, this);
- };
- /**
- * Turn a `VariableDeclaration` into an array of `AssignmentExpressions` with
- * their declarations hoisted to before the closure wrapper.
- */
- BlockScoping.prototype.pushDeclar = function pushDeclar(node) {
- var declars = [];
- var names = t.getBindingIdentifiers(node);
- for (var name in names) {
- declars.push(t.variableDeclarator(names[name]));
- }
- this.body.push(t.variableDeclaration(node.kind, declars));
- var replace = [];
- for (var i = 0; i < node.declarations.length; i++) {
- var declar = node.declarations[i];
- if (!declar.init) continue;
- var expr = t.assignmentExpression("=", declar.id, declar.init);
- replace.push(t.inherits(expr, declar));
- }
- return replace;
- };
- /**
- * Description
- */
- BlockScoping.prototype.buildHas = function buildHas(ret, call) {
- var body = this.body;
- body.push(t.variableDeclaration("var", [t.variableDeclarator(ret, call)]));
- var loop = this.loop;
- var retCheck;
- var has = this.has;
- var cases = [];
- if (has.hasReturn) {
- // typeof ret === "object"
- retCheck = util.template("let-scoping-return", {
- RETURN: ret
- });
- }
- if (has.hasBreakContinue) {
- for (var key in has.map) {
- cases.push(t.switchCase(t.literal(key), [has.map[key]]));
- }
- if (has.hasReturn) {
- cases.push(t.switchCase(null, [retCheck]));
- }
- if (cases.length === 1) {
- var single = cases[0];
- body.push(this.file.attachAuxiliaryComment(t.ifStatement(t.binaryExpression("===", ret, single.test), single.consequent[0])));
- } else {
- // https://github.com/babel/babel/issues/998
- for (var i = 0; i < cases.length; i++) {
- var caseConsequent = cases[i].consequent[0];
- if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
- caseConsequent.label = this.loopLabel = this.loopLabel || this.file.scope.generateUidIdentifier("loop");
- }
- }
- body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
- }
- } else {
- if (has.hasReturn) {
- body.push(this.file.attachAuxiliaryComment(retCheck));
- }
- }
- };
- return BlockScoping;
- })();
- },{"../../../helpers/object":45,"../../../traversal":157,"../../../types":169,"../../../util":173,"lodash/object/extend":419,"lodash/object/values":424}],93:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ClassDeclaration = ClassDeclaration;
- exports.ClassExpression = ClassExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _helpersMemoiseDecorators = require("../../helpers/memoise-decorators");
- var _helpersMemoiseDecorators2 = _interopRequireDefault(_helpersMemoiseDecorators);
- var _helpersReplaceSupers = require("../../helpers/replace-supers");
- var _helpersReplaceSupers2 = _interopRequireDefault(_helpersReplaceSupers);
- var _helpersNameMethod = require("../../helpers/name-method");
- var nameMethod = _interopRequireWildcard(_helpersNameMethod);
- var _helpersDefineMap = require("../../helpers/define-map");
- var defineMap = _interopRequireWildcard(_helpersDefineMap);
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _util = require("../../../util");
- var util = _interopRequireWildcard(_util);
- var _traversal = require("../../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _lodashObjectHas = require("lodash/object/has");
- var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var PROPERTY_COLLISION_METHOD_NAME = "__initializeProperties";
- function ClassDeclaration(node, parent, scope, file) {
- return t.variableDeclaration("let", [t.variableDeclarator(node.id, t.toExpression(node))]);
- }
- function ClassExpression(node, parent, scope, file) {
- return new ClassTransformer(this, file).run();
- }
- var collectPropertyReferencesVisitor = {
- Identifier: {
- enter: function enter(node, parent, scope, state) {
- if (this.parentPath.isClassProperty({ key: node })) {
- return;
- }
- if (this.isReferenced() && scope.getBinding(node.name) === state.scope.getBinding(node.name)) {
- state.references[node.name] = true;
- }
- }
- }
- };
- var constructorVisitor = {
- ThisExpression: {
- enter: function enter(node, parent, scope, ref) {
- return ref;
- }
- },
- Function: {
- enter: function enter(node) {
- if (!node.shadow) {
- this.skip();
- }
- }
- }
- };
- var verifyConstructorVisitor = {
- MethodDefinition: {
- enter: function enter() {
- this.skip();
- }
- },
- Property: {
- enter: function enter(node) {
- if (node.method) this.skip();
- }
- },
- CallExpression: {
- exit: function exit(node, parent, scope, state) {
- if (this.get("callee").isSuper()) {
- state.hasBareSuper = true;
- state.bareSuper = this;
- if (!state.hasSuper) {
- throw this.errorWithNode("super call is only allowed in derived constructor");
- }
- }
- }
- },
- FunctionDeclaration: {
- enter: function enter() {
- this.skip();
- }
- },
- FunctionExpression: {
- enter: function enter() {
- this.skip();
- }
- },
- ThisExpression: {
- enter: function enter(node, parent, scope, state) {
- if (state.hasSuper && !state.hasBareSuper) {
- throw this.errorWithNode("'this' is not allowed before super()");
- }
- }
- }
- };
- var ClassTransformer = (function () {
- /**
- * Description
- */
- function ClassTransformer(path, file) {
- _classCallCheck(this, ClassTransformer);
- this.parent = path.parent;
- this.scope = path.scope;
- this.node = path.node;
- this.path = path;
- this.file = file;
- this.hasInstanceDescriptors = false;
- this.hasStaticDescriptors = false;
- this.instanceMutatorMap = {};
- this.staticMutatorMap = {};
- this.instancePropBody = [];
- this.instancePropRefs = {};
- this.staticPropBody = [];
- this.body = [];
- this.hasConstructor = false;
- this.hasDecorators = false;
- this.className = this.node.id;
- this.classRef = this.node.id || this.scope.generateUidIdentifier("class");
- this.superName = this.node.superClass || t.identifier("Function");
- this.hasSuper = !!this.node.superClass;
- this.isLoose = file.isLoose("es6.classes");
- }
- /**
- * Description
- *
- * @returns {Array}
- */
- ClassTransformer.prototype.run = function run() {
- var superName = this.superName;
- var className = this.className;
- var classBody = this.node.body.body;
- var classRef = this.classRef;
- var file = this.file;
- //
- var body = this.body;
- //
- var constructorBody = this.constructorBody = t.blockStatement([]);
- var constructor;
- if (this.className) {
- constructor = t.functionDeclaration(this.className, [], constructorBody);
- body.push(constructor);
- } else {
- constructor = t.functionExpression(null, [], constructorBody);
- }
- this.constructor = constructor;
- //
- var closureParams = [];
- var closureArgs = [];
- //
- if (this.hasSuper) {
- closureArgs.push(superName);
- superName = this.scope.generateUidIdentifierBasedOnNode(superName);
- closureParams.push(superName);
- this.superName = superName;
- body.push(t.expressionStatement(t.callExpression(file.addHelper("inherits"), [classRef, superName])));
- }
- //
- var decorators = this.node.decorators;
- if (decorators) {
- // create a class reference to use later on
- this.classRef = this.scope.generateUidIdentifier(classRef);
- // this is so super calls and the decorators have access to the raw function
- body.push(t.variableDeclaration("var", [t.variableDeclarator(this.classRef, classRef)]));
- }
- //
- this.buildBody();
- // make sure this class isn't directly called
- constructorBody.body.unshift(t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [t.thisExpression(), this.classRef])));
- //
- if (decorators) {
- // reverse the decorators so we execute them in the right order
- decorators = decorators.reverse();
- for (var i = 0; i < decorators.length; i++) {
- var decorator = decorators[i];
- var decoratorNode = util.template("class-decorator", {
- DECORATOR: decorator.expression,
- CLASS_REF: classRef
- }, true);
- decoratorNode.expression._ignoreModulesRemap = true;
- body.push(decoratorNode);
- }
- }
- if (this.className) {
- // named class with only a constructor
- if (body.length === 1) return t.toExpression(body[0]);
- } else {
- // infer class name if this is a nameless class expression
- constructor = nameMethod.bare(constructor, this.parent, this.scope) || constructor;
- body.unshift(t.variableDeclaration("var", [t.variableDeclarator(classRef, constructor)]));
- t.inheritsComments(body[0], this.node);
- }
- body = body.concat(this.staticPropBody);
- //
- body.push(t.returnStatement(classRef));
- return t.callExpression(t.functionExpression(null, closureParams, t.blockStatement(body)), closureArgs);
- };
- /**
- * Description
- */
- ClassTransformer.prototype.pushToMap = function pushToMap(node, enumerable) {
- var kind = arguments[2] === undefined ? "value" : arguments[2];
- var mutatorMap;
- if (node["static"]) {
- this.hasStaticDescriptors = true;
- mutatorMap = this.staticMutatorMap;
- } else {
- this.hasInstanceDescriptors = true;
- mutatorMap = this.instanceMutatorMap;
- }
- var map = defineMap.push(mutatorMap, node, kind, this.file);
- if (enumerable) {
- map.enumerable = t.literal(true);
- }
- if (map.decorators) {
- this.hasDecorators = true;
- }
- };
- /**
- * Description
- */
- ClassTransformer.prototype.buildBody = function buildBody() {
- var constructorBody = this.constructorBody;
- var constructor = this.constructor;
- var className = this.className;
- var superName = this.superName;
- var classBody = this.node.body.body;
- var body = this.body;
- var classBodyPaths = this.path.get("body").get("body");
- for (var i = 0; i < classBody.length; i++) {
- var node = classBody[i];
- var path = classBodyPaths[i];
- if (node.decorators) {
- (0, _helpersMemoiseDecorators2["default"])(node.decorators, this.scope);
- }
- if (t.isMethodDefinition(node)) {
- var isConstructor = node.kind === "constructor";
- if (isConstructor) this.verifyConstructor(path);
- var replaceSupers = new _helpersReplaceSupers2["default"]({
- methodPath: path,
- methodNode: node,
- objectRef: this.classRef,
- superRef: this.superName,
- isStatic: node["static"],
- isLoose: this.isLoose,
- scope: this.scope,
- file: this.file
- }, true);
- replaceSupers.replace();
- if (isConstructor) {
- this.pushConstructor(node, path);
- } else {
- this.pushMethod(node, path);
- }
- } else if (t.isClassProperty(node)) {
- this.pushProperty(node);
- }
- }
- // we have no constructor, but we're a derived class
- if (!this.hasConstructor && this.hasSuper) {
- var helperName = "class-super-constructor-call";
- if (this.isLoose) helperName += "-loose";
- constructorBody.body.push(util.template(helperName, {
- CLASS_NAME: this.classRef,
- SUPER_NAME: this.superName
- }, true));
- }
- //
- this.placePropertyInitializers();
- //
- if (this.userConstructor) {
- constructorBody.body = constructorBody.body.concat(this.userConstructor.body.body);
- t.inherits(this.constructor, this.userConstructor);
- t.inherits(this.constructorBody, this.userConstructor.body);
- }
- var instanceProps;
- var staticProps;
- var classHelper = "create-class";
- if (this.hasDecorators) classHelper = "create-decorated-class";
- if (this.hasInstanceDescriptors) {
- instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
- }
- if (this.hasStaticDescriptors) {
- staticProps = defineMap.toClassObject(this.staticMutatorMap);
- }
- if (instanceProps || staticProps) {
- if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
- if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
- var nullNode = t.literal(null);
- // (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
- var args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
- if (instanceProps) args[1] = instanceProps;
- if (staticProps) args[2] = staticProps;
- if (this.instanceInitializersId) {
- args[3] = this.instanceInitializersId;
- body.unshift(this.buildObjectAssignment(this.instanceInitializersId));
- }
- if (this.staticInitializersId) {
- args[4] = this.staticInitializersId;
- body.unshift(this.buildObjectAssignment(this.staticInitializersId));
- }
- var lastNonNullIndex = 0;
- for (var i = 0; i < args.length; i++) {
- if (args[i] !== nullNode) lastNonNullIndex = i;
- }
- args = args.slice(0, lastNonNullIndex + 1);
- body.push(t.expressionStatement(t.callExpression(this.file.addHelper(classHelper), args)));
- }
- };
- ClassTransformer.prototype.buildObjectAssignment = function buildObjectAssignment(id) {
- return t.variableDeclaration("var", [t.variableDeclarator(id, t.objectExpression([]))]);
- };
- /**
- * Description
- */
- ClassTransformer.prototype.placePropertyInitializers = function placePropertyInitializers() {
- var body = this.instancePropBody;
- if (!body.length) return;
- if (this.hasPropertyCollision()) {
- var call = t.expressionStatement(t.callExpression(t.memberExpression(t.thisExpression(), t.identifier(PROPERTY_COLLISION_METHOD_NAME)), []));
- this.pushMethod(t.methodDefinition(t.identifier(PROPERTY_COLLISION_METHOD_NAME), t.functionExpression(null, [], t.blockStatement(body))), null, true);
- if (this.hasSuper) {
- this.bareSuper.insertAfter(call);
- } else {
- this.constructorBody.body.unshift(call);
- }
- } else {
- if (this.hasSuper) {
- if (this.hasConstructor) {
- this.bareSuper.insertAfter(body);
- } else {
- this.constructorBody.body = this.constructorBody.body.concat(body);
- }
- } else {
- this.constructorBody.body = body.concat(this.constructorBody.body);
- }
- }
- };
- /**
- * Description
- */
- ClassTransformer.prototype.hasPropertyCollision = function hasPropertyCollision() {
- if (this.userConstructorPath) {
- for (var name in this.instancePropRefs) {
- if (this.userConstructorPath.scope.hasOwnBinding(name)) {
- return true;
- }
- }
- }
- return false;
- };
- /**
- * Description
- */
- ClassTransformer.prototype.verifyConstructor = function verifyConstructor(path) {
- var state = {
- hasBareSuper: false,
- bareSuper: null,
- hasSuper: this.hasSuper,
- file: this.file
- };
- path.get("value").traverse(verifyConstructorVisitor, state);
- this.bareSuper = state.bareSuper;
- if (!state.hasBareSuper && this.hasSuper) {
- throw path.errorWithNode("Derived constructor must call super()");
- }
- };
- /**
- * Push a method to its respective mutatorMap.
- */
- ClassTransformer.prototype.pushMethod = function pushMethod(node, path, allowedIllegal) {
- if (!allowedIllegal && t.isLiteral(t.toComputedKey(node), { value: PROPERTY_COLLISION_METHOD_NAME })) {
- throw this.file.errorWithNode(node, messages.get("illegalMethodName", PROPERTY_COLLISION_METHOD_NAME));
- }
- if (node.kind === "method") {
- nameMethod.property(node, this.file, path ? path.get("value").scope : this.scope);
- if (this.isLoose && !node.decorators) {
- // use assignments instead of define properties for loose classes
- var classRef = this.classRef;
- if (!node["static"]) classRef = t.memberExpression(classRef, t.identifier("prototype"));
- var methodName = t.memberExpression(classRef, node.key, node.computed);
- var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
- t.inheritsComments(expr, node);
- this.body.push(expr);
- return;
- }
- }
- this.pushToMap(node);
- };
- /**
- * Description
- */
- ClassTransformer.prototype.pushProperty = function pushProperty(node) {
- var key;
- this.scope.traverse(node, collectPropertyReferencesVisitor, {
- references: this.instancePropRefs,
- scope: this.scope
- });
- if (node.decorators) {
- var body = [];
- if (node.value) {
- body.push(t.returnStatement(node.value));
- node.value = t.functionExpression(null, [], t.blockStatement(body));
- } else {
- node.value = t.literal(null);
- }
- this.pushToMap(node, true, "initializer");
- var initializers;
- var body;
- var target;
- if (node["static"]) {
- initializers = this.staticInitializersId = this.staticInitializersId || this.scope.generateUidIdentifier("staticInitializers");
- body = this.staticPropBody;
- target = this.classRef;
- } else {
- initializers = this.instanceInitializersId = this.instanceInitializersId || this.scope.generateUidIdentifier("instanceInitializers");
- body = this.instancePropBody;
- target = t.thisExpression();
- }
- body.push(t.expressionStatement(t.callExpression(this.file.addHelper("define-decorated-property-descriptor"), [target, t.literal(node.key.name), initializers])));
- } else {
- if (!node.value && !node.decorators) return;
- if (node["static"]) {
- // can just be added to the static map
- this.pushToMap(node, true);
- } else if (node.value) {
- // add this to the instancePropBody which will be added after the super call in a derived constructor
- // or at the start of a constructor for a non-derived constructor
- this.instancePropBody.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)));
- }
- }
- };
- /**
- * Replace the constructor body of our class.
- */
- ClassTransformer.prototype.pushConstructor = function pushConstructor(method, path) {
- // https://github.com/babel/babel/issues/1077
- var fnPath = path.get("value");
- if (fnPath.scope.hasOwnBinding(this.classRef.name)) {
- fnPath.scope.rename(this.classRef.name);
- }
- var construct = this.constructor;
- var fn = method.value;
- this.userConstructorPath = fnPath;
- this.userConstructor = fn;
- this.hasConstructor = true;
- t.inheritsComments(construct, method);
- construct._ignoreUserWhitespace = true;
- construct.params = fn.params;
- t.inherits(construct.body, fn.body);
- };
- return ClassTransformer;
- })();
- },{"../../../messages":47,"../../../traversal":157,"../../../types":169,"../../../util":173,"../../helpers/define-map":61,"../../helpers/memoise-decorators":64,"../../helpers/name-method":65,"../../helpers/replace-supers":69,"lodash/collection/each":330,"lodash/object/has":420}],94:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.AssignmentExpression = AssignmentExpression;
- exports.VariableDeclaration = VariableDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function AssignmentExpression(node, parent, scope, file) {
- var ids = this.getBindingIdentifiers();
- for (var name in ids) {
- var id = ids[name];
- var binding = scope.getBinding(name);
- // no binding exists
- if (!binding) continue;
- // not a constant
- if (binding.kind !== "const" && binding.kind !== "module") continue;
- // check if the assignment id matches the constant declaration id
- // if it does then it was the id used to initially declare the
- // constant so we can just ignore it
- if (binding.identifier === id) continue;
- throw file.errorWithNode(id, messages.get("readOnly", name));
- }
- }
- exports.UpdateExpression = AssignmentExpression;
- function VariableDeclaration(node) {
- if (node.kind === "const") node.kind = "let";
- }
- },{"../../../messages":47,"../../../types":169}],95:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ForOfStatement = ForOfStatement;
- exports.Func /*tion*/ = Func;
- exports.CatchClause = CatchClause;
- exports.ExpressionStatement = ExpressionStatement;
- exports.AssignmentExpression = AssignmentExpression;
- exports.VariableDeclaration = VariableDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-advanced"
- };
- exports.metadata = metadata;
- function ForOfStatement(node, parent, scope, file) {
- var left = node.left;
- if (t.isPattern(left)) {
- // for ({ length: k } in { abc: 3 });
- var temp = scope.generateUidIdentifier("ref");
- node.left = t.variableDeclaration("var", [t.variableDeclarator(temp)]);
- t.ensureBlock(node);
- node.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(left, temp)]));
- return;
- }
- if (!t.isVariableDeclaration(left)) return;
- var pattern = left.declarations[0].id;
- if (!t.isPattern(pattern)) return;
- var key = scope.generateUidIdentifier("ref");
- node.left = t.variableDeclaration(left.kind, [t.variableDeclarator(key, null)]);
- var nodes = [];
- var destructuring = new DestructuringTransformer({
- kind: left.kind,
- file: file,
- scope: scope,
- nodes: nodes
- });
- destructuring.init(pattern, key);
- t.ensureBlock(node);
- var block = node.body;
- block.body = nodes.concat(block.body);
- }
- exports.ForInStatement = ForOfStatement;
- function Func(node, parent, scope, file) {
- var nodes = [];
- var hasDestructuring = false;
- node.params = node.params.map(function (pattern, i) {
- if (!t.isPattern(pattern)) return pattern;
- hasDestructuring = true;
- var ref = scope.generateUidIdentifier("ref");
- t.inherits(ref, pattern);
- var destructuring = new DestructuringTransformer({
- blockHoist: node.params.length - i,
- nodes: nodes,
- scope: scope,
- file: file,
- kind: "let"
- });
- destructuring.init(pattern, ref);
- return ref;
- });
- if (!hasDestructuring) return;
- t.ensureBlock(node);
- var block = node.body;
- block.body = nodes.concat(block.body);
- }
- function CatchClause(node, parent, scope, file) {
- var pattern = node.param;
- if (!t.isPattern(pattern)) return;
- var ref = scope.generateUidIdentifier("ref");
- node.param = ref;
- var nodes = [];
- var destructuring = new DestructuringTransformer({
- kind: "let",
- file: file,
- scope: scope,
- nodes: nodes
- });
- destructuring.init(pattern, ref);
- node.body.body = nodes.concat(node.body.body);
- }
- function ExpressionStatement(node, parent, scope, file) {
- var expr = node.expression;
- if (expr.type !== "AssignmentExpression") return;
- if (!t.isPattern(expr.left)) return;
- if (this.isCompletionRecord()) return;
- var destructuring = new DestructuringTransformer({
- operator: expr.operator,
- scope: scope,
- file: file });
- return destructuring.init(expr.left, expr.right);
- }
- function AssignmentExpression(node, parent, scope, file) {
- if (!t.isPattern(node.left)) return;
- var ref = scope.generateUidIdentifier("temp");
- var nodes = [];
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(ref, node.right)]));
- var destructuring = new DestructuringTransformer({
- operator: node.operator,
- file: file,
- scope: scope,
- nodes: nodes
- });
- if (t.isArrayExpression(node.right)) {
- destructuring.arrays[ref.name] = true;
- }
- destructuring.init(node.left, ref);
- nodes.push(t.expressionStatement(ref));
- return nodes;
- }
- function variableDeclarationHasPattern(node) {
- for (var i = 0; i < node.declarations.length; i++) {
- if (t.isPattern(node.declarations[i].id)) {
- return true;
- }
- }
- return false;
- }
- function VariableDeclaration(node, parent, scope, file) {
- if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;
- if (!variableDeclarationHasPattern(node)) return;
- var nodes = [];
- var declar;
- for (var i = 0; i < node.declarations.length; i++) {
- declar = node.declarations[i];
- var patternId = declar.init;
- var pattern = declar.id;
- var destructuring = new DestructuringTransformer({
- nodes: nodes,
- scope: scope,
- kind: node.kind,
- file: file
- });
- if (t.isPattern(pattern)) {
- destructuring.init(pattern, patternId);
- if (+i !== node.declarations.length - 1) {
- // we aren't the last declarator so let's just make the
- // last transformed node inherit from us
- t.inherits(nodes[nodes.length - 1], declar);
- }
- } else {
- nodes.push(t.inherits(destructuring.buildVariableAssignment(declar.id, declar.init), declar));
- }
- }
- if (!t.isProgram(parent) && !t.isBlockStatement(parent)) {
- // https://github.com/babel/babel/issues/113
- // for (let [x] = [0]; false;) {}
- declar = null;
- for (i = 0; i < nodes.length; i++) {
- node = nodes[i];
- declar = declar || t.variableDeclaration(node.kind, []);
- if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) {
- throw file.errorWithNode(node, messages.get("invalidParentForThisNode"));
- }
- declar.declarations = declar.declarations.concat(node.declarations);
- }
- return declar;
- }
- return nodes;
- }
- function hasRest(pattern) {
- for (var i = 0; i < pattern.elements.length; i++) {
- if (t.isRestElement(pattern.elements[i])) {
- return true;
- }
- }
- return false;
- }
- var arrayUnpackVisitor = {
- enter: function enter(node, parent, scope, state) {
- if (this.isReferencedIdentifier() && state.bindings[node.name]) {
- state.deopt = true;
- this.stop();
- }
- }
- };
- var DestructuringTransformer = (function () {
- function DestructuringTransformer(opts) {
- _classCallCheck(this, DestructuringTransformer);
- this.blockHoist = opts.blockHoist;
- this.operator = opts.operator;
- this.arrays = {};
- this.nodes = opts.nodes || [];
- this.scope = opts.scope;
- this.file = opts.file;
- this.kind = opts.kind;
- }
- DestructuringTransformer.prototype.buildVariableAssignment = function buildVariableAssignment(id, init) {
- var op = this.operator;
- if (t.isMemberExpression(id)) op = "=";
- var node;
- if (op) {
- node = t.expressionStatement(t.assignmentExpression(op, id, init));
- } else {
- node = t.variableDeclaration(this.kind, [t.variableDeclarator(id, init)]);
- }
- node._blockHoist = this.blockHoist;
- return node;
- };
- DestructuringTransformer.prototype.buildVariableDeclaration = function buildVariableDeclaration(id, init) {
- var declar = t.variableDeclaration("var", [t.variableDeclarator(id, init)]);
- declar._blockHoist = this.blockHoist;
- return declar;
- };
- DestructuringTransformer.prototype.push = function push(id, init) {
- if (t.isObjectPattern(id)) {
- this.pushObjectPattern(id, init);
- } else if (t.isArrayPattern(id)) {
- this.pushArrayPattern(id, init);
- } else if (t.isAssignmentPattern(id)) {
- this.pushAssignmentPattern(id, init);
- } else {
- this.nodes.push(this.buildVariableAssignment(id, init));
- }
- };
- DestructuringTransformer.prototype.toArray = function toArray(node, count) {
- if (this.file.isLoose("es6.destructuring") || t.isIdentifier(node) && this.arrays[node.name]) {
- return node;
- } else {
- return this.scope.toArray(node, count);
- }
- };
- DestructuringTransformer.prototype.pushAssignmentPattern = function pushAssignmentPattern(pattern, valueRef) {
- // we need to assign the current value of the assignment to avoid evaluating
- // it more than once
- var tempValueRef = this.scope.generateUidIdentifierBasedOnNode(valueRef);
- var declar = t.variableDeclaration("var", [t.variableDeclarator(tempValueRef, valueRef)]);
- declar._blockHoist = this.blockHoist;
- this.nodes.push(declar);
- //
- var tempConditional = t.conditionalExpression(t.binaryExpression("===", tempValueRef, t.identifier("undefined")), pattern.right, tempValueRef);
- var left = pattern.left;
- if (t.isPattern(left)) {
- this.nodes.push(t.expressionStatement(t.assignmentExpression("=", tempValueRef, tempConditional)));
- this.push(left, tempValueRef);
- } else {
- this.nodes.push(this.buildVariableAssignment(left, tempConditional));
- }
- };
- DestructuringTransformer.prototype.pushObjectSpread = function pushObjectSpread(pattern, objRef, spreadProp, spreadPropIndex) {
- // get all the keys that appear in this object before the current spread
- var keys = [];
- for (var i = 0; i < pattern.properties.length; i++) {
- var prop = pattern.properties[i];
- // we've exceeded the index of the spread property to all properties to the
- // right need to be ignored
- if (i >= spreadPropIndex) break;
- // ignore other spread properties
- if (t.isSpreadProperty(prop)) continue;
- var key = prop.key;
- if (t.isIdentifier(key) && !prop.computed) key = t.literal(prop.key.name);
- keys.push(key);
- }
- keys = t.arrayExpression(keys);
- //
- var value = t.callExpression(this.file.addHelper("object-without-properties"), [objRef, keys]);
- this.nodes.push(this.buildVariableAssignment(spreadProp.argument, value));
- };
- DestructuringTransformer.prototype.pushObjectProperty = function pushObjectProperty(prop, propRef) {
- if (t.isLiteral(prop.key)) prop.computed = true;
- var pattern = prop.value;
- var objRef = t.memberExpression(propRef, prop.key, prop.computed);
- if (t.isPattern(pattern)) {
- this.push(pattern, objRef);
- } else {
- this.nodes.push(this.buildVariableAssignment(pattern, objRef));
- }
- };
- DestructuringTransformer.prototype.pushObjectPattern = function pushObjectPattern(pattern, objRef) {
- // https://github.com/babel/babel/issues/681
- if (!pattern.properties.length) {
- this.nodes.push(t.expressionStatement(t.callExpression(this.file.addHelper("object-destructuring-empty"), [objRef])));
- }
- // if we have more than one properties in this pattern and the objectRef is a
- // member expression then we need to assign it to a temporary variable so it's
- // only evaluated once
- if (pattern.properties.length > 1 && t.isMemberExpression(objRef)) {
- var temp = this.scope.generateUidIdentifierBasedOnNode(objRef, this.file);
- this.nodes.push(this.buildVariableDeclaration(temp, objRef));
- objRef = temp;
- }
- //
- for (var i = 0; i < pattern.properties.length; i++) {
- var prop = pattern.properties[i];
- if (t.isSpreadProperty(prop)) {
- this.pushObjectSpread(pattern, objRef, prop, i);
- } else {
- this.pushObjectProperty(prop, objRef);
- }
- }
- };
- DestructuringTransformer.prototype.canUnpackArrayPattern = function canUnpackArrayPattern(pattern, arr) {
- // not an array so there's no way we can deal with this
- if (!t.isArrayExpression(arr)) return false;
- // pattern has less elements than the array and doesn't have a rest so some
- // elements wont be evaluated
- if (pattern.elements.length > arr.elements.length) return;
- if (pattern.elements.length < arr.elements.length && !hasRest(pattern)) return false;
- for (var i = 0; i < pattern.elements.length; i++) {
- var elem = pattern.elements[i];
- // deopt on holes
- if (!elem) return false;
- // deopt on member expressions
- if (t.isMemberExpression(elem)) return false;
- }
- // deopt on reference to left side identifiers
- var bindings = t.getBindingIdentifiers(pattern);
- var state = { deopt: false, bindings: bindings };
- this.scope.traverse(arr, arrayUnpackVisitor, state);
- return !state.deopt;
- };
- DestructuringTransformer.prototype.pushUnpackedArrayPattern = function pushUnpackedArrayPattern(pattern, arr) {
- for (var i = 0; i < pattern.elements.length; i++) {
- var elem = pattern.elements[i];
- if (t.isRestElement(elem)) {
- this.push(elem.argument, t.arrayExpression(arr.elements.slice(i)));
- } else {
- this.push(elem, arr.elements[i]);
- }
- }
- };
- DestructuringTransformer.prototype.pushArrayPattern = function pushArrayPattern(pattern, arrayRef) {
- if (!pattern.elements) return;
- // optimise basic array destructuring of an array expression
- //
- // we can't do this to a pattern of unequal size to it's right hand
- // array expression as then there will be values that wont be evaluated
- //
- // eg: var [a, b] = [1, 2];
- if (this.canUnpackArrayPattern(pattern, arrayRef)) {
- return this.pushUnpackedArrayPattern(pattern, arrayRef);
- }
- // if we have a rest then we need all the elements so don't tell
- // `scope.toArray` to only get a certain amount
- var count = !hasRest(pattern) && pattern.elements.length;
- // so we need to ensure that the `arrayRef` is an array, `scope.toArray` will
- // return a locally bound identifier if it's been inferred to be an array,
- // otherwise it'll be a call to a helper that will ensure it's one
- var toArray = this.toArray(arrayRef, count);
- if (t.isIdentifier(toArray)) {
- // we've been given an identifier so it must have been inferred to be an
- // array
- arrayRef = toArray;
- } else {
- arrayRef = this.scope.generateUidIdentifierBasedOnNode(arrayRef);
- this.arrays[arrayRef.name] = true;
- this.nodes.push(this.buildVariableDeclaration(arrayRef, toArray));
- }
- //
- for (var i = 0; i < pattern.elements.length; i++) {
- var elem = pattern.elements[i];
- // hole
- if (!elem) continue;
- var elemRef;
- if (t.isRestElement(elem)) {
- elemRef = this.toArray(arrayRef);
- if (i > 0) {
- elemRef = t.callExpression(t.memberExpression(elemRef, t.identifier("slice")), [t.literal(i)]);
- }
- // set the element to the rest element argument since we've dealt with it
- // being a rest already
- elem = elem.argument;
- } else {
- elemRef = t.memberExpression(arrayRef, t.literal(i), true);
- }
- this.push(elem, elemRef);
- }
- };
- DestructuringTransformer.prototype.init = function init(pattern, ref) {
- // trying to destructure a value that we can't evaluate more than once so we
- // need to save it to a variable
- var shouldMemoise = true;
- if (!t.isArrayExpression(ref) && !t.isMemberExpression(ref)) {
- var memo = this.scope.maybeGenerateMemoised(ref, true);
- if (memo) {
- this.nodes.push(this.buildVariableDeclaration(memo, ref));
- ref = memo;
- }
- }
- //
- this.push(pattern, ref);
- return this.nodes;
- };
- return DestructuringTransformer;
- })();
- },{"../../../messages":47,"../../../types":169}],96:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ForOfStatement = ForOfStatement;
- exports._ForOfStatementArray = _ForOfStatementArray;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _util = require("../../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function ForOfStatement(node, parent, scope, file) {
- if (this.get("right").isArrayExpression()) {
- return _ForOfStatementArray.call(this, node, scope, file);
- }
- var callback = spec;
- if (file.isLoose("es6.forOf")) callback = loose;
- var build = callback(node, parent, scope, file);
- var declar = build.declar;
- var loop = build.loop;
- var block = loop.body;
- // ensure that it's a block so we can take all its statements
- t.ensureBlock(node);
- // add the value declaration to the new loop body
- if (declar) {
- block.body.push(declar);
- }
- // push the rest of the original loop body onto our new body
- block.body = block.body.concat(node.body.body);
- t.inherits(loop, node);
- t.inherits(loop.body, node.body);
- if (build.replaceParent) {
- this.parentPath.replaceWithMultiple(build.node);
- this.remove();
- } else {
- return build.node;
- }
- }
- function _ForOfStatementArray(node, scope, file) {
- var nodes = [];
- var right = node.right;
- if (!t.isIdentifier(right) || !scope.hasBinding(right.name)) {
- var uid = scope.generateUidIdentifier("arr");
- nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, right)]));
- right = uid;
- }
- var iterationKey = scope.generateUidIdentifier("i");
- var loop = util.template("for-of-array", {
- BODY: node.body,
- KEY: iterationKey,
- ARR: right
- });
- t.inherits(loop, node);
- t.ensureBlock(loop);
- var iterationValue = t.memberExpression(right, iterationKey, true);
- var left = node.left;
- if (t.isVariableDeclaration(left)) {
- left.declarations[0].init = iterationValue;
- loop.body.body.unshift(left);
- } else {
- loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", left, iterationValue)));
- }
- nodes.push(loop);
- return nodes;
- }
- var loose = function loose(node, parent, scope, file) {
- var left = node.left;
- var declar, id;
- if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
- // for (i of test), for ({ i } of test)
- id = left;
- } else if (t.isVariableDeclaration(left)) {
- // for (var i of test)
- id = scope.generateUidIdentifier("ref");
- declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, id)]);
- } else {
- throw file.errorWithNode(left, messages.get("unknownForHead", left.type));
- }
- var iteratorKey = scope.generateUidIdentifier("iterator");
- var isArrayKey = scope.generateUidIdentifier("isArray");
- var loop = util.template("for-of-loose", {
- LOOP_OBJECT: iteratorKey,
- IS_ARRAY: isArrayKey,
- OBJECT: node.right,
- INDEX: scope.generateUidIdentifier("i"),
- ID: id
- });
- if (!declar) {
- // no declaration so we need to remove the variable declaration at the top of
- // the for-of-loose template
- loop.body.body.shift();
- }
- //
- return {
- declar: declar,
- node: loop,
- loop: loop
- };
- };
- var spec = function spec(node, parent, scope, file) {
- var left = node.left;
- var declar;
- var stepKey = scope.generateUidIdentifier("step");
- var stepValue = t.memberExpression(stepKey, t.identifier("value"));
- if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
- // for (i of test), for ({ i } of test)
- declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
- } else if (t.isVariableDeclaration(left)) {
- // for (var i of test)
- declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, stepValue)]);
- } else {
- throw file.errorWithNode(left, messages.get("unknownForHead", left.type));
- }
- //
- var iteratorKey = scope.generateUidIdentifier("iterator");
- var template = util.template("for-of", {
- ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
- ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"),
- ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
- ITERATOR_KEY: iteratorKey,
- STEP_KEY: stepKey,
- OBJECT: node.right,
- BODY: null
- });
- var isLabeledParent = t.isLabeledStatement(parent);
- var tryBody = template[3].block.body;
- var loop = tryBody[0];
- if (isLabeledParent) {
- tryBody[0] = t.labeledStatement(parent.label, loop);
- }
- //
- return {
- replaceParent: isLabeledParent,
- declar: declar,
- loop: loop,
- node: template
- };
- };
- },{"../../../messages":47,"../../../types":169,"../../../util":173}],97:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ImportDeclaration = ImportDeclaration;
- exports.ExportAllDeclaration = ExportAllDeclaration;
- exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
- exports.ExportNamedDeclaration = ExportNamedDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function keepBlockHoist(node, nodes) {
- if (node._blockHoist) {
- for (var i = 0; i < nodes.length; i++) {
- nodes[i]._blockHoist = node._blockHoist;
- }
- }
- }
- var metadata = {
- group: "builtin-modules"
- };
- exports.metadata = metadata;
- function ImportDeclaration(node, parent, scope, file) {
- // flow type
- if (node.isType) return;
- var nodes = [];
- if (node.specifiers.length) {
- for (var i = 0; i < node.specifiers.length; i++) {
- file.moduleFormatter.importSpecifier(node.specifiers[i], node, nodes, parent);
- }
- } else {
- file.moduleFormatter.importDeclaration(node, nodes, parent);
- }
- if (nodes.length === 1) {
- // inherit `_blockHoist` - this is for `_blockHoist` in File.prototype.addImport
- nodes[0]._blockHoist = node._blockHoist;
- }
- return nodes;
- }
- function ExportAllDeclaration(node, parent, scope, file) {
- var nodes = [];
- file.moduleFormatter.exportAllDeclaration(node, nodes, parent);
- keepBlockHoist(node, nodes);
- return nodes;
- }
- function ExportDefaultDeclaration(node, parent, scope, file) {
- var nodes = [];
- file.moduleFormatter.exportDeclaration(node, nodes, parent);
- keepBlockHoist(node, nodes);
- return nodes;
- }
- function ExportNamedDeclaration(node, parent, scope, file) {
- // flow type
- if (this.get("declaration").isTypeAlias()) return;
- var nodes = [];
- if (node.declaration) {
- // make sure variable exports have an initializer
- // this is done here to avoid duplicating it in the module formatters
- if (t.isVariableDeclaration(node.declaration)) {
- var declar = node.declaration.declarations[0];
- declar.init = declar.init || t.identifier("undefined");
- }
- file.moduleFormatter.exportDeclaration(node, nodes, parent);
- } else if (node.specifiers) {
- for (var i = 0; i < node.specifiers.length; i++) {
- file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);
- }
- }
- keepBlockHoist(node, nodes);
- return nodes;
- }
- },{"../../../types":169}],98:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ObjectExpression = ObjectExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersReplaceSupers = require("../../helpers/replace-supers");
- var _helpersReplaceSupers2 = _interopRequireDefault(_helpersReplaceSupers);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function Property(path, node, scope, getObjectRef, file) {
- if (!node.method && node.kind === "init") return;
- if (!t.isFunction(node.value)) return;
- var replaceSupers = new _helpersReplaceSupers2["default"]({
- getObjectRef: getObjectRef,
- methodNode: node,
- methodPath: path,
- isStatic: true,
- scope: scope,
- file: file
- });
- replaceSupers.replace();
- }
- function ObjectExpression(node, parent, scope, file) {
- var objectRef;
- var getObjectRef = function getObjectRef() {
- return objectRef = objectRef || scope.generateUidIdentifier("obj");
- };
- var propPaths = this.get("properties");
- for (var i = 0; i < node.properties.length; i++) {
- Property(propPaths[i], node.properties[i], scope, getObjectRef, file);
- }
- if (objectRef) {
- scope.push({ id: objectRef });
- return t.assignmentExpression("=", objectRef, node);
- }
- }
- },{"../../../types":169,"../../helpers/replace-supers":69}],99:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Func /*tion*/ = Func;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersCallDelegate = require("../../helpers/call-delegate");
- var _helpersCallDelegate2 = _interopRequireDefault(_helpersCallDelegate);
- var _util = require("../../../util");
- var util = _interopRequireWildcard(_util);
- var _traversal = require("../../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var hasDefaults = function hasDefaults(node) {
- for (var i = 0; i < node.params.length; i++) {
- if (!t.isIdentifier(node.params[i])) return true;
- }
- return false;
- };
- var iifeVisitor = {
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
- if (node.name !== "eval") {
- if (!state.scope.hasOwnBinding(node.name)) return;
- if (state.scope.bindingIdentifierEquals(node.name, node)) return;
- }
- state.iife = true;
- this.stop();
- }
- };
- function Func(node, parent, scope, file) {
- if (!hasDefaults(node)) return;
- t.ensureBlock(node);
- var body = [];
- var argsIdentifier = t.identifier("arguments");
- argsIdentifier._shadowedFunctionLiteral = true;
- var lastNonDefaultParam = 0;
- var state = { iife: false, scope: scope };
- var pushDefNode = function pushDefNode(left, right, i) {
- var defNode = util.template("default-parameter", {
- VARIABLE_NAME: left,
- DEFAULT_VALUE: right,
- ARGUMENT_KEY: t.literal(i),
- ARGUMENTS: argsIdentifier
- }, true);
- defNode._blockHoist = node.params.length - i;
- body.push(defNode);
- };
- var params = this.get("params");
- for (var i = 0; i < params.length; i++) {
- var param = params[i];
- if (!param.isAssignmentPattern()) {
- if (!param.isRestElement()) {
- lastNonDefaultParam = i + 1;
- }
- if (!param.isIdentifier()) {
- param.traverse(iifeVisitor, state);
- }
- if (file.transformers["es6.spec.blockScoping"].canTransform() && param.isIdentifier()) {
- pushDefNode(param.node, t.identifier("undefined"), i);
- }
- continue;
- }
- var left = param.get("left");
- var right = param.get("right");
- var placeholder = scope.generateUidIdentifier("x");
- placeholder._isDefaultPlaceholder = true;
- node.params[i] = placeholder;
- if (!state.iife) {
- if (right.isIdentifier() && scope.hasOwnBinding(right.node.name)) {
- state.iife = true;
- } else {
- right.traverse(iifeVisitor, state);
- }
- }
- pushDefNode(left.node, right.node, i);
- }
- // we need to cut off all trailing default parameters
- node.params = node.params.slice(0, lastNonDefaultParam);
- if (state.iife) {
- body.push((0, _helpersCallDelegate2["default"])(node, scope));
- node.body = t.blockStatement(body);
- } else {
- node.body.body = body.concat(node.body.body);
- }
- }
- },{"../../../traversal":157,"../../../types":169,"../../../util":173,"../../helpers/call-delegate":60}],100:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Func /*tion*/ = Func;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangIsNumber = require("lodash/lang/isNumber");
- var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
- var _util = require("../../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var memberExpressionOptimisationVisitor = {
- enter: function enter(node, parent, scope, state) {
- // check if this scope has a local binding that will shadow the rest parameter
- if (this.isScope() && !scope.bindingIdentifierEquals(state.name, state.outerBinding)) {
- return this.skip();
- }
- // skip over functions as whatever `arguments` we reference inside will refer
- // to the wrong function
- if (this.isFunctionDeclaration() || this.isFunctionExpression()) {
- state.noOptimise = true;
- this.traverse(memberExpressionOptimisationVisitor, state);
- state.noOptimise = false;
- return this.skip();
- }
- // is this a referenced identifier and is it referencing the rest parameter?
- if (!this.isReferencedIdentifier({ name: state.name })) return;
- if (!state.noOptimise && t.isMemberExpression(parent) && parent.computed) {
- // if we know that this member expression is referencing a number then we can safely
- // optimise it
- var prop = parent.property;
- if ((0, _lodashLangIsNumber2["default"])(prop.value) || t.isUnaryExpression(prop) || t.isBinaryExpression(prop)) {
- state.candidates.push(this);
- return;
- }
- }
- state.canOptimise = false;
- this.stop();
- }
- };
- function optimizeMemberExpression(parent, offset) {
- var newExpr;
- var prop = parent.property;
- if (t.isLiteral(prop)) {
- prop.value += offset;
- prop.raw = String(prop.value);
- } else {
- // // UnaryExpression, BinaryExpression
- newExpr = t.binaryExpression("+", prop, t.literal(offset));
- parent.property = newExpr;
- }
- }
- var hasRest = function hasRest(node) {
- return t.isRestElement(node.params[node.params.length - 1]);
- };
- function Func(node, parent, scope, file) {
- if (!hasRest(node)) return;
- var restParam = node.params.pop();
- var rest = restParam.argument;
- var argsId = t.identifier("arguments");
- // otherwise `arguments` will be remapped in arrow functions
- argsId._shadowedFunctionLiteral = true;
- // support patterns
- if (t.isPattern(rest)) {
- var pattern = rest;
- rest = scope.generateUidIdentifier("ref");
- var declar = t.variableDeclaration("let", pattern.elements.map(function (elem, index) {
- var accessExpr = t.memberExpression(rest, t.literal(index), true);
- return t.variableDeclarator(elem, accessExpr);
- }));
- node.body.body.unshift(declar);
- }
- // check if rest is used in member expressions and optimise for those cases
- var state = {
- outerBinding: scope.getBindingIdentifier(rest.name),
- canOptimise: true,
- candidates: [],
- method: node,
- name: rest.name
- };
- this.traverse(memberExpressionOptimisationVisitor, state);
- // we only have shorthands and there's no other references
- if (state.canOptimise && state.candidates.length) {
- for (var i = 0; i < state.candidates.length; i++) {
- var candidate = state.candidates[i];
- candidate.replaceWith(argsId);
- optimizeMemberExpression(candidate.parent, node.params.length);
- }
- return;
- }
- //
- var start = t.literal(node.params.length);
- var key = scope.generateUidIdentifier("key");
- var len = scope.generateUidIdentifier("len");
- var arrKey = key;
- var arrLen = len;
- if (node.params.length) {
- // this method has additional params, so we need to subtract
- // the index of the current argument position from the
- // position in the array that we want to populate
- arrKey = t.binaryExpression("-", key, start);
- // we need to work out the size of the array that we're
- // going to store all the rest parameters
- //
- // we need to add a check to avoid constructing the array
- // with <0 if there are less arguments than params as it'll
- // cause an error
- arrLen = t.conditionalExpression(t.binaryExpression(">", len, start), t.binaryExpression("-", len, start), t.literal(0));
- }
- var loop = util.template("rest", {
- ARRAY_TYPE: restParam.typeAnnotation,
- ARGUMENTS: argsId,
- ARRAY_KEY: arrKey,
- ARRAY_LEN: arrLen,
- START: start,
- ARRAY: rest,
- KEY: key,
- LEN: len
- });
- loop._blockHoist = node.params.length + 1;
- node.body.body.unshift(loop);
- }
- },{"../../../types":169,"../../../util":173,"lodash/lang/isNumber":410}],101:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function loose(node, body, objId) {
- for (var i = 0; i < node.properties.length; i++) {
- var prop = node.properties[i];
- body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(objId, prop.key, prop.computed || t.isLiteral(prop.key)), prop.value)));
- }
- }
- function spec(node, body, objId, initProps, file) {
- var props = node.properties;
- // add all non-computed properties and `__proto__` properties to the initializer
- var broken = false;
- for (var i = 0; i < props.length; i++) {
- var prop = props[i];
- if (prop.computed) {
- broken = true;
- }
- if (prop.kind !== "init" || !broken || t.isLiteral(t.toComputedKey(prop, prop.key), { value: "__proto__" })) {
- initProps.push(prop);
- props[i] = null;
- }
- }
- // add a simple assignment for all Symbol member expressions due to symbol polyfill limitations
- // otherwise use Object.defineProperty
- for (var i = 0; i < props.length; i++) {
- var prop = props[i];
- if (!prop) continue;
- var key = prop.key;
- if (t.isIdentifier(key) && !prop.computed) {
- key = t.literal(key.name);
- }
- var bodyNode = t.callExpression(file.addHelper("define-property"), [objId, key, prop.value]);
- body.push(t.expressionStatement(bodyNode));
- }
- // only one node and it's a Object.defineProperty that returns the object
- if (body.length === 1) {
- var first = body[0].expression;
- if (t.isCallExpression(first)) {
- first.arguments[0] = t.objectExpression(initProps);
- return first;
- }
- }
- }
- var ObjectExpression = {
- exit: function exit(node, parent, scope, file) {
- var hasComputed = false;
- var _arr = node.properties;
- for (var _i = 0; _i < _arr.length; _i++) {
- var prop = _arr[_i];
- hasComputed = t.isProperty(prop, { computed: true, kind: "init" });
- if (hasComputed) break;
- }
- if (!hasComputed) return;
- var initProps = [];
- var objId = scope.generateUidIdentifierBasedOnNode(parent);
- //
- var body = [];
- //
- var callback = spec;
- if (file.isLoose("es6.properties.computed")) callback = loose;
- var result = callback(node, body, objId, initProps, file);
- if (result) return result;
- //
- body.unshift(t.variableDeclaration("var", [t.variableDeclarator(objId, t.objectExpression(initProps))]));
- body.push(t.expressionStatement(objId));
- return body;
- }
- };
- exports.ObjectExpression = ObjectExpression;
- },{"../../../types":169}],102:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Property = Property;
- function Property(node) {
- if (node.method) {
- node.method = false;
- }
- if (node.shorthand) {
- node.shorthand = false;
- }
- }
- },{}],103:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Literal = Literal;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _helpersRegex = require("../../helpers/regex");
- var regex = _interopRequireWildcard(_helpersRegex);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function Literal(node) {
- if (!regex.is(node, "y")) return;
- return t.newExpression(t.identifier("RegExp"), [t.literal(node.regex.pattern), t.literal(node.regex.flags)]);
- }
- },{"../../../types":169,"../../helpers/regex":67}],104:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Literal = Literal;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _regexpuRewritePattern = require("regexpu/rewrite-pattern");
- var _regexpuRewritePattern2 = _interopRequireDefault(_regexpuRewritePattern);
- var _helpersRegex = require("../../helpers/regex");
- var regex = _interopRequireWildcard(_helpersRegex);
- function Literal(node) {
- if (!regex.is(node, "u")) return;
- node.regex.pattern = (0, _regexpuRewritePattern2["default"])(node.regex.pattern, node.regex.flags);
- regex.pullFlag(node, "u");
- }
- },{"../../helpers/regex":67,"regexpu/rewrite-pattern":478}],105:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _traversal = require("../../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var visitor = {
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
- if (t.isFor(parent) && parent.left === node) return;
- var declared = state.letRefs[node.name];
- if (!declared) return;
- // declared node is different in this scope
- if (scope.getBindingIdentifier(node.name) !== declared) return;
- var assert = t.callExpression(state.file.addHelper("temporal-assert-defined"), [node, t.literal(node.name), state.file.addHelper("temporal-undefined")]);
- this.skip();
- if (t.isAssignmentExpression(parent) || t.isUpdateExpression(parent)) {
- if (parent._ignoreBlockScopingTDZ) return;
- this.parentPath.replaceWith(t.sequenceExpression([assert, parent]));
- } else {
- return t.logicalExpression("&&", assert, node);
- }
- }
- };
- var metadata = {
- optional: true,
- group: "builtin-advanced"
- };
- exports.metadata = metadata;
- var BlockStatement = {
- exit: function exit(node, parent, scope, file) {
- var letRefs = node._letReferences;
- if (!letRefs) return;
- this.traverse(visitor, {
- letRefs: letRefs,
- file: file
- });
- }
- };
- exports.BlockStatement = BlockStatement;
- exports.Program = BlockStatement;
- exports.Loop = BlockStatement;
- },{"../../../traversal":157,"../../../types":169}],106:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.UnaryExpression = UnaryExpression;
- exports.BinaryExpression = BinaryExpression;
- exports.VariableDeclaration = VariableDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true
- };
- exports.metadata = metadata;
- function UnaryExpression(node, parent, scope, file) {
- if (node._ignoreSpecSymbols) return;
- if (node.operator === "typeof") {
- var call = t.callExpression(file.addHelper("typeof"), [node.argument]);
- if (this.get("argument").isIdentifier()) {
- var undefLiteral = t.literal("undefined");
- var unary = t.unaryExpression("typeof", node.argument);
- unary._ignoreSpecSymbols = true;
- return t.conditionalExpression(t.binaryExpression("===", unary, undefLiteral), undefLiteral, call);
- } else {
- return call;
- }
- }
- }
- function BinaryExpression(node, parent, scope, file) {
- if (node.operator === "instanceof") {
- return t.callExpression(file.addHelper("instanceof"), [node.left, node.right]);
- }
- }
- function VariableDeclaration(node) {
- if (node._generated) this.skip();
- }
- exports.FunctionDeclaration = VariableDeclaration;
- },{"../../../types":169}],107:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.TemplateLiteral = TemplateLiteral;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true
- };
- exports.metadata = metadata;
- function TemplateLiteral(node, parent, scope, file) {
- if (t.isTaggedTemplateExpression(parent)) return;
- for (var i = 0; i < node.expressions.length; i++) {
- node.expressions[i] = t.callExpression(t.identifier("String"), [node.expressions[i]]);
- }
- }
- },{"../../../types":169}],108:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ArrayExpression = ArrayExpression;
- exports.CallExpression = CallExpression;
- exports.NewExpression = NewExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function getSpreadLiteral(spread, scope) {
- if (scope.file.isLoose("es6.spread")) {
- return spread.argument;
- } else {
- return scope.toArray(spread.argument, true);
- }
- }
- function hasSpread(nodes) {
- for (var i = 0; i < nodes.length; i++) {
- if (t.isSpreadElement(nodes[i])) {
- return true;
- }
- }
- return false;
- }
- function build(props, scope) {
- var nodes = [];
- var _props = [];
- var push = function push() {
- if (!_props.length) return;
- nodes.push(t.arrayExpression(_props));
- _props = [];
- };
- for (var i = 0; i < props.length; i++) {
- var prop = props[i];
- if (t.isSpreadElement(prop)) {
- push();
- nodes.push(getSpreadLiteral(prop, scope));
- } else {
- _props.push(prop);
- }
- }
- push();
- return nodes;
- }
- function ArrayExpression(node, parent, scope) {
- var elements = node.elements;
- if (!hasSpread(elements)) return;
- var nodes = build(elements, scope);
- var first = nodes.shift();
- if (!t.isArrayExpression(first)) {
- nodes.unshift(first);
- first = t.arrayExpression([]);
- }
- return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
- }
- function CallExpression(node, parent, scope) {
- var args = node.arguments;
- if (!hasSpread(args)) return;
- var contextLiteral = t.identifier("undefined");
- node.arguments = [];
- var nodes;
- if (args.length === 1 && args[0].argument.name === "arguments") {
- nodes = [args[0].argument];
- } else {
- nodes = build(args, scope);
- }
- var first = nodes.shift();
- if (nodes.length) {
- node.arguments.push(t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes));
- } else {
- node.arguments.push(first);
- }
- var callee = node.callee;
- if (this.get("callee").isMemberExpression()) {
- var temp = scope.maybeGenerateMemoised(callee.object);
- if (temp) {
- callee.object = t.assignmentExpression("=", temp, callee.object);
- contextLiteral = temp;
- } else {
- contextLiteral = callee.object;
- }
- t.appendToMemberExpression(callee, t.identifier("apply"));
- } else {
- node.callee = t.memberExpression(node.callee, t.identifier("apply"));
- }
- node.arguments.unshift(contextLiteral);
- }
- function NewExpression(node, parent, scope, file) {
- var args = node.arguments;
- if (!hasSpread(args)) return;
- var nodes = build(args, scope);
- var context = t.arrayExpression([t.literal(null)]);
- args = t.callExpression(t.memberExpression(context, t.identifier("concat")), nodes);
- return t.newExpression(t.callExpression(t.memberExpression(file.addHelper("bind"), t.identifier("apply")), [node.callee, args]), []);
- }
- },{"../../../types":169,"lodash/collection/includes":332}],109:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Func /*tion*/ = Func;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _lodashCollectionReduceRight = require("lodash/collection/reduceRight");
- var _lodashCollectionReduceRight2 = _interopRequireDefault(_lodashCollectionReduceRight);
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _lodashArrayFlatten = require("lodash/array/flatten");
- var _lodashArrayFlatten2 = _interopRequireDefault(_lodashArrayFlatten);
- var _traversal = require("../../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _util = require("../../../util");
- var util = _interopRequireWildcard(_util);
- var _lodashCollectionMap = require("lodash/collection/map");
- var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-trailing"
- };
- exports.metadata = metadata;
- function Func(node, parent, scope, file) {
- if (node.generator || node.async) return;
- var tailCall = new TailCallTransformer(this, scope, file);
- tailCall.run();
- }
- function returnBlock(expr) {
- return t.blockStatement([t.returnStatement(expr)]);
- }
- var visitor = {
- enter: function enter(node, parent, scope, state) {
- if (t.isTryStatement(parent)) {
- if (node === parent.block) {
- this.skip();
- } else if (parent.finalizer && node !== parent.finalizer) {
- this.skip();
- }
- }
- },
- ReturnStatement: function ReturnStatement(node, parent, scope, state) {
- return state.subTransform(node.argument);
- },
- Function: function Function(node, parent, scope, state) {
- this.skip();
- },
- VariableDeclaration: function VariableDeclaration(node, parent, scope, state) {
- state.vars.push(node);
- },
- ThisExpression: function ThisExpression(node, parent, scope, state) {
- state.needsThis = true;
- state.thisPaths.push(this);
- },
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
- if (node.name === "arguments") {
- state.needsArguments = true;
- state.argumentsPaths.push(this);
- }
- }
- };
- var TailCallTransformer = (function () {
- function TailCallTransformer(path, scope, file) {
- _classCallCheck(this, TailCallTransformer);
- this.hasTailRecursion = false;
- this.needsArguments = false;
- this.argumentsPaths = [];
- this.setsArguments = false;
- this.needsThis = false;
- this.thisPaths = [];
- this.ownerId = path.node.id;
- this.vars = [];
- this.scope = scope;
- this.path = path;
- this.file = file;
- this.node = path.node;
- }
- TailCallTransformer.prototype.getArgumentsId = function getArgumentsId() {
- return this.argumentsId = this.argumentsId || this.scope.generateUidIdentifier("arguments");
- };
- TailCallTransformer.prototype.getThisId = function getThisId() {
- return this.thisId = this.thisId || this.scope.generateUidIdentifier("this");
- };
- TailCallTransformer.prototype.getLeftId = function getLeftId() {
- return this.leftId = this.leftId || this.scope.generateUidIdentifier("left");
- };
- TailCallTransformer.prototype.getFunctionId = function getFunctionId() {
- return this.functionId = this.functionId || this.scope.generateUidIdentifier("function");
- };
- TailCallTransformer.prototype.getAgainId = function getAgainId() {
- return this.againId = this.againId || this.scope.generateUidIdentifier("again");
- };
- TailCallTransformer.prototype.getParams = function getParams() {
- var params = this.params;
- if (!params) {
- params = this.node.params;
- this.paramDecls = [];
- for (var i = 0; i < params.length; i++) {
- var param = params[i];
- if (!param._isDefaultPlaceholder) {
- this.paramDecls.push(t.variableDeclarator(param, params[i] = this.scope.generateUidIdentifier("x")));
- }
- }
- }
- return this.params = params;
- };
- TailCallTransformer.prototype.hasDeopt = function hasDeopt() {
- // check if the ownerId has been reassigned, if it has then it's not safe to
- // perform optimisations
- var ownerIdInfo = this.scope.getBinding(this.ownerId.name);
- return ownerIdInfo && !ownerIdInfo.constant;
- };
- TailCallTransformer.prototype.run = function run() {
- var scope = this.scope;
- var node = this.node;
- // only tail recursion can be optimized as for now, so we can skip anonymous
- // functions entirely
- var ownerId = this.ownerId;
- if (!ownerId) return;
- // traverse the function and look for tail recursion
- this.path.traverse(visitor, this);
- // has no tail call recursion
- if (!this.hasTailRecursion) return;
- // the function binding isn't constant so we can't be sure that it's the same function :(
- if (this.hasDeopt()) {
- this.file.log.deopt(node, messages.get("tailCallReassignmentDeopt"));
- return;
- }
- //
- var body = t.ensureBlock(node).body;
- for (var i = 0; i < body.length; i++) {
- var bodyNode = body[i];
- if (!t.isFunctionDeclaration(bodyNode)) continue;
- bodyNode = body[i] = t.variableDeclaration("var", [t.variableDeclarator(bodyNode.id, t.toExpression(bodyNode))]);
- bodyNode._blockHoist = 2;
- }
- if (this.vars.length > 0) {
- var declarations = (0, _lodashArrayFlatten2["default"])((0, _lodashCollectionMap2["default"])(this.vars, function (decl) {
- return decl.declarations;
- }));
- var assignment = (0, _lodashCollectionReduceRight2["default"])(declarations, function (expr, decl) {
- return t.assignmentExpression("=", decl.id, expr);
- }, t.identifier("undefined"));
- var statement = t.expressionStatement(assignment);
- statement._blockHoist = Infinity;
- body.unshift(statement);
- }
- var paramDecls = this.paramDecls;
- if (paramDecls.length > 0) {
- var paramDecl = t.variableDeclaration("var", paramDecls);
- paramDecl._blockHoist = Infinity;
- body.unshift(paramDecl);
- }
- body.unshift(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(false))));
- node.body = util.template("tail-call-body", {
- FUNCTION_ID: this.getFunctionId(),
- AGAIN_ID: this.getAgainId(),
- BLOCK: node.body
- });
- var topVars = [];
- if (this.needsThis) {
- var _arr = this.thisPaths;
- for (var _i = 0; _i < _arr.length; _i++) {
- var path = _arr[_i];
- path.replaceWith(this.getThisId());
- }
- topVars.push(t.variableDeclarator(this.getThisId(), t.thisExpression()));
- }
- if (this.needsArguments || this.setsArguments) {
- var _arr2 = this.argumentsPaths;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var path = _arr2[_i2];
- path.replaceWith(this.argumentsId);
- }
- var decl = t.variableDeclarator(this.argumentsId);
- if (this.argumentsId) {
- decl.init = t.identifier("arguments");
- }
- topVars.push(decl);
- }
- var leftId = this.leftId;
- if (leftId) {
- topVars.push(t.variableDeclarator(leftId));
- }
- if (topVars.length > 0) {
- node.body.body.unshift(t.variableDeclaration("var", topVars));
- }
- };
- TailCallTransformer.prototype.subTransform = function subTransform(node) {
- if (!node) return;
- var handler = this["subTransform" + node.type];
- if (handler) return handler.call(this, node);
- };
- TailCallTransformer.prototype.subTransformConditionalExpression = function subTransformConditionalExpression(node) {
- var callConsequent = this.subTransform(node.consequent);
- var callAlternate = this.subTransform(node.alternate);
- if (!callConsequent && !callAlternate) {
- return;
- }
- // if ternary operator had tail recursion in value, convert to optimized if-statement
- node.type = "IfStatement";
- node.consequent = callConsequent ? t.toBlock(callConsequent) : returnBlock(node.consequent);
- if (callAlternate) {
- node.alternate = t.isIfStatement(callAlternate) ? callAlternate : t.toBlock(callAlternate);
- } else {
- node.alternate = returnBlock(node.alternate);
- }
- return [node];
- };
- TailCallTransformer.prototype.subTransformLogicalExpression = function subTransformLogicalExpression(node) {
- // only call in right-value of can be optimized
- var callRight = this.subTransform(node.right);
- if (!callRight) return;
- // cache left value as it might have side-effects
- var leftId = this.getLeftId();
- var testExpr = t.assignmentExpression("=", leftId, node.left);
- if (node.operator === "&&") {
- testExpr = t.unaryExpression("!", testExpr);
- }
- return [t.ifStatement(testExpr, returnBlock(leftId))].concat(callRight);
- };
- TailCallTransformer.prototype.subTransformSequenceExpression = function subTransformSequenceExpression(node) {
- var seq = node.expressions;
- // only last element can be optimized
- var lastCall = this.subTransform(seq[seq.length - 1]);
- if (!lastCall) {
- return;
- }
- // remove converted expression from sequence
- // and convert to regular expression if needed
- if (--seq.length === 1) {
- node = seq[0];
- }
- return [t.expressionStatement(node)].concat(lastCall);
- };
- TailCallTransformer.prototype.subTransformCallExpression = function subTransformCallExpression(node) {
- var callee = node.callee,
- thisBinding,
- args;
- if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) {
- switch (callee.property.name) {
- case "call":
- args = t.arrayExpression(node.arguments.slice(1));
- break;
- case "apply":
- args = node.arguments[1] || t.identifier("undefined");
- break;
- default:
- return;
- }
- thisBinding = node.arguments[0];
- callee = callee.object;
- }
- // only tail recursion can be optimized as for now
- if (!t.isIdentifier(callee) || !this.scope.bindingIdentifierEquals(callee.name, this.ownerId)) {
- return;
- }
- this.hasTailRecursion = true;
- if (this.hasDeopt()) return;
- var body = [];
- if (this.needsThis && !t.isThisExpression(thisBinding)) {
- body.push(t.expressionStatement(t.assignmentExpression("=", this.getThisId(), thisBinding || t.identifier("undefined"))));
- }
- if (!args) {
- args = t.arrayExpression(node.arguments);
- }
- var argumentsId = this.getArgumentsId();
- var params = this.getParams();
- if (this.needsArguments) {
- body.push(t.expressionStatement(t.assignmentExpression("=", argumentsId, args)));
- }
- if (t.isArrayExpression(args)) {
- var elems = args.elements;
- for (var i = 0; i < elems.length && i < params.length; i++) {
- var param = params[i];
- var elem = elems[i] || (elems[i] = t.identifier("undefined"));
- if (!param._isDefaultPlaceholder) {
- elems[i] = t.assignmentExpression("=", param, elem);
- }
- }
- if (!this.needsArguments) {
- var _arr3 = elems;
- for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
- var elem = _arr3[_i3];
- body.push(t.expressionStatement(elem));
- }
- }
- } else {
- this.setsArguments = true;
- for (var i = 0; i < params.length; i++) {
- var param = params[i];
- if (!param._isDefaultPlaceholder) {
- body.push(t.expressionStatement(t.assignmentExpression("=", param, t.memberExpression(argumentsId, t.literal(i), true))));
- }
- }
- }
- body.push(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(true))));
- body.push(t.continueStatement(this.getFunctionId()));
- return body;
- };
- return TailCallTransformer;
- })();
- },{"../../../messages":47,"../../../traversal":157,"../../../types":169,"../../../util":173,"lodash/array/flatten":325,"lodash/collection/map":333,"lodash/collection/reduceRight":334}],110:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.TaggedTemplateExpression = TaggedTemplateExpression;
- exports.TemplateLiteral = TemplateLiteral;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var buildBinaryExpression = function buildBinaryExpression(left, right) {
- return t.binaryExpression("+", left, right);
- };
- function TaggedTemplateExpression(node, parent, scope, file) {
- var quasi = node.quasi;
- var args = [];
- var strings = [];
- var raw = [];
- for (var i = 0; i < quasi.quasis.length; i++) {
- var elem = quasi.quasis[i];
- strings.push(t.literal(elem.value.cooked));
- raw.push(t.literal(elem.value.raw));
- }
- strings = t.arrayExpression(strings);
- raw = t.arrayExpression(raw);
- var templateName = "tagged-template-literal";
- if (file.isLoose("es6.templateLiterals")) templateName += "-loose";
- args.push(t.callExpression(file.addHelper(templateName), [strings, raw]));
- args = args.concat(quasi.expressions);
- return t.callExpression(node.tag, args);
- }
- function TemplateLiteral(node, parent, scope, file) {
- var nodes = [];
- var i;
- for (i = 0; i < node.quasis.length; i++) {
- var elem = node.quasis[i];
- nodes.push(t.literal(elem.value.cooked));
- var expr = node.expressions.shift();
- if (expr) nodes.push(expr);
- }
- if (nodes.length > 1) {
- // remove redundant '' at the end of the expression
- var last = nodes[nodes.length - 1];
- if (t.isLiteral(last, { value: "" })) nodes.pop();
- var root = buildBinaryExpression(nodes.shift(), nodes.shift());
- for (i = 0; i < nodes.length; i++) {
- root = buildBinaryExpression(root, nodes[i]);
- }
- return root;
- } else {
- return nodes[0];
- }
- }
- },{"../../../types":169}],111:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- var metadata = {
- stage: 1
- };
- exports.metadata = metadata;
- },{}],112:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- var metadata = {
- stage: 0,
- dependencies: ["es6.classes"]
- };
- exports.metadata = metadata;
- },{}],113:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ComprehensionExpression = ComprehensionExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersBuildComprehension = require("../../helpers/build-comprehension");
- var _helpersBuildComprehension2 = _interopRequireDefault(_helpersBuildComprehension);
- var _traversal = require("../../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _util = require("../../../util");
- var util = _interopRequireWildcard(_util);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- stage: 0
- };
- exports.metadata = metadata;
- function ComprehensionExpression(node, parent, scope, file) {
- var callback = array;
- if (node.generator) callback = generator;
- return callback(node, parent, scope, file);
- }
- function generator(node) {
- var body = [];
- var container = t.functionExpression(null, [], t.blockStatement(body), true);
- container.shadow = true;
- body.push((0, _helpersBuildComprehension2["default"])(node, function () {
- return t.expressionStatement(t.yieldExpression(node.body));
- }));
- return t.callExpression(container, []);
- }
- function array(node, parent, scope, file) {
- var uid = scope.generateUidIdentifierBasedOnNode(parent);
- var container = util.template("array-comprehension-container", {
- KEY: uid
- });
- container.callee.shadow = true;
- var block = container.callee.body;
- var body = block.body;
- if (_traversal2["default"].hasType(node, scope, "YieldExpression", t.FUNCTION_TYPES)) {
- container.callee.generator = true;
- container = t.yieldExpression(container, true);
- }
- var returnStatement = body.pop();
- body.push((0, _helpersBuildComprehension2["default"])(node, function () {
- return util.template("array-push", {
- STATEMENT: node.body,
- KEY: uid
- }, true);
- }));
- body.push(returnStatement);
- return container;
- }
- },{"../../../traversal":157,"../../../types":169,"../../../util":173,"../../helpers/build-comprehension":58}],114:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ObjectExpression = ObjectExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersMemoiseDecorators = require("../../helpers/memoise-decorators");
- var _helpersMemoiseDecorators2 = _interopRequireDefault(_helpersMemoiseDecorators);
- var _helpersDefineMap = require("../../helpers/define-map");
- var defineMap = _interopRequireWildcard(_helpersDefineMap);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- dependencies: ["es6.classes"],
- optional: true,
- stage: 1
- };
- exports.metadata = metadata;
- function ObjectExpression(node, parent, scope, file) {
- var hasDecorators = false;
- for (var i = 0; i < node.properties.length; i++) {
- var prop = node.properties[i];
- if (prop.decorators) {
- hasDecorators = true;
- break;
- }
- }
- if (!hasDecorators) return;
- var mutatorMap = {};
- for (var i = 0; i < node.properties.length; i++) {
- var prop = node.properties[i];
- if (prop.decorators) (0, _helpersMemoiseDecorators2["default"])(prop.decorators, scope);
- if (prop.kind === "init") {
- prop.kind = "";
- prop.value = t.functionExpression(null, [], t.blockStatement([t.returnStatement(prop.value)]));
- }
- defineMap.push(mutatorMap, prop, "initializer", file);
- }
- var obj = defineMap.toClassObject(mutatorMap);
- obj = defineMap.toComputedObjectFromClass(obj);
- return t.callExpression(file.addHelper("create-decorated-object"), [obj]);
- }
- },{"../../../types":169,"../../helpers/define-map":61,"../../helpers/memoise-decorators":64}],115:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.DoExpression = DoExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- stage: 0
- };
- exports.metadata = metadata;
- function DoExpression(node) {
- var body = node.body.body;
- if (body.length) {
- return body;
- } else {
- return t.identifier("undefined");
- }
- }
- },{"../../../types":169}],116:[function(require,module,exports){
- // https://github.com/rwaldron/exponentiation-operator
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersBuildBinaryAssignmentOperatorTransformer = require("../../helpers/build-binary-assignment-operator-transformer");
- var _helpersBuildBinaryAssignmentOperatorTransformer2 = _interopRequireDefault(_helpersBuildBinaryAssignmentOperatorTransformer);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- stage: 2
- };
- exports.metadata = metadata;
- var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
- var _build = (0, _helpersBuildBinaryAssignmentOperatorTransformer2["default"])({
- operator: "**",
- build: function build(left, right) {
- return t.callExpression(MATH_POW, [left, right]);
- }
- });
- var ExpressionStatement = _build.ExpressionStatement;
- var AssignmentExpression = _build.AssignmentExpression;
- var BinaryExpression = _build.BinaryExpression;
- exports.ExpressionStatement = ExpressionStatement;
- exports.AssignmentExpression = AssignmentExpression;
- exports.BinaryExpression = BinaryExpression;
- },{"../../../types":169,"../../helpers/build-binary-assignment-operator-transformer":57}],117:[function(require,module,exports){
- // https://github.com/leebyron/ecmascript-more-export-from
- "use strict";
- exports.__esModule = true;
- exports.ExportNamedDeclaration = ExportNamedDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- stage: 1
- };
- exports.metadata = metadata;
- function build(node, nodes, scope) {
- var first = node.specifiers[0];
- if (!t.isExportNamespaceSpecifier(first) && !t.isExportDefaultSpecifier(first)) return;
- var specifier = node.specifiers.shift();
- var uid = scope.generateUidIdentifier(specifier.exported.name);
- var newSpecifier;
- if (t.isExportNamespaceSpecifier(specifier)) {
- newSpecifier = t.importNamespaceSpecifier(uid);
- } else {
- newSpecifier = t.importDefaultSpecifier(uid);
- }
- nodes.push(t.importDeclaration([newSpecifier], node.source));
- nodes.push(t.exportNamedDeclaration(null, [t.exportSpecifier(uid, specifier.exported)]));
- build(node, nodes, scope);
- }
- function ExportNamedDeclaration(node, parent, scope) {
- var nodes = [];
- build(node, nodes, scope);
- if (!nodes.length) return;
- if (node.specifiers.length >= 1) {
- nodes.push(node);
- }
- return nodes;
- }
- },{"../../../types":169}],118:[function(require,module,exports){
- // https://github.com/zenparsing/es-function-bind
- "use strict";
- exports.__esModule = true;
- exports.CallExpression = CallExpression;
- exports.BindExpression = BindExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- stage: 0
- };
- exports.metadata = metadata;
- function getTempId(scope) {
- var id = scope.path.getData("functionBind");
- if (id) return id;
- id = scope.generateDeclaredUidIdentifier("context");
- return scope.path.setData("functionBind", id);
- }
- function getStaticContext(bind, scope) {
- var object = bind.object || bind.callee.object;
- return scope.isStatic(object) && object;
- }
- function inferBindContext(bind, scope) {
- var staticContext = getStaticContext(bind, scope);
- if (staticContext) return staticContext;
- var tempId = getTempId(scope);
- if (bind.object) {
- bind.callee = t.sequenceExpression([t.assignmentExpression("=", tempId, bind.object), bind.callee]);
- } else {
- bind.callee.object = t.assignmentExpression("=", tempId, bind.callee.object);
- }
- return tempId;
- }
- function CallExpression(node, parent, scope, file) {
- var bind = node.callee;
- if (!t.isBindExpression(bind)) return;
- var context = inferBindContext(bind, scope);
- node.callee = t.memberExpression(bind.callee, t.identifier("call"));
- node.arguments.unshift(context);
- }
- function BindExpression(node, parent, scope, file) {
- var context = inferBindContext(node, scope);
- return t.callExpression(t.memberExpression(node.callee, t.identifier("bind")), [context]);
- }
- },{"../../../types":169}],119:[function(require,module,exports){
- // https://github.com/sebmarkbage/ecmascript-rest-spread
- "use strict";
- exports.__esModule = true;
- exports.ObjectExpression = ObjectExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- stage: 1,
- dependencies: ["es6.destructuring"]
- };
- exports.metadata = metadata;
- var hasSpread = function hasSpread(node) {
- for (var i = 0; i < node.properties.length; i++) {
- if (t.isSpreadProperty(node.properties[i])) {
- return true;
- }
- }
- return false;
- };
- function ObjectExpression(node, parent, scope, file) {
- if (!hasSpread(node)) return;
- var args = [];
- var props = [];
- var push = function push() {
- if (!props.length) return;
- args.push(t.objectExpression(props));
- props = [];
- };
- for (var i = 0; i < node.properties.length; i++) {
- var prop = node.properties[i];
- if (t.isSpreadProperty(prop)) {
- push();
- args.push(prop.argument);
- } else {
- props.push(prop);
- }
- }
- push();
- if (!t.isObjectExpression(args[0])) {
- args.unshift(t.objectExpression([]));
- }
- return t.callExpression(file.addHelper("extends"), args);
- }
- },{"../../../types":169}],120:[function(require,module,exports){
- arguments[4][111][0].apply(exports,arguments)
- },{"dup":111}],121:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.internal = internal;
- exports.blacklist = blacklist;
- exports.whitelist = whitelist;
- exports.stage = stage;
- exports.optional = optional;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- function internal(transformer, opts) {
- if (transformer.key[0] === "_") return true;
- }
- function blacklist(transformer, opts) {
- var blacklist = opts.blacklist;
- if (blacklist.length && (0, _lodashCollectionIncludes2["default"])(blacklist, transformer.key)) return false;
- }
- function whitelist(transformer, opts) {
- var whitelist = opts.whitelist;
- if (whitelist) return (0, _lodashCollectionIncludes2["default"])(whitelist, transformer.key);
- }
- function stage(transformer, opts) {
- var stage = transformer.metadata.stage;
- if (stage != null && stage >= opts.stage) return true;
- }
- function optional(transformer, opts) {
- if (transformer.metadata.optional && !(0, _lodashCollectionIncludes2["default"])(opts.optional, transformer.key)) return false;
- }
- },{"lodash/collection/includes":332}],122:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports["default"] = {
- //- builtin-setup
- strict: require("./other/strict"),
- _explode: require("./internal/explode"),
- _validation: require("./internal/validation"),
- _hoistDirectives: require("./internal/hoist-directives"),
- "minification.removeDebugger": require("./minification/remove-debugger"),
- "minification.removeConsole": require("./minification/remove-console"),
- "utility.inlineEnvironmentVariables": require("./utility/inline-environment-variables"),
- "minification.inlineExpressions": require("./minification/inline-expressions"),
- "minification.deadCodeElimination": require("./minification/dead-code-elimination"),
- _modules: require("./internal/modules"),
- "spec.functionName": require("./spec/function-name"),
- //- builtin-basic
- // this is where the bulk of the ES6 transformations take place, none of them require traversal state
- // so they can all be concatenated together for performance
- "es7.classProperties": require("./es7/class-properties"),
- "es7.trailingFunctionCommas": require("./es7/trailing-function-commas"),
- "es7.asyncFunctions": require("./es7/async-functions"),
- "es7.decorators": require("./es7/decorators"),
- "validation.undeclaredVariableCheck": require("./validation/undeclared-variable-check"),
- "validation.react": require("./validation/react"),
- "es6.arrowFunctions": require("./es6/arrow-functions"),
- "spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
- "optimisation.react.constantElements": require("./optimisation/react.constant-elements"),
- "optimisation.react.inlineElements": require("./optimisation/react.inline-elements"),
- "es7.comprehensions": require("./es7/comprehensions"),
- "es6.classes": require("./es6/classes"),
- asyncToGenerator: require("./other/async-to-generator"),
- bluebirdCoroutines: require("./other/bluebird-coroutines"),
- "es6.objectSuper": require("./es6/object-super"),
- "es7.objectRestSpread": require("./es7/object-rest-spread"),
- "es7.exponentiationOperator": require("./es7/exponentiation-operator"),
- "es6.spec.templateLiterals": require("./es6/spec.template-literals"),
- "es6.templateLiterals": require("./es6/template-literals"),
- "es5.properties.mutators": require("./es5/properties.mutators"),
- "es6.properties.shorthand": require("./es6/properties.shorthand"),
- "es6.properties.computed": require("./es6/properties.computed"),
- "optimisation.flow.forOf": require("./optimisation/flow.for-of"),
- "es6.forOf": require("./es6/for-of"),
- "es6.regex.sticky": require("./es6/regex.sticky"),
- "es6.regex.unicode": require("./es6/regex.unicode"),
- "es6.constants": require("./es6/constants"),
- "es6.parameters.rest": require("./es6/parameters.rest"),
- "es6.spread": require("./es6/spread"),
- "es6.parameters.default": require("./es6/parameters.default"),
- "es7.exportExtensions": require("./es7/export-extensions"),
- "spec.protoToAssign": require("./spec/proto-to-assign"),
- "es7.doExpressions": require("./es7/do-expressions"),
- "es6.spec.symbols": require("./es6/spec.symbols"),
- "es7.functionBind": require("./es7/function-bind"),
- "spec.undefinedToVoid": require("./spec/undefined-to-void"),
- jscript: require("./other/jscript"),
- flow: require("./other/flow"),
- //- builtin-advanced
- "es6.destructuring": require("./es6/destructuring"),
- "es6.blockScoping": require("./es6/block-scoping"),
- "es6.spec.blockScoping": require("./es6/spec.block-scoping"),
- reactCompat: require("./other/react-compat"),
- react: require("./other/react"),
- // es6 syntax transformation is **forbidden** past this point since regenerator will chuck a massive
- // hissy fit
- //- regenerator
- regenerator: require("./other/regenerator"),
- //- builtin-modules
- runtime: require("./other/runtime"),
- "es6.modules": require("./es6/modules"),
- _moduleFormatter: require("./internal/module-formatter"),
- //- builtin-trailing
- // these clean up the output and do finishing up transformations, it's important to note that by this
- // stage you can't import any new modules or insert new ES6 as all those transformers have already
- // been ran
- "es6.tailCall": require("./es6/tail-call"),
- _shadowFunctions: require("./internal/shadow-functions"),
- "es3.propertyLiterals": require("./es3/property-literals"),
- "es3.memberExpressionLiterals": require("./es3/member-expression-literals"),
- "minification.memberExpressionLiterals": require("./minification/member-expression-literals"),
- "minification.propertyLiterals": require("./minification/property-literals"),
- _blockHoist: require("./internal/block-hoist") };
- module.exports = exports["default"];
- },{"./es3/member-expression-literals":88,"./es3/property-literals":89,"./es5/properties.mutators":90,"./es6/arrow-functions":91,"./es6/block-scoping":92,"./es6/classes":93,"./es6/constants":94,"./es6/destructuring":95,"./es6/for-of":96,"./es6/modules":97,"./es6/object-super":98,"./es6/parameters.default":99,"./es6/parameters.rest":100,"./es6/properties.computed":101,"./es6/properties.shorthand":102,"./es6/regex.sticky":103,"./es6/regex.unicode":104,"./es6/spec.block-scoping":105,"./es6/spec.symbols":106,"./es6/spec.template-literals":107,"./es6/spread":108,"./es6/tail-call":109,"./es6/template-literals":110,"./es7/async-functions":111,"./es7/class-properties":112,"./es7/comprehensions":113,"./es7/decorators":114,"./es7/do-expressions":115,"./es7/exponentiation-operator":116,"./es7/export-extensions":117,"./es7/function-bind":118,"./es7/object-rest-spread":119,"./es7/trailing-function-commas":120,"./internal/block-hoist":123,"./internal/explode":124,"./internal/hoist-directives":125,"./internal/module-formatter":126,"./internal/modules":127,"./internal/shadow-functions":128,"./internal/validation":129,"./minification/dead-code-elimination":130,"./minification/inline-expressions":131,"./minification/member-expression-literals":132,"./minification/property-literals":133,"./minification/remove-console":134,"./minification/remove-debugger":135,"./optimisation/flow.for-of":136,"./optimisation/react.constant-elements":137,"./optimisation/react.inline-elements":138,"./other/async-to-generator":139,"./other/bluebird-coroutines":140,"./other/flow":141,"./other/jscript":142,"./other/react":144,"./other/react-compat":143,"./other/regenerator":145,"./other/runtime":147,"./other/strict":148,"./spec/block-scoped-functions":149,"./spec/function-name":150,"./spec/proto-to-assign":151,"./spec/undefined-to-void":152,"./utility/inline-environment-variables":153,"./validation/react":154,"./validation/undeclared-variable-check":155}],123:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionSortBy = require("lodash/collection/sortBy");
- var _lodashCollectionSortBy2 = _interopRequireDefault(_lodashCollectionSortBy);
- var metadata = {
- group: "builtin-trailing"
- };
- exports.metadata = metadata;
- // Priority:
- //
- // - 0 We want this to be at the **very** bottom
- // - 1 Default node position
- // - 2 Priority over normal nodes
- // - 3 We want this to be at the **very** top
- var BlockStatement = {
- exit: function exit(node) {
- var hasChange = false;
- for (var i = 0; i < node.body.length; i++) {
- var bodyNode = node.body[i];
- if (bodyNode && bodyNode._blockHoist != null) hasChange = true;
- }
- if (!hasChange) return;
- node.body = (0, _lodashCollectionSortBy2["default"])(node.body, function (bodyNode) {
- var priority = bodyNode && bodyNode._blockHoist;
- if (priority == null) priority = 1;
- if (priority === true) priority = 2;
- // Higher priorities should move toward the top.
- return -1 * priority;
- });
- }
- };
- exports.BlockStatement = BlockStatement;
- exports.Program = BlockStatement;
- },{"lodash/collection/sortBy":336}],124:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangClone = require("lodash/lang/clone");
- var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- function buildClone(bindingKey, refKey) {
- return function (node) {
- if (node[bindingKey] === node[refKey]) {
- node[refKey] = t.removeComments((0, _lodashLangClone2["default"])(node[refKey]));
- }
- };
- }
- function buildListClone(listKey, bindingKey, refKey) {
- var clone = buildClone(bindingKey, refKey);
- return function (node) {
- if (!node[listKey]) return;
- var _arr = node[listKey];
- for (var _i = 0; _i < _arr.length; _i++) {
- var subNode = _arr[_i];
- clone(subNode);
- }
- };
- }
- var Property = buildClone("value", "key");
- exports.Property = Property;
- var ExportDeclaration = buildListClone("specifiers", "local", "exported");
- exports.ExportDeclaration = ExportDeclaration;
- var ImportDeclaration = buildListClone("specifiers", "local", "imported");
- exports.ImportDeclaration = ImportDeclaration;
- },{"../../../types":169,"lodash/lang/clone":402}],125:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- var BlockStatement = {
- exit: function exit(node) {
- for (var i = 0; i < node.body.length; i++) {
- var bodyNode = node.body[i];
- if (t.isExpressionStatement(bodyNode) && t.isLiteral(bodyNode.expression)) {
- bodyNode._blockHoist = Infinity;
- } else {
- return;
- }
- }
- }
- };
- exports.BlockStatement = BlockStatement;
- exports.Program = BlockStatement;
- },{"../../../types":169}],126:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _helpersStrict = require("../../helpers/strict");
- var strict = _interopRequireWildcard(_helpersStrict);
- var metadata = {
- group: "builtin-modules"
- };
- exports.metadata = metadata;
- var Program = {
- exit: function exit(program, parent, scope, file) {
- strict.wrap(program, function () {
- // ensure that these are at the top, just like normal imports
- var _arr = file.dynamicImports;
- for (var _i = 0; _i < _arr.length; _i++) {
- var node = _arr[_i];
- node._blockHoist = 3;
- }
- program.body = file.dynamicImports.concat(program.body);
- });
- if (!file.transformers["es6.modules"].canTransform()) return;
- if (file.moduleFormatter.transform) {
- file.moduleFormatter.transform(program);
- }
- }
- };
- exports.Program = Program;
- },{"../../helpers/strict":70}],127:[function(require,module,exports){
- // in this transformer we have to split up classes and function declarations
- // from their exports. why? because sometimes we need to replace classes with
- // nodes that aren't allowed in the same contexts. also, if you're exporting
- // a generator function as a default then regenerator will destroy the export
- // declaration and leave a variable declaration in it's place... yeah, handy.
- "use strict";
- exports.__esModule = true;
- exports.ImportDeclaration = ImportDeclaration;
- exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
- exports.ExportNamedDeclaration = ExportNamedDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangClone = require("lodash/lang/clone");
- var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- function ImportDeclaration(node, parent, scope, file) {
- if (node.source) {
- node.source.value = file.resolveModuleSource(node.source.value);
- }
- }
- exports.ExportAllDeclaration = ImportDeclaration;
- function ExportDefaultDeclaration(node, parent, scope) {
- ImportDeclaration.apply(this, arguments);
- var declar = node.declaration;
- var getDeclar = function getDeclar() {
- declar._ignoreUserWhitespace = true;
- return declar;
- };
- if (t.isClassDeclaration(declar)) {
- // export default class Foo {};
- node.declaration = declar.id;
- return [getDeclar(), node];
- } else if (t.isClassExpression(declar)) {
- // export default class {};
- var temp = scope.generateUidIdentifier("default");
- declar = t.variableDeclaration("var", [t.variableDeclarator(temp, declar)]);
- node.declaration = temp;
- return [getDeclar(), node];
- } else if (t.isFunctionDeclaration(declar)) {
- // export default function Foo() {}
- node._blockHoist = 2;
- node.declaration = declar.id;
- return [getDeclar(), node];
- }
- }
- function buildExportSpecifier(id) {
- return t.exportSpecifier((0, _lodashLangClone2["default"])(id), (0, _lodashLangClone2["default"])(id));
- }
- function ExportNamedDeclaration(node, parent, scope) {
- ImportDeclaration.apply(this, arguments);
- var declar = node.declaration;
- var getDeclar = function getDeclar() {
- declar._ignoreUserWhitespace = true;
- return declar;
- };
- if (t.isClassDeclaration(declar)) {
- // export class Foo {}
- node.specifiers = [buildExportSpecifier(declar.id)];
- node.declaration = null;
- return [getDeclar(), node];
- } else if (t.isFunctionDeclaration(declar)) {
- // export function Foo() {}
- node.specifiers = [buildExportSpecifier(declar.id)];
- node.declaration = null;
- node._blockHoist = 2;
- return [getDeclar(), node];
- } else if (t.isVariableDeclaration(declar)) {
- // export var foo = "bar";
- var specifiers = [];
- var bindings = this.get("declaration").getBindingIdentifiers();
- for (var key in bindings) {
- specifiers.push(buildExportSpecifier(bindings[key]));
- }
- return [declar, t.exportNamedDeclaration(null, specifiers)];
- }
- }
- var Program = {
- enter: function enter(node) {
- var imports = [];
- var rest = [];
- for (var i = 0; i < node.body.length; i++) {
- var bodyNode = node.body[i];
- if (t.isImportDeclaration(bodyNode)) {
- imports.push(bodyNode);
- } else {
- rest.push(bodyNode);
- }
- }
- node.body = imports.concat(rest);
- },
- exit: function exit(node, parent, scope, file) {
- if (!file.transformers["es6.modules"].canTransform()) return;
- if (file.moduleFormatter.setup) {
- file.moduleFormatter.setup();
- }
- }
- };
- exports.Program = Program;
- },{"../../../types":169,"lodash/lang/clone":402}],128:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ThisExpression = ThisExpression;
- exports.ReferencedIdentifier = ReferencedIdentifier;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-trailing"
- };
- exports.metadata = metadata;
- function remap(path, key, create) {
- // ensure that we're shadowed
- if (!path.inShadow()) return;
- var fnPath = path.findParent(function (node, path) {
- return !node.shadow && (path.isFunction() || path.isProgram());
- });
- var cached = fnPath.getData(key);
- if (cached) return cached;
- var init = create();
- var id = path.scope.generateUidIdentifier(key);
- fnPath.setData(key, id);
- fnPath.scope.push({ id: id, init: init });
- return id;
- }
- function ThisExpression() {
- return remap(this, "this", function () {
- return t.thisExpression();
- });
- }
- function ReferencedIdentifier(node) {
- if (node.name === "arguments" && !node._shadowedFunctionLiteral) {
- return remap(this, "arguments", function () {
- return t.identifier("arguments");
- });
- }
- }
- },{"../../../types":169}],129:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ForOfStatement = ForOfStatement;
- exports.MethodDefinition = MethodDefinition;
- exports.Property = Property;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- function ForOfStatement(node, parent, scope, file) {
- var left = node.left;
- if (t.isVariableDeclaration(left)) {
- var declar = left.declarations[0];
- if (declar.init) throw file.errorWithNode(declar, messages.get("noAssignmentsInForHead"));
- }
- }
- exports.ForInStatement = ForOfStatement;
- function MethodDefinition(node) {
- if (node.kind !== "constructor") {
- // get constructor() {}
- var isConstructor = !node.computed && t.isIdentifier(node.key, { name: "constructor" });
- // get ["constructor"]() {}
- isConstructor = isConstructor || t.isLiteral(node.key, { value: "constructor" });
- if (isConstructor) {
- throw this.errorWithNode(messages.get("classesIllegalConstructorKind"));
- }
- }
- Property.apply(this, arguments);
- }
- function Property(node, parent, scope, file) {
- if (node.kind === "set") {
- if (node.value.params.length !== 1) {
- throw file.errorWithNode(node.value, messages.get("settersInvalidParamLength"));
- }
- var first = node.value.params[0];
- if (t.isRestElement(first)) {
- throw file.errorWithNode(first, messages.get("settersNoRest"));
- }
- }
- }
- },{"../../../messages":47,"../../../types":169}],130:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ReferencedIdentifier = ReferencedIdentifier;
- exports.FunctionDeclaration = FunctionDeclaration;
- exports.VariableDeclarator = VariableDeclarator;
- exports.ConditionalExpression = ConditionalExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function toStatements(node) {
- if (t.isBlockStatement(node)) {
- var hasBlockScoped = false;
- for (var i = 0; i < node.body.length; i++) {
- var bodyNode = node.body[i];
- if (t.isBlockScoped(bodyNode)) hasBlockScoped = true;
- }
- if (!hasBlockScoped) {
- return node.body;
- }
- }
- return node;
- }
- var metadata = {
- optional: true,
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- function ReferencedIdentifier(node, parent, scope) {
- var binding = scope.getBinding(node.name);
- if (!binding || binding.references > 1 || !binding.constant) return;
- if (binding.kind === "param" || binding.kind === "module") return;
- var replacement = binding.path.node;
- if (t.isVariableDeclarator(replacement)) {
- replacement = replacement.init;
- }
- if (!replacement) return;
- if (this.findParent(function (node) {
- return replacement;
- })) {
- return;
- }
- t.toExpression(replacement);
- scope.removeBinding(node.name);
- binding.path.remove();
- return replacement;
- }
- function FunctionDeclaration(node, parent, scope) {
- var bindingInfo = scope.getBinding(node.id.name);
- if (bindingInfo && !bindingInfo.referenced) {
- this.remove();
- }
- }
- exports.ClassDeclaration = FunctionDeclaration;
- function VariableDeclarator(node, parent, scope) {
- if (!t.isIdentifier(node.id) || !scope.isPure(node.init)) return;
- FunctionDeclaration.apply(this, arguments);
- }
- function ConditionalExpression(node, parent, scope) {
- var evaluateTest = this.get("test").evaluateTruthy();
- if (evaluateTest === true) {
- return node.consequent;
- } else if (evaluateTest === false) {
- return node.alternate;
- }
- }
- var IfStatement = {
- exit: function exit(node, parent, scope) {
- var consequent = node.consequent;
- var alternate = node.alternate;
- var test = node.test;
- var evaluateTest = this.get("test").evaluateTruthy();
- // we can check if a test will be truthy 100% and if so then we can inline
- // the consequent and completely ignore the alternate
- //
- // if (true) { foo; } -> { foo; }
- // if ("foo") { foo; } -> { foo; }
- //
- if (evaluateTest === true) {
- return toStatements(consequent);
- }
- // we can check if a test will be falsy 100% and if so we can inline the
- // alternate if there is one and completely remove the consequent
- //
- // if ("") { bar; } else { foo; } -> { foo; }
- // if ("") { bar; } ->
- //
- if (evaluateTest === false) {
- if (alternate) {
- return toStatements(alternate);
- } else {
- return this.remove();
- }
- }
- // remove alternate blocks that are empty
- //
- // if (foo) { foo; } else {} -> if (foo) { foo; }
- //
- if (t.isBlockStatement(alternate) && !alternate.body.length) {
- alternate = node.alternate = null;
- }
- // if the consequent block is empty turn alternate blocks into a consequent
- // and flip the test
- //
- // if (foo) {} else { bar; } -> if (!foo) { bar; }
- //
- if (t.isBlockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
- node.consequent = node.alternate;
- node.alternate = null;
- node.test = t.unaryExpression("!", test, true);
- }
- }
- };
- exports.IfStatement = IfStatement;
- },{"../../../types":169}],131:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Identifier = Identifier;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- var Expression = {
- exit: function exit(node, parent, scope) {
- var res = this.evaluate();
- if (res.confident) return t.valueToNode(res.value);
- }
- };
- exports.Expression = Expression;
- function Identifier() {}
- // override Expression
- },{"../../../types":169}],132:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- group: "builtin-trailing"
- };
- exports.metadata = metadata;
- var MemberExpression = {
- exit: function exit(node) {
- var prop = node.property;
- if (node.computed && t.isLiteral(prop) && t.isValidIdentifier(prop.value)) {
- // foo["bar"] => foo.bar
- node.property = t.identifier(prop.value);
- node.computed = false;
- }
- }
- };
- exports.MemberExpression = MemberExpression;
- },{"../../../types":169}],133:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- group: "builtin-trailing"
- };
- exports.metadata = metadata;
- var Property = {
- exit: function exit(node) {
- var key = node.key;
- if (t.isLiteral(key) && t.isValidIdentifier(key.value)) {
- // "foo": "bar" -> foo: "bar"
- node.key = t.identifier(key.value);
- node.computed = false;
- }
- }
- };
- exports.Property = Property;
- },{"../../../types":169}],134:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.CallExpression = CallExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- function CallExpression(node, parent) {
- if (this.get("callee").matchesPattern("console", true)) {
- if (t.isExpressionStatement(parent)) {
- this.parentPath.remove();
- } else {
- this.remove();
- }
- }
- }
- },{"../../../types":169}],135:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ExpressionStatement = ExpressionStatement;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- function ExpressionStatement(node) {
- if (this.get("expression").isIdentifier({ name: "debugger" })) {
- this.remove();
- }
- }
- },{"../../../types":169}],136:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ForOfStatement = ForOfStatement;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _es6ForOf = require("../es6/for-of");
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true
- };
- exports.metadata = metadata;
- function ForOfStatement(node, parent, scope, file) {
- if (this.get("right").isTypeGeneric("Array")) {
- return _es6ForOf._ForOfStatementArray.call(this, node, scope, file);
- }
- }
- },{"../../../types":169,"../es6/for-of":96}],137:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.JSXElement = JSXElement;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _helpersReact = require("../../helpers/react");
- var react = _interopRequireWildcard(_helpersReact);
- var metadata = {
- optional: true
- };
- exports.metadata = metadata;
- var immutabilityVisitor = {
- enter: function enter(node, parent, scope, state) {
- var _this = this;
- var stop = function stop() {
- state.isImmutable = false;
- _this.stop();
- };
- if (this.isJSXClosingElement()) {
- this.skip();
- return;
- }
- if (this.isJSXIdentifier({ name: "ref" }) && this.parentPath.isJSXAttribute({ name: node })) {
- return stop();
- }
- if (this.isJSXIdentifier() || this.isIdentifier() || this.isJSXMemberExpression()) {
- return;
- }
- if (!this.isImmutable()) stop();
- }
- };
- function JSXElement(node, parent, scope, file) {
- if (node._hoisted) return;
- var state = { isImmutable: true };
- this.traverse(immutabilityVisitor, state);
- if (state.isImmutable) {
- this.hoist();
- } else {
- node._hoisted = true;
- }
- }
- },{"../../helpers/react":66}],138:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.JSXElement = JSXElement;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _helpersReact = require("../../helpers/react");
- var react = _interopRequireWildcard(_helpersReact);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true
- };
- exports.metadata = metadata;
- function hasRefOrSpread(attrs) {
- for (var i = 0; i < attrs.length; i++) {
- var attr = attrs[i];
- if (t.isJSXSpreadAttribute(attr)) return true;
- if (isJSXAttributeOfName(attr, "ref")) return true;
- }
- return false;
- }
- function isJSXAttributeOfName(attr, name) {
- return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: name });
- }
- function JSXElement(node, parent, scope, file) {
- // filter
- var open = node.openingElement;
- if (hasRefOrSpread(open.attributes)) return;
- // init
- var isComponent = true;
- var props = t.objectExpression([]);
- var obj = t.objectExpression([]);
- var key = t.literal(null);
- var type = open.name;
- if (t.isJSXIdentifier(type) && react.isCompatTag(type.name)) {
- type = t.literal(type.name);
- isComponent = false;
- }
- function pushElemProp(key, value) {
- pushProp(obj.properties, t.identifier(key), value);
- }
- function pushProp(objProps, key, value) {
- objProps.push(t.property("init", key, value));
- }
- // metadata
- pushElemProp("type", type);
- pushElemProp("ref", t.literal(null));
- if (node.children.length) {
- pushProp(props.properties, t.identifier("children"), t.arrayExpression(react.buildChildren(node)));
- }
- // props
- for (var i = 0; i < open.attributes.length; i++) {
- var attr = open.attributes[i];
- if (isJSXAttributeOfName(attr, "key")) {
- key = attr.value;
- } else {
- pushProp(props.properties, attr.name, attr.value || t.identifier("true"));
- }
- }
- if (isComponent) {
- props = t.callExpression(file.addHelper("default-props"), [t.memberExpression(type, t.identifier("defaultProps")), props]);
- }
- pushElemProp("props", props);
- // key
- pushElemProp("key", key);
- return obj;
- }
- },{"../../../types":169,"../../helpers/react":66}],139:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Func /*tion*/ = Func;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersRemapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
- var _helpersRemapAsyncToGenerator2 = _interopRequireDefault(_helpersRemapAsyncToGenerator);
- var _bluebirdCoroutines = require("./bluebird-coroutines");
- exports.manipulateOptions = _bluebirdCoroutines.manipulateOptions;
- var metadata = {
- optional: true,
- dependencies: ["es7.asyncFunctions", "es6.classes"]
- };
- exports.metadata = metadata;
- function Func(node, parent, scope, file) {
- if (!node.async || node.generator) return;
- return (0, _helpersRemapAsyncToGenerator2["default"])(node, file.addHelper("async-to-generator"), scope);
- }
- },{"../../helpers/remap-async-to-generator":68,"./bluebird-coroutines":140}],140:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.manipulateOptions = manipulateOptions;
- exports.Func /*tion*/ = Func;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersRemapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
- var _helpersRemapAsyncToGenerator2 = _interopRequireDefault(_helpersRemapAsyncToGenerator);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function manipulateOptions(opts) {
- opts.blacklist.push("regenerator");
- }
- var metadata = {
- optional: true,
- dependencies: ["es7.asyncFunctions", "es6.classes"]
- };
- exports.metadata = metadata;
- function Func(node, parent, scope, file) {
- if (!node.async || node.generator) return;
- return (0, _helpersRemapAsyncToGenerator2["default"])(node, t.memberExpression(file.addImport("bluebird", null, "absolute"), t.identifier("coroutine")), scope);
- }
- },{"../../../types":169,"../../helpers/remap-async-to-generator":68}],141:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Flow = Flow;
- exports.ClassProperty = ClassProperty;
- exports.Class = Class;
- exports.Func /*tion*/ = Func;
- exports.TypeCastExpression = TypeCastExpression;
- exports.ImportDeclaration = ImportDeclaration;
- exports.ExportDeclaration = ExportDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function Flow(node) {
- this.remove();
- }
- function ClassProperty(node) {
- node.typeAnnotation = null;
- }
- function Class(node) {
- node["implements"] = null;
- }
- function Func(node) {
- for (var i = 0; i < node.params.length; i++) {
- var param = node.params[i];
- param.optional = false;
- }
- }
- function TypeCastExpression(node) {
- return node.expression;
- }
- function ImportDeclaration(node) {
- if (node.isType) this.remove();
- }
- function ExportDeclaration(node) {
- if (this.get("declaration").isTypeAlias()) this.remove();
- }
- },{"../../../types":169}],142:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.FunctionExpression = FunctionExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true
- };
- exports.metadata = metadata;
- function FunctionExpression(node, print) {
- if (!node.id) return;
- node._ignoreUserWhitespace = true;
- return t.callExpression(t.functionExpression(null, [], t.blockStatement([t.toStatement(node), t.returnStatement(node.id)])), []);
- }
- },{"../../../types":169}],143:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.manipulateOptions = manipulateOptions;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _helpersReact = require("../../helpers/react");
- var react = _interopRequireWildcard(_helpersReact);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function manipulateOptions(opts) {
- opts.blacklist.push("react");
- }
- var metadata = {
- optional: true,
- group: "builtin-advanced"
- };
- exports.metadata = metadata;
- require("../../helpers/build-react-transformer")(exports, {
- pre: function pre(state) {
- state.callee = state.tagExpr;
- },
- post: function post(state) {
- if (react.isCompatTag(state.tagName)) {
- state.call = t.callExpression(t.memberExpression(t.memberExpression(t.identifier("React"), t.identifier("DOM")), state.tagExpr, t.isLiteral(state.tagExpr)), state.args);
- }
- }
- });
- },{"../../../types":169,"../../helpers/build-react-transformer":59,"../../helpers/react":66}],144:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Program = Program;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _helpersReact = require("../../helpers/react");
- var react = _interopRequireWildcard(_helpersReact);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
- var metadata = {
- group: "builtin-advanced"
- };
- exports.metadata = metadata;
- function Program(node, parent, scope, file) {
- var id = file.opts.jsxPragma;
- for (var i = 0; i < file.ast.comments.length; i++) {
- var comment = file.ast.comments[i];
- var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
- if (matches) {
- id = matches[1];
- if (id === "React.DOM") {
- throw file.errorWithNode(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12");
- } else {
- break;
- }
- }
- }
- file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {
- return t.memberExpression(object, property);
- }));
- }
- require("../../helpers/build-react-transformer")(exports, {
- pre: function pre(state) {
- var tagName = state.tagName;
- var args = state.args;
- if (react.isCompatTag(tagName)) {
- args.push(t.literal(tagName));
- } else {
- args.push(state.tagExpr);
- }
- },
- post: function post(state, file) {
- state.callee = file.get("jsxIdentifier");
- }
- });
- },{"../../../types":169,"../../helpers/build-react-transformer":59,"../../helpers/react":66}],145:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Func /*tion*/ = Func;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _regenerator = require("regenerator");
- var _regenerator2 = _interopRequireDefault(_regenerator);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var _astTypes = require("ast-types");
- var metadata = {
- group: "regenerator"
- };
- exports.metadata = metadata;
- function Func(node) {
- if (node.async || node.generator) {
- // Although this code transforms only the subtree rooted at the given
- // Function node, that node might contain other generator functions
- // that will also be transformed. It might help performance to ignore
- // nested functions, and rely on the traversal to visit them later,
- // but that's a small optimization. Starting here instead of at the
- // root of the AST is the key optimization, since huge async/generator
- // functions are relatively rare.
- _regenerator2["default"].transform(convertTraversalPathToNodePath(this));
- }
- }
- // Given a TraversalPath, return a NodePath that includes full ancestry
- // information (up to and including the Program node). This is complicated
- // by having to include intermediate objects like blockStatement.body
- // arrays, in addition to Node objects.
- function convertTraversalPathToNodePath(path) {
- var programNode;
- var keysAlongPath = [];
- while (path) {
- var pp = path.parentPath;
- var parentNode = pp && pp.node;
- if (parentNode) {
- keysAlongPath.push(path.key);
- if (parentNode !== path.container) {
- var found = Object.keys(parentNode).some(function (containerKey) {
- if (parentNode[containerKey] === path.container) {
- keysAlongPath.push(containerKey);
- return true;
- }
- });
- if (!found) {
- throw new Error("Failed to find container object in parent node");
- }
- }
- if (t.isProgram(parentNode)) {
- programNode = parentNode;
- break;
- }
- }
- path = pp;
- }
- if (!programNode) {
- throw new Error("Failed to find root Program node");
- }
- var nodePath = new _astTypes.NodePath(programNode);
- while (keysAlongPath.length > 0) {
- nodePath = nodePath.get(keysAlongPath.pop());
- }
- return nodePath;
- }
- },{"../../../types":169,"ast-types":188,"regenerator":442}],146:[function(require,module,exports){
- module.exports={
- "builtins": {
- "Symbol": "symbol",
- "Promise": "promise",
- "Map": "map",
- "WeakMap": "weak-map",
- "Set": "set",
- "WeakSet": "weak-set"
- },
- "methods": {
- "Array": {
- "concat": "array/concat",
- "copyWithin": "array/copy-within",
- "entries": "array/entries",
- "every": "array/every",
- "fill": "array/fill",
- "filter": "array/filter",
- "findIndex": "array/find-index",
- "find": "array/find",
- "forEach": "array/for-each",
- "from": "array/from",
- "includes": "array/includes",
- "indexOf": "array/index-of",
- "join": "array/join",
- "keys": "array/keys",
- "lastIndexOf": "array/last-index-of",
- "map": "array/map",
- "of": "array/of",
- "pop": "array/pop",
- "push": "array/push",
- "reduceRight": "array/reduce-right",
- "reduce": "array/reduce",
- "reverse": "array/reverse",
- "shift": "array/shift",
- "slice": "array/slice",
- "some": "array/some",
- "sort": "array/sort",
- "splice": "array/splice",
- "turn": "array/turn",
- "unshift": "array/unshift",
- "values": "array/values"
- },
- "Object": {
- "assign": "object/assign",
- "classof": "object/classof",
- "create": "object/create",
- "define": "object/define",
- "defineProperties": "object/define-properties",
- "defineProperty": "object/define-property",
- "entries": "object/entries",
- "freeze": "object/freeze",
- "getOwnPropertyDescriptor": "object/get-own-property-descriptor",
- "getOwnPropertyDescriptors": "object/get-own-property-descriptors",
- "getOwnPropertyNames": "object/get-own-property-names",
- "getOwnPropertySymbols": "object/get-own-property-symbols",
- "getPrototypePf": "object/get-prototype-of",
- "index": "object/index",
- "isExtensible": "object/is-extensible",
- "isFrozen": "object/is-frozen",
- "isObject": "object/is-object",
- "isSealed": "object/is-sealed",
- "is": "object/is",
- "keys": "object/keys",
- "make": "object/make",
- "preventExtensions": "object/prevent-extensions",
- "seal": "object/seal",
- "setPrototypeOf": "object/set-prototype-of",
- "values": "object/values"
- },
- "RegExp": {
- "escape": "regexp/escape"
- },
- "Function": {
- "only": "function/only",
- "part": "function/part"
- },
- "Math": {
- "acosh": "math/acosh",
- "asinh": "math/asinh",
- "atanh": "math/atanh",
- "cbrt": "math/cbrt",
- "clz32": "math/clz32",
- "cosh": "math/cosh",
- "expm1": "math/expm1",
- "fround": "math/fround",
- "hypot": "math/hypot",
- "pot": "math/pot",
- "imul": "math/imul",
- "log10": "math/log10",
- "log1p": "math/log1p",
- "log2": "math/log2",
- "sign": "math/sign",
- "sinh": "math/sinh",
- "tanh": "math/tanh",
- "trunc": "math/trunc"
- },
- "Date": {
- "addLocale": "date/add-locale",
- "formatUTC": "date/format-utc",
- "format": "date/format"
- },
- "Symbol": {
- "for": "symbol/for",
- "hasInstance": "symbol/for-instance",
- "is-concat-spreadable": "symbol/is-concat-spreadable",
- "iterator": "symbol/iterator",
- "keyFor": "symbol/key-for",
- "match": "symbol/match",
- "replace": "symbol/replace",
- "search": "symbol/search",
- "species": "symbol/species",
- "split": "symbol/split",
- "toPrimitive": "symbol/to-primitive",
- "toStringTag": "symbol/to-string-tag",
- "unscopables": "symbol/unscopables"
- },
- "String": {
- "at": "string/at",
- "codePointAt": "string/code-point-at",
- "endsWith": "string/ends-with",
- "escapeHTML": "string/escape-html",
- "fromCodePoint": "string/from-code-point",
- "includes": "string/includes",
- "raw": "string/raw",
- "repeat": "string/repeat",
- "startsWith": "string/starts-with",
- "unescapeHTML": "string/unescape-html"
- },
- "Number": {
- "EPSILON": "number/epsilon",
- "isFinite": "number/is-finite",
- "isInteger": "number/is-integer",
- "isNaN": "number/is-nan",
- "isSafeInteger": "number/is-safe-integer",
- "MAX_SAFE_INTEGER": "number/max-safe-integer",
- "MIN_SAFE_INTEGER": "number/min-safe-integer",
- "parseFloat": "number/parse-float",
- "parseInt": "number/parse-int",
- "random": "number/random"
- },
- "Reflect": {
- "apply": "reflect/apply",
- "construct": "reflect/construct",
- "defineProperty": "reflect/define-property",
- "deleteProperty": "reflect/delete-property",
- "enumerate": "reflect/enumerate",
- "getOwnPropertyDescriptor": "reflect/get-own-property-descriptor",
- "getPrototypeOf": "reflect/get-prototype-of",
- "get": "reflect/get",
- "has": "reflect/has",
- "isExtensible": "reflect/is-extensible",
- "ownKeys": "reflect/own-keys",
- "preventExtensions": "reflect/prevent-extensions",
- "setPrototypeOf": "reflect/set-prototype-of",
- "set": "reflect/set"
- }
- }
- }
- },{}],147:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.pre = pre;
- exports.ReferencedIdentifier = ReferencedIdentifier;
- exports.CallExpression = CallExpression;
- exports.BinaryExpression = BinaryExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _traversal = require("../../../../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _util = require("../../../../util");
- var util = _interopRequireWildcard(_util);
- var _lodashObjectHas = require("lodash/object/has");
- var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
- var _types = require("../../../../types");
- var t = _interopRequireWildcard(_types);
- var _definitions = require("./definitions");
- var _definitions2 = _interopRequireDefault(_definitions);
- var isSymbolIterator = t.buildMatchMemberExpression("Symbol.iterator");
- var RUNTIME_MODULE_NAME = "babel-runtime";
- var metadata = {
- optional: true,
- group: "builtin-post-modules"
- };
- exports.metadata = metadata;
- function pre(file) {
- file.set("helperGenerator", function (name) {
- return file.addImport("" + RUNTIME_MODULE_NAME + "/helpers/" + name, name, "absoluteDefault");
- });
- file.setDynamic("regeneratorIdentifier", function () {
- return file.addImport("" + RUNTIME_MODULE_NAME + "/regenerator", "regeneratorRuntime", "absoluteDefault");
- });
- }
- function ReferencedIdentifier(node, parent, scope, file) {
- if (node.name === "regeneratorRuntime") {
- return file.get("regeneratorIdentifier");
- }
- if (t.isMemberExpression(parent)) return;
- if (!(0, _lodashObjectHas2["default"])(_definitions2["default"].builtins, node.name)) return;
- if (scope.getBindingIdentifier(node.name)) return;
- // Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
- var modulePath = _definitions2["default"].builtins[node.name];
- return file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/" + modulePath, node.name, "absoluteDefault");
- }
- function CallExpression(node, parent, scope, file) {
- // arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
- if (node.arguments.length) return;
- var callee = node.callee;
- if (!t.isMemberExpression(callee)) return;
- if (!callee.computed) return;
- if (!this.get("callee.property").matchesPattern("Symbol.iterator")) return;
- return t.callExpression(file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/get-iterator", "getIterator", "absoluteDefault"), [callee.object]);
- }
- function BinaryExpression(node, parent, scope, file) {
- // Symbol.iterator in arr -> core.$for.isIterable(arr)
- if (node.operator !== "in") return;
- if (!this.get("left").matchesPattern("Symbol.iterator")) return;
- return t.callExpression(file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/is-iterable", "isIterable", "absoluteDefault"), [node.right]);
- }
- var MemberExpression = {
- enter: function enter(node, parent, scope, file) {
- // Array.from -> _core.Array.from
- if (!this.isReferenced()) return;
- var obj = node.object;
- var prop = node.property;
- if (!t.isReferenced(obj, node)) return;
- if (node.computed) return;
- if (!(0, _lodashObjectHas2["default"])(_definitions2["default"].methods, obj.name)) return;
- var methods = _definitions2["default"].methods[obj.name];
- if (!(0, _lodashObjectHas2["default"])(methods, prop.name)) return;
- if (scope.getBindingIdentifier(obj.name)) return;
- var modulePath = methods[prop.name];
- return file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/" + modulePath, "" + obj.name + "$" + prop.name, "absoluteDefault");
- },
- exit: function exit(node, parent, scope, file) {
- if (!this.isReferenced()) return;
- var prop = node.property;
- var obj = node.object;
- if (!(0, _lodashObjectHas2["default"])(_definitions2["default"].builtins, obj.name)) return;
- if (scope.getBindingIdentifier(obj.name)) return;
- var modulePath = _definitions2["default"].builtins[obj.name];
- return t.memberExpression(file.addImport("" + RUNTIME_MODULE_NAME + "/core-js/" + modulePath, "" + obj.name, "absoluteDefault"), prop);
- }
- };
- exports.MemberExpression = MemberExpression;
- },{"../../../../traversal":157,"../../../../types":169,"../../../../util":173,"./definitions":146,"lodash/collection/includes":332,"lodash/object/has":420}],148:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.ThisExpression = ThisExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- var THIS_BREAK_KEYS = ["FunctionExpression", "FunctionDeclaration", "ClassExpression", "ClassDeclaration"];
- var Program = {
- enter: function enter(program, parent, scope, file) {
- var first = program.body[0];
- var directive;
- if (t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" })) {
- directive = first;
- } else {
- directive = t.expressionStatement(t.literal("use strict"));
- this.unshiftContainer("body", directive);
- if (first) {
- directive.leadingComments = first.leadingComments;
- first.leadingComments = [];
- }
- }
- directive._blockHoist = Infinity;
- }
- };
- exports.Program = Program;
- function ThisExpression() {
- if (!this.findParent(function (node) {
- return !node.shadow && THIS_BREAK_KEYS.indexOf(node.type) >= 0;
- })) {
- return t.identifier("undefined");
- }
- }
- },{"../../../messages":47,"../../../types":169}],149:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.BlockStatement = BlockStatement;
- exports.SwitchCase = SwitchCase;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- function statementList(key, path, file) {
- var paths = path.get(key);
- for (var i = 0; i < paths.length; i++) {
- var path = paths[i];
- var func = path.node;
- if (!t.isFunctionDeclaration(func)) continue;
- var declar = t.variableDeclaration("let", [t.variableDeclarator(func.id, t.toExpression(func))]);
- // hoist it up above everything else
- declar._blockHoist = 2;
- // todo: name this
- func.id = null;
- path.replaceWith(declar);
- }
- }
- function BlockStatement(node, parent, scope, file) {
- if (t.isFunction(parent) && parent.body === node || t.isExportDeclaration(parent)) {
- return;
- }
- statementList("body", this, file);
- }
- function SwitchCase(node, parent, scope, file) {
- statementList("consequent", this, file);
- }
- },{"../../../types":169}],150:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- var _helpersNameMethod = require("../../helpers/name-method");
- var metadata = {
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- var FunctionExpression = {
- exit: _helpersNameMethod.bare
- };
- exports.FunctionExpression = FunctionExpression;
- exports.ArrowFunctionExpression = FunctionExpression;
- },{"../../helpers/name-method":65}],151:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.AssignmentExpression = AssignmentExpression;
- exports.ExpressionStatement = ExpressionStatement;
- exports.ObjectExpression = ObjectExpression;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var _lodashArrayPull = require("lodash/array/pull");
- var _lodashArrayPull2 = _interopRequireDefault(_lodashArrayPull);
- function isProtoKey(node) {
- return t.isLiteral(t.toComputedKey(node, node.key), { value: "__proto__" });
- }
- function isProtoAssignmentExpression(node) {
- var left = node.left;
- return t.isMemberExpression(left) && t.isLiteral(t.toComputedKey(left, left.property), { value: "__proto__" });
- }
- function buildDefaultsCallExpression(expr, ref, file) {
- return t.expressionStatement(t.callExpression(file.addHelper("defaults"), [ref, expr.right]));
- }
- var metadata = {
- secondPass: true,
- optional: true
- };
- exports.metadata = metadata;
- function AssignmentExpression(node, parent, scope, file) {
- if (!isProtoAssignmentExpression(node)) return;
- var nodes = [];
- var left = node.left.object;
- var temp = scope.maybeGenerateMemoised(left);
- nodes.push(t.expressionStatement(t.assignmentExpression("=", temp, left)));
- nodes.push(buildDefaultsCallExpression(node, temp, file));
- if (temp) nodes.push(temp);
- return nodes;
- }
- function ExpressionStatement(node, parent, scope, file) {
- var expr = node.expression;
- if (!t.isAssignmentExpression(expr, { operator: "=" })) return;
- if (isProtoAssignmentExpression(expr)) {
- return buildDefaultsCallExpression(expr, expr.left.object, file);
- }
- }
- function ObjectExpression(node, parent, scope, file) {
- var proto;
- for (var i = 0; i < node.properties.length; i++) {
- var prop = node.properties[i];
- if (isProtoKey(prop)) {
- proto = prop.value;
- (0, _lodashArrayPull2["default"])(node.properties, prop);
- }
- }
- if (proto) {
- var args = [t.objectExpression([]), proto];
- if (node.properties.length) args.push(node);
- return t.callExpression(file.addHelper("extends"), args);
- }
- }
- },{"../../../types":169,"lodash/array/pull":327}],152:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Identifier = Identifier;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- react: true
- };
- exports.metadata = metadata;
- function Identifier(node, parent) {
- if (node.name === "undefined" && this.isReferenced()) {
- return t.unaryExpression("void", t.literal(0), true);
- }
- }
- },{"../../../types":169}],153:[function(require,module,exports){
- (function (process){
- "use strict";
- exports.__esModule = true;
- exports.MemberExpression = MemberExpression;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- var metadata = {
- optional: true,
- group: "builtin-setup"
- };
- exports.metadata = metadata;
- var match = t.buildMatchMemberExpression("process.env");
- function MemberExpression(node) {
- if (match(node.object)) {
- var key = this.toComputedKey();
- if (t.isLiteral(key)) {
- return t.valueToNode(process.env[key.value]);
- }
- }
- }
- }).call(this,require('_process'))
- },{"../../../types":169,"_process":200}],154:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.CallExpression = CallExpression;
- exports.ModuleDeclaration = ModuleDeclaration;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _types = require("../../../types");
- var t = _interopRequireWildcard(_types);
- // check if the input Literal `source` is an alternate casing of "react"
- function check(source, file) {
- if (t.isLiteral(source)) {
- var name = source.value;
- var lower = name.toLowerCase();
- if (lower === "react" && name !== lower) {
- throw file.errorWithNode(source, messages.get("didYouMean", "react"));
- }
- }
- }
- function CallExpression(node, parent, scope, file) {
- if (this.get("callee").isIdentifier({ name: "require" }) && node.arguments.length === 1) {
- check(node.arguments[0], file);
- }
- }
- function ModuleDeclaration(node, parent, scope, file) {
- check(node.source, file);
- }
- },{"../../../messages":47,"../../../types":169}],155:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.Identifier = Identifier;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _leven = require("leven");
- var _leven2 = _interopRequireDefault(_leven);
- var _messages = require("../../../messages");
- var messages = _interopRequireWildcard(_messages);
- var metadata = {
- optional: true
- };
- exports.metadata = metadata;
- function Identifier(node, parent, scope, file) {
- if (!this.isReferenced()) return;
- if (scope.hasBinding(node.name)) return;
- // get the closest declaration to offer as a suggestion
- // the variable name may have just been mistyped
- var bindings = scope.getAllBindings();
- var closest;
- var shortest = -1;
- for (var name in bindings) {
- var distance = (0, _leven2["default"])(node.name, name);
- if (distance <= 0 || distance > 3) continue;
- if (distance <= shortest) continue;
- closest = name;
- shortest = distance;
- }
- var msg;
- if (closest) {
- msg = messages.get("undeclaredVariableSuggestion", node.name, closest);
- } else {
- msg = messages.get("undeclaredVariable", node.name);
- }
- //
- throw file.errorWithNode(node, msg, ReferenceError);
- }
- },{"../../../messages":47,"leven":321}],156:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _path = require("./path");
- var _path2 = _interopRequireDefault(_path);
- var _lodashArrayCompact = require("lodash/array/compact");
- var _lodashArrayCompact2 = _interopRequireDefault(_lodashArrayCompact);
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- var TraversalContext = (function () {
- function TraversalContext(scope, opts, state, parentPath) {
- _classCallCheck(this, TraversalContext);
- this.parentPath = parentPath;
- this.scope = scope;
- this.state = state;
- this.opts = opts;
- }
- TraversalContext.prototype.shouldVisit = function shouldVisit(node) {
- var keys = t.VISITOR_KEYS[node.type];
- return !!(this.opts.enter || this.opts.exit || this.opts[node.type] || keys && keys.length);
- };
- TraversalContext.prototype.create = function create(node, obj, key) {
- var path = _path2["default"].get(this.parentPath, node, obj, key);
- path.unshiftContext(this);
- return path;
- };
- TraversalContext.prototype.visitMultiple = function visitMultiple(nodes, node, key) {
- // nothing to traverse!
- if (nodes.length === 0) return false;
- var visited = [];
- var queue = this.queue = [];
- var stop = false;
- // build up initial queue
- for (var i = 0; i < nodes.length; i++) {
- var self = nodes[i];
- if (self && this.shouldVisit(self)) {
- queue.push(this.create(node, nodes, i));
- }
- }
- // visit the queue
- var _arr = queue;
- for (var _i = 0; _i < _arr.length; _i++) {
- var path = _arr[_i];
- path.update();
- if (visited.indexOf(path.node) >= 0) continue;
- visited.push(path.node);
- if (path.visit()) {
- stop = true;
- break;
- }
- }
- var _arr2 = queue;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var path = _arr2[_i2];
- path.shiftContext();
- }
- this.queue = null;
- return stop;
- };
- TraversalContext.prototype.visitSingle = function visitSingle(node, key) {
- if (this.shouldVisit(node[key])) {
- var path = this.create(node, node, key);
- path.visit();
- path.shiftContext();
- }
- };
- TraversalContext.prototype.visit = function visit(node, key) {
- var nodes = node[key];
- if (!nodes) return;
- if (Array.isArray(nodes)) {
- return this.visitMultiple(nodes, node, key);
- } else {
- return this.visitSingle(node, key);
- }
- };
- return TraversalContext;
- })();
- exports["default"] = TraversalContext;
- module.exports = exports["default"];
- },{"../types":169,"./path":161,"lodash/array/compact":324}],157:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports["default"] = traverse;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _context = require("./context");
- var _context2 = _interopRequireDefault(_context);
- var _visitors = require("./visitors");
- var visitors = _interopRequireWildcard(_visitors);
- var _messages = require("../messages");
- var messages = _interopRequireWildcard(_messages);
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- function traverse(parent, opts, scope, state, parentPath) {
- if (!parent) return;
- if (!opts.noScope && !scope) {
- if (parent.type !== "Program" && parent.type !== "File") {
- throw new Error(messages.get("traverseNeedsParent", parent.type));
- }
- }
- if (!opts) opts = {};
- visitors.verify(opts);
- visitors.explode(opts);
- // array of nodes
- if (Array.isArray(parent)) {
- for (var i = 0; i < parent.length; i++) {
- traverse.node(parent[i], opts, scope, state, parentPath);
- }
- } else {
- traverse.node(parent, opts, scope, state, parentPath);
- }
- }
- traverse.visitors = visitors;
- traverse.verify = visitors.verify;
- traverse.explode = visitors.explode;
- traverse.node = function (node, opts, scope, state, parentPath) {
- var keys = t.VISITOR_KEYS[node.type];
- if (!keys) return;
- var context = new _context2["default"](scope, opts, state, parentPath);
- for (var i = 0; i < keys.length; i++) {
- if (context.visit(node, keys[i])) {
- return;
- }
- }
- };
- var CLEAR_KEYS = ["trailingComments", "leadingComments", "extendedRange", "_scopeInfo", "_paths", "tokens", "range", "start", "end", "loc", "raw"];
- function clearNode(node) {
- for (var i = 0; i < CLEAR_KEYS.length; i++) {
- var key = CLEAR_KEYS[i];
- if (node[key] != null) node[key] = null;
- }
- for (var key in node) {
- var val = node[key];
- if (Array.isArray(val)) {
- delete val._paths;
- }
- }
- }
- var clearVisitor = {
- noScope: true,
- exit: clearNode
- };
- function clearComments(comments) {
- for (var i = 0; i < comments.length; i++) {
- clearNode(comments[i]);
- }
- }
- traverse.removeProperties = function (tree) {
- traverse(tree, clearVisitor);
- clearNode(tree);
- return tree;
- };
- function hasBlacklistedType(node, parent, scope, state) {
- if (node.type === state.type) {
- state.has = true;
- this.skip();
- }
- }
- traverse.hasType = function (tree, scope, type, blacklistTypes) {
- // the node we're searching in is blacklisted
- if ((0, _lodashCollectionIncludes2["default"])(blacklistTypes, tree.type)) return false;
- // the type we're looking for is the same as the passed node
- if (tree.type === type) return true;
- var state = {
- has: false,
- type: type
- };
- traverse(tree, {
- blacklist: blacklistTypes,
- enter: hasBlacklistedType
- }, scope, state);
- return state.has;
- };
- module.exports = exports["default"];
- },{"../messages":47,"../types":169,"./context":156,"./visitors":165,"lodash/collection/includes":332}],158:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- /**
- * Description
- */
- exports.toComputedKey = toComputedKey;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- function toComputedKey() {
- var node = this.node;
- var key;
- if (this.isMemberExpression()) {
- key = node.property;
- } else if (this.isProperty()) {
- key = node.key;
- } else {
- throw new ReferenceError("todo");
- }
- if (!node.computed) {
- if (t.isIdentifier(key)) key = t.literal(key.name);
- }
- return key;
- }
- },{"../../types":169}],159:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- /**
- * Walk the input `node` and statically evaluate if it's truthy.
- *
- * Returning `true` when we're sure that the expression will evaluate to a
- * truthy value, `false` if we're sure that it will evaluate to a falsy
- * value and `undefined` if we aren't sure. Because of this please do not
- * rely on coercion when using this method and check with === if it's false.
- *
- * For example do:
- *
- * if (t.evaluateTruthy(node) === false) falsyLogic();
- *
- * **AND NOT**
- *
- * if (!t.evaluateTruthy(node)) falsyLogic();
- *
- */
- exports.evaluateTruthy = evaluateTruthy;
- /**
- * Walk the input `node` and statically evaluate it.
- *
- * Returns an object in the form `{ confident, value }`. `confident` indicates
- * whether or not we had to drop out of evaluating the expression because of
- * hitting an unknown node that we couldn't confidently find the value of.
- *
- * Example:
- *
- * t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
- * t.evaluate(parse("!true")) // { confident: true, value: false }
- * t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
- *
- */
- exports.evaluate = evaluate;
- function evaluateTruthy() {
- var res = this.evaluate();
- if (res.confident) return !!res.value;
- }
- function evaluate() {
- var confident = true;
- var value = evaluate(this);
- if (!confident) value = undefined;
- return {
- confident: confident,
- value: value
- };
- function evaluate(path) {
- if (!confident) return;
- var node = path.node;
- if (path.isSequenceExpression()) {
- var exprs = path.get("expressions");
- return evaluate(exprs[exprs.length - 1]);
- }
- if (path.isLiteral()) {
- if (node.regex) {} else {
- return node.value;
- }
- }
- if (path.isConditionalExpression()) {
- if (evaluate(path.get("test"))) {
- return evaluate(path.get("consequent"));
- } else {
- return evaluate(path.get("alternate"));
- }
- }
- if (path.isIdentifier({ name: "undefined" })) {
- return undefined;
- }
- if (path.isIdentifier() || path.isMemberExpression()) {
- path = path.resolve();
- if (path) {
- return evaluate(path);
- } else {
- return confident = false;
- }
- }
- if (path.isUnaryExpression({ prefix: true })) {
- var arg = evaluate(path.get("argument"));
- switch (node.operator) {
- case "void":
- return undefined;
- case "!":
- return !arg;
- case "+":
- return +arg;
- case "-":
- return -arg;
- case "~":
- return ~arg;
- }
- }
- if (path.isArrayExpression() || path.isObjectExpression()) {}
- if (path.isLogicalExpression()) {
- var left = evaluate(path.get("left"));
- var right = evaluate(path.get("right"));
- switch (node.operator) {
- case "||":
- return left || right;
- case "&&":
- return left && right;
- }
- }
- if (path.isBinaryExpression()) {
- var left = evaluate(path.get("left"));
- var right = evaluate(path.get("right"));
- switch (node.operator) {
- case "-":
- return left - right;
- case "+":
- return left + right;
- case "/":
- return left / right;
- case "*":
- return left * right;
- case "%":
- return left % right;
- case "**":
- return Math.pow(left, right);
- case "<":
- return left < right;
- case ">":
- return left > right;
- case "<=":
- return left <= right;
- case ">=":
- return left >= right;
- case "==":
- return left == right;
- case "!=":
- return left != right;
- case "===":
- return left === right;
- case "!==":
- return left !== right;
- }
- }
- confident = false;
- }
- }
- // we have a regex and we can't represent it natively
- // we could evaluate these but it's probably impractical and not very useful
- },{}],160:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _transformationHelpersReact = require("../../transformation/helpers/react");
- var react = _interopRequireWildcard(_transformationHelpersReact);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var referenceVisitor = {
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
- if (this.isJSXIdentifier() && react.isCompatTag(node.name)) {
- return;
- }
- // direct references that we need to track to hoist this to the highest scope we can
- var bindingInfo = scope.getBinding(node.name);
- if (!bindingInfo) return;
- // this binding isn't accessible from the parent scope so we can safely ignore it
- // eg. it's in a closure etc
- if (bindingInfo !== state.scope.getBinding(node.name)) return;
- if (bindingInfo.constant) {
- state.bindings[node.name] = bindingInfo;
- } else {
- var _arr = bindingInfo.constantViolations;
- for (var _i = 0; _i < _arr.length; _i++) {
- var violationPath = _arr[_i];
- state.breakOnScopePaths.push(violationPath.scope.path);
- }
- }
- }
- };
- var PathHoister = (function () {
- function PathHoister(path, scope) {
- _classCallCheck(this, PathHoister);
- this.breakOnScopePaths = [];
- this.bindings = {};
- this.scopes = [];
- this.scope = scope;
- this.path = path;
- }
- PathHoister.prototype.isCompatibleScope = function isCompatibleScope(scope) {
- for (var key in this.bindings) {
- var binding = this.bindings[key];
- if (!scope.bindingIdentifierEquals(key, binding.identifier)) {
- return false;
- }
- }
- return true;
- };
- PathHoister.prototype.getCompatibleScopes = function getCompatibleScopes() {
- var scope = this.path.scope;
- do {
- if (this.isCompatibleScope(scope)) {
- this.scopes.push(scope);
- } else {
- break;
- }
- if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
- break;
- }
- } while (scope = scope.parent);
- };
- PathHoister.prototype.getAttachmentPath = function getAttachmentPath() {
- var scopes = this.scopes;
- var scope = scopes.pop();
- if (!scope) return;
- if (scope.path.isFunction()) {
- if (this.hasOwnParamBindings(scope)) {
- // should ignore this scope since it's ourselves
- if (this.scope.is(scope)) return;
- // needs to be attached to the body
- return scope.path.get("body").get("body")[0];
- } else {
- // doesn't need to be be attached to this scope
- return this.getNextScopeStatementParent();
- }
- } else if (scope.path.isProgram()) {
- return this.getNextScopeStatementParent();
- }
- };
- PathHoister.prototype.getNextScopeStatementParent = function getNextScopeStatementParent() {
- var scope = this.scopes.pop();
- if (scope) return scope.path.getStatementParent();
- };
- PathHoister.prototype.hasOwnParamBindings = function hasOwnParamBindings(scope) {
- for (var name in this.bindings) {
- if (!scope.hasOwnBinding(name)) continue;
- var binding = this.bindings[name];
- if (binding.kind === "param") return true;
- }
- return false;
- };
- PathHoister.prototype.run = function run() {
- var node = this.path.node;
- if (node._hoisted) return;
- node._hoisted = true;
- this.path.traverse(referenceVisitor, this);
- this.getCompatibleScopes();
- var path = this.getAttachmentPath();
- if (!path) return;
- var uid = path.scope.generateUidIdentifier("ref");
- path.insertBefore([t.variableDeclaration("var", [t.variableDeclarator(uid, this.path.node)])]);
- var parent = this.path.parentPath;
- if (parent.isJSXElement() && this.path.container === parent.node.children) {
- // turning the `span` in `<div><span /></div>` to an expression so we need to wrap it with
- // an expression container
- uid = t.jSXExpressionContainer(uid);
- }
- this.path.replaceWith(uid);
- };
- return PathHoister;
- })();
- exports["default"] = PathHoister;
- module.exports = exports["default"];
- },{"../../transformation/helpers/react":66,"../../types":169}],161:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _hoister = require("./hoister");
- var _hoister2 = _interopRequireDefault(_hoister);
- var _virtualTypes = require("./virtual-types");
- var virtualTypes = _interopRequireWildcard(_virtualTypes);
- var _messages = require("../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
- var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
- var _lodashLangIsNumber = require("lodash/lang/isNumber");
- var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
- var _lodashLangIsRegExp = require("lodash/lang/isRegExp");
- var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
- var _lodashLangIsString = require("lodash/lang/isString");
- var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
- var _helpersCodeFrame = require("../../helpers/code-frame");
- var _helpersCodeFrame2 = _interopRequireDefault(_helpersCodeFrame);
- var _helpersParse = require("../../helpers/parse");
- var _helpersParse2 = _interopRequireDefault(_helpersParse);
- var _visitors = require("../visitors");
- var _index = require("../index");
- var _index2 = _interopRequireDefault(_index);
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _lodashObjectAssign = require("lodash/object/assign");
- var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
- var _lodashObjectExtend = require("lodash/object/extend");
- var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
- var _scope = require("../scope");
- var _scope2 = _interopRequireDefault(_scope);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var hoistVariablesVisitor = (0, _visitors.explode)({
- Function: function Function() {
- this.skip();
- },
- VariableDeclaration: function VariableDeclaration(node, parent, scope) {
- if (node.kind !== "var") return;
- var bindings = this.getBindingIdentifiers();
- for (var key in bindings) {
- scope.push({ id: bindings[key] });
- }
- var exprs = [];
- var _arr = node.declarations;
- for (var _i = 0; _i < _arr.length; _i++) {
- var declar = _arr[_i];
- var declar = node.declarations[i];
- if (declar.init) {
- exprs.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
- }
- }
- return exprs;
- }
- });
- var TraversalPath = (function () {
- function TraversalPath(parent, container) {
- _classCallCheck(this, TraversalPath);
- this.container = container;
- this.contexts = [];
- this.parent = parent;
- this.data = {};
- }
- /**
- * Description
- */
- TraversalPath.get = function get(parentPath, parent, container, key) {
- var targetNode = container[key];
- var paths = container._paths = container._paths || [];
- var path;
- for (var i = 0; i < paths.length; i++) {
- var pathCheck = paths[i];
- if (pathCheck.node === targetNode) {
- path = pathCheck;
- break;
- }
- }
- if (!path) {
- path = new TraversalPath(parent, container);
- paths.push(path);
- }
- path.setup(parentPath, key);
- return path;
- };
- /**
- * Description
- */
- TraversalPath.getScope = function getScope(path, scope, file) {
- var ourScope = scope;
- // we're entering a new scope so let's construct it!
- if (path.isScope()) {
- ourScope = new _scope2["default"](path, scope, file);
- }
- return ourScope;
- };
- /**
- * Description
- */
- TraversalPath.prototype.getAncestry = function getAncestry() {
- var ancestry = [];
- var path = this.parentPath;
- while (path) {
- ancestry.push(path.node);
- path = path.parentPath;
- }
- return ancestry;
- };
- /**
- * Description
- */
- TraversalPath.prototype.inType = function inType(types) {
- if (!Array.isArray(types)) types = [types];
- var path = this;
- while (path) {
- var _arr3 = types;
- for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
- var type = _arr3[_i3];
- if (path.node.type === type) return true;
- }
- path = path.parentPath;
- }
- return false;
- };
- /**
- * Description
- */
- TraversalPath.prototype.inShadow = function inShadow() {
- var path = this;
- while (path) {
- if (path.isFunction()) {
- if (path.node.shadow) {
- return path;
- } else {
- return null;
- }
- }
- path = path.parentPath;
- }
- return null;
- };
- /**
- * Check whether this node was a part of the original AST.
- */
- TraversalPath.prototype.isUser = function isUser() {
- return this.node && !!this.node.loc;
- };
- /**
- * Check whether this node was generated by us and not a part of the original AST.
- */
- TraversalPath.prototype.isGenerated = function isGenerated() {
- return !this.isUser();
- };
- /**
- * Description
- */
- TraversalPath.prototype.findParent = function findParent(callback) {
- var path = this;
- while (path) {
- if (callback(path.node, path)) return path;
- path = path.parentPath;
- }
- return null;
- };
- /**
- * Description
- */
- TraversalPath.prototype.queueNode = function queueNode(path) {
- var _arr4 = this.contexts;
- for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
- var context = _arr4[_i4];
- if (context.queue) {
- context.queue.push(path);
- }
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.insertBefore = function insertBefore(nodes) {
- nodes = this._verifyNodeList(nodes);
- if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
- return this.parentPath.insertBefore(nodes);
- } else if (this.isPreviousType("Expression") || this.parentPath.isForStatement() && this.key === "init") {
- if (this.node) nodes.push(this.node);
- this.replaceExpressionWithStatements(nodes);
- } else if (this.isPreviousType("Statement") || !this.type) {
- this._maybePopFromStatements(nodes);
- if (Array.isArray(this.container)) {
- this._containerInsertBefore(nodes);
- } else if (this.isStatementOrBlock()) {
- if (this.node) nodes.push(this.node);
- this.node = this.container[this.key] = t.blockStatement(nodes);
- } else {
- throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
- }
- } else {
- throw new Error("No clue what to do with this node type.");
- }
- };
- TraversalPath.prototype._containerInsert = function _containerInsert(from, nodes) {
- this.updateSiblingKeys(from, nodes.length);
- var paths = [];
- for (var i = 0; i < nodes.length; i++) {
- var to = from + i;
- var node = nodes[i];
- this.container.splice(to, 0, node);
- if (this.context) {
- var path = this.context.create(this.parent, this.container, to);
- paths.push(path);
- this.queueNode(path);
- } else {
- paths.push(TraversalPath.get(this, node, this.container, to));
- }
- }
- return paths;
- };
- TraversalPath.prototype._containerInsertBefore = function _containerInsertBefore(nodes) {
- return this._containerInsert(this.key, nodes);
- };
- TraversalPath.prototype._containerInsertAfter = function _containerInsertAfter(nodes) {
- return this._containerInsert(this.key + 1, nodes);
- };
- TraversalPath.prototype._maybePopFromStatements = function _maybePopFromStatements(nodes) {
- var last = nodes[nodes.length - 1];
- if (t.isExpressionStatement(last) && t.isIdentifier(last.expression) && !this.isCompletionRecord()) {
- nodes.pop();
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.isCompletionRecord = function isCompletionRecord() {
- var path = this;
- do {
- var container = path.container;
- if (Array.isArray(container) && path.key !== container.length - 1) {
- return false;
- }
- } while (path = path.parentPath && !path.isProgram());
- return true;
- };
- /**
- * Description
- */
- TraversalPath.prototype.isStatementOrBlock = function isStatementOrBlock() {
- if (t.isLabeledStatement(this.parent) || t.isBlockStatement(this.container)) {
- return false;
- } else {
- return (0, _lodashCollectionIncludes2["default"])(t.STATEMENT_OR_BLOCK_KEYS, this.key);
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.insertAfter = function insertAfter(nodes) {
- nodes = this._verifyNodeList(nodes);
- if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
- return this.parentPath.insertAfter(nodes);
- } else if (this.isPreviousType("Expression") || this.parentPath.isForStatement() && this.key === "init") {
- if (this.node) {
- var temp = this.scope.generateDeclaredUidIdentifier();
- nodes.unshift(t.expressionStatement(t.assignmentExpression("=", temp, this.node)));
- nodes.push(t.expressionStatement(temp));
- }
- this.replaceExpressionWithStatements(nodes);
- } else if (this.isPreviousType("Statement") || !this.type) {
- this._maybePopFromStatements(nodes);
- if (Array.isArray(this.container)) {
- this._containerInsertAfter(nodes);
- } else if (this.isStatementOrBlock()) {
- if (this.node) nodes.unshift(this.node);
- this.node = this.container[this.key] = t.blockStatement(nodes);
- } else {
- throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
- }
- } else {
- throw new Error("No clue what to do with this node type.");
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.updateSiblingKeys = function updateSiblingKeys(fromIndex, incrementBy) {
- var paths = this.container._paths;
- for (var i = 0; i < paths.length; i++) {
- var path = paths[i];
- if (path.key >= fromIndex) {
- path.key += incrementBy;
- }
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.setData = function setData(key, val) {
- return this.data[key] = val;
- };
- /**
- * Description
- */
- TraversalPath.prototype.getData = function getData(key, def) {
- var val = this.data[key];
- if (!val && def) val = this.data[key] = def;
- return val;
- };
- /**
- * Description
- */
- TraversalPath.prototype.setScope = function setScope(file) {
- if (this.opts && this.opts.noScope) return;
- var target = this.context || this.parentPath;
- this.scope = TraversalPath.getScope(this, target && target.scope, file);
- };
- /**
- * Description
- */
- TraversalPath.prototype.setContext = function setContext(context, file) {
- this.shouldSkip = false;
- this.shouldStop = false;
- this.removed = false;
- if (context) {
- this.context = context;
- this.state = context.state;
- this.opts = context.opts;
- }
- var log = file && this.type === "Program";
- if (log) file.log.debug("Start scope building");
- this.setScope(file);
- if (log) file.log.debug("End scope building");
- return this;
- };
- /**
- * Description
- */
- TraversalPath.prototype.update = function update() {
- if (this.node === this.container[this.key]) return;
- // grrr, path key is out of sync. this is likely due to a modification to the AST
- // not through our path APIs
- if (Array.isArray(this.container)) {
- for (var i = 0; i < this.container.length; i++) {
- if (this.container[i] === this.node) {
- return this.setKey(i);
- }
- }
- } else {
- for (var key in this.container) {
- if (this.container[key] === this.node) {
- return this.setKey(key);
- }
- }
- }
- throw new Error(messages.get("lostTrackNodePath"));
- };
- /**
- * Description
- */
- TraversalPath.prototype.shiftContext = function shiftContext() {
- this.contexts.shift();
- this.setContext(this.contexts[0]);
- };
- /**
- * Description
- */
- TraversalPath.prototype.unshiftContext = function unshiftContext(context) {
- this.contexts.unshift(context);
- this.setContext(context);
- };
- /**
- * Description
- */
- TraversalPath.prototype.setup = function setup(parentPath, key) {
- this.parentPath = parentPath || this.parentPath;
- this.setKey(key);
- };
- /**
- * Description
- */
- TraversalPath.prototype.setKey = function setKey(key) {
- this.key = key;
- this.node = this.container[this.key];
- this.type = this.node && this.node.type;
- };
- /**
- * Share comments amongst siblings.
- */
- TraversalPath.prototype.shareCommentsWithSiblings = function shareCommentsWithSiblings() {
- var node = this.node;
- if (!node) return;
- var trailing = node.trailingComments;
- var leading = node.leadingComments;
- if (!trailing && !leading) return;
- var prev = this.getSibling(this.key - 1);
- var next = this.getSibling(this.key + 1);
- if (!prev.node) prev = next;
- if (!next.node) next = prev;
- prev.giveComments("trailing", leading);
- next.giveComments("leading", trailing);
- };
- /**
- * Give node `comments` of the specified `type`.
- */
- TraversalPath.prototype.giveComments = function giveComments(type, comments) {
- if (!comments) return;
- var node = this.node;
- if (!node) return;
- var key = "" + type + "Comments";
- if (node[key]) {
- node[key] = node[key].concat(comments);
- } else {
- node[key] = comments;
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.remove = function remove() {
- this.shareCommentsWithSiblings();
- this._remove();
- this.removed = true;
- var parentPath = this.parentPath;
- var parent = this.parent;
- if (!parentPath) return;
- // we've just removed the last declarator of a variable declaration so there's no point in
- // keeping it
- if (parentPath.isVariableDeclaration() && parent.declarations.length === 0) {
- return parentPath.remove();
- }
- // we're the child of an expression statement so we should remove the parent
- if (parentPath.isExpressionStatement()) {
- return parentPath.remove();
- }
- // we've just removed the second element of a sequence expression so let's turn that sequence
- // expression into a regular expression
- if (parentPath.isSequenceExpression() && parent.expressions.length === 1) {
- parentPath.replaceWith(parent.expressions[0]);
- }
- // we're in a binary expression, better remove it and replace it with the last expression
- if (parentPath.isBinary()) {
- if (this.key === "left") {
- parentPath.replaceWith(parent.right);
- } else {
- // key === "right"
- parentPath.replaceWith(parent.left);
- }
- }
- };
- TraversalPath.prototype._remove = function _remove() {
- if (Array.isArray(this.container)) {
- this.container.splice(this.key, 1);
- this.updateSiblingKeys(this.key, -1);
- } else {
- this.container[this.key] = null;
- }
- this.node = null;
- };
- /**
- * Description
- */
- TraversalPath.prototype.skip = function skip() {
- this.shouldSkip = true;
- };
- /**
- * Description
- */
- TraversalPath.prototype.stop = function stop() {
- this.shouldStop = true;
- this.shouldSkip = true;
- };
- /**
- * Description
- */
- TraversalPath.prototype.errorWithNode = function errorWithNode(msg) {
- var Error = arguments[1] === undefined ? SyntaxError : arguments[1];
- var loc = this.node.loc.start;
- var err = new Error("Line " + loc.line + ": " + msg);
- err.loc = loc;
- return err;
- };
- /**
- * Description
- */
- TraversalPath.prototype.replaceInline = function replaceInline(nodes) {
- if (Array.isArray(nodes)) {
- if (Array.isArray(this.container)) {
- nodes = this._verifyNodeList(nodes);
- this._containerInsertAfter(nodes);
- return this.remove();
- } else {
- return this.replaceWithMultiple(nodes);
- }
- } else {
- return this.replaceWith(nodes);
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype._verifyNodeList = function _verifyNodeList(nodes) {
- if (nodes.constructor !== Array) {
- nodes = [nodes];
- }
- for (var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- if (!node) {
- throw new Error("Node list has falsy node with the index of " + i);
- } else if (typeof node !== "object") {
- throw new Error("Node list contains a non-object node with the index of " + i);
- } else if (!node.type) {
- throw new Error("Node list contains a node without a type with the index of " + i);
- }
- }
- return nodes;
- };
- /**
- * Description
- */
- TraversalPath.prototype.unshiftContainer = function unshiftContainer(containerKey, nodes) {
- nodes = this._verifyNodeList(nodes);
- // get the first path and insert our nodes before it, if it doesn't exist then it
- // doesn't matter, our nodes will be inserted anyway
- var container = this.node[containerKey];
- var path = TraversalPath.get(this, this.node, container, 0);
- return path.insertBefore(nodes);
- };
- /**
- * Description
- */
- TraversalPath.prototype.pushContainer = function pushContainer(containerKey, nodes) {
- nodes = this._verifyNodeList(nodes);
- // get an invisible path that represents the last node + 1 and replace it with our
- // nodes, effectively inlining it
- var container = this.node[containerKey];
- var i = container.length;
- var path = TraversalPath.get(this, this.node, container, i);
- return path.replaceWith(nodes, true);
- };
- /**
- * Description
- */
- TraversalPath.prototype.replaceWithMultiple = function replaceWithMultiple(nodes) {
- nodes = this._verifyNodeList(nodes);
- t.inheritsComments(nodes[0], this.node);
- this.node = this.container[this.key] = null;
- this.insertAfter(nodes);
- if (!this.node) this.remove();
- };
- /**
- * Description
- */
- TraversalPath.prototype.replaceWithSourceString = function replaceWithSourceString(replacement) {
- try {
- replacement = "(" + replacement + ")";
- replacement = (0, _helpersParse2["default"])(replacement);
- } catch (err) {
- var loc = err.loc;
- if (loc) {
- err.message += " - make sure this is an expression.";
- err.message += "\n" + (0, _helpersCodeFrame2["default"])(replacement, loc.line, loc.column + 1);
- }
- throw err;
- }
- replacement = replacement.program.body[0].expression;
- _index2["default"].removeProperties(replacement);
- return this.replaceWith(replacement);
- };
- /**
- * Description
- */
- TraversalPath.prototype.replaceWith = function replaceWith(replacement, whateverAllowed) {
- if (this.removed) {
- throw new Error("You can't replace this node, we've already removed it");
- }
- if (!replacement) {
- throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead");
- }
- if (this.node === replacement) {
- return;
- }
- // normalise inserting an entire AST
- if (t.isProgram(replacement)) {
- replacement = replacement.body;
- whateverAllowed = true;
- }
- if (Array.isArray(replacement)) {
- if (whateverAllowed) {
- return this.replaceWithMultiple(replacement);
- } else {
- throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");
- }
- }
- if (typeof replacement === "string") {
- if (whateverAllowed) {
- return this.replaceWithSourceString(replacement);
- } else {
- throw new Error("Don't use `path.replaceWith()` with a string, use `path.replaceWithSourceString()`");
- }
- }
- // replacing a statement with an expression so wrap it in an expression statement
- if (this.isPreviousType("Statement") && t.isExpression(replacement)) {
- replacement = t.expressionStatement(replacement);
- }
- // replacing an expression with a statement so let's explode it
- if (this.isPreviousType("Expression") && t.isStatement(replacement)) {
- return this.replaceExpressionWithStatements([replacement]);
- }
- var oldNode = this.node;
- if (oldNode) t.inheritsComments(replacement, oldNode);
- // replace the node
- this.node = this.container[this.key] = replacement;
- this.type = replacement.type;
- // potentially create new scope
- this.setScope();
- };
- /**
- * Description
- */
- TraversalPath.prototype.getStatementParent = function getStatementParent() {
- var path = this;
- do {
- if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
- break;
- } else {
- path = path.parentPath;
- }
- } while (path);
- if (path && (path.isProgram() || path.isFile())) {
- throw new Error("File/Program node, we can't possibly find a statement parent to this");
- }
- return path;
- };
- /**
- * Description
- */
- TraversalPath.prototype.getLastStatements = function getLastStatements() {
- var paths = [];
- var add = function add(path) {
- if (path) paths = paths.concat(path.getLastStatements());
- };
- if (this.isIfStatement()) {
- add(this.get("consequent"));
- add(this.get("alternate"));
- } else if (this.isDoExpression()) {
- add(this.get("body"));
- } else if (this.isProgram() || this.isBlockStatement()) {
- add(this.get("body").pop());
- } else {
- paths.push(this);
- }
- return paths;
- };
- /**
- * Description
- */
- TraversalPath.prototype.replaceExpressionWithStatements = function replaceExpressionWithStatements(nodes) {
- var toSequenceExpression = t.toSequenceExpression(nodes, this.scope);
- if (toSequenceExpression) {
- return this.replaceWith(toSequenceExpression);
- } else {
- var container = t.functionExpression(null, [], t.blockStatement(nodes));
- container.shadow = true;
- // add implicit returns to all ending expression statements
- var last = this.getLastStatements();
- for (var i = 0; i < last.length; i++) {
- var lastNode = last[i];
- if (lastNode.isExpressionStatement()) {
- lastNode.replaceWith(t.returnStatement(lastNode.node.expression));
- }
- }
- this.replaceWith(t.callExpression(container, []));
- this.traverse(hoistVariablesVisitor);
- return this.node;
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.call = function call(key) {
- var node = this.node;
- if (!node) return;
- var opts = this.opts;
- if (!opts[key] && !opts[node.type]) return;
- var fns = [].concat(opts[key]);
- if (opts[node.type]) fns = fns.concat(opts[node.type][key]);
- var _arr5 = fns;
- for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
- var fn = _arr5[_i5];
- if (!fn) continue;
- var node = this.node;
- if (!node) return;
- var previousType = this.type;
- // call the function with the params (node, parent, scope, state)
- var replacement = fn.call(this, node, this.parent, this.scope, this.state);
- if (replacement) {
- this.replaceWith(replacement, true);
- }
- if (this.shouldStop || this.shouldSkip || this.removed) return;
- if (previousType !== this.type) {
- this.queueNode(this);
- return;
- }
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.isBlacklisted = function isBlacklisted() {
- var blacklist = this.opts.blacklist;
- return blacklist && blacklist.indexOf(this.node.type) > -1;
- };
- /**
- * Description
- */
- TraversalPath.prototype.visit = function visit() {
- if (this.isBlacklisted()) return false;
- if (this.opts.shouldSkip && this.opts.shouldSkip(this)) return false;
- this.call("enter");
- if (this.shouldSkip) {
- return this.shouldStop;
- }
- var node = this.node;
- var opts = this.opts;
- if (node) {
- if (Array.isArray(node)) {
- // traverse over these replacement nodes we purposely don't call exitNode
- // as the original node has been destroyed
- for (var i = 0; i < node.length; i++) {
- _index2["default"].node(node[i], opts, this.scope, this.state, this);
- }
- } else {
- _index2["default"].node(node, opts, this.scope, this.state, this);
- this.call("exit");
- }
- }
- return this.shouldStop;
- };
- /**
- * Description
- */
- TraversalPath.prototype.getSibling = function getSibling(key) {
- return TraversalPath.get(this.parentPath, this.parent, this.container, key, this.file);
- };
- /**
- * Description
- */
- TraversalPath.prototype.get = function get(key) {
- var parts = key.split(".");
- if (parts.length === 1) {
- // "foo"
- return this._getKey(key);
- } else {
- // "foo.bar"
- return this._getPattern(parts);
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype._getKey = function _getKey(key) {
- var _this = this;
- var node = this.node;
- var container = node[key];
- if (Array.isArray(container)) {
- // requested a container so give them all the paths
- return container.map(function (_, i) {
- return TraversalPath.get(_this, node, container, i).setContext();
- });
- } else {
- return TraversalPath.get(this, node, node, key).setContext();
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype._getPattern = function _getPattern(parts) {
- var path = this;
- var _arr6 = parts;
- for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
- var part = _arr6[_i6];
- if (part === ".") {
- path = path.parentPath;
- } else {
- if (Array.isArray(path)) {
- path = path[part];
- } else {
- path = path.get(part);
- }
- }
- }
- return path;
- };
- /**
- * Description
- */
- TraversalPath.prototype.has = function has(key) {
- var val = this.node[key];
- if (val && Array.isArray(val)) {
- return !!val.length;
- } else {
- return !!val;
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.is = function is(key) {
- return this.has(key);
- };
- /**
- * Description
- */
- TraversalPath.prototype.isnt = function isnt(key) {
- return !this.has(key);
- };
- /**
- * Description
- */
- TraversalPath.prototype.equals = function equals(key, value) {
- return this.node[key] === value;
- };
- /**
- * Description
- */
- TraversalPath.prototype.getTypeAnnotation = function getTypeAnnotation() {
- if (this.typeInfo) {
- return this.typeInfo;
- }
- var info = this.typeInfo = {
- inferred: false,
- annotation: null
- };
- var type = this.node && this.node.typeAnnotation;
- if (!type) {
- info.inferred = true;
- type = this.inferType(this);
- }
- if (type) {
- if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
- info.annotation = type;
- }
- return info;
- };
- /**
- * Description
- */
- TraversalPath.prototype.resolve = function resolve() {
- if (this.isVariableDeclarator()) {
- if (this.get("id").isIdentifier()) {
- return this.get("init").resolve();
- } else {}
- } else if (this.isIdentifier()) {
- var binding = this.scope.getBinding(this.node.name);
- if (!binding || !binding.constant) return;
- // todo: take into consideration infinite recursion #1149
- return;
- if (binding.path === this) {
- return this;
- } else {
- return binding.path.resolve();
- }
- } else if (this.isMemberExpression()) {
- // this is dangerous, as non-direct target assignments will mutate it's state
- // making this resolution inaccurate
- var targetKey = this.toComputedKey();
- if (!t.isLiteral(targetKey)) return;
- var targetName = targetKey.value;
- var target = this.get("object").resolve();
- if (!target || !target.isObjectExpression()) return;
- var props = target.get("properties");
- for (var i = 0; i < props.length; i++) {
- var prop = props[i];
- if (!prop.isProperty()) continue;
- var key = prop.get("key");
- // { foo: obj }
- var match = prop.isnt("computed") && key.isIdentifier({ name: targetName });
- // { "foo": "obj" } or { ["foo"]: "obj" }
- match = match || key.isLiteral({ value: targetName });
- if (match) return prop.get("value");
- }
- } else {
- return this;
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.inferType = function inferType(path) {
- path = path.resolve();
- if (!path) return;
- if (path.isPreviousType("RestElement") || path.parentPath.isPreviousType("RestElement") || path.isPreviousType("ArrayExpression")) {
- return t.genericTypeAnnotation(t.identifier("Array"));
- }
- if (path.parentPath.isPreviousType("TypeCastExpression")) {
- return path.parentPath.node.typeAnnotation;
- }
- if (path.isPreviousType("TypeCastExpression")) {
- return path.node.typeAnnotation;
- }
- if (path.isPreviousType("ObjectExpression")) {
- return t.genericTypeAnnotation(t.identifier("Object"));
- }
- if (path.isPreviousType("Function")) {
- return t.identifier("Function");
- }
- if (path.isPreviousType("Literal")) {
- var value = path.node.value;
- if ((0, _lodashLangIsString2["default"])(value)) return t.stringTypeAnnotation();
- if ((0, _lodashLangIsNumber2["default"])(value)) return t.numberTypeAnnotation();
- if ((0, _lodashLangIsBoolean2["default"])(value)) return t.booleanTypeAnnotation();
- }
- if (path.isPreviousType("CallExpression")) {
- var callee = path.get("callee").resolve();
- if (callee && callee.isPreviousType("Function")) return callee.node.returnType;
- }
- };
- /**
- * Description
- */
- TraversalPath.prototype.isPreviousType = function isPreviousType(type) {
- return t.isType(this.type, type);
- };
- /**
- * Description
- */
- TraversalPath.prototype.isTypeGeneric = function isTypeGeneric(genericName) {
- var opts = arguments[1] === undefined ? {} : arguments[1];
- var typeInfo = this.getTypeAnnotation();
- var type = typeInfo.annotation;
- if (!type) return false;
- if (typeInfo.inferred && opts.inference === false) {
- return false;
- }
- if (!t.isGenericTypeAnnotation(type) || !t.isIdentifier(type.id, { name: genericName })) {
- return false;
- }
- if (opts.requireTypeParameters && !type.typeParameters) {
- return false;
- }
- return true;
- };
- /**
- * Description
- */
- TraversalPath.prototype.getBindingIdentifiers = function getBindingIdentifiers() {
- return t.getBindingIdentifiers(this.node);
- };
- /**
- * Description
- */
- TraversalPath.prototype.traverse = function traverse(visitor, state) {
- if (!this.scope) console.log(this.contexts);
- (0, _index2["default"])(this.node, visitor, this.scope, state, this);
- };
- /**
- * Description
- */
- TraversalPath.prototype.hoist = function hoist() {
- var scope = arguments[0] === undefined ? this.scope : arguments[0];
- var hoister = new _hoister2["default"](this, scope);
- return hoister.run();
- };
- /**
- * Match the current node if it matches the provided `pattern`.
- *
- * For example, given the match `React.createClass` it would match the
- * parsed nodes of `React.createClass` and `React["createClass"]`.
- */
- TraversalPath.prototype.matchesPattern = function matchesPattern(pattern, allowPartial) {
- var parts = pattern.split(".");
- // not a member expression
- if (!this.isMemberExpression()) return false;
- var search = [this.node];
- var i = 0;
- function matches(name) {
- var part = parts[i];
- return part === "*" || name === part;
- }
- while (search.length) {
- var node = search.shift();
- if (allowPartial && i === parts.length) {
- return true;
- }
- if (t.isIdentifier(node)) {
- // this part doesn't match
- if (!matches(node.name)) return false;
- } else if (t.isLiteral(node)) {
- // this part doesn't match
- if (!matches(node.value)) return false;
- } else if (t.isMemberExpression(node)) {
- if (node.computed && !t.isLiteral(node.property)) {
- // we can't deal with this
- return false;
- } else {
- search.push(node.object);
- search.push(node.property);
- continue;
- }
- } else {
- // we can't deal with this
- return false;
- }
- // too many parts
- if (++i > parts.length) {
- return false;
- }
- }
- return true;
- };
- return TraversalPath;
- })();
- exports["default"] = TraversalPath;
- (0, _lodashObjectAssign2["default"])(TraversalPath.prototype, require("./evaluation"));
- (0, _lodashObjectAssign2["default"])(TraversalPath.prototype, require("./conversion"));
- var _loop = function (type) {
- if (type[0] === "_") return "continue";
- TraversalPath.prototype["is" + type] = function (opts) {
- return virtualTypes[type].checkPath(this, opts);
- };
- };
- for (var type in virtualTypes) {
- var _ret = _loop(type);
- if (_ret === "continue") continue;
- }
- var _arr2 = t.TYPES;
- var _loop2 = function () {
- var type = _arr2[_i2];
- var typeKey = "is" + type;
- TraversalPath.prototype[typeKey] = function (opts) {
- return t[typeKey](this.node, opts);
- };
- };
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- _loop2();
- }
- module.exports = exports["default"];
- // otherwise it's a request for a destructuring declarator and i'm not
- // ready to resolve those just yet
- },{"../../helpers/code-frame":42,"../../helpers/parse":46,"../../messages":47,"../../types":169,"../index":157,"../scope":164,"../visitors":165,"./conversion":158,"./evaluation":159,"./hoister":160,"./virtual-types":162,"lodash/collection/includes":332,"lodash/lang/isBoolean":406,"lodash/lang/isNumber":410,"lodash/lang/isRegExp":413,"lodash/lang/isString":414,"lodash/object/assign":417,"lodash/object/extend":419}],162:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var ReferencedIdentifier = {
- type: "Identifier",
- checkPath: function checkPath(path, opts) {
- return t.isReferencedIdentifier(path.node, path.parent, opts);
- }
- };
- exports.ReferencedIdentifier = ReferencedIdentifier;
- var Scope = {
- type: "Scopable",
- checkPath: function checkPath(path) {
- return t.isScope(path.node, path.parent);
- }
- };
- exports.Scope = Scope;
- var Referenced = {
- checkPath: function checkPath(path) {
- return t.isReferenced(path.node, path.parent);
- }
- };
- exports.Referenced = Referenced;
- var BlockScoped = {
- checkPath: function checkPath(path) {
- return t.isBlockScoped(path.node);
- }
- };
- exports.BlockScoped = BlockScoped;
- var Var = {
- type: "VariableDeclaration",
- checkPath: function checkPath(path) {
- return t.isVar(path.node);
- }
- };
- exports.Var = Var;
- },{"../../types":169}],163:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var Binding = (function () {
- function Binding(_ref) {
- var identifier = _ref.identifier;
- var scope = _ref.scope;
- var path = _ref.path;
- var kind = _ref.kind;
- _classCallCheck(this, Binding);
- this.constantViolations = [];
- this.constant = true;
- this.identifier = identifier;
- this.references = 0;
- this.referenced = false;
- this.scope = scope;
- this.path = path;
- this.kind = kind;
- }
- /**
- * Description
- */
- Binding.prototype.setTypeAnnotation = function setTypeAnnotation() {
- var typeInfo = this.path.getTypeAnnotation();
- this.typeAnnotationInferred = typeInfo.inferred;
- this.typeAnnotation = typeInfo.annotation;
- };
- /**
- * Description
- */
- Binding.prototype.isTypeGeneric = function isTypeGeneric() {
- var _path;
- return (_path = this.path).isTypeGeneric.apply(_path, arguments);
- };
- /**
- * Description
- */
- Binding.prototype.assignTypeGeneric = function assignTypeGeneric(type, params) {
- var typeParams = null;
- if (params) params = t.typeParameterInstantiation(params);
- this.assignType(t.genericTypeAnnotation(t.identifier(type), typeParams));
- };
- /**
- * Description
- */
- Binding.prototype.assignType = function assignType(type) {
- this.typeAnnotation = type;
- };
- /**
- * Description
- */
- Binding.prototype.reassign = function reassign(path) {
- this.constant = false;
- this.constantViolations.push(path);
- if (this.typeAnnotationInferred) {
- // destroy the inferred typeAnnotation
- this.typeAnnotation = null;
- }
- };
- /**
- * Description
- */
- Binding.prototype.reference = function reference() {
- this.referenced = true;
- this.references++;
- };
- /**
- * Description
- */
- Binding.prototype.dereference = function dereference() {
- this.references--;
- this.referenced = !!this.references;
- };
- /**
- * Description
- */
- Binding.prototype.isCompatibleWithType = function isCompatibleWithType(newType) {
- return false;
- };
- return Binding;
- })();
- exports["default"] = Binding;
- module.exports = exports["default"];
- },{"../../types":169}],164:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var _lodashCollectionIncludes = require("lodash/collection/includes");
- var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
- var _visitors = require("../visitors");
- var _index = require("../index");
- var _index2 = _interopRequireDefault(_index);
- var _lodashObjectDefaults = require("lodash/object/defaults");
- var _lodashObjectDefaults2 = _interopRequireDefault(_lodashObjectDefaults);
- var _messages = require("../../messages");
- var messages = _interopRequireWildcard(_messages);
- var _binding = require("./binding");
- var _binding2 = _interopRequireDefault(_binding);
- var _globals = require("globals");
- var _globals2 = _interopRequireDefault(_globals);
- var _lodashArrayFlatten = require("lodash/array/flatten");
- var _lodashArrayFlatten2 = _interopRequireDefault(_lodashArrayFlatten);
- var _lodashObjectExtend = require("lodash/object/extend");
- var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
- var _helpersObject = require("../../helpers/object");
- var _helpersObject2 = _interopRequireDefault(_helpersObject);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _types = require("../../types");
- var t = _interopRequireWildcard(_types);
- var functionVariableVisitor = {
- enter: function enter(node, parent, scope, state) {
- if (t.isFor(node)) {
- var _arr = t.FOR_INIT_KEYS;
- for (var _i = 0; _i < _arr.length; _i++) {
- var key = _arr[_i];
- var declar = this.get(key);
- if (declar.isVar()) state.scope.registerBinding("var", declar);
- }
- }
- // this block is a function so we'll stop since none of the variables
- // declared within are accessible
- if (this.isFunction()) return this.skip();
- // function identifier doesn't belong to this scope
- if (state.blockId && node === state.blockId) return;
- // delegate block scope handling to the `blockVariableVisitor`
- if (this.isBlockScoped()) return;
- // this will be hit again once we traverse into it after this iteration
- if (this.isExportDeclaration() && t.isDeclaration(node.declaration)) return;
- // we've ran into a declaration!
- if (this.isDeclaration()) state.scope.registerDeclaration(this);
- }
- };
- var programReferenceVisitor = (0, _visitors.explode)({
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
- var bindingInfo = scope.getBinding(node.name);
- if (bindingInfo) {
- bindingInfo.reference();
- } else {
- state.addGlobal(node);
- }
- },
- Scopable: function Scopable(node, parent, scope, state) {
- for (var name in scope.bindings) {
- state.references[name] = true;
- }
- },
- ExportDeclaration: {
- exit: function exit(node, parent, scope, state) {
- var declar = node.declaration;
- if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
- scope.getBinding(declar.id.name).reference();
- } else if (t.isVariableDeclaration(declar)) {
- var _arr2 = declar.declarations;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var decl = _arr2[_i2];
- var ids = t.getBindingIdentifiers(decl);
- for (var name in ids) {
- scope.getBinding(name).reference();
- }
- }
- }
- }
- },
- LabeledStatement: function LabeledStatement(node, parent, scope, state) {
- state.addGlobal(node);
- },
- AssignmentExpression: function AssignmentExpression(node, parent, scope, state) {
- scope.registerConstantViolation(this.get("left"), this.get("right"));
- },
- UpdateExpression: function UpdateExpression(node, parent, scope, state) {
- scope.registerConstantViolation(this.get("argument"), null);
- },
- UnaryExpression: function UnaryExpression(node, parent, scope, state) {
- if (node.operator === "delete") scope.registerConstantViolation(this.get("left"), null);
- }
- });
- var blockVariableVisitor = (0, _visitors.explode)({
- Scope: function Scope() {
- this.skip();
- },
- enter: function enter(node, parent, scope, state) {
- if (this.isFunctionDeclaration() || this.isBlockScoped()) {
- state.registerDeclaration(this);
- }
- }
- });
- var renameVisitor = (0, _visitors.explode)({
- ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
- if (node.name === state.oldName) {
- node.name = state.newName;
- }
- },
- Declaration: function Declaration(node, parent, scope, state) {
- var ids = this.getBindingIdentifiers();;
- for (var name in ids) {
- if (name === state.oldName) ids[name].name = state.newName;
- }
- },
- Scopable: function Scopable(node, parent, scope, state) {
- if (this.isScope()) {
- if (!scope.bindingIdentifierEquals(state.oldName, state.binding)) {
- this.skip();
- }
- }
- }
- });
- var Scope = (function () {
- /**
- * This searches the current "scope" and collects all references/bindings
- * within.
- */
- function Scope(path, parent, file) {
- _classCallCheck(this, Scope);
- if (parent && parent.block === path.node) {
- return parent;
- }
- var cached = path.getData("scope");
- if (cached && cached.parent === parent) {
- return cached;
- } else {}
- this.parent = parent;
- this.file = parent ? parent.file : file;
- this.parentBlock = path.parent;
- this.block = path.node;
- this.path = path;
- this.crawl();
- }
- /**
- * Description
- */
- Scope.prototype.traverse = function traverse(node, opts, state) {
- (0, _index2["default"])(node, opts, this, state, this.path);
- };
- /**
- * Since `Scope` instances are unique to their traversal we need some other
- * way to compare if scopes are the same. Here we just compare `this.bindings`
- * as it will be the same across all instances.
- */
- Scope.prototype.is = function is(scope) {
- return this.bindings === scope.bindings;
- };
- /**
- * Description
- */
- Scope.prototype.generateDeclaredUidIdentifier = function generateDeclaredUidIdentifier() {
- var name = arguments[0] === undefined ? "temp" : arguments[0];
- var id = this.generateUidIdentifier(name);
- this.push({ id: id });
- return id;
- };
- /**
- * Description
- */
- Scope.prototype.generateUidIdentifier = function generateUidIdentifier(name) {
- return t.identifier(this.generateUid(name));
- };
- /**
- * Description
- */
- Scope.prototype.generateUid = function generateUid(name) {
- name = t.toIdentifier(name).replace(/^_+/, "");
- var uid;
- var i = 0;
- do {
- uid = this._generateUid(name, i);
- i++;
- } while (this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
- var program = this.getProgramParent();
- program.references[uid] = true;
- program.uids[uid] = true;
- return uid;
- };
- Scope.prototype._generateUid = function _generateUid(name, i) {
- var id = name;
- if (i > 1) id += i;
- return "_" + id;
- };
- /*
- * Description
- */
- Scope.prototype.generateUidIdentifierBasedOnNode = function generateUidIdentifierBasedOnNode(parent, defaultName) {
- var node = parent;
- if (t.isAssignmentExpression(parent)) {
- node = parent.left;
- } else if (t.isVariableDeclarator(parent)) {
- node = parent.id;
- } else if (t.isProperty(node)) {
- node = node.key;
- }
- var parts = [];
- var add = function add(node) {
- if (t.isModuleDeclaration(node)) {
- if (node.source) {
- add(node.source);
- } else if (node.specifiers && node.specifiers.length) {
- var _arr3 = node.specifiers;
- for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
- var specifier = _arr3[_i3];
- add(specifier);
- }
- } else if (node.declaration) {
- add(node.declaration);
- }
- } else if (t.isModuleSpecifier(node)) {
- add(node.local);
- } else if (t.isMemberExpression(node)) {
- add(node.object);
- add(node.property);
- } else if (t.isIdentifier(node)) {
- parts.push(node.name);
- } else if (t.isLiteral(node)) {
- parts.push(node.value);
- } else if (t.isCallExpression(node)) {
- add(node.callee);
- } else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
- var _arr4 = node.properties;
- for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
- var prop = _arr4[_i4];
- add(prop.key || prop.argument);
- }
- }
- };
- add(node);
- var id = parts.join("$");
- id = id.replace(/^_/, "") || defaultName || "ref";
- return this.generateUidIdentifier(id);
- };
- /**
- * Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
- * evaluating it wont result in potentially arbitrary code from being ran. The following are
- * whitelisted and determined not cause side effects:
- *
- * - `this` expressions
- * - `super` expressions
- * - Bound identifiers
- */
- Scope.prototype.isStatic = function isStatic(node) {
- if (t.isThisExpression(node) || t.isSuper(node)) {
- return true;
- }
- if (t.isIdentifier(node) && this.hasBinding(node.name)) {
- return true;
- }
- return false;
- };
- /**
- * Description
- */
- Scope.prototype.maybeGenerateMemoised = function maybeGenerateMemoised(node, dontPush) {
- if (this.isStatic(node)) {
- return null;
- } else {
- var id = this.generateUidIdentifierBasedOnNode(node);
- if (!dontPush) this.push({ id: id });
- return id;
- }
- };
- /**
- * Description
- */
- Scope.prototype.checkBlockScopedCollisions = function checkBlockScopedCollisions(kind, name, id) {
- var local = this.getOwnBindingInfo(name);
- if (!local) return;
- if (kind === "param") return;
- if (kind === "hoisted" && local.kind === "let") return;
- var duplicate = false;
- if (!duplicate) duplicate = kind === "let" || kind === "const" || local.kind === "let" || local.kind === "const" || local.kind === "module";
- if (!duplicate) duplicate = local.kind === "param" && (kind === "let" || kind === "const");
- if (duplicate) {
- throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
- }
- };
- /**
- * Description
- */
- Scope.prototype.rename = function rename(oldName, newName, block) {
- newName = newName || this.generateUidIdentifier(oldName).name;
- var info = this.getBinding(oldName);
- if (!info) return;
- var state = {
- newName: newName,
- oldName: oldName,
- binding: info.identifier,
- info: info
- };
- var scope = info.scope;
- scope.traverse(block || scope.block, renameVisitor, state);
- if (!block) {
- scope.removeOwnBinding(oldName);
- scope.bindings[newName] = info;
- state.binding.name = newName;
- }
- var file = this.file;
- if (file) {
- this._renameFromMap(file.moduleFormatter.localImports, oldName, newName, state.binding);
- //this._renameFromMap(file.moduleFormatter.localExports, oldName, newName);
- }
- };
- Scope.prototype._renameFromMap = function _renameFromMap(map, oldName, newName, value) {
- if (map[oldName]) {
- map[newName] = value;
- map[oldName] = null;
- }
- };
- /**
- * Description
- */
- Scope.prototype.dump = function dump() {
- var scope = this;
- do {
- console.log(scope.block.type, "Bindings:", Object.keys(scope.bindings));
- } while (scope = scope.parent);
- console.log("-------------");
- };
- /**
- * Description
- */
- Scope.prototype.toArray = function toArray(node, i) {
- var file = this.file;
- if (t.isIdentifier(node)) {
- var binding = this.getBinding(node.name);
- if (binding && binding.constant && binding.isTypeGeneric("Array")) return node;
- }
- if (t.isArrayExpression(node)) {
- return node;
- }
- if (t.isIdentifier(node, { name: "arguments" })) {
- return t.callExpression(t.memberExpression(file.addHelper("slice"), t.identifier("call")), [node]);
- }
- var helperName = "to-array";
- var args = [node];
- if (i === true) {
- helperName = "to-consumable-array";
- } else if (i) {
- args.push(t.literal(i));
- helperName = "sliced-to-array";
- if (this.file.isLoose("es6.forOf")) helperName += "-loose";
- }
- return t.callExpression(file.addHelper(helperName), args);
- };
- /**
- * Description
- */
- Scope.prototype.registerDeclaration = function registerDeclaration(path) {
- var node = path.node;
- if (t.isFunctionDeclaration(node)) {
- this.registerBinding("hoisted", path);
- } else if (t.isVariableDeclaration(node)) {
- var declarations = path.get("declarations");
- var _arr5 = declarations;
- for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
- var declar = _arr5[_i5];
- this.registerBinding(node.kind, declar);
- }
- } else if (t.isClassDeclaration(node)) {
- this.registerBinding("let", path);
- } else if (t.isImportDeclaration(node) || t.isExportDeclaration(node)) {
- this.registerBinding("module", path);
- } else {
- this.registerBinding("unknown", path);
- }
- };
- /**
- * Description
- */
- Scope.prototype.registerConstantViolation = function registerConstantViolation(left, right) {
- var ids = left.getBindingIdentifiers();
- for (var name in ids) {
- var binding = this.getBinding(name);
- if (!binding) continue;
- if (right) {
- var rightType = right.typeAnnotation;
- if (rightType && binding.isCompatibleWithType(rightType)) continue;
- }
- binding.reassign(left, right);
- }
- };
- /**
- * Description
- */
- Scope.prototype.registerBinding = function registerBinding(kind, path) {
- if (!kind) throw new ReferenceError("no `kind`");
- if (path.isVariableDeclaration()) {
- var declarators = path.get("declarations");
- var _arr6 = declarators;
- for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
- var declar = _arr6[_i6];
- this.registerBinding(kind, declar);
- }
- return;
- }
- var ids = path.getBindingIdentifiers();
- for (var name in ids) {
- var id = ids[name];
- this.checkBlockScopedCollisions(kind, name, id);
- this.bindings[name] = new _binding2["default"]({
- identifier: id,
- scope: this,
- path: path,
- kind: kind
- });
- }
- };
- /**
- * Description
- */
- Scope.prototype.addGlobal = function addGlobal(node) {
- this.globals[node.name] = node;
- };
- /**
- * Description
- */
- Scope.prototype.hasUid = function hasUid(name) {
- var scope = this;
- do {
- if (scope.uids[name]) return true;
- } while (scope = scope.parent);
- return false;
- };
- /**
- * Description
- */
- Scope.prototype.hasGlobal = function hasGlobal(name) {
- var scope = this;
- do {
- if (scope.globals[name]) return true;
- } while (scope = scope.parent);
- return false;
- };
- /**
- * Description
- */
- Scope.prototype.hasReference = function hasReference(name) {
- var scope = this;
- do {
- if (scope.references[name]) return true;
- } while (scope = scope.parent);
- return false;
- };
- /**
- * Description
- */
- Scope.prototype.recrawl = function recrawl() {
- this.path.setData("scopeInfo", null);
- this.crawl();
- };
- /**
- * Description
- */
- Scope.prototype.isPure = function isPure(node) {
- if (t.isIdentifier(node)) {
- var bindingInfo = this.getBinding(node.name);
- return bindingInfo && bindingInfo.constant;
- } else {
- return t.isPure(node);
- }
- };
- /**
- * Description
- */
- Scope.prototype.crawl = function crawl() {
- var path = this.path;
- //
- var info = this.block._scopeInfo;
- if (info) return (0, _lodashObjectExtend2["default"])(this, info);
- info = this.block._scopeInfo = {
- references: (0, _helpersObject2["default"])(),
- bindings: (0, _helpersObject2["default"])(),
- globals: (0, _helpersObject2["default"])(),
- uids: (0, _helpersObject2["default"])() };
- (0, _lodashObjectExtend2["default"])(this, info);
- // ForStatement - left, init
- if (path.isLoop()) {
- var _arr7 = t.FOR_INIT_KEYS;
- for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
- var key = _arr7[_i7];
- var node = path.get(key);
- if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
- }
- }
- // FunctionExpression - id
- if (path.isFunctionExpression() && path.has("id")) {
- if (!t.isProperty(path.parent, { method: true })) {
- this.registerBinding("var", path.get("id"));
- }
- }
- // Class
- if (path.isClassDeclaration()) {
- var name = path.node.id.name;
- this.bindings[name] = this.parent.bindings[name];
- }
- if (path.isClassExpression() && path.has("id")) {
- this.registerBinding("var", path);
- }
- // Function - params, rest
- if (path.isFunction()) {
- var params = path.get("params");
- var _arr8 = params;
- for (var _i8 = 0; _i8 < _arr8.length; _i8++) {
- var param = _arr8[_i8];
- this.registerBinding("param", param);
- }
- this.traverse(path.get("body").node, blockVariableVisitor, this);
- }
- // Program, Function - var variables
- if (path.isProgram() || path.isFunction()) {
- this.traverse(path.node, functionVariableVisitor, {
- blockId: path.get("id").node,
- scope: this
- });
- }
- // Program, BlockStatement, Function - let variables
- if (path.isBlockStatement() || path.isProgram()) {
- this.traverse(path.node, blockVariableVisitor, this);
- }
- // CatchClause - param
- if (path.isCatchClause()) {
- this.registerBinding("let", path.get("param"));
- }
- // ComprehensionExpression - blocks
- if (path.isComprehensionExpression()) {
- this.registerBinding("let", path);
- }
- // Program
- if (path.isProgram()) {
- this.traverse(path.node, programReferenceVisitor, this);
- }
- };
- /**
- * Description
- */
- Scope.prototype.push = function push(opts) {
- var path = this.path;
- if (path.isLoop() || path.isCatchClause() || path.isFunction()) {
- t.ensureBlock(path.node);
- path = path.get("body");
- }
- if (!path.isBlockStatement() && !path.isProgram()) {
- path = this.getBlockParent().path;
- }
- var unique = opts.unique;
- var kind = opts.kind || "var";
- var dataKey = "declaration:" + kind;
- var declar = !unique && path.getData(dataKey);
- if (!declar) {
- declar = t.variableDeclaration(kind, []);
- declar._generated = true;
- declar._blockHoist = 2;
- this.file.attachAuxiliaryComment(declar);
- var _path$get$0$_containerInsertBefore = path.get("body")[0]._containerInsertBefore([declar]);
- var declarPath = _path$get$0$_containerInsertBefore[0];
- this.registerBinding(kind, declarPath);
- if (!unique) path.setData(dataKey, declar);
- }
- declar.declarations.push(t.variableDeclarator(opts.id, opts.init));
- };
- /**
- * Walk up to the top of the scope tree and get the `Program`.
- */
- Scope.prototype.getProgramParent = function getProgramParent() {
- var scope = this;
- while (scope.parent) {
- scope = scope.parent;
- }
- return scope;
- };
- /**
- * Walk up the scope tree until we hit either a Function or reach the
- * very top and hit Program.
- */
- Scope.prototype.getFunctionParent = function getFunctionParent() {
- var scope = this;
- while (scope.parent && !t.isFunction(scope.block)) {
- scope = scope.parent;
- }
- return scope;
- };
- /**
- * Walk up the scope tree until we hit either a BlockStatement/Loop or reach the
- * very top and hit Program.
- */
- Scope.prototype.getBlockParent = function getBlockParent() {
- var scope = this;
- while (scope.parent && !t.isFunction(scope.block) && !t.isLoop(scope.block) && !t.isFunction(scope.block)) {
- scope = scope.parent;
- }
- return scope;
- };
- /**
- * Walks the scope tree and gathers **all** bindings.
- */
- Scope.prototype.getAllBindings = function getAllBindings() {
- var ids = (0, _helpersObject2["default"])();
- var scope = this;
- do {
- (0, _lodashObjectDefaults2["default"])(ids, scope.bindings);
- scope = scope.parent;
- } while (scope);
- return ids;
- };
- /**
- * Walks the scope tree and gathers all declarations of `kind`.
- */
- Scope.prototype.getAllBindingsOfKind = function getAllBindingsOfKind() {
- var ids = (0, _helpersObject2["default"])();
- var _arr9 = arguments;
- for (var _i9 = 0; _i9 < _arr9.length; _i9++) {
- var kind = _arr9[_i9];
- var scope = this;
- do {
- for (var name in scope.bindings) {
- var binding = scope.bindings[name];
- if (binding.kind === kind) ids[name] = binding;
- }
- scope = scope.parent;
- } while (scope);
- }
- return ids;
- };
- /**
- * Description
- */
- Scope.prototype.bindingIdentifierEquals = function bindingIdentifierEquals(name, node) {
- return this.getBindingIdentifier(name) === node;
- };
- /**
- * Description
- */
- Scope.prototype.getBinding = function getBinding(name) {
- var scope = this;
- do {
- var binding = scope.getOwnBindingInfo(name);
- if (binding) return binding;
- } while (scope = scope.parent);
- };
- /**
- * Description
- */
- Scope.prototype.getOwnBindingInfo = function getOwnBindingInfo(name) {
- return this.bindings[name];
- };
- /**
- * Description
- */
- Scope.prototype.getBindingIdentifier = function getBindingIdentifier(name) {
- var info = this.getBinding(name);
- return info && info.identifier;
- };
- /**
- * Description
- */
- Scope.prototype.getOwnBindingIdentifier = function getOwnBindingIdentifier(name) {
- var binding = this.bindings[name];
- return binding && binding.identifier;
- };
- /**
- * Description
- */
- Scope.prototype.hasOwnBinding = function hasOwnBinding(name) {
- return !!this.getOwnBindingInfo(name);
- };
- /**
- * Description
- */
- Scope.prototype.hasBinding = function hasBinding(name) {
- if (!name) return false;
- if (this.hasOwnBinding(name)) return true;
- if (this.parentHasBinding(name)) return true;
- if (this.hasUid(name)) return true;
- if ((0, _lodashCollectionIncludes2["default"])(Scope.globals, name)) return true;
- if ((0, _lodashCollectionIncludes2["default"])(Scope.contextVariables, name)) return true;
- return false;
- };
- /**
- * Description
- */
- Scope.prototype.parentHasBinding = function parentHasBinding(name) {
- return this.parent && this.parent.hasBinding(name);
- };
- /**
- * Move a binding of `name` to another `scope`.
- */
- Scope.prototype.moveBindingTo = function moveBindingTo(name, scope) {
- var info = this.getBinding(name);
- if (info) {
- info.scope.removeOwnBinding(name);
- info.scope = scope;
- scope.bindings[name] = info;
- }
- };
- /**
- * Description
- */
- Scope.prototype.removeOwnBinding = function removeOwnBinding(name) {
- delete this.bindings[name];
- };
- /**
- * Description
- */
- Scope.prototype.removeBinding = function removeBinding(name) {
- var info = this.getBinding(name);
- if (info) info.scope.removeOwnBinding(name);
- };
- _createClass(Scope, null, [{
- key: "globals",
- value: (0, _lodashArrayFlatten2["default"])([_globals2["default"].builtin, _globals2["default"].browser, _globals2["default"].node].map(Object.keys)),
- enumerable: true
- }, {
- key: "contextVariables",
- value: ["this", "arguments", "super"],
- enumerable: true
- }]);
- return Scope;
- })();
- exports["default"] = Scope;
- module.exports = exports["default"];
- //path.setData("scope", this);
- },{"../../helpers/object":45,"../../messages":47,"../../types":169,"../index":157,"../visitors":165,"./binding":163,"globals":316,"lodash/array/flatten":325,"lodash/collection/each":330,"lodash/collection/includes":332,"lodash/object/defaults":418,"lodash/object/extend":419}],165:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- exports.explode = explode;
- exports.verify = verify;
- exports.merge = merge;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- var _pathVirtualTypes = require("./path/virtual-types");
- var virtualTypes = _interopRequireWildcard(_pathVirtualTypes);
- var _messages = require("../messages");
- var messages = _interopRequireWildcard(_messages);
- var _types = require("../types");
- var t = _interopRequireWildcard(_types);
- var _esquery = require("esquery");
- var _esquery2 = _interopRequireDefault(_esquery);
- function explode(visitor, mergeConflicts) {
- if (visitor._exploded) return visitor;
- visitor._exploded = true;
- // make sure there's no __esModule type since this is because we're using loose mode
- // and it sets __esModule to be enumerable on all modules :(
- delete visitor.__esModule;
- if (visitor.queries) {
- ensureEntranceObjects(visitor.queries);
- addQueries(visitor);
- delete visitor.queries;
- }
- // ensure visitors are objects
- ensureEntranceObjects(visitor);
- // add type wrappers
- for (var nodeType in visitor) {
- if (shouldIgnoreKey(nodeType)) continue;
- var wrapper = virtualTypes[nodeType];
- if (!wrapper) continue;
- // wrap all the functions
- var fns = visitor[nodeType];
- for (var type in fns) {
- fns[type] = wrapCheck(wrapper, fns[type]);
- }
- // clear it from the visitor
- delete visitor[nodeType];
- if (wrapper.type) {
- // merge the visitor if necessary or just put it back in
- if (visitor[wrapper.type]) {
- mergePair(visitor[wrapper.type], fns);
- } else {
- visitor[wrapper.type] = fns;
- }
- } else {
- mergePair(visitor, fns);
- }
- }
- // add aliases
- for (var nodeType in visitor) {
- if (shouldIgnoreKey(nodeType)) continue;
- var fns = visitor[nodeType];
- var aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
- if (!aliases) continue;
- // clear it form the visitor
- delete visitor[nodeType];
- var _arr = aliases;
- for (var _i = 0; _i < _arr.length; _i++) {
- var alias = _arr[_i];
- var existing = visitor[alias];
- if (existing) {
- if (mergeConflicts) {
- mergePair(existing, fns);
- }
- } else {
- visitor[alias] = fns;
- }
- }
- }
- return visitor;
- }
- function verify(visitor) {
- if (visitor._verified) return;
- if (typeof visitor === "function") {
- throw new Error(messages.get("traverseVerifyRootFunction"));
- }
- for (var nodeType in visitor) {
- if (shouldIgnoreKey(nodeType)) continue;
- if (t.TYPES.indexOf(nodeType) < 0 && !virtualTypes[nodeType]) {
- throw new Error(messages.get("traverseVerifyNodeType", nodeType));
- }
- var visitors = visitor[nodeType];
- if (typeof visitors === "object") {
- for (var visitorKey in visitors) {
- if (visitorKey === "enter" || visitorKey === "exit") continue;
- throw new Error(messages.get("traverseVerifyVisitorProperty", nodeType, visitorKey));
- }
- }
- }
- visitor._verified = true;
- }
- function merge(visitors) {
- var rootVisitor = {};
- var _arr2 = visitors;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var visitor = _arr2[_i2];
- for (var type in visitor) {
- var nodeVisitor = rootVisitor[type] = rootVisitor[type] || {};
- mergePair(nodeVisitor, visitor[type]);
- }
- }
- return rootVisitor;
- }
- function ensureEntranceObjects(obj) {
- for (var key in obj) {
- if (shouldIgnoreKey(key)) continue;
- var fns = obj[key];
- if (typeof fns === "function") {
- obj[key] = { enter: fns };
- }
- }
- }
- function addQueries(visitor) {
- for (var selector in visitor.queries) {
- var fns = visitor.queries[selector];
- addSelector(visitor, selector, fns);
- }
- }
- function addSelector(visitor, selector, fns) {
- selector = _esquery2["default"].parse(selector);
- var _loop = function () {
- var fn = fns[key];
- fns[key] = function (node) {
- if (_esquery2["default"].matches(node, selector, this.getAncestry())) {
- return fn.apply(this, arguments);
- }
- };
- };
- for (var key in fns) {
- _loop();
- }
- mergePair(visitor, fns);
- }
- function wrapCheck(wrapper, fn) {
- return function () {
- if (wrapper.checkPath(this)) {
- return fn.apply(this, arguments);
- }
- };
- }
- function shouldIgnoreKey(key) {
- // internal/hidden key
- if (key[0] === "_") return true;
- // ignore function keys
- if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
- // ignore other options
- if (key === "blacklist" || key === "noScope") return true;
- return false;
- }
- function mergePair(dest, src) {
- for (var key in src) {
- dest[key] = (dest[key] || []).concat(src[key]);
- }
- }
- },{"../messages":47,"../types":169,"./path/virtual-types":162,"esquery":307}],166:[function(require,module,exports){
- module.exports={
- "ExpressionStatement": ["Statement"],
- "BreakStatement": ["Statement", "Terminatorless"],
- "ContinueStatement": ["Statement", "Terminatorless"],
- "DebuggerStatement": ["Statement"],
- "DoWhileStatement": ["Statement", "Loop", "While", "Scopable"],
- "IfStatement": ["Statement"],
- "ReturnStatement": ["Statement", "Terminatorless"],
- "SwitchStatement": ["Statement", "Scopable"],
- "ThrowStatement": ["Statement", "Terminatorless"],
- "TryStatement": ["Statement"],
- "WhileStatement": ["Statement", "Loop", "While", "Scopable"],
- "WithStatement": ["Statement"],
- "EmptyStatement": ["Statement"],
- "LabeledStatement": ["Statement"],
- "VariableDeclaration": ["Statement", "Declaration"],
- "ImportSpecifier": ["ModuleSpecifier"],
- "ExportSpecifier": ["ModuleSpecifier"],
- "ImportDefaultSpecifier": ["ModuleSpecifier"],
- "ExportDefaultSpecifier": ["ModuleSpecifier"],
- "ExportNamespaceSpecifier": ["ModuleSpecifier"],
- "ExportDefaultFromSpecifier": ["ModuleSpecifier"],
- "ExportAllDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
- "ExportDefaultDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
- "ExportNamedDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
- "ImportDeclaration": ["Statement", "Declaration", "ModuleDeclaration"],
- "ArrowFunctionExpression": ["Scopable", "Function", "Func", "Expression", "Pure"],
- "FunctionDeclaration": ["Scopable", "Function", "Func", "Statement", "Pure", "Declaration"],
- "FunctionExpression": ["Scopable", "Function", "Func", "Expression", "Pure"],
- "BlockStatement": ["Scopable", "Statement"],
- "Program": ["Scopable"],
- "CatchClause": ["Scopable"],
- "LogicalExpression": ["Binary", "Expression"],
- "BinaryExpression": ["Binary", "Expression"],
- "UnaryExpression": ["UnaryLike", "Expression"],
- "SpreadProperty": ["UnaryLike"],
- "SpreadElement": ["UnaryLike"],
- "ClassDeclaration": ["Scopable", "Class", "Pure", "Statement", "Declaration"],
- "ClassExpression": ["Scopable", "Class", "Pure", "Expression"],
- "ForOfStatement": ["Scopable", "Statement", "For", "Loop"],
- "ForInStatement": ["Scopable", "Statement", "For", "Loop"],
- "ForStatement": ["Scopable", "Statement", "For", "Loop"],
- "ObjectPattern": ["Pattern"],
- "ArrayPattern": ["Pattern"],
- "AssignmentPattern": ["Pattern"],
- "Property": ["UserWhitespacable"],
- "ArrayExpression": ["Expression"],
- "AssignmentExpression": ["Expression"],
- "AwaitExpression": ["Expression", "Terminatorless"],
- "CallExpression": ["Expression"],
- "ComprehensionExpression": ["Expression", "Scopable"],
- "ConditionalExpression": ["Expression"],
- "DoExpression": ["Expression"],
- "Identifier": ["Expression"],
- "Literal": ["Expression", "Pure"],
- "MemberExpression": ["Expression"],
- "MetaProperty": ["Expression"],
- "NewExpression": ["Expression"],
- "ObjectExpression": ["Expression"],
- "SequenceExpression": ["Expression"],
- "TaggedTemplateExpression": ["Expression"],
- "ThisExpression": ["Expression"],
- "Super": ["Expression"],
- "UpdateExpression": ["Expression"],
- "JSXEmptyExpression": ["Expression"],
- "JSXMemberExpression": ["Expression"],
- "YieldExpression": ["Expression", "Terminatorless"],
- "AnyTypeAnnotation": ["Flow"],
- "ArrayTypeAnnotation": ["Flow"],
- "BooleanTypeAnnotation": ["Flow"],
- "ClassImplements": ["Flow"],
- "DeclareClass": ["Flow", "Statement"],
- "DeclareFunction": ["Flow", "Statement"],
- "DeclareModule": ["Flow", "Statement"],
- "DeclareVariable": ["Flow", "Statement"],
- "FunctionTypeAnnotation": ["Flow"],
- "FunctionTypeParam": ["Flow"],
- "GenericTypeAnnotation": ["Flow"],
- "InterfaceExtends": ["Flow"],
- "InterfaceDeclaration": ["Flow", "Statement", "Declaration"],
- "IntersectionTypeAnnotation": ["Flow"],
- "NullableTypeAnnotation": ["Flow"],
- "NumberTypeAnnotation": ["Flow"],
- "StringLiteralTypeAnnotation": ["Flow"],
- "StringTypeAnnotation": ["Flow"],
- "TupleTypeAnnotation": ["Flow"],
- "TypeofTypeAnnotation": ["Flow"],
- "TypeAlias": ["Flow", "Statement"],
- "TypeAnnotation": ["Flow"],
- "TypeCastExpression": ["Flow"],
- "TypeParameterDeclaration": ["Flow"],
- "TypeParameterInstantiation": ["Flow"],
- "ObjectTypeAnnotation": ["Flow"],
- "ObjectTypeCallProperty": ["Flow", "UserWhitespacable"],
- "ObjectTypeIndexer": ["Flow", "UserWhitespacable"],
- "ObjectTypeProperty": ["Flow", "UserWhitespacable"],
- "QualifiedTypeIdentifier": ["Flow"],
- "UnionTypeAnnotation": ["Flow"],
- "VoidTypeAnnotation": ["Flow"],
- "JSXAttribute": ["JSX", "Immutable"],
- "JSXClosingElement": ["JSX", "Immutable"],
- "JSXElement": ["JSX", "Immutable", "Expression"],
- "JSXEmptyExpression": ["JSX", "Immutable"],
- "JSXExpressionContainer": ["JSX", "Immutable"],
- "JSXIdentifier": ["JSX"],
- "JSXMemberExpression": ["JSX"],
- "JSXNamespacedName": ["JSX"],
- "JSXOpeningElement": ["JSX", "Immutable"],
- "JSXSpreadAttribute": ["JSX"]
- }
- },{}],167:[function(require,module,exports){
- module.exports={
- "ArrayExpression": {
- "elements": null
- },
- "ArrowFunctionExpression": {
- "params": null,
- "body": null
- },
- "AssignmentExpression": {
- "operator": null,
- "left": null,
- "right": null
- },
- "BinaryExpression": {
- "operator": null,
- "left": null,
- "right": null
- },
- "BindExpression": {
- "object": null,
- "callee": null
- },
- "BlockStatement": {
- "body": null
- },
- "CallExpression": {
- "callee": null,
- "arguments": null
- },
- "ConditionalExpression": {
- "test": null,
- "consequent": null,
- "alternate": null
- },
- "ExpressionStatement": {
- "expression": null
- },
- "File": {
- "program": null,
- "comments": null,
- "tokens": null
- },
- "FunctionExpression": {
- "id": null,
- "params": null,
- "body": null,
- "generator": false,
- "async": false
- },
- "FunctionDeclaration": {
- "id": null,
- "params": null,
- "body": null,
- "generator": false,
- "async": false
- },
- "GenericTypeAnnotation": {
- "id": null,
- "typeParameters": null
- },
- "Identifier": {
- "name": null
- },
- "IfStatement": {
- "test": null,
- "consequent": null,
- "alternate": null
- },
- "ImportDeclaration": {
- "specifiers": null,
- "source": null
- },
- "ImportSpecifier": {
- "local": null,
- "imported": null
- },
- "LabeledStatement": {
- "label": null,
- "body": null
- },
- "Literal": {
- "value": null
- },
- "LogicalExpression": {
- "operator": null,
- "left": null,
- "right": null
- },
- "MemberExpression": {
- "object": null,
- "property": null,
- "computed": false
- },
- "MethodDefinition": {
- "key": null,
- "value": null,
- "kind": "method",
- "computed": false,
- "static": false
- },
- "NewExpression": {
- "callee": null,
- "arguments": null
- },
- "ObjectExpression": {
- "properties": null
- },
- "Program": {
- "body": null
- },
- "Property": {
- "kind": null,
- "key": null,
- "value": null,
- "computed": false
- },
- "ReturnStatement": {
- "argument": null
- },
- "SequenceExpression": {
- "expressions": null
- },
- "TemplateLiteral": {
- "quasis": null,
- "expressions": null
- },
- "ThrowExpression": {
- "argument": null
- },
- "UnaryExpression": {
- "operator": null,
- "argument": null,
- "prefix": null
- },
- "VariableDeclaration": {
- "kind": null,
- "declarations": null
- },
- "VariableDeclarator": {
- "id": null,
- "init": null
- },
- "WithStatement": {
- "object": null,
- "body": null
- },
- "YieldExpression": {
- "argument": null,
- "delegate": null
- }
- }
- },{}],168:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- /**
- * Description
- */
- exports.toComputedKey = toComputedKey;
- /**
- * Turn an array of statement `nodes` into a `SequenceExpression`.
- *
- * Variable declarations are turned into simple assignments and their
- * declarations hoisted to the top of the current scope.
- *
- * Expression statements are just resolved to their expression.
- */
- exports.toSequenceExpression = toSequenceExpression;
- /**
- * Description
- */
- exports.toKeyAlias = toKeyAlias;
- /*
- * Description
- */
- exports.toIdentifier = toIdentifier;
- /**
- * Description
- *
- * @returns {Object|Boolean}
- */
- exports.toStatement = toStatement;
- /**
- * Description
- */
- exports.toExpression = toExpression;
- /**
- * Description
- */
- exports.toBlock = toBlock;
- /**
- * Description
- */
- exports.valueToNode = valueToNode;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _lodashLangIsPlainObject = require("lodash/lang/isPlainObject");
- var _lodashLangIsPlainObject2 = _interopRequireDefault(_lodashLangIsPlainObject);
- var _lodashLangIsNumber = require("lodash/lang/isNumber");
- var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
- var _lodashLangIsRegExp = require("lodash/lang/isRegExp");
- var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
- var _lodashLangIsString = require("lodash/lang/isString");
- var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
- var _traversal = require("../traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _index = require("./index");
- var t = _interopRequireWildcard(_index);
- function toComputedKey(node) {
- var key = arguments[1] === undefined ? node.key || node.property : arguments[1];
- return (function () {
- if (!node.computed) {
- if (t.isIdentifier(key)) key = t.literal(key.name);
- }
- return key;
- })();
- }
- function toSequenceExpression(nodes, scope) {
- var declars = [];
- var bailed = false;
- var result = convert(nodes);
- if (bailed) return;
- for (var i = 0; i < declars.length; i++) {
- scope.push(declars[i]);
- }
- return result;
- function convert(nodes) {
- var ensureLastUndefined = false;
- var exprs = [];
- var _arr = nodes;
- for (var _i = 0; _i < _arr.length; _i++) {
- var node = _arr[_i];
- if (t.isExpression(node)) {
- exprs.push(node);
- } else if (t.isExpressionStatement(node)) {
- exprs.push(node.expression);
- } else if (t.isVariableDeclaration(node)) {
- if (node.kind !== "var") return bailed = true; // bailed
- var _arr2 = node.declarations;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var declar = _arr2[_i2];
- var bindings = t.getBindingIdentifiers(declar);
- for (var key in bindings) {
- declars.push({
- kind: node.kind,
- id: bindings[key]
- });
- }
- if (declar.init) {
- exprs.push(t.assignmentExpression("=", declar.id, declar.init));
- }
- }
- ensureLastUndefined = true;
- continue;
- } else if (t.isIfStatement(node)) {
- var consequent = node.consequent ? convert([node.consequent]) : t.identifier("undefined");
- var alternate = node.alternate ? convert([node.alternate]) : t.identifier("undefined");
- if (!consequent || !alternate) return bailed = true;
- exprs.push(t.conditionalExpression(node.test, consequent, alternate));
- } else if (t.isBlockStatement(node)) {
- exprs.push(convert(node.body));
- } else {
- // bailed, we can't understand this
- return bailed = true;
- }
- ensureLastUndefined = false;
- }
- if (ensureLastUndefined) {
- exprs.push(t.identifier("undefined"));
- }
- //
- if (exprs.length === 1) {
- return exprs[0];
- } else {
- return t.sequenceExpression(exprs);
- }
- }
- }
- function toKeyAlias(node) {
- var key = arguments[1] === undefined ? node.key : arguments[1];
- return (function () {
- var alias;
- if (t.isIdentifier(key)) {
- alias = key.name;
- } else if (t.isLiteral(key)) {
- alias = JSON.stringify(key.value);
- } else {
- alias = JSON.stringify(_traversal2["default"].removeProperties(t.cloneDeep(key)));
- }
- if (node.computed) alias = "[" + alias + "]";
- return alias;
- })();
- }
- function toIdentifier(name) {
- if (t.isIdentifier(name)) return name.name;
- name = name + "";
- // replace all non-valid identifiers with dashes
- name = name.replace(/[^a-zA-Z0-9$_]/g, "-");
- // remove all dashes and numbers from start of name
- name = name.replace(/^[-0-9]+/, "");
- // camel case
- name = name.replace(/[-\s]+(.)?/g, function (match, c) {
- return c ? c.toUpperCase() : "";
- });
- if (!t.isValidIdentifier(name)) {
- name = "_" + name;
- }
- return name || "_";
- }
- function toStatement(node, ignore) {
- if (t.isStatement(node)) {
- return node;
- }
- var mustHaveId = false;
- var newType;
- if (t.isClass(node)) {
- mustHaveId = true;
- newType = "ClassDeclaration";
- } else if (t.isFunction(node)) {
- mustHaveId = true;
- newType = "FunctionDeclaration";
- } else if (t.isAssignmentExpression(node)) {
- return t.expressionStatement(node);
- }
- if (mustHaveId && !node.id) {
- newType = false;
- }
- if (!newType) {
- if (ignore) {
- return false;
- } else {
- throw new Error("cannot turn " + node.type + " to a statement");
- }
- }
- node.type = newType;
- return node;
- }
- function toExpression(node) {
- if (t.isExpressionStatement(node)) {
- node = node.expression;
- }
- if (t.isClass(node)) {
- node.type = "ClassExpression";
- } else if (t.isFunction(node)) {
- node.type = "FunctionExpression";
- }
- if (t.isExpression(node)) {
- return node;
- } else {
- throw new Error("cannot turn " + node.type + " to an expression");
- }
- }
- function toBlock(node, parent) {
- if (t.isBlockStatement(node)) {
- return node;
- }
- if (t.isEmptyStatement(node)) {
- node = [];
- }
- if (!Array.isArray(node)) {
- if (!t.isStatement(node)) {
- if (t.isFunction(parent)) {
- node = t.returnStatement(node);
- } else {
- node = t.expressionStatement(node);
- }
- }
- node = [node];
- }
- return t.blockStatement(node);
- }
- function valueToNode(value) {
- if (value === undefined) {
- return t.identifier("undefined");
- }
- if (value === true || value === false || value === null || (0, _lodashLangIsString2["default"])(value) || (0, _lodashLangIsNumber2["default"])(value) || (0, _lodashLangIsRegExp2["default"])(value)) {
- return t.literal(value);
- }
- if (Array.isArray(value)) {
- return t.arrayExpression(value.map(t.valueToNode));
- }
- if ((0, _lodashLangIsPlainObject2["default"])(value)) {
- var props = [];
- for (var key in value) {
- var nodeKey;
- if (t.isValidIdentifier(key)) {
- nodeKey = t.identifier(key);
- } else {
- nodeKey = t.literal(key);
- }
- props.push(t.property("init", nodeKey, t.valueToNode(value[key])));
- }
- return t.objectExpression(props);
- }
- throw new Error("don't know how to turn this value into a node");
- }
- },{"../traversal":157,"./index":169,"lodash/collection/each":330,"lodash/lang/isNumber":410,"lodash/lang/isPlainObject":412,"lodash/lang/isRegExp":413,"lodash/lang/isString":414}],169:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- /**
- * Returns whether `node` is of given `type`.
- *
- * For better performance, use this instead of `is[Type]` when `type` is unknown.
- * Optionally, pass `skipAliasCheck` to directly compare `node.type` with `type`.
- */
- exports.is = is;
- exports.isType = isType;
- /*
- * Description
- */
- exports.shallowEqual = shallowEqual;
- /**
- * Description
- */
- exports.appendToMemberExpression = appendToMemberExpression;
- /**
- * Description
- */
- exports.prependToMemberExpression = prependToMemberExpression;
- /**
- * Description
- */
- exports.ensureBlock = ensureBlock;
- /**
- * Description
- */
- exports.clone = clone;
- /**
- * Description
- */
- exports.cloneDeep = cloneDeep;
- /**
- * Build a function that when called will return whether or not the
- * input `node` `MemberExpression` matches the input `match`.
- *
- * For example, given the match `React.createClass` it would match the
- * parsed nodes of `React.createClass` and `React["createClass"]`.
- */
- exports.buildMatchMemberExpression = buildMatchMemberExpression;
- /**
- * Description
- */
- exports.removeComments = removeComments;
- /**
- * Description
- */
- exports.inheritsComments = inheritsComments;
- /**
- * Description
- */
- exports.inherits = inherits;
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _toFastProperties = require("to-fast-properties");
- var _toFastProperties2 = _interopRequireDefault(_toFastProperties);
- var _lodashArrayCompact = require("lodash/array/compact");
- var _lodashArrayCompact2 = _interopRequireDefault(_lodashArrayCompact);
- var _lodashObjectAssign = require("lodash/object/assign");
- var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
- var _lodashCollectionEach = require("lodash/collection/each");
- var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
- var _lodashArrayUniq = require("lodash/array/uniq");
- var _lodashArrayUniq2 = _interopRequireDefault(_lodashArrayUniq);
- var t = exports;
- /**
- * Registers `is[Type]` and `assert[Type]` generated functions for a given `type`.
- * Pass `skipAliasCheck` to force it to directly compare `node.type` with `type`.
- */
- function registerType(type, skipAliasCheck) {
- var is = t["is" + type] = function (node, opts) {
- return t.is(type, node, opts, skipAliasCheck);
- };
- t["assert" + type] = function (node, opts) {
- opts = opts || {};
- if (!is(node, opts)) {
- throw new Error("Expected type " + JSON.stringify(type) + " with option " + JSON.stringify(opts));
- }
- };
- }
- var STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
- exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS;
- var NATIVE_TYPE_NAMES = ["Array", "ArrayBuffer", "Boolean", "DataView", "Date", "Error", "EvalError", "Float32Array", "Float64Array", "Function", "Int8Array", "Int16Array", "Int32Array", "Map", "Number", "Object", "Proxy", "Promise", "RangeError", "ReferenceError", "RegExp", "Set", "String", "Symbol", "SyntaxError", "TypeError", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "URIError", "WeakMap", "WeakSet"];
- exports.NATIVE_TYPE_NAMES = NATIVE_TYPE_NAMES;
- var FLATTENABLE_KEYS = ["body", "expressions"];
- exports.FLATTENABLE_KEYS = FLATTENABLE_KEYS;
- var FOR_INIT_KEYS = ["left", "init"];
- exports.FOR_INIT_KEYS = FOR_INIT_KEYS;
- var COMMENT_KEYS = ["leadingComments", "trailingComments"];
- exports.COMMENT_KEYS = COMMENT_KEYS;
- var VISITOR_KEYS = require("./visitor-keys");
- exports.VISITOR_KEYS = VISITOR_KEYS;
- var BUILDER_KEYS = require("./builder-keys");
- exports.BUILDER_KEYS = BUILDER_KEYS;
- var ALIAS_KEYS = require("./alias-keys");
- exports.ALIAS_KEYS = ALIAS_KEYS;
- t.FLIPPED_ALIAS_KEYS = {};
- (0, _lodashCollectionEach2["default"])(t.VISITOR_KEYS, function (keys, type) {
- registerType(type, true);
- });
- (0, _lodashCollectionEach2["default"])(t.ALIAS_KEYS, function (aliases, type) {
- (0, _lodashCollectionEach2["default"])(aliases, function (alias) {
- var types = t.FLIPPED_ALIAS_KEYS[alias] = t.FLIPPED_ALIAS_KEYS[alias] || [];
- types.push(type);
- });
- });
- (0, _lodashCollectionEach2["default"])(t.FLIPPED_ALIAS_KEYS, function (types, type) {
- t[type.toUpperCase() + "_TYPES"] = types;
- registerType(type, false);
- });
- var TYPES = Object.keys(t.VISITOR_KEYS).concat(Object.keys(t.FLIPPED_ALIAS_KEYS));exports.TYPES = TYPES;
- function is(type, node, opts, skipAliasCheck) {
- if (!node) return false;
- var matches = isType(node.type, type);
- if (!matches) return false;
- if (typeof opts === "undefined") {
- return true;
- } else {
- return t.shallowEqual(node, opts);
- }
- }
- function isType(nodeType, targetType) {
- if (nodeType === targetType) return true;
- var aliases = t.FLIPPED_ALIAS_KEYS[targetType];
- if (aliases) {
- if (aliases[0] === nodeType) return true;
- var _arr = aliases;
- for (var _i = 0; _i < _arr.length; _i++) {
- var alias = _arr[_i];
- if (nodeType === alias) return true;
- }
- }
- return false;
- }
- (0, _lodashCollectionEach2["default"])(t.VISITOR_KEYS, function (keys, type) {
- if (t.BUILDER_KEYS[type]) return;
- var defs = {};
- (0, _lodashCollectionEach2["default"])(keys, function (key) {
- defs[key] = null;
- });
- t.BUILDER_KEYS[type] = defs;
- });
- (0, _lodashCollectionEach2["default"])(t.BUILDER_KEYS, function (keys, type) {
- t[type[0].toLowerCase() + type.slice(1)] = function () {
- var node = {};
- node.start = null;
- node.type = type;
- var i = 0;
- for (var key in keys) {
- var arg = arguments[i++];
- if (arg === undefined) arg = keys[key];
- node[key] = arg;
- }
- return node;
- };
- });
- function shallowEqual(actual, expected) {
- var keys = Object.keys(expected);
- var _arr2 = keys;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var key = _arr2[_i2];
- if (actual[key] !== expected[key]) {
- return false;
- }
- }
- return true;
- }
- function appendToMemberExpression(member, append, computed) {
- member.object = t.memberExpression(member.object, member.property, member.computed);
- member.property = append;
- member.computed = !!computed;
- return member;
- }
- function prependToMemberExpression(member, append) {
- member.object = t.memberExpression(append, member.object);
- return member;
- }
- function ensureBlock(node) {
- var key = arguments[1] === undefined ? "body" : arguments[1];
- return node[key] = t.toBlock(node[key], node);
- }
- function clone(node) {
- var newNode = {};
- for (var key in node) {
- if (key[0] === "_") continue;
- newNode[key] = node[key];
- }
- return newNode;
- }
- function cloneDeep(node) {
- var newNode = {};
- for (var key in node) {
- if (key[0] === "_") continue;
- var val = node[key];
- if (val) {
- if (val.type) {
- val = t.cloneDeep(val);
- } else if (Array.isArray(val)) {
- val = val.map(t.cloneDeep);
- }
- }
- newNode[key] = val;
- }
- return newNode;
- }
- function buildMatchMemberExpression(match, allowPartial) {
- var parts = match.split(".");
- return function (member) {
- // not a member expression
- if (!t.isMemberExpression(member)) return false;
- var search = [member];
- var i = 0;
- while (search.length) {
- var node = search.shift();
- if (allowPartial && i === parts.length) {
- return true;
- }
- if (t.isIdentifier(node)) {
- // this part doesn't match
- if (parts[i] !== node.name) return false;
- } else if (t.isLiteral(node)) {
- // this part doesn't match
- if (parts[i] !== node.value) return false;
- } else if (t.isMemberExpression(node)) {
- if (node.computed && !t.isLiteral(node.property)) {
- // we can't deal with this
- return false;
- } else {
- search.push(node.object);
- search.push(node.property);
- continue;
- }
- } else {
- // we can't deal with this
- return false;
- }
- // too many parts
- if (++i > parts.length) {
- return false;
- }
- }
- return true;
- };
- }
- function removeComments(child) {
- var _arr3 = COMMENT_KEYS;
- for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
- var key = _arr3[_i3];
- delete child[key];
- }
- return child;
- }
- function inheritsComments(child, parent) {
- if (child && parent) {
- var _arr4 = COMMENT_KEYS;
- for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
- var key = _arr4[_i4];
- child[key] = (0, _lodashArrayUniq2["default"])((0, _lodashArrayCompact2["default"])([].concat(child[key], parent[key])));
- }
- }
- return child;
- }
- function inherits(child, parent) {
- if (!child || !parent) return child;
- child._scopeInfo = parent._scopeInfo;
- child.range = parent.range;
- child.start = parent.start;
- child.loc = parent.loc;
- child.end = parent.end;
- child.typeAnnotation = parent.typeAnnotation;
- child.returnType = parent.returnType;
- t.inheritsComments(child, parent);
- return child;
- }
- (0, _toFastProperties2["default"])(t);
- (0, _toFastProperties2["default"])(t.VISITOR_KEYS);
- exports.__esModule = true;
- (0, _lodashObjectAssign2["default"])(t, require("./retrievers"));
- (0, _lodashObjectAssign2["default"])(t, require("./validators"));
- (0, _lodashObjectAssign2["default"])(t, require("./converters"));
- },{"./alias-keys":166,"./builder-keys":167,"./converters":168,"./retrievers":170,"./validators":171,"./visitor-keys":172,"lodash/array/compact":324,"lodash/array/uniq":328,"lodash/collection/each":330,"lodash/object/assign":417,"to-fast-properties":495}],170:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- /**
- * Return a list of binding identifiers associated with
- * the input `node`.
- */
- exports.getBindingIdentifiers = getBindingIdentifiers;
- /**
- * Description
- */
- exports.getLastStatements = getLastStatements;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _helpersObject = require("../helpers/object");
- var _helpersObject2 = _interopRequireDefault(_helpersObject);
- var _index = require("./index");
- var t = _interopRequireWildcard(_index);
- function getBindingIdentifiers(node) {
- var search = [].concat(node);
- var ids = (0, _helpersObject2["default"])();
- while (search.length) {
- var id = search.shift();
- if (!id) continue;
- var keys = t.getBindingIdentifiers.keys[id.type];
- if (t.isIdentifier(id)) {
- ids[id.name] = id;
- } else if (t.isExportDeclaration(id)) {
- if (t.isDeclaration(node.declaration)) {
- search.push(node.declaration);
- }
- } else if (keys) {
- var _arr = keys;
- for (var _i = 0; _i < _arr.length; _i++) {
- var key = _arr[_i];
- search = search.concat(id[key] || []);
- }
- }
- }
- return ids;
- }
- getBindingIdentifiers.keys = {
- UnaryExpression: ["argument"],
- AssignmentExpression: ["left"],
- ImportSpecifier: ["local"],
- ImportNamespaceSpecifier: ["local"],
- ImportDefaultSpecifier: ["local"],
- VariableDeclarator: ["id"],
- FunctionDeclaration: ["id"],
- FunctionExpression: ["id"],
- ClassDeclaration: ["id"],
- ClassExpression: ["id"],
- SpreadElement: ["argument"],
- RestElement: ["argument"],
- UpdateExpression: ["argument"],
- SpreadProperty: ["argument"],
- Property: ["value"],
- ComprehensionBlock: ["left"],
- AssignmentPattern: ["left"],
- ComprehensionExpression: ["blocks"],
- ImportDeclaration: ["specifiers"],
- VariableDeclaration: ["declarations"],
- ArrayPattern: ["elements"],
- ObjectPattern: ["properties"]
- };
- function getLastStatements(node) {
- var nodes = [];
- var add = function add(node) {
- nodes = nodes.concat(getLastStatements(node));
- };
- if (t.isIfStatement(node)) {
- add(node.consequent);
- add(node.alternate);
- } else if (t.isFor(node) || t.isWhile(node)) {
- add(node.body);
- } else if (t.isProgram(node) || t.isBlockStatement(node)) {
- add(node.body[node.body.length - 1]);
- } else if (t.isLoop()) {} else if (node) {
- nodes.push(node);
- }
- return nodes;
- }
- },{"../helpers/object":45,"./index":169}],171:[function(require,module,exports){
- "use strict";
- exports.__esModule = true;
- /**
- * Check if the input `node` is a reference to a bound variable.
- */
- exports.isReferenced = isReferenced;
- /**
- * Check if the input `node` is an `Identifier` and `isReferenced`.
- */
- exports.isReferencedIdentifier = isReferencedIdentifier;
- /**
- * Check if the input `name` is a valid identifier name
- * and isn't a reserved word.
- */
- exports.isValidIdentifier = isValidIdentifier;
- /**
- * Description
- */
- exports.isLet = isLet;
- /**
- * Description
- */
- exports.isBlockScoped = isBlockScoped;
- /**
- * Description
- */
- exports.isVar = isVar;
- /**
- * Description
- */
- exports.isSpecifierDefault = isSpecifierDefault;
- /**
- * Description
- */
- exports.isScope = isScope;
- /**
- * Description
- */
- exports.isImmutable = isImmutable;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- var _esutils = require("esutils");
- var _esutils2 = _interopRequireDefault(_esutils);
- var _index = require("./index");
- var t = _interopRequireWildcard(_index);
- function isReferenced(node, parent) {
- switch (parent.type) {
- // yes: PARENT[NODE]
- // yes: NODE.child
- // no: parent.CHILD
- case "MemberExpression":
- if (parent.property === node && parent.computed) {
- return true;
- } else if (parent.object === node) {
- return true;
- } else {
- return false;
- }
- // no: new.NODE
- // no: NODE.target
- case "MetaProperty":
- return false;
- // yes: { [NODE]: "" }
- // yes: { NODE }
- // no: { NODE: "" }
- case "Property":
- if (parent.key === node) {
- return parent.computed;
- }
- // no: var NODE = init;
- // yes: var id = NODE;
- case "VariableDeclarator":
- return parent.id !== node;
- // no: function NODE() {}
- // no: function foo(NODE) {}
- case "ArrowFunctionExpression":
- case "FunctionDeclaration":
- case "FunctionExpression":
- var _arr = parent.params;
- for (var _i = 0; _i < _arr.length; _i++) {
- var param = _arr[_i];
- if (param === node) return false;
- }
- return parent.id !== node;
- // no: export { foo as NODE };
- // yes: export { NODE as foo };
- // no: export { NODE as foo } from "foo";
- case "ExportSpecifier":
- if (parent.source) {
- return false;
- } else {
- return parent.local === node;
- }
- // no: import NODE from "foo";
- case "ImportDefaultSpecifier":
- return false;
- // no: import * as NODE from "foo";
- case "ImportNamespaceSpecifier":
- return false;
- // no: import { NODE as foo } from "foo";
- // no: import { foo as NODE } from "foo";
- case "ImportSpecifier":
- return false;
- // no: class NODE {}
- case "ClassDeclaration":
- case "ClassExpression":
- return parent.id !== node;
- // yes: class { [NODE](){} }
- case "MethodDefinition":
- return parent.key === node && parent.computed;
- // no: NODE: for (;;) {}
- case "LabeledStatement":
- return false;
- // no: try {} catch (NODE) {}
- case "CatchClause":
- return parent.param !== node;
- // no: function foo(...NODE) {}
- case "RestElement":
- return false;
- // no: [NODE = foo] = [];
- // yes: [foo = NODE] = [];
- case "AssignmentPattern":
- return parent.right === node;
- // no: [NODE] = [];
- // no: ({ NODE }) = [];
- case "ObjectPattern":
- case "ArrayPattern":
- return false;
- // no: import NODE from "bar";
- case "ImportSpecifier":
- return false;
- // no: import * as NODE from "foo";
- case "ImportNamespaceSpecifier":
- return false;
- }
- return true;
- }
- function isReferencedIdentifier(node, parent, opts) {
- return (t.isIdentifier(node, opts) || t.isJSXIdentifier(node, opts)) && t.isReferenced(node, parent);
- }
- function isValidIdentifier(name) {
- if (typeof name !== "string" || _esutils2["default"].keyword.isReservedWordES6(name, true)) {
- return false;
- } else {
- return _esutils2["default"].keyword.isIdentifierNameES6(name);
- }
- }
- function isLet(node) {
- return t.isVariableDeclaration(node) && (node.kind !== "var" || node._let);
- }
- function isBlockScoped(node) {
- return t.isFunctionDeclaration(node) || t.isClassDeclaration(node) || t.isLet(node);
- }
- function isVar(node) {
- return t.isVariableDeclaration(node, { kind: "var" }) && !node._let;
- }
- function isSpecifierDefault(specifier) {
- return t.isImportDefaultSpecifier(specifier) || t.isExportDefaultSpecifier(specifier) || t.isIdentifier(specifier.imported || specifier.exported, { name: "default" });
- }
- function isScope(node, parent) {
- if (t.isBlockStatement(node) && t.isFunction(parent, { body: node })) {
- return false;
- }
- return t.isScopable(node);
- }
- function isImmutable(node) {
- if (t.isType(node.type, "Immutable")) return true;
- if (t.isLiteral(node)) {
- if (node.regex) {
- // regexes are mutable
- return false;
- } else {
- // immutable!
- return true;
- }
- } else if (t.isIdentifier(node)) {
- if (node.name === "undefined") {
- // immutable!
- return true;
- } else {
- // no idea...
- return false;
- }
- }
- return false;
- }
- },{"./index":169,"esutils":314}],172:[function(require,module,exports){
- module.exports={
- "ArrayExpression": ["elements"],
- "ArrayPattern": ["elements", "typeAnnotation"],
- "ArrowFunctionExpression": ["params", "body", "returnType"],
- "AssignmentExpression": ["left", "right"],
- "AssignmentPattern": ["left", "right"],
- "AwaitExpression": ["argument"],
- "BinaryExpression": ["left", "right"],
- "BindExpression": ["object", "callee"],
- "BlockStatement": ["body"],
- "BreakStatement": ["label"],
- "CallExpression": ["callee", "arguments"],
- "CatchClause": ["param", "body"],
- "ClassBody": ["body"],
- "ClassDeclaration": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
- "ClassExpression": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
- "ComprehensionBlock": ["left", "right", "body"],
- "ComprehensionExpression": ["filter", "blocks", "body"],
- "ConditionalExpression": ["test", "consequent", "alternate"],
- "ContinueStatement": ["label"],
- "Decorator": ["expression"],
- "DebuggerStatement": [],
- "DoWhileStatement": ["body", "test"],
- "DoExpression": ["body"],
- "EmptyStatement": [],
- "ExpressionStatement": ["expression"],
- "File": ["program"],
- "ForInStatement": ["left", "right", "body"],
- "ForOfStatement": ["left", "right", "body"],
- "ForStatement": ["init", "test", "update", "body"],
- "FunctionDeclaration": ["id", "params", "body", "returnType", "typeParameters"],
- "FunctionExpression": ["id", "params", "body", "returnType", "typeParameters"],
- "Identifier": ["typeAnnotation"],
- "IfStatement": ["test", "consequent", "alternate"],
- "ImportDefaultSpecifier": ["local"],
- "ImportNamespaceSpecifier": ["local"],
- "ImportDeclaration": ["specifiers", "source"],
- "ImportSpecifier": ["imported", "local"],
- "LabeledStatement": ["label", "body"],
- "Literal": [],
- "LogicalExpression": ["left", "right"],
- "MemberExpression": ["object", "property"],
- "MetaProperty": ["meta", "property"],
- "MethodDefinition": ["key", "value", "decorators"],
- "NewExpression": ["callee", "arguments"],
- "ObjectExpression": ["properties"],
- "ObjectPattern": ["properties", "typeAnnotation"],
- "Program": ["body"],
- "Property": ["key", "value", "decorators"],
- "RestElement": ["argument", "typeAnnotation"],
- "ReturnStatement": ["argument"],
- "SequenceExpression": ["expressions"],
- "SpreadElement": ["argument"],
- "SpreadProperty": ["argument"],
- "Super": [],
- "SwitchCase": ["test", "consequent"],
- "SwitchStatement": ["discriminant", "cases"],
- "TaggedTemplateExpression": ["tag", "quasi"],
- "TemplateElement": [],
- "TemplateLiteral": ["quasis", "expressions"],
- "ThisExpression": [],
- "ThrowStatement": ["argument"],
- "TryStatement": ["block", "handlers", "handler", "guardedHandlers", "finalizer"],
- "UnaryExpression": ["argument"],
- "UpdateExpression": ["argument"],
- "VariableDeclaration": ["declarations"],
- "VariableDeclarator": ["id", "init"],
- "WhileStatement": ["test", "body"],
- "WithStatement": ["object", "body"],
- "YieldExpression": ["argument"],
- "ExportAllDeclaration": ["source", "exported"],
- "ExportDefaultDeclaration": ["declaration"],
- "ExportNamedDeclaration": ["declaration", "specifiers", "source"],
- "ExportDefaultSpecifier": ["exported"],
- "ExportNamespaceSpecifier": ["exported"],
- "ExportSpecifier": ["local", "exported"],
- "AnyTypeAnnotation": [],
- "ArrayTypeAnnotation": ["elementType"],
- "BooleanTypeAnnotation": [],
- "ClassImplements": ["id", "typeParameters"],
- "ClassProperty": ["key", "value", "typeAnnotation", "decorators"],
- "DeclareClass": ["id", "typeParameters", "extends", "body"],
- "DeclareFunction": ["id"],
- "DeclareModule": ["id", "body"],
- "DeclareVariable": ["id"],
- "FunctionTypeAnnotation": ["typeParameters", "params", "rest", "returnType"],
- "FunctionTypeParam": ["name", "typeAnnotation"],
- "GenericTypeAnnotation": ["id", "typeParameters"],
- "InterfaceExtends": ["id", "typeParameters"],
- "InterfaceDeclaration": ["id", "typeParameters", "extends", "body"],
- "IntersectionTypeAnnotation": ["types"],
- "NullableTypeAnnotation": ["typeAnnotation"],
- "NumberTypeAnnotation": [],
- "StringLiteralTypeAnnotation": [],
- "StringTypeAnnotation": [],
- "TupleTypeAnnotation": ["types"],
- "TypeofTypeAnnotation": ["argument"],
- "TypeAlias": ["id", "typeParameters", "right"],
- "TypeAnnotation": ["typeAnnotation"],
- "TypeCastExpression": ["expression", "typeAnnotation"],
- "TypeParameterDeclaration": ["params"],
- "TypeParameterInstantiation": ["params"],
- "ObjectTypeAnnotation": ["properties", "indexers", "callProperties"],
- "ObjectTypeCallProperty": ["value"],
- "ObjectTypeIndexer": ["id", "key", "value"],
- "ObjectTypeProperty": ["key", "value"],
- "QualifiedTypeIdentifier": ["id", "qualification"],
- "UnionTypeAnnotation": ["types"],
- "VoidTypeAnnotation": [],
- "JSXAttribute": ["name", "value"],
- "JSXClosingElement": ["name"],
- "JSXElement": ["openingElement", "closingElement", "children"],
- "JSXEmptyExpression": [],
- "JSXExpressionContainer": ["expression"],
- "JSXIdentifier": [],
- "JSXMemberExpression": ["object", "property"],
- "JSXNamespacedName": ["namespace", "name"],
- "JSXOpeningElement": ["name", "attributes"],
- "JSXSpreadAttribute": ["argument"]
- }
- },{}],173:[function(require,module,exports){
- (function (process,__dirname){
- "use strict";
- exports.__esModule = true;
- exports.canCompile = canCompile;
- exports.resolve = resolve;
- exports.resolveRelative = resolveRelative;
- exports.list = list;
- exports.regexify = regexify;
- exports.arrayify = arrayify;
- exports.booleanify = booleanify;
- exports.shouldIgnore = shouldIgnore;
- //
- exports.template = template;
- exports.parseTemplate = parseTemplate;
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
- require("./patch");
- var _lodashStringEscapeRegExp = require("lodash/string/escapeRegExp");
- var _lodashStringEscapeRegExp2 = _interopRequireDefault(_lodashStringEscapeRegExp);
- var _lodashStringStartsWith = require("lodash/string/startsWith");
- var _lodashStringStartsWith2 = _interopRequireDefault(_lodashStringStartsWith);
- var _lodashLangCloneDeep = require("lodash/lang/cloneDeep");
- var _lodashLangCloneDeep2 = _interopRequireDefault(_lodashLangCloneDeep);
- var _lodashLangIsBoolean = require("lodash/lang/isBoolean");
- var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
- var _messages = require("./messages");
- var messages = _interopRequireWildcard(_messages);
- var _minimatch = require("minimatch");
- var _minimatch2 = _interopRequireDefault(_minimatch);
- var _lodashCollectionContains = require("lodash/collection/contains");
- var _lodashCollectionContains2 = _interopRequireDefault(_lodashCollectionContains);
- var _traversal = require("./traversal");
- var _traversal2 = _interopRequireDefault(_traversal);
- var _lodashLangIsString = require("lodash/lang/isString");
- var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
- var _lodashLangIsRegExp = require("lodash/lang/isRegExp");
- var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
- var _module2 = require("module");
- var _module3 = _interopRequireDefault(_module2);
- var _lodashLangIsEmpty = require("lodash/lang/isEmpty");
- var _lodashLangIsEmpty2 = _interopRequireDefault(_lodashLangIsEmpty);
- var _helpersParse = require("./helpers/parse");
- var _helpersParse2 = _interopRequireDefault(_helpersParse);
- var _path = require("path");
- var _path2 = _interopRequireDefault(_path);
- var _lodashObjectHas = require("lodash/object/has");
- var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
- var _fs = require("fs");
- var _fs2 = _interopRequireDefault(_fs);
- var _types = require("./types");
- var t = _interopRequireWildcard(_types);
- var _slash = require("slash");
- var _slash2 = _interopRequireDefault(_slash);
- var _util = require("util");
- exports.inherits = _util.inherits;
- exports.inspect = _util.inspect;
- function canCompile(filename, altExts) {
- var exts = altExts || canCompile.EXTENSIONS;
- var ext = _path2["default"].extname(filename);
- return (0, _lodashCollectionContains2["default"])(exts, ext);
- }
- canCompile.EXTENSIONS = [".js", ".jsx", ".es6", ".es"];
- function resolve(loc) {
- try {
- return require.resolve(loc);
- } catch (err) {
- return null;
- }
- }
- var relativeMod;
- function resolveRelative(loc) {
- // we're in the browser, probably
- if (typeof _module3["default"] === "object") return null;
- if (!relativeMod) {
- relativeMod = new _module3["default"]();
- relativeMod.paths = _module3["default"]._nodeModulePaths(process.cwd());
- }
- try {
- return _module3["default"]._resolveFilename(loc, relativeMod);
- } catch (err) {
- return null;
- }
- }
- function list(val) {
- if (!val) {
- return [];
- } else if (Array.isArray(val)) {
- return val;
- } else if (typeof val === "string") {
- return val.split(",");
- } else {
- return [val];
- }
- }
- function regexify(val) {
- if (!val) return new RegExp(/.^/);
- if (Array.isArray(val)) val = new RegExp(val.map(_lodashStringEscapeRegExp2["default"]).join("|"), "i");
- if ((0, _lodashLangIsString2["default"])(val)) {
- // normalise path separators
- val = (0, _slash2["default"])(val);
- // remove starting wildcards or relative separator if present
- if ((0, _lodashStringStartsWith2["default"])(val, "./") || (0, _lodashStringStartsWith2["default"])(val, "*/")) val = val.slice(2);
- if ((0, _lodashStringStartsWith2["default"])(val, "**/")) val = val.slice(3);
- var regex = _minimatch2["default"].makeRe(val, { nocase: true });
- return new RegExp(regex.source.slice(1, -1), "i");
- }
- if ((0, _lodashLangIsRegExp2["default"])(val)) return val;
- throw new TypeError("illegal type for regexify");
- }
- function arrayify(val, mapFn) {
- if (!val) return [];
- if ((0, _lodashLangIsBoolean2["default"])(val)) return arrayify([val], mapFn);
- if ((0, _lodashLangIsString2["default"])(val)) return arrayify(list(val), mapFn);
- if (Array.isArray(val)) {
- if (mapFn) val = val.map(mapFn);
- return val;
- }
- return [val];
- }
- function booleanify(val) {
- if (val === "true") return true;
- if (val === "false") return false;
- return val;
- }
- function shouldIgnore(filename, ignore, only) {
- filename = (0, _slash2["default"])(filename);
- if (only.length) {
- var _arr = only;
- for (var _i = 0; _i < _arr.length; _i++) {
- var pattern = _arr[_i];
- if (pattern.test(filename)) return false;
- }
- return true;
- } else if (ignore.length) {
- var _arr2 = ignore;
- for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
- var pattern = _arr2[_i2];
- if (pattern.test(filename)) return true;
- }
- }
- return false;
- }
- var templateVisitor = {
- enter: function enter(node, parent, scope, nodes) {
- if (t.isExpressionStatement(node)) {
- node = node.expression;
- }
- if (t.isIdentifier(node) && (0, _lodashObjectHas2["default"])(nodes, node.name)) {
- this.skip();
- this.replaceInline(nodes[node.name]);
- }
- }
- };
- function template(name, nodes, keepExpression) {
- var ast = exports.templates[name];
- if (!ast) throw new ReferenceError("unknown template " + name);
- if (nodes === true) {
- keepExpression = true;
- nodes = null;
- }
- ast = (0, _lodashLangCloneDeep2["default"])(ast);
- if (!(0, _lodashLangIsEmpty2["default"])(nodes)) {
- (0, _traversal2["default"])(ast, templateVisitor, null, nodes);
- }
- if (ast.body.length > 1) return ast.body;
- var node = ast.body[0];
- if (!keepExpression && t.isExpressionStatement(node)) {
- return node.expression;
- } else {
- return node;
- }
- }
- function parseTemplate(loc, code) {
- var ast = (0, _helpersParse2["default"])(code, { filename: loc, looseModules: true }).program;
- ast = _traversal2["default"].removeProperties(ast);
- return ast;
- }
- function loadTemplates() {
- var templates = {};
- var templatesLoc = _path2["default"].join(__dirname, "transformation/templates");
- if (!_fs2["default"].existsSync(templatesLoc)) {
- throw new ReferenceError(messages.get("missingTemplatesDirectory"));
- }
- var _arr3 = _fs2["default"].readdirSync(templatesLoc);
- for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
- var name = _arr3[_i3];
- if (name[0] === ".") return;
- var key = _path2["default"].basename(name, _path2["default"].extname(name));
- var loc = _path2["default"].join(templatesLoc, name);
- var code = _fs2["default"].readFileSync(loc, "utf8");
- templates[key] = parseTemplate(loc, code);
- }
- return templates;
- }
- try {
- exports.templates = require("../../templates.json");
- } catch (err) {
- if (err.code !== "MODULE_NOT_FOUND") throw err;
- exports.templates = loadTemplates();
- }
- }).call(this,require('_process'),"/lib/babel")
- },{"../../templates.json":498,"./helpers/parse":46,"./messages":47,"./patch":48,"./traversal":157,"./types":169,"_process":200,"fs":189,"lodash/collection/contains":329,"lodash/lang/cloneDeep":403,"lodash/lang/isBoolean":406,"lodash/lang/isEmpty":407,"lodash/lang/isRegExp":413,"lodash/lang/isString":414,"lodash/object/has":420,"lodash/string/escapeRegExp":425,"lodash/string/startsWith":426,"minimatch":430,"module":189,"path":199,"slash":482,"util":216}],174:[function(require,module,exports){
- 'use strict';
- module.exports = function(acorn) {
- var tt = acorn.tokTypes;
- var tc = acorn.tokContexts;
- tc.j_oTag = new acorn.TokContext('<tag', false);
- tc.j_cTag = new acorn.TokContext('</tag', false);
- tc.j_expr = new acorn.TokContext('<tag>...</tag>', true, true);
- tt.jsxName = new acorn.TokenType('jsxName');
- tt.jsxText = new acorn.TokenType('jsxText', {beforeExpr: true});
- tt.jsxTagStart = new acorn.TokenType('jsxTagStart');
- tt.jsxTagEnd = new acorn.TokenType('jsxTagEnd');
- tt.jsxTagStart.updateContext = function() {
- this.context.push(tc.j_expr); // treat as beginning of JSX expression
- this.context.push(tc.j_oTag); // start opening tag context
- this.exprAllowed = false;
- };
- tt.jsxTagEnd.updateContext = function(prevType) {
- var out = this.context.pop();
- if (out === tc.j_oTag && prevType === tt.slash || out === tc.j_cTag) {
- this.context.pop();
- this.exprAllowed = this.curContext() === tc.j_expr;
- } else {
- this.exprAllowed = true;
- }
- };
- var pp = acorn.Parser.prototype;
- // Reads inline JSX contents token.
- pp.jsx_readToken = function() {
- var out = '', chunkStart = this.pos;
- for (;;) {
- if (this.pos >= this.input.length)
- this.raise(this.start, 'Unterminated JSX contents');
- var ch = this.input.charCodeAt(this.pos);
- switch (ch) {
- case 60: // '<'
- case 123: // '{'
- if (this.pos === this.start) {
- if (ch === 60 && this.exprAllowed) {
- ++this.pos;
- return this.finishToken(tt.jsxTagStart);
- }
- return this.getTokenFromCode(ch);
- }
- out += this.input.slice(chunkStart, this.pos);
- return this.finishToken(tt.jsxText, out);
- case 38: // '&'
- out += this.input.slice(chunkStart, this.pos);
- out += this.jsx_readEntity();
- chunkStart = this.pos;
- break;
- default:
- if (acorn.isNewLine(ch)) {
- out += this.input.slice(chunkStart, this.pos);
- ++this.pos;
- if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
- ++this.pos;
- out += '\n';
- } else {
- out += String.fromCharCode(ch);
- }
- if (this.options.locations) {
- ++this.curLine;
- this.lineStart = this.pos;
- }
- chunkStart = this.pos;
- } else {
- ++this.pos;
- }
- }
- }
- };
- pp.jsx_readString = function(quote) {
- var out = '', chunkStart = ++this.pos;
- for (;;) {
- if (this.pos >= this.input.length)
- this.raise(this.start, 'Unterminated string constant');
- var ch = this.input.charCodeAt(this.pos);
- if (ch === quote) break;
- if (ch === 38) { // '&'
- out += this.input.slice(chunkStart, this.pos);
- out += this.jsx_readEntity();
- chunkStart = this.pos;
- } else {
- ++this.pos;
- }
- }
- out += this.input.slice(chunkStart, this.pos++);
- return this.finishToken(tt.string, out);
- };
- var XHTMLEntities = {
- quot: '\u0022',
- amp: '&',
- apos: '\u0027',
- lt: '<',
- gt: '>',
- nbsp: '\u00A0',
- iexcl: '\u00A1',
- cent: '\u00A2',
- pound: '\u00A3',
- curren: '\u00A4',
- yen: '\u00A5',
- brvbar: '\u00A6',
- sect: '\u00A7',
- uml: '\u00A8',
- copy: '\u00A9',
- ordf: '\u00AA',
- laquo: '\u00AB',
- not: '\u00AC',
- shy: '\u00AD',
- reg: '\u00AE',
- macr: '\u00AF',
- deg: '\u00B0',
- plusmn: '\u00B1',
- sup2: '\u00B2',
- sup3: '\u00B3',
- acute: '\u00B4',
- micro: '\u00B5',
- para: '\u00B6',
- middot: '\u00B7',
- cedil: '\u00B8',
- sup1: '\u00B9',
- ordm: '\u00BA',
- raquo: '\u00BB',
- frac14: '\u00BC',
- frac12: '\u00BD',
- frac34: '\u00BE',
- iquest: '\u00BF',
- Agrave: '\u00C0',
- Aacute: '\u00C1',
- Acirc: '\u00C2',
- Atilde: '\u00C3',
- Auml: '\u00C4',
- Aring: '\u00C5',
- AElig: '\u00C6',
- Ccedil: '\u00C7',
- Egrave: '\u00C8',
- Eacute: '\u00C9',
- Ecirc: '\u00CA',
- Euml: '\u00CB',
- Igrave: '\u00CC',
- Iacute: '\u00CD',
- Icirc: '\u00CE',
- Iuml: '\u00CF',
- ETH: '\u00D0',
- Ntilde: '\u00D1',
- Ograve: '\u00D2',
- Oacute: '\u00D3',
- Ocirc: '\u00D4',
- Otilde: '\u00D5',
- Ouml: '\u00D6',
- times: '\u00D7',
- Oslash: '\u00D8',
- Ugrave: '\u00D9',
- Uacute: '\u00DA',
- Ucirc: '\u00DB',
- Uuml: '\u00DC',
- Yacute: '\u00DD',
- THORN: '\u00DE',
- szlig: '\u00DF',
- agrave: '\u00E0',
- aacute: '\u00E1',
- acirc: '\u00E2',
- atilde: '\u00E3',
- auml: '\u00E4',
- aring: '\u00E5',
- aelig: '\u00E6',
- ccedil: '\u00E7',
- egrave: '\u00E8',
- eacute: '\u00E9',
- ecirc: '\u00EA',
- euml: '\u00EB',
- igrave: '\u00EC',
- iacute: '\u00ED',
- icirc: '\u00EE',
- iuml: '\u00EF',
- eth: '\u00F0',
- ntilde: '\u00F1',
- ograve: '\u00F2',
- oacute: '\u00F3',
- ocirc: '\u00F4',
- otilde: '\u00F5',
- ouml: '\u00F6',
- divide: '\u00F7',
- oslash: '\u00F8',
- ugrave: '\u00F9',
- uacute: '\u00FA',
- ucirc: '\u00FB',
- uuml: '\u00FC',
- yacute: '\u00FD',
- thorn: '\u00FE',
- yuml: '\u00FF',
- OElig: '\u0152',
- oelig: '\u0153',
- Scaron: '\u0160',
- scaron: '\u0161',
- Yuml: '\u0178',
- fnof: '\u0192',
- circ: '\u02C6',
- tilde: '\u02DC',
- Alpha: '\u0391',
- Beta: '\u0392',
- Gamma: '\u0393',
- Delta: '\u0394',
- Epsilon: '\u0395',
- Zeta: '\u0396',
- Eta: '\u0397',
- Theta: '\u0398',
- Iota: '\u0399',
- Kappa: '\u039A',
- Lambda: '\u039B',
- Mu: '\u039C',
- Nu: '\u039D',
- Xi: '\u039E',
- Omicron: '\u039F',
- Pi: '\u03A0',
- Rho: '\u03A1',
- Sigma: '\u03A3',
- Tau: '\u03A4',
- Upsilon: '\u03A5',
- Phi: '\u03A6',
- Chi: '\u03A7',
- Psi: '\u03A8',
- Omega: '\u03A9',
- alpha: '\u03B1',
- beta: '\u03B2',
- gamma: '\u03B3',
- delta: '\u03B4',
- epsilon: '\u03B5',
- zeta: '\u03B6',
- eta: '\u03B7',
- theta: '\u03B8',
- iota: '\u03B9',
- kappa: '\u03BA',
- lambda: '\u03BB',
- mu: '\u03BC',
- nu: '\u03BD',
- xi: '\u03BE',
- omicron: '\u03BF',
- pi: '\u03C0',
- rho: '\u03C1',
- sigmaf: '\u03C2',
- sigma: '\u03C3',
- tau: '\u03C4',
- upsilon: '\u03C5',
- phi: '\u03C6',
- chi: '\u03C7',
- psi: '\u03C8',
- omega: '\u03C9',
- thetasym: '\u03D1',
- upsih: '\u03D2',
- piv: '\u03D6',
- ensp: '\u2002',
- emsp: '\u2003',
- thinsp: '\u2009',
- zwnj: '\u200C',
- zwj: '\u200D',
- lrm: '\u200E',
- rlm: '\u200F',
- ndash: '\u2013',
- mdash: '\u2014',
- lsquo: '\u2018',
- rsquo: '\u2019',
- sbquo: '\u201A',
- ldquo: '\u201C',
- rdquo: '\u201D',
- bdquo: '\u201E',
- dagger: '\u2020',
- Dagger: '\u2021',
- bull: '\u2022',
- hellip: '\u2026',
- permil: '\u2030',
- prime: '\u2032',
- Prime: '\u2033',
- lsaquo: '\u2039',
- rsaquo: '\u203A',
- oline: '\u203E',
- frasl: '\u2044',
- euro: '\u20AC',
- image: '\u2111',
- weierp: '\u2118',
- real: '\u211C',
- trade: '\u2122',
- alefsym: '\u2135',
- larr: '\u2190',
- uarr: '\u2191',
- rarr: '\u2192',
- darr: '\u2193',
- harr: '\u2194',
- crarr: '\u21B5',
- lArr: '\u21D0',
- uArr: '\u21D1',
- rArr: '\u21D2',
- dArr: '\u21D3',
- hArr: '\u21D4',
- forall: '\u2200',
- part: '\u2202',
- exist: '\u2203',
- empty: '\u2205',
- nabla: '\u2207',
- isin: '\u2208',
- notin: '\u2209',
- ni: '\u220B',
- prod: '\u220F',
- sum: '\u2211',
- minus: '\u2212',
- lowast: '\u2217',
- radic: '\u221A',
- prop: '\u221D',
- infin: '\u221E',
- ang: '\u2220',
- and: '\u2227',
- or: '\u2228',
- cap: '\u2229',
- cup: '\u222A',
- 'int': '\u222B',
- there4: '\u2234',
- sim: '\u223C',
- cong: '\u2245',
- asymp: '\u2248',
- ne: '\u2260',
- equiv: '\u2261',
- le: '\u2264',
- ge: '\u2265',
- sub: '\u2282',
- sup: '\u2283',
- nsub: '\u2284',
- sube: '\u2286',
- supe: '\u2287',
- oplus: '\u2295',
- otimes: '\u2297',
- perp: '\u22A5',
- sdot: '\u22C5',
- lceil: '\u2308',
- rceil: '\u2309',
- lfloor: '\u230A',
- rfloor: '\u230B',
- lang: '\u2329',
- rang: '\u232A',
- loz: '\u25CA',
- spades: '\u2660',
- clubs: '\u2663',
- hearts: '\u2665',
- diams: '\u2666'
- };
- var hexNumber = /^[\da-fA-F]+$/;
- var decimalNumber = /^\d+$/;
- pp.jsx_readEntity = function() {
- var str = '', count = 0, entity;
- var ch = this.input[this.pos];
- if (ch !== '&')
- this.raise(this.pos, 'Entity must start with an ampersand');
- var startPos = ++this.pos;
- while (this.pos < this.input.length && count++ < 10) {
- ch = this.input[this.pos++];
- if (ch === ';') {
- if (str[0] === '#') {
- if (str[1] === 'x') {
- str = str.substr(2);
- if (hexNumber.test(str))
- entity = String.fromCharCode(parseInt(str, 16));
- } else {
- str = str.substr(1);
- if (decimalNumber.test(str))
- entity = String.fromCharCode(parseInt(str, 10));
- }
- } else {
- entity = XHTMLEntities[str];
- }
- break;
- }
- str += ch;
- }
- if (!entity) {
- this.pos = startPos;
- return '&';
- }
- return entity;
- };
- // Read a JSX identifier (valid tag or attribute name).
- //
- // Optimized version since JSX identifiers can't contain
- // escape characters and so can be read as single slice.
- // Also assumes that first character was already checked
- // by isIdentifierStart in readToken.
- pp.jsx_readWord = function() {
- var ch, start = this.pos;
- do {
- ch = this.input.charCodeAt(++this.pos);
- } while (acorn.isIdentifierChar(ch) || ch === 45); // '-'
- return this.finishToken(tt.jsxName, this.input.slice(start, this.pos));
- };
- // Transforms JSX element name to string.
- function getQualifiedJSXName(object) {
- if (object.type === 'JSXIdentifier')
- return object.name;
- if (object.type === 'JSXNamespacedName')
- return object.namespace.name + ':' + object.name.name;
- if (object.type === 'JSXMemberExpression')
- return getQualifiedJSXName(object.object) + '.' +
- getQualifiedJSXName(object.property);
- }
- // Parse next token as JSX identifier
- pp.jsx_parseIdentifier = function() {
- var node = this.startNode();
- if (this.type === tt.jsxName)
- node.name = this.value;
- else if (this.type.keyword)
- node.name = this.type.keyword;
- else
- this.unexpected();
- this.next();
- return this.finishNode(node, 'JSXIdentifier');
- };
- // Parse namespaced identifier.
- pp.jsx_parseNamespacedName = function() {
- var start = this.markPosition();
- var name = this.jsx_parseIdentifier();
- if (!this.eat(tt.colon)) return name;
- var node = this.startNodeAt(start);
- node.namespace = name;
- node.name = this.jsx_parseIdentifier();
- return this.finishNode(node, 'JSXNamespacedName');
- };
- // Parses element name in any form - namespaced, member
- // or single identifier.
- pp.jsx_parseElementName = function() {
- var start = this.markPosition();
- var node = this.jsx_parseNamespacedName();
- while (this.eat(tt.dot)) {
- var newNode = this.startNodeAt(start);
- newNode.object = node;
- newNode.property = this.jsx_parseIdentifier();
- node = this.finishNode(newNode, 'JSXMemberExpression');
- }
- return node;
- };
- // Parses any type of JSX attribute value.
- pp.jsx_parseAttributeValue = function() {
- switch (this.type) {
- case tt.braceL:
- var node = this.jsx_parseExpressionContainer();
- if (node.expression.type === 'JSXEmptyExpression')
- this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
- return node;
- case tt.jsxTagStart:
- case tt.string:
- return this.parseExprAtom();
- default:
- this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
- }
- };
- // JSXEmptyExpression is unique type since it doesn't actually parse anything,
- // and so it should start at the end of last read token (left brace) and finish
- // at the beginning of the next one (right brace).
- pp.jsx_parseEmptyExpression = function() {
- var tmp = this.start;
- this.start = this.lastTokEnd;
- this.lastTokEnd = tmp;
- tmp = this.startLoc;
- this.startLoc = this.lastTokEndLoc;
- this.lastTokEndLoc = tmp;
- return this.finishNode(this.startNode(), 'JSXEmptyExpression');
- };
- // Parses JSX expression enclosed into curly brackets.
- pp.jsx_parseExpressionContainer = function() {
- var node = this.startNode();
- this.next();
- node.expression = this.type === tt.braceR
- ? this.jsx_parseEmptyExpression()
- : this.parseExpression();
- this.expect(tt.braceR);
- return this.finishNode(node, 'JSXExpressionContainer');
- };
- // Parses following JSX attribute name-value pair.
- pp.jsx_parseAttribute = function() {
- var node = this.startNode();
- if (this.eat(tt.braceL)) {
- this.expect(tt.ellipsis);
- node.argument = this.parseMaybeAssign();
- this.expect(tt.braceR);
- return this.finishNode(node, 'JSXSpreadAttribute');
- }
- node.name = this.jsx_parseNamespacedName();
- node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
- return this.finishNode(node, 'JSXAttribute');
- };
- // Parses JSX opening tag starting after '<'.
- pp.jsx_parseOpeningElementAt = function(start) {
- var node = this.startNodeAt(start);
- node.attributes = [];
- node.name = this.jsx_parseElementName();
- while (this.type !== tt.slash && this.type !== tt.jsxTagEnd)
- node.attributes.push(this.jsx_parseAttribute());
- node.selfClosing = this.eat(tt.slash);
- this.expect(tt.jsxTagEnd);
- return this.finishNode(node, 'JSXOpeningElement');
- };
- // Parses JSX closing tag starting after '</'.
- pp.jsx_parseClosingElementAt = function(start) {
- var node = this.startNodeAt(start);
- node.name = this.jsx_parseElementName();
- this.expect(tt.jsxTagEnd);
- return this.finishNode(node, 'JSXClosingElement');
- };
- // Parses entire JSX element, including it's opening tag
- // (starting after '<'), attributes, contents and closing tag.
- pp.jsx_parseElementAt = function(start) {
- var node = this.startNodeAt(start);
- var children = [];
- var openingElement = this.jsx_parseOpeningElementAt(start);
- var closingElement = null;
- if (!openingElement.selfClosing) {
- contents: for (;;) {
- switch (this.type) {
- case tt.jsxTagStart:
- start = this.markPosition();
- this.next();
- if (this.eat(tt.slash)) {
- closingElement = this.jsx_parseClosingElementAt(start);
- break contents;
- }
- children.push(this.jsx_parseElementAt(start));
- break;
- case tt.jsxText:
- children.push(this.parseExprAtom());
- break;
- case tt.braceL:
- children.push(this.jsx_parseExpressionContainer());
- break;
- default:
- this.unexpected();
- }
- }
- if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name))
- this.raise(
- closingElement.start,
- 'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
- }
- node.openingElement = openingElement;
- node.closingElement = closingElement;
- node.children = children;
- return this.finishNode(node, 'JSXElement');
- };
- // Parses entire JSX element from current position.
- pp.jsx_parseElement = function() {
- var start = this.markPosition();
- this.next();
- return this.jsx_parseElementAt(start);
- };
- acorn.plugins.jsx = function(instance) {
- instance.extend('parseExprAtom', function(inner) {
- return function(refShortHandDefaultPos) {
- if (this.type === tt.jsxText)
- return this.parseLiteral(this.value);
- else if (this.type === tt.jsxTagStart)
- return this.jsx_parseElement();
- else
- return inner.call(this, refShortHandDefaultPos);
- };
- });
- instance.extend('readToken', function(inner) {
- return function(code) {
- var context = this.curContext();
- if (context === tc.j_expr) return this.jsx_readToken();
- if (context === tc.j_oTag || context === tc.j_cTag) {
- if (acorn.isIdentifierStart(code)) return this.jsx_readWord();
- if (code == 62) {
- ++this.pos;
- return this.finishToken(tt.jsxTagEnd);
- }
- if ((code === 34 || code === 39) && context == tc.j_oTag)
- return this.jsx_readString(code);
- }
- if (code === 60 && this.exprAllowed) {
- ++this.pos;
- return this.finishToken(tt.jsxTagStart);
- }
- return inner.call(this, code);
- };
- });
- instance.extend('updateContext', function(inner) {
- return function(prevType) {
- if (this.type == tt.braceL) {
- var curContext = this.curContext();
- if (curContext == tc.j_oTag) this.context.push(tc.b_expr);
- else if (curContext == tc.j_expr) this.context.push(tc.b_tmpl);
- else inner.call(this, prevType);
- this.exprAllowed = true;
- } else if (this.type === tt.slash && prevType === tt.jsxTagStart) {
- this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
- this.context.push(tc.j_cTag); // reconsider as closing tag context
- this.exprAllowed = false;
- } else {
- return inner.call(this, prevType);
- }
- };
- });
- };
- return acorn;
- };
- },{}],175:[function(require,module,exports){
- var types = require("../lib/types");
- var Type = types.Type;
- var def = Type.def;
- var or = Type.or;
- var builtin = types.builtInTypes;
- var isString = builtin.string;
- var isNumber = builtin.number;
- var isBoolean = builtin.boolean;
- var isRegExp = builtin.RegExp;
- var shared = require("../lib/shared");
- var defaults = shared.defaults;
- var geq = shared.geq;
- // Abstract supertype of all syntactic entities that are allowed to have a
- // .loc field.
- def("Printable")
- .field("loc", or(
- def("SourceLocation"),
- null
- ), defaults["null"], true);
- def("Node")
- .bases("Printable")
- .field("type", isString)
- .field("comments", or(
- [def("Comment")],
- null
- ), defaults["null"], true);
- def("SourceLocation")
- .build("start", "end", "source")
- .field("start", def("Position"))
- .field("end", def("Position"))
- .field("source", or(isString, null), defaults["null"]);
- def("Position")
- .build("line", "column")
- .field("line", geq(1))
- .field("column", geq(0));
- def("Program")
- .bases("Node")
- .build("body")
- .field("body", [def("Statement")]);
- def("Function")
- .bases("Node")
- .field("id", or(def("Identifier"), null), defaults["null"])
- .field("params", [def("Pattern")])
- .field("body", def("BlockStatement"));
- def("Statement").bases("Node");
- // The empty .build() here means that an EmptyStatement can be constructed
- // (i.e. it's not abstract) but that it needs no arguments.
- def("EmptyStatement").bases("Statement").build();
- def("BlockStatement")
- .bases("Statement")
- .build("body")
- .field("body", [def("Statement")]);
- // TODO Figure out how to silently coerce Expressions to
- // ExpressionStatements where a Statement was expected.
- def("ExpressionStatement")
- .bases("Statement")
- .build("expression")
- .field("expression", def("Expression"));
- def("IfStatement")
- .bases("Statement")
- .build("test", "consequent", "alternate")
- .field("test", def("Expression"))
- .field("consequent", def("Statement"))
- .field("alternate", or(def("Statement"), null), defaults["null"]);
- def("LabeledStatement")
- .bases("Statement")
- .build("label", "body")
- .field("label", def("Identifier"))
- .field("body", def("Statement"));
- def("BreakStatement")
- .bases("Statement")
- .build("label")
- .field("label", or(def("Identifier"), null), defaults["null"]);
- def("ContinueStatement")
- .bases("Statement")
- .build("label")
- .field("label", or(def("Identifier"), null), defaults["null"]);
- def("WithStatement")
- .bases("Statement")
- .build("object", "body")
- .field("object", def("Expression"))
- .field("body", def("Statement"));
- def("SwitchStatement")
- .bases("Statement")
- .build("discriminant", "cases", "lexical")
- .field("discriminant", def("Expression"))
- .field("cases", [def("SwitchCase")])
- .field("lexical", isBoolean, defaults["false"]);
- def("ReturnStatement")
- .bases("Statement")
- .build("argument")
- .field("argument", or(def("Expression"), null));
- def("ThrowStatement")
- .bases("Statement")
- .build("argument")
- .field("argument", def("Expression"));
- def("TryStatement")
- .bases("Statement")
- .build("block", "handler", "finalizer")
- .field("block", def("BlockStatement"))
- .field("handler", or(def("CatchClause"), null), function() {
- return this.handlers && this.handlers[0] || null;
- })
- .field("handlers", [def("CatchClause")], function() {
- return this.handler ? [this.handler] : [];
- }, true) // Indicates this field is hidden from eachField iteration.
- .field("guardedHandlers", [def("CatchClause")], defaults.emptyArray)
- .field("finalizer", or(def("BlockStatement"), null), defaults["null"]);
- def("CatchClause")
- .bases("Node")
- .build("param", "guard", "body")
- .field("param", def("Pattern"))
- .field("guard", or(def("Expression"), null), defaults["null"])
- .field("body", def("BlockStatement"));
- def("WhileStatement")
- .bases("Statement")
- .build("test", "body")
- .field("test", def("Expression"))
- .field("body", def("Statement"));
- def("DoWhileStatement")
- .bases("Statement")
- .build("body", "test")
- .field("body", def("Statement"))
- .field("test", def("Expression"));
- def("ForStatement")
- .bases("Statement")
- .build("init", "test", "update", "body")
- .field("init", or(
- def("VariableDeclaration"),
- def("Expression"),
- null))
- .field("test", or(def("Expression"), null))
- .field("update", or(def("Expression"), null))
- .field("body", def("Statement"));
- def("ForInStatement")
- .bases("Statement")
- .build("left", "right", "body", "each")
- .field("left", or(
- def("VariableDeclaration"),
- def("Expression")))
- .field("right", def("Expression"))
- .field("body", def("Statement"))
- .field("each", isBoolean);
- def("DebuggerStatement").bases("Statement").build();
- def("Declaration").bases("Statement");
- def("FunctionDeclaration")
- .bases("Function", "Declaration")
- .build("id", "params", "body")
- .field("id", def("Identifier"));
- def("FunctionExpression")
- .bases("Function", "Expression")
- .build("id", "params", "body");
- def("VariableDeclaration")
- .bases("Declaration")
- .build("kind", "declarations")
- .field("kind", or("var", "let", "const"))
- .field("declarations", [or(
- def("VariableDeclarator"),
- def("Identifier") // TODO Esprima deviation.
- )]);
- def("VariableDeclarator")
- .bases("Node")
- .build("id", "init")
- .field("id", def("Pattern"))
- .field("init", or(def("Expression"), null));
- // TODO Are all Expressions really Patterns?
- def("Expression").bases("Node", "Pattern");
- def("ThisExpression").bases("Expression").build();
- def("ArrayExpression")
- .bases("Expression")
- .build("elements")
- .field("elements", [or(def("Expression"), null)]);
- def("ObjectExpression")
- .bases("Expression")
- .build("properties")
- .field("properties", [def("Property")]);
- // TODO Not in the Mozilla Parser API, but used by Esprima.
- def("Property")
- .bases("Node") // Want to be able to visit Property Nodes.
- .build("kind", "key", "value")
- .field("kind", or("init", "get", "set"))
- .field("key", or(def("Literal"), def("Identifier")))
- // esprima allows Pattern
- .field("value", or(def("Expression"), def("Pattern")));
- def("SequenceExpression")
- .bases("Expression")
- .build("expressions")
- .field("expressions", [def("Expression")]);
- var UnaryOperator = or(
- "-", "+", "!", "~",
- "typeof", "void", "delete");
- def("UnaryExpression")
- .bases("Expression")
- .build("operator", "argument", "prefix")
- .field("operator", UnaryOperator)
- .field("argument", def("Expression"))
- // TODO Esprima doesn't bother with this field, presumably because
- // it's always true for unary operators.
- .field("prefix", isBoolean, defaults["true"]);
- var BinaryOperator = or(
- "==", "!=", "===", "!==",
- "<", "<=", ">", ">=",
- "<<", ">>", ">>>",
- "+", "-", "*", "/", "%",
- "&", // TODO Missing from the Parser API.
- "|", "^", "in",
- "instanceof", "..");
- def("BinaryExpression")
- .bases("Expression")
- .build("operator", "left", "right")
- .field("operator", BinaryOperator)
- .field("left", def("Expression"))
- .field("right", def("Expression"));
- var AssignmentOperator = or(
- "=", "+=", "-=", "*=", "/=", "%=",
- "<<=", ">>=", ">>>=",
- "|=", "^=", "&=");
- def("AssignmentExpression")
- .bases("Expression")
- .build("operator", "left", "right")
- .field("operator", AssignmentOperator)
- .field("left", def("Pattern"))
- .field("right", def("Expression"));
- var UpdateOperator = or("++", "--");
- def("UpdateExpression")
- .bases("Expression")
- .build("operator", "argument", "prefix")
- .field("operator", UpdateOperator)
- .field("argument", def("Expression"))
- .field("prefix", isBoolean);
- var LogicalOperator = or("||", "&&");
- def("LogicalExpression")
- .bases("Expression")
- .build("operator", "left", "right")
- .field("operator", LogicalOperator)
- .field("left", def("Expression"))
- .field("right", def("Expression"));
- def("ConditionalExpression")
- .bases("Expression")
- .build("test", "consequent", "alternate")
- .field("test", def("Expression"))
- .field("consequent", def("Expression"))
- .field("alternate", def("Expression"));
- def("NewExpression")
- .bases("Expression")
- .build("callee", "arguments")
- .field("callee", def("Expression"))
- // The Mozilla Parser API gives this type as [or(def("Expression"),
- // null)], but null values don't really make sense at the call site.
- // TODO Report this nonsense.
- .field("arguments", [def("Expression")]);
- def("CallExpression")
- .bases("Expression")
- .build("callee", "arguments")
- .field("callee", def("Expression"))
- // See comment for NewExpression above.
- .field("arguments", [def("Expression")]);
- def("MemberExpression")
- .bases("Expression")
- .build("object", "property", "computed")
- .field("object", def("Expression"))
- .field("property", or(def("Identifier"), def("Expression")))
- .field("computed", isBoolean, defaults["false"]);
- def("Pattern").bases("Node");
- def("ObjectPattern")
- .bases("Pattern")
- .build("properties")
- // TODO File a bug to get PropertyPattern added to the interfaces API.
- // esprima uses Property
- .field("properties", [or(def("PropertyPattern"), def("Property"))]);
- def("PropertyPattern")
- .bases("Pattern")
- .build("key", "pattern")
- .field("key", or(def("Literal"), def("Identifier")))
- .field("pattern", def("Pattern"));
- def("ArrayPattern")
- .bases("Pattern")
- .build("elements")
- .field("elements", [or(def("Pattern"), null)]);
- def("SwitchCase")
- .bases("Node")
- .build("test", "consequent")
- .field("test", or(def("Expression"), null))
- .field("consequent", [def("Statement")]);
- def("Identifier")
- // But aren't Expressions and Patterns already Nodes? TODO Report this.
- .bases("Node", "Expression", "Pattern")
- .build("name")
- .field("name", isString);
- def("Literal")
- // But aren't Expressions already Nodes? TODO Report this.
- .bases("Node", "Expression")
- .build("value")
- .field("value", or(
- isString,
- isBoolean,
- null, // isNull would also work here.
- isNumber,
- isRegExp
- ))
- .field("regex", or({
- pattern: isString,
- flags: isString
- }, null), function() {
- if (!isRegExp.check(this.value))
- return null;
- var flags = "";
- if (this.value.ignoreCase) flags += "i";
- if (this.value.multiline) flags += "m";
- if (this.value.global) flags += "g";
- return {
- pattern: this.value.source,
- flags: flags
- };
- });
- // Abstract (non-buildable) comment supertype. Not a Node.
- def("Comment")
- .bases("Printable")
- .field("value", isString)
- // A .leading comment comes before the node, whereas a .trailing
- // comment comes after it. These two fields should not both be true,
- // but they might both be false when the comment falls inside a node
- // and the node has no children for the comment to lead or trail,
- // e.g. { /*dangling*/ }.
- .field("leading", isBoolean, defaults["true"])
- .field("trailing", isBoolean, defaults["false"]);
- // Block comment. The .type really should be BlockComment rather than
- // Block, but that's what we're stuck with for now.
- def("Block")
- .bases("Comment")
- .build("value", /*optional:*/ "leading", "trailing");
- // Single line comment. The .type really should be LineComment rather than
- // Line, but that's what we're stuck with for now.
- def("Line")
- .bases("Comment")
- .build("value", /*optional:*/ "leading", "trailing");
- },{"../lib/shared":186,"../lib/types":187}],176:[function(require,module,exports){
- require("./core");
- var types = require("../lib/types");
- var def = types.Type.def;
- var or = types.Type.or;
- var builtin = types.builtInTypes;
- var isString = builtin.string;
- var isBoolean = builtin.boolean;
- // Note that none of these types are buildable because the Mozilla Parser
- // API doesn't specify any builder functions, and nobody uses E4X anymore.
- def("XMLDefaultDeclaration")
- .bases("Declaration")
- .field("namespace", def("Expression"));
- def("XMLAnyName").bases("Expression");
- def("XMLQualifiedIdentifier")
- .bases("Expression")
- .field("left", or(def("Identifier"), def("XMLAnyName")))
- .field("right", or(def("Identifier"), def("Expression")))
- .field("computed", isBoolean);
- def("XMLFunctionQualifiedIdentifier")
- .bases("Expression")
- .field("right", or(def("Identifier"), def("Expression")))
- .field("computed", isBoolean);
- def("XMLAttributeSelector")
- .bases("Expression")
- .field("attribute", def("Expression"));
- def("XMLFilterExpression")
- .bases("Expression")
- .field("left", def("Expression"))
- .field("right", def("Expression"));
- def("XMLElement")
- .bases("XML", "Expression")
- .field("contents", [def("XML")]);
- def("XMLList")
- .bases("XML", "Expression")
- .field("contents", [def("XML")]);
- def("XML").bases("Node");
- def("XMLEscape")
- .bases("XML")
- .field("expression", def("Expression"));
- def("XMLText")
- .bases("XML")
- .field("text", isString);
- def("XMLStartTag")
- .bases("XML")
- .field("contents", [def("XML")]);
- def("XMLEndTag")
- .bases("XML")
- .field("contents", [def("XML")]);
- def("XMLPointTag")
- .bases("XML")
- .field("contents", [def("XML")]);
- def("XMLName")
- .bases("XML")
- .field("contents", or(isString, [def("XML")]));
- def("XMLAttribute")
- .bases("XML")
- .field("value", isString);
- def("XMLCdata")
- .bases("XML")
- .field("contents", isString);
- def("XMLComment")
- .bases("XML")
- .field("contents", isString);
- def("XMLProcessingInstruction")
- .bases("XML")
- .field("target", isString)
- .field("contents", or(isString, null));
- },{"../lib/types":187,"./core":175}],177:[function(require,module,exports){
- require("./core");
- var types = require("../lib/types");
- var def = types.Type.def;
- var or = types.Type.or;
- var builtin = types.builtInTypes;
- var isBoolean = builtin.boolean;
- var isObject = builtin.object;
- var isString = builtin.string;
- var defaults = require("../lib/shared").defaults;
- def("Function")
- .field("generator", isBoolean, defaults["false"])
- .field("expression", isBoolean, defaults["false"])
- .field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
- // TODO This could be represented as a SpreadElementPattern in .params.
- .field("rest", or(def("Identifier"), null), defaults["null"]);
- def("FunctionDeclaration")
- .build("id", "params", "body", "generator", "expression");
- def("FunctionExpression")
- .build("id", "params", "body", "generator", "expression");
- // TODO The Parser API calls this ArrowExpression, but Esprima uses
- // ArrowFunctionExpression.
- def("ArrowFunctionExpression")
- .bases("Function", "Expression")
- .build("params", "body", "expression")
- // The forced null value here is compatible with the overridden
- // definition of the "id" field in the Function interface.
- .field("id", null, defaults["null"])
- // Arrow function bodies are allowed to be expressions.
- .field("body", or(def("BlockStatement"), def("Expression")))
- // The current spec forbids arrow generators, so I have taken the
- // liberty of enforcing that. TODO Report this.
- .field("generator", false, defaults["false"]);
- def("YieldExpression")
- .bases("Expression")
- .build("argument", "delegate")
- .field("argument", or(def("Expression"), null))
- .field("delegate", isBoolean, defaults["false"]);
- def("GeneratorExpression")
- .bases("Expression")
- .build("body", "blocks", "filter")
- .field("body", def("Expression"))
- .field("blocks", [def("ComprehensionBlock")])
- .field("filter", or(def("Expression"), null));
- def("ComprehensionExpression")
- .bases("Expression")
- .build("body", "blocks", "filter")
- .field("body", def("Expression"))
- .field("blocks", [def("ComprehensionBlock")])
- .field("filter", or(def("Expression"), null));
- def("ComprehensionBlock")
- .bases("Node")
- .build("left", "right", "each")
- .field("left", def("Pattern"))
- .field("right", def("Expression"))
- .field("each", isBoolean);
- def("ModuleSpecifier")
- .bases("Literal")
- .build("value")
- .field("value", isString);
- def("Property")
- // Esprima extensions not mentioned in the Mozilla Parser API:
- .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
- .field("method", isBoolean, defaults["false"])
- .field("shorthand", isBoolean, defaults["false"])
- .field("computed", isBoolean, defaults["false"]);
- def("PropertyPattern")
- .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
- .field("computed", isBoolean, defaults["false"]);
- def("MethodDefinition")
- .bases("Declaration")
- .build("kind", "key", "value", "static")
- .field("kind", or("init", "get", "set", ""))
- .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
- .field("value", def("Function"))
- .field("computed", isBoolean, defaults["false"])
- .field("static", isBoolean, defaults["false"]);
- def("SpreadElement")
- .bases("Node")
- .build("argument")
- .field("argument", def("Expression"));
- def("ArrayExpression")
- .field("elements", [or(def("Expression"), def("SpreadElement"), null)]);
- def("NewExpression")
- .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
- def("CallExpression")
- .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
- def("SpreadElementPattern")
- .bases("Pattern")
- .build("argument")
- .field("argument", def("Pattern"));
- def("ArrayPattern")
- .field("elements", [or(
- def("Pattern"),
- null,
- // used by esprima
- def("SpreadElement")
- )]);
- var ClassBodyElement = or(
- def("MethodDefinition"),
- def("VariableDeclarator"),
- def("ClassPropertyDefinition"),
- def("ClassProperty")
- );
- def("ClassProperty")
- .bases("Declaration")
- .build("key")
- .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
- .field("computed", isBoolean, defaults["false"]);
- def("ClassPropertyDefinition") // static property
- .bases("Declaration")
- .build("definition")
- // Yes, Virginia, circular definitions are permitted.
- .field("definition", ClassBodyElement);
- def("ClassBody")
- .bases("Declaration")
- .build("body")
- .field("body", [ClassBodyElement]);
- def("ClassDeclaration")
- .bases("Declaration")
- .build("id", "body", "superClass")
- .field("id", or(def("Identifier"), null))
- .field("body", def("ClassBody"))
- .field("superClass", or(def("Expression"), null), defaults["null"]);
- def("ClassExpression")
- .bases("Expression")
- .build("id", "body", "superClass")
- .field("id", or(def("Identifier"), null), defaults["null"])
- .field("body", def("ClassBody"))
- .field("superClass", or(def("Expression"), null), defaults["null"])
- .field("implements", [def("ClassImplements")], defaults.emptyArray);
- def("ClassImplements")
- .bases("Node")
- .build("id")
- .field("id", def("Identifier"))
- .field("superClass", or(def("Expression"), null), defaults["null"]);
- // Specifier and NamedSpecifier are abstract non-standard types that I
- // introduced for definitional convenience.
- def("Specifier").bases("Node");
- def("NamedSpecifier")
- .bases("Specifier")
- // Note: this abstract type is intentionally not buildable.
- .field("id", def("Identifier"))
- .field("name", or(def("Identifier"), null), defaults["null"]);
- // Like NamedSpecifier, except type:"ExportSpecifier" and buildable.
- // export {<id [as name]>} [from ...];
- def("ExportSpecifier")
- .bases("NamedSpecifier")
- .build("id", "name");
- // export <*> from ...;
- def("ExportBatchSpecifier")
- .bases("Specifier")
- .build();
- // Like NamedSpecifier, except type:"ImportSpecifier" and buildable.
- // import {<id [as name]>} from ...;
- def("ImportSpecifier")
- .bases("NamedSpecifier")
- .build("id", "name");
- // import <* as id> from ...;
- def("ImportNamespaceSpecifier")
- .bases("Specifier")
- .build("id")
- .field("id", def("Identifier"));
- // import <id> from ...;
- def("ImportDefaultSpecifier")
- .bases("Specifier")
- .build("id")
- .field("id", def("Identifier"));
- def("ExportDeclaration")
- .bases("Declaration")
- .build("default", "declaration", "specifiers", "source")
- .field("default", isBoolean)
- .field("declaration", or(
- def("Declaration"),
- def("Expression"), // Implies default.
- null
- ))
- .field("specifiers", [or(
- def("ExportSpecifier"),
- def("ExportBatchSpecifier")
- )], defaults.emptyArray)
- .field("source", or(
- def("Literal"),
- def("ModuleSpecifier"),
- null
- ), defaults["null"]);
- def("ImportDeclaration")
- .bases("Declaration")
- .build("specifiers", "source")
- .field("specifiers", [or(
- def("ImportSpecifier"),
- def("ImportNamespaceSpecifier"),
- def("ImportDefaultSpecifier")
- )], defaults.emptyArray)
- .field("source", or(
- def("Literal"),
- def("ModuleSpecifier")
- ));
- def("TaggedTemplateExpression")
- .bases("Expression")
- .field("tag", def("Expression"))
- .field("quasi", def("TemplateLiteral"));
- def("TemplateLiteral")
- .bases("Expression")
- .build("quasis", "expressions")
- .field("quasis", [def("TemplateElement")])
- .field("expressions", [def("Expression")]);
- def("TemplateElement")
- .bases("Node")
- .build("value", "tail")
- .field("value", {"cooked": isString, "raw": isString})
- .field("tail", isBoolean);
- },{"../lib/shared":186,"../lib/types":187,"./core":175}],178:[function(require,module,exports){
- require("./core");
- var types = require("../lib/types");
- var def = types.Type.def;
- var or = types.Type.or;
- var builtin = types.builtInTypes;
- var isBoolean = builtin.boolean;
- var defaults = require("../lib/shared").defaults;
- def("Function")
- .field("async", isBoolean, defaults["false"]);
- def("SpreadProperty")
- .bases("Node")
- .build("argument")
- .field("argument", def("Expression"));
- def("ObjectExpression")
- .field("properties", [or(def("Property"), def("SpreadProperty"))]);
- def("SpreadPropertyPattern")
- .bases("Pattern")
- .build("argument")
- .field("argument", def("Pattern"));
- def("ObjectPattern")
- .field("properties", [or(
- def("PropertyPattern"),
- def("SpreadPropertyPattern"),
- // used by esprima
- def("Property"),
- def("SpreadProperty")
- )]);
- def("AwaitExpression")
- .bases("Expression")
- .build("argument", "all")
- .field("argument", or(def("Expression"), null))
- .field("all", isBoolean, defaults["false"]);
- },{"../lib/shared":186,"../lib/types":187,"./core":175}],179:[function(require,module,exports){
- require("./core");
- var types = require("../lib/types");
- var def = types.Type.def;
- var or = types.Type.or;
- var builtin = types.builtInTypes;
- var isString = builtin.string;
- var isBoolean = builtin.boolean;
- var defaults = require("../lib/shared").defaults;
- def("JSXAttribute")
- .bases("Node")
- .build("name", "value")
- .field("name", or(def("JSXIdentifier"), def("JSXNamespacedName")))
- .field("value", or(
- def("Literal"), // attr="value"
- def("JSXExpressionContainer"), // attr={value}
- null // attr= or just attr
- ), defaults["null"]);
- def("JSXIdentifier")
- .bases("Identifier")
- .build("name")
- .field("name", isString);
- def("JSXNamespacedName")
- .bases("Node")
- .build("namespace", "name")
- .field("namespace", def("JSXIdentifier"))
- .field("name", def("JSXIdentifier"));
- def("JSXMemberExpression")
- .bases("MemberExpression")
- .build("object", "property")
- .field("object", or(def("JSXIdentifier"), def("JSXMemberExpression")))
- .field("property", def("JSXIdentifier"))
- .field("computed", isBoolean, defaults.false);
- var JSXElementName = or(
- def("JSXIdentifier"),
- def("JSXNamespacedName"),
- def("JSXMemberExpression")
- );
- def("JSXSpreadAttribute")
- .bases("Node")
- .build("argument")
- .field("argument", def("Expression"));
- var JSXAttributes = [or(
- def("JSXAttribute"),
- def("JSXSpreadAttribute")
- )];
- def("JSXExpressionContainer")
- .bases("Expression")
- .build("expression")
- .field("expression", def("Expression"));
- def("JSXElement")
- .bases("Expression")
- .build("openingElement", "closingElement", "children")
- .field("openingElement", def("JSXOpeningElement"))
- .field("closingElement", or(def("JSXClosingElement"), null), defaults["null"])
- .field("children", [or(
- def("JSXElement"),
- def("JSXExpressionContainer"),
- def("JSXText"),
- def("Literal") // TODO Esprima should return JSXText instead.
- )], defaults.emptyArray)
- .field("name", JSXElementName, function() {
- // Little-known fact: the `this` object inside a default function
- // is none other than the partially-built object itself, and any
- // fields initialized directly from builder function arguments
- // (like openingElement, closingElement, and children) are
- // guaranteed to be available.
- return this.openingElement.name;
- })
- .field("selfClosing", isBoolean, function() {
- return this.openingElement.selfClosing;
- })
- .field("attributes", JSXAttributes, function() {
- return this.openingElement.attributes;
- });
- def("JSXOpeningElement")
- .bases("Node") // TODO Does this make sense? Can't really be an JSXElement.
- .build("name", "attributes", "selfClosing")
- .field("name", JSXElementName)
- .field("attributes", JSXAttributes, defaults.emptyArray)
- .field("selfClosing", isBoolean, defaults["false"]);
- def("JSXClosingElement")
- .bases("Node") // TODO Same concern.
- .build("name")
- .field("name", JSXElementName);
- def("JSXText")
- .bases("Literal")
- .build("value")
- .field("value", isString);
- def("JSXEmptyExpression").bases("Expression").build();
- // Type Annotations
- def("Type")
- .bases("Node");
- def("AnyTypeAnnotation")
- .bases("Type");
- def("VoidTypeAnnotation")
- .bases("Type");
- def("NumberTypeAnnotation")
- .bases("Type");
- def("StringTypeAnnotation")
- .bases("Type");
- def("StringLiteralTypeAnnotation")
- .bases("Type")
- .build("value", "raw")
- .field("value", isString)
- .field("raw", isString);
- def("BooleanTypeAnnotation")
- .bases("Type");
- def("TypeAnnotation")
- .bases("Node")
- .build("typeAnnotation")
- .field("typeAnnotation", def("Type"));
- def("NullableTypeAnnotation")
- .bases("Type")
- .build("typeAnnotation")
- .field("typeAnnotation", def("Type"));
- def("FunctionTypeAnnotation")
- .bases("Type")
- .build("params", "returnType", "rest", "typeParameters")
- .field("params", [def("FunctionTypeParam")])
- .field("returnType", def("Type"))
- .field("rest", or(def("FunctionTypeParam"), null))
- .field("typeParameters", or(def("TypeParameterDeclaration"), null));
- def("FunctionTypeParam")
- .bases("Node")
- .build("name", "typeAnnotation", "optional")
- .field("name", def("Identifier"))
- .field("typeAnnotation", def("Type"))
- .field("optional", isBoolean);
- def("ArrayTypeAnnotation")
- .bases("Type")
- .build("elementType")
- .field("elementType", def("Type"));
- def("ObjectTypeAnnotation")
- .bases("Type")
- .build("properties")
- .field("properties", [def("ObjectTypeProperty")])
- .field("indexers", [def("ObjectTypeIndexer")], defaults.emptyArray)
- .field("callProperties", [def("ObjectTypeCallProperty")], defaults.emptyArray);
- def("ObjectTypeProperty")
- .bases("Node")
- .build("key", "value", "optional")
- .field("key", or(def("Literal"), def("Identifier")))
- .field("value", def("Type"))
- .field("optional", isBoolean);
- def("ObjectTypeIndexer")
- .bases("Node")
- .build("id", "key", "value")
- .field("id", def("Identifier"))
- .field("key", def("Type"))
- .field("value", def("Type"));
- def("ObjectTypeCallProperty")
- .bases("Node")
- .build("value")
- .field("value", def("FunctionTypeAnnotation"))
- .field("static", isBoolean, false);
- def("QualifiedTypeIdentifier")
- .bases("Node")
- .build("qualification", "id")
- .field("qualification", or(def("Identifier"), def("QualifiedTypeIdentifier")))
- .field("id", def("Identifier"));
- def("GenericTypeAnnotation")
- .bases("Type")
- .build("id", "typeParameters")
- .field("id", or(def("Identifier"), def("QualifiedTypeIdentifier")))
- .field("typeParameters", or(def("TypeParameterInstantiation"), null));
- def("MemberTypeAnnotation")
- .bases("Type")
- .build("object", "property")
- .field("object", def("Identifier"))
- .field("property", or(def("MemberTypeAnnotation"), def("GenericTypeAnnotation")));
- def("UnionTypeAnnotation")
- .bases("Type")
- .build("types")
- .field("types", [def("Type")]);
- def("IntersectionTypeAnnotation")
- .bases("Type")
- .build("types")
- .field("types", [def("Type")]);
- def("TypeofTypeAnnotation")
- .bases("Type")
- .build("argument")
- .field("argument", def("Type"));
- def("Identifier")
- .field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]);
- def("TypeParameterDeclaration")
- .bases("Node")
- .build("params")
- .field("params", [def("Identifier")]);
- def("TypeParameterInstantiation")
- .bases("Node")
- .build("params")
- .field("params", [def("Type")]);
- def("Function")
- .field("returnType", or(def("TypeAnnotation"), null), defaults["null"])
- .field("typeParameters", or(def("TypeParameterDeclaration"), null), defaults["null"]);
- def("ClassProperty")
- .build("key", "typeAnnotation")
- .field("typeAnnotation", def("TypeAnnotation"))
- .field("static", isBoolean, false);
- def("ClassImplements")
- .field("typeParameters", or(def("TypeParameterInstantiation"), null), defaults["null"]);
- def("InterfaceDeclaration")
- .bases("Statement")
- .build("id", "body", "extends")
- .field("id", def("Identifier"))
- .field("typeParameters", or(def("TypeParameterDeclaration"), null), defaults["null"])
- .field("body", def("ObjectTypeAnnotation"))
- .field("extends", [def("InterfaceExtends")]);
- def("InterfaceExtends")
- .bases("Node")
- .build("id")
- .field("id", def("Identifier"))
- .field("typeParameters", or(def("TypeParameterInstantiation"), null));
- def("TypeAlias")
- .bases("Statement")
- .build("id", "typeParameters", "right")
- .field("id", def("Identifier"))
- .field("typeParameters", or(def("TypeParameterDeclaration"), null))
- .field("right", def("Type"));
- def("TypeCastExpression")
- .bases("Expression")
- .build("expression", "typeAnnotation")
- .field("expression", def("Expression"))
- .field("typeAnnotation", def("TypeAnnotation"));
- def("TupleTypeAnnotation")
- .bases("Type")
- .build("types")
- .field("types", [def("Type")]);
- def("DeclareVariable")
- .bases("Statement")
- .build("id")
- .field("id", def("Identifier"));
- def("DeclareFunction")
- .bases("Statement")
- .build("id")
- .field("id", def("Identifier"));
- def("DeclareClass")
- .bases("InterfaceDeclaration")
- .build("id");
- def("DeclareModule")
- .bases("Statement")
- .build("id", "body")
- .field("id", or(def("Identifier"), def("Literal")))
- .field("body", def("BlockStatement"));
- },{"../lib/shared":186,"../lib/types":187,"./core":175}],180:[function(require,module,exports){
- require("./core");
- var types = require("../lib/types");
- var def = types.Type.def;
- var or = types.Type.or;
- var geq = require("../lib/shared").geq;
- def("Function")
- // SpiderMonkey allows expression closures: function(x) x+1
- .field("body", or(def("BlockStatement"), def("Expression")));
- def("ForOfStatement")
- .bases("Statement")
- .build("left", "right", "body")
- .field("left", or(
- def("VariableDeclaration"),
- def("Expression")))
- .field("right", def("Expression"))
- .field("body", def("Statement"));
- def("LetStatement")
- .bases("Statement")
- .build("head", "body")
- // TODO Deviating from the spec by reusing VariableDeclarator here.
- .field("head", [def("VariableDeclarator")])
- .field("body", def("Statement"));
- def("LetExpression")
- .bases("Expression")
- .build("head", "body")
- // TODO Deviating from the spec by reusing VariableDeclarator here.
- .field("head", [def("VariableDeclarator")])
- .field("body", def("Expression"));
- def("GraphExpression")
- .bases("Expression")
- .build("index", "expression")
- .field("index", geq(0))
- .field("expression", def("Literal"));
- def("GraphIndexExpression")
- .bases("Expression")
- .build("index")
- .field("index", geq(0));
- },{"../lib/shared":186,"../lib/types":187,"./core":175}],181:[function(require,module,exports){
- var assert = require("assert");
- var types = require("../main");
- var getFieldNames = types.getFieldNames;
- var getFieldValue = types.getFieldValue;
- var isArray = types.builtInTypes.array;
- var isObject = types.builtInTypes.object;
- var isDate = types.builtInTypes.Date;
- var isRegExp = types.builtInTypes.RegExp;
- var hasOwn = Object.prototype.hasOwnProperty;
- function astNodesAreEquivalent(a, b, problemPath) {
- if (isArray.check(problemPath)) {
- problemPath.length = 0;
- } else {
- problemPath = null;
- }
- return areEquivalent(a, b, problemPath);
- }
- astNodesAreEquivalent.assert = function(a, b) {
- var problemPath = [];
- if (!astNodesAreEquivalent(a, b, problemPath)) {
- if (problemPath.length === 0) {
- assert.strictEqual(a, b);
- } else {
- assert.ok(
- false,
- "Nodes differ in the following path: " +
- problemPath.map(subscriptForProperty).join("")
- );
- }
- }
- };
- function subscriptForProperty(property) {
- if (/[_$a-z][_$a-z0-9]*/i.test(property)) {
- return "." + property;
- }
- return "[" + JSON.stringify(property) + "]";
- }
- function areEquivalent(a, b, problemPath) {
- if (a === b) {
- return true;
- }
- if (isArray.check(a)) {
- return arraysAreEquivalent(a, b, problemPath);
- }
- if (isObject.check(a)) {
- return objectsAreEquivalent(a, b, problemPath);
- }
- if (isDate.check(a)) {
- return isDate.check(b) && (+a === +b);
- }
- if (isRegExp.check(a)) {
- return isRegExp.check(b) && (
- a.source === b.source &&
- a.global === b.global &&
- a.multiline === b.multiline &&
- a.ignoreCase === b.ignoreCase
- );
- }
- return a == b;
- }
- function arraysAreEquivalent(a, b, problemPath) {
- isArray.assert(a);
- var aLength = a.length;
- if (!isArray.check(b) || b.length !== aLength) {
- if (problemPath) {
- problemPath.push("length");
- }
- return false;
- }
- for (var i = 0; i < aLength; ++i) {
- if (problemPath) {
- problemPath.push(i);
- }
- if (i in a !== i in b) {
- return false;
- }
- if (!areEquivalent(a[i], b[i], problemPath)) {
- return false;
- }
- if (problemPath) {
- assert.strictEqual(problemPath.pop(), i);
- }
- }
- return true;
- }
- function objectsAreEquivalent(a, b, problemPath) {
- isObject.assert(a);
- if (!isObject.check(b)) {
- return false;
- }
- // Fast path for a common property of AST nodes.
- if (a.type !== b.type) {
- if (problemPath) {
- problemPath.push("type");
- }
- return false;
- }
- var aNames = getFieldNames(a);
- var aNameCount = aNames.length;
- var bNames = getFieldNames(b);
- var bNameCount = bNames.length;
- if (aNameCount === bNameCount) {
- for (var i = 0; i < aNameCount; ++i) {
- var name = aNames[i];
- var aChild = getFieldValue(a, name);
- var bChild = getFieldValue(b, name);
- if (problemPath) {
- problemPath.push(name);
- }
- if (!areEquivalent(aChild, bChild, problemPath)) {
- return false;
- }
- if (problemPath) {
- assert.strictEqual(problemPath.pop(), name);
- }
- }
- return true;
- }
- if (!problemPath) {
- return false;
- }
- // Since aNameCount !== bNameCount, we need to find some name that's
- // missing in aNames but present in bNames, or vice-versa.
- var seenNames = Object.create(null);
- for (i = 0; i < aNameCount; ++i) {
- seenNames[aNames[i]] = true;
- }
- for (i = 0; i < bNameCount; ++i) {
- name = bNames[i];
- if (!hasOwn.call(seenNames, name)) {
- problemPath.push(name);
- return false;
- }
- delete seenNames[name];
- }
- for (name in seenNames) {
- problemPath.push(name);
- break;
- }
- return false;
- }
- module.exports = astNodesAreEquivalent;
- },{"../main":188,"assert":190}],182:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var n = types.namedTypes;
- var b = types.builders;
- var isNumber = types.builtInTypes.number;
- var isArray = types.builtInTypes.array;
- var Path = require("./path");
- var Scope = require("./scope");
- function NodePath(value, parentPath, name) {
- assert.ok(this instanceof NodePath);
- Path.call(this, value, parentPath, name);
- }
- require("util").inherits(NodePath, Path);
- var NPp = NodePath.prototype;
- Object.defineProperties(NPp, {
- node: {
- get: function() {
- Object.defineProperty(this, "node", {
- configurable: true, // Enable deletion.
- value: this._computeNode()
- });
- return this.node;
- }
- },
- parent: {
- get: function() {
- Object.defineProperty(this, "parent", {
- configurable: true, // Enable deletion.
- value: this._computeParent()
- });
- return this.parent;
- }
- },
- scope: {
- get: function() {
- Object.defineProperty(this, "scope", {
- configurable: true, // Enable deletion.
- value: this._computeScope()
- });
- return this.scope;
- }
- }
- });
- NPp.replace = function() {
- delete this.node;
- delete this.parent;
- delete this.scope;
- return Path.prototype.replace.apply(this, arguments);
- };
- NPp.prune = function() {
- var remainingNodePath = this.parent;
- this.replace();
- return cleanUpNodesAfterPrune(remainingNodePath);
- };
- // The value of the first ancestor Path whose value is a Node.
- NPp._computeNode = function() {
- var value = this.value;
- if (n.Node.check(value)) {
- return value;
- }
- var pp = this.parentPath;
- return pp && pp.node || null;
- };
- // The first ancestor Path whose value is a Node distinct from this.node.
- NPp._computeParent = function() {
- var value = this.value;
- var pp = this.parentPath;
- if (!n.Node.check(value)) {
- while (pp && !n.Node.check(pp.value)) {
- pp = pp.parentPath;
- }
- if (pp) {
- pp = pp.parentPath;
- }
- }
- while (pp && !n.Node.check(pp.value)) {
- pp = pp.parentPath;
- }
- return pp || null;
- };
- // The closest enclosing scope that governs this node.
- NPp._computeScope = function() {
- var value = this.value;
- var pp = this.parentPath;
- var scope = pp && pp.scope;
- if (n.Node.check(value) &&
- Scope.isEstablishedBy(value)) {
- scope = new Scope(this, scope);
- }
- return scope || null;
- };
- NPp.getValueProperty = function(name) {
- return types.getFieldValue(this.value, name);
- };
- /**
- * Determine whether this.node needs to be wrapped in parentheses in order
- * for a parser to reproduce the same local AST structure.
- *
- * For instance, in the expression `(1 + 2) * 3`, the BinaryExpression
- * whose operator is "+" needs parentheses, because `1 + 2 * 3` would
- * parse differently.
- *
- * If assumeExpressionContext === true, we don't worry about edge cases
- * like an anonymous FunctionExpression appearing lexically first in its
- * enclosing statement and thus needing parentheses to avoid being parsed
- * as a FunctionDeclaration with a missing name.
- */
- NPp.needsParens = function(assumeExpressionContext) {
- var pp = this.parentPath;
- if (!pp) {
- return false;
- }
- var node = this.value;
- // Only expressions need parentheses.
- if (!n.Expression.check(node)) {
- return false;
- }
- // Identifiers never need parentheses.
- if (node.type === "Identifier") {
- return false;
- }
- while (!n.Node.check(pp.value)) {
- pp = pp.parentPath;
- if (!pp) {
- return false;
- }
- }
- var parent = pp.value;
- switch (node.type) {
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- return parent.type === "MemberExpression"
- && this.name === "object"
- && parent.object === node;
- case "BinaryExpression":
- case "LogicalExpression":
- switch (parent.type) {
- case "CallExpression":
- return this.name === "callee"
- && parent.callee === node;
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- return true;
- case "MemberExpression":
- return this.name === "object"
- && parent.object === node;
- case "BinaryExpression":
- case "LogicalExpression":
- var po = parent.operator;
- var pp = PRECEDENCE[po];
- var no = node.operator;
- var np = PRECEDENCE[no];
- if (pp > np) {
- return true;
- }
- if (pp === np && this.name === "right") {
- assert.strictEqual(parent.right, node);
- return true;
- }
- default:
- return false;
- }
- case "SequenceExpression":
- switch (parent.type) {
- case "ForStatement":
- // Although parentheses wouldn't hurt around sequence
- // expressions in the head of for loops, traditional style
- // dictates that e.g. i++, j++ should not be wrapped with
- // parentheses.
- return false;
- case "ExpressionStatement":
- return this.name !== "expression";
- default:
- // Otherwise err on the side of overparenthesization, adding
- // explicit exceptions above if this proves overzealous.
- return true;
- }
- case "YieldExpression":
- switch (parent.type) {
- case "BinaryExpression":
- case "LogicalExpression":
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- case "CallExpression":
- case "MemberExpression":
- case "NewExpression":
- case "ConditionalExpression":
- case "YieldExpression":
- return true;
- default:
- return false;
- }
- case "Literal":
- return parent.type === "MemberExpression"
- && isNumber.check(node.value)
- && this.name === "object"
- && parent.object === node;
- case "AssignmentExpression":
- case "ConditionalExpression":
- switch (parent.type) {
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- case "BinaryExpression":
- case "LogicalExpression":
- return true;
- case "CallExpression":
- return this.name === "callee"
- && parent.callee === node;
- case "ConditionalExpression":
- return this.name === "test"
- && parent.test === node;
- case "MemberExpression":
- return this.name === "object"
- && parent.object === node;
- default:
- return false;
- }
- default:
- if (parent.type === "NewExpression" &&
- this.name === "callee" &&
- parent.callee === node) {
- return containsCallExpression(node);
- }
- }
- if (assumeExpressionContext !== true &&
- !this.canBeFirstInStatement() &&
- this.firstInStatement())
- return true;
- return false;
- };
- function isBinary(node) {
- return n.BinaryExpression.check(node)
- || n.LogicalExpression.check(node);
- }
- function isUnaryLike(node) {
- return n.UnaryExpression.check(node)
- // I considered making SpreadElement and SpreadProperty subtypes
- // of UnaryExpression, but they're not really Expression nodes.
- || (n.SpreadElement && n.SpreadElement.check(node))
- || (n.SpreadProperty && n.SpreadProperty.check(node));
- }
- var PRECEDENCE = {};
- [["||"],
- ["&&"],
- ["|"],
- ["^"],
- ["&"],
- ["==", "===", "!=", "!=="],
- ["<", ">", "<=", ">=", "in", "instanceof"],
- [">>", "<<", ">>>"],
- ["+", "-"],
- ["*", "/", "%"]
- ].forEach(function(tier, i) {
- tier.forEach(function(op) {
- PRECEDENCE[op] = i;
- });
- });
- function containsCallExpression(node) {
- if (n.CallExpression.check(node)) {
- return true;
- }
- if (isArray.check(node)) {
- return node.some(containsCallExpression);
- }
- if (n.Node.check(node)) {
- return types.someField(node, function(name, child) {
- return containsCallExpression(child);
- });
- }
- return false;
- }
- NPp.canBeFirstInStatement = function() {
- var node = this.node;
- return !n.FunctionExpression.check(node)
- && !n.ObjectExpression.check(node);
- };
- NPp.firstInStatement = function() {
- return firstInStatement(this);
- };
- function firstInStatement(path) {
- for (var node, parent; path.parent; path = path.parent) {
- node = path.node;
- parent = path.parent.node;
- if (n.BlockStatement.check(parent) &&
- path.parent.name === "body" &&
- path.name === 0) {
- assert.strictEqual(parent.body[0], node);
- return true;
- }
- if (n.ExpressionStatement.check(parent) &&
- path.name === "expression") {
- assert.strictEqual(parent.expression, node);
- return true;
- }
- if (n.SequenceExpression.check(parent) &&
- path.parent.name === "expressions" &&
- path.name === 0) {
- assert.strictEqual(parent.expressions[0], node);
- continue;
- }
- if (n.CallExpression.check(parent) &&
- path.name === "callee") {
- assert.strictEqual(parent.callee, node);
- continue;
- }
- if (n.MemberExpression.check(parent) &&
- path.name === "object") {
- assert.strictEqual(parent.object, node);
- continue;
- }
- if (n.ConditionalExpression.check(parent) &&
- path.name === "test") {
- assert.strictEqual(parent.test, node);
- continue;
- }
- if (isBinary(parent) &&
- path.name === "left") {
- assert.strictEqual(parent.left, node);
- continue;
- }
- if (n.UnaryExpression.check(parent) &&
- !parent.prefix &&
- path.name === "argument") {
- assert.strictEqual(parent.argument, node);
- continue;
- }
- return false;
- }
- return true;
- }
- /**
- * Pruning certain nodes will result in empty or incomplete nodes, here we clean those nodes up.
- */
- function cleanUpNodesAfterPrune(remainingNodePath) {
- if (n.VariableDeclaration.check(remainingNodePath.node)) {
- var declarations = remainingNodePath.get('declarations').value;
- if (!declarations || declarations.length === 0) {
- return remainingNodePath.prune();
- }
- } else if (n.ExpressionStatement.check(remainingNodePath.node)) {
- if (!remainingNodePath.get('expression').value) {
- return remainingNodePath.prune();
- }
- } else if (n.IfStatement.check(remainingNodePath.node)) {
- cleanUpIfStatementAfterPrune(remainingNodePath);
- }
- return remainingNodePath;
- }
- function cleanUpIfStatementAfterPrune(ifStatement) {
- var testExpression = ifStatement.get('test').value;
- var alternate = ifStatement.get('alternate').value;
- var consequent = ifStatement.get('consequent').value;
- if (!consequent && !alternate) {
- var testExpressionStatement = b.expressionStatement(testExpression);
- ifStatement.replace(testExpressionStatement);
- } else if (!consequent && alternate) {
- var negatedTestExpression = b.unaryExpression('!', testExpression, true);
- if (n.UnaryExpression.check(testExpression) && testExpression.operator === '!') {
- negatedTestExpression = testExpression.argument;
- }
- ifStatement.get("test").replace(negatedTestExpression);
- ifStatement.get("consequent").replace(alternate);
- ifStatement.get("alternate").replace();
- }
- }
- module.exports = NodePath;
- },{"./path":184,"./scope":185,"./types":187,"assert":190,"util":216}],183:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var NodePath = require("./node-path");
- var Printable = types.namedTypes.Printable;
- var isArray = types.builtInTypes.array;
- var isObject = types.builtInTypes.object;
- var isFunction = types.builtInTypes.function;
- var hasOwn = Object.prototype.hasOwnProperty;
- var undefined;
- function PathVisitor() {
- assert.ok(this instanceof PathVisitor);
- // Permanent state.
- this._reusableContextStack = [];
- this._methodNameTable = computeMethodNameTable(this);
- this._shouldVisitComments =
- hasOwn.call(this._methodNameTable, "Block") ||
- hasOwn.call(this._methodNameTable, "Line");
- this.Context = makeContextConstructor(this);
- // State reset every time PathVisitor.prototype.visit is called.
- this._visiting = false;
- this._changeReported = false;
- }
- function computeMethodNameTable(visitor) {
- var typeNames = Object.create(null);
- for (var methodName in visitor) {
- if (/^visit[A-Z]/.test(methodName)) {
- typeNames[methodName.slice("visit".length)] = true;
- }
- }
- var supertypeTable = types.computeSupertypeLookupTable(typeNames);
- var methodNameTable = Object.create(null);
- var typeNames = Object.keys(supertypeTable);
- var typeNameCount = typeNames.length;
- for (var i = 0; i < typeNameCount; ++i) {
- var typeName = typeNames[i];
- methodName = "visit" + supertypeTable[typeName];
- if (isFunction.check(visitor[methodName])) {
- methodNameTable[typeName] = methodName;
- }
- }
- return methodNameTable;
- }
- PathVisitor.fromMethodsObject = function fromMethodsObject(methods) {
- if (methods instanceof PathVisitor) {
- return methods;
- }
- if (!isObject.check(methods)) {
- // An empty visitor?
- return new PathVisitor;
- }
- function Visitor() {
- assert.ok(this instanceof Visitor);
- PathVisitor.call(this);
- }
- var Vp = Visitor.prototype = Object.create(PVp);
- Vp.constructor = Visitor;
- extend(Vp, methods);
- extend(Visitor, PathVisitor);
- isFunction.assert(Visitor.fromMethodsObject);
- isFunction.assert(Visitor.visit);
- return new Visitor;
- };
- function extend(target, source) {
- for (var property in source) {
- if (hasOwn.call(source, property)) {
- target[property] = source[property];
- }
- }
- return target;
- }
- PathVisitor.visit = function visit(node, methods) {
- return PathVisitor.fromMethodsObject(methods).visit(node);
- };
- var PVp = PathVisitor.prototype;
- var recursiveVisitWarning = [
- "Recursively calling visitor.visit(path) resets visitor state.",
- "Try this.visit(path) or this.traverse(path) instead."
- ].join(" ");
- PVp.visit = function() {
- assert.ok(!this._visiting, recursiveVisitWarning);
- // Private state that needs to be reset before every traversal.
- this._visiting = true;
- this._changeReported = false;
- this._abortRequested = false;
- var argc = arguments.length;
- var args = new Array(argc)
- for (var i = 0; i < argc; ++i) {
- args[i] = arguments[i];
- }
- if (!(args[0] instanceof NodePath)) {
- args[0] = new NodePath({ root: args[0] }).get("root");
- }
- // Called with the same arguments as .visit.
- this.reset.apply(this, args);
- try {
- var root = this.visitWithoutReset(args[0]);
- var didNotThrow = true;
- } finally {
- this._visiting = false;
- if (!didNotThrow && this._abortRequested) {
- // If this.visitWithoutReset threw an exception and
- // this._abortRequested was set to true, return the root of
- // the AST instead of letting the exception propagate, so that
- // client code does not have to provide a try-catch block to
- // intercept the AbortRequest exception. Other kinds of
- // exceptions will propagate without being intercepted and
- // rethrown by a catch block, so their stacks will accurately
- // reflect the original throwing context.
- return args[0].value;
- }
- }
- return root;
- };
- PVp.AbortRequest = function AbortRequest() {};
- PVp.abort = function() {
- var visitor = this;
- visitor._abortRequested = true;
- var request = new visitor.AbortRequest();
- // If you decide to catch this exception and stop it from propagating,
- // make sure to call its cancel method to avoid silencing other
- // exceptions that might be thrown later in the traversal.
- request.cancel = function() {
- visitor._abortRequested = false;
- };
- throw request;
- };
- PVp.reset = function(path/*, additional arguments */) {
- // Empty stub; may be reassigned or overridden by subclasses.
- };
- PVp.visitWithoutReset = function(path) {
- if (this instanceof this.Context) {
- // Since this.Context.prototype === this, there's a chance we
- // might accidentally call context.visitWithoutReset. If that
- // happens, re-invoke the method against context.visitor.
- return this.visitor.visitWithoutReset(path);
- }
- assert.ok(path instanceof NodePath);
- var value = path.value;
- var methodName = Printable.check(value) && this._methodNameTable[value.type];
- if (methodName) {
- var context = this.acquireContext(path);
- try {
- return context.invokeVisitorMethod(methodName);
- } finally {
- this.releaseContext(context);
- }
- } else {
- // If there was no visitor method to call, visit the children of
- // this node generically.
- return visitChildren(path, this);
- }
- };
- function visitChildren(path, visitor) {
- assert.ok(path instanceof NodePath);
- assert.ok(visitor instanceof PathVisitor);
- var value = path.value;
- if (isArray.check(value)) {
- path.each(visitor.visitWithoutReset, visitor);
- } else if (!isObject.check(value)) {
- // No children to visit.
- } else {
- var childNames = types.getFieldNames(value);
- // The .comments field of the Node type is hidden, so we only
- // visit it if the visitor defines visitBlock or visitLine, and
- // value.comments is defined.
- if (visitor._shouldVisitComments &&
- value.comments &&
- childNames.indexOf("comments") < 0) {
- childNames.push("comments");
- }
- var childCount = childNames.length;
- var childPaths = [];
- for (var i = 0; i < childCount; ++i) {
- var childName = childNames[i];
- if (!hasOwn.call(value, childName)) {
- value[childName] = types.getFieldValue(value, childName);
- }
- childPaths.push(path.get(childName));
- }
- for (var i = 0; i < childCount; ++i) {
- visitor.visitWithoutReset(childPaths[i]);
- }
- }
- return path.value;
- }
- PVp.acquireContext = function(path) {
- if (this._reusableContextStack.length === 0) {
- return new this.Context(path);
- }
- return this._reusableContextStack.pop().reset(path);
- };
- PVp.releaseContext = function(context) {
- assert.ok(context instanceof this.Context);
- this._reusableContextStack.push(context);
- context.currentPath = null;
- };
- PVp.reportChanged = function() {
- this._changeReported = true;
- };
- PVp.wasChangeReported = function() {
- return this._changeReported;
- };
- function makeContextConstructor(visitor) {
- function Context(path) {
- assert.ok(this instanceof Context);
- assert.ok(this instanceof PathVisitor);
- assert.ok(path instanceof NodePath);
- Object.defineProperty(this, "visitor", {
- value: visitor,
- writable: false,
- enumerable: true,
- configurable: false
- });
- this.currentPath = path;
- this.needToCallTraverse = true;
- Object.seal(this);
- }
- assert.ok(visitor instanceof PathVisitor);
- // Note that the visitor object is the prototype of Context.prototype,
- // so all visitor methods are inherited by context objects.
- var Cp = Context.prototype = Object.create(visitor);
- Cp.constructor = Context;
- extend(Cp, sharedContextProtoMethods);
- return Context;
- }
- // Every PathVisitor has a different this.Context constructor and
- // this.Context.prototype object, but those prototypes can all use the
- // same reset, invokeVisitorMethod, and traverse function objects.
- var sharedContextProtoMethods = Object.create(null);
- sharedContextProtoMethods.reset =
- function reset(path) {
- assert.ok(this instanceof this.Context);
- assert.ok(path instanceof NodePath);
- this.currentPath = path;
- this.needToCallTraverse = true;
- return this;
- };
- sharedContextProtoMethods.invokeVisitorMethod =
- function invokeVisitorMethod(methodName) {
- assert.ok(this instanceof this.Context);
- assert.ok(this.currentPath instanceof NodePath);
- var result = this.visitor[methodName].call(this, this.currentPath);
- if (result === false) {
- // Visitor methods return false to indicate that they have handled
- // their own traversal needs, and we should not complain if
- // this.needToCallTraverse is still true.
- this.needToCallTraverse = false;
- } else if (result !== undefined) {
- // Any other non-undefined value returned from the visitor method
- // is interpreted as a replacement value.
- this.currentPath = this.currentPath.replace(result)[0];
- if (this.needToCallTraverse) {
- // If this.traverse still hasn't been called, visit the
- // children of the replacement node.
- this.traverse(this.currentPath);
- }
- }
- assert.strictEqual(
- this.needToCallTraverse, false,
- "Must either call this.traverse or return false in " + methodName
- );
- var path = this.currentPath;
- return path && path.value;
- };
- sharedContextProtoMethods.traverse =
- function traverse(path, newVisitor) {
- assert.ok(this instanceof this.Context);
- assert.ok(path instanceof NodePath);
- assert.ok(this.currentPath instanceof NodePath);
- this.needToCallTraverse = false;
- return visitChildren(path, PathVisitor.fromMethodsObject(
- newVisitor || this.visitor
- ));
- };
- sharedContextProtoMethods.visit =
- function visit(path, newVisitor) {
- assert.ok(this instanceof this.Context);
- assert.ok(path instanceof NodePath);
- assert.ok(this.currentPath instanceof NodePath);
- this.needToCallTraverse = false;
- return PathVisitor.fromMethodsObject(
- newVisitor || this.visitor
- ).visitWithoutReset(path);
- };
- sharedContextProtoMethods.reportChanged = function reportChanged() {
- this.visitor.reportChanged();
- };
- sharedContextProtoMethods.abort = function abort() {
- this.needToCallTraverse = false;
- this.visitor.abort();
- };
- module.exports = PathVisitor;
- },{"./node-path":182,"./types":187,"assert":190}],184:[function(require,module,exports){
- var assert = require("assert");
- var Op = Object.prototype;
- var hasOwn = Op.hasOwnProperty;
- var types = require("./types");
- var isArray = types.builtInTypes.array;
- var isNumber = types.builtInTypes.number;
- var Ap = Array.prototype;
- var slice = Ap.slice;
- var map = Ap.map;
- function Path(value, parentPath, name) {
- assert.ok(this instanceof Path);
- if (parentPath) {
- assert.ok(parentPath instanceof Path);
- } else {
- parentPath = null;
- name = null;
- }
- // The value encapsulated by this Path, generally equal to
- // parentPath.value[name] if we have a parentPath.
- this.value = value;
- // The immediate parent Path of this Path.
- this.parentPath = parentPath;
- // The name of the property of parentPath.value through which this
- // Path's value was reached.
- this.name = name;
- // Calling path.get("child") multiple times always returns the same
- // child Path object, for both performance and consistency reasons.
- this.__childCache = null;
- }
- var Pp = Path.prototype;
- function getChildCache(path) {
- // Lazily create the child cache. This also cheapens cache
- // invalidation, since you can just reset path.__childCache to null.
- return path.__childCache || (path.__childCache = Object.create(null));
- }
- function getChildPath(path, name) {
- var cache = getChildCache(path);
- var actualChildValue = path.getValueProperty(name);
- var childPath = cache[name];
- if (!hasOwn.call(cache, name) ||
- // Ensure consistency between cache and reality.
- childPath.value !== actualChildValue) {
- childPath = cache[name] = new path.constructor(
- actualChildValue, path, name
- );
- }
- return childPath;
- }
- // This method is designed to be overridden by subclasses that need to
- // handle missing properties, etc.
- Pp.getValueProperty = function getValueProperty(name) {
- return this.value[name];
- };
- Pp.get = function get(name) {
- var path = this;
- var names = arguments;
- var count = names.length;
- for (var i = 0; i < count; ++i) {
- path = getChildPath(path, names[i]);
- }
- return path;
- };
- Pp.each = function each(callback, context) {
- var childPaths = [];
- var len = this.value.length;
- var i = 0;
- // Collect all the original child paths before invoking the callback.
- for (var i = 0; i < len; ++i) {
- if (hasOwn.call(this.value, i)) {
- childPaths[i] = this.get(i);
- }
- }
- // Invoke the callback on just the original child paths, regardless of
- // any modifications made to the array by the callback. I chose these
- // semantics over cleverly invoking the callback on new elements because
- // this way is much easier to reason about.
- context = context || this;
- for (i = 0; i < len; ++i) {
- if (hasOwn.call(childPaths, i)) {
- callback.call(context, childPaths[i]);
- }
- }
- };
- Pp.map = function map(callback, context) {
- var result = [];
- this.each(function(childPath) {
- result.push(callback.call(this, childPath));
- }, context);
- return result;
- };
- Pp.filter = function filter(callback, context) {
- var result = [];
- this.each(function(childPath) {
- if (callback.call(this, childPath)) {
- result.push(childPath);
- }
- }, context);
- return result;
- };
- function emptyMoves() {}
- function getMoves(path, offset, start, end) {
- isArray.assert(path.value);
- if (offset === 0) {
- return emptyMoves;
- }
- var length = path.value.length;
- if (length < 1) {
- return emptyMoves;
- }
- var argc = arguments.length;
- if (argc === 2) {
- start = 0;
- end = length;
- } else if (argc === 3) {
- start = Math.max(start, 0);
- end = length;
- } else {
- start = Math.max(start, 0);
- end = Math.min(end, length);
- }
- isNumber.assert(start);
- isNumber.assert(end);
- var moves = Object.create(null);
- var cache = getChildCache(path);
- for (var i = start; i < end; ++i) {
- if (hasOwn.call(path.value, i)) {
- var childPath = path.get(i);
- assert.strictEqual(childPath.name, i);
- var newIndex = i + offset;
- childPath.name = newIndex;
- moves[newIndex] = childPath;
- delete cache[i];
- }
- }
- delete cache.length;
- return function() {
- for (var newIndex in moves) {
- var childPath = moves[newIndex];
- assert.strictEqual(childPath.name, +newIndex);
- cache[newIndex] = childPath;
- path.value[newIndex] = childPath.value;
- }
- };
- }
- Pp.shift = function shift() {
- var move = getMoves(this, -1);
- var result = this.value.shift();
- move();
- return result;
- };
- Pp.unshift = function unshift(node) {
- var move = getMoves(this, arguments.length);
- var result = this.value.unshift.apply(this.value, arguments);
- move();
- return result;
- };
- Pp.push = function push(node) {
- isArray.assert(this.value);
- delete getChildCache(this).length
- return this.value.push.apply(this.value, arguments);
- };
- Pp.pop = function pop() {
- isArray.assert(this.value);
- var cache = getChildCache(this);
- delete cache[this.value.length - 1];
- delete cache.length;
- return this.value.pop();
- };
- Pp.insertAt = function insertAt(index, node) {
- var argc = arguments.length;
- var move = getMoves(this, argc - 1, index);
- if (move === emptyMoves) {
- return this;
- }
- index = Math.max(index, 0);
- for (var i = 1; i < argc; ++i) {
- this.value[index + i - 1] = arguments[i];
- }
- move();
- return this;
- };
- Pp.insertBefore = function insertBefore(node) {
- var pp = this.parentPath;
- var argc = arguments.length;
- var insertAtArgs = [this.name];
- for (var i = 0; i < argc; ++i) {
- insertAtArgs.push(arguments[i]);
- }
- return pp.insertAt.apply(pp, insertAtArgs);
- };
- Pp.insertAfter = function insertAfter(node) {
- var pp = this.parentPath;
- var argc = arguments.length;
- var insertAtArgs = [this.name + 1];
- for (var i = 0; i < argc; ++i) {
- insertAtArgs.push(arguments[i]);
- }
- return pp.insertAt.apply(pp, insertAtArgs);
- };
- function repairRelationshipWithParent(path) {
- assert.ok(path instanceof Path);
- var pp = path.parentPath;
- if (!pp) {
- // Orphan paths have no relationship to repair.
- return path;
- }
- var parentValue = pp.value;
- var parentCache = getChildCache(pp);
- // Make sure parentCache[path.name] is populated.
- if (parentValue[path.name] === path.value) {
- parentCache[path.name] = path;
- } else if (isArray.check(parentValue)) {
- // Something caused path.name to become out of date, so attempt to
- // recover by searching for path.value in parentValue.
- var i = parentValue.indexOf(path.value);
- if (i >= 0) {
- parentCache[path.name = i] = path;
- }
- } else {
- // If path.value disagrees with parentValue[path.name], and
- // path.name is not an array index, let path.value become the new
- // parentValue[path.name] and update parentCache accordingly.
- parentValue[path.name] = path.value;
- parentCache[path.name] = path;
- }
- assert.strictEqual(parentValue[path.name], path.value);
- assert.strictEqual(path.parentPath.get(path.name), path);
- return path;
- }
- Pp.replace = function replace(replacement) {
- var results = [];
- var parentValue = this.parentPath.value;
- var parentCache = getChildCache(this.parentPath);
- var count = arguments.length;
- repairRelationshipWithParent(this);
- if (isArray.check(parentValue)) {
- var originalLength = parentValue.length;
- var move = getMoves(this.parentPath, count - 1, this.name + 1);
- var spliceArgs = [this.name, 1];
- for (var i = 0; i < count; ++i) {
- spliceArgs.push(arguments[i]);
- }
- var splicedOut = parentValue.splice.apply(parentValue, spliceArgs);
- assert.strictEqual(splicedOut[0], this.value);
- assert.strictEqual(
- parentValue.length,
- originalLength - 1 + count
- );
- move();
- if (count === 0) {
- delete this.value;
- delete parentCache[this.name];
- this.__childCache = null;
- } else {
- assert.strictEqual(parentValue[this.name], replacement);
- if (this.value !== replacement) {
- this.value = replacement;
- this.__childCache = null;
- }
- for (i = 0; i < count; ++i) {
- results.push(this.parentPath.get(this.name + i));
- }
- assert.strictEqual(results[0], this);
- }
- } else if (count === 1) {
- if (this.value !== replacement) {
- this.__childCache = null;
- }
- this.value = parentValue[this.name] = replacement;
- results.push(this);
- } else if (count === 0) {
- delete parentValue[this.name];
- delete this.value;
- this.__childCache = null;
- // Leave this path cached as parentCache[this.name], even though
- // it no longer has a value defined.
- } else {
- assert.ok(false, "Could not replace path");
- }
- return results;
- };
- module.exports = Path;
- },{"./types":187,"assert":190}],185:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var Type = types.Type;
- var namedTypes = types.namedTypes;
- var Node = namedTypes.Node;
- var Expression = namedTypes.Expression;
- var isArray = types.builtInTypes.array;
- var hasOwn = Object.prototype.hasOwnProperty;
- var b = types.builders;
- function Scope(path, parentScope) {
- assert.ok(this instanceof Scope);
- assert.ok(path instanceof require("./node-path"));
- ScopeType.assert(path.value);
- var depth;
- if (parentScope) {
- assert.ok(parentScope instanceof Scope);
- depth = parentScope.depth + 1;
- } else {
- parentScope = null;
- depth = 0;
- }
- Object.defineProperties(this, {
- path: { value: path },
- node: { value: path.value },
- isGlobal: { value: !parentScope, enumerable: true },
- depth: { value: depth },
- parent: { value: parentScope },
- bindings: { value: {} }
- });
- }
- var scopeTypes = [
- // Program nodes introduce global scopes.
- namedTypes.Program,
- // Function is the supertype of FunctionExpression,
- // FunctionDeclaration, ArrowExpression, etc.
- namedTypes.Function,
- // In case you didn't know, the caught parameter shadows any variable
- // of the same name in an outer scope.
- namedTypes.CatchClause
- ];
- var ScopeType = Type.or.apply(Type, scopeTypes);
- Scope.isEstablishedBy = function(node) {
- return ScopeType.check(node);
- };
- var Sp = Scope.prototype;
- // Will be overridden after an instance lazily calls scanScope.
- Sp.didScan = false;
- Sp.declares = function(name) {
- this.scan();
- return hasOwn.call(this.bindings, name);
- };
- Sp.declareTemporary = function(prefix) {
- if (prefix) {
- assert.ok(/^[a-z$_]/i.test(prefix), prefix);
- } else {
- prefix = "t$";
- }
- // Include this.depth in the name to make sure the name does not
- // collide with any variables in nested/enclosing scopes.
- prefix += this.depth.toString(36) + "$";
- this.scan();
- var index = 0;
- while (this.declares(prefix + index)) {
- ++index;
- }
- var name = prefix + index;
- return this.bindings[name] = types.builders.identifier(name);
- };
- Sp.injectTemporary = function(identifier, init) {
- identifier || (identifier = this.declareTemporary());
- var bodyPath = this.path.get("body");
- if (namedTypes.BlockStatement.check(bodyPath.value)) {
- bodyPath = bodyPath.get("body");
- }
- bodyPath.unshift(
- b.variableDeclaration(
- "var",
- [b.variableDeclarator(identifier, init || null)]
- )
- );
- return identifier;
- };
- Sp.scan = function(force) {
- if (force || !this.didScan) {
- for (var name in this.bindings) {
- // Empty out this.bindings, just in cases.
- delete this.bindings[name];
- }
- scanScope(this.path, this.bindings);
- this.didScan = true;
- }
- };
- Sp.getBindings = function () {
- this.scan();
- return this.bindings;
- };
- function scanScope(path, bindings) {
- var node = path.value;
- ScopeType.assert(node);
- if (namedTypes.CatchClause.check(node)) {
- // A catch clause establishes a new scope but the only variable
- // bound in that scope is the catch parameter. Any other
- // declarations create bindings in the outer scope.
- addPattern(path.get("param"), bindings);
- } else {
- recursiveScanScope(path, bindings);
- }
- }
- function recursiveScanScope(path, bindings) {
- var node = path.value;
- if (path.parent &&
- namedTypes.FunctionExpression.check(path.parent.node) &&
- path.parent.node.id) {
- addPattern(path.parent.get("id"), bindings);
- }
- if (!node) {
- // None of the remaining cases matter if node is falsy.
- } else if (isArray.check(node)) {
- path.each(function(childPath) {
- recursiveScanChild(childPath, bindings);
- });
- } else if (namedTypes.Function.check(node)) {
- path.get("params").each(function(paramPath) {
- addPattern(paramPath, bindings);
- });
- recursiveScanChild(path.get("body"), bindings);
- } else if (namedTypes.VariableDeclarator.check(node)) {
- addPattern(path.get("id"), bindings);
- recursiveScanChild(path.get("init"), bindings);
- } else if (node.type === "ImportSpecifier" ||
- node.type === "ImportNamespaceSpecifier" ||
- node.type === "ImportDefaultSpecifier") {
- addPattern(
- // Esprima used to use the .name field to refer to the local
- // binding identifier for ImportSpecifier nodes, but .id for
- // ImportNamespaceSpecifier and ImportDefaultSpecifier nodes.
- // ESTree/Acorn/ESpree use .local for all three node types.
- path.get(node.local ? "local" :
- node.name ? "name" : "id"),
- bindings
- );
- } else if (Node.check(node) && !Expression.check(node)) {
- types.eachField(node, function(name, child) {
- var childPath = path.get(name);
- assert.strictEqual(childPath.value, child);
- recursiveScanChild(childPath, bindings);
- });
- }
- }
- function recursiveScanChild(path, bindings) {
- var node = path.value;
- if (!node || Expression.check(node)) {
- // Ignore falsy values and Expressions.
- } else if (namedTypes.FunctionDeclaration.check(node)) {
- addPattern(path.get("id"), bindings);
- } else if (namedTypes.ClassDeclaration &&
- namedTypes.ClassDeclaration.check(node)) {
- addPattern(path.get("id"), bindings);
- } else if (ScopeType.check(node)) {
- if (namedTypes.CatchClause.check(node)) {
- var catchParamName = node.param.name;
- var hadBinding = hasOwn.call(bindings, catchParamName);
- // Any declarations that occur inside the catch body that do
- // not have the same name as the catch parameter should count
- // as bindings in the outer scope.
- recursiveScanScope(path.get("body"), bindings);
- // If a new binding matching the catch parameter name was
- // created while scanning the catch body, ignore it because it
- // actually refers to the catch parameter and not the outer
- // scope that we're currently scanning.
- if (!hadBinding) {
- delete bindings[catchParamName];
- }
- }
- } else {
- recursiveScanScope(path, bindings);
- }
- }
- function addPattern(patternPath, bindings) {
- var pattern = patternPath.value;
- namedTypes.Pattern.assert(pattern);
- if (namedTypes.Identifier.check(pattern)) {
- if (hasOwn.call(bindings, pattern.name)) {
- bindings[pattern.name].push(patternPath);
- } else {
- bindings[pattern.name] = [patternPath];
- }
- } else if (namedTypes.ObjectPattern &&
- namedTypes.ObjectPattern.check(pattern)) {
- patternPath.get('properties').each(function(propertyPath) {
- var property = propertyPath.value;
- if (namedTypes.Pattern.check(property)) {
- addPattern(propertyPath, bindings);
- } else if (namedTypes.Property.check(property)) {
- addPattern(propertyPath.get('value'), bindings);
- } else if (namedTypes.SpreadProperty &&
- namedTypes.SpreadProperty.check(property)) {
- addPattern(propertyPath.get('argument'), bindings);
- }
- });
- } else if (namedTypes.ArrayPattern &&
- namedTypes.ArrayPattern.check(pattern)) {
- patternPath.get('elements').each(function(elementPath) {
- var element = elementPath.value;
- if (namedTypes.Pattern.check(element)) {
- addPattern(elementPath, bindings);
- } else if (namedTypes.SpreadElement &&
- namedTypes.SpreadElement.check(element)) {
- addPattern(elementPath.get("argument"), bindings);
- }
- });
- } else if (namedTypes.PropertyPattern &&
- namedTypes.PropertyPattern.check(pattern)) {
- addPattern(patternPath.get('pattern'), bindings);
- } else if ((namedTypes.SpreadElementPattern &&
- namedTypes.SpreadElementPattern.check(pattern)) ||
- (namedTypes.SpreadPropertyPattern &&
- namedTypes.SpreadPropertyPattern.check(pattern))) {
- addPattern(patternPath.get('argument'), bindings);
- }
- }
- Sp.lookup = function(name) {
- for (var scope = this; scope; scope = scope.parent)
- if (scope.declares(name))
- break;
- return scope;
- };
- Sp.getGlobalScope = function() {
- var scope = this;
- while (!scope.isGlobal)
- scope = scope.parent;
- return scope;
- };
- module.exports = Scope;
- },{"./node-path":182,"./types":187,"assert":190}],186:[function(require,module,exports){
- var types = require("../lib/types");
- var Type = types.Type;
- var builtin = types.builtInTypes;
- var isNumber = builtin.number;
- // An example of constructing a new type with arbitrary constraints from
- // an existing type.
- exports.geq = function(than) {
- return new Type(function(value) {
- return isNumber.check(value) && value >= than;
- }, isNumber + " >= " + than);
- };
- // Default value-returning functions that may optionally be passed as a
- // third argument to Def.prototype.field.
- exports.defaults = {
- // Functions were used because (among other reasons) that's the most
- // elegant way to allow for the emptyArray one always to give a new
- // array instance.
- "null": function() { return null },
- "emptyArray": function() { return [] },
- "false": function() { return false },
- "true": function() { return true },
- "undefined": function() {}
- };
- var naiveIsPrimitive = Type.or(
- builtin.string,
- builtin.number,
- builtin.boolean,
- builtin.null,
- builtin.undefined
- );
- exports.isPrimitive = new Type(function(value) {
- if (value === null)
- return true;
- var type = typeof value;
- return !(type === "object" ||
- type === "function");
- }, naiveIsPrimitive.toString());
- },{"../lib/types":187}],187:[function(require,module,exports){
- var assert = require("assert");
- var Ap = Array.prototype;
- var slice = Ap.slice;
- var map = Ap.map;
- var each = Ap.forEach;
- var Op = Object.prototype;
- var objToStr = Op.toString;
- var funObjStr = objToStr.call(function(){});
- var strObjStr = objToStr.call("");
- var hasOwn = Op.hasOwnProperty;
- // A type is an object with a .check method that takes a value and returns
- // true or false according to whether the value matches the type.
- function Type(check, name) {
- var self = this;
- assert.ok(self instanceof Type, self);
- // Unfortunately we can't elegantly reuse isFunction and isString,
- // here, because this code is executed while defining those types.
- assert.strictEqual(objToStr.call(check), funObjStr,
- check + " is not a function");
- // The `name` parameter can be either a function or a string.
- var nameObjStr = objToStr.call(name);
- assert.ok(nameObjStr === funObjStr ||
- nameObjStr === strObjStr,
- name + " is neither a function nor a string");
- Object.defineProperties(self, {
- name: { value: name },
- check: {
- value: function(value, deep) {
- var result = check.call(self, value, deep);
- if (!result && deep && objToStr.call(deep) === funObjStr)
- deep(self, value);
- return result;
- }
- }
- });
- }
- var Tp = Type.prototype;
- // Throughout this file we use Object.defineProperty to prevent
- // redefinition of exported properties.
- exports.Type = Type;
- // Like .check, except that failure triggers an AssertionError.
- Tp.assert = function(value, deep) {
- if (!this.check(value, deep)) {
- var str = shallowStringify(value);
- assert.ok(false, str + " does not match type " + this);
- return false;
- }
- return true;
- };
- function shallowStringify(value) {
- if (isObject.check(value))
- return "{" + Object.keys(value).map(function(key) {
- return key + ": " + value[key];
- }).join(", ") + "}";
- if (isArray.check(value))
- return "[" + value.map(shallowStringify).join(", ") + "]";
- return JSON.stringify(value);
- }
- Tp.toString = function() {
- var name = this.name;
- if (isString.check(name))
- return name;
- if (isFunction.check(name))
- return name.call(this) + "";
- return name + " type";
- };
- var builtInTypes = {};
- exports.builtInTypes = builtInTypes;
- function defBuiltInType(example, name) {
- var objStr = objToStr.call(example);
- Object.defineProperty(builtInTypes, name, {
- enumerable: true,
- value: new Type(function(value) {
- return objToStr.call(value) === objStr;
- }, name)
- });
- return builtInTypes[name];
- }
- // These types check the underlying [[Class]] attribute of the given
- // value, rather than using the problematic typeof operator. Note however
- // that no subtyping is considered; so, for instance, isObject.check
- // returns false for [], /./, new Date, and null.
- var isString = defBuiltInType("", "string");
- var isFunction = defBuiltInType(function(){}, "function");
- var isArray = defBuiltInType([], "array");
- var isObject = defBuiltInType({}, "object");
- var isRegExp = defBuiltInType(/./, "RegExp");
- var isDate = defBuiltInType(new Date, "Date");
- var isNumber = defBuiltInType(3, "number");
- var isBoolean = defBuiltInType(true, "boolean");
- var isNull = defBuiltInType(null, "null");
- var isUndefined = defBuiltInType(void 0, "undefined");
- // There are a number of idiomatic ways of expressing types, so this
- // function serves to coerce them all to actual Type objects. Note that
- // providing the name argument is not necessary in most cases.
- function toType(from, name) {
- // The toType function should of course be idempotent.
- if (from instanceof Type)
- return from;
- // The Def type is used as a helper for constructing compound
- // interface types for AST nodes.
- if (from instanceof Def)
- return from.type;
- // Support [ElemType] syntax.
- if (isArray.check(from))
- return Type.fromArray(from);
- // Support { someField: FieldType, ... } syntax.
- if (isObject.check(from))
- return Type.fromObject(from);
- // If isFunction.check(from), assume that from is a binary predicate
- // function we can use to define the type.
- if (isFunction.check(from))
- return new Type(from, name);
- // As a last resort, toType returns a type that matches any value that
- // is === from. This is primarily useful for literal values like
- // toType(null), but it has the additional advantage of allowing
- // toType to be a total function.
- return new Type(function(value) {
- return value === from;
- }, isUndefined.check(name) ? function() {
- return from + "";
- } : name);
- }
- // Returns a type that matches the given value iff any of type1, type2,
- // etc. match the value.
- Type.or = function(/* type1, type2, ... */) {
- var types = [];
- var len = arguments.length;
- for (var i = 0; i < len; ++i)
- types.push(toType(arguments[i]));
- return new Type(function(value, deep) {
- for (var i = 0; i < len; ++i)
- if (types[i].check(value, deep))
- return true;
- return false;
- }, function() {
- return types.join(" | ");
- });
- };
- Type.fromArray = function(arr) {
- assert.ok(isArray.check(arr));
- assert.strictEqual(
- arr.length, 1,
- "only one element type is permitted for typed arrays");
- return toType(arr[0]).arrayOf();
- };
- Tp.arrayOf = function() {
- var elemType = this;
- return new Type(function(value, deep) {
- return isArray.check(value) && value.every(function(elem) {
- return elemType.check(elem, deep);
- });
- }, function() {
- return "[" + elemType + "]";
- });
- };
- Type.fromObject = function(obj) {
- var fields = Object.keys(obj).map(function(name) {
- return new Field(name, obj[name]);
- });
- return new Type(function(value, deep) {
- return isObject.check(value) && fields.every(function(field) {
- return field.type.check(value[field.name], deep);
- });
- }, function() {
- return "{ " + fields.join(", ") + " }";
- });
- };
- function Field(name, type, defaultFn, hidden) {
- var self = this;
- assert.ok(self instanceof Field);
- isString.assert(name);
- type = toType(type);
- var properties = {
- name: { value: name },
- type: { value: type },
- hidden: { value: !!hidden }
- };
- if (isFunction.check(defaultFn)) {
- properties.defaultFn = { value: defaultFn };
- }
- Object.defineProperties(self, properties);
- }
- var Fp = Field.prototype;
- Fp.toString = function() {
- return JSON.stringify(this.name) + ": " + this.type;
- };
- Fp.getValue = function(obj) {
- var value = obj[this.name];
- if (!isUndefined.check(value))
- return value;
- if (this.defaultFn)
- value = this.defaultFn.call(obj);
- return value;
- };
- // Define a type whose name is registered in a namespace (the defCache) so
- // that future definitions will return the same type given the same name.
- // In particular, this system allows for circular and forward definitions.
- // The Def object d returned from Type.def may be used to configure the
- // type d.type by calling methods such as d.bases, d.build, and d.field.
- Type.def = function(typeName) {
- isString.assert(typeName);
- return hasOwn.call(defCache, typeName)
- ? defCache[typeName]
- : defCache[typeName] = new Def(typeName);
- };
- // In order to return the same Def instance every time Type.def is called
- // with a particular name, those instances need to be stored in a cache.
- var defCache = Object.create(null);
- function Def(typeName) {
- var self = this;
- assert.ok(self instanceof Def);
- Object.defineProperties(self, {
- typeName: { value: typeName },
- baseNames: { value: [] },
- ownFields: { value: Object.create(null) },
- // These two are populated during finalization.
- allSupertypes: { value: Object.create(null) }, // Includes own typeName.
- supertypeList: { value: [] }, // Linear inheritance hierarchy.
- allFields: { value: Object.create(null) }, // Includes inherited fields.
- fieldNames: { value: [] }, // Non-hidden keys of allFields.
- type: {
- value: new Type(function(value, deep) {
- return self.check(value, deep);
- }, typeName)
- }
- });
- }
- Def.fromValue = function(value) {
- if (value && typeof value === "object") {
- var type = value.type;
- if (typeof type === "string" &&
- hasOwn.call(defCache, type)) {
- var d = defCache[type];
- if (d.finalized) {
- return d;
- }
- }
- }
- return null;
- };
- var Dp = Def.prototype;
- Dp.isSupertypeOf = function(that) {
- if (that instanceof Def) {
- assert.strictEqual(this.finalized, true);
- assert.strictEqual(that.finalized, true);
- return hasOwn.call(that.allSupertypes, this.typeName);
- } else {
- assert.ok(false, that + " is not a Def");
- }
- };
- // Note that the list returned by this function is a copy of the internal
- // supertypeList, *without* the typeName itself as the first element.
- exports.getSupertypeNames = function(typeName) {
- assert.ok(hasOwn.call(defCache, typeName));
- var d = defCache[typeName];
- assert.strictEqual(d.finalized, true);
- return d.supertypeList.slice(1);
- };
- // Returns an object mapping from every known type in the defCache to the
- // most specific supertype whose name is an own property of the candidates
- // object.
- exports.computeSupertypeLookupTable = function(candidates) {
- var table = {};
- var typeNames = Object.keys(defCache);
- var typeNameCount = typeNames.length;
- for (var i = 0; i < typeNameCount; ++i) {
- var typeName = typeNames[i];
- var d = defCache[typeName];
- assert.strictEqual(d.finalized, true);
- for (var j = 0; j < d.supertypeList.length; ++j) {
- var superTypeName = d.supertypeList[j];
- if (hasOwn.call(candidates, superTypeName)) {
- table[typeName] = superTypeName;
- break;
- }
- }
- }
- return table;
- };
- Dp.checkAllFields = function(value, deep) {
- var allFields = this.allFields;
- assert.strictEqual(this.finalized, true);
- function checkFieldByName(name) {
- var field = allFields[name];
- var type = field.type;
- var child = field.getValue(value);
- return type.check(child, deep);
- }
- return isObject.check(value)
- && Object.keys(allFields).every(checkFieldByName);
- };
- Dp.check = function(value, deep) {
- assert.strictEqual(
- this.finalized, true,
- "prematurely checking unfinalized type " + this.typeName);
- // A Def type can only match an object value.
- if (!isObject.check(value))
- return false;
- var vDef = Def.fromValue(value);
- if (!vDef) {
- // If we couldn't infer the Def associated with the given value,
- // and we expected it to be a SourceLocation or a Position, it was
- // probably just missing a "type" field (because Esprima does not
- // assign a type property to such nodes). Be optimistic and let
- // this.checkAllFields make the final decision.
- if (this.typeName === "SourceLocation" ||
- this.typeName === "Position") {
- return this.checkAllFields(value, deep);
- }
- // Calling this.checkAllFields for any other type of node is both
- // bad for performance and way too forgiving.
- return false;
- }
- // If checking deeply and vDef === this, then we only need to call
- // checkAllFields once. Calling checkAllFields is too strict when deep
- // is false, because then we only care about this.isSupertypeOf(vDef).
- if (deep && vDef === this)
- return this.checkAllFields(value, deep);
- // In most cases we rely exclusively on isSupertypeOf to make O(1)
- // subtyping determinations. This suffices in most situations outside
- // of unit tests, since interface conformance is checked whenever new
- // instances are created using builder functions.
- if (!this.isSupertypeOf(vDef))
- return false;
- // The exception is when deep is true; then, we recursively check all
- // fields.
- if (!deep)
- return true;
- // Use the more specific Def (vDef) to perform the deep check, but
- // shallow-check fields defined by the less specific Def (this).
- return vDef.checkAllFields(value, deep)
- && this.checkAllFields(value, false);
- };
- Dp.bases = function() {
- var bases = this.baseNames;
- assert.strictEqual(this.finalized, false);
- each.call(arguments, function(baseName) {
- isString.assert(baseName);
- // This indexOf lookup may be O(n), but the typical number of base
- // names is very small, and indexOf is a native Array method.
- if (bases.indexOf(baseName) < 0)
- bases.push(baseName);
- });
- return this; // For chaining.
- };
- // False by default until .build(...) is called on an instance.
- Object.defineProperty(Dp, "buildable", { value: false });
- var builders = {};
- exports.builders = builders;
- // This object is used as prototype for any node created by a builder.
- var nodePrototype = {};
- // Call this function to define a new method to be shared by all AST
- // nodes. The replaced method (if any) is returned for easy wrapping.
- exports.defineMethod = function(name, func) {
- var old = nodePrototype[name];
- // Pass undefined as func to delete nodePrototype[name].
- if (isUndefined.check(func)) {
- delete nodePrototype[name];
- } else {
- isFunction.assert(func);
- Object.defineProperty(nodePrototype, name, {
- enumerable: true, // For discoverability.
- configurable: true, // For delete proto[name].
- value: func
- });
- }
- return old;
- };
- // Calling the .build method of a Def simultaneously marks the type as
- // buildable (by defining builders[getBuilderName(typeName)]) and
- // specifies the order of arguments that should be passed to the builder
- // function to create an instance of the type.
- Dp.build = function(/* param1, param2, ... */) {
- var self = this;
- // Calling Def.prototype.build multiple times has the effect of merely
- // redefining this property.
- Object.defineProperty(self, "buildParams", {
- value: slice.call(arguments),
- writable: false,
- enumerable: false,
- configurable: true
- });
- assert.strictEqual(self.finalized, false);
- isString.arrayOf().assert(self.buildParams);
- if (self.buildable) {
- // If this Def is already buildable, update self.buildParams and
- // continue using the old builder function.
- return self;
- }
- // Every buildable type will have its "type" field filled in
- // automatically. This includes types that are not subtypes of Node,
- // like SourceLocation, but that seems harmless (TODO?).
- self.field("type", self.typeName, function() { return self.typeName });
- // Override Dp.buildable for this Def instance.
- Object.defineProperty(self, "buildable", { value: true });
- Object.defineProperty(builders, getBuilderName(self.typeName), {
- enumerable: true,
- value: function() {
- var args = arguments;
- var argc = args.length;
- var built = Object.create(nodePrototype);
- assert.ok(
- self.finalized,
- "attempting to instantiate unfinalized type " + self.typeName);
- function add(param, i) {
- if (hasOwn.call(built, param))
- return;
- var all = self.allFields;
- assert.ok(hasOwn.call(all, param), param);
- var field = all[param];
- var type = field.type;
- var value;
- if (isNumber.check(i) && i < argc) {
- value = args[i];
- } else if (field.defaultFn) {
- // Expose the partially-built object to the default
- // function as its `this` object.
- value = field.defaultFn.call(built);
- } else {
- var message = "no value or default function given for field " +
- JSON.stringify(param) + " of " + self.typeName + "(" +
- self.buildParams.map(function(name) {
- return all[name];
- }).join(", ") + ")";
- assert.ok(false, message);
- }
- if (!type.check(value)) {
- assert.ok(
- false,
- shallowStringify(value) +
- " does not match field " + field +
- " of type " + self.typeName
- );
- }
- // TODO Could attach getters and setters here to enforce
- // dynamic type safety.
- built[param] = value;
- }
- self.buildParams.forEach(function(param, i) {
- add(param, i);
- });
- Object.keys(self.allFields).forEach(function(param) {
- add(param); // Use the default value.
- });
- // Make sure that the "type" field was filled automatically.
- assert.strictEqual(built.type, self.typeName);
- return built;
- }
- });
- return self; // For chaining.
- };
- function getBuilderName(typeName) {
- return typeName.replace(/^[A-Z]+/, function(upperCasePrefix) {
- var len = upperCasePrefix.length;
- switch (len) {
- case 0: return "";
- // If there's only one initial capital letter, just lower-case it.
- case 1: return upperCasePrefix.toLowerCase();
- default:
- // If there's more than one initial capital letter, lower-case
- // all but the last one, so that XMLDefaultDeclaration (for
- // example) becomes xmlDefaultDeclaration.
- return upperCasePrefix.slice(
- 0, len - 1).toLowerCase() +
- upperCasePrefix.charAt(len - 1);
- }
- });
- }
- // The reason fields are specified using .field(...) instead of an object
- // literal syntax is somewhat subtle: the object literal syntax would
- // support only one key and one value, but with .field(...) we can pass
- // any number of arguments to specify the field.
- Dp.field = function(name, type, defaultFn, hidden) {
- assert.strictEqual(this.finalized, false);
- this.ownFields[name] = new Field(name, type, defaultFn, hidden);
- return this; // For chaining.
- };
- var namedTypes = {};
- exports.namedTypes = namedTypes;
- // Like Object.keys, but aware of what fields each AST type should have.
- function getFieldNames(object) {
- var d = Def.fromValue(object);
- if (d) {
- return d.fieldNames.slice(0);
- }
- if ("type" in object) {
- assert.ok(
- false,
- "did not recognize object of type " +
- JSON.stringify(object.type)
- );
- }
- return Object.keys(object);
- }
- exports.getFieldNames = getFieldNames;
- // Get the value of an object property, taking object.type and default
- // functions into account.
- function getFieldValue(object, fieldName) {
- var d = Def.fromValue(object);
- if (d) {
- var field = d.allFields[fieldName];
- if (field) {
- return field.getValue(object);
- }
- }
- return object[fieldName];
- }
- exports.getFieldValue = getFieldValue;
- // Iterate over all defined fields of an object, including those missing
- // or undefined, passing each field name and effective value (as returned
- // by getFieldValue) to the callback. If the object has no corresponding
- // Def, the callback will never be called.
- exports.eachField = function(object, callback, context) {
- getFieldNames(object).forEach(function(name) {
- callback.call(this, name, getFieldValue(object, name));
- }, context);
- };
- // Similar to eachField, except that iteration stops as soon as the
- // callback returns a truthy value. Like Array.prototype.some, the final
- // result is either true or false to indicates whether the callback
- // returned true for any element or not.
- exports.someField = function(object, callback, context) {
- return getFieldNames(object).some(function(name) {
- return callback.call(this, name, getFieldValue(object, name));
- }, context);
- };
- // This property will be overridden as true by individual Def instances
- // when they are finalized.
- Object.defineProperty(Dp, "finalized", { value: false });
- Dp.finalize = function() {
- // It's not an error to finalize a type more than once, but only the
- // first call to .finalize does anything.
- if (!this.finalized) {
- var allFields = this.allFields;
- var allSupertypes = this.allSupertypes;
- this.baseNames.forEach(function(name) {
- var def = defCache[name];
- def.finalize();
- extend(allFields, def.allFields);
- extend(allSupertypes, def.allSupertypes);
- });
- // TODO Warn if fields are overridden with incompatible types.
- extend(allFields, this.ownFields);
- allSupertypes[this.typeName] = this;
- this.fieldNames.length = 0;
- for (var fieldName in allFields) {
- if (hasOwn.call(allFields, fieldName) &&
- !allFields[fieldName].hidden) {
- this.fieldNames.push(fieldName);
- }
- }
- // Types are exported only once they have been finalized.
- Object.defineProperty(namedTypes, this.typeName, {
- enumerable: true,
- value: this.type
- });
- Object.defineProperty(this, "finalized", { value: true });
- // A linearization of the inheritance hierarchy.
- populateSupertypeList(this.typeName, this.supertypeList);
- }
- };
- function populateSupertypeList(typeName, list) {
- list.length = 0;
- list.push(typeName);
- var lastSeen = Object.create(null);
- for (var pos = 0; pos < list.length; ++pos) {
- typeName = list[pos];
- var d = defCache[typeName];
- assert.strictEqual(d.finalized, true);
- // If we saw typeName earlier in the breadth-first traversal,
- // delete the last-seen occurrence.
- if (hasOwn.call(lastSeen, typeName)) {
- delete list[lastSeen[typeName]];
- }
- // Record the new index of the last-seen occurrence of typeName.
- lastSeen[typeName] = pos;
- // Enqueue the base names of this type.
- list.push.apply(list, d.baseNames);
- }
- // Compaction loop to remove array holes.
- for (var to = 0, from = to, len = list.length; from < len; ++from) {
- if (hasOwn.call(list, from)) {
- list[to++] = list[from];
- }
- }
- list.length = to;
- }
- function extend(into, from) {
- Object.keys(from).forEach(function(name) {
- into[name] = from[name];
- });
- return into;
- };
- exports.finalize = function() {
- Object.keys(defCache).forEach(function(name) {
- defCache[name].finalize();
- });
- };
- },{"assert":190}],188:[function(require,module,exports){
- var types = require("./lib/types");
- // This core module of AST types captures ES5 as it is parsed today by
- // git://github.com/ariya/esprima.git#master.
- require("./def/core");
- // Feel free to add to or remove from this list of extension modules to
- // configure the precise type hierarchy that you need.
- require("./def/es6");
- require("./def/es7");
- require("./def/mozilla");
- require("./def/e4x");
- require("./def/fb-harmony");
- types.finalize();
- exports.Type = types.Type;
- exports.builtInTypes = types.builtInTypes;
- exports.namedTypes = types.namedTypes;
- exports.builders = types.builders;
- exports.defineMethod = types.defineMethod;
- exports.getFieldNames = types.getFieldNames;
- exports.getFieldValue = types.getFieldValue;
- exports.eachField = types.eachField;
- exports.someField = types.someField;
- exports.getSupertypeNames = types.getSupertypeNames;
- exports.astNodesAreEquivalent = require("./lib/equiv");
- exports.finalize = types.finalize;
- exports.NodePath = require("./lib/node-path");
- exports.PathVisitor = require("./lib/path-visitor");
- exports.visit = exports.PathVisitor.visit;
- },{"./def/core":175,"./def/e4x":176,"./def/es6":177,"./def/es7":178,"./def/fb-harmony":179,"./def/mozilla":180,"./lib/equiv":181,"./lib/node-path":182,"./lib/path-visitor":183,"./lib/types":187}],189:[function(require,module,exports){
- },{}],190:[function(require,module,exports){
- // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
- //
- // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
- //
- // Originally from narwhal.js (http://narwhaljs.org)
- // Copyright (c) 2009 Thomas Robinson <280north.com>
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the 'Software'), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- // when used in node, this will actually load the util module we depend on
- // versus loading the builtin util module as happens otherwise
- // this is a bug in node module loading as far as I am concerned
- var util = require('util/');
- var pSlice = Array.prototype.slice;
- var hasOwn = Object.prototype.hasOwnProperty;
- // 1. The assert module provides functions that throw
- // AssertionError's when particular conditions are not met. The
- // assert module must conform to the following interface.
- var assert = module.exports = ok;
- // 2. The AssertionError is defined in assert.
- // new assert.AssertionError({ message: message,
- // actual: actual,
- // expected: expected })
- assert.AssertionError = function AssertionError(options) {
- this.name = 'AssertionError';
- this.actual = options.actual;
- this.expected = options.expected;
- this.operator = options.operator;
- if (options.message) {
- this.message = options.message;
- this.generatedMessage = false;
- } else {
- this.message = getMessage(this);
- this.generatedMessage = true;
- }
- var stackStartFunction = options.stackStartFunction || fail;
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, stackStartFunction);
- }
- else {
- // non v8 browsers so we can have a stacktrace
- var err = new Error();
- if (err.stack) {
- var out = err.stack;
- // try to strip useless frames
- var fn_name = stackStartFunction.name;
- var idx = out.indexOf('\n' + fn_name);
- if (idx >= 0) {
- // once we have located the function frame
- // we need to strip out everything before it (and its line)
- var next_line = out.indexOf('\n', idx + 1);
- out = out.substring(next_line + 1);
- }
- this.stack = out;
- }
- }
- };
- // assert.AssertionError instanceof Error
- util.inherits(assert.AssertionError, Error);
- function replacer(key, value) {
- if (util.isUndefined(value)) {
- return '' + value;
- }
- if (util.isNumber(value) && !isFinite(value)) {
- return value.toString();
- }
- if (util.isFunction(value) || util.isRegExp(value)) {
- return value.toString();
- }
- return value;
- }
- function truncate(s, n) {
- if (util.isString(s)) {
- return s.length < n ? s : s.slice(0, n);
- } else {
- return s;
- }
- }
- function getMessage(self) {
- return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
- self.operator + ' ' +
- truncate(JSON.stringify(self.expected, replacer), 128);
- }
- // At present only the three keys mentioned above are used and
- // understood by the spec. Implementations or sub modules can pass
- // other keys to the AssertionError's constructor - they will be
- // ignored.
- // 3. All of the following functions must throw an AssertionError
- // when a corresponding condition is not met, with a message that
- // may be undefined if not provided. All assertion methods provide
- // both the actual and expected values to the assertion error for
- // display purposes.
- function fail(actual, expected, message, operator, stackStartFunction) {
- throw new assert.AssertionError({
- message: message,
- actual: actual,
- expected: expected,
- operator: operator,
- stackStartFunction: stackStartFunction
- });
- }
- // EXTENSION! allows for well behaved errors defined elsewhere.
- assert.fail = fail;
- // 4. Pure assertion tests whether a value is truthy, as determined
- // by !!guard.
- // assert.ok(guard, message_opt);
- // This statement is equivalent to assert.equal(true, !!guard,
- // message_opt);. To test strictly for the value true, use
- // assert.strictEqual(true, guard, message_opt);.
- function ok(value, message) {
- if (!value) fail(value, true, message, '==', assert.ok);
- }
- assert.ok = ok;
- // 5. The equality assertion tests shallow, coercive equality with
- // ==.
- // assert.equal(actual, expected, message_opt);
- assert.equal = function equal(actual, expected, message) {
- if (actual != expected) fail(actual, expected, message, '==', assert.equal);
- };
- // 6. The non-equality assertion tests for whether two objects are not equal
- // with != assert.notEqual(actual, expected, message_opt);
- assert.notEqual = function notEqual(actual, expected, message) {
- if (actual == expected) {
- fail(actual, expected, message, '!=', assert.notEqual);
- }
- };
- // 7. The equivalence assertion tests a deep equality relation.
- // assert.deepEqual(actual, expected, message_opt);
- assert.deepEqual = function deepEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected)) {
- fail(actual, expected, message, 'deepEqual', assert.deepEqual);
- }
- };
- function _deepEqual(actual, expected) {
- // 7.1. All identical values are equivalent, as determined by ===.
- if (actual === expected) {
- return true;
- } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
- if (actual.length != expected.length) return false;
- for (var i = 0; i < actual.length; i++) {
- if (actual[i] !== expected[i]) return false;
- }
- return true;
- // 7.2. If the expected value is a Date object, the actual value is
- // equivalent if it is also a Date object that refers to the same time.
- } else if (util.isDate(actual) && util.isDate(expected)) {
- return actual.getTime() === expected.getTime();
- // 7.3 If the expected value is a RegExp object, the actual value is
- // equivalent if it is also a RegExp object with the same source and
- // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
- } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
- return actual.source === expected.source &&
- actual.global === expected.global &&
- actual.multiline === expected.multiline &&
- actual.lastIndex === expected.lastIndex &&
- actual.ignoreCase === expected.ignoreCase;
- // 7.4. Other pairs that do not both pass typeof value == 'object',
- // equivalence is determined by ==.
- } else if (!util.isObject(actual) && !util.isObject(expected)) {
- return actual == expected;
- // 7.5 For all other Object pairs, including Array objects, equivalence is
- // determined by having the same number of owned properties (as verified
- // with Object.prototype.hasOwnProperty.call), the same set of keys
- // (although not necessarily the same order), equivalent values for every
- // corresponding key, and an identical 'prototype' property. Note: this
- // accounts for both named and indexed properties on Arrays.
- } else {
- return objEquiv(actual, expected);
- }
- }
- function isArguments(object) {
- return Object.prototype.toString.call(object) == '[object Arguments]';
- }
- function objEquiv(a, b) {
- if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
- return false;
- // an identical 'prototype' property.
- if (a.prototype !== b.prototype) return false;
- // if one is a primitive, the other must be same
- if (util.isPrimitive(a) || util.isPrimitive(b)) {
- return a === b;
- }
- var aIsArgs = isArguments(a),
- bIsArgs = isArguments(b);
- if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
- return false;
- if (aIsArgs) {
- a = pSlice.call(a);
- b = pSlice.call(b);
- return _deepEqual(a, b);
- }
- var ka = objectKeys(a),
- kb = objectKeys(b),
- key, i;
- // having the same number of owned properties (keys incorporates
- // hasOwnProperty)
- if (ka.length != kb.length)
- return false;
- //the same set of keys (although not necessarily the same order),
- ka.sort();
- kb.sort();
- //~~~cheap key test
- for (i = ka.length - 1; i >= 0; i--) {
- if (ka[i] != kb[i])
- return false;
- }
- //equivalent values for every corresponding key, and
- //~~~possibly expensive deep test
- for (i = ka.length - 1; i >= 0; i--) {
- key = ka[i];
- if (!_deepEqual(a[key], b[key])) return false;
- }
- return true;
- }
- // 8. The non-equivalence assertion tests for any deep inequality.
- // assert.notDeepEqual(actual, expected, message_opt);
- assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
- if (_deepEqual(actual, expected)) {
- fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
- }
- };
- // 9. The strict equality assertion tests strict equality, as determined by ===.
- // assert.strictEqual(actual, expected, message_opt);
- assert.strictEqual = function strictEqual(actual, expected, message) {
- if (actual !== expected) {
- fail(actual, expected, message, '===', assert.strictEqual);
- }
- };
- // 10. The strict non-equality assertion tests for strict inequality, as
- // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
- assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
- if (actual === expected) {
- fail(actual, expected, message, '!==', assert.notStrictEqual);
- }
- };
- function expectedException(actual, expected) {
- if (!actual || !expected) {
- return false;
- }
- if (Object.prototype.toString.call(expected) == '[object RegExp]') {
- return expected.test(actual);
- } else if (actual instanceof expected) {
- return true;
- } else if (expected.call({}, actual) === true) {
- return true;
- }
- return false;
- }
- function _throws(shouldThrow, block, expected, message) {
- var actual;
- if (util.isString(expected)) {
- message = expected;
- expected = null;
- }
- try {
- block();
- } catch (e) {
- actual = e;
- }
- message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
- (message ? ' ' + message : '.');
- if (shouldThrow && !actual) {
- fail(actual, expected, 'Missing expected exception' + message);
- }
- if (!shouldThrow && expectedException(actual, expected)) {
- fail(actual, expected, 'Got unwanted exception' + message);
- }
- if ((shouldThrow && actual && expected &&
- !expectedException(actual, expected)) || (!shouldThrow && actual)) {
- throw actual;
- }
- }
- // 11. Expected to throw an error:
- // assert.throws(block, Error_opt, message_opt);
- assert.throws = function(block, /*optional*/error, /*optional*/message) {
- _throws.apply(this, [true].concat(pSlice.call(arguments)));
- };
- // EXTENSION! This is annoying to write outside this module.
- assert.doesNotThrow = function(block, /*optional*/message) {
- _throws.apply(this, [false].concat(pSlice.call(arguments)));
- };
- assert.ifError = function(err) { if (err) {throw err;}};
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- if (hasOwn.call(obj, key)) keys.push(key);
- }
- return keys;
- };
- },{"util/":216}],191:[function(require,module,exports){
- arguments[4][189][0].apply(exports,arguments)
- },{"dup":189}],192:[function(require,module,exports){
- /*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
- * @license MIT
- */
- var base64 = require('base64-js')
- var ieee754 = require('ieee754')
- var isArray = require('is-array')
- exports.Buffer = Buffer
- exports.SlowBuffer = SlowBuffer
- exports.INSPECT_MAX_BYTES = 50
- Buffer.poolSize = 8192 // not used by this implementation
- var kMaxLength = 0x3fffffff
- var rootParent = {}
- /**
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
- * === true Use Uint8Array implementation (fastest)
- * === false Use Object implementation (most compatible, even IE6)
- *
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
- * Opera 11.6+, iOS 4.2+.
- *
- * Note:
- *
- * - Implementation must support adding new properties to `Uint8Array` instances.
- * Firefox 4-29 lacked support, fixed in Firefox 30+.
- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
- *
- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
- *
- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
- * incorrect length in some situations.
- *
- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will
- * get the Object implementation, which is slower but will work correctly.
- */
- Buffer.TYPED_ARRAY_SUPPORT = (function () {
- try {
- var buf = new ArrayBuffer(0)
- var arr = new Uint8Array(buf)
- arr.foo = function () { return 42 }
- return arr.foo() === 42 && // typed array instances can be augmented
- typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
- new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
- } catch (e) {
- return false
- }
- })()
- /**
- * Class: Buffer
- * =============
- *
- * The Buffer constructor returns instances of `Uint8Array` that are augmented
- * with function properties for all the node `Buffer` API functions. We use
- * `Uint8Array` so that square bracket notation works as expected -- it returns
- * a single octet.
- *
- * By augmenting the instances, we can avoid modifying the `Uint8Array`
- * prototype.
- */
- function Buffer (subject, encoding) {
- var self = this
- if (!(self instanceof Buffer)) return new Buffer(subject, encoding)
- var type = typeof subject
- var length
- if (type === 'number') {
- length = +subject
- } else if (type === 'string') {
- length = Buffer.byteLength(subject, encoding)
- } else if (type === 'object' && subject !== null) {
- // assume object is array-like
- if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data
- length = +subject.length
- } else {
- throw new TypeError('must start with number, buffer, array or string')
- }
- if (length > kMaxLength) {
- throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x' +
- kMaxLength.toString(16) + ' bytes')
- }
- if (length < 0) length = 0
- else length >>>= 0 // coerce to uint32
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- // Preferred: Return an augmented `Uint8Array` instance for best performance
- self = Buffer._augment(new Uint8Array(length)) // eslint-disable-line consistent-this
- } else {
- // Fallback: Return THIS instance of Buffer (created by `new`)
- self.length = length
- self._isBuffer = true
- }
- var i
- if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
- // Speed optimization -- use set if we're copying from a typed array
- self._set(subject)
- } else if (isArrayish(subject)) {
- // Treat array-ish objects as a byte array
- if (Buffer.isBuffer(subject)) {
- for (i = 0; i < length; i++) {
- self[i] = subject.readUInt8(i)
- }
- } else {
- for (i = 0; i < length; i++) {
- self[i] = ((subject[i] % 256) + 256) % 256
- }
- }
- } else if (type === 'string') {
- self.write(subject, 0, encoding)
- } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT) {
- for (i = 0; i < length; i++) {
- self[i] = 0
- }
- }
- if (length > 0 && length <= Buffer.poolSize) self.parent = rootParent
- return self
- }
- function SlowBuffer (subject, encoding) {
- if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
- var buf = new Buffer(subject, encoding)
- delete buf.parent
- return buf
- }
- Buffer.isBuffer = function isBuffer (b) {
- return !!(b != null && b._isBuffer)
- }
- Buffer.compare = function compare (a, b) {
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
- throw new TypeError('Arguments must be Buffers')
- }
- if (a === b) return 0
- var x = a.length
- var y = b.length
- for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
- if (i !== len) {
- x = a[i]
- y = b[i]
- }
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
- Buffer.isEncoding = function isEncoding (encoding) {
- switch (String(encoding).toLowerCase()) {
- case 'hex':
- case 'utf8':
- case 'utf-8':
- case 'ascii':
- case 'binary':
- case 'base64':
- case 'raw':
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return true
- default:
- return false
- }
- }
- Buffer.concat = function concat (list, totalLength) {
- if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
- if (list.length === 0) {
- return new Buffer(0)
- } else if (list.length === 1) {
- return list[0]
- }
- var i
- if (totalLength === undefined) {
- totalLength = 0
- for (i = 0; i < list.length; i++) {
- totalLength += list[i].length
- }
- }
- var buf = new Buffer(totalLength)
- var pos = 0
- for (i = 0; i < list.length; i++) {
- var item = list[i]
- item.copy(buf, pos)
- pos += item.length
- }
- return buf
- }
- Buffer.byteLength = function byteLength (str, encoding) {
- var ret
- str = str + ''
- switch (encoding || 'utf8') {
- case 'ascii':
- case 'binary':
- case 'raw':
- ret = str.length
- break
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- ret = str.length * 2
- break
- case 'hex':
- ret = str.length >>> 1
- break
- case 'utf8':
- case 'utf-8':
- ret = utf8ToBytes(str).length
- break
- case 'base64':
- ret = base64ToBytes(str).length
- break
- default:
- ret = str.length
- }
- return ret
- }
- // pre-set for values that may exist in the future
- Buffer.prototype.length = undefined
- Buffer.prototype.parent = undefined
- // toString(encoding, start=0, end=buffer.length)
- Buffer.prototype.toString = function toString (encoding, start, end) {
- var loweredCase = false
- start = start >>> 0
- end = end === undefined || end === Infinity ? this.length : end >>> 0
- if (!encoding) encoding = 'utf8'
- if (start < 0) start = 0
- if (end > this.length) end = this.length
- if (end <= start) return ''
- while (true) {
- switch (encoding) {
- case 'hex':
- return hexSlice(this, start, end)
- case 'utf8':
- case 'utf-8':
- return utf8Slice(this, start, end)
- case 'ascii':
- return asciiSlice(this, start, end)
- case 'binary':
- return binarySlice(this, start, end)
- case 'base64':
- return base64Slice(this, start, end)
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return utf16leSlice(this, start, end)
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = (encoding + '').toLowerCase()
- loweredCase = true
- }
- }
- }
- Buffer.prototype.equals = function equals (b) {
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
- if (this === b) return true
- return Buffer.compare(this, b) === 0
- }
- Buffer.prototype.inspect = function inspect () {
- var str = ''
- var max = exports.INSPECT_MAX_BYTES
- if (this.length > 0) {
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
- if (this.length > max) str += ' ... '
- }
- return '<Buffer ' + str + '>'
- }
- Buffer.prototype.compare = function compare (b) {
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
- if (this === b) return 0
- return Buffer.compare(this, b)
- }
- Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
- if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
- else if (byteOffset < -0x80000000) byteOffset = -0x80000000
- byteOffset >>= 0
- if (this.length === 0) return -1
- if (byteOffset >= this.length) return -1
- // Negative offsets start from the end of the buffer
- if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
- if (typeof val === 'string') {
- if (val.length === 0) return -1 // special case: looking for empty string always fails
- return String.prototype.indexOf.call(this, val, byteOffset)
- }
- if (Buffer.isBuffer(val)) {
- return arrayIndexOf(this, val, byteOffset)
- }
- if (typeof val === 'number') {
- if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
- return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
- }
- return arrayIndexOf(this, [ val ], byteOffset)
- }
- function arrayIndexOf (arr, val, byteOffset) {
- var foundIndex = -1
- for (var i = 0; byteOffset + i < arr.length; i++) {
- if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
- if (foundIndex === -1) foundIndex = i
- if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
- } else {
- foundIndex = -1
- }
- }
- return -1
- }
- throw new TypeError('val must be string, number or Buffer')
- }
- // `get` will be removed in Node 0.13+
- Buffer.prototype.get = function get (offset) {
- console.log('.get() is deprecated. Access using array indexes instead.')
- return this.readUInt8(offset)
- }
- // `set` will be removed in Node 0.13+
- Buffer.prototype.set = function set (v, offset) {
- console.log('.set() is deprecated. Access using array indexes instead.')
- return this.writeUInt8(v, offset)
- }
- function hexWrite (buf, string, offset, length) {
- offset = Number(offset) || 0
- var remaining = buf.length - offset
- if (!length) {
- length = remaining
- } else {
- length = Number(length)
- if (length > remaining) {
- length = remaining
- }
- }
- // must be an even number of digits
- var strLen = string.length
- if (strLen % 2 !== 0) throw new Error('Invalid hex string')
- if (length > strLen / 2) {
- length = strLen / 2
- }
- for (var i = 0; i < length; i++) {
- var parsed = parseInt(string.substr(i * 2, 2), 16)
- if (isNaN(parsed)) throw new Error('Invalid hex string')
- buf[offset + i] = parsed
- }
- return i
- }
- function utf8Write (buf, string, offset, length) {
- var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
- return charsWritten
- }
- function asciiWrite (buf, string, offset, length) {
- var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
- return charsWritten
- }
- function binaryWrite (buf, string, offset, length) {
- return asciiWrite(buf, string, offset, length)
- }
- function base64Write (buf, string, offset, length) {
- var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
- return charsWritten
- }
- function utf16leWrite (buf, string, offset, length) {
- var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
- return charsWritten
- }
- Buffer.prototype.write = function write (string, offset, length, encoding) {
- // Support both (string, offset, length, encoding)
- // and the legacy (string, encoding, offset, length)
- if (isFinite(offset)) {
- if (!isFinite(length)) {
- encoding = length
- length = undefined
- }
- } else { // legacy
- var swap = encoding
- encoding = offset
- offset = length
- length = swap
- }
- offset = Number(offset) || 0
- if (length < 0 || offset < 0 || offset > this.length) {
- throw new RangeError('attempt to write outside buffer bounds')
- }
- var remaining = this.length - offset
- if (!length) {
- length = remaining
- } else {
- length = Number(length)
- if (length > remaining) {
- length = remaining
- }
- }
- encoding = String(encoding || 'utf8').toLowerCase()
- var ret
- switch (encoding) {
- case 'hex':
- ret = hexWrite(this, string, offset, length)
- break
- case 'utf8':
- case 'utf-8':
- ret = utf8Write(this, string, offset, length)
- break
- case 'ascii':
- ret = asciiWrite(this, string, offset, length)
- break
- case 'binary':
- ret = binaryWrite(this, string, offset, length)
- break
- case 'base64':
- ret = base64Write(this, string, offset, length)
- break
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- ret = utf16leWrite(this, string, offset, length)
- break
- default:
- throw new TypeError('Unknown encoding: ' + encoding)
- }
- return ret
- }
- Buffer.prototype.toJSON = function toJSON () {
- return {
- type: 'Buffer',
- data: Array.prototype.slice.call(this._arr || this, 0)
- }
- }
- function base64Slice (buf, start, end) {
- if (start === 0 && end === buf.length) {
- return base64.fromByteArray(buf)
- } else {
- return base64.fromByteArray(buf.slice(start, end))
- }
- }
- function utf8Slice (buf, start, end) {
- var res = ''
- var tmp = ''
- end = Math.min(buf.length, end)
- for (var i = start; i < end; i++) {
- if (buf[i] <= 0x7F) {
- res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
- tmp = ''
- } else {
- tmp += '%' + buf[i].toString(16)
- }
- }
- return res + decodeUtf8Char(tmp)
- }
- function asciiSlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
- for (var i = start; i < end; i++) {
- ret += String.fromCharCode(buf[i] & 0x7F)
- }
- return ret
- }
- function binarySlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
- for (var i = start; i < end; i++) {
- ret += String.fromCharCode(buf[i])
- }
- return ret
- }
- function hexSlice (buf, start, end) {
- var len = buf.length
- if (!start || start < 0) start = 0
- if (!end || end < 0 || end > len) end = len
- var out = ''
- for (var i = start; i < end; i++) {
- out += toHex(buf[i])
- }
- return out
- }
- function utf16leSlice (buf, start, end) {
- var bytes = buf.slice(start, end)
- var res = ''
- for (var i = 0; i < bytes.length; i += 2) {
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
- }
- return res
- }
- Buffer.prototype.slice = function slice (start, end) {
- var len = this.length
- start = ~~start
- end = end === undefined ? len : ~~end
- if (start < 0) {
- start += len
- if (start < 0) start = 0
- } else if (start > len) {
- start = len
- }
- if (end < 0) {
- end += len
- if (end < 0) end = 0
- } else if (end > len) {
- end = len
- }
- if (end < start) end = start
- var newBuf
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- newBuf = Buffer._augment(this.subarray(start, end))
- } else {
- var sliceLen = end - start
- newBuf = new Buffer(sliceLen, undefined)
- for (var i = 0; i < sliceLen; i++) {
- newBuf[i] = this[i + start]
- }
- }
- if (newBuf.length) newBuf.parent = this.parent || this
- return newBuf
- }
- /*
- * Need to make sure that buffer isn't trying to write out of bounds.
- */
- function checkOffset (offset, ext, length) {
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
- }
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- return val
- }
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- checkOffset(offset, byteLength, this.length)
- }
- var val = this[offset + --byteLength]
- var mul = 1
- while (byteLength > 0 && (mul *= 0x100)) {
- val += this[offset + --byteLength] * mul
- }
- return val
- }
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 1, this.length)
- return this[offset]
- }
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- return this[offset] | (this[offset + 1] << 8)
- }
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- return (this[offset] << 8) | this[offset + 1]
- }
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ((this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16)) +
- (this[offset + 3] * 0x1000000)
- }
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset] * 0x1000000) +
- ((this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- this[offset + 3])
- }
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- mul *= 0x80
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
- return val
- }
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var i = byteLength
- var mul = 1
- var val = this[offset + --i]
- while (i > 0 && (mul *= 0x100)) {
- val += this[offset + --i] * mul
- }
- mul *= 0x80
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
- return val
- }
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 1, this.length)
- if (!(this[offset] & 0x80)) return (this[offset])
- return ((0xff - this[offset] + 1) * -1)
- }
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset] | (this[offset + 1] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset + 1] | (this[offset] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16) |
- (this[offset + 3] << 24)
- }
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset] << 24) |
- (this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- (this[offset + 3])
- }
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, true, 23, 4)
- }
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, false, 23, 4)
- }
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, true, 52, 8)
- }
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, false, 52, 8)
- }
- function checkInt (buf, value, offset, ext, max, min) {
- if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
- if (value > max || value < min) throw new RangeError('value is out of bounds')
- if (offset + ext > buf.length) throw new RangeError('index out of range')
- }
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
- var mul = 1
- var i = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- this[offset + i] = (value / mul) >>> 0 & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
- var i = byteLength - 1
- var mul = 1
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- this[offset + i] = (value / mul) >>> 0 & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
- this[offset] = value
- return offset + 1
- }
- function objectWriteUInt16 (buf, value, offset, littleEndian) {
- if (value < 0) value = 0xffff + value + 1
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
- (littleEndian ? i : 1 - i) * 8
- }
- }
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = value
- this[offset + 1] = (value >>> 8)
- } else {
- objectWriteUInt16(this, value, offset, true)
- }
- return offset + 2
- }
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 8)
- this[offset + 1] = value
- } else {
- objectWriteUInt16(this, value, offset, false)
- }
- return offset + 2
- }
- function objectWriteUInt32 (buf, value, offset, littleEndian) {
- if (value < 0) value = 0xffffffff + value + 1
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
- }
- }
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset + 3] = (value >>> 24)
- this[offset + 2] = (value >>> 16)
- this[offset + 1] = (value >>> 8)
- this[offset] = value
- } else {
- objectWriteUInt32(this, value, offset, true)
- }
- return offset + 4
- }
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = value
- } else {
- objectWriteUInt32(this, value, offset, false)
- }
- return offset + 4
- }
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkInt(
- this, value, offset, byteLength,
- Math.pow(2, 8 * byteLength - 1) - 1,
- -Math.pow(2, 8 * byteLength - 1)
- )
- }
- var i = 0
- var mul = 1
- var sub = value < 0 ? 1 : 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkInt(
- this, value, offset, byteLength,
- Math.pow(2, 8 * byteLength - 1) - 1,
- -Math.pow(2, 8 * byteLength - 1)
- )
- }
- var i = byteLength - 1
- var mul = 1
- var sub = value < 0 ? 1 : 0
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
- if (value < 0) value = 0xff + value + 1
- this[offset] = value
- return offset + 1
- }
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = value
- this[offset + 1] = (value >>> 8)
- } else {
- objectWriteUInt16(this, value, offset, true)
- }
- return offset + 2
- }
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 8)
- this[offset + 1] = value
- } else {
- objectWriteUInt16(this, value, offset, false)
- }
- return offset + 2
- }
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = value
- this[offset + 1] = (value >>> 8)
- this[offset + 2] = (value >>> 16)
- this[offset + 3] = (value >>> 24)
- } else {
- objectWriteUInt32(this, value, offset, true)
- }
- return offset + 4
- }
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (value < 0) value = 0xffffffff + value + 1
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = value
- } else {
- objectWriteUInt32(this, value, offset, false)
- }
- return offset + 4
- }
- function checkIEEE754 (buf, value, offset, ext, max, min) {
- if (value > max || value < min) throw new RangeError('value is out of bounds')
- if (offset + ext > buf.length) throw new RangeError('index out of range')
- if (offset < 0) throw new RangeError('index out of range')
- }
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
- }
- ieee754.write(buf, value, offset, littleEndian, 23, 4)
- return offset + 4
- }
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
- return writeFloat(this, value, offset, true, noAssert)
- }
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
- return writeFloat(this, value, offset, false, noAssert)
- }
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
- }
- ieee754.write(buf, value, offset, littleEndian, 52, 8)
- return offset + 8
- }
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
- return writeDouble(this, value, offset, true, noAssert)
- }
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
- return writeDouble(this, value, offset, false, noAssert)
- }
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
- Buffer.prototype.copy = function copy (target, target_start, start, end) {
- if (!start) start = 0
- if (!end && end !== 0) end = this.length
- if (target_start >= target.length) target_start = target.length
- if (!target_start) target_start = 0
- if (end > 0 && end < start) end = start
- // Copy 0 bytes; we're done
- if (end === start) return 0
- if (target.length === 0 || this.length === 0) return 0
- // Fatal error conditions
- if (target_start < 0) {
- throw new RangeError('targetStart out of bounds')
- }
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
- // Are we oob?
- if (end > this.length) end = this.length
- if (target.length - target_start < end - start) {
- end = target.length - target_start + start
- }
- var len = end - start
- if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
- for (var i = 0; i < len; i++) {
- target[i + target_start] = this[i + start]
- }
- } else {
- target._set(this.subarray(start, start + len), target_start)
- }
- return len
- }
- // fill(value, start=0, end=buffer.length)
- Buffer.prototype.fill = function fill (value, start, end) {
- if (!value) value = 0
- if (!start) start = 0
- if (!end) end = this.length
- if (end < start) throw new RangeError('end < start')
- // Fill 0 bytes; we're done
- if (end === start) return
- if (this.length === 0) return
- if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
- if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
- var i
- if (typeof value === 'number') {
- for (i = start; i < end; i++) {
- this[i] = value
- }
- } else {
- var bytes = utf8ToBytes(value.toString())
- var len = bytes.length
- for (i = start; i < end; i++) {
- this[i] = bytes[i % len]
- }
- }
- return this
- }
- /**
- * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
- * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
- */
- Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
- if (typeof Uint8Array !== 'undefined') {
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- return (new Buffer(this)).buffer
- } else {
- var buf = new Uint8Array(this.length)
- for (var i = 0, len = buf.length; i < len; i += 1) {
- buf[i] = this[i]
- }
- return buf.buffer
- }
- } else {
- throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
- }
- }
- // HELPER FUNCTIONS
- // ================
- var BP = Buffer.prototype
- /**
- * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
- */
- Buffer._augment = function _augment (arr) {
- arr.constructor = Buffer
- arr._isBuffer = true
- // save reference to original Uint8Array set method before overwriting
- arr._set = arr.set
- // deprecated, will be removed in node 0.13+
- arr.get = BP.get
- arr.set = BP.set
- arr.write = BP.write
- arr.toString = BP.toString
- arr.toLocaleString = BP.toString
- arr.toJSON = BP.toJSON
- arr.equals = BP.equals
- arr.compare = BP.compare
- arr.indexOf = BP.indexOf
- arr.copy = BP.copy
- arr.slice = BP.slice
- arr.readUIntLE = BP.readUIntLE
- arr.readUIntBE = BP.readUIntBE
- arr.readUInt8 = BP.readUInt8
- arr.readUInt16LE = BP.readUInt16LE
- arr.readUInt16BE = BP.readUInt16BE
- arr.readUInt32LE = BP.readUInt32LE
- arr.readUInt32BE = BP.readUInt32BE
- arr.readIntLE = BP.readIntLE
- arr.readIntBE = BP.readIntBE
- arr.readInt8 = BP.readInt8
- arr.readInt16LE = BP.readInt16LE
- arr.readInt16BE = BP.readInt16BE
- arr.readInt32LE = BP.readInt32LE
- arr.readInt32BE = BP.readInt32BE
- arr.readFloatLE = BP.readFloatLE
- arr.readFloatBE = BP.readFloatBE
- arr.readDoubleLE = BP.readDoubleLE
- arr.readDoubleBE = BP.readDoubleBE
- arr.writeUInt8 = BP.writeUInt8
- arr.writeUIntLE = BP.writeUIntLE
- arr.writeUIntBE = BP.writeUIntBE
- arr.writeUInt16LE = BP.writeUInt16LE
- arr.writeUInt16BE = BP.writeUInt16BE
- arr.writeUInt32LE = BP.writeUInt32LE
- arr.writeUInt32BE = BP.writeUInt32BE
- arr.writeIntLE = BP.writeIntLE
- arr.writeIntBE = BP.writeIntBE
- arr.writeInt8 = BP.writeInt8
- arr.writeInt16LE = BP.writeInt16LE
- arr.writeInt16BE = BP.writeInt16BE
- arr.writeInt32LE = BP.writeInt32LE
- arr.writeInt32BE = BP.writeInt32BE
- arr.writeFloatLE = BP.writeFloatLE
- arr.writeFloatBE = BP.writeFloatBE
- arr.writeDoubleLE = BP.writeDoubleLE
- arr.writeDoubleBE = BP.writeDoubleBE
- arr.fill = BP.fill
- arr.inspect = BP.inspect
- arr.toArrayBuffer = BP.toArrayBuffer
- return arr
- }
- var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
- function base64clean (str) {
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
- str = stringtrim(str).replace(INVALID_BASE64_RE, '')
- // Node converts strings with length < 2 to ''
- if (str.length < 2) return ''
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
- while (str.length % 4 !== 0) {
- str = str + '='
- }
- return str
- }
- function stringtrim (str) {
- if (str.trim) return str.trim()
- return str.replace(/^\s+|\s+$/g, '')
- }
- function isArrayish (subject) {
- return isArray(subject) || Buffer.isBuffer(subject) ||
- subject && typeof subject === 'object' &&
- typeof subject.length === 'number'
- }
- function toHex (n) {
- if (n < 16) return '0' + n.toString(16)
- return n.toString(16)
- }
- function utf8ToBytes (string, units) {
- units = units || Infinity
- var codePoint
- var length = string.length
- var leadSurrogate = null
- var bytes = []
- var i = 0
- for (; i < length; i++) {
- codePoint = string.charCodeAt(i)
- // is surrogate component
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
- // last char was a lead
- if (leadSurrogate) {
- // 2 leads in a row
- if (codePoint < 0xDC00) {
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- leadSurrogate = codePoint
- continue
- } else {
- // valid surrogate pair
- codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
- leadSurrogate = null
- }
- } else {
- // no lead yet
- if (codePoint > 0xDBFF) {
- // unexpected trail
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- } else if (i + 1 === length) {
- // unpaired lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- } else {
- // valid lead
- leadSurrogate = codePoint
- continue
- }
- }
- } else if (leadSurrogate) {
- // valid bmp char, but last char was a lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- leadSurrogate = null
- }
- // encode utf8
- if (codePoint < 0x80) {
- if ((units -= 1) < 0) break
- bytes.push(codePoint)
- } else if (codePoint < 0x800) {
- if ((units -= 2) < 0) break
- bytes.push(
- codePoint >> 0x6 | 0xC0,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x10000) {
- if ((units -= 3) < 0) break
- bytes.push(
- codePoint >> 0xC | 0xE0,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x200000) {
- if ((units -= 4) < 0) break
- bytes.push(
- codePoint >> 0x12 | 0xF0,
- codePoint >> 0xC & 0x3F | 0x80,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else {
- throw new Error('Invalid code point')
- }
- }
- return bytes
- }
- function asciiToBytes (str) {
- var byteArray = []
- for (var i = 0; i < str.length; i++) {
- // Node's code seems to be doing this and not & 0x7F..
- byteArray.push(str.charCodeAt(i) & 0xFF)
- }
- return byteArray
- }
- function utf16leToBytes (str, units) {
- var c, hi, lo
- var byteArray = []
- for (var i = 0; i < str.length; i++) {
- if ((units -= 2) < 0) break
- c = str.charCodeAt(i)
- hi = c >> 8
- lo = c % 256
- byteArray.push(lo)
- byteArray.push(hi)
- }
- return byteArray
- }
- function base64ToBytes (str) {
- return base64.toByteArray(base64clean(str))
- }
- function blitBuffer (src, dst, offset, length) {
- for (var i = 0; i < length; i++) {
- if ((i + offset >= dst.length) || (i >= src.length)) break
- dst[i + offset] = src[i]
- }
- return i
- }
- function decodeUtf8Char (str) {
- try {
- return decodeURIComponent(str)
- } catch (err) {
- return String.fromCharCode(0xFFFD) // UTF 8 invalid char
- }
- }
- },{"base64-js":193,"ieee754":194,"is-array":195}],193:[function(require,module,exports){
- var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
- ;(function (exports) {
- 'use strict';
- var Arr = (typeof Uint8Array !== 'undefined')
- ? Uint8Array
- : Array
- var PLUS = '+'.charCodeAt(0)
- var SLASH = '/'.charCodeAt(0)
- var NUMBER = '0'.charCodeAt(0)
- var LOWER = 'a'.charCodeAt(0)
- var UPPER = 'A'.charCodeAt(0)
- var PLUS_URL_SAFE = '-'.charCodeAt(0)
- var SLASH_URL_SAFE = '_'.charCodeAt(0)
- function decode (elt) {
- var code = elt.charCodeAt(0)
- if (code === PLUS ||
- code === PLUS_URL_SAFE)
- return 62 // '+'
- if (code === SLASH ||
- code === SLASH_URL_SAFE)
- return 63 // '/'
- if (code < NUMBER)
- return -1 //no match
- if (code < NUMBER + 10)
- return code - NUMBER + 26 + 26
- if (code < UPPER + 26)
- return code - UPPER
- if (code < LOWER + 26)
- return code - LOWER + 26
- }
- function b64ToByteArray (b64) {
- var i, j, l, tmp, placeHolders, arr
- if (b64.length % 4 > 0) {
- throw new Error('Invalid string. Length must be a multiple of 4')
- }
- // the number of equal signs (place holders)
- // if there are two placeholders, than the two characters before it
- // represent one byte
- // if there is only one, then the three characters before it represent 2 bytes
- // this is just a cheap hack to not do indexOf twice
- var len = b64.length
- placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
- // base64 is 4/3 + up to two characters of the original data
- arr = new Arr(b64.length * 3 / 4 - placeHolders)
- // if there are placeholders, only get up to the last complete 4 chars
- l = placeHolders > 0 ? b64.length - 4 : b64.length
- var L = 0
- function push (v) {
- arr[L++] = v
- }
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
- tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
- push((tmp & 0xFF0000) >> 16)
- push((tmp & 0xFF00) >> 8)
- push(tmp & 0xFF)
- }
- if (placeHolders === 2) {
- tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
- push(tmp & 0xFF)
- } else if (placeHolders === 1) {
- tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
- push((tmp >> 8) & 0xFF)
- push(tmp & 0xFF)
- }
- return arr
- }
- function uint8ToBase64 (uint8) {
- var i,
- extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
- output = "",
- temp, length
- function encode (num) {
- return lookup.charAt(num)
- }
- function tripletToBase64 (num) {
- return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
- }
- // go through the array every three bytes, we'll deal with trailing stuff later
- for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
- temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
- output += tripletToBase64(temp)
- }
- // pad the end with zeros, but make sure to not forget the extra bytes
- switch (extraBytes) {
- case 1:
- temp = uint8[uint8.length - 1]
- output += encode(temp >> 2)
- output += encode((temp << 4) & 0x3F)
- output += '=='
- break
- case 2:
- temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
- output += encode(temp >> 10)
- output += encode((temp >> 4) & 0x3F)
- output += encode((temp << 2) & 0x3F)
- output += '='
- break
- }
- return output
- }
- exports.toByteArray = b64ToByteArray
- exports.fromByteArray = uint8ToBase64
- }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
- },{}],194:[function(require,module,exports){
- exports.read = function(buffer, offset, isLE, mLen, nBytes) {
- var e, m,
- eLen = nBytes * 8 - mLen - 1,
- eMax = (1 << eLen) - 1,
- eBias = eMax >> 1,
- nBits = -7,
- i = isLE ? (nBytes - 1) : 0,
- d = isLE ? -1 : 1,
- s = buffer[offset + i];
- i += d;
- e = s & ((1 << (-nBits)) - 1);
- s >>= (-nBits);
- nBits += eLen;
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
- m = e & ((1 << (-nBits)) - 1);
- e >>= (-nBits);
- nBits += mLen;
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
- if (e === 0) {
- e = 1 - eBias;
- } else if (e === eMax) {
- return m ? NaN : ((s ? -1 : 1) * Infinity);
- } else {
- m = m + Math.pow(2, mLen);
- e = e - eBias;
- }
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
- };
- exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
- var e, m, c,
- eLen = nBytes * 8 - mLen - 1,
- eMax = (1 << eLen) - 1,
- eBias = eMax >> 1,
- rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
- i = isLE ? 0 : (nBytes - 1),
- d = isLE ? 1 : -1,
- s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
- value = Math.abs(value);
- if (isNaN(value) || value === Infinity) {
- m = isNaN(value) ? 1 : 0;
- e = eMax;
- } else {
- e = Math.floor(Math.log(value) / Math.LN2);
- if (value * (c = Math.pow(2, -e)) < 1) {
- e--;
- c *= 2;
- }
- if (e + eBias >= 1) {
- value += rt / c;
- } else {
- value += rt * Math.pow(2, 1 - eBias);
- }
- if (value * c >= 2) {
- e++;
- c /= 2;
- }
- if (e + eBias >= eMax) {
- m = 0;
- e = eMax;
- } else if (e + eBias >= 1) {
- m = (value * c - 1) * Math.pow(2, mLen);
- e = e + eBias;
- } else {
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
- e = 0;
- }
- }
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
- e = (e << mLen) | m;
- eLen += mLen;
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
- buffer[offset + i - d] |= s * 128;
- };
- },{}],195:[function(require,module,exports){
- /**
- * isArray
- */
- var isArray = Array.isArray;
- /**
- * toString
- */
- var str = Object.prototype.toString;
- /**
- * Whether or not the given `val`
- * is an array.
- *
- * example:
- *
- * isArray([]);
- * // > true
- * isArray(arguments);
- * // > false
- * isArray('');
- * // > false
- *
- * @param {mixed} val
- * @return {bool}
- */
- module.exports = isArray || function (val) {
- return !! val && '[object Array]' == str.call(val);
- };
- },{}],196:[function(require,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- function EventEmitter() {
- this._events = this._events || {};
- this._maxListeners = this._maxListeners || undefined;
- }
- module.exports = EventEmitter;
- // Backwards-compat with node 0.10.x
- EventEmitter.EventEmitter = EventEmitter;
- EventEmitter.prototype._events = undefined;
- EventEmitter.prototype._maxListeners = undefined;
- // By default EventEmitters will print a warning if more than 10 listeners are
- // added to it. This is a useful default which helps finding memory leaks.
- EventEmitter.defaultMaxListeners = 10;
- // Obviously not all Emitters should be limited to 10. This function allows
- // that to be increased. Set to zero for unlimited.
- EventEmitter.prototype.setMaxListeners = function(n) {
- if (!isNumber(n) || n < 0 || isNaN(n))
- throw TypeError('n must be a positive number');
- this._maxListeners = n;
- return this;
- };
- EventEmitter.prototype.emit = function(type) {
- var er, handler, len, args, i, listeners;
- if (!this._events)
- this._events = {};
- // If there is no 'error' event listener then throw.
- if (type === 'error') {
- if (!this._events.error ||
- (isObject(this._events.error) && !this._events.error.length)) {
- er = arguments[1];
- if (er instanceof Error) {
- throw er; // Unhandled 'error' event
- }
- throw TypeError('Uncaught, unspecified "error" event.');
- }
- }
- handler = this._events[type];
- if (isUndefined(handler))
- return false;
- if (isFunction(handler)) {
- switch (arguments.length) {
- // fast cases
- case 1:
- handler.call(this);
- break;
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
- len = arguments.length;
- args = new Array(len - 1);
- for (i = 1; i < len; i++)
- args[i - 1] = arguments[i];
- handler.apply(this, args);
- }
- } else if (isObject(handler)) {
- len = arguments.length;
- args = new Array(len - 1);
- for (i = 1; i < len; i++)
- args[i - 1] = arguments[i];
- listeners = handler.slice();
- len = listeners.length;
- for (i = 0; i < len; i++)
- listeners[i].apply(this, args);
- }
- return true;
- };
- EventEmitter.prototype.addListener = function(type, listener) {
- var m;
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- if (!this._events)
- this._events = {};
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (this._events.newListener)
- this.emit('newListener', type,
- isFunction(listener.listener) ?
- listener.listener : listener);
- if (!this._events[type])
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- else if (isObject(this._events[type]))
- // If we've already got an array, just append.
- this._events[type].push(listener);
- else
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
- // Check for listener leak
- if (isObject(this._events[type]) && !this._events[type].warned) {
- var m;
- if (!isUndefined(this._maxListeners)) {
- m = this._maxListeners;
- } else {
- m = EventEmitter.defaultMaxListeners;
- }
- if (m && m > 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- this._events[type].length);
- if (typeof console.trace === 'function') {
- // not supported in IE 10
- console.trace();
- }
- }
- }
- return this;
- };
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
- EventEmitter.prototype.once = function(type, listener) {
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- var fired = false;
- function g() {
- this.removeListener(type, g);
- if (!fired) {
- fired = true;
- listener.apply(this, arguments);
- }
- }
- g.listener = listener;
- this.on(type, g);
- return this;
- };
- // emits a 'removeListener' event iff the listener was removed
- EventEmitter.prototype.removeListener = function(type, listener) {
- var list, position, length, i;
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- if (!this._events || !this._events[type])
- return this;
- list = this._events[type];
- length = list.length;
- position = -1;
- if (list === listener ||
- (isFunction(list.listener) && list.listener === listener)) {
- delete this._events[type];
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- } else if (isObject(list)) {
- for (i = length; i-- > 0;) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener)) {
- position = i;
- break;
- }
- }
- if (position < 0)
- return this;
- if (list.length === 1) {
- list.length = 0;
- delete this._events[type];
- } else {
- list.splice(position, 1);
- }
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- }
- return this;
- };
- EventEmitter.prototype.removeAllListeners = function(type) {
- var key, listeners;
- if (!this._events)
- return this;
- // not listening for removeListener, no need to emit
- if (!this._events.removeListener) {
- if (arguments.length === 0)
- this._events = {};
- else if (this._events[type])
- delete this._events[type];
- return this;
- }
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- for (key in this._events) {
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = {};
- return this;
- }
- listeners = this._events[type];
- if (isFunction(listeners)) {
- this.removeListener(type, listeners);
- } else {
- // LIFO order
- while (listeners.length)
- this.removeListener(type, listeners[listeners.length - 1]);
- }
- delete this._events[type];
- return this;
- };
- EventEmitter.prototype.listeners = function(type) {
- var ret;
- if (!this._events || !this._events[type])
- ret = [];
- else if (isFunction(this._events[type]))
- ret = [this._events[type]];
- else
- ret = this._events[type].slice();
- return ret;
- };
- EventEmitter.listenerCount = function(emitter, type) {
- var ret;
- if (!emitter._events || !emitter._events[type])
- ret = 0;
- else if (isFunction(emitter._events[type]))
- ret = 1;
- else
- ret = emitter._events[type].length;
- return ret;
- };
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- function isUndefined(arg) {
- return arg === void 0;
- }
- },{}],197:[function(require,module,exports){
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
- },{}],198:[function(require,module,exports){
- module.exports = Array.isArray || function (arr) {
- return Object.prototype.toString.call(arr) == '[object Array]';
- };
- },{}],199:[function(require,module,exports){
- (function (process){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // resolves . and .. elements in a path array with directory names there
- // must be no slashes, empty elements, or device names (c:\) in the array
- // (so also no leading and trailing slashes - it does not distinguish
- // relative and absolute paths)
- function normalizeArray(parts, allowAboveRoot) {
- // if the path tries to go above the root, `up` ends up > 0
- var up = 0;
- for (var i = parts.length - 1; i >= 0; i--) {
- var last = parts[i];
- if (last === '.') {
- parts.splice(i, 1);
- } else if (last === '..') {
- parts.splice(i, 1);
- up++;
- } else if (up) {
- parts.splice(i, 1);
- up--;
- }
- }
- // if the path is allowed to go above the root, restore leading ..s
- if (allowAboveRoot) {
- for (; up--; up) {
- parts.unshift('..');
- }
- }
- return parts;
- }
- // Split a filename into [root, dir, basename, ext], unix version
- // 'root' is just a slash, or nothing.
- var splitPathRe =
- /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
- var splitPath = function(filename) {
- return splitPathRe.exec(filename).slice(1);
- };
- // path.resolve([from ...], to)
- // posix version
- exports.resolve = function() {
- var resolvedPath = '',
- resolvedAbsolute = false;
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
- var path = (i >= 0) ? arguments[i] : process.cwd();
- // Skip empty and invalid entries
- if (typeof path !== 'string') {
- throw new TypeError('Arguments to path.resolve must be strings');
- } else if (!path) {
- continue;
- }
- resolvedPath = path + '/' + resolvedPath;
- resolvedAbsolute = path.charAt(0) === '/';
- }
- // At this point the path should be resolved to a full absolute path, but
- // handle relative paths to be safe (might happen when process.cwd() fails)
- // Normalize the path
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
- return !!p;
- }), !resolvedAbsolute).join('/');
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
- };
- // path.normalize(path)
- // posix version
- exports.normalize = function(path) {
- var isAbsolute = exports.isAbsolute(path),
- trailingSlash = substr(path, -1) === '/';
- // Normalize the path
- path = normalizeArray(filter(path.split('/'), function(p) {
- return !!p;
- }), !isAbsolute).join('/');
- if (!path && !isAbsolute) {
- path = '.';
- }
- if (path && trailingSlash) {
- path += '/';
- }
- return (isAbsolute ? '/' : '') + path;
- };
- // posix version
- exports.isAbsolute = function(path) {
- return path.charAt(0) === '/';
- };
- // posix version
- exports.join = function() {
- var paths = Array.prototype.slice.call(arguments, 0);
- return exports.normalize(filter(paths, function(p, index) {
- if (typeof p !== 'string') {
- throw new TypeError('Arguments to path.join must be strings');
- }
- return p;
- }).join('/'));
- };
- // path.relative(from, to)
- // posix version
- exports.relative = function(from, to) {
- from = exports.resolve(from).substr(1);
- to = exports.resolve(to).substr(1);
- function trim(arr) {
- var start = 0;
- for (; start < arr.length; start++) {
- if (arr[start] !== '') break;
- }
- var end = arr.length - 1;
- for (; end >= 0; end--) {
- if (arr[end] !== '') break;
- }
- if (start > end) return [];
- return arr.slice(start, end - start + 1);
- }
- var fromParts = trim(from.split('/'));
- var toParts = trim(to.split('/'));
- var length = Math.min(fromParts.length, toParts.length);
- var samePartsLength = length;
- for (var i = 0; i < length; i++) {
- if (fromParts[i] !== toParts[i]) {
- samePartsLength = i;
- break;
- }
- }
- var outputParts = [];
- for (var i = samePartsLength; i < fromParts.length; i++) {
- outputParts.push('..');
- }
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
- return outputParts.join('/');
- };
- exports.sep = '/';
- exports.delimiter = ':';
- exports.dirname = function(path) {
- var result = splitPath(path),
- root = result[0],
- dir = result[1];
- if (!root && !dir) {
- // No dirname whatsoever
- return '.';
- }
- if (dir) {
- // It has a dirname, strip trailing slash
- dir = dir.substr(0, dir.length - 1);
- }
- return root + dir;
- };
- exports.basename = function(path, ext) {
- var f = splitPath(path)[2];
- // TODO: make this comparison case-insensitive on windows?
- if (ext && f.substr(-1 * ext.length) === ext) {
- f = f.substr(0, f.length - ext.length);
- }
- return f;
- };
- exports.extname = function(path) {
- return splitPath(path)[3];
- };
- function filter (xs, f) {
- if (xs.filter) return xs.filter(f);
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- if (f(xs[i], i, xs)) res.push(xs[i]);
- }
- return res;
- }
- // String.prototype.substr - negative index don't work in IE8
- var substr = 'ab'.substr(-1) === 'b'
- ? function (str, start, len) { return str.substr(start, len) }
- : function (str, start, len) {
- if (start < 0) start = str.length + start;
- return str.substr(start, len);
- }
- ;
- }).call(this,require('_process'))
- },{"_process":200}],200:[function(require,module,exports){
- // shim for using process in browser
- var process = module.exports = {};
- var queue = [];
- var draining = false;
- function drainQueue() {
- if (draining) {
- return;
- }
- draining = true;
- var currentQueue;
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- var i = -1;
- while (++i < len) {
- currentQueue[i]();
- }
- len = queue.length;
- }
- draining = false;
- }
- process.nextTick = function (fun) {
- queue.push(fun);
- if (!draining) {
- setTimeout(drainQueue, 0);
- }
- };
- process.title = 'browser';
- process.browser = true;
- process.env = {};
- process.argv = [];
- process.version = ''; // empty string to avoid regexp issues
- process.versions = {};
- function noop() {}
- process.on = noop;
- process.addListener = noop;
- process.once = noop;
- process.off = noop;
- process.removeListener = noop;
- process.removeAllListeners = noop;
- process.emit = noop;
- process.binding = function (name) {
- throw new Error('process.binding is not supported');
- };
- // TODO(shtylman)
- process.cwd = function () { return '/' };
- process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
- };
- process.umask = function() { return 0; };
- },{}],201:[function(require,module,exports){
- module.exports = require("./lib/_stream_duplex.js")
- },{"./lib/_stream_duplex.js":202}],202:[function(require,module,exports){
- (function (process){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // a duplex stream is just a stream that is both readable and writable.
- // Since JS doesn't have multiple prototypal inheritance, this class
- // prototypally inherits from Readable, and then parasitically from
- // Writable.
- module.exports = Duplex;
- /*<replacement>*/
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) keys.push(key);
- return keys;
- }
- /*</replacement>*/
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- var Readable = require('./_stream_readable');
- var Writable = require('./_stream_writable');
- util.inherits(Duplex, Readable);
- forEach(objectKeys(Writable.prototype), function(method) {
- if (!Duplex.prototype[method])
- Duplex.prototype[method] = Writable.prototype[method];
- });
- function Duplex(options) {
- if (!(this instanceof Duplex))
- return new Duplex(options);
- Readable.call(this, options);
- Writable.call(this, options);
- if (options && options.readable === false)
- this.readable = false;
- if (options && options.writable === false)
- this.writable = false;
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false)
- this.allowHalfOpen = false;
- this.once('end', onend);
- }
- // the no-half-open enforcer
- function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended)
- return;
- // no more data can be written.
- // But allow more writes to happen in this tick.
- process.nextTick(this.end.bind(this));
- }
- function forEach (xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- }).call(this,require('_process'))
- },{"./_stream_readable":204,"./_stream_writable":206,"_process":200,"core-util-is":207,"inherits":197}],203:[function(require,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // a passthrough stream.
- // basically just the most minimal sort of Transform stream.
- // Every written chunk gets output as-is.
- module.exports = PassThrough;
- var Transform = require('./_stream_transform');
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- util.inherits(PassThrough, Transform);
- function PassThrough(options) {
- if (!(this instanceof PassThrough))
- return new PassThrough(options);
- Transform.call(this, options);
- }
- PassThrough.prototype._transform = function(chunk, encoding, cb) {
- cb(null, chunk);
- };
- },{"./_stream_transform":205,"core-util-is":207,"inherits":197}],204:[function(require,module,exports){
- (function (process){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- module.exports = Readable;
- /*<replacement>*/
- var isArray = require('isarray');
- /*</replacement>*/
- /*<replacement>*/
- var Buffer = require('buffer').Buffer;
- /*</replacement>*/
- Readable.ReadableState = ReadableState;
- var EE = require('events').EventEmitter;
- /*<replacement>*/
- if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
- return emitter.listeners(type).length;
- };
- /*</replacement>*/
- var Stream = require('stream');
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- var StringDecoder;
- /*<replacement>*/
- var debug = require('util');
- if (debug && debug.debuglog) {
- debug = debug.debuglog('stream');
- } else {
- debug = function () {};
- }
- /*</replacement>*/
- util.inherits(Readable, Stream);
- function ReadableState(options, stream) {
- var Duplex = require('./_stream_duplex');
- options = options || {};
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- var defaultHwm = options.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
- this.buffer = [];
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = null;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex)
- this.objectMode = this.objectMode || !!options.readableObjectMode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // when piping, we only care about 'readable' events that happen
- // after read()ing all the bytes and not getting any pushback.
- this.ranOut = false;
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder)
- StringDecoder = require('string_decoder/').StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
- }
- function Readable(options) {
- var Duplex = require('./_stream_duplex');
- if (!(this instanceof Readable))
- return new Readable(options);
- this._readableState = new ReadableState(options, this);
- // legacy
- this.readable = true;
- Stream.call(this);
- }
- // Manually shove something into the read() buffer.
- // This returns true if the highWaterMark has not been hit yet,
- // similar to how Writable.write() returns true if you should
- // write() some more.
- Readable.prototype.push = function(chunk, encoding) {
- var state = this._readableState;
- if (util.isString(chunk) && !state.objectMode) {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = new Buffer(chunk, encoding);
- encoding = '';
- }
- }
- return readableAddChunk(this, state, chunk, encoding, false);
- };
- // Unshift should *always* be something directly out of read()
- Readable.prototype.unshift = function(chunk) {
- var state = this._readableState;
- return readableAddChunk(this, state, chunk, '', true);
- };
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
- var er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (util.isNullOrUndefined(chunk)) {
- state.reading = false;
- if (!state.ended)
- onEofChunk(stream, state);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (state.ended && !addToFront) {
- var e = new Error('stream.push() after EOF');
- stream.emit('error', e);
- } else if (state.endEmitted && addToFront) {
- var e = new Error('stream.unshift() after end event');
- stream.emit('error', e);
- } else {
- if (state.decoder && !addToFront && !encoding)
- chunk = state.decoder.write(chunk);
- if (!addToFront)
- state.reading = false;
- // if we want the data now, just emit it.
- if (state.flowing && state.length === 0 && !state.sync) {
- stream.emit('data', chunk);
- stream.read(0);
- } else {
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront)
- state.buffer.unshift(chunk);
- else
- state.buffer.push(chunk);
- if (state.needReadable)
- emitReadable(stream);
- }
- maybeReadMore(stream, state);
- }
- } else if (!addToFront) {
- state.reading = false;
- }
- return needMoreData(state);
- }
- // if it's past the high water mark, we can push in some more.
- // Also, if we have no data yet, we can stand some
- // more bytes. This is to work around cases where hwm=0,
- // such as the repl. Also, if the push() triggered a
- // readable event, and the user called read(largeNumber) such that
- // needReadable was set, then we ought to push more, so that another
- // 'readable' event will be triggered.
- function needMoreData(state) {
- return !state.ended &&
- (state.needReadable ||
- state.length < state.highWaterMark ||
- state.length === 0);
- }
- // backwards compatibility.
- Readable.prototype.setEncoding = function(enc) {
- if (!StringDecoder)
- StringDecoder = require('string_decoder/').StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- return this;
- };
- // Don't raise the hwm > 128MB
- var MAX_HWM = 0x800000;
- function roundUpToNextPowerOf2(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2
- n--;
- for (var p = 1; p < 32; p <<= 1) n |= n >> p;
- n++;
- }
- return n;
- }
- function howMuchToRead(n, state) {
- if (state.length === 0 && state.ended)
- return 0;
- if (state.objectMode)
- return n === 0 ? 0 : 1;
- if (isNaN(n) || util.isNull(n)) {
- // only flow one buffer at a time
- if (state.flowing && state.buffer.length)
- return state.buffer[0].length;
- else
- return state.length;
- }
- if (n <= 0)
- return 0;
- // If we're asking for more than the target buffer level,
- // then raise the water mark. Bump up to the next highest
- // power of 2, to prevent increasing it excessively in tiny
- // amounts.
- if (n > state.highWaterMark)
- state.highWaterMark = roundUpToNextPowerOf2(n);
- // don't have that much. return null, unless we've ended.
- if (n > state.length) {
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- } else
- return state.length;
- }
- return n;
- }
- // you can override either this method, or the async _read(n) below.
- Readable.prototype.read = function(n) {
- debug('read', n);
- var state = this._readableState;
- var nOrig = n;
- if (!util.isNumber(n) || n > 0)
- state.emittedReadable = false;
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 &&
- state.needReadable &&
- (state.length >= state.highWaterMark || state.ended)) {
- debug('read: emitReadable', state.length, state.ended);
- if (state.length === 0 && state.ended)
- endReadable(this);
- else
- emitReadable(this);
- return null;
- }
- n = howMuchToRead(n, state);
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- if (state.length === 0)
- endReadable(this);
- return null;
- }
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- debug('need readable', doRead);
- // if we currently have less than the highWaterMark, then also read some
- if (state.length === 0 || state.length - n < state.highWaterMark) {
- doRead = true;
- debug('length less than watermark', doRead);
- }
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading) {
- doRead = false;
- debug('reading or ended', doRead);
- }
- if (doRead) {
- debug('do read');
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0)
- state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- }
- // If _read pushed data synchronously, then `reading` will be false,
- // and we need to re-evaluate how much data we can return to the user.
- if (doRead && !state.reading)
- n = howMuchToRead(nOrig, state);
- var ret;
- if (n > 0)
- ret = fromList(n, state);
- else
- ret = null;
- if (util.isNull(ret)) {
- state.needReadable = true;
- n = 0;
- }
- state.length -= n;
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (state.length === 0 && !state.ended)
- state.needReadable = true;
- // If we tried to read() past the EOF, then emit end on the next tick.
- if (nOrig !== n && state.ended && state.length === 0)
- endReadable(this);
- if (!util.isNull(ret))
- this.emit('data', ret);
- return ret;
- };
- function chunkInvalid(state, chunk) {
- var er = null;
- if (!util.isBuffer(chunk) &&
- !util.isString(chunk) &&
- !util.isNullOrUndefined(chunk) &&
- !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
- }
- function onEofChunk(stream, state) {
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
- // emit 'readable' now to make sure it gets picked up.
- emitReadable(stream);
- }
- // Don't emit readable right away in sync mode, because this can trigger
- // another read() call => stack overflow. This way, it might trigger
- // a nextTick recursion warning, but that's not so bad.
- function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (!state.emittedReadable) {
- debug('emitReadable', state.flowing);
- state.emittedReadable = true;
- if (state.sync)
- process.nextTick(function() {
- emitReadable_(stream);
- });
- else
- emitReadable_(stream);
- }
- }
- function emitReadable_(stream) {
- debug('emit readable');
- stream.emit('readable');
- flow(stream);
- }
- // at this point, the user has presumably seen the 'readable' event,
- // and called read() to consume some data. that may have triggered
- // in turn another _read(n) call, in which case reading = true if
- // it's in progress.
- // However, if we're not ended, or reading, and the length < hwm,
- // then go ahead and try to read some more preemptively.
- function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- process.nextTick(function() {
- maybeReadMore_(stream, state);
- });
- }
- }
- function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended &&
- state.length < state.highWaterMark) {
- debug('maybeReadMore read 0');
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;
- else
- len = state.length;
- }
- state.readingMore = false;
- }
- // abstract method. to be overridden in specific implementation classes.
- // call cb(er, data) where data is <= n in length.
- // for virtual (non-string, non-buffer) streams, "length" is somewhat
- // arbitrary, and perhaps not very meaningful.
- Readable.prototype._read = function(n) {
- this.emit('error', new Error('not implemented'));
- };
- Readable.prototype.pipe = function(dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
- var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
- dest !== process.stdout &&
- dest !== process.stderr;
- var endFn = doEnd ? onend : cleanup;
- if (state.endEmitted)
- process.nextTick(endFn);
- else
- src.once('end', endFn);
- dest.on('unpipe', onunpipe);
- function onunpipe(readable) {
- debug('onunpipe');
- if (readable === src) {
- cleanup();
- }
- }
- function onend() {
- debug('onend');
- dest.end();
- }
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
- function cleanup() {
- debug('cleanup');
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', cleanup);
- src.removeListener('data', ondata);
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (state.awaitDrain &&
- (!dest._writableState || dest._writableState.needDrain))
- ondrain();
- }
- src.on('data', ondata);
- function ondata(chunk) {
- debug('ondata');
- var ret = dest.write(chunk);
- if (false === ret) {
- debug('false write response, pause',
- src._readableState.awaitDrain);
- src._readableState.awaitDrain++;
- src.pause();
- }
- }
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- debug('onerror', er);
- unpipe();
- dest.removeListener('error', onerror);
- if (EE.listenerCount(dest, 'error') === 0)
- dest.emit('error', er);
- }
- // This is a brutally ugly hack to make sure that our error handler
- // is attached before any userland ones. NEVER DO THIS.
- if (!dest._events || !dest._events.error)
- dest.on('error', onerror);
- else if (isArray(dest._events.error))
- dest._events.error.unshift(onerror);
- else
- dest._events.error = [onerror, dest._events.error];
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- debug('onfinish');
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
- function unpipe() {
- debug('unpipe');
- src.unpipe(dest);
- }
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- debug('pipe resume');
- src.resume();
- }
- return dest;
- };
- function pipeOnDrain(src) {
- return function() {
- var state = src._readableState;
- debug('pipeOnDrain', state.awaitDrain);
- if (state.awaitDrain)
- state.awaitDrain--;
- if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {
- state.flowing = true;
- flow(src);
- }
- };
- }
- Readable.prototype.unpipe = function(dest) {
- var state = this._readableState;
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0)
- return this;
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes)
- return this;
- if (!dest)
- dest = state.pipes;
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- if (dest)
- dest.emit('unpipe', this);
- return this;
- }
- // slow case. multiple pipe destinations.
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- for (var i = 0; i < len; i++)
- dests[i].emit('unpipe', this);
- return this;
- }
- // try to find the right one.
- var i = indexOf(state.pipes, dest);
- if (i === -1)
- return this;
- state.pipes.splice(i, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1)
- state.pipes = state.pipes[0];
- dest.emit('unpipe', this);
- return this;
- };
- // set up data events if they are asked for
- // Ensure readable listeners eventually get something
- Readable.prototype.on = function(ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
- // If listening to data, and it has not explicitly been paused,
- // then call resume to start the flow of data on the next tick.
- if (ev === 'data' && false !== this._readableState.flowing) {
- this.resume();
- }
- if (ev === 'readable' && this.readable) {
- var state = this._readableState;
- if (!state.readableListening) {
- state.readableListening = true;
- state.emittedReadable = false;
- state.needReadable = true;
- if (!state.reading) {
- var self = this;
- process.nextTick(function() {
- debug('readable nexttick read 0');
- self.read(0);
- });
- } else if (state.length) {
- emitReadable(this, state);
- }
- }
- }
- return res;
- };
- Readable.prototype.addListener = Readable.prototype.on;
- // pause() and resume() are remnants of the legacy readable stream API
- // If the user uses them, then switch into old mode.
- Readable.prototype.resume = function() {
- var state = this._readableState;
- if (!state.flowing) {
- debug('resume');
- state.flowing = true;
- if (!state.reading) {
- debug('resume read 0');
- this.read(0);
- }
- resume(this, state);
- }
- return this;
- };
- function resume(stream, state) {
- if (!state.resumeScheduled) {
- state.resumeScheduled = true;
- process.nextTick(function() {
- resume_(stream, state);
- });
- }
- }
- function resume_(stream, state) {
- state.resumeScheduled = false;
- stream.emit('resume');
- flow(stream);
- if (state.flowing && !state.reading)
- stream.read(0);
- }
- Readable.prototype.pause = function() {
- debug('call pause flowing=%j', this._readableState.flowing);
- if (false !== this._readableState.flowing) {
- debug('pause');
- this._readableState.flowing = false;
- this.emit('pause');
- }
- return this;
- };
- function flow(stream) {
- var state = stream._readableState;
- debug('flow', state.flowing);
- if (state.flowing) {
- do {
- var chunk = stream.read();
- } while (null !== chunk && state.flowing);
- }
- }
- // wrap an old-style stream as the async data source.
- // This is *not* part of the readable stream interface.
- // It is an ugly unfortunate mess of history.
- Readable.prototype.wrap = function(stream) {
- var state = this._readableState;
- var paused = false;
- var self = this;
- stream.on('end', function() {
- debug('wrapped end');
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length)
- self.push(chunk);
- }
- self.push(null);
- });
- stream.on('data', function(chunk) {
- debug('wrapped data');
- if (state.decoder)
- chunk = state.decoder.write(chunk);
- if (!chunk || !state.objectMode && !chunk.length)
- return;
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
- this[i] = function(method) { return function() {
- return stream[method].apply(stream, arguments);
- }}(i);
- }
- }
- // proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function(ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function(n) {
- debug('wrapped _read', n);
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
- return self;
- };
- // exposed for testing purposes only.
- Readable._fromList = fromList;
- // Pluck off n bytes from an array of buffers.
- // Length is the combined lengths of all the buffers in the list.
- function fromList(n, state) {
- var list = state.buffer;
- var length = state.length;
- var stringMode = !!state.decoder;
- var objectMode = !!state.objectMode;
- var ret;
- // nothing in the list, definitely empty.
- if (list.length === 0)
- return null;
- if (length === 0)
- ret = null;
- else if (objectMode)
- ret = list.shift();
- else if (!n || n >= length) {
- // read it all, truncate the array.
- if (stringMode)
- ret = list.join('');
- else
- ret = Buffer.concat(list, length);
- list.length = 0;
- } else {
- // read just some of it.
- if (n < list[0].length) {
- // just take a part of the first list item.
- // slice is the same for buffers and strings.
- var buf = list[0];
- ret = buf.slice(0, n);
- list[0] = buf.slice(n);
- } else if (n === list[0].length) {
- // first list is a perfect match
- ret = list.shift();
- } else {
- // complex case.
- // we have enough to cover it, but it spans past the first buffer.
- if (stringMode)
- ret = '';
- else
- ret = new Buffer(n);
- var c = 0;
- for (var i = 0, l = list.length; i < l && c < n; i++) {
- var buf = list[0];
- var cpy = Math.min(n - c, buf.length);
- if (stringMode)
- ret += buf.slice(0, cpy);
- else
- buf.copy(ret, c, 0, cpy);
- if (cpy < buf.length)
- list[0] = buf.slice(cpy);
- else
- list.shift();
- c += cpy;
- }
- }
- }
- return ret;
- }
- function endReadable(stream) {
- var state = stream._readableState;
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0)
- throw new Error('endReadable called on non-empty stream');
- if (!state.endEmitted) {
- state.ended = true;
- process.nextTick(function() {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
- });
- }
- }
- function forEach (xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- function indexOf (xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
- }
- }).call(this,require('_process'))
- },{"./_stream_duplex":202,"_process":200,"buffer":192,"core-util-is":207,"events":196,"inherits":197,"isarray":198,"stream":212,"string_decoder/":213,"util":191}],205:[function(require,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // a transform stream is a readable/writable stream where you do
- // something with the data. Sometimes it's called a "filter",
- // but that's not a great name for it, since that implies a thing where
- // some bits pass through, and others are simply ignored. (That would
- // be a valid example of a transform, of course.)
- //
- // While the output is causally related to the input, it's not a
- // necessarily symmetric or synchronous transformation. For example,
- // a zlib stream might take multiple plain-text writes(), and then
- // emit a single compressed chunk some time in the future.
- //
- // Here's how this works:
- //
- // The Transform stream has all the aspects of the readable and writable
- // stream classes. When you write(chunk), that calls _write(chunk,cb)
- // internally, and returns false if there's a lot of pending writes
- // buffered up. When you call read(), that calls _read(n) until
- // there's enough pending readable data buffered up.
- //
- // In a transform stream, the written data is placed in a buffer. When
- // _read(n) is called, it transforms the queued up data, calling the
- // buffered _write cb's as it consumes chunks. If consuming a single
- // written chunk would result in multiple output chunks, then the first
- // outputted bit calls the readcb, and subsequent chunks just go into
- // the read buffer, and will cause it to emit 'readable' if necessary.
- //
- // This way, back-pressure is actually determined by the reading side,
- // since _read has to be called to start processing a new chunk. However,
- // a pathological inflate type of transform can cause excessive buffering
- // here. For example, imagine a stream where every byte of input is
- // interpreted as an integer from 0-255, and then results in that many
- // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
- // 1kb of data being output. In this case, you could write a very small
- // amount of input, and end up with a very large amount of output. In
- // such a pathological inflating mechanism, there'd be no way to tell
- // the system to stop doing the transform. A single 4MB write could
- // cause the system to run out of memory.
- //
- // However, even in such a pathological case, only a single written chunk
- // would be consumed, and then the rest would wait (un-transformed) until
- // the results of the previous transformed chunk were consumed.
- module.exports = Transform;
- var Duplex = require('./_stream_duplex');
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- util.inherits(Transform, Duplex);
- function TransformState(options, stream) {
- this.afterTransform = function(er, data) {
- return afterTransform(stream, er, data);
- };
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- }
- function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
- var cb = ts.writecb;
- if (!cb)
- return stream.emit('error', new Error('no writecb in Transform class'));
- ts.writechunk = null;
- ts.writecb = null;
- if (!util.isNullOrUndefined(data))
- stream.push(data);
- if (cb)
- cb(er);
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
- }
- function Transform(options) {
- if (!(this instanceof Transform))
- return new Transform(options);
- Duplex.call(this, options);
- this._transformState = new TransformState(options, this);
- // when the writable side finishes, then flush out anything remaining.
- var stream = this;
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
- this.once('prefinish', function() {
- if (util.isFunction(this._flush))
- this._flush(function(er) {
- done(stream, er);
- });
- else
- done(stream);
- });
- }
- Transform.prototype.push = function(chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
- };
- // This is the part where you do stuff!
- // override this function in implementation classes.
- // 'chunk' is an input chunk.
- //
- // Call `push(newChunk)` to pass along transformed output
- // to the readable side. You may call 'push' zero or more times.
- //
- // Call `cb(err)` when you are done with this chunk. If you pass
- // an error, then that'll put the hurt on the whole operation. If you
- // never call cb(), then you'll never get another chunk.
- Transform.prototype._transform = function(chunk, encoding, cb) {
- throw new Error('not implemented');
- };
- Transform.prototype._write = function(chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform ||
- rs.needReadable ||
- rs.length < rs.highWaterMark)
- this._read(rs.highWaterMark);
- }
- };
- // Doesn't matter what the args are here.
- // _transform does all the work.
- // That we got here means that the readable side wants more data.
- Transform.prototype._read = function(n) {
- var ts = this._transformState;
- if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
- };
- function done(stream, er) {
- if (er)
- return stream.emit('error', er);
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var ts = stream._transformState;
- if (ws.length)
- throw new Error('calling transform done when ws.length != 0');
- if (ts.transforming)
- throw new Error('calling transform done when still transforming');
- return stream.push(null);
- }
- },{"./_stream_duplex":202,"core-util-is":207,"inherits":197}],206:[function(require,module,exports){
- (function (process){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // A bit simpler than readable streams.
- // Implement an async ._write(chunk, cb), and it'll handle all
- // the drain event emission and buffering.
- module.exports = Writable;
- /*<replacement>*/
- var Buffer = require('buffer').Buffer;
- /*</replacement>*/
- Writable.WritableState = WritableState;
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- var Stream = require('stream');
- util.inherits(Writable, Stream);
- function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- }
- function WritableState(options, stream) {
- var Duplex = require('./_stream_duplex');
- options = options || {};
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- var defaultHwm = options.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex)
- this.objectMode = this.objectMode || !!options.writableObjectMode;
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
- // a flag to see when we're in the middle of a write.
- this.writing = false;
- // when true all writes will be buffered until .uncork() call
- this.corked = 0;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function(er) {
- onwrite(stream, er);
- };
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
- // the amount that is being written when _write is called.
- this.writelen = 0;
- this.buffer = [];
- // number of pending user-supplied write callbacks
- // this must be 0 before 'finish' can be emitted
- this.pendingcb = 0;
- // emit prefinish if the only thing we're waiting for is _write cbs
- // This is relevant for synchronous Transform streams
- this.prefinished = false;
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
- }
- function Writable(options) {
- var Duplex = require('./_stream_duplex');
- // Writable ctor is applied to Duplexes, though they're not
- // instanceof Writable, they're instanceof Readable.
- if (!(this instanceof Writable) && !(this instanceof Duplex))
- return new Writable(options);
- this._writableState = new WritableState(options, this);
- // legacy.
- this.writable = true;
- Stream.call(this);
- }
- // Otherwise people can pipe Writable streams, which is just wrong.
- Writable.prototype.pipe = function() {
- this.emit('error', new Error('Cannot pipe. Not readable.'));
- };
- function writeAfterEnd(stream, state, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- process.nextTick(function() {
- cb(er);
- });
- }
- // If we get something that is not a buffer, string, null, or undefined,
- // and we're not in objectMode, then that's an error.
- // Otherwise stream chunks are all considered to be of length=1, and the
- // watermarks determine how many objects to keep in the buffer, rather than
- // how many bytes or characters.
- function validChunk(stream, state, chunk, cb) {
- var valid = true;
- if (!util.isBuffer(chunk) &&
- !util.isString(chunk) &&
- !util.isNullOrUndefined(chunk) &&
- !state.objectMode) {
- var er = new TypeError('Invalid non-string/buffer chunk');
- stream.emit('error', er);
- process.nextTick(function() {
- cb(er);
- });
- valid = false;
- }
- return valid;
- }
- Writable.prototype.write = function(chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- if (util.isFunction(encoding)) {
- cb = encoding;
- encoding = null;
- }
- if (util.isBuffer(chunk))
- encoding = 'buffer';
- else if (!encoding)
- encoding = state.defaultEncoding;
- if (!util.isFunction(cb))
- cb = function() {};
- if (state.ended)
- writeAfterEnd(this, state, cb);
- else if (validChunk(this, state, chunk, cb)) {
- state.pendingcb++;
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
- }
- return ret;
- };
- Writable.prototype.cork = function() {
- var state = this._writableState;
- state.corked++;
- };
- Writable.prototype.uncork = function() {
- var state = this._writableState;
- if (state.corked) {
- state.corked--;
- if (!state.writing &&
- !state.corked &&
- !state.finished &&
- !state.bufferProcessing &&
- state.buffer.length)
- clearBuffer(this, state);
- }
- };
- function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode &&
- state.decodeStrings !== false &&
- util.isString(chunk)) {
- chunk = new Buffer(chunk, encoding);
- }
- return chunk;
- }
- // if we're already writing something, then just put this
- // in the queue, and wait our turn. Otherwise, call _write
- // If we return false, then we need a drain event, so set that flag.
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
- chunk = decodeChunk(state, chunk, encoding);
- if (util.isBuffer(chunk))
- encoding = 'buffer';
- var len = state.objectMode ? 1 : chunk.length;
- state.length += len;
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret)
- state.needDrain = true;
- if (state.writing || state.corked)
- state.buffer.push(new WriteReq(chunk, encoding, cb));
- else
- doWrite(stream, state, false, len, chunk, encoding, cb);
- return ret;
- }
- function doWrite(stream, state, writev, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- if (writev)
- stream._writev(chunk, state.onwrite);
- else
- stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
- }
- function onwriteError(stream, state, sync, er, cb) {
- if (sync)
- process.nextTick(function() {
- state.pendingcb--;
- cb(er);
- });
- else {
- state.pendingcb--;
- cb(er);
- }
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- }
- function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
- }
- function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
- onwriteStateUpdate(state);
- if (er)
- onwriteError(stream, state, sync, er, cb);
- else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(stream, state);
- if (!finished &&
- !state.corked &&
- !state.bufferProcessing &&
- state.buffer.length) {
- clearBuffer(stream, state);
- }
- if (sync) {
- process.nextTick(function() {
- afterWrite(stream, state, finished, cb);
- });
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
- }
- function afterWrite(stream, state, finished, cb) {
- if (!finished)
- onwriteDrain(stream, state);
- state.pendingcb--;
- cb();
- finishMaybe(stream, state);
- }
- // Must force callback to be called on nextTick, so that we don't
- // emit 'drain' before the write() consumer gets the 'false' return
- // value, and has a chance to attach a 'drain' listener.
- function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
- }
- // if there's something in the buffer waiting, then process it
- function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- if (stream._writev && state.buffer.length > 1) {
- // Fast case, write everything using _writev()
- var cbs = [];
- for (var c = 0; c < state.buffer.length; c++)
- cbs.push(state.buffer[c].callback);
- // count the one we are adding, as well.
- // TODO(isaacs) clean this up
- state.pendingcb++;
- doWrite(stream, state, true, state.length, state.buffer, '', function(err) {
- for (var i = 0; i < cbs.length; i++) {
- state.pendingcb--;
- cbs[i](err);
- }
- });
- // Clear buffer
- state.buffer = [];
- } else {
- // Slow case, write chunks one-by-one
- for (var c = 0; c < state.buffer.length; c++) {
- var entry = state.buffer[c];
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
- doWrite(stream, state, false, len, chunk, encoding, cb);
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- c++;
- break;
- }
- }
- if (c < state.buffer.length)
- state.buffer = state.buffer.slice(c);
- else
- state.buffer.length = 0;
- }
- state.bufferProcessing = false;
- }
- Writable.prototype._write = function(chunk, encoding, cb) {
- cb(new Error('not implemented'));
- };
- Writable.prototype._writev = null;
- Writable.prototype.end = function(chunk, encoding, cb) {
- var state = this._writableState;
- if (util.isFunction(chunk)) {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (util.isFunction(encoding)) {
- cb = encoding;
- encoding = null;
- }
- if (!util.isNullOrUndefined(chunk))
- this.write(chunk, encoding);
- // .end() fully uncorks
- if (state.corked) {
- state.corked = 1;
- this.uncork();
- }
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished)
- endWritable(this, state, cb);
- };
- function needFinish(stream, state) {
- return (state.ending &&
- state.length === 0 &&
- !state.finished &&
- !state.writing);
- }
- function prefinish(stream, state) {
- if (!state.prefinished) {
- state.prefinished = true;
- stream.emit('prefinish');
- }
- }
- function finishMaybe(stream, state) {
- var need = needFinish(stream, state);
- if (need) {
- if (state.pendingcb === 0) {
- prefinish(stream, state);
- state.finished = true;
- stream.emit('finish');
- } else
- prefinish(stream, state);
- }
- return need;
- }
- function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished)
- process.nextTick(cb);
- else
- stream.once('finish', cb);
- }
- state.ended = true;
- }
- }).call(this,require('_process'))
- },{"./_stream_duplex":202,"_process":200,"buffer":192,"core-util-is":207,"inherits":197,"stream":212}],207:[function(require,module,exports){
- (function (Buffer){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
- function isArray(ar) {
- return Array.isArray(ar);
- }
- exports.isArray = isArray;
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
- function isRegExp(re) {
- return isObject(re) && objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
- function isDate(d) {
- return isObject(d) && objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
- function isError(e) {
- return isObject(e) &&
- (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
- function isBuffer(arg) {
- return Buffer.isBuffer(arg);
- }
- exports.isBuffer = isBuffer;
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
- }).call(this,require("buffer").Buffer)
- },{"buffer":192}],208:[function(require,module,exports){
- module.exports = require("./lib/_stream_passthrough.js")
- },{"./lib/_stream_passthrough.js":203}],209:[function(require,module,exports){
- exports = module.exports = require('./lib/_stream_readable.js');
- exports.Stream = require('stream');
- exports.Readable = exports;
- exports.Writable = require('./lib/_stream_writable.js');
- exports.Duplex = require('./lib/_stream_duplex.js');
- exports.Transform = require('./lib/_stream_transform.js');
- exports.PassThrough = require('./lib/_stream_passthrough.js');
- },{"./lib/_stream_duplex.js":202,"./lib/_stream_passthrough.js":203,"./lib/_stream_readable.js":204,"./lib/_stream_transform.js":205,"./lib/_stream_writable.js":206,"stream":212}],210:[function(require,module,exports){
- module.exports = require("./lib/_stream_transform.js")
- },{"./lib/_stream_transform.js":205}],211:[function(require,module,exports){
- module.exports = require("./lib/_stream_writable.js")
- },{"./lib/_stream_writable.js":206}],212:[function(require,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- module.exports = Stream;
- var EE = require('events').EventEmitter;
- var inherits = require('inherits');
- inherits(Stream, EE);
- Stream.Readable = require('readable-stream/readable.js');
- Stream.Writable = require('readable-stream/writable.js');
- Stream.Duplex = require('readable-stream/duplex.js');
- Stream.Transform = require('readable-stream/transform.js');
- Stream.PassThrough = require('readable-stream/passthrough.js');
- // Backwards-compat with node 0.4.x
- Stream.Stream = Stream;
- // old-style streams. Note that the pipe method (the only relevant
- // part of this class) is overridden in the Readable class.
- function Stream() {
- EE.call(this);
- }
- Stream.prototype.pipe = function(dest, options) {
- var source = this;
- function ondata(chunk) {
- if (dest.writable) {
- if (false === dest.write(chunk) && source.pause) {
- source.pause();
- }
- }
- }
- source.on('data', ondata);
- function ondrain() {
- if (source.readable && source.resume) {
- source.resume();
- }
- }
- dest.on('drain', ondrain);
- // If the 'end' option is not supplied, dest.end() will be called when
- // source gets the 'end' or 'close' events. Only dest.end() once.
- if (!dest._isStdio && (!options || options.end !== false)) {
- source.on('end', onend);
- source.on('close', onclose);
- }
- var didOnEnd = false;
- function onend() {
- if (didOnEnd) return;
- didOnEnd = true;
- dest.end();
- }
- function onclose() {
- if (didOnEnd) return;
- didOnEnd = true;
- if (typeof dest.destroy === 'function') dest.destroy();
- }
- // don't leave dangling pipes when there are errors.
- function onerror(er) {
- cleanup();
- if (EE.listenerCount(this, 'error') === 0) {
- throw er; // Unhandled stream error in pipe.
- }
- }
- source.on('error', onerror);
- dest.on('error', onerror);
- // remove all the event listeners that were added.
- function cleanup() {
- source.removeListener('data', ondata);
- dest.removeListener('drain', ondrain);
- source.removeListener('end', onend);
- source.removeListener('close', onclose);
- source.removeListener('error', onerror);
- dest.removeListener('error', onerror);
- source.removeListener('end', cleanup);
- source.removeListener('close', cleanup);
- dest.removeListener('close', cleanup);
- }
- source.on('end', cleanup);
- source.on('close', cleanup);
- dest.on('close', cleanup);
- dest.emit('pipe', source);
- // Allow for unix-like usage: A.pipe(B).pipe(C)
- return dest;
- };
- },{"events":196,"inherits":197,"readable-stream/duplex.js":201,"readable-stream/passthrough.js":208,"readable-stream/readable.js":209,"readable-stream/transform.js":210,"readable-stream/writable.js":211}],213:[function(require,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var Buffer = require('buffer').Buffer;
- var isBufferEncoding = Buffer.isEncoding
- || function(encoding) {
- switch (encoding && encoding.toLowerCase()) {
- case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
- default: return false;
- }
- }
- function assertEncoding(encoding) {
- if (encoding && !isBufferEncoding(encoding)) {
- throw new Error('Unknown encoding: ' + encoding);
- }
- }
- // StringDecoder provides an interface for efficiently splitting a series of
- // buffers into a series of JS strings without breaking apart multi-byte
- // characters. CESU-8 is handled as part of the UTF-8 encoding.
- //
- // @TODO Handling all encodings inside a single object makes it very difficult
- // to reason about this code, so it should be split up in the future.
- // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
- // points as used by CESU-8.
- var StringDecoder = exports.StringDecoder = function(encoding) {
- this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
- assertEncoding(encoding);
- switch (this.encoding) {
- case 'utf8':
- // CESU-8 represents each of Surrogate Pair by 3-bytes
- this.surrogateSize = 3;
- break;
- case 'ucs2':
- case 'utf16le':
- // UTF-16 represents each of Surrogate Pair by 2-bytes
- this.surrogateSize = 2;
- this.detectIncompleteChar = utf16DetectIncompleteChar;
- break;
- case 'base64':
- // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
- this.surrogateSize = 3;
- this.detectIncompleteChar = base64DetectIncompleteChar;
- break;
- default:
- this.write = passThroughWrite;
- return;
- }
- // Enough space to store all bytes of a single character. UTF-8 needs 4
- // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
- this.charBuffer = new Buffer(6);
- // Number of bytes received for the current incomplete multi-byte character.
- this.charReceived = 0;
- // Number of bytes expected for the current incomplete multi-byte character.
- this.charLength = 0;
- };
- // write decodes the given buffer and returns it as JS string that is
- // guaranteed to not contain any partial multi-byte characters. Any partial
- // character found at the end of the buffer is buffered up, and will be
- // returned when calling write again with the remaining bytes.
- //
- // Note: Converting a Buffer containing an orphan surrogate to a String
- // currently works, but converting a String to a Buffer (via `new Buffer`, or
- // Buffer#write) will replace incomplete surrogates with the unicode
- // replacement character. See https://codereview.chromium.org/121173009/ .
- StringDecoder.prototype.write = function(buffer) {
- var charStr = '';
- // if our last write ended with an incomplete multibyte character
- while (this.charLength) {
- // determine how many remaining bytes this buffer has to offer for this char
- var available = (buffer.length >= this.charLength - this.charReceived) ?
- this.charLength - this.charReceived :
- buffer.length;
- // add the new bytes to the char buffer
- buffer.copy(this.charBuffer, this.charReceived, 0, available);
- this.charReceived += available;
- if (this.charReceived < this.charLength) {
- // still not enough chars in this buffer? wait for more ...
- return '';
- }
- // remove bytes belonging to the current character from the buffer
- buffer = buffer.slice(available, buffer.length);
- // get the character that was split
- charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- var charCode = charStr.charCodeAt(charStr.length - 1);
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- this.charLength += this.surrogateSize;
- charStr = '';
- continue;
- }
- this.charReceived = this.charLength = 0;
- // if there are no more bytes in this buffer, just emit our char
- if (buffer.length === 0) {
- return charStr;
- }
- break;
- }
- // determine and set charLength / charReceived
- this.detectIncompleteChar(buffer);
- var end = buffer.length;
- if (this.charLength) {
- // buffer the incomplete character bytes we got
- buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
- end -= this.charReceived;
- }
- charStr += buffer.toString(this.encoding, 0, end);
- var end = charStr.length - 1;
- var charCode = charStr.charCodeAt(end);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- var size = this.surrogateSize;
- this.charLength += size;
- this.charReceived += size;
- this.charBuffer.copy(this.charBuffer, size, 0, size);
- buffer.copy(this.charBuffer, 0, 0, size);
- return charStr.substring(0, end);
- }
- // or just emit the charStr
- return charStr;
- };
- // detectIncompleteChar determines if there is an incomplete UTF-8 character at
- // the end of the given buffer. If so, it sets this.charLength to the byte
- // length that character, and sets this.charReceived to the number of bytes
- // that are available for this character.
- StringDecoder.prototype.detectIncompleteChar = function(buffer) {
- // determine how many bytes we have to check at the end of this buffer
- var i = (buffer.length >= 3) ? 3 : buffer.length;
- // Figure out if one of the last i bytes of our buffer announces an
- // incomplete char.
- for (; i > 0; i--) {
- var c = buffer[buffer.length - i];
- // See http://en.wikipedia.org/wiki/UTF-8#Description
- // 110XXXXX
- if (i == 1 && c >> 5 == 0x06) {
- this.charLength = 2;
- break;
- }
- // 1110XXXX
- if (i <= 2 && c >> 4 == 0x0E) {
- this.charLength = 3;
- break;
- }
- // 11110XXX
- if (i <= 3 && c >> 3 == 0x1E) {
- this.charLength = 4;
- break;
- }
- }
- this.charReceived = i;
- };
- StringDecoder.prototype.end = function(buffer) {
- var res = '';
- if (buffer && buffer.length)
- res = this.write(buffer);
- if (this.charReceived) {
- var cr = this.charReceived;
- var buf = this.charBuffer;
- var enc = this.encoding;
- res += buf.slice(0, cr).toString(enc);
- }
- return res;
- };
- function passThroughWrite(buffer) {
- return buffer.toString(this.encoding);
- }
- function utf16DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 2;
- this.charLength = this.charReceived ? 2 : 0;
- }
- function base64DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 3;
- this.charLength = this.charReceived ? 3 : 0;
- }
- },{"buffer":192}],214:[function(require,module,exports){
- exports.isatty = function () { return false; };
- function ReadStream() {
- throw new Error('tty.ReadStream is not implemented');
- }
- exports.ReadStream = ReadStream;
- function WriteStream() {
- throw new Error('tty.ReadStream is not implemented');
- }
- exports.WriteStream = WriteStream;
- },{}],215:[function(require,module,exports){
- module.exports = function isBuffer(arg) {
- return arg && typeof arg === 'object'
- && typeof arg.copy === 'function'
- && typeof arg.fill === 'function'
- && typeof arg.readUInt8 === 'function';
- }
- },{}],216:[function(require,module,exports){
- (function (process,global){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var formatRegExp = /%[sdj%]/g;
- exports.format = function(f) {
- if (!isString(f)) {
- var objects = [];
- for (var i = 0; i < arguments.length; i++) {
- objects.push(inspect(arguments[i]));
- }
- return objects.join(' ');
- }
- var i = 1;
- var args = arguments;
- var len = args.length;
- var str = String(f).replace(formatRegExp, function(x) {
- if (x === '%%') return '%';
- if (i >= len) return x;
- switch (x) {
- case '%s': return String(args[i++]);
- case '%d': return Number(args[i++]);
- case '%j':
- try {
- return JSON.stringify(args[i++]);
- } catch (_) {
- return '[Circular]';
- }
- default:
- return x;
- }
- });
- for (var x = args[i]; i < len; x = args[++i]) {
- if (isNull(x) || !isObject(x)) {
- str += ' ' + x;
- } else {
- str += ' ' + inspect(x);
- }
- }
- return str;
- };
- // Mark that a method should not be used.
- // Returns a modified function which warns once by default.
- // If --no-deprecation is set, then it is a no-op.
- exports.deprecate = function(fn, msg) {
- // Allow for deprecating things in the process of starting up.
- if (isUndefined(global.process)) {
- return function() {
- return exports.deprecate(fn, msg).apply(this, arguments);
- };
- }
- if (process.noDeprecation === true) {
- return fn;
- }
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
- } else {
- console.error(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
- return deprecated;
- };
- var debugs = {};
- var debugEnviron;
- exports.debuglog = function(set) {
- if (isUndefined(debugEnviron))
- debugEnviron = process.env.NODE_DEBUG || '';
- set = set.toUpperCase();
- if (!debugs[set]) {
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
- var pid = process.pid;
- debugs[set] = function() {
- var msg = exports.format.apply(exports, arguments);
- console.error('%s %d: %s', set, pid, msg);
- };
- } else {
- debugs[set] = function() {};
- }
- }
- return debugs[set];
- };
- /**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
- *
- * @param {Object} obj The object to print out.
- * @param {Object} opts Optional options object that alters the output.
- */
- /* legacy: obj, showHidden, depth, colors*/
- function inspect(obj, opts) {
- // default options
- var ctx = {
- seen: [],
- stylize: stylizeNoColor
- };
- // legacy...
- if (arguments.length >= 3) ctx.depth = arguments[2];
- if (arguments.length >= 4) ctx.colors = arguments[3];
- if (isBoolean(opts)) {
- // legacy...
- ctx.showHidden = opts;
- } else if (opts) {
- // got an "options" object
- exports._extend(ctx, opts);
- }
- // set default options
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
- if (isUndefined(ctx.depth)) ctx.depth = 2;
- if (isUndefined(ctx.colors)) ctx.colors = false;
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
- if (ctx.colors) ctx.stylize = stylizeWithColor;
- return formatValue(ctx, obj, ctx.depth);
- }
- exports.inspect = inspect;
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
- inspect.colors = {
- 'bold' : [1, 22],
- 'italic' : [3, 23],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- 'white' : [37, 39],
- 'grey' : [90, 39],
- 'black' : [30, 39],
- 'blue' : [34, 39],
- 'cyan' : [36, 39],
- 'green' : [32, 39],
- 'magenta' : [35, 39],
- 'red' : [31, 39],
- 'yellow' : [33, 39]
- };
- // Don't use 'blue' not visible on cmd.exe
- inspect.styles = {
- 'special': 'cyan',
- 'number': 'yellow',
- 'boolean': 'yellow',
- 'undefined': 'grey',
- 'null': 'bold',
- 'string': 'green',
- 'date': 'magenta',
- // "name": intentionally not styling
- 'regexp': 'red'
- };
- function stylizeWithColor(str, styleType) {
- var style = inspect.styles[styleType];
- if (style) {
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
- '\u001b[' + inspect.colors[style][1] + 'm';
- } else {
- return str;
- }
- }
- function stylizeNoColor(str, styleType) {
- return str;
- }
- function arrayToHash(array) {
- var hash = {};
- array.forEach(function(val, idx) {
- hash[val] = true;
- });
- return hash;
- }
- function formatValue(ctx, value, recurseTimes) {
- // Provide a hook for user-specified inspect functions.
- // Check that value is an object with an inspect function on it
- if (ctx.customInspect &&
- value &&
- isFunction(value.inspect) &&
- // Filter out the util module, it's inspect function is special
- value.inspect !== exports.inspect &&
- // Also filter out any prototype objects using the circular check.
- !(value.constructor && value.constructor.prototype === value)) {
- var ret = value.inspect(recurseTimes, ctx);
- if (!isString(ret)) {
- ret = formatValue(ctx, ret, recurseTimes);
- }
- return ret;
- }
- // Primitive types cannot have properties
- var primitive = formatPrimitive(ctx, value);
- if (primitive) {
- return primitive;
- }
- // Look up the keys of the object.
- var keys = Object.keys(value);
- var visibleKeys = arrayToHash(keys);
- if (ctx.showHidden) {
- keys = Object.getOwnPropertyNames(value);
- }
- // IE doesn't make error fields non-enumerable
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
- if (isError(value)
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
- return formatError(value);
- }
- // Some type of object without properties can be shortcutted.
- if (keys.length === 0) {
- if (isFunction(value)) {
- var name = value.name ? ': ' + value.name : '';
- return ctx.stylize('[Function' + name + ']', 'special');
- }
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- }
- if (isDate(value)) {
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
- }
- if (isError(value)) {
- return formatError(value);
- }
- }
- var base = '', array = false, braces = ['{', '}'];
- // Make Array say that they are Array
- if (isArray(value)) {
- array = true;
- braces = ['[', ']'];
- }
- // Make functions say that they are functions
- if (isFunction(value)) {
- var n = value.name ? ': ' + value.name : '';
- base = ' [Function' + n + ']';
- }
- // Make RegExps say that they are RegExps
- if (isRegExp(value)) {
- base = ' ' + RegExp.prototype.toString.call(value);
- }
- // Make dates with properties first say the date
- if (isDate(value)) {
- base = ' ' + Date.prototype.toUTCString.call(value);
- }
- // Make error with message first say the error
- if (isError(value)) {
- base = ' ' + formatError(value);
- }
- if (keys.length === 0 && (!array || value.length == 0)) {
- return braces[0] + base + braces[1];
- }
- if (recurseTimes < 0) {
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- } else {
- return ctx.stylize('[Object]', 'special');
- }
- }
- ctx.seen.push(value);
- var output;
- if (array) {
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
- } else {
- output = keys.map(function(key) {
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
- });
- }
- ctx.seen.pop();
- return reduceToSingleString(output, base, braces);
- }
- function formatPrimitive(ctx, value) {
- if (isUndefined(value))
- return ctx.stylize('undefined', 'undefined');
- if (isString(value)) {
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
- .replace(/'/g, "\\'")
- .replace(/\\"/g, '"') + '\'';
- return ctx.stylize(simple, 'string');
- }
- if (isNumber(value))
- return ctx.stylize('' + value, 'number');
- if (isBoolean(value))
- return ctx.stylize('' + value, 'boolean');
- // For some reason typeof null is "object", so special case here.
- if (isNull(value))
- return ctx.stylize('null', 'null');
- }
- function formatError(value) {
- return '[' + Error.prototype.toString.call(value) + ']';
- }
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
- var output = [];
- for (var i = 0, l = value.length; i < l; ++i) {
- if (hasOwnProperty(value, String(i))) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- String(i), true));
- } else {
- output.push('');
- }
- }
- keys.forEach(function(key) {
- if (!key.match(/^\d+$/)) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- key, true));
- }
- });
- return output;
- }
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
- var name, str, desc;
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
- if (desc.get) {
- if (desc.set) {
- str = ctx.stylize('[Getter/Setter]', 'special');
- } else {
- str = ctx.stylize('[Getter]', 'special');
- }
- } else {
- if (desc.set) {
- str = ctx.stylize('[Setter]', 'special');
- }
- }
- if (!hasOwnProperty(visibleKeys, key)) {
- name = '[' + key + ']';
- }
- if (!str) {
- if (ctx.seen.indexOf(desc.value) < 0) {
- if (isNull(recurseTimes)) {
- str = formatValue(ctx, desc.value, null);
- } else {
- str = formatValue(ctx, desc.value, recurseTimes - 1);
- }
- if (str.indexOf('\n') > -1) {
- if (array) {
- str = str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n').substr(2);
- } else {
- str = '\n' + str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n');
- }
- }
- } else {
- str = ctx.stylize('[Circular]', 'special');
- }
- }
- if (isUndefined(name)) {
- if (array && key.match(/^\d+$/)) {
- return str;
- }
- name = JSON.stringify('' + key);
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = ctx.stylize(name, 'name');
- } else {
- name = name.replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
- name = ctx.stylize(name, 'string');
- }
- }
- return name + ': ' + str;
- }
- function reduceToSingleString(output, base, braces) {
- var numLinesEst = 0;
- var length = output.reduce(function(prev, cur) {
- numLinesEst++;
- if (cur.indexOf('\n') >= 0) numLinesEst++;
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
- }, 0);
- if (length > 60) {
- return braces[0] +
- (base === '' ? '' : base + '\n ') +
- ' ' +
- output.join(',\n ') +
- ' ' +
- braces[1];
- }
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
- }
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
- function isArray(ar) {
- return Array.isArray(ar);
- }
- exports.isArray = isArray;
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
- function isRegExp(re) {
- return isObject(re) && objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
- function isDate(d) {
- return isObject(d) && objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
- function isError(e) {
- return isObject(e) &&
- (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
- exports.isBuffer = require('./support/isBuffer');
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
- function pad(n) {
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
- }
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
- 'Oct', 'Nov', 'Dec'];
- // 26 Feb 16:19:34
- function timestamp() {
- var d = new Date();
- var time = [pad(d.getHours()),
- pad(d.getMinutes()),
- pad(d.getSeconds())].join(':');
- return [d.getDate(), months[d.getMonth()], time].join(' ');
- }
- // log is just a thin wrapper to console.log that prepends a timestamp
- exports.log = function() {
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
- };
- /**
- * Inherit the prototype methods from one constructor into another.
- *
- * The Function.prototype.inherits from lang.js rewritten as a standalone
- * function (not on Function.prototype). NOTE: If this file is to be loaded
- * during bootstrapping this function needs to be rewritten using some native
- * functions as prototype setup using normal JavaScript does not work as
- * expected during bootstrapping (see mirror.js in r114903).
- *
- * @param {function} ctor Constructor function which needs to inherit the
- * prototype.
- * @param {function} superCtor Constructor function to inherit prototype from.
- */
- exports.inherits = require('inherits');
- exports._extend = function(origin, add) {
- // Don't do anything if add isn't an object
- if (!add || !isObject(add)) return origin;
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
- };
- function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
- }
- }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"./support/isBuffer":215,"_process":200,"inherits":197}],217:[function(require,module,exports){
- (function (process){
- 'use strict';
- var escapeStringRegexp = require('escape-string-regexp');
- var ansiStyles = require('ansi-styles');
- var stripAnsi = require('strip-ansi');
- var hasAnsi = require('has-ansi');
- var supportsColor = require('supports-color');
- var defineProps = Object.defineProperties;
- function Chalk(options) {
- // detect mode if not set manually
- this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
- }
- // use bright blue on Windows as the normal blue color is illegible
- if (process.platform === 'win32') {
- ansiStyles.blue.open = '\u001b[94m';
- }
- function build(_styles) {
- var builder = function builder() {
- return applyStyle.apply(builder, arguments);
- };
- builder._styles = _styles;
- builder.enabled = this.enabled;
- // __proto__ is used because we must return a function, but there is
- // no way to create a function with a different prototype.
- builder.__proto__ = proto;
- return builder;
- }
- var styles = (function () {
- var ret = {};
- Object.keys(ansiStyles).forEach(function (key) {
- ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
- ret[key] = {
- get: function () {
- return build.call(this, this._styles.concat(key));
- }
- };
- });
- return ret;
- })();
- var proto = defineProps(function chalk() {}, styles);
- function applyStyle() {
- // support varags, but simply cast to string in case there's only one arg
- var args = arguments;
- var argsLen = args.length;
- var str = argsLen !== 0 && String(arguments[0]);
- if (argsLen > 1) {
- // don't slice `arguments`, it prevents v8 optimizations
- for (var a = 1; a < argsLen; a++) {
- str += ' ' + args[a];
- }
- }
- if (!this.enabled || !str) {
- return str;
- }
- /*jshint validthis: true */
- var nestedStyles = this._styles;
- var i = nestedStyles.length;
- while (i--) {
- var code = ansiStyles[nestedStyles[i]];
- // Replace any instances already present with a re-opening code
- // otherwise only the part of the string until said closing code
- // will be colored, and the rest will simply be 'plain'.
- str = code.open + str.replace(code.closeRe, code.open) + code.close;
- }
- return str;
- }
- function init() {
- var ret = {};
- Object.keys(styles).forEach(function (name) {
- ret[name] = {
- get: function () {
- return build.call(this, [name]);
- }
- };
- });
- return ret;
- }
- defineProps(Chalk.prototype, init());
- module.exports = new Chalk();
- module.exports.styles = ansiStyles;
- module.exports.hasColor = hasAnsi;
- module.exports.stripColor = stripAnsi;
- module.exports.supportsColor = supportsColor;
- }).call(this,require('_process'))
- },{"_process":200,"ansi-styles":218,"escape-string-regexp":219,"has-ansi":220,"strip-ansi":222,"supports-color":224}],218:[function(require,module,exports){
- 'use strict';
- var styles = module.exports = {
- modifiers: {
- reset: [0, 0],
- bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
- dim: [2, 22],
- italic: [3, 23],
- underline: [4, 24],
- inverse: [7, 27],
- hidden: [8, 28],
- strikethrough: [9, 29]
- },
- colors: {
- black: [30, 39],
- red: [31, 39],
- green: [32, 39],
- yellow: [33, 39],
- blue: [34, 39],
- magenta: [35, 39],
- cyan: [36, 39],
- white: [37, 39],
- gray: [90, 39]
- },
- bgColors: {
- bgBlack: [40, 49],
- bgRed: [41, 49],
- bgGreen: [42, 49],
- bgYellow: [43, 49],
- bgBlue: [44, 49],
- bgMagenta: [45, 49],
- bgCyan: [46, 49],
- bgWhite: [47, 49]
- }
- };
- // fix humans
- styles.colors.grey = styles.colors.gray;
- Object.keys(styles).forEach(function (groupName) {
- var group = styles[groupName];
- Object.keys(group).forEach(function (styleName) {
- var style = group[styleName];
- styles[styleName] = group[styleName] = {
- open: '\u001b[' + style[0] + 'm',
- close: '\u001b[' + style[1] + 'm'
- };
- });
- Object.defineProperty(styles, groupName, {
- value: group,
- enumerable: false
- });
- });
- },{}],219:[function(require,module,exports){
- 'use strict';
- var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
- module.exports = function (str) {
- if (typeof str !== 'string') {
- throw new TypeError('Expected a string');
- }
- return str.replace(matchOperatorsRe, '\\$&');
- };
- },{}],220:[function(require,module,exports){
- 'use strict';
- var ansiRegex = require('ansi-regex');
- var re = new RegExp(ansiRegex().source); // remove the `g` flag
- module.exports = re.test.bind(re);
- },{"ansi-regex":221}],221:[function(require,module,exports){
- 'use strict';
- module.exports = function () {
- return /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/g;
- };
- },{}],222:[function(require,module,exports){
- 'use strict';
- var ansiRegex = require('ansi-regex')();
- module.exports = function (str) {
- return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
- };
- },{"ansi-regex":223}],223:[function(require,module,exports){
- arguments[4][221][0].apply(exports,arguments)
- },{"dup":221}],224:[function(require,module,exports){
- (function (process){
- 'use strict';
- var argv = process.argv;
- module.exports = (function () {
- if ('FORCE_COLOR' in process.env) {
- return true;
- }
- if (argv.indexOf('--no-color') !== -1 ||
- argv.indexOf('--no-colors') !== -1 ||
- argv.indexOf('--color=false') !== -1) {
- return false;
- }
- if (argv.indexOf('--color') !== -1 ||
- argv.indexOf('--colors') !== -1 ||
- argv.indexOf('--color=true') !== -1 ||
- argv.indexOf('--color=always') !== -1) {
- return true;
- }
- if (process.stdout && !process.stdout.isTTY) {
- return false;
- }
- if (process.platform === 'win32') {
- return true;
- }
- if ('COLORTERM' in process.env) {
- return true;
- }
- if (process.env.TERM === 'dumb') {
- return false;
- }
- if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
- return true;
- }
- return false;
- })();
- }).call(this,require('_process'))
- },{"_process":200}],225:[function(require,module,exports){
- (function (Buffer){
- 'use strict';
- var fs = require('fs');
- var path = require('path');
- var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+;)?base64,(.*)$/mg;
- var mapFileCommentRx =
- // //# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */
- /(?:\/\/[@#][ \t]+sourceMappingURL=(.+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
- function decodeBase64(base64) {
- return new Buffer(base64, 'base64').toString();
- }
- function stripComment(sm) {
- return sm.split(',').pop();
- }
- function readFromFileMap(sm, dir) {
- // NOTE: this will only work on the server since it attempts to read the map file
- var r = mapFileCommentRx.exec(sm);
- mapFileCommentRx.lastIndex = 0;
-
- // for some odd reason //# .. captures in 1 and /* .. */ in 2
- var filename = r[1] || r[2];
- var filepath = path.join(dir, filename);
- try {
- return fs.readFileSync(filepath, 'utf8');
- } catch (e) {
- throw new Error('An error occurred while trying to read the map file at ' + filepath + '\n' + e);
- }
- }
- function Converter (sm, opts) {
- opts = opts || {};
- if (opts.isFileComment) sm = readFromFileMap(sm, opts.commentFileDir);
- if (opts.hasComment) sm = stripComment(sm);
- if (opts.isEncoded) sm = decodeBase64(sm);
- if (opts.isJSON || opts.isEncoded) sm = JSON.parse(sm);
- this.sourcemap = sm;
- }
- function convertFromLargeSource(content){
- var lines = content.split('\n');
- var line;
- // find first line which contains a source map starting at end of content
- for (var i = lines.length - 1; i > 0; i--) {
- line = lines[i]
- if (~line.indexOf('sourceMappingURL=data:')) return exports.fromComment(line);
- }
- }
- Converter.prototype.toJSON = function (space) {
- return JSON.stringify(this.sourcemap, null, space);
- };
- Converter.prototype.toBase64 = function () {
- var json = this.toJSON();
- return new Buffer(json).toString('base64');
- };
- Converter.prototype.toComment = function (options) {
- var base64 = this.toBase64();
- var data = 'sourceMappingURL=data:application/json;base64,' + base64;
- return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
- };
- // returns copy instead of original
- Converter.prototype.toObject = function () {
- return JSON.parse(this.toJSON());
- };
- Converter.prototype.addProperty = function (key, value) {
- if (this.sourcemap.hasOwnProperty(key)) throw new Error('property %s already exists on the sourcemap, use set property instead');
- return this.setProperty(key, value);
- };
- Converter.prototype.setProperty = function (key, value) {
- this.sourcemap[key] = value;
- return this;
- };
- Converter.prototype.getProperty = function (key) {
- return this.sourcemap[key];
- };
- exports.fromObject = function (obj) {
- return new Converter(obj);
- };
- exports.fromJSON = function (json) {
- return new Converter(json, { isJSON: true });
- };
- exports.fromBase64 = function (base64) {
- return new Converter(base64, { isEncoded: true });
- };
- exports.fromComment = function (comment) {
- comment = comment
- .replace(/^\/\*/g, '//')
- .replace(/\*\/$/g, '');
- return new Converter(comment, { isEncoded: true, hasComment: true });
- };
- exports.fromMapFileComment = function (comment, dir) {
- return new Converter(comment, { commentFileDir: dir, isFileComment: true, isJSON: true });
- };
- // Finds last sourcemap comment in file or returns null if none was found
- exports.fromSource = function (content, largeSource) {
- if (largeSource) return convertFromLargeSource(content);
- var m = content.match(commentRx);
- commentRx.lastIndex = 0;
- return m ? exports.fromComment(m.pop()) : null;
- };
- // Finds last sourcemap comment in file or returns null if none was found
- exports.fromMapFileSource = function (content, dir) {
- var m = content.match(mapFileCommentRx);
- mapFileCommentRx.lastIndex = 0;
- return m ? exports.fromMapFileComment(m.pop(), dir) : null;
- };
- exports.removeComments = function (src) {
- commentRx.lastIndex = 0;
- return src.replace(commentRx, '');
- };
- exports.removeMapFileComments = function (src) {
- mapFileCommentRx.lastIndex = 0;
- return src.replace(mapFileCommentRx, '');
- };
- Object.defineProperty(exports, 'commentRegex', {
- get: function getCommentRegex () {
- commentRx.lastIndex = 0;
- return commentRx;
- }
- });
- Object.defineProperty(exports, 'mapFileCommentRegex', {
- get: function getMapFileCommentRegex () {
- mapFileCommentRx.lastIndex = 0;
- return mapFileCommentRx;
- }
- });
- }).call(this,require("buffer").Buffer)
- },{"buffer":192,"fs":189,"path":199}],226:[function(require,module,exports){
- 'use strict';
- // false -> Array#indexOf
- // true -> Array#includes
- var $ = require('./$');
- module.exports = function(IS_INCLUDES){
- return function(el /*, fromIndex = 0 */){
- var O = $.toObject(this)
- , length = $.toLength(O.length)
- , index = $.toIndex(arguments[1], length)
- , value;
- if(IS_INCLUDES && el != el)while(length > index){
- value = O[index++];
- if(value != value)return true;
- } else for(;length > index; index++)if(IS_INCLUDES || index in O){
- if(O[index] === el)return IS_INCLUDES || index;
- } return !IS_INCLUDES && -1;
- };
- };
- },{"./$":245}],227:[function(require,module,exports){
- 'use strict';
- // 0 -> Array#forEach
- // 1 -> Array#map
- // 2 -> Array#filter
- // 3 -> Array#some
- // 4 -> Array#every
- // 5 -> Array#find
- // 6 -> Array#findIndex
- var $ = require('./$')
- , ctx = require('./$.ctx');
- module.exports = function(TYPE){
- var IS_MAP = TYPE == 1
- , IS_FILTER = TYPE == 2
- , IS_SOME = TYPE == 3
- , IS_EVERY = TYPE == 4
- , IS_FIND_INDEX = TYPE == 6
- , NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
- return function(callbackfn/*, that = undefined */){
- var O = Object($.assertDefined(this))
- , self = $.ES5Object(O)
- , f = ctx(callbackfn, arguments[1], 3)
- , length = $.toLength(self.length)
- , index = 0
- , result = IS_MAP ? Array(length) : IS_FILTER ? [] : undefined
- , val, res;
- for(;length > index; index++)if(NO_HOLES || index in self){
- val = self[index];
- res = f(val, index, O);
- if(TYPE){
- if(IS_MAP)result[index] = res; // map
- else if(res)switch(TYPE){
- case 3: return true; // some
- case 5: return val; // find
- case 6: return index; // findIndex
- case 2: result.push(val); // filter
- } else if(IS_EVERY)return false; // every
- }
- }
- return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
- };
- };
- },{"./$":245,"./$.ctx":235}],228:[function(require,module,exports){
- var $ = require('./$');
- function assert(condition, msg1, msg2){
- if(!condition)throw TypeError(msg2 ? msg1 + msg2 : msg1);
- }
- assert.def = $.assertDefined;
- assert.fn = function(it){
- if(!$.isFunction(it))throw TypeError(it + ' is not a function!');
- return it;
- };
- assert.obj = function(it){
- if(!$.isObject(it))throw TypeError(it + ' is not an object!');
- return it;
- };
- assert.inst = function(it, Constructor, name){
- if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!");
- return it;
- };
- module.exports = assert;
- },{"./$":245}],229:[function(require,module,exports){
- var $ = require('./$')
- , enumKeys = require('./$.enum-keys');
- // 19.1.2.1 Object.assign(target, source, ...)
- /* eslint-disable no-unused-vars */
- module.exports = Object.assign || function assign(target, source){
- /* eslint-enable no-unused-vars */
- var T = Object($.assertDefined(target))
- , l = arguments.length
- , i = 1;
- while(l > i){
- var S = $.ES5Object(arguments[i++])
- , keys = enumKeys(S)
- , length = keys.length
- , j = 0
- , key;
- while(length > j)T[key = keys[j++]] = S[key];
- }
- return T;
- };
- },{"./$":245,"./$.enum-keys":237}],230:[function(require,module,exports){
- var $ = require('./$')
- , TAG = require('./$.wks')('toStringTag')
- , toString = {}.toString;
- function cof(it){
- return toString.call(it).slice(8, -1);
- }
- cof.classof = function(it){
- var O, T;
- return it == undefined ? it === undefined ? 'Undefined' : 'Null'
- : typeof (T = (O = Object(it))[TAG]) == 'string' ? T : cof(O);
- };
- cof.set = function(it, tag, stat){
- if(it && !$.has(it = stat ? it : it.prototype, TAG))$.hide(it, TAG, tag);
- };
- module.exports = cof;
- },{"./$":245,"./$.wks":256}],231:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , ctx = require('./$.ctx')
- , safe = require('./$.uid').safe
- , assert = require('./$.assert')
- , forOf = require('./$.for-of')
- , step = require('./$.iter').step
- , has = $.has
- , set = $.set
- , isObject = $.isObject
- , hide = $.hide
- , isFrozen = Object.isFrozen || $.core.Object.isFrozen
- , ID = safe('id')
- , O1 = safe('O1')
- , LAST = safe('last')
- , FIRST = safe('first')
- , ITER = safe('iter')
- , SIZE = $.DESC ? safe('size') : 'size'
- , id = 0;
- function fastKey(it, create){
- // return primitive with prefix
- if(!isObject(it))return (typeof it == 'string' ? 'S' : 'P') + it;
- // can't set id to frozen object
- if(isFrozen(it))return 'F';
- if(!has(it, ID)){
- // not necessary to add id
- if(!create)return 'E';
- // add missing object id
- hide(it, ID, ++id);
- // return object id with prefix
- } return 'O' + it[ID];
- }
- function getEntry(that, key){
- // fast case
- var index = fastKey(key), entry;
- if(index != 'F')return that[O1][index];
- // frozen object case
- for(entry = that[FIRST]; entry; entry = entry.n){
- if(entry.k == key)return entry;
- }
- }
- module.exports = {
- getConstructor: function(NAME, IS_MAP, ADDER){
- function C(){
- var that = assert.inst(this, C, NAME)
- , iterable = arguments[0];
- set(that, O1, $.create(null));
- set(that, SIZE, 0);
- set(that, LAST, undefined);
- set(that, FIRST, undefined);
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- }
- $.mix(C.prototype, {
- // 23.1.3.1 Map.prototype.clear()
- // 23.2.3.2 Set.prototype.clear()
- clear: function clear(){
- for(var that = this, data = that[O1], entry = that[FIRST]; entry; entry = entry.n){
- entry.r = true;
- if(entry.p)entry.p = entry.p.n = undefined;
- delete data[entry.i];
- }
- that[FIRST] = that[LAST] = undefined;
- that[SIZE] = 0;
- },
- // 23.1.3.3 Map.prototype.delete(key)
- // 23.2.3.4 Set.prototype.delete(value)
- 'delete': function(key){
- var that = this
- , entry = getEntry(that, key);
- if(entry){
- var next = entry.n
- , prev = entry.p;
- delete that[O1][entry.i];
- entry.r = true;
- if(prev)prev.n = next;
- if(next)next.p = prev;
- if(that[FIRST] == entry)that[FIRST] = next;
- if(that[LAST] == entry)that[LAST] = prev;
- that[SIZE]--;
- } return !!entry;
- },
- // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
- // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
- forEach: function forEach(callbackfn /*, that = undefined */){
- var f = ctx(callbackfn, arguments[1], 3)
- , entry;
- while(entry = entry ? entry.n : this[FIRST]){
- f(entry.v, entry.k, this);
- // revert to the last existing entry
- while(entry && entry.r)entry = entry.p;
- }
- },
- // 23.1.3.7 Map.prototype.has(key)
- // 23.2.3.7 Set.prototype.has(value)
- has: function has(key){
- return !!getEntry(this, key);
- }
- });
- if($.DESC)$.setDesc(C.prototype, 'size', {
- get: function(){
- return assert.def(this[SIZE]);
- }
- });
- return C;
- },
- def: function(that, key, value){
- var entry = getEntry(that, key)
- , prev, index;
- // change existing entry
- if(entry){
- entry.v = value;
- // create new entry
- } else {
- that[LAST] = entry = {
- i: index = fastKey(key, true), // <- index
- k: key, // <- key
- v: value, // <- value
- p: prev = that[LAST], // <- previous entry
- n: undefined, // <- next entry
- r: false // <- removed
- };
- if(!that[FIRST])that[FIRST] = entry;
- if(prev)prev.n = entry;
- that[SIZE]++;
- // add to index
- if(index != 'F')that[O1][index] = entry;
- } return that;
- },
- getEntry: getEntry,
- // add .keys, .values, .entries, [@@iterator]
- // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
- setIter: function(C, NAME, IS_MAP){
- require('./$.iter-define')(C, NAME, function(iterated, kind){
- set(this, ITER, {o: iterated, k: kind});
- }, function(){
- var iter = this[ITER]
- , kind = iter.k
- , entry = iter.l;
- // revert to the last existing entry
- while(entry && entry.r)entry = entry.p;
- // get next entry
- if(!iter.o || !(iter.l = entry = entry ? entry.n : iter.o[FIRST])){
- // or finish the iteration
- iter.o = undefined;
- return step(1);
- }
- // return step by kind
- if(kind == 'keys' )return step(0, entry.k);
- if(kind == 'values')return step(0, entry.v);
- return step(0, [entry.k, entry.v]);
- }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
- }
- };
- },{"./$":245,"./$.assert":228,"./$.ctx":235,"./$.for-of":238,"./$.iter":244,"./$.iter-define":242,"./$.uid":254}],232:[function(require,module,exports){
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- var $def = require('./$.def')
- , forOf = require('./$.for-of');
- module.exports = function(NAME){
- $def($def.P, NAME, {
- toJSON: function toJSON(){
- var arr = [];
- forOf(this, false, arr.push, arr);
- return arr;
- }
- });
- };
- },{"./$.def":236,"./$.for-of":238}],233:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , safe = require('./$.uid').safe
- , assert = require('./$.assert')
- , forOf = require('./$.for-of')
- , _has = $.has
- , isObject = $.isObject
- , hide = $.hide
- , isFrozen = Object.isFrozen || $.core.Object.isFrozen
- , id = 0
- , ID = safe('id')
- , WEAK = safe('weak')
- , LEAK = safe('leak')
- , method = require('./$.array-methods')
- , find = method(5)
- , findIndex = method(6);
- function findFrozen(store, key){
- return find.call(store.array, function(it){
- return it[0] === key;
- });
- }
- // fallback for frozen keys
- function leakStore(that){
- return that[LEAK] || hide(that, LEAK, {
- array: [],
- get: function(key){
- var entry = findFrozen(this, key);
- if(entry)return entry[1];
- },
- has: function(key){
- return !!findFrozen(this, key);
- },
- set: function(key, value){
- var entry = findFrozen(this, key);
- if(entry)entry[1] = value;
- else this.array.push([key, value]);
- },
- 'delete': function(key){
- var index = findIndex.call(this.array, function(it){
- return it[0] === key;
- });
- if(~index)this.array.splice(index, 1);
- return !!~index;
- }
- })[LEAK];
- }
- module.exports = {
- getConstructor: function(NAME, IS_MAP, ADDER){
- function C(){
- $.set(assert.inst(this, C, NAME), ID, id++);
- var iterable = arguments[0];
- if(iterable != undefined)forOf(iterable, IS_MAP, this[ADDER], this);
- }
- $.mix(C.prototype, {
- // 23.3.3.2 WeakMap.prototype.delete(key)
- // 23.4.3.3 WeakSet.prototype.delete(value)
- 'delete': function(key){
- if(!isObject(key))return false;
- if(isFrozen(key))return leakStore(this)['delete'](key);
- return _has(key, WEAK) && _has(key[WEAK], this[ID]) && delete key[WEAK][this[ID]];
- },
- // 23.3.3.4 WeakMap.prototype.has(key)
- // 23.4.3.4 WeakSet.prototype.has(value)
- has: function has(key){
- if(!isObject(key))return false;
- if(isFrozen(key))return leakStore(this).has(key);
- return _has(key, WEAK) && _has(key[WEAK], this[ID]);
- }
- });
- return C;
- },
- def: function(that, key, value){
- if(isFrozen(assert.obj(key))){
- leakStore(that).set(key, value);
- } else {
- _has(key, WEAK) || hide(key, WEAK, {});
- key[WEAK][that[ID]] = value;
- } return that;
- },
- leakStore: leakStore,
- WEAK: WEAK,
- ID: ID
- };
- },{"./$":245,"./$.array-methods":227,"./$.assert":228,"./$.for-of":238,"./$.uid":254}],234:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , $def = require('./$.def')
- , BUGGY = require('./$.iter').BUGGY
- , forOf = require('./$.for-of')
- , species = require('./$.species')
- , assertInstance = require('./$.assert').inst;
- module.exports = function(NAME, methods, common, IS_MAP, IS_WEAK){
- var Base = $.g[NAME]
- , C = Base
- , ADDER = IS_MAP ? 'set' : 'add'
- , proto = C && C.prototype
- , O = {};
- function fixMethod(KEY, CHAIN){
- var method = proto[KEY];
- if($.FW)proto[KEY] = function(a, b){
- var result = method.call(this, a === 0 ? 0 : a, b);
- return CHAIN ? this : result;
- };
- }
- if(!$.isFunction(C) || !(IS_WEAK || !BUGGY && proto.forEach && proto.entries)){
- // create collection constructor
- C = common.getConstructor(NAME, IS_MAP, ADDER);
- $.mix(C.prototype, methods);
- } else {
- var inst = new C
- , chain = inst[ADDER](IS_WEAK ? {} : -0, 1)
- , buggyZero;
- // wrap for init collections from iterable
- if(!require('./$.iter-detect')(function(iter){ new C(iter); })){ // eslint-disable-line no-new
- C = function(){
- assertInstance(this, C, NAME);
- var that = new Base
- , iterable = arguments[0];
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- return that;
- };
- C.prototype = proto;
- if($.FW)proto.constructor = C;
- }
- IS_WEAK || inst.forEach(function(val, key){
- buggyZero = 1 / key === -Infinity;
- });
- // fix converting -0 key to +0
- if(buggyZero){
- fixMethod('delete');
- fixMethod('has');
- IS_MAP && fixMethod('get');
- }
- // + fix .add & .set for chaining
- if(buggyZero || chain !== inst)fixMethod(ADDER, true);
- }
- require('./$.cof').set(C, NAME);
- O[NAME] = C;
- $def($def.G + $def.W + $def.F * (C != Base), O);
- species(C);
- species($.core[NAME]); // for wrapper
- if(!IS_WEAK)common.setIter(C, NAME, IS_MAP);
- return C;
- };
- },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.def":236,"./$.for-of":238,"./$.iter":244,"./$.iter-detect":243,"./$.species":251}],235:[function(require,module,exports){
- // Optional / simple context binding
- var assertFunction = require('./$.assert').fn;
- module.exports = function(fn, that, length){
- assertFunction(fn);
- if(~length && that === undefined)return fn;
- switch(length){
- case 1: return function(a){
- return fn.call(that, a);
- };
- case 2: return function(a, b){
- return fn.call(that, a, b);
- };
- case 3: return function(a, b, c){
- return fn.call(that, a, b, c);
- };
- } return function(/* ...args */){
- return fn.apply(that, arguments);
- };
- };
- },{"./$.assert":228}],236:[function(require,module,exports){
- var $ = require('./$')
- , global = $.g
- , core = $.core
- , isFunction = $.isFunction;
- function ctx(fn, that){
- return function(){
- return fn.apply(that, arguments);
- };
- }
- global.core = core;
- // type bitmap
- $def.F = 1; // forced
- $def.G = 2; // global
- $def.S = 4; // static
- $def.P = 8; // proto
- $def.B = 16; // bind
- $def.W = 32; // wrap
- function $def(type, name, source){
- var key, own, out, exp
- , isGlobal = type & $def.G
- , target = isGlobal ? global : type & $def.S
- ? global[name] : (global[name] || {}).prototype
- , exports = isGlobal ? core : core[name] || (core[name] = {});
- if(isGlobal)source = name;
- for(key in source){
- // contains in native
- own = !(type & $def.F) && target && key in target;
- // export native or passed
- out = (own ? target : source)[key];
- // bind timers to global for call from export context
- if(type & $def.B && own)exp = ctx(out, global);
- else exp = type & $def.P && isFunction(out) ? ctx(Function.call, out) : out;
- // extend global
- if(target && !own){
- if(isGlobal)target[key] = out;
- else delete target[key] && $.hide(target, key, out);
- }
- // export
- if(exports[key] != out)$.hide(exports, key, exp);
- }
- }
- module.exports = $def;
- },{"./$":245}],237:[function(require,module,exports){
- var $ = require('./$');
- module.exports = function(it){
- var keys = $.getKeys(it)
- , getDesc = $.getDesc
- , getSymbols = $.getSymbols;
- if(getSymbols)$.each.call(getSymbols(it), function(key){
- if(getDesc(it, key).enumerable)keys.push(key);
- });
- return keys;
- };
- },{"./$":245}],238:[function(require,module,exports){
- var ctx = require('./$.ctx')
- , get = require('./$.iter').get
- , call = require('./$.iter-call');
- module.exports = function(iterable, entries, fn, that){
- var iterator = get(iterable)
- , f = ctx(fn, that, entries ? 2 : 1)
- , step;
- while(!(step = iterator.next()).done){
- if(call(iterator, f, step.value, entries) === false){
- return call.close(iterator);
- }
- }
- };
- },{"./$.ctx":235,"./$.iter":244,"./$.iter-call":241}],239:[function(require,module,exports){
- module.exports = function($){
- $.FW = true;
- $.path = $.g;
- return $;
- };
- },{}],240:[function(require,module,exports){
- // Fast apply
- // http://jsperf.lnkit.com/fast-apply/5
- module.exports = function(fn, args, that){
- var un = that === undefined;
- switch(args.length){
- case 0: return un ? fn()
- : fn.call(that);
- case 1: return un ? fn(args[0])
- : fn.call(that, args[0]);
- case 2: return un ? fn(args[0], args[1])
- : fn.call(that, args[0], args[1]);
- case 3: return un ? fn(args[0], args[1], args[2])
- : fn.call(that, args[0], args[1], args[2]);
- case 4: return un ? fn(args[0], args[1], args[2], args[3])
- : fn.call(that, args[0], args[1], args[2], args[3]);
- case 5: return un ? fn(args[0], args[1], args[2], args[3], args[4])
- : fn.call(that, args[0], args[1], args[2], args[3], args[4]);
- } return fn.apply(that, args);
- };
- },{}],241:[function(require,module,exports){
- var assertObject = require('./$.assert').obj;
- function close(iterator){
- var ret = iterator['return'];
- if(ret !== undefined)assertObject(ret.call(iterator));
- }
- function call(iterator, fn, value, entries){
- try {
- return entries ? fn(assertObject(value)[0], value[1]) : fn(value);
- } catch(e){
- close(iterator);
- throw e;
- }
- }
- call.close = close;
- module.exports = call;
- },{"./$.assert":228}],242:[function(require,module,exports){
- var $def = require('./$.def')
- , $ = require('./$')
- , cof = require('./$.cof')
- , $iter = require('./$.iter')
- , SYMBOL_ITERATOR = require('./$.wks')('iterator')
- , FF_ITERATOR = '@@iterator'
- , VALUES = 'values'
- , Iterators = $iter.Iterators;
- module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE){
- $iter.create(Constructor, NAME, next);
- function createMethod(kind){
- return function(){
- return new Constructor(this, kind);
- };
- }
- var TAG = NAME + ' Iterator'
- , proto = Base.prototype
- , _native = proto[SYMBOL_ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
- , _default = _native || createMethod(DEFAULT)
- , methods, key;
- // Fix native
- if(_native){
- var IteratorPrototype = $.getProto(_default.call(new Base));
- // Set @@toStringTag to native iterators
- cof.set(IteratorPrototype, TAG, true);
- // FF fix
- if($.FW && $.has(proto, FF_ITERATOR))$iter.set(IteratorPrototype, $.that);
- }
- // Define iterator
- if($.FW)$iter.set(proto, _default);
- // Plug for library
- Iterators[NAME] = _default;
- Iterators[TAG] = $.that;
- if(DEFAULT){
- methods = {
- keys: IS_SET ? _default : createMethod('keys'),
- values: DEFAULT == VALUES ? _default : createMethod(VALUES),
- entries: DEFAULT != VALUES ? _default : createMethod('entries')
- };
- if(FORCE)for(key in methods){
- if(!(key in proto))$.hide(proto, key, methods[key]);
- } else $def($def.P + $def.F * $iter.BUGGY, NAME, methods);
- }
- };
- },{"./$":245,"./$.cof":230,"./$.def":236,"./$.iter":244,"./$.wks":256}],243:[function(require,module,exports){
- var SYMBOL_ITERATOR = require('./$.wks')('iterator')
- , SAFE_CLOSING = false;
- try {
- var riter = [7][SYMBOL_ITERATOR]();
- riter['return'] = function(){ SAFE_CLOSING = true; };
- Array.from(riter, function(){ throw 2; });
- } catch(e){ /* empty */ }
- module.exports = function(exec){
- if(!SAFE_CLOSING)return false;
- var safe = false;
- try {
- var arr = [7]
- , iter = arr[SYMBOL_ITERATOR]();
- iter.next = function(){ safe = true; };
- arr[SYMBOL_ITERATOR] = function(){ return iter; };
- exec(arr);
- } catch(e){ /* empty */ }
- return safe;
- };
- },{"./$.wks":256}],244:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , cof = require('./$.cof')
- , assertObject = require('./$.assert').obj
- , SYMBOL_ITERATOR = require('./$.wks')('iterator')
- , FF_ITERATOR = '@@iterator'
- , Iterators = {}
- , IteratorPrototype = {};
- // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
- setIterator(IteratorPrototype, $.that);
- function setIterator(O, value){
- $.hide(O, SYMBOL_ITERATOR, value);
- // Add iterator for FF iterator protocol
- if(FF_ITERATOR in [])$.hide(O, FF_ITERATOR, value);
- }
- module.exports = {
- // Safari has buggy iterators w/o `next`
- BUGGY: 'keys' in [] && !('next' in [].keys()),
- Iterators: Iterators,
- step: function(done, value){
- return {value: value, done: !!done};
- },
- is: function(it){
- var O = Object(it)
- , Symbol = $.g.Symbol
- , SYM = Symbol && Symbol.iterator || FF_ITERATOR;
- return SYM in O || SYMBOL_ITERATOR in O || $.has(Iterators, cof.classof(O));
- },
- get: function(it){
- var Symbol = $.g.Symbol
- , ext = it[Symbol && Symbol.iterator || FF_ITERATOR]
- , getIter = ext || it[SYMBOL_ITERATOR] || Iterators[cof.classof(it)];
- return assertObject(getIter.call(it));
- },
- set: setIterator,
- create: function(Constructor, NAME, next, proto){
- Constructor.prototype = $.create(proto || IteratorPrototype, {next: $.desc(1, next)});
- cof.set(Constructor, NAME + ' Iterator');
- }
- };
- },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.wks":256}],245:[function(require,module,exports){
- 'use strict';
- var global = typeof self != 'undefined' ? self : Function('return this')()
- , core = {}
- , defineProperty = Object.defineProperty
- , hasOwnProperty = {}.hasOwnProperty
- , ceil = Math.ceil
- , floor = Math.floor
- , max = Math.max
- , min = Math.min;
- // The engine works fine with descriptors? Thank's IE8 for his funny defineProperty.
- var DESC = !!function(){
- try {
- return defineProperty({}, 'a', {get: function(){ return 2; }}).a == 2;
- } catch(e){ /* empty */ }
- }();
- var hide = createDefiner(1);
- // 7.1.4 ToInteger
- function toInteger(it){
- return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
- }
- function desc(bitmap, value){
- return {
- enumerable : !(bitmap & 1),
- configurable: !(bitmap & 2),
- writable : !(bitmap & 4),
- value : value
- };
- }
- function simpleSet(object, key, value){
- object[key] = value;
- return object;
- }
- function createDefiner(bitmap){
- return DESC ? function(object, key, value){
- return $.setDesc(object, key, desc(bitmap, value));
- } : simpleSet;
- }
- function isObject(it){
- return it !== null && (typeof it == 'object' || typeof it == 'function');
- }
- function isFunction(it){
- return typeof it == 'function';
- }
- function assertDefined(it){
- if(it == undefined)throw TypeError("Can't call method on " + it);
- return it;
- }
- var $ = module.exports = require('./$.fw')({
- g: global,
- core: core,
- html: global.document && document.documentElement,
- // http://jsperf.com/core-js-isobject
- isObject: isObject,
- isFunction: isFunction,
- it: function(it){
- return it;
- },
- that: function(){
- return this;
- },
- // 7.1.4 ToInteger
- toInteger: toInteger,
- // 7.1.15 ToLength
- toLength: function(it){
- return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
- },
- toIndex: function(index, length){
- index = toInteger(index);
- return index < 0 ? max(index + length, 0) : min(index, length);
- },
- has: function(it, key){
- return hasOwnProperty.call(it, key);
- },
- create: Object.create,
- getProto: Object.getPrototypeOf,
- DESC: DESC,
- desc: desc,
- getDesc: Object.getOwnPropertyDescriptor,
- setDesc: defineProperty,
- setDescs: Object.defineProperties,
- getKeys: Object.keys,
- getNames: Object.getOwnPropertyNames,
- getSymbols: Object.getOwnPropertySymbols,
- assertDefined: assertDefined,
- // Dummy, fix for not array-like ES3 string in es5 module
- ES5Object: Object,
- toObject: function(it){
- return $.ES5Object(assertDefined(it));
- },
- hide: hide,
- def: createDefiner(0),
- set: global.Symbol ? simpleSet : hide,
- mix: function(target, src){
- for(var key in src)hide(target, key, src[key]);
- return target;
- },
- each: [].forEach
- });
- /* eslint-disable no-undef */
- if(typeof __e != 'undefined')__e = core;
- if(typeof __g != 'undefined')__g = global;
- },{"./$.fw":239}],246:[function(require,module,exports){
- var $ = require('./$');
- module.exports = function(object, el){
- var O = $.toObject(object)
- , keys = $.getKeys(O)
- , length = keys.length
- , index = 0
- , key;
- while(length > index)if(O[key = keys[index++]] === el)return key;
- };
- },{"./$":245}],247:[function(require,module,exports){
- var $ = require('./$')
- , assertObject = require('./$.assert').obj;
- module.exports = function ownKeys(it){
- assertObject(it);
- var keys = $.getNames(it)
- , getSymbols = $.getSymbols;
- return getSymbols ? keys.concat(getSymbols(it)) : keys;
- };
- },{"./$":245,"./$.assert":228}],248:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , invoke = require('./$.invoke')
- , assertFunction = require('./$.assert').fn;
- module.exports = function(/* ...pargs */){
- var fn = assertFunction(this)
- , length = arguments.length
- , pargs = Array(length)
- , i = 0
- , _ = $.path._
- , holder = false;
- while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
- return function(/* ...args */){
- var that = this
- , _length = arguments.length
- , j = 0, k = 0, args;
- if(!holder && !_length)return invoke(fn, pargs, that);
- args = pargs.slice();
- if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++];
- while(_length > k)args.push(arguments[k++]);
- return invoke(fn, args, that);
- };
- };
- },{"./$":245,"./$.assert":228,"./$.invoke":240}],249:[function(require,module,exports){
- 'use strict';
- module.exports = function(regExp, replace, isStatic){
- var replacer = replace === Object(replace) ? function(part){
- return replace[part];
- } : replace;
- return function(it){
- return String(isStatic ? it : this).replace(regExp, replacer);
- };
- };
- },{}],250:[function(require,module,exports){
- // Works with __proto__ only. Old v8 can't work with null proto objects.
- /* eslint-disable no-proto */
- var $ = require('./$')
- , assert = require('./$.assert');
- function check(O, proto){
- assert.obj(O);
- assert(proto === null || $.isObject(proto), proto, ": can't set as prototype!");
- }
- module.exports = {
- set: Object.setPrototypeOf || ('__proto__' in {} // eslint-disable-line
- ? function(buggy, set){
- try {
- set = require('./$.ctx')(Function.call, $.getDesc(Object.prototype, '__proto__').set, 2);
- set({}, []);
- } catch(e){ buggy = true; }
- return function setPrototypeOf(O, proto){
- check(O, proto);
- if(buggy)O.__proto__ = proto;
- else set(O, proto);
- return O;
- };
- }()
- : undefined),
- check: check
- };
- },{"./$":245,"./$.assert":228,"./$.ctx":235}],251:[function(require,module,exports){
- var $ = require('./$')
- , SPECIES = require('./$.wks')('species');
- module.exports = function(C){
- if($.DESC && !(SPECIES in C))$.setDesc(C, SPECIES, {
- configurable: true,
- get: $.that
- });
- };
- },{"./$":245,"./$.wks":256}],252:[function(require,module,exports){
- 'use strict';
- // true -> String#at
- // false -> String#codePointAt
- var $ = require('./$');
- module.exports = function(TO_STRING){
- return function(pos){
- var s = String($.assertDefined(this))
- , i = $.toInteger(pos)
- , l = s.length
- , a, b;
- if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
- a = s.charCodeAt(i);
- return a < 0xd800 || a > 0xdbff || i + 1 === l
- || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
- ? TO_STRING ? s.charAt(i) : a
- : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
- };
- };
- },{"./$":245}],253:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , ctx = require('./$.ctx')
- , cof = require('./$.cof')
- , invoke = require('./$.invoke')
- , global = $.g
- , isFunction = $.isFunction
- , html = $.html
- , document = global.document
- , process = global.process
- , setTask = global.setImmediate
- , clearTask = global.clearImmediate
- , postMessage = global.postMessage
- , addEventListener = global.addEventListener
- , MessageChannel = global.MessageChannel
- , counter = 0
- , queue = {}
- , ONREADYSTATECHANGE = 'onreadystatechange'
- , defer, channel, port;
- function run(){
- var id = +this;
- if($.has(queue, id)){
- var fn = queue[id];
- delete queue[id];
- fn();
- }
- }
- function listner(event){
- run.call(event.data);
- }
- // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
- if(!isFunction(setTask) || !isFunction(clearTask)){
- setTask = function(fn){
- var args = [], i = 1;
- while(arguments.length > i)args.push(arguments[i++]);
- queue[++counter] = function(){
- invoke(isFunction(fn) ? fn : Function(fn), args);
- };
- defer(counter);
- return counter;
- };
- clearTask = function(id){
- delete queue[id];
- };
- // Node.js 0.8-
- if(cof(process) == 'process'){
- defer = function(id){
- process.nextTick(ctx(run, id, 1));
- };
- // Modern browsers, skip implementation for WebWorkers
- // IE8 has postMessage, but it's sync & typeof its postMessage is object
- } else if(addEventListener && isFunction(postMessage) && !global.importScripts){
- defer = function(id){
- postMessage(id, '*');
- };
- addEventListener('message', listner, false);
- // WebWorkers
- } else if(isFunction(MessageChannel)){
- channel = new MessageChannel;
- port = channel.port2;
- channel.port1.onmessage = listner;
- defer = ctx(port.postMessage, port, 1);
- // IE8-
- } else if(document && ONREADYSTATECHANGE in document.createElement('script')){
- defer = function(id){
- html.appendChild(document.createElement('script'))[ONREADYSTATECHANGE] = function(){
- html.removeChild(this);
- run.call(id);
- };
- };
- // Rest old browsers
- } else {
- defer = function(id){
- setTimeout(ctx(run, id, 1), 0);
- };
- }
- }
- module.exports = {
- set: setTask,
- clear: clearTask
- };
- },{"./$":245,"./$.cof":230,"./$.ctx":235,"./$.invoke":240}],254:[function(require,module,exports){
- var sid = 0;
- function uid(key){
- return 'Symbol(' + key + ')_' + (++sid + Math.random()).toString(36);
- }
- uid.safe = require('./$').g.Symbol || uid;
- module.exports = uid;
- },{"./$":245}],255:[function(require,module,exports){
- // 22.1.3.31 Array.prototype[@@unscopables]
- var $ = require('./$')
- , UNSCOPABLES = require('./$.wks')('unscopables');
- if($.FW && !(UNSCOPABLES in []))$.hide(Array.prototype, UNSCOPABLES, {});
- module.exports = function(key){
- if($.FW)[][UNSCOPABLES][key] = true;
- };
- },{"./$":245,"./$.wks":256}],256:[function(require,module,exports){
- var global = require('./$').g
- , store = {};
- module.exports = function(name){
- return store[name] || (store[name] =
- global.Symbol && global.Symbol[name] || require('./$.uid').safe('Symbol.' + name));
- };
- },{"./$":245,"./$.uid":254}],257:[function(require,module,exports){
- var $ = require('./$')
- , cof = require('./$.cof')
- , $def = require('./$.def')
- , invoke = require('./$.invoke')
- , arrayMethod = require('./$.array-methods')
- , IE_PROTO = require('./$.uid').safe('__proto__')
- , assert = require('./$.assert')
- , assertObject = assert.obj
- , ObjectProto = Object.prototype
- , A = []
- , slice = A.slice
- , indexOf = A.indexOf
- , classof = cof.classof
- , has = $.has
- , defineProperty = $.setDesc
- , getOwnDescriptor = $.getDesc
- , defineProperties = $.setDescs
- , isFunction = $.isFunction
- , toObject = $.toObject
- , toLength = $.toLength
- , IE8_DOM_DEFINE = false;
- if(!$.DESC){
- try {
- IE8_DOM_DEFINE = defineProperty(document.createElement('div'), 'x',
- {get: function(){ return 8; }}
- ).x == 8;
- } catch(e){ /* empty */ }
- $.setDesc = function(O, P, Attributes){
- if(IE8_DOM_DEFINE)try {
- return defineProperty(O, P, Attributes);
- } catch(e){ /* empty */ }
- if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
- if('value' in Attributes)assertObject(O)[P] = Attributes.value;
- return O;
- };
- $.getDesc = function(O, P){
- if(IE8_DOM_DEFINE)try {
- return getOwnDescriptor(O, P);
- } catch(e){ /* empty */ }
- if(has(O, P))return $.desc(!ObjectProto.propertyIsEnumerable.call(O, P), O[P]);
- };
- $.setDescs = defineProperties = function(O, Properties){
- assertObject(O);
- var keys = $.getKeys(Properties)
- , length = keys.length
- , i = 0
- , P;
- while(length > i)$.setDesc(O, P = keys[i++], Properties[P]);
- return O;
- };
- }
- $def($def.S + $def.F * !$.DESC, 'Object', {
- // 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P)
- getOwnPropertyDescriptor: $.getDesc,
- // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
- defineProperty: $.setDesc,
- // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
- defineProperties: defineProperties
- });
- // IE 8- don't enum bug keys
- var keys1 = ('constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,' +
- 'toLocaleString,toString,valueOf').split(',')
- // Additional keys for getOwnPropertyNames
- , keys2 = keys1.concat('length', 'prototype')
- , keysLen1 = keys1.length;
- // Create object with `null` prototype: use iframe Object with cleared prototype
- var createDict = function(){
- // Thrash, waste and sodomy: IE GC bug
- var iframe = document.createElement('iframe')
- , i = keysLen1
- , gt = '>'
- , iframeDocument;
- iframe.style.display = 'none';
- $.html.appendChild(iframe);
- iframe.src = 'javascript:'; // eslint-disable-line no-script-url
- // createDict = iframe.contentWindow.Object;
- // html.removeChild(iframe);
- iframeDocument = iframe.contentWindow.document;
- iframeDocument.open();
- iframeDocument.write('<script>document.F=Object</script' + gt);
- iframeDocument.close();
- createDict = iframeDocument.F;
- while(i--)delete createDict.prototype[keys1[i]];
- return createDict();
- };
- function createGetKeys(names, length){
- return function(object){
- var O = toObject(object)
- , i = 0
- , result = []
- , key;
- for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
- // Don't enum bug & hidden keys
- while(length > i)if(has(O, key = names[i++])){
- ~indexOf.call(result, key) || result.push(key);
- }
- return result;
- };
- }
- function isPrimitive(it){ return !$.isObject(it); }
- function Empty(){}
- $def($def.S, 'Object', {
- // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
- getPrototypeOf: $.getProto = $.getProto || function(O){
- O = Object(assert.def(O));
- if(has(O, IE_PROTO))return O[IE_PROTO];
- if(isFunction(O.constructor) && O instanceof O.constructor){
- return O.constructor.prototype;
- } return O instanceof Object ? ObjectProto : null;
- },
- // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
- getOwnPropertyNames: $.getNames = $.getNames || createGetKeys(keys2, keys2.length, true),
- // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
- create: $.create = $.create || function(O, /*?*/Properties){
- var result;
- if(O !== null){
- Empty.prototype = assertObject(O);
- result = new Empty();
- Empty.prototype = null;
- // add "__proto__" for Object.getPrototypeOf shim
- result[IE_PROTO] = O;
- } else result = createDict();
- return Properties === undefined ? result : defineProperties(result, Properties);
- },
- // 19.1.2.14 / 15.2.3.14 Object.keys(O)
- keys: $.getKeys = $.getKeys || createGetKeys(keys1, keysLen1, false),
- // 19.1.2.17 / 15.2.3.8 Object.seal(O)
- seal: $.it, // <- cap
- // 19.1.2.5 / 15.2.3.9 Object.freeze(O)
- freeze: $.it, // <- cap
- // 19.1.2.15 / 15.2.3.10 Object.preventExtensions(O)
- preventExtensions: $.it, // <- cap
- // 19.1.2.13 / 15.2.3.11 Object.isSealed(O)
- isSealed: isPrimitive, // <- cap
- // 19.1.2.12 / 15.2.3.12 Object.isFrozen(O)
- isFrozen: isPrimitive, // <- cap
- // 19.1.2.11 / 15.2.3.13 Object.isExtensible(O)
- isExtensible: $.isObject // <- cap
- });
- // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
- $def($def.P, 'Function', {
- bind: function(that /*, args... */){
- var fn = assert.fn(this)
- , partArgs = slice.call(arguments, 1);
- function bound(/* args... */){
- var args = partArgs.concat(slice.call(arguments));
- return invoke(fn, args, this instanceof bound ? $.create(fn.prototype) : that);
- }
- if(fn.prototype)bound.prototype = fn.prototype;
- return bound;
- }
- });
- // Fix for not array-like ES3 string
- function arrayMethodFix(fn){
- return function(){
- return fn.apply($.ES5Object(this), arguments);
- };
- }
- if(!(0 in Object('z') && 'z'[0] == 'z')){
- $.ES5Object = function(it){
- return cof(it) == 'String' ? it.split('') : Object(it);
- };
- }
- $def($def.P + $def.F * ($.ES5Object != Object), 'Array', {
- slice: arrayMethodFix(slice),
- join: arrayMethodFix(A.join)
- });
- // 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
- $def($def.S, 'Array', {
- isArray: function(arg){
- return cof(arg) == 'Array';
- }
- });
- function createArrayReduce(isRight){
- return function(callbackfn, memo){
- assert.fn(callbackfn);
- var O = toObject(this)
- , length = toLength(O.length)
- , index = isRight ? length - 1 : 0
- , i = isRight ? -1 : 1;
- if(arguments.length < 2)for(;;){
- if(index in O){
- memo = O[index];
- index += i;
- break;
- }
- index += i;
- assert(isRight ? index >= 0 : length > index, 'Reduce of empty array with no initial value');
- }
- for(;isRight ? index >= 0 : length > index; index += i)if(index in O){
- memo = callbackfn(memo, O[index], index, this);
- }
- return memo;
- };
- }
- $def($def.P, 'Array', {
- // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
- forEach: $.each = $.each || arrayMethod(0),
- // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
- map: arrayMethod(1),
- // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
- filter: arrayMethod(2),
- // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
- some: arrayMethod(3),
- // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
- every: arrayMethod(4),
- // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
- reduce: createArrayReduce(false),
- // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
- reduceRight: createArrayReduce(true),
- // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
- indexOf: indexOf = indexOf || require('./$.array-includes')(false),
- // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
- lastIndexOf: function(el, fromIndex /* = @[*-1] */){
- var O = toObject(this)
- , length = toLength(O.length)
- , index = length - 1;
- if(arguments.length > 1)index = Math.min(index, $.toInteger(fromIndex));
- if(index < 0)index = toLength(length + index);
- for(;index >= 0; index--)if(index in O)if(O[index] === el)return index;
- return -1;
- }
- });
- // 21.1.3.25 / 15.5.4.20 String.prototype.trim()
- $def($def.P, 'String', {trim: require('./$.replacer')(/^\s*([\s\S]*\S)?\s*$/, '$1')});
- // 20.3.3.1 / 15.9.4.4 Date.now()
- $def($def.S, 'Date', {now: function(){
- return +new Date;
- }});
- function lz(num){
- return num > 9 ? num : '0' + num;
- }
- // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
- // PhantomJS and old webkit had a broken Date implementation.
- var date = new Date(-5e13 - 1)
- , brokenDate = !(date.toISOString && date.toISOString() == '0385-07-25T07:06:39.999Z');
- $def($def.P + $def.F * brokenDate, 'Date', {toISOString: function(){
- if(!isFinite(this))throw RangeError('Invalid time value');
- var d = this
- , y = d.getUTCFullYear()
- , m = d.getUTCMilliseconds()
- , s = y < 0 ? '-' : y > 9999 ? '+' : '';
- return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
- '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
- 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
- ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
- }});
- if(classof(function(){ return arguments; }()) == 'Object')cof.classof = function(it){
- var tag = classof(it);
- return tag == 'Object' && isFunction(it.callee) ? 'Arguments' : tag;
- };
- },{"./$":245,"./$.array-includes":226,"./$.array-methods":227,"./$.assert":228,"./$.cof":230,"./$.def":236,"./$.invoke":240,"./$.replacer":249,"./$.uid":254}],258:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , $def = require('./$.def')
- , toIndex = $.toIndex;
- $def($def.P, 'Array', {
- // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
- copyWithin: function copyWithin(target/* = 0 */, start /* = 0, end = @length */){
- var O = Object($.assertDefined(this))
- , len = $.toLength(O.length)
- , to = toIndex(target, len)
- , from = toIndex(start, len)
- , end = arguments[2]
- , fin = end === undefined ? len : toIndex(end, len)
- , count = Math.min(fin - from, len - to)
- , inc = 1;
- if(from < to && to < from + count){
- inc = -1;
- from = from + count - 1;
- to = to + count - 1;
- }
- while(count-- > 0){
- if(from in O)O[to] = O[from];
- else delete O[to];
- to += inc;
- from += inc;
- } return O;
- }
- });
- require('./$.unscope')('copyWithin');
- },{"./$":245,"./$.def":236,"./$.unscope":255}],259:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , $def = require('./$.def')
- , toIndex = $.toIndex;
- $def($def.P, 'Array', {
- // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
- fill: function fill(value /*, start = 0, end = @length */){
- var O = Object($.assertDefined(this))
- , length = $.toLength(O.length)
- , index = toIndex(arguments[1], length)
- , end = arguments[2]
- , endPos = end === undefined ? length : toIndex(end, length);
- while(endPos > index)O[index++] = value;
- return O;
- }
- });
- require('./$.unscope')('fill');
- },{"./$":245,"./$.def":236,"./$.unscope":255}],260:[function(require,module,exports){
- var $def = require('./$.def');
- $def($def.P, 'Array', {
- // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
- findIndex: require('./$.array-methods')(6)
- });
- require('./$.unscope')('findIndex');
- },{"./$.array-methods":227,"./$.def":236,"./$.unscope":255}],261:[function(require,module,exports){
- var $def = require('./$.def');
- $def($def.P, 'Array', {
- // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
- find: require('./$.array-methods')(5)
- });
- require('./$.unscope')('find');
- },{"./$.array-methods":227,"./$.def":236,"./$.unscope":255}],262:[function(require,module,exports){
- var $ = require('./$')
- , ctx = require('./$.ctx')
- , $def = require('./$.def')
- , $iter = require('./$.iter')
- , call = require('./$.iter-call');
- $def($def.S + $def.F * !require('./$.iter-detect')(function(iter){ Array.from(iter); }), 'Array', {
- // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
- from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
- var O = Object($.assertDefined(arrayLike))
- , mapfn = arguments[1]
- , mapping = mapfn !== undefined
- , f = mapping ? ctx(mapfn, arguments[2], 2) : undefined
- , index = 0
- , length, result, step, iterator;
- if($iter.is(O)){
- iterator = $iter.get(O);
- // strange IE quirks mode bug -> use typeof instead of isFunction
- result = new (typeof this == 'function' ? this : Array);
- for(; !(step = iterator.next()).done; index++){
- result[index] = mapping ? call(iterator, f, [step.value, index], true) : step.value;
- }
- } else {
- // strange IE quirks mode bug -> use typeof instead of isFunction
- result = new (typeof this == 'function' ? this : Array)(length = $.toLength(O.length));
- for(; length > index; index++){
- result[index] = mapping ? f(O[index], index) : O[index];
- }
- }
- result.length = index;
- return result;
- }
- });
- },{"./$":245,"./$.ctx":235,"./$.def":236,"./$.iter":244,"./$.iter-call":241,"./$.iter-detect":243}],263:[function(require,module,exports){
- var $ = require('./$')
- , setUnscope = require('./$.unscope')
- , ITER = require('./$.uid').safe('iter')
- , $iter = require('./$.iter')
- , step = $iter.step
- , Iterators = $iter.Iterators;
- // 22.1.3.4 Array.prototype.entries()
- // 22.1.3.13 Array.prototype.keys()
- // 22.1.3.29 Array.prototype.values()
- // 22.1.3.30 Array.prototype[@@iterator]()
- require('./$.iter-define')(Array, 'Array', function(iterated, kind){
- $.set(this, ITER, {o: $.toObject(iterated), i: 0, k: kind});
- // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
- }, function(){
- var iter = this[ITER]
- , O = iter.o
- , kind = iter.k
- , index = iter.i++;
- if(!O || index >= O.length){
- iter.o = undefined;
- return step(1);
- }
- if(kind == 'keys' )return step(0, index);
- if(kind == 'values')return step(0, O[index]);
- return step(0, [index, O[index]]);
- }, 'values');
- // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
- Iterators.Arguments = Iterators.Array;
- setUnscope('keys');
- setUnscope('values');
- setUnscope('entries');
- },{"./$":245,"./$.iter":244,"./$.iter-define":242,"./$.uid":254,"./$.unscope":255}],264:[function(require,module,exports){
- var $def = require('./$.def');
- $def($def.S, 'Array', {
- // 22.1.2.3 Array.of( ...items)
- of: function of(/* ...args */){
- var index = 0
- , length = arguments.length
- // strange IE quirks mode bug -> use typeof instead of isFunction
- , result = new (typeof this == 'function' ? this : Array)(length);
- while(length > index)result[index] = arguments[index++];
- result.length = length;
- return result;
- }
- });
- },{"./$.def":236}],265:[function(require,module,exports){
- require('./$.species')(Array);
- },{"./$.species":251}],266:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , NAME = 'name'
- , setDesc = $.setDesc
- , FunctionProto = Function.prototype;
- // 19.2.4.2 name
- NAME in FunctionProto || $.FW && $.DESC && setDesc(FunctionProto, NAME, {
- configurable: true,
- get: function(){
- var match = String(this).match(/^\s*function ([^ (]*)/)
- , name = match ? match[1] : '';
- $.has(this, NAME) || setDesc(this, NAME, $.desc(5, name));
- return name;
- },
- set: function(value){
- $.has(this, NAME) || setDesc(this, NAME, $.desc(0, value));
- }
- });
- },{"./$":245}],267:[function(require,module,exports){
- 'use strict';
- var strong = require('./$.collection-strong');
- // 23.1 Map Objects
- require('./$.collection')('Map', {
- // 23.1.3.6 Map.prototype.get(key)
- get: function get(key){
- var entry = strong.getEntry(this, key);
- return entry && entry.v;
- },
- // 23.1.3.9 Map.prototype.set(key, value)
- set: function set(key, value){
- return strong.def(this, key === 0 ? 0 : key, value);
- }
- }, strong, true);
- },{"./$.collection":234,"./$.collection-strong":231}],268:[function(require,module,exports){
- var Infinity = 1 / 0
- , $def = require('./$.def')
- , E = Math.E
- , pow = Math.pow
- , abs = Math.abs
- , exp = Math.exp
- , log = Math.log
- , sqrt = Math.sqrt
- , ceil = Math.ceil
- , floor = Math.floor
- , EPSILON = pow(2, -52)
- , EPSILON32 = pow(2, -23)
- , MAX32 = pow(2, 127) * (2 - EPSILON32)
- , MIN32 = pow(2, -126);
- function roundTiesToEven(n){
- return n + 1 / EPSILON - 1 / EPSILON;
- }
- // 20.2.2.28 Math.sign(x)
- function sign(x){
- return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
- }
- // 20.2.2.5 Math.asinh(x)
- function asinh(x){
- return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));
- }
- // 20.2.2.14 Math.expm1(x)
- function expm1(x){
- return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp(x) - 1;
- }
- $def($def.S, 'Math', {
- // 20.2.2.3 Math.acosh(x)
- acosh: function acosh(x){
- return (x = +x) < 1 ? NaN : isFinite(x) ? log(x / E + sqrt(x + 1) * sqrt(x - 1) / E) + 1 : x;
- },
- // 20.2.2.5 Math.asinh(x)
- asinh: asinh,
- // 20.2.2.7 Math.atanh(x)
- atanh: function atanh(x){
- return (x = +x) == 0 ? x : log((1 + x) / (1 - x)) / 2;
- },
- // 20.2.2.9 Math.cbrt(x)
- cbrt: function cbrt(x){
- return sign(x = +x) * pow(abs(x), 1 / 3);
- },
- // 20.2.2.11 Math.clz32(x)
- clz32: function clz32(x){
- return (x >>>= 0) ? 31 - floor(log(x + 0.5) * Math.LOG2E) : 32;
- },
- // 20.2.2.12 Math.cosh(x)
- cosh: function cosh(x){
- return (exp(x = +x) + exp(-x)) / 2;
- },
- // 20.2.2.14 Math.expm1(x)
- expm1: expm1,
- // 20.2.2.16 Math.fround(x)
- fround: function fround(x){
- var $abs = abs(x)
- , $sign = sign(x)
- , a, result;
- if($abs < MIN32)return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
- a = (1 + EPSILON32 / EPSILON) * $abs;
- result = a - (a - $abs);
- if(result > MAX32 || result != result)return $sign * Infinity;
- return $sign * result;
- },
- // 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
- hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars
- var sum = 0
- , len1 = arguments.length
- , len2 = len1
- , args = Array(len1)
- , larg = -Infinity
- , arg;
- while(len1--){
- arg = args[len1] = +arguments[len1];
- if(arg == Infinity || arg == -Infinity)return Infinity;
- if(arg > larg)larg = arg;
- }
- larg = arg || 1;
- while(len2--)sum += pow(args[len2] / larg, 2);
- return larg * sqrt(sum);
- },
- // 20.2.2.18 Math.imul(x, y)
- imul: function imul(x, y){
- var UInt16 = 0xffff
- , xn = +x
- , yn = +y
- , xl = UInt16 & xn
- , yl = UInt16 & yn;
- return 0 | xl * yl + ((UInt16 & xn >>> 16) * yl + xl * (UInt16 & yn >>> 16) << 16 >>> 0);
- },
- // 20.2.2.20 Math.log1p(x)
- log1p: function log1p(x){
- return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log(1 + x);
- },
- // 20.2.2.21 Math.log10(x)
- log10: function log10(x){
- return log(x) / Math.LN10;
- },
- // 20.2.2.22 Math.log2(x)
- log2: function log2(x){
- return log(x) / Math.LN2;
- },
- // 20.2.2.28 Math.sign(x)
- sign: sign,
- // 20.2.2.30 Math.sinh(x)
- sinh: function sinh(x){
- return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);
- },
- // 20.2.2.33 Math.tanh(x)
- tanh: function tanh(x){
- var a = expm1(x = +x)
- , b = expm1(-x);
- return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
- },
- // 20.2.2.34 Math.trunc(x)
- trunc: function trunc(it){
- return (it > 0 ? floor : ceil)(it);
- }
- });
- },{"./$.def":236}],269:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , isObject = $.isObject
- , isFunction = $.isFunction
- , NUMBER = 'Number'
- , Number = $.g[NUMBER]
- , Base = Number
- , proto = Number.prototype;
- function toPrimitive(it){
- var fn, val;
- if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;
- if(isFunction(fn = it.toString) && !isObject(val = fn.call(it)))return val;
- throw TypeError("Can't convert object to number");
- }
- function toNumber(it){
- if(isObject(it))it = toPrimitive(it);
- if(typeof it == 'string' && it.length > 2 && it.charCodeAt(0) == 48){
- var binary = false;
- switch(it.charCodeAt(1)){
- case 66 : case 98 : binary = true;
- case 79 : case 111 : return parseInt(it.slice(2), binary ? 2 : 8);
- }
- } return +it;
- }
- if($.FW && !(Number('0o1') && Number('0b1'))){
- Number = function Number(it){
- return this instanceof Number ? new Base(toNumber(it)) : toNumber(it);
- };
- $.each.call($.DESC ? $.getNames(Base) : (
- // ES3:
- 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
- // ES6 (in case, if modules with ES6 Number statics required before):
- 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
- 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
- ).split(','), function(key){
- if($.has(Base, key) && !$.has(Number, key)){
- $.setDesc(Number, key, $.getDesc(Base, key));
- }
- }
- );
- Number.prototype = proto;
- proto.constructor = Number;
- $.hide($.g, NUMBER, Number);
- }
- },{"./$":245}],270:[function(require,module,exports){
- var $ = require('./$')
- , $def = require('./$.def')
- , abs = Math.abs
- , floor = Math.floor
- , _isFinite = $.g.isFinite
- , MAX_SAFE_INTEGER = 0x1fffffffffffff; // pow(2, 53) - 1 == 9007199254740991;
- function isInteger(it){
- return !$.isObject(it) && _isFinite(it) && floor(it) === it;
- }
- $def($def.S, 'Number', {
- // 20.1.2.1 Number.EPSILON
- EPSILON: Math.pow(2, -52),
- // 20.1.2.2 Number.isFinite(number)
- isFinite: function isFinite(it){
- return typeof it == 'number' && _isFinite(it);
- },
- // 20.1.2.3 Number.isInteger(number)
- isInteger: isInteger,
- // 20.1.2.4 Number.isNaN(number)
- isNaN: function isNaN(number){
- return number != number;
- },
- // 20.1.2.5 Number.isSafeInteger(number)
- isSafeInteger: function isSafeInteger(number){
- return isInteger(number) && abs(number) <= MAX_SAFE_INTEGER;
- },
- // 20.1.2.6 Number.MAX_SAFE_INTEGER
- MAX_SAFE_INTEGER: MAX_SAFE_INTEGER,
- // 20.1.2.10 Number.MIN_SAFE_INTEGER
- MIN_SAFE_INTEGER: -MAX_SAFE_INTEGER,
- // 20.1.2.12 Number.parseFloat(string)
- parseFloat: parseFloat,
- // 20.1.2.13 Number.parseInt(string, radix)
- parseInt: parseInt
- });
- },{"./$":245,"./$.def":236}],271:[function(require,module,exports){
- // 19.1.3.1 Object.assign(target, source)
- var $def = require('./$.def');
- $def($def.S, 'Object', {assign: require('./$.assign')});
- },{"./$.assign":229,"./$.def":236}],272:[function(require,module,exports){
- // 19.1.3.10 Object.is(value1, value2)
- var $def = require('./$.def');
- $def($def.S, 'Object', {
- is: function is(x, y){
- return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
- }
- });
- },{"./$.def":236}],273:[function(require,module,exports){
- // 19.1.3.19 Object.setPrototypeOf(O, proto)
- var $def = require('./$.def');
- $def($def.S, 'Object', {setPrototypeOf: require('./$.set-proto').set});
- },{"./$.def":236,"./$.set-proto":250}],274:[function(require,module,exports){
- var $ = require('./$')
- , $def = require('./$.def')
- , isObject = $.isObject
- , toObject = $.toObject;
- function wrapObjectMethod(METHOD, MODE){
- var fn = ($.core.Object || {})[METHOD] || Object[METHOD]
- , f = 0
- , o = {};
- o[METHOD] = MODE == 1 ? function(it){
- return isObject(it) ? fn(it) : it;
- } : MODE == 2 ? function(it){
- return isObject(it) ? fn(it) : true;
- } : MODE == 3 ? function(it){
- return isObject(it) ? fn(it) : false;
- } : MODE == 4 ? function getOwnPropertyDescriptor(it, key){
- return fn(toObject(it), key);
- } : MODE == 5 ? function getPrototypeOf(it){
- return fn(Object($.assertDefined(it)));
- } : function(it){
- return fn(toObject(it));
- };
- try {
- fn('z');
- } catch(e){
- f = 1;
- }
- $def($def.S + $def.F * f, 'Object', o);
- }
- wrapObjectMethod('freeze', 1);
- wrapObjectMethod('seal', 1);
- wrapObjectMethod('preventExtensions', 1);
- wrapObjectMethod('isFrozen', 2);
- wrapObjectMethod('isSealed', 2);
- wrapObjectMethod('isExtensible', 3);
- wrapObjectMethod('getOwnPropertyDescriptor', 4);
- wrapObjectMethod('getPrototypeOf', 5);
- wrapObjectMethod('keys');
- wrapObjectMethod('getOwnPropertyNames');
- },{"./$":245,"./$.def":236}],275:[function(require,module,exports){
- 'use strict';
- // 19.1.3.6 Object.prototype.toString()
- var $ = require('./$')
- , cof = require('./$.cof')
- , tmp = {};
- tmp[require('./$.wks')('toStringTag')] = 'z';
- if($.FW && cof(tmp) != 'z')$.hide(Object.prototype, 'toString', function toString(){
- return '[object ' + cof.classof(this) + ']';
- });
- },{"./$":245,"./$.cof":230,"./$.wks":256}],276:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , ctx = require('./$.ctx')
- , cof = require('./$.cof')
- , $def = require('./$.def')
- , assert = require('./$.assert')
- , forOf = require('./$.for-of')
- , setProto = require('./$.set-proto').set
- , species = require('./$.species')
- , SPECIES = require('./$.wks')('species')
- , RECORD = require('./$.uid').safe('record')
- , PROMISE = 'Promise'
- , global = $.g
- , process = global.process
- , asap = process && process.nextTick || require('./$.task').set
- , P = global[PROMISE]
- , isFunction = $.isFunction
- , isObject = $.isObject
- , assertFunction = assert.fn
- , assertObject = assert.obj
- , test;
- var useNative = isFunction(P) && isFunction(P.resolve) &&
- P.resolve(test = new P(function(){})) == test;
- // actual Firefox has broken subclass support, test that
- function P2(x){
- var self = new P(x);
- setProto(self, P2.prototype);
- return self;
- }
- if(useNative){
- try { // protect against bad/buggy Object.setPrototype
- setProto(P2, P);
- P2.prototype = $.create(P.prototype, {constructor: {value: P2}});
- if(!(P2.resolve(5).then(function(){}) instanceof P2)){
- useNative = false;
- }
- } catch(e){ useNative = false; }
- }
- // helpers
- function getConstructor(C){
- var S = assertObject(C)[SPECIES];
- return S != undefined ? S : C;
- }
- function isThenable(it){
- var then;
- if(isObject(it))then = it.then;
- return isFunction(then) ? then : false;
- }
- function notify(record){
- var chain = record.c;
- if(chain.length)asap(function(){
- var value = record.v
- , ok = record.s == 1
- , i = 0;
- while(chain.length > i)!function(react){
- var cb = ok ? react.ok : react.fail
- , ret, then;
- try {
- if(cb){
- if(!ok)record.h = true;
- ret = cb === true ? value : cb(value);
- if(ret === react.P){
- react.rej(TypeError('Promise-chain cycle'));
- } else if(then = isThenable(ret)){
- then.call(ret, react.res, react.rej);
- } else react.res(ret);
- } else react.rej(value);
- } catch(err){
- react.rej(err);
- }
- }(chain[i++]);
- chain.length = 0;
- });
- }
- function isUnhandled(promise){
- var record = promise[RECORD]
- , chain = record.a
- , i = 0
- , react;
- if(record.h)return false;
- while(chain.length > i){
- react = chain[i++];
- if(react.fail || !isUnhandled(react.P))return false;
- } return true;
- }
- function $reject(value){
- var record = this
- , promise;
- if(record.d)return;
- record.d = true;
- record = record.r || record; // unwrap
- record.v = value;
- record.s = 2;
- asap(function(){
- setTimeout(function(){
- if(isUnhandled(promise = record.p)){
- if(cof(process) == 'process'){
- process.emit('unhandledRejection', value, promise);
- } else if(global.console && isFunction(console.error)){
- console.error('Unhandled promise rejection', value);
- }
- }
- }, 1);
- });
- notify(record);
- }
- function $resolve(value){
- var record = this
- , then, wrapper;
- if(record.d)return;
- record.d = true;
- record = record.r || record; // unwrap
- try {
- if(then = isThenable(value)){
- wrapper = {r: record, d: false}; // wrap
- then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
- } else {
- record.v = value;
- record.s = 1;
- notify(record);
- }
- } catch(err){
- $reject.call(wrapper || {r: record, d: false}, err); // wrap
- }
- }
- // constructor polyfill
- if(!useNative){
- // 25.4.3.1 Promise(executor)
- P = function Promise(executor){
- assertFunction(executor);
- var record = {
- p: assert.inst(this, P, PROMISE), // <- promise
- c: [], // <- awaiting reactions
- a: [], // <- all reactions
- s: 0, // <- state
- d: false, // <- done
- v: undefined, // <- value
- h: false // <- handled rejection
- };
- $.hide(this, RECORD, record);
- try {
- executor(ctx($resolve, record, 1), ctx($reject, record, 1));
- } catch(err){
- $reject.call(record, err);
- }
- };
- $.mix(P.prototype, {
- // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
- then: function then(onFulfilled, onRejected){
- var S = assertObject(assertObject(this).constructor)[SPECIES];
- var react = {
- ok: isFunction(onFulfilled) ? onFulfilled : true,
- fail: isFunction(onRejected) ? onRejected : false
- };
- var promise = react.P = new (S != undefined ? S : P)(function(res, rej){
- react.res = assertFunction(res);
- react.rej = assertFunction(rej);
- });
- var record = this[RECORD];
- record.a.push(react);
- record.c.push(react);
- record.s && notify(record);
- return promise;
- },
- // 25.4.5.1 Promise.prototype.catch(onRejected)
- 'catch': function(onRejected){
- return this.then(undefined, onRejected);
- }
- });
- }
- // export
- $def($def.G + $def.W + $def.F * !useNative, {Promise: P});
- cof.set(P, PROMISE);
- species(P);
- species($.core[PROMISE]); // for wrapper
- // statics
- $def($def.S + $def.F * !useNative, PROMISE, {
- // 25.4.4.5 Promise.reject(r)
- reject: function reject(r){
- return new (getConstructor(this))(function(res, rej){
- rej(r);
- });
- },
- // 25.4.4.6 Promise.resolve(x)
- resolve: function resolve(x){
- return isObject(x) && RECORD in x && $.getProto(x) === this.prototype
- ? x : new (getConstructor(this))(function(res){
- res(x);
- });
- }
- });
- $def($def.S + $def.F * !(useNative && require('./$.iter-detect')(function(iter){
- P.all(iter)['catch'](function(){});
- })), PROMISE, {
- // 25.4.4.1 Promise.all(iterable)
- all: function all(iterable){
- var C = getConstructor(this)
- , values = [];
- return new C(function(res, rej){
- forOf(iterable, false, values.push, values);
- var remaining = values.length
- , results = Array(remaining);
- if(remaining)$.each.call(values, function(promise, index){
- C.resolve(promise).then(function(value){
- results[index] = value;
- --remaining || res(results);
- }, rej);
- });
- else res(results);
- });
- },
- // 25.4.4.4 Promise.race(iterable)
- race: function race(iterable){
- var C = getConstructor(this);
- return new C(function(res, rej){
- forOf(iterable, false, function(promise){
- C.resolve(promise).then(res, rej);
- });
- });
- }
- });
- },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.ctx":235,"./$.def":236,"./$.for-of":238,"./$.iter-detect":243,"./$.set-proto":250,"./$.species":251,"./$.task":253,"./$.uid":254,"./$.wks":256}],277:[function(require,module,exports){
- var $ = require('./$')
- , $def = require('./$.def')
- , setProto = require('./$.set-proto')
- , $iter = require('./$.iter')
- , ITER = require('./$.uid').safe('iter')
- , step = $iter.step
- , assert = require('./$.assert')
- , isObject = $.isObject
- , getDesc = $.getDesc
- , setDesc = $.setDesc
- , getProto = $.getProto
- , apply = Function.apply
- , assertObject = assert.obj
- , _isExtensible = Object.isExtensible || $.it;
- function Enumerate(iterated){
- $.set(this, ITER, {o: iterated, k: undefined, i: 0});
- }
- $iter.create(Enumerate, 'Object', function(){
- var iter = this[ITER]
- , keys = iter.k
- , key;
- if(keys == undefined){
- iter.k = keys = [];
- for(key in iter.o)keys.push(key);
- }
- do {
- if(iter.i >= keys.length)return step(1);
- } while(!((key = keys[iter.i++]) in iter.o));
- return step(0, key);
- });
- function wrap(fn){
- return function(it){
- assertObject(it);
- try {
- fn.apply(undefined, arguments);
- return true;
- } catch(e){
- return false;
- }
- };
- }
- function get(target, propertyKey/*, receiver*/){
- var receiver = arguments.length < 3 ? target : arguments[2]
- , desc = getDesc(assertObject(target), propertyKey), proto;
- if(desc)return $.has(desc, 'value')
- ? desc.value
- : desc.get === undefined
- ? undefined
- : desc.get.call(receiver);
- return isObject(proto = getProto(target))
- ? get(proto, propertyKey, receiver)
- : undefined;
- }
- function set(target, propertyKey, V/*, receiver*/){
- var receiver = arguments.length < 4 ? target : arguments[3]
- , ownDesc = getDesc(assertObject(target), propertyKey)
- , existingDescriptor, proto;
- if(!ownDesc){
- if(isObject(proto = getProto(target))){
- return set(proto, propertyKey, V, receiver);
- }
- ownDesc = $.desc(0);
- }
- if($.has(ownDesc, 'value')){
- if(ownDesc.writable === false || !isObject(receiver))return false;
- existingDescriptor = getDesc(receiver, propertyKey) || $.desc(0);
- existingDescriptor.value = V;
- setDesc(receiver, propertyKey, existingDescriptor);
- return true;
- }
- return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
- }
- var reflect = {
- // 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
- apply: require('./$.ctx')(Function.call, apply, 3),
- // 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
- construct: function construct(target, argumentsList /*, newTarget*/){
- var proto = assert.fn(arguments.length < 3 ? target : arguments[2]).prototype
- , instance = $.create(isObject(proto) ? proto : Object.prototype)
- , result = apply.call(target, instance, argumentsList);
- return isObject(result) ? result : instance;
- },
- // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
- defineProperty: wrap(setDesc),
- // 26.1.4 Reflect.deleteProperty(target, propertyKey)
- deleteProperty: function deleteProperty(target, propertyKey){
- var desc = getDesc(assertObject(target), propertyKey);
- return desc && !desc.configurable ? false : delete target[propertyKey];
- },
- // 26.1.5 Reflect.enumerate(target)
- enumerate: function enumerate(target){
- return new Enumerate(assertObject(target));
- },
- // 26.1.6 Reflect.get(target, propertyKey [, receiver])
- get: get,
- // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
- getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey){
- return getDesc(assertObject(target), propertyKey);
- },
- // 26.1.8 Reflect.getPrototypeOf(target)
- getPrototypeOf: function getPrototypeOf(target){
- return getProto(assertObject(target));
- },
- // 26.1.9 Reflect.has(target, propertyKey)
- has: function has(target, propertyKey){
- return propertyKey in target;
- },
- // 26.1.10 Reflect.isExtensible(target)
- isExtensible: function isExtensible(target){
- return !!_isExtensible(assertObject(target));
- },
- // 26.1.11 Reflect.ownKeys(target)
- ownKeys: require('./$.own-keys'),
- // 26.1.12 Reflect.preventExtensions(target)
- preventExtensions: wrap(Object.preventExtensions || $.it),
- // 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
- set: set
- };
- // 26.1.14 Reflect.setPrototypeOf(target, proto)
- if(setProto)reflect.setPrototypeOf = function setPrototypeOf(target, proto){
- setProto.check(target, proto);
- try {
- setProto.set(target, proto);
- return true;
- } catch(e){
- return false;
- }
- };
- $def($def.G, {Reflect: {}});
- $def($def.S, 'Reflect', reflect);
- },{"./$":245,"./$.assert":228,"./$.ctx":235,"./$.def":236,"./$.iter":244,"./$.own-keys":247,"./$.set-proto":250,"./$.uid":254}],278:[function(require,module,exports){
- var $ = require('./$')
- , cof = require('./$.cof')
- , RegExp = $.g.RegExp
- , Base = RegExp
- , proto = RegExp.prototype;
- function regExpBroken() {
- try {
- var a = /a/g;
- // "new" creates a new object
- if (a === new RegExp(a)) { return true; }
- // RegExp allows a regex with flags as the pattern
- return RegExp(/a/g, 'i') != '/a/i';
- } catch(e) {
- return true;
- }
- }
- if($.FW && $.DESC){
- if(regExpBroken()) {
- RegExp = function RegExp(pattern, flags){
- return new Base(cof(pattern) == 'RegExp' ? pattern.source : pattern,
- flags === undefined ? pattern.flags : flags);
- };
- $.each.call($.getNames(Base), function(key){
- key in RegExp || $.setDesc(RegExp, key, {
- configurable: true,
- get: function(){ return Base[key]; },
- set: function(it){ Base[key] = it; }
- });
- });
- proto.constructor = RegExp;
- RegExp.prototype = proto;
- $.hide($.g, 'RegExp', RegExp);
- }
- // 21.2.5.3 get RegExp.prototype.flags()
- if(/./g.flags != 'g')$.setDesc(proto, 'flags', {
- configurable: true,
- get: require('./$.replacer')(/^.*\/(\w*)$/, '$1')
- });
- }
- require('./$.species')(RegExp);
- },{"./$":245,"./$.cof":230,"./$.replacer":249,"./$.species":251}],279:[function(require,module,exports){
- 'use strict';
- var strong = require('./$.collection-strong');
- // 23.2 Set Objects
- require('./$.collection')('Set', {
- // 23.2.3.1 Set.prototype.add(value)
- add: function add(value){
- return strong.def(this, value = value === 0 ? 0 : value, value);
- }
- }, strong);
- },{"./$.collection":234,"./$.collection-strong":231}],280:[function(require,module,exports){
- var $def = require('./$.def');
- $def($def.P, 'String', {
- // 21.1.3.3 String.prototype.codePointAt(pos)
- codePointAt: require('./$.string-at')(false)
- });
- },{"./$.def":236,"./$.string-at":252}],281:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , cof = require('./$.cof')
- , $def = require('./$.def')
- , toLength = $.toLength;
- $def($def.P, 'String', {
- // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
- endsWith: function endsWith(searchString /*, endPosition = @length */){
- if(cof(searchString) == 'RegExp')throw TypeError();
- var that = String($.assertDefined(this))
- , endPosition = arguments[1]
- , len = toLength(that.length)
- , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
- searchString += '';
- return that.slice(end - searchString.length, end) === searchString;
- }
- });
- },{"./$":245,"./$.cof":230,"./$.def":236}],282:[function(require,module,exports){
- var $def = require('./$.def')
- , toIndex = require('./$').toIndex
- , fromCharCode = String.fromCharCode;
- $def($def.S, 'String', {
- // 21.1.2.2 String.fromCodePoint(...codePoints)
- fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
- var res = []
- , len = arguments.length
- , i = 0
- , code;
- while(len > i){
- code = +arguments[i++];
- if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
- res.push(code < 0x10000
- ? fromCharCode(code)
- : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
- );
- } return res.join('');
- }
- });
- },{"./$":245,"./$.def":236}],283:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , cof = require('./$.cof')
- , $def = require('./$.def');
- $def($def.P, 'String', {
- // 21.1.3.7 String.prototype.includes(searchString, position = 0)
- includes: function includes(searchString /*, position = 0 */){
- if(cof(searchString) == 'RegExp')throw TypeError();
- return !!~String($.assertDefined(this)).indexOf(searchString, arguments[1]);
- }
- });
- },{"./$":245,"./$.cof":230,"./$.def":236}],284:[function(require,module,exports){
- var set = require('./$').set
- , at = require('./$.string-at')(true)
- , ITER = require('./$.uid').safe('iter')
- , $iter = require('./$.iter')
- , step = $iter.step;
- // 21.1.3.27 String.prototype[@@iterator]()
- require('./$.iter-define')(String, 'String', function(iterated){
- set(this, ITER, {o: String(iterated), i: 0});
- // 21.1.5.2.1 %StringIteratorPrototype%.next()
- }, function(){
- var iter = this[ITER]
- , O = iter.o
- , index = iter.i
- , point;
- if(index >= O.length)return step(1);
- point = at.call(O, index);
- iter.i += point.length;
- return step(0, point);
- });
- },{"./$":245,"./$.iter":244,"./$.iter-define":242,"./$.string-at":252,"./$.uid":254}],285:[function(require,module,exports){
- var $ = require('./$')
- , $def = require('./$.def');
- $def($def.S, 'String', {
- // 21.1.2.4 String.raw(callSite, ...substitutions)
- raw: function raw(callSite){
- var tpl = $.toObject(callSite.raw)
- , len = $.toLength(tpl.length)
- , sln = arguments.length
- , res = []
- , i = 0;
- while(len > i){
- res.push(String(tpl[i++]));
- if(i < sln)res.push(String(arguments[i]));
- } return res.join('');
- }
- });
- },{"./$":245,"./$.def":236}],286:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , $def = require('./$.def');
- $def($def.P, 'String', {
- // 21.1.3.13 String.prototype.repeat(count)
- repeat: function repeat(count){
- var str = String($.assertDefined(this))
- , res = ''
- , n = $.toInteger(count);
- if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
- for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
- return res;
- }
- });
- },{"./$":245,"./$.def":236}],287:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , cof = require('./$.cof')
- , $def = require('./$.def');
- $def($def.P, 'String', {
- // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
- startsWith: function startsWith(searchString /*, position = 0 */){
- if(cof(searchString) == 'RegExp')throw TypeError();
- var that = String($.assertDefined(this))
- , index = $.toLength(Math.min(arguments[1], that.length));
- searchString += '';
- return that.slice(index, index + searchString.length) === searchString;
- }
- });
- },{"./$":245,"./$.cof":230,"./$.def":236}],288:[function(require,module,exports){
- 'use strict';
- // ECMAScript 6 symbols shim
- var $ = require('./$')
- , setTag = require('./$.cof').set
- , uid = require('./$.uid')
- , $def = require('./$.def')
- , keyOf = require('./$.keyof')
- , enumKeys = require('./$.enum-keys')
- , assertObject = require('./$.assert').obj
- , has = $.has
- , $create = $.create
- , getDesc = $.getDesc
- , setDesc = $.setDesc
- , desc = $.desc
- , getNames = $.getNames
- , toObject = $.toObject
- , Symbol = $.g.Symbol
- , setter = false
- , TAG = uid('tag')
- , HIDDEN = uid('hidden')
- , SymbolRegistry = {}
- , AllSymbols = {}
- , useNative = $.isFunction(Symbol);
- function wrap(tag){
- var sym = AllSymbols[tag] = $.set($create(Symbol.prototype), TAG, tag);
- $.DESC && setter && setDesc(Object.prototype, tag, {
- configurable: true,
- set: function(value){
- if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
- setDesc(this, tag, desc(1, value));
- }
- });
- return sym;
- }
- function defineProperty(it, key, D){
- if(D && has(AllSymbols, key)){
- if(!D.enumerable){
- if(!has(it, HIDDEN))setDesc(it, HIDDEN, desc(1, {}));
- it[HIDDEN][key] = true;
- } else {
- if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
- D.enumerable = false;
- }
- } return setDesc(it, key, D);
- }
- function defineProperties(it, P){
- assertObject(it);
- var keys = enumKeys(P = toObject(P))
- , i = 0
- , l = keys.length
- , key;
- while(l > i)defineProperty(it, key = keys[i++], P[key]);
- return it;
- }
- function create(it, P){
- return P === undefined ? $create(it) : defineProperties($create(it), P);
- }
- function getOwnPropertyDescriptor(it, key){
- var D = getDesc(it = toObject(it), key);
- if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
- return D;
- }
- function getOwnPropertyNames(it){
- var names = getNames(toObject(it))
- , result = []
- , i = 0
- , key;
- while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key);
- return result;
- }
- function getOwnPropertySymbols(it){
- var names = getNames(toObject(it))
- , result = []
- , i = 0
- , key;
- while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]);
- return result;
- }
- // 19.4.1.1 Symbol([description])
- if(!useNative){
- Symbol = function Symbol(description){
- if(this instanceof Symbol)throw TypeError('Symbol is not a constructor');
- return wrap(uid(description));
- };
- $.hide(Symbol.prototype, 'toString', function(){
- return this[TAG];
- });
- $.create = create;
- $.setDesc = defineProperty;
- $.getDesc = getOwnPropertyDescriptor;
- $.setDescs = defineProperties;
- $.getNames = getOwnPropertyNames;
- $.getSymbols = getOwnPropertySymbols;
- }
- var symbolStatics = {
- // 19.4.2.1 Symbol.for(key)
- 'for': function(key){
- return has(SymbolRegistry, key += '')
- ? SymbolRegistry[key]
- : SymbolRegistry[key] = Symbol(key);
- },
- // 19.4.2.5 Symbol.keyFor(sym)
- keyFor: function keyFor(key){
- return keyOf(SymbolRegistry, key);
- },
- useSetter: function(){ setter = true; },
- useSimple: function(){ setter = false; }
- };
- // 19.4.2.2 Symbol.hasInstance
- // 19.4.2.3 Symbol.isConcatSpreadable
- // 19.4.2.4 Symbol.iterator
- // 19.4.2.6 Symbol.match
- // 19.4.2.8 Symbol.replace
- // 19.4.2.9 Symbol.search
- // 19.4.2.10 Symbol.species
- // 19.4.2.11 Symbol.split
- // 19.4.2.12 Symbol.toPrimitive
- // 19.4.2.13 Symbol.toStringTag
- // 19.4.2.14 Symbol.unscopables
- $.each.call((
- 'hasInstance,isConcatSpreadable,iterator,match,replace,search,' +
- 'species,split,toPrimitive,toStringTag,unscopables'
- ).split(','), function(it){
- var sym = require('./$.wks')(it);
- symbolStatics[it] = useNative ? sym : wrap(sym);
- }
- );
- setter = true;
- $def($def.G + $def.W, {Symbol: Symbol});
- $def($def.S, 'Symbol', symbolStatics);
- $def($def.S + $def.F * !useNative, 'Object', {
- // 19.1.2.2 Object.create(O [, Properties])
- create: create,
- // 19.1.2.4 Object.defineProperty(O, P, Attributes)
- defineProperty: defineProperty,
- // 19.1.2.3 Object.defineProperties(O, Properties)
- defineProperties: defineProperties,
- // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
- getOwnPropertyDescriptor: getOwnPropertyDescriptor,
- // 19.1.2.7 Object.getOwnPropertyNames(O)
- getOwnPropertyNames: getOwnPropertyNames,
- // 19.1.2.8 Object.getOwnPropertySymbols(O)
- getOwnPropertySymbols: getOwnPropertySymbols
- });
- // 19.4.3.5 Symbol.prototype[@@toStringTag]
- setTag(Symbol, 'Symbol');
- // 20.2.1.9 Math[@@toStringTag]
- setTag(Math, 'Math', true);
- // 24.3.3 JSON[@@toStringTag]
- setTag($.g.JSON, 'JSON', true);
- },{"./$":245,"./$.assert":228,"./$.cof":230,"./$.def":236,"./$.enum-keys":237,"./$.keyof":246,"./$.uid":254,"./$.wks":256}],289:[function(require,module,exports){
- 'use strict';
- var $ = require('./$')
- , weak = require('./$.collection-weak')
- , leakStore = weak.leakStore
- , ID = weak.ID
- , WEAK = weak.WEAK
- , has = $.has
- , isObject = $.isObject
- , isFrozen = Object.isFrozen || $.core.Object.isFrozen
- , tmp = {};
- // 23.3 WeakMap Objects
- var WeakMap = require('./$.collection')('WeakMap', {
- // 23.3.3.3 WeakMap.prototype.get(key)
- get: function get(key){
- if(isObject(key)){
- if(isFrozen(key))return leakStore(this).get(key);
- if(has(key, WEAK))return key[WEAK][this[ID]];
- }
- },
- // 23.3.3.5 WeakMap.prototype.set(key, value)
- set: function set(key, value){
- return weak.def(this, key, value);
- }
- }, weak, true, true);
- // IE11 WeakMap frozen keys fix
- if($.FW && new WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
- $.each.call(['delete', 'has', 'get', 'set'], function(key){
- var method = WeakMap.prototype[key];
- WeakMap.prototype[key] = function(a, b){
- // store frozen objects on leaky map
- if(isObject(a) && isFrozen(a)){
- var result = leakStore(this)[key](a, b);
- return key == 'set' ? this : result;
- // store all the rest on native weakmap
- } return method.call(this, a, b);
- };
- });
- }
- },{"./$":245,"./$.collection":234,"./$.collection-weak":233}],290:[function(require,module,exports){
- 'use strict';
- var weak = require('./$.collection-weak');
- // 23.4 WeakSet Objects
- require('./$.collection')('WeakSet', {
- // 23.4.3.1 WeakSet.prototype.add(value)
- add: function add(value){
- return weak.def(this, value, true);
- }
- }, weak, false, true);
- },{"./$.collection":234,"./$.collection-weak":233}],291:[function(require,module,exports){
- // https://github.com/domenic/Array.prototype.includes
- var $def = require('./$.def');
- $def($def.P, 'Array', {
- includes: require('./$.array-includes')(true)
- });
- require('./$.unscope')('includes');
- },{"./$.array-includes":226,"./$.def":236,"./$.unscope":255}],292:[function(require,module,exports){
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- require('./$.collection-to-json')('Map');
- },{"./$.collection-to-json":232}],293:[function(require,module,exports){
- // https://gist.github.com/WebReflection/9353781
- var $ = require('./$')
- , $def = require('./$.def')
- , ownKeys = require('./$.own-keys');
- $def($def.S, 'Object', {
- getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
- var O = $.toObject(object)
- , result = {};
- $.each.call(ownKeys(O), function(key){
- $.setDesc(result, key, $.desc(0, $.getDesc(O, key)));
- });
- return result;
- }
- });
- },{"./$":245,"./$.def":236,"./$.own-keys":247}],294:[function(require,module,exports){
- // http://goo.gl/XkBrjD
- var $ = require('./$')
- , $def = require('./$.def');
- function createObjectToArray(isEntries){
- return function(object){
- var O = $.toObject(object)
- , keys = $.getKeys(O)
- , length = keys.length
- , i = 0
- , result = Array(length)
- , key;
- if(isEntries)while(length > i)result[i] = [key = keys[i++], O[key]];
- else while(length > i)result[i] = O[keys[i++]];
- return result;
- };
- }
- $def($def.S, 'Object', {
- values: createObjectToArray(false),
- entries: createObjectToArray(true)
- });
- },{"./$":245,"./$.def":236}],295:[function(require,module,exports){
- // https://gist.github.com/kangax/9698100
- var $def = require('./$.def');
- $def($def.S, 'RegExp', {
- escape: require('./$.replacer')(/([\\\-[\]{}()*+?.,^$|])/g, '\\$1', true)
- });
- },{"./$.def":236,"./$.replacer":249}],296:[function(require,module,exports){
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- require('./$.collection-to-json')('Set');
- },{"./$.collection-to-json":232}],297:[function(require,module,exports){
- // https://github.com/mathiasbynens/String.prototype.at
- var $def = require('./$.def');
- $def($def.P, 'String', {
- at: require('./$.string-at')(true)
- });
- },{"./$.def":236,"./$.string-at":252}],298:[function(require,module,exports){
- // JavaScript 1.6 / Strawman array statics shim
- var $ = require('./$')
- , $def = require('./$.def')
- , $Array = $.core.Array || Array
- , statics = {};
- function setStatics(keys, length){
- $.each.call(keys.split(','), function(key){
- if(length == undefined && key in $Array)statics[key] = $Array[key];
- else if(key in [])statics[key] = require('./$.ctx')(Function.call, [][key], length);
- });
- }
- setStatics('pop,reverse,shift,keys,values,entries', 1);
- setStatics('indexOf,every,some,forEach,map,filter,find,findIndex,includes', 3);
- setStatics('join,slice,concat,push,splice,unshift,sort,lastIndexOf,' +
- 'reduce,reduceRight,copyWithin,fill,turn');
- $def($def.S, 'Array', statics);
- },{"./$":245,"./$.ctx":235,"./$.def":236}],299:[function(require,module,exports){
- require('./es6.array.iterator');
- var $ = require('./$')
- , Iterators = require('./$.iter').Iterators
- , ITERATOR = require('./$.wks')('iterator')
- , ArrayValues = Iterators.Array
- , NodeList = $.g.NodeList;
- if($.FW && NodeList && !(ITERATOR in NodeList.prototype)){
- $.hide(NodeList.prototype, ITERATOR, ArrayValues);
- }
- Iterators.NodeList = ArrayValues;
- },{"./$":245,"./$.iter":244,"./$.wks":256,"./es6.array.iterator":263}],300:[function(require,module,exports){
- var $def = require('./$.def')
- , $task = require('./$.task');
- $def($def.G + $def.B, {
- setImmediate: $task.set,
- clearImmediate: $task.clear
- });
- },{"./$.def":236,"./$.task":253}],301:[function(require,module,exports){
- // ie9- setTimeout & setInterval additional parameters fix
- var $ = require('./$')
- , $def = require('./$.def')
- , invoke = require('./$.invoke')
- , partial = require('./$.partial')
- , navigator = $.g.navigator
- , MSIE = !!navigator && /MSIE .\./.test(navigator.userAgent); // <- dirty ie9- check
- function wrap(set){
- return MSIE ? function(fn, time /*, ...args */){
- return set(invoke(
- partial,
- [].slice.call(arguments, 2),
- $.isFunction(fn) ? fn : Function(fn)
- ), time);
- } : set;
- }
- $def($def.G + $def.B + $def.F * MSIE, {
- setTimeout: wrap($.g.setTimeout),
- setInterval: wrap($.g.setInterval)
- });
- },{"./$":245,"./$.def":236,"./$.invoke":240,"./$.partial":248}],302:[function(require,module,exports){
- require('./modules/es5');
- require('./modules/es6.symbol');
- require('./modules/es6.object.assign');
- require('./modules/es6.object.is');
- require('./modules/es6.object.set-prototype-of');
- require('./modules/es6.object.to-string');
- require('./modules/es6.object.statics-accept-primitives');
- require('./modules/es6.function.name');
- require('./modules/es6.number.constructor');
- require('./modules/es6.number.statics');
- require('./modules/es6.math');
- require('./modules/es6.string.from-code-point');
- require('./modules/es6.string.raw');
- require('./modules/es6.string.iterator');
- require('./modules/es6.string.code-point-at');
- require('./modules/es6.string.ends-with');
- require('./modules/es6.string.includes');
- require('./modules/es6.string.repeat');
- require('./modules/es6.string.starts-with');
- require('./modules/es6.array.from');
- require('./modules/es6.array.of');
- require('./modules/es6.array.iterator');
- require('./modules/es6.array.species');
- require('./modules/es6.array.copy-within');
- require('./modules/es6.array.fill');
- require('./modules/es6.array.find');
- require('./modules/es6.array.find-index');
- require('./modules/es6.regexp');
- require('./modules/es6.promise');
- require('./modules/es6.map');
- require('./modules/es6.set');
- require('./modules/es6.weak-map');
- require('./modules/es6.weak-set');
- require('./modules/es6.reflect');
- require('./modules/es7.array.includes');
- require('./modules/es7.string.at');
- require('./modules/es7.regexp.escape');
- require('./modules/es7.object.get-own-property-descriptors');
- require('./modules/es7.object.to-array');
- require('./modules/es7.map.to-json');
- require('./modules/es7.set.to-json');
- require('./modules/js.array.statics');
- require('./modules/web.timers');
- require('./modules/web.immediate');
- require('./modules/web.dom.iterable');
- module.exports = require('./modules/$').core;
- },{"./modules/$":245,"./modules/es5":257,"./modules/es6.array.copy-within":258,"./modules/es6.array.fill":259,"./modules/es6.array.find":261,"./modules/es6.array.find-index":260,"./modules/es6.array.from":262,"./modules/es6.array.iterator":263,"./modules/es6.array.of":264,"./modules/es6.array.species":265,"./modules/es6.function.name":266,"./modules/es6.map":267,"./modules/es6.math":268,"./modules/es6.number.constructor":269,"./modules/es6.number.statics":270,"./modules/es6.object.assign":271,"./modules/es6.object.is":272,"./modules/es6.object.set-prototype-of":273,"./modules/es6.object.statics-accept-primitives":274,"./modules/es6.object.to-string":275,"./modules/es6.promise":276,"./modules/es6.reflect":277,"./modules/es6.regexp":278,"./modules/es6.set":279,"./modules/es6.string.code-point-at":280,"./modules/es6.string.ends-with":281,"./modules/es6.string.from-code-point":282,"./modules/es6.string.includes":283,"./modules/es6.string.iterator":284,"./modules/es6.string.raw":285,"./modules/es6.string.repeat":286,"./modules/es6.string.starts-with":287,"./modules/es6.symbol":288,"./modules/es6.weak-map":289,"./modules/es6.weak-set":290,"./modules/es7.array.includes":291,"./modules/es7.map.to-json":292,"./modules/es7.object.get-own-property-descriptors":293,"./modules/es7.object.to-array":294,"./modules/es7.regexp.escape":295,"./modules/es7.set.to-json":296,"./modules/es7.string.at":297,"./modules/js.array.statics":298,"./modules/web.dom.iterable":299,"./modules/web.immediate":300,"./modules/web.timers":301}],303:[function(require,module,exports){
- /**
- * This is the common logic for both the Node.js and web browser
- * implementations of `debug()`.
- *
- * Expose `debug()` as the module.
- */
- exports = module.exports = debug;
- exports.coerce = coerce;
- exports.disable = disable;
- exports.enable = enable;
- exports.enabled = enabled;
- exports.humanize = require('ms');
- /**
- * The currently active debug mode names, and names to skip.
- */
- exports.names = [];
- exports.skips = [];
- /**
- * Map of special "%n" handling functions, for the debug "format" argument.
- *
- * Valid key names are a single, lowercased letter, i.e. "n".
- */
- exports.formatters = {};
- /**
- * Previously assigned color.
- */
- var prevColor = 0;
- /**
- * Previous log timestamp.
- */
- var prevTime;
- /**
- * Select a color.
- *
- * @return {Number}
- * @api private
- */
- function selectColor() {
- return exports.colors[prevColor++ % exports.colors.length];
- }
- /**
- * Create a debugger with the given `namespace`.
- *
- * @param {String} namespace
- * @return {Function}
- * @api public
- */
- function debug(namespace) {
- // define the `disabled` version
- function disabled() {
- }
- disabled.enabled = false;
- // define the `enabled` version
- function enabled() {
- var self = enabled;
- // set `diff` timestamp
- var curr = +new Date();
- var ms = curr - (prevTime || curr);
- self.diff = ms;
- self.prev = prevTime;
- self.curr = curr;
- prevTime = curr;
- // add the `color` if not set
- if (null == self.useColors) self.useColors = exports.useColors();
- if (null == self.color && self.useColors) self.color = selectColor();
- var args = Array.prototype.slice.call(arguments);
- args[0] = exports.coerce(args[0]);
- if ('string' !== typeof args[0]) {
- // anything else let's inspect with %o
- args = ['%o'].concat(args);
- }
- // apply any `formatters` transformations
- var index = 0;
- args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
- // if we encounter an escaped % then don't increase the array index
- if (match === '%%') return match;
- index++;
- var formatter = exports.formatters[format];
- if ('function' === typeof formatter) {
- var val = args[index];
- match = formatter.call(self, val);
- // now we need to remove `args[index]` since it's inlined in the `format`
- args.splice(index, 1);
- index--;
- }
- return match;
- });
- if ('function' === typeof exports.formatArgs) {
- args = exports.formatArgs.apply(self, args);
- }
- var logFn = enabled.log || exports.log || console.log.bind(console);
- logFn.apply(self, args);
- }
- enabled.enabled = true;
- var fn = exports.enabled(namespace) ? enabled : disabled;
- fn.namespace = namespace;
- return fn;
- }
- /**
- * Enables a debug mode by namespaces. This can include modes
- * separated by a colon and wildcards.
- *
- * @param {String} namespaces
- * @api public
- */
- function enable(namespaces) {
- exports.save(namespaces);
- var split = (namespaces || '').split(/[\s,]+/);
- var len = split.length;
- for (var i = 0; i < len; i++) {
- if (!split[i]) continue; // ignore empty strings
- namespaces = split[i].replace(/\*/g, '.*?');
- if (namespaces[0] === '-') {
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
- } else {
- exports.names.push(new RegExp('^' + namespaces + '$'));
- }
- }
- }
- /**
- * Disable debug output.
- *
- * @api public
- */
- function disable() {
- exports.enable('');
- }
- /**
- * Returns true if the given mode name is enabled, false otherwise.
- *
- * @param {String} name
- * @return {Boolean}
- * @api public
- */
- function enabled(name) {
- var i, len;
- for (i = 0, len = exports.skips.length; i < len; i++) {
- if (exports.skips[i].test(name)) {
- return false;
- }
- }
- for (i = 0, len = exports.names.length; i < len; i++) {
- if (exports.names[i].test(name)) {
- return true;
- }
- }
- return false;
- }
- /**
- * Coerce `val`.
- *
- * @param {Mixed} val
- * @return {Mixed}
- * @api private
- */
- function coerce(val) {
- if (val instanceof Error) return val.stack || val.message;
- return val;
- }
- },{"ms":305}],304:[function(require,module,exports){
- (function (process){
- /**
- * Module dependencies.
- */
- var tty = require('tty');
- var util = require('util');
- /**
- * This is the Node.js implementation of `debug()`.
- *
- * Expose `debug()` as the module.
- */
- exports = module.exports = require('./debug');
- exports.log = log;
- exports.formatArgs = formatArgs;
- exports.save = save;
- exports.load = load;
- exports.useColors = useColors;
- /**
- * Colors.
- */
- exports.colors = [6, 2, 3, 4, 5, 1];
- /**
- * The file descriptor to write the `debug()` calls to.
- * Set the `DEBUG_FD` env variable to override with another value. i.e.:
- *
- * $ DEBUG_FD=3 node script.js 3>debug.log
- */
- var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
- var stream = 1 === fd ? process.stdout :
- 2 === fd ? process.stderr :
- createWritableStdioStream(fd);
- /**
- * Is stdout a TTY? Colored output is enabled when `true`.
- */
- function useColors() {
- var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
- if (0 === debugColors.length) {
- return tty.isatty(fd);
- } else {
- return '0' !== debugColors
- && 'no' !== debugColors
- && 'false' !== debugColors
- && 'disabled' !== debugColors;
- }
- }
- /**
- * Map %o to `util.inspect()`, since Node doesn't do that out of the box.
- */
- var inspect = (4 === util.inspect.length ?
- // node <= 0.8.x
- function (v, colors) {
- return util.inspect(v, void 0, void 0, colors);
- } :
- // node > 0.8.x
- function (v, colors) {
- return util.inspect(v, { colors: colors });
- }
- );
- exports.formatters.o = function(v) {
- return inspect(v, this.useColors)
- .replace(/\s*\n\s*/g, ' ');
- };
- /**
- * Adds ANSI color escape codes if enabled.
- *
- * @api public
- */
- function formatArgs() {
- var args = arguments;
- var useColors = this.useColors;
- var name = this.namespace;
- if (useColors) {
- var c = this.color;
- args[0] = ' \u001b[3' + c + ';1m' + name + ' '
- + '\u001b[0m'
- + args[0] + '\u001b[3' + c + 'm'
- + ' +' + exports.humanize(this.diff) + '\u001b[0m';
- } else {
- args[0] = new Date().toUTCString()
- + ' ' + name + ' ' + args[0];
- }
- return args;
- }
- /**
- * Invokes `console.error()` with the specified arguments.
- */
- function log() {
- return stream.write(util.format.apply(this, arguments) + '\n');
- }
- /**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
- function save(namespaces) {
- if (null == namespaces) {
- // If you set a process.env field to null or undefined, it gets cast to the
- // string 'null' or 'undefined'. Just delete instead.
- delete process.env.DEBUG;
- } else {
- process.env.DEBUG = namespaces;
- }
- }
- /**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
- function load() {
- return process.env.DEBUG;
- }
- /**
- * Copied from `node/src/node.js`.
- *
- * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
- * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
- */
- function createWritableStdioStream (fd) {
- var stream;
- var tty_wrap = process.binding('tty_wrap');
- // Note stream._type is used for test-module-load-list.js
- switch (tty_wrap.guessHandleType(fd)) {
- case 'TTY':
- stream = new tty.WriteStream(fd);
- stream._type = 'tty';
- // Hack to have stream not keep the event loop alive.
- // See https://github.com/joyent/node/issues/1726
- if (stream._handle && stream._handle.unref) {
- stream._handle.unref();
- }
- break;
- case 'FILE':
- var fs = require('fs');
- stream = new fs.SyncWriteStream(fd, { autoClose: false });
- stream._type = 'fs';
- break;
- case 'PIPE':
- case 'TCP':
- var net = require('net');
- stream = new net.Socket({
- fd: fd,
- readable: false,
- writable: true
- });
- // FIXME Should probably have an option in net.Socket to create a
- // stream from an existing fd which is writable only. But for now
- // we'll just add this hack and set the `readable` member to false.
- // Test: ./node test/fixtures/echo.js < /etc/passwd
- stream.readable = false;
- stream.read = null;
- stream._type = 'pipe';
- // FIXME Hack to have stream not keep the event loop alive.
- // See https://github.com/joyent/node/issues/1726
- if (stream._handle && stream._handle.unref) {
- stream._handle.unref();
- }
- break;
- default:
- // Probably an error on in uv_guess_handle()
- throw new Error('Implement me. Unknown stream file type!');
- }
- // For supporting legacy API we put the FD here.
- stream.fd = fd;
- stream._isStdio = true;
- return stream;
- }
- /**
- * Enable namespaces listed in `process.env.DEBUG` initially.
- */
- exports.enable(load());
- }).call(this,require('_process'))
- },{"./debug":303,"_process":200,"fs":189,"net":189,"tty":214,"util":216}],305:[function(require,module,exports){
- /**
- * Helpers.
- */
- var s = 1000;
- var m = s * 60;
- var h = m * 60;
- var d = h * 24;
- var y = d * 365.25;
- /**
- * Parse or format the given `val`.
- *
- * Options:
- *
- * - `long` verbose formatting [false]
- *
- * @param {String|Number} val
- * @param {Object} options
- * @return {String|Number}
- * @api public
- */
- module.exports = function(val, options){
- options = options || {};
- if ('string' == typeof val) return parse(val);
- return options.long
- ? long(val)
- : short(val);
- };
- /**
- * Parse the given `str` and return milliseconds.
- *
- * @param {String} str
- * @return {Number}
- * @api private
- */
- function parse(str) {
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
- if (!match) return;
- var n = parseFloat(match[1]);
- var type = (match[2] || 'ms').toLowerCase();
- switch (type) {
- case 'years':
- case 'year':
- case 'yrs':
- case 'yr':
- case 'y':
- return n * y;
- case 'days':
- case 'day':
- case 'd':
- return n * d;
- case 'hours':
- case 'hour':
- case 'hrs':
- case 'hr':
- case 'h':
- return n * h;
- case 'minutes':
- case 'minute':
- case 'mins':
- case 'min':
- case 'm':
- return n * m;
- case 'seconds':
- case 'second':
- case 'secs':
- case 'sec':
- case 's':
- return n * s;
- case 'milliseconds':
- case 'millisecond':
- case 'msecs':
- case 'msec':
- case 'ms':
- return n;
- }
- }
- /**
- * Short format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
- function short(ms) {
- if (ms >= d) return Math.round(ms / d) + 'd';
- if (ms >= h) return Math.round(ms / h) + 'h';
- if (ms >= m) return Math.round(ms / m) + 'm';
- if (ms >= s) return Math.round(ms / s) + 's';
- return ms + 'ms';
- }
- /**
- * Long format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
- function long(ms) {
- return plural(ms, d, 'day')
- || plural(ms, h, 'hour')
- || plural(ms, m, 'minute')
- || plural(ms, s, 'second')
- || ms + ' ms';
- }
- /**
- * Pluralization helper.
- */
- function plural(ms, n, name) {
- if (ms < n) return;
- if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
- return Math.ceil(ms / n) + ' ' + name + 's';
- }
- },{}],306:[function(require,module,exports){
- 'use strict';
- var repeating = require('repeating');
- // detect either spaces or tabs but not both to properly handle tabs
- // for indentation and spaces for alignment
- var INDENT_RE = /^(?:( )+|\t+)/;
- function getMostUsed(indents) {
- var result = 0;
- var maxUsed = 0;
- var maxWeight = 0;
- for (var n in indents) {
- var indent = indents[n];
- var u = indent[0];
- var w = indent[1];
- if (u > maxUsed || u === maxUsed && w > maxWeight) {
- maxUsed = u;
- maxWeight = w;
- result = +n;
- }
- }
- return result;
- }
- module.exports = function (str) {
- if (typeof str !== 'string') {
- throw new TypeError('Expected a string');
- }
- // used to see if tabs or spaces are the most used
- var tabs = 0;
- var spaces = 0;
- // remember the size of previous line's indentation
- var prev = 0;
- // remember how many indents/unindents as occurred for a given size
- // and how much lines follow a given indentation
- //
- // indents = {
- // 3: [1, 0],
- // 4: [1, 5],
- // 5: [1, 0],
- // 12: [1, 0],
- // }
- var indents = {};
- // pointer to the array of last used indent
- var current;
- // whether the last action was an indent (opposed to an unindent)
- var isIndent;
- str.split(/\n/g).forEach(function (line) {
- if (!line) {
- // ignore empty lines
- return;
- }
- var indent;
- var matches = line.match(INDENT_RE);
- if (!matches) {
- indent = 0;
- } else {
- indent = matches[0].length;
- if (matches[1]) {
- spaces++;
- } else {
- tabs++;
- }
- }
- var diff = indent - prev;
- prev = indent;
- if (diff) {
- // an indent or unindent has been detected
- isIndent = diff > 0;
- current = indents[isIndent ? diff : -diff];
- if (current) {
- current[0]++;
- } else {
- current = indents[diff] = [1, 0];
- }
- } else if (current) {
- // if the last action was an indent, increment the weight
- current[1] += +isIndent;
- }
- });
- var amount = getMostUsed(indents);
- var type;
- var actual;
- if (!amount) {
- type = null;
- actual = '';
- } else if (spaces >= tabs) {
- type = 'space';
- actual = repeating(' ', amount);
- } else {
- type = 'tab';
- actual = repeating('\t', amount);
- }
- return {
- amount: amount,
- type: type,
- indent: actual
- };
- };
- },{"repeating":479}],307:[function(require,module,exports){
- /* vim: set sw=4 sts=4 : */
- (function () {
- var estraverse = require('estraverse');
- var parser = require('./parser');
- var isArray = Array.isArray || function isArray(array) {
- return {}.toString.call(array) === '[object Array]';
- };
- function esqueryModule() {
- /**
- * Get the value of a property which may be multiple levels down in the object.
- */
- function getPath(obj, key) {
- var i, keys = key.split(".");
- for (i = 0; i < keys.length; i++) {
- if (obj == null) { return obj; }
- obj = obj[keys[i]];
- }
- return obj;
- }
- /**
- * Determine whether `node` can be reached by following `path`, starting at `ancestor`.
- */
- function inPath(node, ancestor, path) {
- var field, remainingPath, i;
- if (path.length === 0) { return node === ancestor; }
- if (ancestor == null) { return false; }
- field = ancestor[path[0]];
- remainingPath = path.slice(1);
- if (isArray(field)) {
- for (i = 0, l = field.length; i < l; ++i) {
- if (inPath(node, field[i], remainingPath)) { return true; }
- }
- return false;
- } else {
- return inPath(node, field, remainingPath);
- }
- }
- /**
- * Given a `node` and its ancestors, determine if `node` is matched by `selector`.
- */
- function matches(node, selector, ancestry) {
- var path, ancestor, i, l, p;
- if (!selector) { return true; }
- if (!node) { return false; }
- if (!ancestry) { ancestry = []; }
- switch(selector.type) {
- case 'wildcard':
- return true;
- case 'identifier':
- return selector.value.toLowerCase() === node.type.toLowerCase();
- case 'field':
- path = selector.name.split('.');
- ancestor = ancestry[path.length - 1];
- return inPath(node, ancestor, path);
- case 'matches':
- for (i = 0, l = selector.selectors.length; i < l; ++i) {
- if (matches(node, selector.selectors[i], ancestry)) { return true; }
- }
- return false;
- case 'compound':
- for (i = 0, l = selector.selectors.length; i < l; ++i) {
- if (!matches(node, selector.selectors[i], ancestry)) { return false; }
- }
- return true;
- case 'not':
- for (i = 0, l = selector.selectors.length; i < l; ++i) {
- if (matches(node, selector.selectors[i], ancestry)) { return false; }
- }
- return true;
- case 'child':
- if (matches(node, selector.right, ancestry)) {
- return matches(ancestry[0], selector.left, ancestry.slice(1));
- }
- return false;
- case 'descendant':
- if (matches(node, selector.right, ancestry)) {
- for (i = 0, l = ancestry.length; i < l; ++i) {
- if (matches(ancestry[i], selector.left, ancestry.slice(i + 1))) {
- return true;
- }
- }
- }
- return false;
- case 'attribute':
- p = getPath(node, selector.name);
- switch (selector.operator) {
- case null:
- case void 0:
- return p != null;
- case '=':
- switch (selector.value.type) {
- case 'regexp': return selector.value.value.test(p);
- case 'literal': return '' + selector.value.value === '' + p;
- case 'type': return selector.value.value === typeof p;
- }
- case '!=':
- switch (selector.value.type) {
- case 'regexp': return !selector.value.value.test(p);
- case 'literal': return '' + selector.value.value !== '' + p;
- case 'type': return selector.value.value !== typeof p;
- }
- case '<=': return p <= selector.value.value;
- case '<': return p < selector.value.value;
- case '>': return p > selector.value.value;
- case '>=': return p >= selector.value.value;
- }
- case 'sibling':
- return matches(node, selector.right, ancestry) &&
- sibling(node, selector.left, ancestry) ||
- matches(node, selector.left, ancestry) &&
- sibling(node, selector.right, ancestry);
- case 'adjacent':
- return matches(node, selector.right, ancestry) &&
- adjacent(node, selector.left, ancestry) ||
- matches(node, selector.left, ancestry) &&
- adjacent(node, selector.right, ancestry);
- case 'nth-child':
- return matches(node, selector.right, ancestry) &&
- nthChild(node, ancestry, function (length) {
- return selector.index.value - 1;
- });
- case 'nth-last-child':
- return matches(node, selector.right, ancestry) &&
- nthChild(node, ancestry, function (length) {
- return length - selector.index.value;
- });
- case 'class':
- if(!node.type) return false;
- switch(selector.name.toLowerCase()){
- case 'statement':
- if(node.type.slice(-9) === 'Statement') return true;
- // fallthrough: interface Declaration <: Statement { }
- case 'declaration':
- return node.type.slice(-11) === 'Declaration';
- case 'pattern':
- if(node.type.slice(-7) === 'Pattern') return true;
- // fallthrough: interface Expression <: Node, Pattern { }
- case 'expression':
- return node.type.slice(-10) === 'Expression' ||
- node.type === 'Literal' ||
- node.type === 'Identifier';
- case 'function':
- return node.type.slice(0, 8) === 'Function' ||
- node.type === 'ArrowFunctionExpression';
- }
- throw new Error('Unknown class name: ' + selector.name);
- }
- throw new Error('Unknown selector type: ' + selector.type);
- }
- /*
- * Determines if the given node has a sibling that matches the given selector.
- */
- function sibling(node, selector, ancestry) {
- var parent = ancestry[0], listProp, keys, i, l, k, m;
- if (!parent) { return false; }
- keys = estraverse.VisitorKeys[parent.type];
- for (i = 0, l = keys.length; i < l; ++i) {
- listProp = parent[keys[i]];
- if (isArray(listProp)) {
- for (k = 0, m = listProp.length; k < m; ++k) {
- if (listProp[k] !== node && matches(listProp[k], selector, ancestry)) {
- return true;
- }
- }
- }
- }
- return false;
- }
- /*
- * Determines if the given node has an asjacent sibling that matches the given selector.
- */
- function adjacent(node, selector, ancestry) {
- var parent = ancestry[0], listProp, keys, i, l, idx;
- if (!parent) { return false; }
- keys = estraverse.VisitorKeys[parent.type];
- for (i = 0, l = keys.length; i < l; ++i) {
- listProp = parent[keys[i]];
- if (isArray(listProp)) {
- idx = listProp.indexOf(node);
- if (idx < 0) { continue; }
- if (idx > 0 && matches(listProp[idx - 1], selector, ancestry)) {
- return true;
- }
- if (idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) {
- return true;
- }
- }
- }
- return false;
- }
- /*
- * Determines if the given node is the nth child, determined by idxFn, which is given the containing list's length.
- */
- function nthChild(node, ancestry, idxFn) {
- var parent = ancestry[0], listProp, keys, i, l, idx;
- if (!parent) { return false; }
- keys = estraverse.VisitorKeys[parent.type];
- for (i = 0, l = keys.length; i < l; ++i) {
- listProp = parent[keys[i]];
- if (isArray(listProp)) {
- idx = listProp.indexOf(node);
- if (idx >= 0 && idx === idxFn(listProp.length)) { return true; }
- }
- }
- return false;
- }
- /*
- * For each selector node marked as a subject, find the portion of the selector that the subject must match.
- */
- function subjects(selector, ancestor) {
- var results, p;
- if (selector == null || typeof selector != 'object') { return []; }
- if (ancestor == null) { ancestor = selector; }
- results = selector.subject ? [ancestor] : [];
- for(p in selector) {
- if(!{}.hasOwnProperty.call(selector, p)) { continue; }
- [].push.apply(results, subjects(selector[p], p === 'left' ? selector[p] : ancestor));
- }
- return results;
- }
- /**
- * From a JS AST and a selector AST, collect all JS AST nodes that match the selector.
- */
- function match(ast, selector) {
- var ancestry = [], results = [], altSubjects, i, l, k, m;
- if (!selector) { return results; }
- altSubjects = subjects(selector);
- estraverse.traverse(ast, {
- enter: function (node, parent) {
- if (parent != null) { ancestry.unshift(parent); }
- if (matches(node, selector, ancestry)) {
- if (altSubjects.length) {
- for (i = 0, l = altSubjects.length; i < l; ++i) {
- if (matches(node, altSubjects[i], ancestry)) { results.push(node); }
- for (k = 0, m = ancestry.length; k < m; ++k) {
- if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) {
- results.push(ancestry[k]);
- }
- }
- }
- } else {
- results.push(node);
- }
- }
- },
- leave: function () { ancestry.shift(); }
- });
- return results;
- }
- /**
- * Parse a selector string and return its AST.
- */
- function parse(selector) {
- return parser.parse(selector);
- }
- /**
- * Query the code AST using the selector string.
- */
- function query(ast, selector) {
- return match(ast, parse(selector));
- }
- query.parse = parse;
- query.match = match;
- query.matches = matches;
- return query.query = query;
- }
- if (typeof define === "function" && define.amd) {
- define(esqueryModule);
- } else if (typeof module !== 'undefined' && module.exports) {
- module.exports = esqueryModule();
- } else {
- this.esquery = esqueryModule();
- }
- })();
- },{"./parser":308,"estraverse":309}],308:[function(require,module,exports){
- var result = (function(){
- /*
- * Generated by PEG.js 0.7.0.
- *
- * http://pegjs.majda.cz/
- */
-
- function quote(s) {
- /*
- * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
- * string literal except for the closing quote character, backslash,
- * carriage return, line separator, paragraph separator, and line feed.
- * Any character may appear in the form of an escape sequence.
- *
- * For portability, we also escape escape all control and non-ASCII
- * characters. Note that "\0" and "\v" escape sequences are not used
- * because JSHint does not like the first and IE the second.
- */
- return '"' + s
- .replace(/\\/g, '\\\\') // backslash
- .replace(/"/g, '\\"') // closing quote character
- .replace(/\x08/g, '\\b') // backspace
- .replace(/\t/g, '\\t') // horizontal tab
- .replace(/\n/g, '\\n') // line feed
- .replace(/\f/g, '\\f') // form feed
- .replace(/\r/g, '\\r') // carriage return
- .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape)
- + '"';
- }
-
- var result = {
- /*
- * Parses the input with a generated parser. If the parsing is successfull,
- * returns a value explicitly or implicitly specified by the grammar from
- * which the parser was generated (see |PEG.buildParser|). If the parsing is
- * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
- */
- parse: function(input, startRule) {
- var parseFunctions = {
- "start": parse_start,
- "_": parse__,
- "identifierName": parse_identifierName,
- "binaryOp": parse_binaryOp,
- "selectors": parse_selectors,
- "selector": parse_selector,
- "sequence": parse_sequence,
- "atom": parse_atom,
- "wildcard": parse_wildcard,
- "identifier": parse_identifier,
- "attr": parse_attr,
- "attrOps": parse_attrOps,
- "attrEqOps": parse_attrEqOps,
- "attrName": parse_attrName,
- "attrValue": parse_attrValue,
- "string": parse_string,
- "number": parse_number,
- "path": parse_path,
- "type": parse_type,
- "regex": parse_regex,
- "field": parse_field,
- "negation": parse_negation,
- "matches": parse_matches,
- "firstChild": parse_firstChild,
- "lastChild": parse_lastChild,
- "nthChild": parse_nthChild,
- "nthLastChild": parse_nthLastChild,
- "class": parse_class
- };
-
- if (startRule !== undefined) {
- if (parseFunctions[startRule] === undefined) {
- throw new Error("Invalid rule name: " + quote(startRule) + ".");
- }
- } else {
- startRule = "start";
- }
-
- var pos = 0;
- var reportFailures = 0;
- var rightmostFailuresPos = 0;
- var rightmostFailuresExpected = [];
- var cache = {};
-
- function padLeft(input, padding, length) {
- var result = input;
-
- var padLength = length - input.length;
- for (var i = 0; i < padLength; i++) {
- result = padding + result;
- }
-
- return result;
- }
-
- function escape(ch) {
- var charCode = ch.charCodeAt(0);
- var escapeChar;
- var length;
-
- if (charCode <= 0xFF) {
- escapeChar = 'x';
- length = 2;
- } else {
- escapeChar = 'u';
- length = 4;
- }
-
- return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
- }
-
- function matchFailed(failure) {
- if (pos < rightmostFailuresPos) {
- return;
- }
-
- if (pos > rightmostFailuresPos) {
- rightmostFailuresPos = pos;
- rightmostFailuresExpected = [];
- }
-
- rightmostFailuresExpected.push(failure);
- }
-
- function parse_start() {
- var cacheKey = "start@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- result1 = parse_selectors();
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, ss) { return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss }; })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- result0 = parse__();
- if (result0 !== null) {
- result0 = (function(offset) { return void 0; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse__() {
- var cacheKey = "_@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
-
- result0 = [];
- if (input.charCodeAt(pos) === 32) {
- result1 = " ";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\" \"");
- }
- }
- while (result1 !== null) {
- result0.push(result1);
- if (input.charCodeAt(pos) === 32) {
- result1 = " ";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\" \"");
- }
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_identifierName() {
- var cacheKey = "identifierName@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0;
-
- pos0 = pos;
- if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[^ [\\],():#!=><~+.]");
- }
- }
- if (result1 !== null) {
- result0 = [];
- while (result1 !== null) {
- result0.push(result1);
- if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[^ [\\],():#!=><~+.]");
- }
- }
- }
- } else {
- result0 = null;
- }
- if (result0 !== null) {
- result0 = (function(offset, i) { return i.join(''); })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_binaryOp() {
- var cacheKey = "binaryOp@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 62) {
- result1 = ">";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\">\"");
- }
- }
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'child'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 126) {
- result1 = "~";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"~\"");
- }
- }
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'sibling'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 43) {
- result1 = "+";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"+\"");
- }
- }
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'adjacent'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 32) {
- result0 = " ";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\" \"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'descendant'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- }
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_selectors() {
- var cacheKey = "selectors@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4, result5;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse_selector();
- if (result0 !== null) {
- result1 = [];
- pos2 = pos;
- result2 = parse__();
- if (result2 !== null) {
- if (input.charCodeAt(pos) === 44) {
- result3 = ",";
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\",\"");
- }
- }
- if (result3 !== null) {
- result4 = parse__();
- if (result4 !== null) {
- result5 = parse_selector();
- if (result5 !== null) {
- result2 = [result2, result3, result4, result5];
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- while (result2 !== null) {
- result1.push(result2);
- pos2 = pos;
- result2 = parse__();
- if (result2 !== null) {
- if (input.charCodeAt(pos) === 44) {
- result3 = ",";
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\",\"");
- }
- }
- if (result3 !== null) {
- result4 = parse__();
- if (result4 !== null) {
- result5 = parse_selector();
- if (result5 !== null) {
- result2 = [result2, result3, result4, result5];
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, s, ss) {
- return [s].concat(ss.map(function (s) { return s[3]; }));
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_selector() {
- var cacheKey = "selector@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse_sequence();
- if (result0 !== null) {
- result1 = [];
- pos2 = pos;
- result2 = parse_binaryOp();
- if (result2 !== null) {
- result3 = parse_sequence();
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- while (result2 !== null) {
- result1.push(result2);
- pos2 = pos;
- result2 = parse_binaryOp();
- if (result2 !== null) {
- result3 = parse_sequence();
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos2;
- }
- } else {
- result2 = null;
- pos = pos2;
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, a, ops) {
- return ops.reduce(function (memo, rhs) {
- return { type: rhs[0], left: memo, right: rhs[1] };
- }, a);
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_sequence() {
- var cacheKey = "sequence@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 33) {
- result0 = "!";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"!\"");
- }
- }
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- result2 = parse_atom();
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- result2 = parse_atom();
- }
- } else {
- result1 = null;
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, subject, as) {
- var b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
- if(subject) b.subject = true;
- return b;
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_atom() {
- var cacheKey = "atom@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
-
- result0 = parse_wildcard();
- if (result0 === null) {
- result0 = parse_identifier();
- if (result0 === null) {
- result0 = parse_attr();
- if (result0 === null) {
- result0 = parse_field();
- if (result0 === null) {
- result0 = parse_negation();
- if (result0 === null) {
- result0 = parse_matches();
- if (result0 === null) {
- result0 = parse_firstChild();
- if (result0 === null) {
- result0 = parse_lastChild();
- if (result0 === null) {
- result0 = parse_nthChild();
- if (result0 === null) {
- result0 = parse_nthLastChild();
- if (result0 === null) {
- result0 = parse_class();
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_wildcard() {
- var cacheKey = "wildcard@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- if (input.charCodeAt(pos) === 42) {
- result0 = "*";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"*\"");
- }
- }
- if (result0 !== null) {
- result0 = (function(offset, a) { return { type: 'wildcard', value: a }; })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_identifier() {
- var cacheKey = "identifier@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 35) {
- result0 = "#";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"#\"");
- }
- }
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- result1 = parse_identifierName();
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, i) { return { type: 'identifier', value: i }; })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attr() {
- var cacheKey = "attr@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 91) {
- result0 = "[";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"[\"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_attrValue();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 93) {
- result4 = "]";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\"]\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, v) { return v; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrOps() {
- var cacheKey = "attrOps@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (/^[><!]/.test(input.charAt(pos))) {
- result0 = input.charAt(pos);
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("[><!]");
- }
- }
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 61) {
- result1 = "=";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"=\"");
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, a) { return a + '='; })(pos0, result0[0]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- if (/^[><]/.test(input.charAt(pos))) {
- result0 = input.charAt(pos);
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("[><]");
- }
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrEqOps() {
- var cacheKey = "attrEqOps@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 33) {
- result0 = "!";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"!\"");
- }
- }
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 61) {
- result1 = "=";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"=\"");
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, a) { return a + '='; })(pos0, result0[0]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrName() {
- var cacheKey = "attrName@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0;
-
- pos0 = pos;
- result1 = parse_identifierName();
- if (result1 === null) {
- if (input.charCodeAt(pos) === 46) {
- result1 = ".";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
- }
- }
- if (result1 !== null) {
- result0 = [];
- while (result1 !== null) {
- result0.push(result1);
- result1 = parse_identifierName();
- if (result1 === null) {
- if (input.charCodeAt(pos) === 46) {
- result1 = ".";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
- }
- }
- }
- } else {
- result0 = null;
- }
- if (result0 !== null) {
- result0 = (function(offset, i) { return i.join(''); })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrValue() {
- var cacheKey = "attrValue@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse_attrName();
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_attrEqOps();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- result4 = parse_type();
- if (result4 === null) {
- result4 = parse_regex();
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, name, op, value) {
- return { type: 'attribute', name: name, operator: op, value: value };
- })(pos0, result0[0], result0[2], result0[4]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- result0 = parse_attrName();
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_attrOps();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- result4 = parse_string();
- if (result4 === null) {
- result4 = parse_number();
- if (result4 === null) {
- result4 = parse_path();
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, name, op, value) {
- return { type: 'attribute', name: name, operator: op, value: value };
- })(pos0, result0[0], result0[2], result0[4]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- result0 = parse_attrName();
- if (result0 !== null) {
- result0 = (function(offset, name) { return { type: 'attribute', name: name }; })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_string() {
- var cacheKey = "string@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3;
- var pos0, pos1, pos2, pos3;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 34) {
- result0 = "\"";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\"\"");
- }
- }
- if (result0 !== null) {
- result1 = [];
- if (/^[^\\"]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\\"]");
- }
- }
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
- }
- while (result2 !== null) {
- result1.push(result2);
- if (/^[^\\"]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\\"]");
- }
- }
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
- }
- }
- if (result1 !== null) {
- if (input.charCodeAt(pos) === 34) {
- result2 = "\"";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\"\"");
- }
- }
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, d) {
- return { type: 'literal', value: strUnescape(d.join('')) };
- })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 39) {
- result0 = "'";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"'\"");
- }
- }
- if (result0 !== null) {
- result1 = [];
- if (/^[^\\']/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\']");
- }
- }
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
- }
- while (result2 !== null) {
- result1.push(result2);
- if (/^[^\\']/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\']");
- }
- }
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
- }
- }
- if (result1 !== null) {
- if (input.charCodeAt(pos) === 39) {
- result2 = "'";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"'\"");
- }
- }
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, d) {
- return { type: 'literal', value: strUnescape(d.join('')) };
- })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_number() {
- var cacheKey = "number@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- pos2 = pos;
- result0 = [];
- if (/^[0-9]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- while (result1 !== null) {
- result0.push(result1);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- }
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 46) {
- result1 = ".";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos2;
- }
- } else {
- result0 = null;
- pos = pos2;
- }
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- if (/^[0-9]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- }
- } else {
- result1 = null;
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, a, b) {
- return { type: 'literal', value: parseFloat((a ? a.join('') : '') + b.join('')) };
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_path() {
- var cacheKey = "path@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- result0 = parse_identifierName();
- if (result0 !== null) {
- result0 = (function(offset, i) { return { type: 'literal', value: i }; })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_type() {
- var cacheKey = "type@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.substr(pos, 5) === "type(") {
- result0 = "type(";
- pos += 5;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"type(\"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- if (/^[^ )]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[^ )]");
- }
- }
- if (result3 !== null) {
- result2 = [];
- while (result3 !== null) {
- result2.push(result3);
- if (/^[^ )]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[^ )]");
- }
- }
- }
- } else {
- result2 = null;
- }
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, t) { return { type: 'type', value: t.join('') }; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_regex() {
- var cacheKey = "regex@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 47) {
- result0 = "/";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"/\"");
- }
- }
- if (result0 !== null) {
- if (/^[^\/]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\/]");
- }
- }
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- if (/^[^\/]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\/]");
- }
- }
- }
- } else {
- result1 = null;
- }
- if (result1 !== null) {
- if (input.charCodeAt(pos) === 47) {
- result2 = "/";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"/\"");
- }
- }
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, d) { return { type: 'regexp', value: new RegExp(d.join('')) }; })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_field() {
- var cacheKey = "field@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 46) {
- result0 = ".";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
- }
- if (result0 !== null) {
- result1 = parse_identifierName();
- if (result1 !== null) {
- result2 = [];
- pos2 = pos;
- if (input.charCodeAt(pos) === 46) {
- result3 = ".";
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
- }
- if (result3 !== null) {
- result4 = parse_identifierName();
- if (result4 !== null) {
- result3 = [result3, result4];
- } else {
- result3 = null;
- pos = pos2;
- }
- } else {
- result3 = null;
- pos = pos2;
- }
- while (result3 !== null) {
- result2.push(result3);
- pos2 = pos;
- if (input.charCodeAt(pos) === 46) {
- result3 = ".";
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
- }
- if (result3 !== null) {
- result4 = parse_identifierName();
- if (result4 !== null) {
- result3 = [result3, result4];
- } else {
- result3 = null;
- pos = pos2;
- }
- } else {
- result3 = null;
- pos = pos2;
- }
- }
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, i, is) {
- return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
- })(pos0, result0[1], result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_negation() {
- var cacheKey = "negation@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.substr(pos, 5) === ":not(") {
- result0 = ":not(";
- pos += 5;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":not(\"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_selectors();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, ss) { return { type: 'not', selectors: ss }; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_matches() {
- var cacheKey = "matches@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.substr(pos, 9) === ":matches(") {
- result0 = ":matches(";
- pos += 9;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":matches(\"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_selectors();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, ss) { return { type: 'matches', selectors: ss }; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_firstChild() {
- var cacheKey = "firstChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- if (input.substr(pos, 12) === ":first-child") {
- result0 = ":first-child";
- pos += 12;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":first-child\"");
- }
- }
- if (result0 !== null) {
- result0 = (function(offset) { return nth(1); })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_lastChild() {
- var cacheKey = "lastChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- if (input.substr(pos, 11) === ":last-child") {
- result0 = ":last-child";
- pos += 11;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":last-child\"");
- }
- }
- if (result0 !== null) {
- result0 = (function(offset) { return nthLast(1); })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_nthChild() {
- var cacheKey = "nthChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.substr(pos, 11) === ":nth-child(") {
- result0 = ":nth-child(";
- pos += 11;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":nth-child(\"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- if (result3 !== null) {
- result2 = [];
- while (result3 !== null) {
- result2.push(result3);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- }
- } else {
- result2 = null;
- }
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, n) { return nth(parseInt(n.join(''), 10)); })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_nthLastChild() {
- var cacheKey = "nthLastChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.substr(pos, 16) === ":nth-last-child(") {
- result0 = ":nth-last-child(";
- pos += 16;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":nth-last-child(\"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- if (result3 !== null) {
- result2 = [];
- while (result3 !== null) {
- result2.push(result3);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- }
- } else {
- result2 = null;
- }
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, n) { return nthLast(parseInt(n.join(''), 10)); })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_class() {
- var cacheKey = "class@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 58) {
- result0 = ":";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":\"");
- }
- }
- if (result0 !== null) {
- if (input.substr(pos, 9).toLowerCase() === "statement") {
- result1 = input.substr(pos, 9);
- pos += 9;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"statement\"");
- }
- }
- if (result1 === null) {
- if (input.substr(pos, 10).toLowerCase() === "expression") {
- result1 = input.substr(pos, 10);
- pos += 10;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"expression\"");
- }
- }
- if (result1 === null) {
- if (input.substr(pos, 11).toLowerCase() === "declaration") {
- result1 = input.substr(pos, 11);
- pos += 11;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"declaration\"");
- }
- }
- if (result1 === null) {
- if (input.substr(pos, 8).toLowerCase() === "function") {
- result1 = input.substr(pos, 8);
- pos += 8;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"function\"");
- }
- }
- if (result1 === null) {
- if (input.substr(pos, 7).toLowerCase() === "pattern") {
- result1 = input.substr(pos, 7);
- pos += 7;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"pattern\"");
- }
- }
- }
- }
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, c) {
- return { type: 'class', name: c };
- })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
-
- function cleanupExpected(expected) {
- expected.sort();
-
- var lastExpected = null;
- var cleanExpected = [];
- for (var i = 0; i < expected.length; i++) {
- if (expected[i] !== lastExpected) {
- cleanExpected.push(expected[i]);
- lastExpected = expected[i];
- }
- }
- return cleanExpected;
- }
-
- function computeErrorPosition() {
- /*
- * The first idea was to use |String.split| to break the input up to the
- * error position along newlines and derive the line and column from
- * there. However IE's |split| implementation is so broken that it was
- * enough to prevent it.
- */
-
- var line = 1;
- var column = 1;
- var seenCR = false;
-
- for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {
- var ch = input.charAt(i);
- if (ch === "\n") {
- if (!seenCR) { line++; }
- column = 1;
- seenCR = false;
- } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
- line++;
- column = 1;
- seenCR = true;
- } else {
- column++;
- seenCR = false;
- }
- }
-
- return { line: line, column: column };
- }
-
-
- function nth(n) { return { type: 'nth-child', index: { type: 'literal', value: n } }; }
- function nthLast(n) { return { type: 'nth-last-child', index: { type: 'literal', value: n } }; }
- function strUnescape(s) {
- return s.replace(/\\(.)/g, function(match, ch) {
- switch(ch) {
- case 'a': return '\a';
- case 'b': return '\b';
- case 'f': return '\f';
- case 'n': return '\n';
- case 'r': return '\r';
- case 't': return '\t';
- case 'v': return '\v';
- default: return ch;
- }
- });
- }
-
-
- var result = parseFunctions[startRule]();
-
- /*
- * The parser is now in one of the following three states:
- *
- * 1. The parser successfully parsed the whole input.
- *
- * - |result !== null|
- * - |pos === input.length|
- * - |rightmostFailuresExpected| may or may not contain something
- *
- * 2. The parser successfully parsed only a part of the input.
- *
- * - |result !== null|
- * - |pos < input.length|
- * - |rightmostFailuresExpected| may or may not contain something
- *
- * 3. The parser did not successfully parse any part of the input.
- *
- * - |result === null|
- * - |pos === 0|
- * - |rightmostFailuresExpected| contains at least one failure
- *
- * All code following this comment (including called functions) must
- * handle these states.
- */
- if (result === null || pos !== input.length) {
- var offset = Math.max(pos, rightmostFailuresPos);
- var found = offset < input.length ? input.charAt(offset) : null;
- var errorPosition = computeErrorPosition();
-
- throw new this.SyntaxError(
- cleanupExpected(rightmostFailuresExpected),
- found,
- offset,
- errorPosition.line,
- errorPosition.column
- );
- }
-
- return result;
- },
-
- /* Returns the parser source code. */
- toSource: function() { return this._source; }
- };
-
- /* Thrown when a parser encounters a syntax error. */
-
- result.SyntaxError = function(expected, found, offset, line, column) {
- function buildMessage(expected, found) {
- var expectedHumanized, foundHumanized;
-
- switch (expected.length) {
- case 0:
- expectedHumanized = "end of input";
- break;
- case 1:
- expectedHumanized = expected[0];
- break;
- default:
- expectedHumanized = expected.slice(0, expected.length - 1).join(", ")
- + " or "
- + expected[expected.length - 1];
- }
-
- foundHumanized = found ? quote(found) : "end of input";
-
- return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
- }
-
- this.name = "SyntaxError";
- this.expected = expected;
- this.found = found;
- this.message = buildMessage(expected, found);
- this.offset = offset;
- this.line = line;
- this.column = column;
- };
-
- result.SyntaxError.prototype = Error.prototype;
-
- return result;
- })();
- if (typeof define === "function" && define.amd) { define(function(){ return result; }); } else if (typeof module !== "undefined" && module.exports) { module.exports = result; } else { this.esquery = result; }
- },{}],309:[function(require,module,exports){
- /*
- Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- /*jslint vars:false, bitwise:true*/
- /*jshint indent:4*/
- /*global exports:true*/
- (function clone(exports) {
- 'use strict';
- var Syntax,
- isArray,
- VisitorOption,
- VisitorKeys,
- objectCreate,
- objectKeys,
- BREAK,
- SKIP,
- REMOVE;
- function ignoreJSHintError() { }
- isArray = Array.isArray;
- if (!isArray) {
- isArray = function isArray(array) {
- return Object.prototype.toString.call(array) === '[object Array]';
- };
- }
- function deepCopy(obj) {
- var ret = {}, key, val;
- for (key in obj) {
- if (obj.hasOwnProperty(key)) {
- val = obj[key];
- if (typeof val === 'object' && val !== null) {
- ret[key] = deepCopy(val);
- } else {
- ret[key] = val;
- }
- }
- }
- return ret;
- }
- function shallowCopy(obj) {
- var ret = {}, key;
- for (key in obj) {
- if (obj.hasOwnProperty(key)) {
- ret[key] = obj[key];
- }
- }
- return ret;
- }
- ignoreJSHintError(shallowCopy);
- // based on LLVM libc++ upper_bound / lower_bound
- // MIT License
- function upperBound(array, func) {
- var diff, len, i, current;
- len = array.length;
- i = 0;
- while (len) {
- diff = len >>> 1;
- current = i + diff;
- if (func(array[current])) {
- len = diff;
- } else {
- i = current + 1;
- len -= diff + 1;
- }
- }
- return i;
- }
- function lowerBound(array, func) {
- var diff, len, i, current;
- len = array.length;
- i = 0;
- while (len) {
- diff = len >>> 1;
- current = i + diff;
- if (func(array[current])) {
- i = current + 1;
- len -= diff + 1;
- } else {
- len = diff;
- }
- }
- return i;
- }
- ignoreJSHintError(lowerBound);
- objectCreate = Object.create || (function () {
- function F() { }
- return function (o) {
- F.prototype = o;
- return new F();
- };
- })();
- objectKeys = Object.keys || function (o) {
- var keys = [], key;
- for (key in o) {
- keys.push(key);
- }
- return keys;
- };
- function extend(to, from) {
- var keys = objectKeys(from), key, i, len;
- for (i = 0, len = keys.length; i < len; i += 1) {
- key = keys[i];
- to[key] = from[key];
- }
- return to;
- }
- Syntax = {
- AssignmentExpression: 'AssignmentExpression',
- AssignmentPattern: 'AssignmentPattern',
- ArrayExpression: 'ArrayExpression',
- ArrayPattern: 'ArrayPattern',
- ArrowFunctionExpression: 'ArrowFunctionExpression',
- AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
- BlockStatement: 'BlockStatement',
- BinaryExpression: 'BinaryExpression',
- BreakStatement: 'BreakStatement',
- CallExpression: 'CallExpression',
- CatchClause: 'CatchClause',
- ClassBody: 'ClassBody',
- ClassDeclaration: 'ClassDeclaration',
- ClassExpression: 'ClassExpression',
- ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
- ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
- ConditionalExpression: 'ConditionalExpression',
- ContinueStatement: 'ContinueStatement',
- DebuggerStatement: 'DebuggerStatement',
- DirectiveStatement: 'DirectiveStatement',
- DoWhileStatement: 'DoWhileStatement',
- EmptyStatement: 'EmptyStatement',
- ExportAllDeclaration: 'ExportAllDeclaration',
- ExportDefaultDeclaration: 'ExportDefaultDeclaration',
- ExportNamedDeclaration: 'ExportNamedDeclaration',
- ExportSpecifier: 'ExportSpecifier',
- ExpressionStatement: 'ExpressionStatement',
- ForStatement: 'ForStatement',
- ForInStatement: 'ForInStatement',
- ForOfStatement: 'ForOfStatement',
- FunctionDeclaration: 'FunctionDeclaration',
- FunctionExpression: 'FunctionExpression',
- GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
- Identifier: 'Identifier',
- IfStatement: 'IfStatement',
- ImportDeclaration: 'ImportDeclaration',
- ImportDefaultSpecifier: 'ImportDefaultSpecifier',
- ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
- ImportSpecifier: 'ImportSpecifier',
- Literal: 'Literal',
- LabeledStatement: 'LabeledStatement',
- LogicalExpression: 'LogicalExpression',
- MemberExpression: 'MemberExpression',
- MetaProperty: 'MetaProperty',
- MethodDefinition: 'MethodDefinition',
- ModuleSpecifier: 'ModuleSpecifier',
- NewExpression: 'NewExpression',
- ObjectExpression: 'ObjectExpression',
- ObjectPattern: 'ObjectPattern',
- Program: 'Program',
- Property: 'Property',
- RestElement: 'RestElement',
- ReturnStatement: 'ReturnStatement',
- SequenceExpression: 'SequenceExpression',
- SpreadElement: 'SpreadElement',
- Super: 'Super',
- SwitchStatement: 'SwitchStatement',
- SwitchCase: 'SwitchCase',
- TaggedTemplateExpression: 'TaggedTemplateExpression',
- TemplateElement: 'TemplateElement',
- TemplateLiteral: 'TemplateLiteral',
- ThisExpression: 'ThisExpression',
- ThrowStatement: 'ThrowStatement',
- TryStatement: 'TryStatement',
- UnaryExpression: 'UnaryExpression',
- UpdateExpression: 'UpdateExpression',
- VariableDeclaration: 'VariableDeclaration',
- VariableDeclarator: 'VariableDeclarator',
- WhileStatement: 'WhileStatement',
- WithStatement: 'WithStatement',
- YieldExpression: 'YieldExpression'
- };
- VisitorKeys = {
- AssignmentExpression: ['left', 'right'],
- AssignmentPattern: ['left', 'right'],
- ArrayExpression: ['elements'],
- ArrayPattern: ['elements'],
- ArrowFunctionExpression: ['params', 'body'],
- AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
- BlockStatement: ['body'],
- BinaryExpression: ['left', 'right'],
- BreakStatement: ['label'],
- CallExpression: ['callee', 'arguments'],
- CatchClause: ['param', 'body'],
- ClassBody: ['body'],
- ClassDeclaration: ['id', 'superClass', 'body'],
- ClassExpression: ['id', 'superClass', 'body'],
- ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
- ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
- ConditionalExpression: ['test', 'consequent', 'alternate'],
- ContinueStatement: ['label'],
- DebuggerStatement: [],
- DirectiveStatement: [],
- DoWhileStatement: ['body', 'test'],
- EmptyStatement: [],
- ExportAllDeclaration: ['source'],
- ExportDefaultDeclaration: ['declaration'],
- ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
- ExportSpecifier: ['exported', 'local'],
- ExpressionStatement: ['expression'],
- ForStatement: ['init', 'test', 'update', 'body'],
- ForInStatement: ['left', 'right', 'body'],
- ForOfStatement: ['left', 'right', 'body'],
- FunctionDeclaration: ['id', 'params', 'body'],
- FunctionExpression: ['id', 'params', 'body'],
- GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
- Identifier: [],
- IfStatement: ['test', 'consequent', 'alternate'],
- ImportDeclaration: ['specifiers', 'source'],
- ImportDefaultSpecifier: ['local'],
- ImportNamespaceSpecifier: ['local'],
- ImportSpecifier: ['imported', 'local'],
- Literal: [],
- LabeledStatement: ['label', 'body'],
- LogicalExpression: ['left', 'right'],
- MemberExpression: ['object', 'property'],
- MetaProperty: ['meta', 'property'],
- MethodDefinition: ['key', 'value'],
- ModuleSpecifier: [],
- NewExpression: ['callee', 'arguments'],
- ObjectExpression: ['properties'],
- ObjectPattern: ['properties'],
- Program: ['body'],
- Property: ['key', 'value'],
- RestElement: [ 'argument' ],
- ReturnStatement: ['argument'],
- SequenceExpression: ['expressions'],
- SpreadElement: ['argument'],
- Super: [],
- SwitchStatement: ['discriminant', 'cases'],
- SwitchCase: ['test', 'consequent'],
- TaggedTemplateExpression: ['tag', 'quasi'],
- TemplateElement: [],
- TemplateLiteral: ['quasis', 'expressions'],
- ThisExpression: [],
- ThrowStatement: ['argument'],
- TryStatement: ['block', 'handler', 'finalizer'],
- UnaryExpression: ['argument'],
- UpdateExpression: ['argument'],
- VariableDeclaration: ['declarations'],
- VariableDeclarator: ['id', 'init'],
- WhileStatement: ['test', 'body'],
- WithStatement: ['object', 'body'],
- YieldExpression: ['argument']
- };
- // unique id
- BREAK = {};
- SKIP = {};
- REMOVE = {};
- VisitorOption = {
- Break: BREAK,
- Skip: SKIP,
- Remove: REMOVE
- };
- function Reference(parent, key) {
- this.parent = parent;
- this.key = key;
- }
- Reference.prototype.replace = function replace(node) {
- this.parent[this.key] = node;
- };
- Reference.prototype.remove = function remove() {
- if (isArray(this.parent)) {
- this.parent.splice(this.key, 1);
- return true;
- } else {
- this.replace(null);
- return false;
- }
- };
- function Element(node, path, wrap, ref) {
- this.node = node;
- this.path = path;
- this.wrap = wrap;
- this.ref = ref;
- }
- function Controller() { }
- // API:
- // return property path array from root to current node
- Controller.prototype.path = function path() {
- var i, iz, j, jz, result, element;
- function addToPath(result, path) {
- if (isArray(path)) {
- for (j = 0, jz = path.length; j < jz; ++j) {
- result.push(path[j]);
- }
- } else {
- result.push(path);
- }
- }
- // root node
- if (!this.__current.path) {
- return null;
- }
- // first node is sentinel, second node is root element
- result = [];
- for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
- element = this.__leavelist[i];
- addToPath(result, element.path);
- }
- addToPath(result, this.__current.path);
- return result;
- };
- // API:
- // return type of current node
- Controller.prototype.type = function () {
- var node = this.current();
- return node.type || this.__current.wrap;
- };
- // API:
- // return array of parent elements
- Controller.prototype.parents = function parents() {
- var i, iz, result;
- // first node is sentinel
- result = [];
- for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
- result.push(this.__leavelist[i].node);
- }
- return result;
- };
- // API:
- // return current node
- Controller.prototype.current = function current() {
- return this.__current.node;
- };
- Controller.prototype.__execute = function __execute(callback, element) {
- var previous, result;
- result = undefined;
- previous = this.__current;
- this.__current = element;
- this.__state = null;
- if (callback) {
- result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
- }
- this.__current = previous;
- return result;
- };
- // API:
- // notify control skip / break
- Controller.prototype.notify = function notify(flag) {
- this.__state = flag;
- };
- // API:
- // skip child nodes of current node
- Controller.prototype.skip = function () {
- this.notify(SKIP);
- };
- // API:
- // break traversals
- Controller.prototype['break'] = function () {
- this.notify(BREAK);
- };
- // API:
- // remove node
- Controller.prototype.remove = function () {
- this.notify(REMOVE);
- };
- Controller.prototype.__initialize = function(root, visitor) {
- this.visitor = visitor;
- this.root = root;
- this.__worklist = [];
- this.__leavelist = [];
- this.__current = null;
- this.__state = null;
- this.__fallback = visitor.fallback === 'iteration';
- this.__keys = VisitorKeys;
- if (visitor.keys) {
- this.__keys = extend(objectCreate(this.__keys), visitor.keys);
- }
- };
- function isNode(node) {
- if (node == null) {
- return false;
- }
- return typeof node === 'object' && typeof node.type === 'string';
- }
- function isProperty(nodeType, key) {
- return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
- }
- Controller.prototype.traverse = function traverse(root, visitor) {
- var worklist,
- leavelist,
- element,
- node,
- nodeType,
- ret,
- key,
- current,
- current2,
- candidates,
- candidate,
- sentinel;
- this.__initialize(root, visitor);
- sentinel = {};
- // reference
- worklist = this.__worklist;
- leavelist = this.__leavelist;
- // initialize
- worklist.push(new Element(root, null, null, null));
- leavelist.push(new Element(null, null, null, null));
- while (worklist.length) {
- element = worklist.pop();
- if (element === sentinel) {
- element = leavelist.pop();
- ret = this.__execute(visitor.leave, element);
- if (this.__state === BREAK || ret === BREAK) {
- return;
- }
- continue;
- }
- if (element.node) {
- ret = this.__execute(visitor.enter, element);
- if (this.__state === BREAK || ret === BREAK) {
- return;
- }
- worklist.push(sentinel);
- leavelist.push(element);
- if (this.__state === SKIP || ret === SKIP) {
- continue;
- }
- node = element.node;
- nodeType = element.wrap || node.type;
- candidates = this.__keys[nodeType];
- if (!candidates) {
- if (this.__fallback) {
- candidates = objectKeys(node);
- } else {
- throw new Error('Unknown node type ' + nodeType + '.');
- }
- }
- current = candidates.length;
- while ((current -= 1) >= 0) {
- key = candidates[current];
- candidate = node[key];
- if (!candidate) {
- continue;
- }
- if (isArray(candidate)) {
- current2 = candidate.length;
- while ((current2 -= 1) >= 0) {
- if (!candidate[current2]) {
- continue;
- }
- if (isProperty(nodeType, candidates[current])) {
- element = new Element(candidate[current2], [key, current2], 'Property', null);
- } else if (isNode(candidate[current2])) {
- element = new Element(candidate[current2], [key, current2], null, null);
- } else {
- continue;
- }
- worklist.push(element);
- }
- } else if (isNode(candidate)) {
- worklist.push(new Element(candidate, key, null, null));
- }
- }
- }
- }
- };
- Controller.prototype.replace = function replace(root, visitor) {
- function removeElem(element) {
- var i,
- key,
- nextElem,
- parent;
- if (element.ref.remove()) {
- // When the reference is an element of an array.
- key = element.ref.key;
- parent = element.ref.parent;
- // If removed from array, then decrease following items' keys.
- i = worklist.length;
- while (i--) {
- nextElem = worklist[i];
- if (nextElem.ref && nextElem.ref.parent === parent) {
- if (nextElem.ref.key < key) {
- break;
- }
- --nextElem.ref.key;
- }
- }
- }
- }
- var worklist,
- leavelist,
- node,
- nodeType,
- target,
- element,
- current,
- current2,
- candidates,
- candidate,
- sentinel,
- outer,
- key;
- this.__initialize(root, visitor);
- sentinel = {};
- // reference
- worklist = this.__worklist;
- leavelist = this.__leavelist;
- // initialize
- outer = {
- root: root
- };
- element = new Element(root, null, null, new Reference(outer, 'root'));
- worklist.push(element);
- leavelist.push(element);
- while (worklist.length) {
- element = worklist.pop();
- if (element === sentinel) {
- element = leavelist.pop();
- target = this.__execute(visitor.leave, element);
- // node may be replaced with null,
- // so distinguish between undefined and null in this place
- if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
- // replace
- element.ref.replace(target);
- }
- if (this.__state === REMOVE || target === REMOVE) {
- removeElem(element);
- }
- if (this.__state === BREAK || target === BREAK) {
- return outer.root;
- }
- continue;
- }
- target = this.__execute(visitor.enter, element);
- // node may be replaced with null,
- // so distinguish between undefined and null in this place
- if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
- // replace
- element.ref.replace(target);
- element.node = target;
- }
- if (this.__state === REMOVE || target === REMOVE) {
- removeElem(element);
- element.node = null;
- }
- if (this.__state === BREAK || target === BREAK) {
- return outer.root;
- }
- // node may be null
- node = element.node;
- if (!node) {
- continue;
- }
- worklist.push(sentinel);
- leavelist.push(element);
- if (this.__state === SKIP || target === SKIP) {
- continue;
- }
- nodeType = element.wrap || node.type;
- candidates = this.__keys[nodeType];
- if (!candidates) {
- if (this.__fallback) {
- candidates = objectKeys(node);
- } else {
- throw new Error('Unknown node type ' + nodeType + '.');
- }
- }
- current = candidates.length;
- while ((current -= 1) >= 0) {
- key = candidates[current];
- candidate = node[key];
- if (!candidate) {
- continue;
- }
- if (isArray(candidate)) {
- current2 = candidate.length;
- while ((current2 -= 1) >= 0) {
- if (!candidate[current2]) {
- continue;
- }
- if (isProperty(nodeType, candidates[current])) {
- element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
- } else if (isNode(candidate[current2])) {
- element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
- } else {
- continue;
- }
- worklist.push(element);
- }
- } else if (isNode(candidate)) {
- worklist.push(new Element(candidate, key, null, new Reference(node, key)));
- }
- }
- }
- return outer.root;
- };
- function traverse(root, visitor) {
- var controller = new Controller();
- return controller.traverse(root, visitor);
- }
- function replace(root, visitor) {
- var controller = new Controller();
- return controller.replace(root, visitor);
- }
- function extendCommentRange(comment, tokens) {
- var target;
- target = upperBound(tokens, function search(token) {
- return token.range[0] > comment.range[0];
- });
- comment.extendedRange = [comment.range[0], comment.range[1]];
- if (target !== tokens.length) {
- comment.extendedRange[1] = tokens[target].range[0];
- }
- target -= 1;
- if (target >= 0) {
- comment.extendedRange[0] = tokens[target].range[1];
- }
- return comment;
- }
- function attachComments(tree, providedComments, tokens) {
- // At first, we should calculate extended comment ranges.
- var comments = [], comment, len, i, cursor;
- if (!tree.range) {
- throw new Error('attachComments needs range information');
- }
- // tokens array is empty, we attach comments to tree as 'leadingComments'
- if (!tokens.length) {
- if (providedComments.length) {
- for (i = 0, len = providedComments.length; i < len; i += 1) {
- comment = deepCopy(providedComments[i]);
- comment.extendedRange = [0, tree.range[0]];
- comments.push(comment);
- }
- tree.leadingComments = comments;
- }
- return tree;
- }
- for (i = 0, len = providedComments.length; i < len; i += 1) {
- comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
- }
- // This is based on John Freeman's implementation.
- cursor = 0;
- traverse(tree, {
- enter: function (node) {
- var comment;
- while (cursor < comments.length) {
- comment = comments[cursor];
- if (comment.extendedRange[1] > node.range[0]) {
- break;
- }
- if (comment.extendedRange[1] === node.range[0]) {
- if (!node.leadingComments) {
- node.leadingComments = [];
- }
- node.leadingComments.push(comment);
- comments.splice(cursor, 1);
- } else {
- cursor += 1;
- }
- }
- // already out of owned node
- if (cursor === comments.length) {
- return VisitorOption.Break;
- }
- if (comments[cursor].extendedRange[0] > node.range[1]) {
- return VisitorOption.Skip;
- }
- }
- });
- cursor = 0;
- traverse(tree, {
- leave: function (node) {
- var comment;
- while (cursor < comments.length) {
- comment = comments[cursor];
- if (node.range[1] < comment.extendedRange[0]) {
- break;
- }
- if (node.range[1] === comment.extendedRange[0]) {
- if (!node.trailingComments) {
- node.trailingComments = [];
- }
- node.trailingComments.push(comment);
- comments.splice(cursor, 1);
- } else {
- cursor += 1;
- }
- }
- // already out of owned node
- if (cursor === comments.length) {
- return VisitorOption.Break;
- }
- if (comments[cursor].extendedRange[0] > node.range[1]) {
- return VisitorOption.Skip;
- }
- }
- });
- return tree;
- }
- exports.version = require('./package.json').version;
- exports.Syntax = Syntax;
- exports.traverse = traverse;
- exports.replace = replace;
- exports.attachComments = attachComments;
- exports.VisitorKeys = VisitorKeys;
- exports.VisitorOption = VisitorOption;
- exports.Controller = Controller;
- exports.cloneEnvironment = function () { return clone({}); };
- return exports;
- }(exports));
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{"./package.json":310}],310:[function(require,module,exports){
- module.exports={
- "name": "estraverse",
- "description": "ECMAScript JS AST traversal functions",
- "homepage": "https://github.com/estools/estraverse",
- "main": "estraverse.js",
- "version": "4.1.0",
- "engines": {
- "node": ">=0.10.0"
- },
- "maintainers": [
- {
- "name": "constellation",
- "email": "utatane.tea@gmail.com"
- },
- {
- "name": "michaelficarra",
- "email": "npm@michael.ficarra.me"
- }
- ],
- "repository": {
- "type": "git",
- "url": "git+ssh://git@github.com/estools/estraverse.git"
- },
- "devDependencies": {
- "chai": "^2.1.1",
- "coffee-script": "^1.8.0",
- "espree": "^1.11.0",
- "gulp": "^3.8.10",
- "gulp-bump": "^0.2.2",
- "gulp-filter": "^2.0.0",
- "gulp-git": "^1.0.1",
- "gulp-tag-version": "^1.2.1",
- "jshint": "^2.5.6",
- "mocha": "^2.1.0"
- },
- "licenses": [
- {
- "type": "BSD",
- "url": "http://github.com/estools/estraverse/raw/master/LICENSE.BSD"
- }
- ],
- "scripts": {
- "test": "npm run-script lint && npm run-script unit-test",
- "lint": "jshint estraverse.js",
- "unit-test": "mocha --compilers coffee:coffee-script/register"
- },
- "gitHead": "347d52996336719b5910c7ffb5ff3ea8ecb87cf3",
- "bugs": {
- "url": "https://github.com/estools/estraverse/issues"
- },
- "_id": "estraverse@4.1.0",
- "_shasum": "40f23a76092041be6467d7f235c933b670766e05",
- "_from": "estraverse@>=4.0.0 <5.0.0",
- "_npmVersion": "2.8.3",
- "_nodeVersion": "1.8.1",
- "_npmUser": {
- "name": "constellation",
- "email": "utatane.tea@gmail.com"
- },
- "dist": {
- "shasum": "40f23a76092041be6467d7f235c933b670766e05",
- "tarball": "http://registry.npmjs.org/estraverse/-/estraverse-4.1.0.tgz"
- },
- "directories": {},
- "_resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.1.0.tgz"
- }
- },{}],311:[function(require,module,exports){
- /*
- Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- (function () {
- 'use strict';
- function isExpression(node) {
- if (node == null) { return false; }
- switch (node.type) {
- case 'ArrayExpression':
- case 'AssignmentExpression':
- case 'BinaryExpression':
- case 'CallExpression':
- case 'ConditionalExpression':
- case 'FunctionExpression':
- case 'Identifier':
- case 'Literal':
- case 'LogicalExpression':
- case 'MemberExpression':
- case 'NewExpression':
- case 'ObjectExpression':
- case 'SequenceExpression':
- case 'ThisExpression':
- case 'UnaryExpression':
- case 'UpdateExpression':
- return true;
- }
- return false;
- }
- function isIterationStatement(node) {
- if (node == null) { return false; }
- switch (node.type) {
- case 'DoWhileStatement':
- case 'ForInStatement':
- case 'ForStatement':
- case 'WhileStatement':
- return true;
- }
- return false;
- }
- function isStatement(node) {
- if (node == null) { return false; }
- switch (node.type) {
- case 'BlockStatement':
- case 'BreakStatement':
- case 'ContinueStatement':
- case 'DebuggerStatement':
- case 'DoWhileStatement':
- case 'EmptyStatement':
- case 'ExpressionStatement':
- case 'ForInStatement':
- case 'ForStatement':
- case 'IfStatement':
- case 'LabeledStatement':
- case 'ReturnStatement':
- case 'SwitchStatement':
- case 'ThrowStatement':
- case 'TryStatement':
- case 'VariableDeclaration':
- case 'WhileStatement':
- case 'WithStatement':
- return true;
- }
- return false;
- }
- function isSourceElement(node) {
- return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
- }
- function trailingStatement(node) {
- switch (node.type) {
- case 'IfStatement':
- if (node.alternate != null) {
- return node.alternate;
- }
- return node.consequent;
- case 'LabeledStatement':
- case 'ForStatement':
- case 'ForInStatement':
- case 'WhileStatement':
- case 'WithStatement':
- return node.body;
- }
- return null;
- }
- function isProblematicIfStatement(node) {
- var current;
- if (node.type !== 'IfStatement') {
- return false;
- }
- if (node.alternate == null) {
- return false;
- }
- current = node.consequent;
- do {
- if (current.type === 'IfStatement') {
- if (current.alternate == null) {
- return true;
- }
- }
- current = trailingStatement(current);
- } while (current);
- return false;
- }
- module.exports = {
- isExpression: isExpression,
- isStatement: isStatement,
- isIterationStatement: isIterationStatement,
- isSourceElement: isSourceElement,
- isProblematicIfStatement: isProblematicIfStatement,
- trailingStatement: trailingStatement
- };
- }());
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{}],312:[function(require,module,exports){
- /*
- Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
- Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- (function () {
- 'use strict';
- var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch;
- // See `tools/generate-identifier-regex.js`.
- ES5Regex = {
- // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
- NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
- // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
- NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
- };
- ES6Regex = {
- // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
- NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/,
- // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
- NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
- };
- function isDecimalDigit(ch) {
- return 0x30 <= ch && ch <= 0x39; // 0..9
- }
- function isHexDigit(ch) {
- return 0x30 <= ch && ch <= 0x39 || // 0..9
- 0x61 <= ch && ch <= 0x66 || // a..f
- 0x41 <= ch && ch <= 0x46; // A..F
- }
- function isOctalDigit(ch) {
- return ch >= 0x30 && ch <= 0x37; // 0..7
- }
- // 7.2 White Space
- NON_ASCII_WHITESPACES = [
- 0x1680, 0x180E,
- 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A,
- 0x202F, 0x205F,
- 0x3000,
- 0xFEFF
- ];
- function isWhiteSpace(ch) {
- return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 ||
- ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
- }
- // 7.3 Line Terminators
- function isLineTerminator(ch) {
- return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
- }
- // 7.6 Identifier Names and Identifiers
- function fromCodePoint(cp) {
- if (cp <= 0xFFFF) { return String.fromCharCode(cp); }
- var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
- var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00);
- return cu1 + cu2;
- }
- IDENTIFIER_START = new Array(0x80);
- for(ch = 0; ch < 0x80; ++ch) {
- IDENTIFIER_START[ch] =
- ch >= 0x61 && ch <= 0x7A || // a..z
- ch >= 0x41 && ch <= 0x5A || // A..Z
- ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
- }
- IDENTIFIER_PART = new Array(0x80);
- for(ch = 0; ch < 0x80; ++ch) {
- IDENTIFIER_PART[ch] =
- ch >= 0x61 && ch <= 0x7A || // a..z
- ch >= 0x41 && ch <= 0x5A || // A..Z
- ch >= 0x30 && ch <= 0x39 || // 0..9
- ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
- }
- function isIdentifierStartES5(ch) {
- return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
- }
- function isIdentifierPartES5(ch) {
- return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
- }
- function isIdentifierStartES6(ch) {
- return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
- }
- function isIdentifierPartES6(ch) {
- return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
- }
- module.exports = {
- isDecimalDigit: isDecimalDigit,
- isHexDigit: isHexDigit,
- isOctalDigit: isOctalDigit,
- isWhiteSpace: isWhiteSpace,
- isLineTerminator: isLineTerminator,
- isIdentifierStartES5: isIdentifierStartES5,
- isIdentifierPartES5: isIdentifierPartES5,
- isIdentifierStartES6: isIdentifierStartES6,
- isIdentifierPartES6: isIdentifierPartES6
- };
- }());
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{}],313:[function(require,module,exports){
- /*
- Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- (function () {
- 'use strict';
- var code = require('./code');
- function isStrictModeReservedWordES6(id) {
- switch (id) {
- case 'implements':
- case 'interface':
- case 'package':
- case 'private':
- case 'protected':
- case 'public':
- case 'static':
- case 'let':
- return true;
- default:
- return false;
- }
- }
- function isKeywordES5(id, strict) {
- // yield should not be treated as keyword under non-strict mode.
- if (!strict && id === 'yield') {
- return false;
- }
- return isKeywordES6(id, strict);
- }
- function isKeywordES6(id, strict) {
- if (strict && isStrictModeReservedWordES6(id)) {
- return true;
- }
- switch (id.length) {
- case 2:
- return (id === 'if') || (id === 'in') || (id === 'do');
- case 3:
- return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try');
- case 4:
- return (id === 'this') || (id === 'else') || (id === 'case') ||
- (id === 'void') || (id === 'with') || (id === 'enum');
- case 5:
- return (id === 'while') || (id === 'break') || (id === 'catch') ||
- (id === 'throw') || (id === 'const') || (id === 'yield') ||
- (id === 'class') || (id === 'super');
- case 6:
- return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
- (id === 'switch') || (id === 'export') || (id === 'import');
- case 7:
- return (id === 'default') || (id === 'finally') || (id === 'extends');
- case 8:
- return (id === 'function') || (id === 'continue') || (id === 'debugger');
- case 10:
- return (id === 'instanceof');
- default:
- return false;
- }
- }
- function isReservedWordES5(id, strict) {
- return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
- }
- function isReservedWordES6(id, strict) {
- return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
- }
- function isRestrictedWord(id) {
- return id === 'eval' || id === 'arguments';
- }
- function isIdentifierNameES5(id) {
- var i, iz, ch;
- if (id.length === 0) { return false; }
- ch = id.charCodeAt(0);
- if (!code.isIdentifierStartES5(ch)) {
- return false;
- }
- for (i = 1, iz = id.length; i < iz; ++i) {
- ch = id.charCodeAt(i);
- if (!code.isIdentifierPartES5(ch)) {
- return false;
- }
- }
- return true;
- }
- function decodeUtf16(lead, trail) {
- return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
- }
- function isIdentifierNameES6(id) {
- var i, iz, ch, lowCh, check;
- if (id.length === 0) { return false; }
- check = code.isIdentifierStartES6;
- for (i = 0, iz = id.length; i < iz; ++i) {
- ch = id.charCodeAt(i);
- if (0xD800 <= ch && ch <= 0xDBFF) {
- ++i;
- if (i >= iz) { return false; }
- lowCh = id.charCodeAt(i);
- if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
- return false;
- }
- ch = decodeUtf16(ch, lowCh);
- }
- if (!check(ch)) {
- return false;
- }
- check = code.isIdentifierPartES6;
- }
- return true;
- }
- function isIdentifierES5(id, strict) {
- return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
- }
- function isIdentifierES6(id, strict) {
- return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
- }
- module.exports = {
- isKeywordES5: isKeywordES5,
- isKeywordES6: isKeywordES6,
- isReservedWordES5: isReservedWordES5,
- isReservedWordES6: isReservedWordES6,
- isRestrictedWord: isRestrictedWord,
- isIdentifierNameES5: isIdentifierNameES5,
- isIdentifierNameES6: isIdentifierNameES6,
- isIdentifierES5: isIdentifierES5,
- isIdentifierES6: isIdentifierES6
- };
- }());
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{"./code":312}],314:[function(require,module,exports){
- /*
- Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- (function () {
- 'use strict';
- exports.ast = require('./ast');
- exports.code = require('./code');
- exports.keyword = require('./keyword');
- }());
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{"./ast":311,"./code":312,"./keyword":313}],315:[function(require,module,exports){
- module.exports={
- "builtin": {
- "Array": false,
- "ArrayBuffer": false,
- "Boolean": false,
- "constructor": false,
- "Date": false,
- "decodeURI": false,
- "decodeURIComponent": false,
- "encodeURI": false,
- "encodeURIComponent": false,
- "Error": false,
- "eval": false,
- "EvalError": false,
- "Float32Array": false,
- "Float64Array": false,
- "Function": false,
- "hasOwnProperty": false,
- "Infinity": false,
- "Int16Array": false,
- "Int32Array": false,
- "Int8Array": false,
- "isFinite": false,
- "isNaN": false,
- "isPrototypeOf": false,
- "JSON": false,
- "Map": false,
- "Math": false,
- "NaN": false,
- "Number": false,
- "Object": false,
- "parseFloat": false,
- "parseInt": false,
- "Promise": false,
- "propertyIsEnumerable": false,
- "Proxy": false,
- "RangeError": false,
- "ReferenceError": false,
- "Reflect": false,
- "RegExp": false,
- "Set": false,
- "String": false,
- "Symbol": false,
- "SyntaxError": false,
- "System": false,
- "toLocaleString": false,
- "toString": false,
- "TypeError": false,
- "Uint16Array": false,
- "Uint32Array": false,
- "Uint8Array": false,
- "Uint8ClampedArray": false,
- "undefined": false,
- "URIError": false,
- "valueOf": false,
- "WeakMap": false,
- "WeakSet": false
- },
- "nonstandard": {
- "escape": false,
- "unescape": false
- },
- "browser": {
- "addEventListener": false,
- "alert": false,
- "applicationCache": false,
- "atob": false,
- "Audio": false,
- "AudioProcessingEvent": false,
- "BeforeUnloadEvent": false,
- "Blob": false,
- "blur": false,
- "btoa": false,
- "cancelAnimationFrame": false,
- "CanvasGradient": false,
- "CanvasPattern": false,
- "CanvasRenderingContext2D": false,
- "clearInterval": false,
- "clearTimeout": false,
- "close": false,
- "closed": false,
- "CloseEvent": false,
- "Comment": false,
- "CompositionEvent": false,
- "confirm": false,
- "console": false,
- "crypto": false,
- "CSS": false,
- "CustomEvent": false,
- "DataView": false,
- "Debug": false,
- "defaultStatus": false,
- "devicePixelRatio": false,
- "dispatchEvent": false,
- "document": false,
- "Document": false,
- "DocumentFragment": false,
- "DOMParser": false,
- "DragEvent": false,
- "Element": false,
- "ElementTimeControl": false,
- "ErrorEvent": false,
- "event": false,
- "Event": false,
- "FileReader": false,
- "fetch": false,
- "find": false,
- "focus": false,
- "FocusEvent": false,
- "FormData": false,
- "frameElement": false,
- "frames": false,
- "GamepadEvent": false,
- "getComputedStyle": false,
- "getSelection": false,
- "HashChangeEvent": false,
- "Headers": false,
- "history": false,
- "HTMLAnchorElement": false,
- "HTMLBaseElement": false,
- "HTMLBlockquoteElement": false,
- "HTMLBodyElement": false,
- "HTMLBRElement": false,
- "HTMLButtonElement": false,
- "HTMLCanvasElement": false,
- "HTMLDirectoryElement": false,
- "HTMLDivElement": false,
- "HTMLDListElement": false,
- "HTMLElement": false,
- "HTMLFieldSetElement": false,
- "HTMLFontElement": false,
- "HTMLFormElement": false,
- "HTMLFrameElement": false,
- "HTMLFrameSetElement": false,
- "HTMLHeadElement": false,
- "HTMLHeadingElement": false,
- "HTMLHRElement": false,
- "HTMLHtmlElement": false,
- "HTMLIFrameElement": false,
- "HTMLImageElement": false,
- "HTMLInputElement": false,
- "HTMLIsIndexElement": false,
- "HTMLLabelElement": false,
- "HTMLLayerElement": false,
- "HTMLLegendElement": false,
- "HTMLLIElement": false,
- "HTMLLinkElement": false,
- "HTMLMapElement": false,
- "HTMLMenuElement": false,
- "HTMLMetaElement": false,
- "HTMLModElement": false,
- "HTMLObjectElement": false,
- "HTMLOListElement": false,
- "HTMLOptGroupElement": false,
- "HTMLOptionElement": false,
- "HTMLParagraphElement": false,
- "HTMLParamElement": false,
- "HTMLPreElement": false,
- "HTMLQuoteElement": false,
- "HTMLScriptElement": false,
- "HTMLSelectElement": false,
- "HTMLStyleElement": false,
- "HTMLTableCaptionElement": false,
- "HTMLTableCellElement": false,
- "HTMLTableColElement": false,
- "HTMLTableElement": false,
- "HTMLTableRowElement": false,
- "HTMLTableSectionElement": false,
- "HTMLTextAreaElement": false,
- "HTMLTitleElement": false,
- "HTMLUListElement": false,
- "HTMLVideoElement": false,
- "IDBCursor": false,
- "IDBCursorWithValue": false,
- "IDBDatabase": false,
- "IDBEnvironment": false,
- "IDBFactory": false,
- "IDBIndex": false,
- "IDBKeyRange": false,
- "IDBObjectStore": false,
- "IDBOpenDBRequest": false,
- "IDBRequest": false,
- "IDBTransaction": false,
- "IDBVersionChangeEvent": false,
- "Image": false,
- "indexedDB": false,
- "innerHeight": false,
- "innerWidth": false,
- "InputEvent": false,
- "Intl": false,
- "KeyboardEvent": false,
- "length": false,
- "localStorage": false,
- "location": false,
- "matchMedia": false,
- "MessageChannel": false,
- "MessageEvent": false,
- "MessagePort": false,
- "MouseEvent": false,
- "moveBy": false,
- "moveTo": false,
- "MutationObserver": false,
- "name": false,
- "navigator": false,
- "Node": false,
- "NodeFilter": false,
- "NodeList": false,
- "Notification": false,
- "OfflineAudioCompletionEvent": false,
- "onbeforeunload": true,
- "onblur": true,
- "onerror": true,
- "onfocus": true,
- "onload": true,
- "onresize": true,
- "onunload": true,
- "open": false,
- "openDatabase": false,
- "opener": false,
- "opera": false,
- "Option": false,
- "outerHeight": false,
- "outerWidth": false,
- "PageTransitionEvent": false,
- "pageXOffset": false,
- "pageYOffset": false,
- "parent": false,
- "PopStateEvent": false,
- "postMessage": false,
- "print": false,
- "ProgressEvent": false,
- "prompt": false,
- "Range": false,
- "Request": false,
- "Response": false,
- "removeEventListener": false,
- "requestAnimationFrame": false,
- "resizeBy": false,
- "resizeTo": false,
- "screen": false,
- "screenX": false,
- "screenY": false,
- "scroll": false,
- "scrollbars": false,
- "scrollBy": false,
- "scrollTo": false,
- "scrollX": false,
- "scrollY": false,
- "self": false,
- "sessionStorage": false,
- "setInterval": false,
- "setTimeout": false,
- "SharedWorker": false,
- "showModalDialog": false,
- "status": false,
- "stop": false,
- "StorageEvent": false,
- "SVGAElement": false,
- "SVGAltGlyphDefElement": false,
- "SVGAltGlyphElement": false,
- "SVGAltGlyphItemElement": false,
- "SVGAngle": false,
- "SVGAnimateColorElement": false,
- "SVGAnimatedAngle": false,
- "SVGAnimatedBoolean": false,
- "SVGAnimatedEnumeration": false,
- "SVGAnimatedInteger": false,
- "SVGAnimatedLength": false,
- "SVGAnimatedLengthList": false,
- "SVGAnimatedNumber": false,
- "SVGAnimatedNumberList": false,
- "SVGAnimatedPathData": false,
- "SVGAnimatedPoints": false,
- "SVGAnimatedPreserveAspectRatio": false,
- "SVGAnimatedRect": false,
- "SVGAnimatedString": false,
- "SVGAnimatedTransformList": false,
- "SVGAnimateElement": false,
- "SVGAnimateMotionElement": false,
- "SVGAnimateTransformElement": false,
- "SVGAnimationElement": false,
- "SVGCircleElement": false,
- "SVGClipPathElement": false,
- "SVGColor": false,
- "SVGColorProfileElement": false,
- "SVGColorProfileRule": false,
- "SVGComponentTransferFunctionElement": false,
- "SVGCSSRule": false,
- "SVGCursorElement": false,
- "SVGDefsElement": false,
- "SVGDescElement": false,
- "SVGDocument": false,
- "SVGElement": false,
- "SVGElementInstance": false,
- "SVGElementInstanceList": false,
- "SVGEllipseElement": false,
- "SVGEvent": false,
- "SVGExternalResourcesRequired": false,
- "SVGFEBlendElement": false,
- "SVGFEColorMatrixElement": false,
- "SVGFEComponentTransferElement": false,
- "SVGFECompositeElement": false,
- "SVGFEConvolveMatrixElement": false,
- "SVGFEDiffuseLightingElement": false,
- "SVGFEDisplacementMapElement": false,
- "SVGFEDistantLightElement": false,
- "SVGFEFloodElement": false,
- "SVGFEFuncAElement": false,
- "SVGFEFuncBElement": false,
- "SVGFEFuncGElement": false,
- "SVGFEFuncRElement": false,
- "SVGFEGaussianBlurElement": false,
- "SVGFEImageElement": false,
- "SVGFEMergeElement": false,
- "SVGFEMergeNodeElement": false,
- "SVGFEMorphologyElement": false,
- "SVGFEOffsetElement": false,
- "SVGFEPointLightElement": false,
- "SVGFESpecularLightingElement": false,
- "SVGFESpotLightElement": false,
- "SVGFETileElement": false,
- "SVGFETurbulenceElement": false,
- "SVGFilterElement": false,
- "SVGFilterPrimitiveStandardAttributes": false,
- "SVGFitToViewBox": false,
- "SVGFontElement": false,
- "SVGFontFaceElement": false,
- "SVGFontFaceFormatElement": false,
- "SVGFontFaceNameElement": false,
- "SVGFontFaceSrcElement": false,
- "SVGFontFaceUriElement": false,
- "SVGForeignObjectElement": false,
- "SVGGElement": false,
- "SVGGlyphElement": false,
- "SVGGlyphRefElement": false,
- "SVGGradientElement": false,
- "SVGHKernElement": false,
- "SVGICCColor": false,
- "SVGImageElement": false,
- "SVGLangSpace": false,
- "SVGLength": false,
- "SVGLengthList": false,
- "SVGLinearGradientElement": false,
- "SVGLineElement": false,
- "SVGLocatable": false,
- "SVGMarkerElement": false,
- "SVGMaskElement": false,
- "SVGMatrix": false,
- "SVGMetadataElement": false,
- "SVGMissingGlyphElement": false,
- "SVGMPathElement": false,
- "SVGNumber": false,
- "SVGNumberList": false,
- "SVGPaint": false,
- "SVGPathElement": false,
- "SVGPathSeg": false,
- "SVGPathSegArcAbs": false,
- "SVGPathSegArcRel": false,
- "SVGPathSegClosePath": false,
- "SVGPathSegCurvetoCubicAbs": false,
- "SVGPathSegCurvetoCubicRel": false,
- "SVGPathSegCurvetoCubicSmoothAbs": false,
- "SVGPathSegCurvetoCubicSmoothRel": false,
- "SVGPathSegCurvetoQuadraticAbs": false,
- "SVGPathSegCurvetoQuadraticRel": false,
- "SVGPathSegCurvetoQuadraticSmoothAbs": false,
- "SVGPathSegCurvetoQuadraticSmoothRel": false,
- "SVGPathSegLinetoAbs": false,
- "SVGPathSegLinetoHorizontalAbs": false,
- "SVGPathSegLinetoHorizontalRel": false,
- "SVGPathSegLinetoRel": false,
- "SVGPathSegLinetoVerticalAbs": false,
- "SVGPathSegLinetoVerticalRel": false,
- "SVGPathSegList": false,
- "SVGPathSegMovetoAbs": false,
- "SVGPathSegMovetoRel": false,
- "SVGPatternElement": false,
- "SVGPoint": false,
- "SVGPointList": false,
- "SVGPolygonElement": false,
- "SVGPolylineElement": false,
- "SVGPreserveAspectRatio": false,
- "SVGRadialGradientElement": false,
- "SVGRect": false,
- "SVGRectElement": false,
- "SVGRenderingIntent": false,
- "SVGScriptElement": false,
- "SVGSetElement": false,
- "SVGStopElement": false,
- "SVGStringList": false,
- "SVGStylable": false,
- "SVGStyleElement": false,
- "SVGSVGElement": false,
- "SVGSwitchElement": false,
- "SVGSymbolElement": false,
- "SVGTests": false,
- "SVGTextContentElement": false,
- "SVGTextElement": false,
- "SVGTextPathElement": false,
- "SVGTextPositioningElement": false,
- "SVGTitleElement": false,
- "SVGTransform": false,
- "SVGTransformable": false,
- "SVGTransformList": false,
- "SVGTRefElement": false,
- "SVGTSpanElement": false,
- "SVGUnitTypes": false,
- "SVGURIReference": false,
- "SVGUseElement": false,
- "SVGViewElement": false,
- "SVGViewSpec": false,
- "SVGVKernElement": false,
- "SVGZoomAndPan": false,
- "Text": false,
- "TextDecoder": false,
- "TextEncoder": false,
- "TimeEvent": false,
- "top": false,
- "TouchEvent": false,
- "UIEvent": false,
- "URL": false,
- "WebGLActiveInfo": false,
- "WebGLBuffer": false,
- "WebGLContextEvent": false,
- "WebGLFramebuffer": false,
- "WebGLProgram": false,
- "WebGLRenderbuffer": false,
- "WebGLRenderingContext": false,
- "WebGLShader": false,
- "WebGLShaderPrecisionFormat": false,
- "WebGLTexture": false,
- "WebGLUniformLocation": false,
- "WebSocket": false,
- "WheelEvent": false,
- "window": false,
- "Window": false,
- "Worker": false,
- "XDomainRequest": false,
- "XMLHttpRequest": false,
- "XMLSerializer": false,
- "XPathEvaluator": false,
- "XPathException": false,
- "XPathExpression": false,
- "XPathNamespace": false,
- "XPathNSResolver": false,
- "XPathResult": false
- },
- "worker": {
- "importScripts": true,
- "postMessage": true,
- "self": true
- },
- "node": {
- "__dirname": false,
- "__filename": false,
- "arguments": false,
- "Buffer": false,
- "clearImmediate": false,
- "clearInterval": false,
- "clearTimeout": false,
- "console": false,
- "DataView": false,
- "exports": true,
- "GLOBAL": false,
- "global": false,
- "module": false,
- "process": false,
- "require": false,
- "setImmediate": false,
- "setInterval": false,
- "setTimeout": false
- },
- "amd": {
- "define": false,
- "require": false
- },
- "mocha": {
- "after": false,
- "afterEach": false,
- "before": false,
- "beforeEach": false,
- "context": false,
- "describe": false,
- "it": false,
- "setup": false,
- "specify": false,
- "suite": false,
- "suiteSetup": false,
- "suiteTeardown": false,
- "teardown": false,
- "test": false,
- "xcontext": false,
- "xdescribe": false,
- "xit": false,
- "xspecify": false
- },
- "jasmine": {
- "afterAll": false,
- "afterEach": false,
- "beforeAll": false,
- "beforeEach": false,
- "describe": false,
- "expect": false,
- "fail": false,
- "fdescribe": false,
- "fit": false,
- "it": false,
- "jasmine": false,
- "pending": false,
- "runs": false,
- "spyOn": false,
- "waits": false,
- "waitsFor": false,
- "xdescribe": false,
- "xit": false
- },
- "qunit": {
- "asyncTest": false,
- "deepEqual": false,
- "equal": false,
- "expect": false,
- "module": false,
- "notDeepEqual": false,
- "notEqual": false,
- "notPropEqual": false,
- "notStrictEqual": false,
- "ok": false,
- "propEqual": false,
- "QUnit": false,
- "raises": false,
- "start": false,
- "stop": false,
- "strictEqual": false,
- "test": false,
- "throws": false
- },
- "phantomjs": {
- "console": true,
- "exports": true,
- "phantom": true,
- "require": true,
- "WebPage": true
- },
- "couch": {
- "emit": false,
- "exports": false,
- "getRow": false,
- "log": false,
- "module": false,
- "provides": false,
- "require": false,
- "respond": false,
- "send": false,
- "start": false,
- "sum": false
- },
- "rhino": {
- "defineClass": false,
- "deserialize": false,
- "gc": false,
- "help": false,
- "importClass": false,
- "importPackage": false,
- "java": false,
- "load": false,
- "loadClass": false,
- "Packages": false,
- "print": false,
- "quit": false,
- "readFile": false,
- "readUrl": false,
- "runCommand": false,
- "seal": false,
- "serialize": false,
- "spawn": false,
- "sync": false,
- "toint32": false,
- "version": false
- },
- "wsh": {
- "ActiveXObject": true,
- "Enumerator": true,
- "GetObject": true,
- "ScriptEngine": true,
- "ScriptEngineBuildVersion": true,
- "ScriptEngineMajorVersion": true,
- "ScriptEngineMinorVersion": true,
- "VBArray": true,
- "WScript": true,
- "WSH": true,
- "XDomainRequest": true
- },
- "jquery": {
- "$": false,
- "jQuery": false
- },
- "yui": {
- "Y": false,
- "YUI": false,
- "YUI_config": false
- },
- "shelljs": {
- "cat": false,
- "cd": false,
- "chmod": false,
- "config": false,
- "cp": false,
- "dirs": false,
- "echo": false,
- "env": false,
- "error": false,
- "exec": false,
- "exit": false,
- "find": false,
- "grep": false,
- "ls": false,
- "mkdir": false,
- "mv": false,
- "popd": false,
- "pushd": false,
- "pwd": false,
- "rm": false,
- "sed": false,
- "target": false,
- "tempdir": false,
- "test": false,
- "which": false
- },
- "prototypejs": {
- "$": false,
- "$$": false,
- "$A": false,
- "$break": false,
- "$continue": false,
- "$F": false,
- "$H": false,
- "$R": false,
- "$w": false,
- "Abstract": false,
- "Ajax": false,
- "Autocompleter": false,
- "Builder": false,
- "Class": false,
- "Control": false,
- "Draggable": false,
- "Draggables": false,
- "Droppables": false,
- "Effect": false,
- "Element": false,
- "Enumerable": false,
- "Event": false,
- "Field": false,
- "Form": false,
- "Hash": false,
- "Insertion": false,
- "ObjectRange": false,
- "PeriodicalExecuter": false,
- "Position": false,
- "Prototype": false,
- "Scriptaculous": false,
- "Selector": false,
- "Sortable": false,
- "SortableObserver": false,
- "Sound": false,
- "Template": false,
- "Toggle": false,
- "Try": false
- },
- "meteor": {
- "$": false,
- "_": false,
- "Accounts": false,
- "App": false,
- "Assets": false,
- "Blaze": false,
- "check": false,
- "Cordova": false,
- "DDP": false,
- "DDPServer": false,
- "Deps": false,
- "EJSON": false,
- "Email": false,
- "HTTP": false,
- "Log": false,
- "Match": false,
- "Meteor": false,
- "Mongo": false,
- "MongoInternals": false,
- "Npm": false,
- "Package": false,
- "Plugin": false,
- "process": false,
- "Random": false,
- "ReactiveDict": false,
- "ReactiveVar": false,
- "Router": false,
- "Session": false,
- "share": false,
- "Spacebars": false,
- "Template": false,
- "Tinytest": false,
- "Tracker": false,
- "UI": false,
- "Utils": false,
- "WebApp": false,
- "WebAppInternals": false
- },
- "mongo": {
- "_isWindows": false,
- "_rand": false,
- "BulkWriteResult": false,
- "cat": false,
- "cd": false,
- "connect": false,
- "db": false,
- "getHostName": false,
- "getMemInfo": false,
- "hostname": false,
- "listFiles": false,
- "load": false,
- "ls": false,
- "md5sumFile": false,
- "mkdir": false,
- "Mongo": false,
- "ObjectId": false,
- "PlanCache": false,
- "pwd": false,
- "quit": false,
- "removeFile": false,
- "rs": false,
- "sh": false,
- "UUID": false,
- "version": false,
- "WriteResult": false
- },
- "applescript": {
- "$": false,
- "Application": false,
- "Automation": false,
- "console": false,
- "delay": false,
- "Library": false,
- "ObjC": false,
- "ObjectSpecifier": false,
- "Path": false,
- "Progress": false,
- "Ref": false
- }
- }
- },{}],316:[function(require,module,exports){
- module.exports = require('./globals.json');
- },{"./globals.json":315}],317:[function(require,module,exports){
- // https://github.com/paulmillr/es6-shim
- // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isinteger
- var isNaN = require("is-nan");
- var isFinite = require("is-finite");
- module.exports = Number.isInteger || function(val) {
- return typeof val === "number" &&
- ! isNaN(val) &&
- isFinite(val) &&
- parseInt(val, 10) === val;
- };
- },{"is-finite":318,"is-nan":319}],318:[function(require,module,exports){
- 'use strict';
- module.exports = Number.isFinite || function (val) {
- // Number.isNaN() => val !== val
- if (typeof val !== 'number' || val !== val || val === Infinity || val === -Infinity) {
- return false;
- }
- return true;
- };
- },{}],319:[function(require,module,exports){
- "use strict";
- /* https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isnan */
- module.exports = function isNaN(value) {
- return value !== value;
- };
- },{}],320:[function(require,module,exports){
- // Copyright 2014, 2015 Simon Lydell
- // X11 (“MIT”) Licensed. (See LICENSE.)
- // This regex comes from regex.coffee, and is inserted here by generate-index.js
- // (run `npm run build`).
- module.exports = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|((?:0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?))|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]{1,6}\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-*\/%&|^]|<{1,2}|>{1,3}|!=?|={1,2})=?|[?:~]|[;,.[\](){}])|(\s+)|(^$|[\s\S])/g
- module.exports.matchToToken = function(match) {
- token = {type: "invalid", value: match[0]}
- if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
- else if (match[ 5]) token.type = "comment"
- else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
- else if (match[ 8]) token.type = "regex"
- else if (match[ 9]) token.type = "number"
- else if (match[10]) token.type = "name"
- else if (match[11]) token.type = "punctuator"
- else if (match[12]) token.type = "whitespace"
- return token
- }
- },{}],321:[function(require,module,exports){
- // intentionally commented out as it makes it slower...
- //'use strict';
- var arr = [];
- var charCodeCache = [];
- module.exports = function (a, b) {
- if (a === b) {
- return 0;
- }
- var aLen = a.length;
- var bLen = b.length;
- if (aLen === 0) {
- return bLen;
- }
- if (bLen === 0) {
- return aLen;
- }
- var bCharCode;
- var ret;
- var tmp;
- var tmp2;
- var i = 0;
- var j = 0;
- while (i < aLen) {
- charCodeCache[i] = a.charCodeAt(i);
- arr[i] = ++i;
- }
- while (j < bLen) {
- bCharCode = b.charCodeAt(j);
- tmp = j++;
- ret = j;
- for (i = 0; i < aLen; i++) {
- tmp2 = bCharCode === charCodeCache[i] ? tmp : tmp + 1;
- tmp = arr[i];
- ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
- }
- }
- return ret;
- };
- },{}],322:[function(require,module,exports){
- // Copyright 2014, 2015 Simon Lydell
- // X11 (“MIT”) Licensed. (See LICENSE.)
- var leftPad = require("left-pad")
- function get(options, key, defaultValue) {
- return (key in options ? options[key] : defaultValue)
- }
- function lineNumbers(code, options) {
- var getOption = get.bind(null, options || {})
- var transform = getOption("transform", Function.prototype)
- var padding = getOption("padding", " ")
- var before = getOption("before", " ")
- var after = getOption("after", " | ")
- var start = getOption("start", 1)
- var isArray = Array.isArray(code)
- var lines = (isArray ? code : code.split("\n"))
- var end = start + lines.length - 1
- var width = String(end).length
- var numbered = lines.map(function(line, index) {
- var number = start + index
- var params = {before: before, number: number, width: width, after: after,
- line: line}
- transform(params)
- return params.before + leftPad(params.number, width, padding) +
- params.after + params.line
- })
- return (isArray ? numbered : numbered.join("\n"))
- }
- module.exports = lineNumbers
- },{"left-pad":323}],323:[function(require,module,exports){
- module.exports = leftpad;
- function leftpad (str, len, ch) {
- str = String(str);
- var i = -1;
- ch || (ch = ' ');
- len = len - str.length;
- while (++i < len) {
- str = ch + str;
- }
- return str;
- }
- },{}],324:[function(require,module,exports){
- /**
- * Creates an array with all falsey values removed. The values `false`, `null`,
- * `0`, `""`, `undefined`, and `NaN` are falsey.
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to compact.
- * @returns {Array} Returns the new array of filtered values.
- * @example
- *
- * _.compact([0, 1, false, 2, '', 3]);
- * // => [1, 2, 3]
- */
- function compact(array) {
- var index = -1,
- length = array ? array.length : 0,
- resIndex = -1,
- result = [];
- while (++index < length) {
- var value = array[index];
- if (value) {
- result[++resIndex] = value;
- }
- }
- return result;
- }
- module.exports = compact;
- },{}],325:[function(require,module,exports){
- var baseFlatten = require('../internal/baseFlatten'),
- isIterateeCall = require('../internal/isIterateeCall');
- /**
- * Flattens a nested array. If `isDeep` is `true` the array is recursively
- * flattened, otherwise it is only flattened a single level.
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to flatten.
- * @param {boolean} [isDeep] Specify a deep flatten.
- * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
- * @returns {Array} Returns the new flattened array.
- * @example
- *
- * _.flatten([1, [2, 3, [4]]]);
- * // => [1, 2, 3, [4]]
- *
- * // using `isDeep`
- * _.flatten([1, [2, 3, [4]]], true);
- * // => [1, 2, 3, 4]
- */
- function flatten(array, isDeep, guard) {
- var length = array ? array.length : 0;
- if (guard && isIterateeCall(array, isDeep, guard)) {
- isDeep = false;
- }
- return length ? baseFlatten(array, isDeep) : [];
- }
- module.exports = flatten;
- },{"../internal/baseFlatten":352,"../internal/isIterateeCall":394}],326:[function(require,module,exports){
- /**
- * Gets the last element of `array`.
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to query.
- * @returns {*} Returns the last element of `array`.
- * @example
- *
- * _.last([1, 2, 3]);
- * // => 3
- */
- function last(array) {
- var length = array ? array.length : 0;
- return length ? array[length - 1] : undefined;
- }
- module.exports = last;
- },{}],327:[function(require,module,exports){
- var baseIndexOf = require('../internal/baseIndexOf');
- /** Used for native method references. */
- var arrayProto = Array.prototype;
- /** Native method references. */
- var splice = arrayProto.splice;
- /**
- * Removes all provided values from `array` using `SameValueZero` for equality
- * comparisons.
- *
- * **Notes:**
- * - Unlike `_.without`, this method mutates `array`
- * - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
- * comparisons are like strict equality comparisons, e.g. `===`, except
- * that `NaN` matches `NaN`
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to modify.
- * @param {...*} [values] The values to remove.
- * @returns {Array} Returns `array`.
- * @example
- *
- * var array = [1, 2, 3, 1, 2, 3];
- *
- * _.pull(array, 2, 3);
- * console.log(array);
- * // => [1, 1]
- */
- function pull() {
- var args = arguments,
- array = args[0];
- if (!(array && array.length)) {
- return array;
- }
- var index = 0,
- indexOf = baseIndexOf,
- length = args.length;
- while (++index < length) {
- var fromIndex = 0,
- value = args[index];
- while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
- splice.call(array, fromIndex, 1);
- }
- }
- return array;
- }
- module.exports = pull;
- },{"../internal/baseIndexOf":358}],328:[function(require,module,exports){
- var baseCallback = require('../internal/baseCallback'),
- baseUniq = require('../internal/baseUniq'),
- isIterateeCall = require('../internal/isIterateeCall'),
- sortedUniq = require('../internal/sortedUniq');
- /**
- * Creates a duplicate-value-free version of an array using `SameValueZero`
- * for equality comparisons. Providing `true` for `isSorted` performs a faster
- * search algorithm for sorted arrays. If an iteratee function is provided it
- * is invoked for each value in the array to generate the criterion by which
- * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
- * with three arguments: (value, index, array).
- *
- * If a property name is provided for `iteratee` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `iteratee` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
- * comparisons are like strict equality comparisons, e.g. `===`, except that
- * `NaN` matches `NaN`.
- *
- * @static
- * @memberOf _
- * @alias unique
- * @category Array
- * @param {Array} array The array to inspect.
- * @param {boolean} [isSorted] Specify the array is sorted.
- * @param {Function|Object|string} [iteratee] The function invoked per iteration.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array} Returns the new duplicate-value-free array.
- * @example
- *
- * _.uniq([1, 2, 1]);
- * // => [1, 2]
- *
- * // using `isSorted`
- * _.uniq([1, 1, 2], true);
- * // => [1, 2]
- *
- * // using an iteratee function
- * _.uniq([1, 2.5, 1.5, 2], function(n) {
- * return this.floor(n);
- * }, Math);
- * // => [1, 2.5]
- *
- * // using the `_.property` callback shorthand
- * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
- * // => [{ 'x': 1 }, { 'x': 2 }]
- */
- function uniq(array, isSorted, iteratee, thisArg) {
- var length = array ? array.length : 0;
- if (!length) {
- return [];
- }
- if (isSorted != null && typeof isSorted != 'boolean') {
- thisArg = iteratee;
- iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
- isSorted = false;
- }
- iteratee = iteratee == null ? iteratee : baseCallback(iteratee, thisArg, 3);
- return (isSorted)
- ? sortedUniq(array, iteratee)
- : baseUniq(array, iteratee);
- }
- module.exports = uniq;
- },{"../internal/baseCallback":346,"../internal/baseUniq":373,"../internal/isIterateeCall":394,"../internal/sortedUniq":400}],329:[function(require,module,exports){
- module.exports = require('./includes');
- },{"./includes":332}],330:[function(require,module,exports){
- module.exports = require('./forEach');
- },{"./forEach":331}],331:[function(require,module,exports){
- var arrayEach = require('../internal/arrayEach'),
- baseEach = require('../internal/baseEach'),
- createForEach = require('../internal/createForEach');
- /**
- * Iterates over elements of `collection` invoking `iteratee` for each element.
- * The `iteratee` is bound to `thisArg` and invoked with three arguments:
- * (value, index|key, collection). Iterator functions may exit iteration early
- * by explicitly returning `false`.
- *
- * **Note:** As with other "Collections" methods, objects with a `length` property
- * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
- * may be used for object iteration.
- *
- * @static
- * @memberOf _
- * @alias each
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array|Object|string} Returns `collection`.
- * @example
- *
- * _([1, 2]).forEach(function(n) {
- * console.log(n);
- * }).value();
- * // => logs each value from left to right and returns the array
- *
- * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
- * console.log(n, key);
- * });
- * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
- */
- var forEach = createForEach(arrayEach, baseEach);
- module.exports = forEach;
- },{"../internal/arrayEach":340,"../internal/baseEach":350,"../internal/createForEach":384}],332:[function(require,module,exports){
- var baseIndexOf = require('../internal/baseIndexOf'),
- isArray = require('../lang/isArray'),
- isIterateeCall = require('../internal/isIterateeCall'),
- isLength = require('../internal/isLength'),
- isString = require('../lang/isString'),
- values = require('../object/values');
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Checks if `value` is in `collection` using `SameValueZero` for equality
- * comparisons. If `fromIndex` is negative, it is used as the offset from
- * the end of `collection`.
- *
- * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
- * comparisons are like strict equality comparisons, e.g. `===`, except that
- * `NaN` matches `NaN`.
- *
- * @static
- * @memberOf _
- * @alias contains, include
- * @category Collection
- * @param {Array|Object|string} collection The collection to search.
- * @param {*} target The value to search for.
- * @param {number} [fromIndex=0] The index to search from.
- * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
- * @returns {boolean} Returns `true` if a matching element is found, else `false`.
- * @example
- *
- * _.includes([1, 2, 3], 1);
- * // => true
- *
- * _.includes([1, 2, 3], 1, 2);
- * // => false
- *
- * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
- * // => true
- *
- * _.includes('pebbles', 'eb');
- * // => true
- */
- function includes(collection, target, fromIndex, guard) {
- var length = collection ? collection.length : 0;
- if (!isLength(length)) {
- collection = values(collection);
- length = collection.length;
- }
- if (!length) {
- return false;
- }
- if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
- fromIndex = 0;
- } else {
- fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
- }
- return (typeof collection == 'string' || !isArray(collection) && isString(collection))
- ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
- : (baseIndexOf(collection, target, fromIndex) > -1);
- }
- module.exports = includes;
- },{"../internal/baseIndexOf":358,"../internal/isIterateeCall":394,"../internal/isLength":395,"../lang/isArray":405,"../lang/isString":414,"../object/values":424}],333:[function(require,module,exports){
- var arrayMap = require('../internal/arrayMap'),
- baseCallback = require('../internal/baseCallback'),
- baseMap = require('../internal/baseMap'),
- isArray = require('../lang/isArray');
- /**
- * Creates an array of values by running each element in `collection` through
- * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
- * arguments: (value, index|key, collection).
- *
- * If a property name is provided for `iteratee` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `iteratee` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * Many lodash methods are guarded to work as interatees for methods like
- * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
- *
- * The guarded methods are:
- * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
- * `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
- * `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
- * `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
- *
- * @static
- * @memberOf _
- * @alias collect
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [iteratee=_.identity] The function invoked
- * per iteration.
- * create a `_.property` or `_.matches` style callback respectively.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array} Returns the new mapped array.
- * @example
- *
- * function timesThree(n) {
- * return n * 3;
- * }
- *
- * _.map([1, 2], timesThree);
- * // => [3, 6]
- *
- * _.map({ 'a': 1, 'b': 2 }, timesThree);
- * // => [3, 6] (iteration order is not guaranteed)
- *
- * var users = [
- * { 'user': 'barney' },
- * { 'user': 'fred' }
- * ];
- *
- * // using the `_.property` callback shorthand
- * _.map(users, 'user');
- * // => ['barney', 'fred']
- */
- function map(collection, iteratee, thisArg) {
- var func = isArray(collection) ? arrayMap : baseMap;
- iteratee = baseCallback(iteratee, thisArg, 3);
- return func(collection, iteratee);
- }
- module.exports = map;
- },{"../internal/arrayMap":341,"../internal/baseCallback":346,"../internal/baseMap":363,"../lang/isArray":405}],334:[function(require,module,exports){
- var arrayReduceRight = require('../internal/arrayReduceRight'),
- baseEachRight = require('../internal/baseEachRight'),
- createReduce = require('../internal/createReduce');
- /**
- * This method is like `_.reduce` except that it iterates over elements of
- * `collection` from right to left.
- *
- * @static
- * @memberOf _
- * @alias foldr
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @param {*} [accumulator] The initial value.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {*} Returns the accumulated value.
- * @example
- *
- * var array = [[0, 1], [2, 3], [4, 5]];
- *
- * _.reduceRight(array, function(flattened, other) {
- * return flattened.concat(other);
- * }, []);
- * // => [4, 5, 2, 3, 0, 1]
- */
- var reduceRight = createReduce(arrayReduceRight, baseEachRight);
- module.exports = reduceRight;
- },{"../internal/arrayReduceRight":342,"../internal/baseEachRight":351,"../internal/createReduce":385}],335:[function(require,module,exports){
- var arraySome = require('../internal/arraySome'),
- baseCallback = require('../internal/baseCallback'),
- baseSome = require('../internal/baseSome'),
- isArray = require('../lang/isArray'),
- isIterateeCall = require('../internal/isIterateeCall');
- /**
- * Checks if `predicate` returns truthy for **any** element of `collection`.
- * The function returns as soon as it finds a passing value and does not iterate
- * over the entire collection. The predicate is bound to `thisArg` and invoked
- * with three arguments: (value, index|key, collection).
- *
- * If a property name is provided for `predicate` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `predicate` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @alias any
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `predicate`.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- * @example
- *
- * _.some([null, 0, 'yes', false], Boolean);
- * // => true
- *
- * var users = [
- * { 'user': 'barney', 'active': true },
- * { 'user': 'fred', 'active': false }
- * ];
- *
- * // using the `_.matches` callback shorthand
- * _.some(users, { 'user': 'barney', 'active': false });
- * // => false
- *
- * // using the `_.matchesProperty` callback shorthand
- * _.some(users, 'active', false);
- * // => true
- *
- * // using the `_.property` callback shorthand
- * _.some(users, 'active');
- * // => true
- */
- function some(collection, predicate, thisArg) {
- var func = isArray(collection) ? arraySome : baseSome;
- if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
- predicate = null;
- }
- if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
- predicate = baseCallback(predicate, thisArg, 3);
- }
- return func(collection, predicate);
- }
- module.exports = some;
- },{"../internal/arraySome":343,"../internal/baseCallback":346,"../internal/baseSome":370,"../internal/isIterateeCall":394,"../lang/isArray":405}],336:[function(require,module,exports){
- var baseCallback = require('../internal/baseCallback'),
- baseEach = require('../internal/baseEach'),
- baseSortBy = require('../internal/baseSortBy'),
- compareAscending = require('../internal/compareAscending'),
- isIterateeCall = require('../internal/isIterateeCall'),
- isLength = require('../internal/isLength');
- /**
- * Creates an array of elements, sorted in ascending order by the results of
- * running each element in a collection through `iteratee`. This method performs
- * a stable sort, that is, it preserves the original sort order of equal elements.
- * The `iteratee` is bound to `thisArg` and invoked with three arguments:
- * (value, index|key, collection).
- *
- * If a property name is provided for `iteratee` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `iteratee` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity] The function
- * invoked per iteration. If a property name or an object is provided it is
- * used to create a `_.property` or `_.matches` style callback respectively.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array} Returns the new sorted array.
- * @example
- *
- * _.sortBy([1, 2, 3], function(n) {
- * return Math.sin(n);
- * });
- * // => [3, 1, 2]
- *
- * _.sortBy([1, 2, 3], function(n) {
- * return this.sin(n);
- * }, Math);
- * // => [3, 1, 2]
- *
- * var users = [
- * { 'user': 'fred' },
- * { 'user': 'pebbles' },
- * { 'user': 'barney' }
- * ];
- *
- * // using the `_.property` callback shorthand
- * _.pluck(_.sortBy(users, 'user'), 'user');
- * // => ['barney', 'fred', 'pebbles']
- */
- function sortBy(collection, iteratee, thisArg) {
- if (collection == null) {
- return [];
- }
- var index = -1,
- length = collection.length,
- result = isLength(length) ? Array(length) : [];
- if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
- iteratee = null;
- }
- iteratee = baseCallback(iteratee, thisArg, 3);
- baseEach(collection, function(value, key, collection) {
- result[++index] = { 'criteria': iteratee(value, key, collection), 'index': index, 'value': value };
- });
- return baseSortBy(result, compareAscending);
- }
- module.exports = sortBy;
- },{"../internal/baseCallback":346,"../internal/baseEach":350,"../internal/baseSortBy":371,"../internal/compareAscending":379,"../internal/isIterateeCall":394,"../internal/isLength":395}],337:[function(require,module,exports){
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Creates a function that invokes `func` with the `this` binding of the
- * created function and arguments from `start` and beyond provided as an array.
- *
- * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
- *
- * @static
- * @memberOf _
- * @category Function
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var say = _.restParam(function(what, names) {
- * return what + ' ' + _.initial(names).join(', ') +
- * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
- * });
- *
- * say('hello', 'fred', 'barney', 'pebbles');
- * // => 'hello fred, barney, & pebbles'
- */
- function restParam(func, start) {
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- start = nativeMax(typeof start == 'undefined' ? (func.length - 1) : (+start || 0), 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- rest = Array(length);
- while (++index < length) {
- rest[index] = args[start + index];
- }
- switch (start) {
- case 0: return func.call(this, rest);
- case 1: return func.call(this, args[0], rest);
- case 2: return func.call(this, args[0], args[1], rest);
- }
- var otherArgs = Array(start + 1);
- index = -1;
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = rest;
- return func.apply(this, otherArgs);
- };
- }
- module.exports = restParam;
- },{}],338:[function(require,module,exports){
- (function (global){
- var cachePush = require('./cachePush'),
- isNative = require('../lang/isNative');
- /** Native method references. */
- var Set = isNative(Set = global.Set) && Set;
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
- /**
- *
- * Creates a cache object to store unique values.
- *
- * @private
- * @param {Array} [values] The values to cache.
- */
- function SetCache(values) {
- var length = values ? values.length : 0;
- this.data = { 'hash': nativeCreate(null), 'set': new Set };
- while (length--) {
- this.push(values[length]);
- }
- }
- // Add functions to the `Set` cache.
- SetCache.prototype.push = cachePush;
- module.exports = SetCache;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"../lang/isNative":409,"./cachePush":378}],339:[function(require,module,exports){
- /**
- * Copies the values of `source` to `array`.
- *
- * @private
- * @param {Array} source The array to copy values from.
- * @param {Array} [array=[]] The array to copy values to.
- * @returns {Array} Returns `array`.
- */
- function arrayCopy(source, array) {
- var index = -1,
- length = source.length;
- array || (array = Array(length));
- while (++index < length) {
- array[index] = source[index];
- }
- return array;
- }
- module.exports = arrayCopy;
- },{}],340:[function(require,module,exports){
- /**
- * A specialized version of `_.forEach` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns `array`.
- */
- function arrayEach(array, iteratee) {
- var index = -1,
- length = array.length;
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
- }
- }
- return array;
- }
- module.exports = arrayEach;
- },{}],341:[function(require,module,exports){
- /**
- * A specialized version of `_.map` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array.length,
- result = Array(length);
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
- module.exports = arrayMap;
- },{}],342:[function(require,module,exports){
- /**
- * A specialized version of `_.reduceRight` for arrays without support for
- * callback shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {*} [accumulator] The initial value.
- * @param {boolean} [initFromArray] Specify using the last element of `array`
- * as the initial value.
- * @returns {*} Returns the accumulated value.
- */
- function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
- var length = array.length;
- if (initFromArray && length) {
- accumulator = array[--length];
- }
- while (length--) {
- accumulator = iteratee(accumulator, array[length], length, array);
- }
- return accumulator;
- }
- module.exports = arrayReduceRight;
- },{}],343:[function(require,module,exports){
- /**
- * A specialized version of `_.some` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- */
- function arraySome(array, predicate) {
- var index = -1,
- length = array.length;
- while (++index < length) {
- if (predicate(array[index], index, array)) {
- return true;
- }
- }
- return false;
- }
- module.exports = arraySome;
- },{}],344:[function(require,module,exports){
- /**
- * Used by `_.defaults` to customize its `_.assign` use.
- *
- * @private
- * @param {*} objectValue The destination object property value.
- * @param {*} sourceValue The source object property value.
- * @returns {*} Returns the value to assign to the destination object.
- */
- function assignDefaults(objectValue, sourceValue) {
- return typeof objectValue == 'undefined' ? sourceValue : objectValue;
- }
- module.exports = assignDefaults;
- },{}],345:[function(require,module,exports){
- var baseCopy = require('./baseCopy'),
- keys = require('../object/keys');
- /**
- * The base implementation of `_.assign` without support for argument juggling,
- * multiple sources, and `this` binding `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {Function} [customizer] The function to customize assigning values.
- * @returns {Object} Returns the destination object.
- */
- function baseAssign(object, source, customizer) {
- var props = keys(source);
- if (!customizer) {
- return baseCopy(source, object, props);
- }
- var index = -1,
- length = props.length;
- while (++index < length) {
- var key = props[index],
- value = object[key],
- result = customizer(value, source[key], key, object, source);
- if ((result === result ? (result !== value) : (value === value)) ||
- (typeof value == 'undefined' && !(key in object))) {
- object[key] = result;
- }
- }
- return object;
- }
- module.exports = baseAssign;
- },{"../object/keys":421,"./baseCopy":349}],346:[function(require,module,exports){
- var baseMatches = require('./baseMatches'),
- baseMatchesProperty = require('./baseMatchesProperty'),
- baseProperty = require('./baseProperty'),
- bindCallback = require('./bindCallback'),
- identity = require('../utility/identity');
- /**
- * The base implementation of `_.callback` which supports specifying the
- * number of arguments to provide to `func`.
- *
- * @private
- * @param {*} [func=_.identity] The value to convert to a callback.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {number} [argCount] The number of arguments to provide to `func`.
- * @returns {Function} Returns the callback.
- */
- function baseCallback(func, thisArg, argCount) {
- var type = typeof func;
- if (type == 'function') {
- return typeof thisArg == 'undefined'
- ? func
- : bindCallback(func, thisArg, argCount);
- }
- if (func == null) {
- return identity;
- }
- if (type == 'object') {
- return baseMatches(func);
- }
- return typeof thisArg == 'undefined'
- ? baseProperty(func + '')
- : baseMatchesProperty(func + '', thisArg);
- }
- module.exports = baseCallback;
- },{"../utility/identity":429,"./baseMatches":364,"./baseMatchesProperty":365,"./baseProperty":368,"./bindCallback":375}],347:[function(require,module,exports){
- var arrayCopy = require('./arrayCopy'),
- arrayEach = require('./arrayEach'),
- baseCopy = require('./baseCopy'),
- baseForOwn = require('./baseForOwn'),
- initCloneArray = require('./initCloneArray'),
- initCloneByTag = require('./initCloneByTag'),
- initCloneObject = require('./initCloneObject'),
- isArray = require('../lang/isArray'),
- isObject = require('../lang/isObject'),
- keys = require('../object/keys');
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- funcTag = '[object Function]',
- mapTag = '[object Map]',
- numberTag = '[object Number]',
- objectTag = '[object Object]',
- regexpTag = '[object RegExp]',
- setTag = '[object Set]',
- stringTag = '[object String]',
- weakMapTag = '[object WeakMap]';
- var arrayBufferTag = '[object ArrayBuffer]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
- /** Used to identify `toStringTag` values supported by `_.clone`. */
- var cloneableTags = {};
- cloneableTags[argsTag] = cloneableTags[arrayTag] =
- cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
- cloneableTags[dateTag] = cloneableTags[float32Tag] =
- cloneableTags[float64Tag] = cloneableTags[int8Tag] =
- cloneableTags[int16Tag] = cloneableTags[int32Tag] =
- cloneableTags[numberTag] = cloneableTags[objectTag] =
- cloneableTags[regexpTag] = cloneableTags[stringTag] =
- cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
- cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
- cloneableTags[errorTag] = cloneableTags[funcTag] =
- cloneableTags[mapTag] = cloneableTags[setTag] =
- cloneableTags[weakMapTag] = false;
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * The base implementation of `_.clone` without support for argument juggling
- * and `this` binding `customizer` functions.
- *
- * @private
- * @param {*} value The value to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @param {Function} [customizer] The function to customize cloning values.
- * @param {string} [key] The key of `value`.
- * @param {Object} [object] The object `value` belongs to.
- * @param {Array} [stackA=[]] Tracks traversed source objects.
- * @param {Array} [stackB=[]] Associates clones with source counterparts.
- * @returns {*} Returns the cloned value.
- */
- function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
- var result;
- if (customizer) {
- result = object ? customizer(value, key, object) : customizer(value);
- }
- if (typeof result != 'undefined') {
- return result;
- }
- if (!isObject(value)) {
- return value;
- }
- var isArr = isArray(value);
- if (isArr) {
- result = initCloneArray(value);
- if (!isDeep) {
- return arrayCopy(value, result);
- }
- } else {
- var tag = objToString.call(value),
- isFunc = tag == funcTag;
- if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
- result = initCloneObject(isFunc ? {} : value);
- if (!isDeep) {
- return baseCopy(value, result, keys(value));
- }
- } else {
- return cloneableTags[tag]
- ? initCloneByTag(value, tag, isDeep)
- : (object ? value : {});
- }
- }
- // Check for circular references and return corresponding clone.
- stackA || (stackA = []);
- stackB || (stackB = []);
- var length = stackA.length;
- while (length--) {
- if (stackA[length] == value) {
- return stackB[length];
- }
- }
- // Add the source value to the stack of traversed objects and associate it with its clone.
- stackA.push(value);
- stackB.push(result);
- // Recursively populate clone (susceptible to call stack limits).
- (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
- result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
- });
- return result;
- }
- module.exports = baseClone;
- },{"../lang/isArray":405,"../lang/isObject":411,"../object/keys":421,"./arrayCopy":339,"./arrayEach":340,"./baseCopy":349,"./baseForOwn":355,"./initCloneArray":390,"./initCloneByTag":391,"./initCloneObject":392}],348:[function(require,module,exports){
- /**
- * The base implementation of `compareAscending` which compares values and
- * sorts them in ascending order without guaranteeing a stable sort.
- *
- * @private
- * @param {*} value The value to compare to `other`.
- * @param {*} other The value to compare to `value`.
- * @returns {number} Returns the sort order indicator for `value`.
- */
- function baseCompareAscending(value, other) {
- if (value !== other) {
- var valIsReflexive = value === value,
- othIsReflexive = other === other;
- if (value > other || !valIsReflexive || (typeof value == 'undefined' && othIsReflexive)) {
- return 1;
- }
- if (value < other || !othIsReflexive || (typeof other == 'undefined' && valIsReflexive)) {
- return -1;
- }
- }
- return 0;
- }
- module.exports = baseCompareAscending;
- },{}],349:[function(require,module,exports){
- /**
- * Copies the properties of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy properties from.
- * @param {Object} [object={}] The object to copy properties to.
- * @param {Array} props The property names to copy.
- * @returns {Object} Returns `object`.
- */
- function baseCopy(source, object, props) {
- if (!props) {
- props = object;
- object = {};
- }
- var index = -1,
- length = props.length;
- while (++index < length) {
- var key = props[index];
- object[key] = source[key];
- }
- return object;
- }
- module.exports = baseCopy;
- },{}],350:[function(require,module,exports){
- var baseForOwn = require('./baseForOwn'),
- createBaseEach = require('./createBaseEach');
- /**
- * The base implementation of `_.forEach` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array|Object|string} Returns `collection`.
- */
- var baseEach = createBaseEach(baseForOwn);
- module.exports = baseEach;
- },{"./baseForOwn":355,"./createBaseEach":381}],351:[function(require,module,exports){
- var baseForOwnRight = require('./baseForOwnRight'),
- createBaseEach = require('./createBaseEach');
- /**
- * The base implementation of `_.forEachRight` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array|Object|string} Returns `collection`.
- */
- var baseEachRight = createBaseEach(baseForOwnRight, true);
- module.exports = baseEachRight;
- },{"./baseForOwnRight":356,"./createBaseEach":381}],352:[function(require,module,exports){
- var isArguments = require('../lang/isArguments'),
- isArray = require('../lang/isArray'),
- isLength = require('./isLength'),
- isObjectLike = require('./isObjectLike');
- /**
- * The base implementation of `_.flatten` with added support for restricting
- * flattening and specifying the start index.
- *
- * @private
- * @param {Array} array The array to flatten.
- * @param {boolean} isDeep Specify a deep flatten.
- * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
- * @returns {Array} Returns the new flattened array.
- */
- function baseFlatten(array, isDeep, isStrict) {
- var index = -1,
- length = array.length,
- resIndex = -1,
- result = [];
- while (++index < length) {
- var value = array[index];
- if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
- if (isDeep) {
- // Recursively flatten arrays (susceptible to call stack limits).
- value = baseFlatten(value, isDeep, isStrict);
- }
- var valIndex = -1,
- valLength = value.length;
- result.length += valLength;
- while (++valIndex < valLength) {
- result[++resIndex] = value[valIndex];
- }
- } else if (!isStrict) {
- result[++resIndex] = value;
- }
- }
- return result;
- }
- module.exports = baseFlatten;
- },{"../lang/isArguments":404,"../lang/isArray":405,"./isLength":395,"./isObjectLike":396}],353:[function(require,module,exports){
- var createBaseFor = require('./createBaseFor');
- /**
- * The base implementation of `baseForIn` and `baseForOwn` which iterates
- * over `object` properties returned by `keysFunc` invoking `iteratee` for
- * each property. Iterator functions may exit iteration early by explicitly
- * returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = createBaseFor();
- module.exports = baseFor;
- },{"./createBaseFor":382}],354:[function(require,module,exports){
- var baseFor = require('./baseFor'),
- keysIn = require('../object/keysIn');
- /**
- * The base implementation of `_.forIn` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForIn(object, iteratee) {
- return baseFor(object, iteratee, keysIn);
- }
- module.exports = baseForIn;
- },{"../object/keysIn":422,"./baseFor":353}],355:[function(require,module,exports){
- var baseFor = require('./baseFor'),
- keys = require('../object/keys');
- /**
- * The base implementation of `_.forOwn` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwn(object, iteratee) {
- return baseFor(object, iteratee, keys);
- }
- module.exports = baseForOwn;
- },{"../object/keys":421,"./baseFor":353}],356:[function(require,module,exports){
- var baseForRight = require('./baseForRight'),
- keys = require('../object/keys');
- /**
- * The base implementation of `_.forOwnRight` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwnRight(object, iteratee) {
- return baseForRight(object, iteratee, keys);
- }
- module.exports = baseForOwnRight;
- },{"../object/keys":421,"./baseForRight":357}],357:[function(require,module,exports){
- var createBaseFor = require('./createBaseFor');
- /**
- * This function is like `baseFor` except that it iterates over properties
- * in the opposite order.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseForRight = createBaseFor(true);
- module.exports = baseForRight;
- },{"./createBaseFor":382}],358:[function(require,module,exports){
- var indexOfNaN = require('./indexOfNaN');
- /**
- * The base implementation of `_.indexOf` without support for binary searches.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseIndexOf(array, value, fromIndex) {
- if (value !== value) {
- return indexOfNaN(array, fromIndex);
- }
- var index = fromIndex - 1,
- length = array.length;
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
- }
- module.exports = baseIndexOf;
- },{"./indexOfNaN":389}],359:[function(require,module,exports){
- var baseIsEqualDeep = require('./baseIsEqualDeep');
- /**
- * The base implementation of `_.isEqual` without support for `this` binding
- * `customizer` functions.
- *
- * @private
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @param {Function} [customizer] The function to customize comparing values.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA] Tracks traversed `value` objects.
- * @param {Array} [stackB] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- */
- function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
- // Exit early for identical values.
- if (value === other) {
- // Treat `+0` vs. `-0` as not equal.
- return value !== 0 || (1 / value == 1 / other);
- }
- var valType = typeof value,
- othType = typeof other;
- // Exit early for unlike primitive values.
- if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
- value == null || other == null) {
- // Return `false` unless both values are `NaN`.
- return value !== value && other !== other;
- }
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
- }
- module.exports = baseIsEqual;
- },{"./baseIsEqualDeep":360}],360:[function(require,module,exports){
- var equalArrays = require('./equalArrays'),
- equalByTag = require('./equalByTag'),
- equalObjects = require('./equalObjects'),
- isArray = require('../lang/isArray'),
- isTypedArray = require('../lang/isTypedArray');
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- funcTag = '[object Function]',
- objectTag = '[object Object]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * A specialized version of `baseIsEqual` for arrays and objects which performs
- * deep comparisons and tracks traversed objects enabling objects with circular
- * references to be compared.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparing objects.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA=[]] Tracks traversed `value` objects.
- * @param {Array} [stackB=[]] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
- var objIsArr = isArray(object),
- othIsArr = isArray(other),
- objTag = arrayTag,
- othTag = arrayTag;
- if (!objIsArr) {
- objTag = objToString.call(object);
- if (objTag == argsTag) {
- objTag = objectTag;
- } else if (objTag != objectTag) {
- objIsArr = isTypedArray(object);
- }
- }
- if (!othIsArr) {
- othTag = objToString.call(other);
- if (othTag == argsTag) {
- othTag = objectTag;
- } else if (othTag != objectTag) {
- othIsArr = isTypedArray(other);
- }
- }
- var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)),
- othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)),
- isSameTag = objTag == othTag;
- if (isSameTag && !(objIsArr || objIsObj)) {
- return equalByTag(object, other, objTag);
- }
- if (isLoose) {
- if (!isSameTag && !(objIsObj && othIsObj)) {
- return false;
- }
- } else {
- var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
- othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
- if (valWrapped || othWrapped) {
- return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
- }
- if (!isSameTag) {
- return false;
- }
- }
- // Assume cyclic values are equal.
- // For more information on detecting circular references see https://es5.github.io/#JO.
- stackA || (stackA = []);
- stackB || (stackB = []);
- var length = stackA.length;
- while (length--) {
- if (stackA[length] == object) {
- return stackB[length] == other;
- }
- }
- // Add `object` and `other` to the stack of traversed objects.
- stackA.push(object);
- stackB.push(other);
- var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
- stackA.pop();
- stackB.pop();
- return result;
- }
- module.exports = baseIsEqualDeep;
- },{"../lang/isArray":405,"../lang/isTypedArray":415,"./equalArrays":386,"./equalByTag":387,"./equalObjects":388}],361:[function(require,module,exports){
- /**
- * The base implementation of `_.isFunction` without support for environments
- * with incorrect `typeof` results.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- */
- function baseIsFunction(value) {
- // Avoid a Chakra JIT bug in compatibility modes of IE 11.
- // See https://github.com/jashkenas/underscore/issues/1621 for more details.
- return typeof value == 'function' || false;
- }
- module.exports = baseIsFunction;
- },{}],362:[function(require,module,exports){
- var baseIsEqual = require('./baseIsEqual');
- /**
- * The base implementation of `_.isMatch` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Object} object The object to inspect.
- * @param {Array} props The source property names to match.
- * @param {Array} values The source values to match.
- * @param {Array} strictCompareFlags Strict comparison flags for source values.
- * @param {Function} [customizer] The function to customize comparing objects.
- * @returns {boolean} Returns `true` if `object` is a match, else `false`.
- */
- function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
- var index = -1,
- length = props.length,
- noCustomizer = !customizer;
- while (++index < length) {
- if ((noCustomizer && strictCompareFlags[index])
- ? values[index] !== object[props[index]]
- : !(props[index] in object)
- ) {
- return false;
- }
- }
- index = -1;
- while (++index < length) {
- var key = props[index],
- objValue = object[key],
- srcValue = values[index];
- if (noCustomizer && strictCompareFlags[index]) {
- var result = typeof objValue != 'undefined' || (key in object);
- } else {
- result = customizer ? customizer(objValue, srcValue, key) : undefined;
- if (typeof result == 'undefined') {
- result = baseIsEqual(srcValue, objValue, customizer, true);
- }
- }
- if (!result) {
- return false;
- }
- }
- return true;
- }
- module.exports = baseIsMatch;
- },{"./baseIsEqual":359}],363:[function(require,module,exports){
- var baseEach = require('./baseEach');
- /**
- * The base implementation of `_.map` without support for callback shorthands
- * and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function baseMap(collection, iteratee) {
- var result = [];
- baseEach(collection, function(value, key, collection) {
- result.push(iteratee(value, key, collection));
- });
- return result;
- }
- module.exports = baseMap;
- },{"./baseEach":350}],364:[function(require,module,exports){
- var baseIsMatch = require('./baseIsMatch'),
- constant = require('../utility/constant'),
- isStrictComparable = require('./isStrictComparable'),
- keys = require('../object/keys'),
- toObject = require('./toObject');
- /**
- * The base implementation of `_.matches` which does not clone `source`.
- *
- * @private
- * @param {Object} source The object of property values to match.
- * @returns {Function} Returns the new function.
- */
- function baseMatches(source) {
- var props = keys(source),
- length = props.length;
- if (!length) {
- return constant(true);
- }
- if (length == 1) {
- var key = props[0],
- value = source[key];
- if (isStrictComparable(value)) {
- return function(object) {
- return object != null && object[key] === value &&
- (typeof value != 'undefined' || (key in toObject(object)));
- };
- }
- }
- var values = Array(length),
- strictCompareFlags = Array(length);
- while (length--) {
- value = source[props[length]];
- values[length] = value;
- strictCompareFlags[length] = isStrictComparable(value);
- }
- return function(object) {
- return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
- };
- }
- module.exports = baseMatches;
- },{"../object/keys":421,"../utility/constant":428,"./baseIsMatch":362,"./isStrictComparable":397,"./toObject":401}],365:[function(require,module,exports){
- var baseIsEqual = require('./baseIsEqual'),
- isStrictComparable = require('./isStrictComparable'),
- toObject = require('./toObject');
- /**
- * The base implementation of `_.matchesProperty` which does not coerce `key`
- * to a string.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @param {*} value The value to compare.
- * @returns {Function} Returns the new function.
- */
- function baseMatchesProperty(key, value) {
- if (isStrictComparable(value)) {
- return function(object) {
- return object != null && object[key] === value &&
- (typeof value != 'undefined' || (key in toObject(object)));
- };
- }
- return function(object) {
- return object != null && baseIsEqual(value, object[key], null, true);
- };
- }
- module.exports = baseMatchesProperty;
- },{"./baseIsEqual":359,"./isStrictComparable":397,"./toObject":401}],366:[function(require,module,exports){
- var arrayEach = require('./arrayEach'),
- baseForOwn = require('./baseForOwn'),
- baseMergeDeep = require('./baseMergeDeep'),
- isArray = require('../lang/isArray'),
- isLength = require('./isLength'),
- isObject = require('../lang/isObject'),
- isObjectLike = require('./isObjectLike'),
- isTypedArray = require('../lang/isTypedArray');
- /**
- * The base implementation of `_.merge` without support for argument juggling,
- * multiple sources, and `this` binding `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {Function} [customizer] The function to customize merging properties.
- * @param {Array} [stackA=[]] Tracks traversed source objects.
- * @param {Array} [stackB=[]] Associates values with source counterparts.
- * @returns {Object} Returns the destination object.
- */
- function baseMerge(object, source, customizer, stackA, stackB) {
- if (!isObject(object)) {
- return object;
- }
- var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
- (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) {
- if (isObjectLike(srcValue)) {
- stackA || (stackA = []);
- stackB || (stackB = []);
- return baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
- }
- var value = object[key],
- result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
- isCommon = typeof result == 'undefined';
- if (isCommon) {
- result = srcValue;
- }
- if ((isSrcArr || typeof result != 'undefined') &&
- (isCommon || (result === result ? (result !== value) : (value === value)))) {
- object[key] = result;
- }
- });
- return object;
- }
- module.exports = baseMerge;
- },{"../lang/isArray":405,"../lang/isObject":411,"../lang/isTypedArray":415,"./arrayEach":340,"./baseForOwn":355,"./baseMergeDeep":367,"./isLength":395,"./isObjectLike":396}],367:[function(require,module,exports){
- var arrayCopy = require('./arrayCopy'),
- isArguments = require('../lang/isArguments'),
- isArray = require('../lang/isArray'),
- isLength = require('./isLength'),
- isPlainObject = require('../lang/isPlainObject'),
- isTypedArray = require('../lang/isTypedArray'),
- toPlainObject = require('../lang/toPlainObject');
- /**
- * A specialized version of `baseMerge` for arrays and objects which performs
- * deep merges and tracks traversed objects enabling objects with circular
- * references to be merged.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {string} key The key of the value to merge.
- * @param {Function} mergeFunc The function to merge values.
- * @param {Function} [customizer] The function to customize merging properties.
- * @param {Array} [stackA=[]] Tracks traversed source objects.
- * @param {Array} [stackB=[]] Associates values with source counterparts.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
- var length = stackA.length,
- srcValue = source[key];
- while (length--) {
- if (stackA[length] == srcValue) {
- object[key] = stackB[length];
- return;
- }
- }
- var value = object[key],
- result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
- isCommon = typeof result == 'undefined';
- if (isCommon) {
- result = srcValue;
- if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
- result = isArray(value)
- ? value
- : ((value && value.length) ? arrayCopy(value) : []);
- }
- else if (isPlainObject(srcValue) || isArguments(srcValue)) {
- result = isArguments(value)
- ? toPlainObject(value)
- : (isPlainObject(value) ? value : {});
- }
- else {
- isCommon = false;
- }
- }
- // Add the source value to the stack of traversed objects and associate
- // it with its merged value.
- stackA.push(srcValue);
- stackB.push(result);
- if (isCommon) {
- // Recursively merge objects and arrays (susceptible to call stack limits).
- object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
- } else if (result === result ? (result !== value) : (value === value)) {
- object[key] = result;
- }
- }
- module.exports = baseMergeDeep;
- },{"../lang/isArguments":404,"../lang/isArray":405,"../lang/isPlainObject":412,"../lang/isTypedArray":415,"../lang/toPlainObject":416,"./arrayCopy":339,"./isLength":395}],368:[function(require,module,exports){
- /**
- * The base implementation of `_.property` which does not coerce `key` to a string.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
- module.exports = baseProperty;
- },{}],369:[function(require,module,exports){
- /**
- * The base implementation of `_.reduce` and `_.reduceRight` without support
- * for callback shorthands and `this` binding, which iterates over `collection`
- * using the provided `eachFunc`.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {*} accumulator The initial value.
- * @param {boolean} initFromCollection Specify using the first or last element
- * of `collection` as the initial value.
- * @param {Function} eachFunc The function to iterate over `collection`.
- * @returns {*} Returns the accumulated value.
- */
- function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
- eachFunc(collection, function(value, index, collection) {
- accumulator = initFromCollection
- ? (initFromCollection = false, value)
- : iteratee(accumulator, value, index, collection);
- });
- return accumulator;
- }
- module.exports = baseReduce;
- },{}],370:[function(require,module,exports){
- var baseEach = require('./baseEach');
- /**
- * The base implementation of `_.some` without support for callback shorthands
- * and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- */
- function baseSome(collection, predicate) {
- var result;
- baseEach(collection, function(value, index, collection) {
- result = predicate(value, index, collection);
- return !result;
- });
- return !!result;
- }
- module.exports = baseSome;
- },{"./baseEach":350}],371:[function(require,module,exports){
- /**
- * The base implementation of `_.sortBy` which uses `comparer` to define
- * the sort order of `array` and replaces criteria objects with their
- * corresponding values.
- *
- * @private
- * @param {Array} array The array to sort.
- * @param {Function} comparer The function to define sort order.
- * @returns {Array} Returns `array`.
- */
- function baseSortBy(array, comparer) {
- var length = array.length;
- array.sort(comparer);
- while (length--) {
- array[length] = array[length].value;
- }
- return array;
- }
- module.exports = baseSortBy;
- },{}],372:[function(require,module,exports){
- /**
- * Converts `value` to a string if it is not one. An empty string is returned
- * for `null` or `undefined` values.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- if (typeof value == 'string') {
- return value;
- }
- return value == null ? '' : (value + '');
- }
- module.exports = baseToString;
- },{}],373:[function(require,module,exports){
- var baseIndexOf = require('./baseIndexOf'),
- cacheIndexOf = require('./cacheIndexOf'),
- createCache = require('./createCache');
- /**
- * The base implementation of `_.uniq` without support for callback shorthands
- * and `this` binding.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {Function} [iteratee] The function invoked per iteration.
- * @returns {Array} Returns the new duplicate-value-free array.
- */
- function baseUniq(array, iteratee) {
- var index = -1,
- indexOf = baseIndexOf,
- length = array.length,
- isCommon = true,
- isLarge = isCommon && length >= 200,
- seen = isLarge ? createCache() : null,
- result = [];
- if (seen) {
- indexOf = cacheIndexOf;
- isCommon = false;
- } else {
- isLarge = false;
- seen = iteratee ? [] : result;
- }
- outer:
- while (++index < length) {
- var value = array[index],
- computed = iteratee ? iteratee(value, index, array) : value;
- if (isCommon && value === value) {
- var seenIndex = seen.length;
- while (seenIndex--) {
- if (seen[seenIndex] === computed) {
- continue outer;
- }
- }
- if (iteratee) {
- seen.push(computed);
- }
- result.push(value);
- }
- else if (indexOf(seen, computed, 0) < 0) {
- if (iteratee || isLarge) {
- seen.push(computed);
- }
- result.push(value);
- }
- }
- return result;
- }
- module.exports = baseUniq;
- },{"./baseIndexOf":358,"./cacheIndexOf":377,"./createCache":383}],374:[function(require,module,exports){
- /**
- * The base implementation of `_.values` and `_.valuesIn` which creates an
- * array of `object` property values corresponding to the property names
- * returned by `keysFunc`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array} props The property names to get values for.
- * @returns {Object} Returns the array of property values.
- */
- function baseValues(object, props) {
- var index = -1,
- length = props.length,
- result = Array(length);
- while (++index < length) {
- result[index] = object[props[index]];
- }
- return result;
- }
- module.exports = baseValues;
- },{}],375:[function(require,module,exports){
- var identity = require('../utility/identity');
- /**
- * A specialized version of `baseCallback` which only supports `this` binding
- * and specifying the number of arguments to provide to `func`.
- *
- * @private
- * @param {Function} func The function to bind.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {number} [argCount] The number of arguments to provide to `func`.
- * @returns {Function} Returns the callback.
- */
- function bindCallback(func, thisArg, argCount) {
- if (typeof func != 'function') {
- return identity;
- }
- if (typeof thisArg == 'undefined') {
- return func;
- }
- switch (argCount) {
- case 1: return function(value) {
- return func.call(thisArg, value);
- };
- case 3: return function(value, index, collection) {
- return func.call(thisArg, value, index, collection);
- };
- case 4: return function(accumulator, value, index, collection) {
- return func.call(thisArg, accumulator, value, index, collection);
- };
- case 5: return function(value, other, key, object, source) {
- return func.call(thisArg, value, other, key, object, source);
- };
- }
- return function() {
- return func.apply(thisArg, arguments);
- };
- }
- module.exports = bindCallback;
- },{"../utility/identity":429}],376:[function(require,module,exports){
- (function (global){
- var constant = require('../utility/constant'),
- isNative = require('../lang/isNative');
- /** Native method references. */
- var ArrayBuffer = isNative(ArrayBuffer = global.ArrayBuffer) && ArrayBuffer,
- bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
- floor = Math.floor,
- Uint8Array = isNative(Uint8Array = global.Uint8Array) && Uint8Array;
- /** Used to clone array buffers. */
- var Float64Array = (function() {
- // Safari 5 errors when using an array buffer to initialize a typed array
- // where the array buffer's `byteLength` is not a multiple of the typed
- // array's `BYTES_PER_ELEMENT`.
- try {
- var func = isNative(func = global.Float64Array) && func,
- result = new func(new ArrayBuffer(10), 0, 1) && func;
- } catch(e) {}
- return result;
- }());
- /** Used as the size, in bytes, of each `Float64Array` element. */
- var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
- /**
- * Creates a clone of the given array buffer.
- *
- * @private
- * @param {ArrayBuffer} buffer The array buffer to clone.
- * @returns {ArrayBuffer} Returns the cloned array buffer.
- */
- function bufferClone(buffer) {
- return bufferSlice.call(buffer, 0);
- }
- if (!bufferSlice) {
- // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`.
- bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
- var byteLength = buffer.byteLength,
- floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
- offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
- result = new ArrayBuffer(byteLength);
- if (floatLength) {
- var view = new Float64Array(result, 0, floatLength);
- view.set(new Float64Array(buffer, 0, floatLength));
- }
- if (byteLength != offset) {
- view = new Uint8Array(result, offset);
- view.set(new Uint8Array(buffer, offset));
- }
- return result;
- };
- }
- module.exports = bufferClone;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"../lang/isNative":409,"../utility/constant":428}],377:[function(require,module,exports){
- var isObject = require('../lang/isObject');
- /**
- * Checks if `value` is in `cache` mimicking the return signature of
- * `_.indexOf` by returning `0` if the value is found, else `-1`.
- *
- * @private
- * @param {Object} cache The cache to search.
- * @param {*} value The value to search for.
- * @returns {number} Returns `0` if `value` is found, else `-1`.
- */
- function cacheIndexOf(cache, value) {
- var data = cache.data,
- result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
- return result ? 0 : -1;
- }
- module.exports = cacheIndexOf;
- },{"../lang/isObject":411}],378:[function(require,module,exports){
- var isObject = require('../lang/isObject');
- /**
- * Adds `value` to the cache.
- *
- * @private
- * @name push
- * @memberOf SetCache
- * @param {*} value The value to cache.
- */
- function cachePush(value) {
- var data = this.data;
- if (typeof value == 'string' || isObject(value)) {
- data.set.add(value);
- } else {
- data.hash[value] = true;
- }
- }
- module.exports = cachePush;
- },{"../lang/isObject":411}],379:[function(require,module,exports){
- var baseCompareAscending = require('./baseCompareAscending');
- /**
- * Used by `_.sortBy` to compare transformed elements of a collection and stable
- * sort them in ascending order.
- *
- * @private
- * @param {Object} object The object to compare to `other`.
- * @param {Object} other The object to compare to `object`.
- * @returns {number} Returns the sort order indicator for `object`.
- */
- function compareAscending(object, other) {
- return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);
- }
- module.exports = compareAscending;
- },{"./baseCompareAscending":348}],380:[function(require,module,exports){
- var bindCallback = require('./bindCallback'),
- isIterateeCall = require('./isIterateeCall');
- /**
- * Creates a function that assigns properties of source object(s) to a given
- * destination object.
- *
- * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
- *
- * @private
- * @param {Function} assigner The function to assign values.
- * @returns {Function} Returns the new assigner function.
- */
- function createAssigner(assigner) {
- return function() {
- var args = arguments,
- length = args.length,
- object = args[0];
- if (length < 2 || object == null) {
- return object;
- }
- var customizer = args[length - 2],
- thisArg = args[length - 1],
- guard = args[3];
- if (length > 3 && typeof customizer == 'function') {
- customizer = bindCallback(customizer, thisArg, 5);
- length -= 2;
- } else {
- customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null;
- length -= (customizer ? 1 : 0);
- }
- if (guard && isIterateeCall(args[1], args[2], guard)) {
- customizer = length == 3 ? null : customizer;
- length = 2;
- }
- var index = 0;
- while (++index < length) {
- var source = args[index];
- if (source) {
- assigner(object, source, customizer);
- }
- }
- return object;
- };
- }
- module.exports = createAssigner;
- },{"./bindCallback":375,"./isIterateeCall":394}],381:[function(require,module,exports){
- var isLength = require('./isLength'),
- toObject = require('./toObject');
- /**
- * Creates a `baseEach` or `baseEachRight` function.
- *
- * @private
- * @param {Function} eachFunc The function to iterate over a collection.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseEach(eachFunc, fromRight) {
- return function(collection, iteratee) {
- var length = collection ? collection.length : 0;
- if (!isLength(length)) {
- return eachFunc(collection, iteratee);
- }
- var index = fromRight ? length : -1,
- iterable = toObject(collection);
- while ((fromRight ? index-- : ++index < length)) {
- if (iteratee(iterable[index], index, iterable) === false) {
- break;
- }
- }
- return collection;
- };
- }
- module.exports = createBaseEach;
- },{"./isLength":395,"./toObject":401}],382:[function(require,module,exports){
- var toObject = require('./toObject');
- /**
- * Creates a base function for `_.forIn` or `_.forInRight`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var iterable = toObject(object),
- props = keysFunc(object),
- length = props.length,
- index = fromRight ? length : -1;
- while ((fromRight ? index-- : ++index < length)) {
- var key = props[index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
- }
- }
- return object;
- };
- }
- module.exports = createBaseFor;
- },{"./toObject":401}],383:[function(require,module,exports){
- (function (global){
- var SetCache = require('./SetCache'),
- constant = require('../utility/constant'),
- isNative = require('../lang/isNative');
- /** Native method references. */
- var Set = isNative(Set = global.Set) && Set;
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate;
- /**
- * Creates a `Set` cache object to optimize linear searches of large arrays.
- *
- * @private
- * @param {Array} [values] The values to cache.
- * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
- */
- var createCache = !(nativeCreate && Set) ? constant(null) : function(values) {
- return new SetCache(values);
- };
- module.exports = createCache;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"../lang/isNative":409,"../utility/constant":428,"./SetCache":338}],384:[function(require,module,exports){
- var bindCallback = require('./bindCallback'),
- isArray = require('../lang/isArray');
- /**
- * Creates a function for `_.forEach` or `_.forEachRight`.
- *
- * @private
- * @param {Function} arrayFunc The function to iterate over an array.
- * @param {Function} eachFunc The function to iterate over a collection.
- * @returns {Function} Returns the new each function.
- */
- function createForEach(arrayFunc, eachFunc) {
- return function(collection, iteratee, thisArg) {
- return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
- ? arrayFunc(collection, iteratee)
- : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
- };
- }
- module.exports = createForEach;
- },{"../lang/isArray":405,"./bindCallback":375}],385:[function(require,module,exports){
- var baseCallback = require('./baseCallback'),
- baseReduce = require('./baseReduce'),
- isArray = require('../lang/isArray');
- /**
- * Creates a function for `_.reduce` or `_.reduceRight`.
- *
- * @private
- * @param {Function} arrayFunc The function to iterate over an array.
- * @param {Function} eachFunc The function to iterate over a collection.
- * @returns {Function} Returns the new each function.
- */
- function createReduce(arrayFunc, eachFunc) {
- return function(collection, iteratee, accumulator, thisArg) {
- var initFromArray = arguments.length < 3;
- return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
- ? arrayFunc(collection, iteratee, accumulator, initFromArray)
- : baseReduce(collection, baseCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
- };
- }
- module.exports = createReduce;
- },{"../lang/isArray":405,"./baseCallback":346,"./baseReduce":369}],386:[function(require,module,exports){
- /**
- * A specialized version of `baseIsEqualDeep` for arrays with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Array} array The array to compare.
- * @param {Array} other The other array to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparing arrays.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA] Tracks traversed `value` objects.
- * @param {Array} [stackB] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
- */
- function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
- var index = -1,
- arrLength = array.length,
- othLength = other.length,
- result = true;
- if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
- return false;
- }
- // Deep compare the contents, ignoring non-numeric properties.
- while (result && ++index < arrLength) {
- var arrValue = array[index],
- othValue = other[index];
- result = undefined;
- if (customizer) {
- result = isLoose
- ? customizer(othValue, arrValue, index)
- : customizer(arrValue, othValue, index);
- }
- if (typeof result == 'undefined') {
- // Recursively compare arrays (susceptible to call stack limits).
- if (isLoose) {
- var othIndex = othLength;
- while (othIndex--) {
- othValue = other[othIndex];
- result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
- if (result) {
- break;
- }
- }
- } else {
- result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
- }
- }
- }
- return !!result;
- }
- module.exports = equalArrays;
- },{}],387:[function(require,module,exports){
- /** `Object#toString` result references. */
- var boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- numberTag = '[object Number]',
- regexpTag = '[object RegExp]',
- stringTag = '[object String]';
- /**
- * A specialized version of `baseIsEqualDeep` for comparing objects of
- * the same `toStringTag`.
- *
- * **Note:** This function only supports comparing values with tags of
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
- *
- * @private
- * @param {Object} value The object to compare.
- * @param {Object} other The other object to compare.
- * @param {string} tag The `toStringTag` of the objects to compare.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalByTag(object, other, tag) {
- switch (tag) {
- case boolTag:
- case dateTag:
- // Coerce dates and booleans to numbers, dates to milliseconds and booleans
- // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
- return +object == +other;
- case errorTag:
- return object.name == other.name && object.message == other.message;
- case numberTag:
- // Treat `NaN` vs. `NaN` as equal.
- return (object != +object)
- ? other != +other
- // But, treat `-0` vs. `+0` as not equal.
- : (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
- case regexpTag:
- case stringTag:
- // Coerce regexes to strings and treat strings primitives and string
- // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
- return object == (other + '');
- }
- return false;
- }
- module.exports = equalByTag;
- },{}],388:[function(require,module,exports){
- var keys = require('../object/keys');
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * A specialized version of `baseIsEqualDeep` for objects with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparing values.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA] Tracks traversed `value` objects.
- * @param {Array} [stackB] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
- var objProps = keys(object),
- objLength = objProps.length,
- othProps = keys(other),
- othLength = othProps.length;
- if (objLength != othLength && !isLoose) {
- return false;
- }
- var skipCtor = isLoose,
- index = -1;
- while (++index < objLength) {
- var key = objProps[index],
- result = isLoose ? key in other : hasOwnProperty.call(other, key);
- if (result) {
- var objValue = object[key],
- othValue = other[key];
- result = undefined;
- if (customizer) {
- result = isLoose
- ? customizer(othValue, objValue, key)
- : customizer(objValue, othValue, key);
- }
- if (typeof result == 'undefined') {
- // Recursively compare objects (susceptible to call stack limits).
- result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
- }
- }
- if (!result) {
- return false;
- }
- skipCtor || (skipCtor = key == 'constructor');
- }
- if (!skipCtor) {
- var objCtor = object.constructor,
- othCtor = other.constructor;
- // Non `Object` object instances with different constructors are not equal.
- if (objCtor != othCtor &&
- ('constructor' in object && 'constructor' in other) &&
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
- return false;
- }
- }
- return true;
- }
- module.exports = equalObjects;
- },{"../object/keys":421}],389:[function(require,module,exports){
- /**
- * Gets the index at which the first occurrence of `NaN` is found in `array`.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {number} fromIndex The index to search from.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched `NaN`, else `-1`.
- */
- function indexOfNaN(array, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 0 : -1);
- while ((fromRight ? index-- : ++index < length)) {
- var other = array[index];
- if (other !== other) {
- return index;
- }
- }
- return -1;
- }
- module.exports = indexOfNaN;
- },{}],390:[function(require,module,exports){
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Initializes an array clone.
- *
- * @private
- * @param {Array} array The array to clone.
- * @returns {Array} Returns the initialized clone.
- */
- function initCloneArray(array) {
- var length = array.length,
- result = new array.constructor(length);
- // Add array properties assigned by `RegExp#exec`.
- if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
- result.index = array.index;
- result.input = array.input;
- }
- return result;
- }
- module.exports = initCloneArray;
- },{}],391:[function(require,module,exports){
- var bufferClone = require('./bufferClone');
- /** `Object#toString` result references. */
- var boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- numberTag = '[object Number]',
- regexpTag = '[object RegExp]',
- stringTag = '[object String]';
- var arrayBufferTag = '[object ArrayBuffer]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
- /** Used to match `RegExp` flags from their coerced string values. */
- var reFlags = /\w*$/;
- /**
- * Initializes an object clone based on its `toStringTag`.
- *
- * **Note:** This function only supports cloning values with tags of
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
- *
- *
- * @private
- * @param {Object} object The object to clone.
- * @param {string} tag The `toStringTag` of the object to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Object} Returns the initialized clone.
- */
- function initCloneByTag(object, tag, isDeep) {
- var Ctor = object.constructor;
- switch (tag) {
- case arrayBufferTag:
- return bufferClone(object);
- case boolTag:
- case dateTag:
- return new Ctor(+object);
- case float32Tag: case float64Tag:
- case int8Tag: case int16Tag: case int32Tag:
- case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
- var buffer = object.buffer;
- return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
- case numberTag:
- case stringTag:
- return new Ctor(object);
- case regexpTag:
- var result = new Ctor(object.source, reFlags.exec(object));
- result.lastIndex = object.lastIndex;
- }
- return result;
- }
- module.exports = initCloneByTag;
- },{"./bufferClone":376}],392:[function(require,module,exports){
- /**
- * Initializes an object clone.
- *
- * @private
- * @param {Object} object The object to clone.
- * @returns {Object} Returns the initialized clone.
- */
- function initCloneObject(object) {
- var Ctor = object.constructor;
- if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
- Ctor = Object;
- }
- return new Ctor;
- }
- module.exports = initCloneObject;
- },{}],393:[function(require,module,exports){
- /**
- * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
- * of an array-like value.
- */
- var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- value = +value;
- length = length == null ? MAX_SAFE_INTEGER : length;
- return value > -1 && value % 1 == 0 && value < length;
- }
- module.exports = isIndex;
- },{}],394:[function(require,module,exports){
- var isIndex = require('./isIndex'),
- isLength = require('./isLength'),
- isObject = require('../lang/isObject');
- /**
- * Checks if the provided arguments are from an iteratee call.
- *
- * @private
- * @param {*} value The potential iteratee value argument.
- * @param {*} index The potential iteratee index or key argument.
- * @param {*} object The potential iteratee object argument.
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
- */
- function isIterateeCall(value, index, object) {
- if (!isObject(object)) {
- return false;
- }
- var type = typeof index;
- if (type == 'number') {
- var length = object.length,
- prereq = isLength(length) && isIndex(index, length);
- } else {
- prereq = type == 'string' && index in object;
- }
- if (prereq) {
- var other = object[index];
- return value === value ? (value === other) : (other !== other);
- }
- return false;
- }
- module.exports = isIterateeCall;
- },{"../lang/isObject":411,"./isIndex":393,"./isLength":395}],395:[function(require,module,exports){
- /**
- * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
- * of an array-like value.
- */
- var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
- */
- function isLength(value) {
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- module.exports = isLength;
- },{}],396:[function(require,module,exports){
- /**
- * Checks if `value` is object-like.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- */
- function isObjectLike(value) {
- return !!value && typeof value == 'object';
- }
- module.exports = isObjectLike;
- },{}],397:[function(require,module,exports){
- var isObject = require('../lang/isObject');
- /**
- * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` if suitable for strict
- * equality comparisons, else `false`.
- */
- function isStrictComparable(value) {
- return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
- }
- module.exports = isStrictComparable;
- },{"../lang/isObject":411}],398:[function(require,module,exports){
- var baseForIn = require('./baseForIn'),
- isObjectLike = require('./isObjectLike');
- /** `Object#toString` result references. */
- var objectTag = '[object Object]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * A fallback implementation of `_.isPlainObject` which checks if `value`
- * is an object created by the `Object` constructor or has a `[[Prototype]]`
- * of `null`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
- */
- function shimIsPlainObject(value) {
- var Ctor;
- // Exit early for non `Object` objects.
- if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
- (!hasOwnProperty.call(value, 'constructor') &&
- (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
- return false;
- }
- // IE < 9 iterates inherited properties before own properties. If the first
- // iterated property is an object's own property then there are no inherited
- // enumerable properties.
- var result;
- // In most environments an object's own properties are iterated before
- // its inherited properties. If the last iterated property is an object's
- // own property then there are no inherited enumerable properties.
- baseForIn(value, function(subValue, key) {
- result = key;
- });
- return typeof result == 'undefined' || hasOwnProperty.call(value, result);
- }
- module.exports = shimIsPlainObject;
- },{"./baseForIn":354,"./isObjectLike":396}],399:[function(require,module,exports){
- var isArguments = require('../lang/isArguments'),
- isArray = require('../lang/isArray'),
- isIndex = require('./isIndex'),
- isLength = require('./isLength'),
- keysIn = require('../object/keysIn'),
- support = require('../support');
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * A fallback implementation of `Object.keys` which creates an array of the
- * own enumerable property names of `object`.
- *
- * @private
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns the array of property names.
- */
- function shimKeys(object) {
- var props = keysIn(object),
- propsLength = props.length,
- length = propsLength && object.length;
- var allowIndexes = length && isLength(length) &&
- (isArray(object) || (support.nonEnumArgs && isArguments(object)));
- var index = -1,
- result = [];
- while (++index < propsLength) {
- var key = props[index];
- if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
- result.push(key);
- }
- }
- return result;
- }
- module.exports = shimKeys;
- },{"../lang/isArguments":404,"../lang/isArray":405,"../object/keysIn":422,"../support":427,"./isIndex":393,"./isLength":395}],400:[function(require,module,exports){
- /**
- * An implementation of `_.uniq` optimized for sorted arrays without support
- * for callback shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {Function} [iteratee] The function invoked per iteration.
- * @returns {Array} Returns the new duplicate-value-free array.
- */
- function sortedUniq(array, iteratee) {
- var seen,
- index = -1,
- length = array.length,
- resIndex = -1,
- result = [];
- while (++index < length) {
- var value = array[index],
- computed = iteratee ? iteratee(value, index, array) : value;
- if (!index || seen !== computed) {
- seen = computed;
- result[++resIndex] = value;
- }
- }
- return result;
- }
- module.exports = sortedUniq;
- },{}],401:[function(require,module,exports){
- var isObject = require('../lang/isObject');
- /**
- * Converts `value` to an object if it is not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Object} Returns the object.
- */
- function toObject(value) {
- return isObject(value) ? value : Object(value);
- }
- module.exports = toObject;
- },{"../lang/isObject":411}],402:[function(require,module,exports){
- var baseClone = require('../internal/baseClone'),
- bindCallback = require('../internal/bindCallback'),
- isIterateeCall = require('../internal/isIterateeCall');
- /**
- * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,
- * otherwise they are assigned by reference. If `customizer` is provided it is
- * invoked to produce the cloned values. If `customizer` returns `undefined`
- * cloning is handled by the method instead. The `customizer` is bound to
- * `thisArg` and invoked with two argument; (value [, index|key, object]).
- *
- * **Note:** This method is loosely based on the
- * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
- * The enumerable properties of `arguments` objects and objects created by
- * constructors other than `Object` are cloned to plain `Object` objects. An
- * empty object is returned for uncloneable values such as functions, DOM nodes,
- * Maps, Sets, and WeakMaps.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @param {Function} [customizer] The function to customize cloning values.
- * @param {*} [thisArg] The `this` binding of `customizer`.
- * @returns {*} Returns the cloned value.
- * @example
- *
- * var users = [
- * { 'user': 'barney' },
- * { 'user': 'fred' }
- * ];
- *
- * var shallow = _.clone(users);
- * shallow[0] === users[0];
- * // => true
- *
- * var deep = _.clone(users, true);
- * deep[0] === users[0];
- * // => false
- *
- * // using a customizer callback
- * var el = _.clone(document.body, function(value) {
- * if (_.isElement(value)) {
- * return value.cloneNode(false);
- * }
- * });
- *
- * el === document.body
- * // => false
- * el.nodeName
- * // => BODY
- * el.childNodes.length;
- * // => 0
- */
- function clone(value, isDeep, customizer, thisArg) {
- if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
- isDeep = false;
- }
- else if (typeof isDeep == 'function') {
- thisArg = customizer;
- customizer = isDeep;
- isDeep = false;
- }
- customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
- return baseClone(value, isDeep, customizer);
- }
- module.exports = clone;
- },{"../internal/baseClone":347,"../internal/bindCallback":375,"../internal/isIterateeCall":394}],403:[function(require,module,exports){
- var baseClone = require('../internal/baseClone'),
- bindCallback = require('../internal/bindCallback');
- /**
- * Creates a deep clone of `value`. If `customizer` is provided it is invoked
- * to produce the cloned values. If `customizer` returns `undefined` cloning
- * is handled by the method instead. The `customizer` is bound to `thisArg`
- * and invoked with two argument; (value [, index|key, object]).
- *
- * **Note:** This method is loosely based on the
- * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
- * The enumerable properties of `arguments` objects and objects created by
- * constructors other than `Object` are cloned to plain `Object` objects. An
- * empty object is returned for uncloneable values such as functions, DOM nodes,
- * Maps, Sets, and WeakMaps.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to deep clone.
- * @param {Function} [customizer] The function to customize cloning values.
- * @param {*} [thisArg] The `this` binding of `customizer`.
- * @returns {*} Returns the deep cloned value.
- * @example
- *
- * var users = [
- * { 'user': 'barney' },
- * { 'user': 'fred' }
- * ];
- *
- * var deep = _.cloneDeep(users);
- * deep[0] === users[0];
- * // => false
- *
- * // using a customizer callback
- * var el = _.cloneDeep(document.body, function(value) {
- * if (_.isElement(value)) {
- * return value.cloneNode(true);
- * }
- * });
- *
- * el === document.body
- * // => false
- * el.nodeName
- * // => BODY
- * el.childNodes.length;
- * // => 20
- */
- function cloneDeep(value, customizer, thisArg) {
- customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
- return baseClone(value, true, customizer);
- }
- module.exports = cloneDeep;
- },{"../internal/baseClone":347,"../internal/bindCallback":375}],404:[function(require,module,exports){
- var isLength = require('../internal/isLength'),
- isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as an `arguments` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- function isArguments(value) {
- var length = isObjectLike(value) ? value.length : undefined;
- return isLength(length) && objToString.call(value) == argsTag;
- }
- module.exports = isArguments;
- },{"../internal/isLength":395,"../internal/isObjectLike":396}],405:[function(require,module,exports){
- var isLength = require('../internal/isLength'),
- isNative = require('./isNative'),
- isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var arrayTag = '[object Array]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray;
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(function() { return arguments; }());
- * // => false
- */
- var isArray = nativeIsArray || function(value) {
- return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
- };
- module.exports = isArray;
- },{"../internal/isLength":395,"../internal/isObjectLike":396,"./isNative":409}],406:[function(require,module,exports){
- var isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var boolTag = '[object Boolean]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a boolean primitive or object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isBoolean(false);
- * // => true
- *
- * _.isBoolean(null);
- * // => false
- */
- function isBoolean(value) {
- return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag);
- }
- module.exports = isBoolean;
- },{"../internal/isObjectLike":396}],407:[function(require,module,exports){
- var isArguments = require('./isArguments'),
- isArray = require('./isArray'),
- isFunction = require('./isFunction'),
- isLength = require('../internal/isLength'),
- isObjectLike = require('../internal/isObjectLike'),
- isString = require('./isString'),
- keys = require('../object/keys');
- /**
- * Checks if `value` is empty. A value is considered empty unless it is an
- * `arguments` object, array, string, or jQuery-like collection with a length
- * greater than `0` or an object with own enumerable properties.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {Array|Object|string} value The value to inspect.
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
- * @example
- *
- * _.isEmpty(null);
- * // => true
- *
- * _.isEmpty(true);
- * // => true
- *
- * _.isEmpty(1);
- * // => true
- *
- * _.isEmpty([1, 2, 3]);
- * // => false
- *
- * _.isEmpty({ 'a': 1 });
- * // => false
- */
- function isEmpty(value) {
- if (value == null) {
- return true;
- }
- var length = value.length;
- if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
- (isObjectLike(value) && isFunction(value.splice)))) {
- return !length;
- }
- return !keys(value).length;
- }
- module.exports = isEmpty;
- },{"../internal/isLength":395,"../internal/isObjectLike":396,"../object/keys":421,"./isArguments":404,"./isArray":405,"./isFunction":408,"./isString":414}],408:[function(require,module,exports){
- (function (global){
- var baseIsFunction = require('../internal/baseIsFunction'),
- isNative = require('./isNative');
- /** `Object#toString` result references. */
- var funcTag = '[object Function]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /** Native method references. */
- var Uint8Array = isNative(Uint8Array = global.Uint8Array) && Uint8Array;
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in older versions of Chrome and Safari which return 'function' for regexes
- // and Safari 8 equivalents which return 'object' for typed array constructors.
- return objToString.call(value) == funcTag;
- };
- module.exports = isFunction;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"../internal/baseIsFunction":361,"./isNative":409}],409:[function(require,module,exports){
- var escapeRegExp = require('../string/escapeRegExp'),
- isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var funcTag = '[object Function]';
- /** Used to detect host constructors (Safari > 5). */
- var reHostCtor = /^\[object .+?Constructor\]$/;
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to resolve the decompiled source of functions. */
- var fnToString = Function.prototype.toString;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /** Used to detect if a method is native. */
- var reNative = RegExp('^' +
- escapeRegExp(objToString)
- .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
- /**
- * Checks if `value` is a native function.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
- * @example
- *
- * _.isNative(Array.prototype.push);
- * // => true
- *
- * _.isNative(_);
- * // => false
- */
- function isNative(value) {
- if (value == null) {
- return false;
- }
- if (objToString.call(value) == funcTag) {
- return reNative.test(fnToString.call(value));
- }
- return isObjectLike(value) && reHostCtor.test(value);
- }
- module.exports = isNative;
- },{"../internal/isObjectLike":396,"../string/escapeRegExp":425}],410:[function(require,module,exports){
- var isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var numberTag = '[object Number]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a `Number` primitive or object.
- *
- * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
- * as numbers, use the `_.isFinite` method.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isNumber(8.4);
- * // => true
- *
- * _.isNumber(NaN);
- * // => true
- *
- * _.isNumber('8.4');
- * // => false
- */
- function isNumber(value) {
- return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
- }
- module.exports = isNumber;
- },{"../internal/isObjectLike":396}],411:[function(require,module,exports){
- /**
- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(1);
- * // => false
- */
- function isObject(value) {
- // Avoid a V8 JIT bug in Chrome 19-20.
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
- var type = typeof value;
- return type == 'function' || (!!value && type == 'object');
- }
- module.exports = isObject;
- },{}],412:[function(require,module,exports){
- var isNative = require('./isNative'),
- shimIsPlainObject = require('../internal/shimIsPlainObject');
- /** `Object#toString` result references. */
- var objectTag = '[object Object]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /** Native method references. */
- var getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf;
- /**
- * Checks if `value` is a plain object, that is, an object created by the
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
- *
- * **Note:** This method assumes objects created by the `Object` constructor
- * have no inherited enumerable properties.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * }
- *
- * _.isPlainObject(new Foo);
- * // => false
- *
- * _.isPlainObject([1, 2, 3]);
- * // => false
- *
- * _.isPlainObject({ 'x': 0, 'y': 0 });
- * // => true
- *
- * _.isPlainObject(Object.create(null));
- * // => true
- */
- var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
- if (!(value && objToString.call(value) == objectTag)) {
- return false;
- }
- var valueOf = value.valueOf,
- objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
- return objProto
- ? (value == objProto || getPrototypeOf(value) == objProto)
- : shimIsPlainObject(value);
- };
- module.exports = isPlainObject;
- },{"../internal/shimIsPlainObject":398,"./isNative":409}],413:[function(require,module,exports){
- var isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var regexpTag = '[object RegExp]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a `RegExp` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isRegExp(/abc/);
- * // => true
- *
- * _.isRegExp('/abc/');
- * // => false
- */
- function isRegExp(value) {
- return (isObjectLike(value) && objToString.call(value) == regexpTag) || false;
- }
- module.exports = isRegExp;
- },{"../internal/isObjectLike":396}],414:[function(require,module,exports){
- var isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var stringTag = '[object String]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a `String` primitive or object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isString('abc');
- * // => true
- *
- * _.isString(1);
- * // => false
- */
- function isString(value) {
- return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
- }
- module.exports = isString;
- },{"../internal/isObjectLike":396}],415:[function(require,module,exports){
- var isLength = require('../internal/isLength'),
- isObjectLike = require('../internal/isObjectLike');
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- funcTag = '[object Function]',
- mapTag = '[object Map]',
- numberTag = '[object Number]',
- objectTag = '[object Object]',
- regexpTag = '[object RegExp]',
- setTag = '[object Set]',
- stringTag = '[object String]',
- weakMapTag = '[object WeakMap]';
- var arrayBufferTag = '[object ArrayBuffer]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
- typedArrayTags[uint32Tag] = true;
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
- typedArrayTags[dateTag] = typedArrayTags[errorTag] =
- typedArrayTags[funcTag] = typedArrayTags[mapTag] =
- typedArrayTags[numberTag] = typedArrayTags[objectTag] =
- typedArrayTags[regexpTag] = typedArrayTags[setTag] =
- typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- function isTypedArray(value) {
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
- }
- module.exports = isTypedArray;
- },{"../internal/isLength":395,"../internal/isObjectLike":396}],416:[function(require,module,exports){
- var baseCopy = require('../internal/baseCopy'),
- keysIn = require('../object/keysIn');
- /**
- * Converts `value` to a plain object flattening inherited enumerable
- * properties of `value` to own properties of the plain object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {Object} Returns the converted plain object.
- * @example
- *
- * function Foo() {
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.assign({ 'a': 1 }, new Foo);
- * // => { 'a': 1, 'b': 2 }
- *
- * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
- * // => { 'a': 1, 'b': 2, 'c': 3 }
- */
- function toPlainObject(value) {
- return baseCopy(value, keysIn(value));
- }
- module.exports = toPlainObject;
- },{"../internal/baseCopy":349,"../object/keysIn":422}],417:[function(require,module,exports){
- var baseAssign = require('../internal/baseAssign'),
- createAssigner = require('../internal/createAssigner');
- /**
- * Assigns own enumerable properties of source object(s) to the destination
- * object. Subsequent sources overwrite property assignments of previous sources.
- * If `customizer` is provided it is invoked to produce the assigned values.
- * The `customizer` is bound to `thisArg` and invoked with five arguments:
- * (objectValue, sourceValue, key, object, source).
- *
- * @static
- * @memberOf _
- * @alias extend
- * @category Object
- * @param {Object} object The destination object.
- * @param {...Object} [sources] The source objects.
- * @param {Function} [customizer] The function to customize assigning values.
- * @param {*} [thisArg] The `this` binding of `customizer`.
- * @returns {Object} Returns `object`.
- * @example
- *
- * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
- * // => { 'user': 'fred', 'age': 40 }
- *
- * // using a customizer callback
- * var defaults = _.partialRight(_.assign, function(value, other) {
- * return typeof value == 'undefined' ? other : value;
- * });
- *
- * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
- * // => { 'user': 'barney', 'age': 36 }
- */
- var assign = createAssigner(baseAssign);
- module.exports = assign;
- },{"../internal/baseAssign":345,"../internal/createAssigner":380}],418:[function(require,module,exports){
- var assign = require('./assign'),
- assignDefaults = require('../internal/assignDefaults'),
- restParam = require('../function/restParam');
- /**
- * Assigns own enumerable properties of source object(s) to the destination
- * object for all destination properties that resolve to `undefined`. Once a
- * property is set, additional values of the same property are ignored.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The destination object.
- * @param {...Object} [sources] The source objects.
- * @returns {Object} Returns `object`.
- * @example
- *
- * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
- * // => { 'user': 'barney', 'age': 36 }
- */
- var defaults = restParam(function(args) {
- var object = args[0];
- if (object == null) {
- return object;
- }
- args.push(assignDefaults);
- return assign.apply(undefined, args);
- });
- module.exports = defaults;
- },{"../function/restParam":337,"../internal/assignDefaults":344,"./assign":417}],419:[function(require,module,exports){
- module.exports = require('./assign');
- },{"./assign":417}],420:[function(require,module,exports){
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Checks if `key` exists as a direct property of `object` instead of an
- * inherited property.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to inspect.
- * @param {string} key The key to check.
- * @returns {boolean} Returns `true` if `key` is a direct property, else `false`.
- * @example
- *
- * var object = { 'a': 1, 'b': 2, 'c': 3 };
- *
- * _.has(object, 'b');
- * // => true
- */
- function has(object, key) {
- return object ? hasOwnProperty.call(object, key) : false;
- }
- module.exports = has;
- },{}],421:[function(require,module,exports){
- var isLength = require('../internal/isLength'),
- isNative = require('../lang/isNative'),
- isObject = require('../lang/isObject'),
- shimKeys = require('../internal/shimKeys');
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys)
- * for more details.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- var keys = !nativeKeys ? shimKeys : function(object) {
- if (object) {
- var Ctor = object.constructor,
- length = object.length;
- }
- if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
- (typeof object != 'function' && (length && isLength(length)))) {
- return shimKeys(object);
- }
- return isObject(object) ? nativeKeys(object) : [];
- };
- module.exports = keys;
- },{"../internal/isLength":395,"../internal/shimKeys":399,"../lang/isNative":409,"../lang/isObject":411}],422:[function(require,module,exports){
- var isArguments = require('../lang/isArguments'),
- isArray = require('../lang/isArray'),
- isIndex = require('../internal/isIndex'),
- isLength = require('../internal/isLength'),
- isObject = require('../lang/isObject'),
- support = require('../support');
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Creates an array of the own and inherited enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keysIn(new Foo);
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
- */
- function keysIn(object) {
- if (object == null) {
- return [];
- }
- if (!isObject(object)) {
- object = Object(object);
- }
- var length = object.length;
- length = (length && isLength(length) &&
- (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
- var Ctor = object.constructor,
- index = -1,
- isProto = typeof Ctor == 'function' && Ctor.prototype === object,
- result = Array(length),
- skipIndexes = length > 0;
- while (++index < length) {
- result[index] = (index + '');
- }
- for (var key in object) {
- if (!(skipIndexes && isIndex(key, length)) &&
- !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
- result.push(key);
- }
- }
- return result;
- }
- module.exports = keysIn;
- },{"../internal/isIndex":393,"../internal/isLength":395,"../lang/isArguments":404,"../lang/isArray":405,"../lang/isObject":411,"../support":427}],423:[function(require,module,exports){
- var baseMerge = require('../internal/baseMerge'),
- createAssigner = require('../internal/createAssigner');
- /**
- * Recursively merges own enumerable properties of the source object(s), that
- * don't resolve to `undefined` into the destination object. Subsequent sources
- * overwrite property assignments of previous sources. If `customizer` is
- * provided it is invoked to produce the merged values of the destination and
- * source properties. If `customizer` returns `undefined` merging is handled
- * by the method instead. The `customizer` is bound to `thisArg` and invoked
- * with five arguments: (objectValue, sourceValue, key, object, source).
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The destination object.
- * @param {...Object} [sources] The source objects.
- * @param {Function} [customizer] The function to customize merging properties.
- * @param {*} [thisArg] The `this` binding of `customizer`.
- * @returns {Object} Returns `object`.
- * @example
- *
- * var users = {
- * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
- * };
- *
- * var ages = {
- * 'data': [{ 'age': 36 }, { 'age': 40 }]
- * };
- *
- * _.merge(users, ages);
- * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
- *
- * // using a customizer callback
- * var object = {
- * 'fruits': ['apple'],
- * 'vegetables': ['beet']
- * };
- *
- * var other = {
- * 'fruits': ['banana'],
- * 'vegetables': ['carrot']
- * };
- *
- * _.merge(object, other, function(a, b) {
- * if (_.isArray(a)) {
- * return a.concat(b);
- * }
- * });
- * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
- */
- var merge = createAssigner(baseMerge);
- module.exports = merge;
- },{"../internal/baseMerge":366,"../internal/createAssigner":380}],424:[function(require,module,exports){
- var baseValues = require('../internal/baseValues'),
- keys = require('./keys');
- /**
- * Creates an array of the own enumerable property values of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property values.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.values(new Foo);
- * // => [1, 2] (iteration order is not guaranteed)
- *
- * _.values('hi');
- * // => ['h', 'i']
- */
- function values(object) {
- return baseValues(object, keys(object));
- }
- module.exports = values;
- },{"../internal/baseValues":374,"./keys":421}],425:[function(require,module,exports){
- var baseToString = require('../internal/baseToString');
- /**
- * Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).
- * In addition to special characters the forward slash is escaped to allow for
- * easier `eval` use and `Function` compilation.
- */
- var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
- reHasRegExpChars = RegExp(reRegExpChars.source);
- /**
- * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?",
- * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`.
- *
- * @static
- * @memberOf _
- * @category String
- * @param {string} [string=''] The string to escape.
- * @returns {string} Returns the escaped string.
- * @example
- *
- * _.escapeRegExp('[lodash](https://lodash.com/)');
- * // => '\[lodash\]\(https:\/\/lodash\.com\/\)'
- */
- function escapeRegExp(string) {
- string = baseToString(string);
- return (string && reHasRegExpChars.test(string))
- ? string.replace(reRegExpChars, '\\$&')
- : string;
- }
- module.exports = escapeRegExp;
- },{"../internal/baseToString":372}],426:[function(require,module,exports){
- var baseToString = require('../internal/baseToString');
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMin = Math.min;
- /**
- * Checks if `string` starts with the given target string.
- *
- * @static
- * @memberOf _
- * @category String
- * @param {string} [string=''] The string to search.
- * @param {string} [target] The string to search for.
- * @param {number} [position=0] The position to search from.
- * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`.
- * @example
- *
- * _.startsWith('abc', 'a');
- * // => true
- *
- * _.startsWith('abc', 'b');
- * // => false
- *
- * _.startsWith('abc', 'b', 1);
- * // => true
- */
- function startsWith(string, target, position) {
- string = baseToString(string);
- position = position == null
- ? 0
- : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
- return string.lastIndexOf(target, position) == position;
- }
- module.exports = startsWith;
- },{"../internal/baseToString":372}],427:[function(require,module,exports){
- (function (global){
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to detect DOM support. */
- var document = (document = global.window) && document.document;
- /** Native method references. */
- var propertyIsEnumerable = objectProto.propertyIsEnumerable;
- /**
- * An object environment feature flags.
- *
- * @static
- * @memberOf _
- * @type Object
- */
- var support = {};
- (function(x) {
- /**
- * Detect if functions can be decompiled by `Function#toString`
- * (all but Firefox OS certified apps, older Opera mobile browsers, and
- * the PlayStation 3; forced `false` for Windows 8 apps).
- *
- * @memberOf _.support
- * @type boolean
- */
- support.funcDecomp = /\bthis\b/.test(function() { return this; });
- /**
- * Detect if `Function#name` is supported (all but IE).
- *
- * @memberOf _.support
- * @type boolean
- */
- support.funcNames = typeof Function.name == 'string';
- /**
- * Detect if the DOM is supported.
- *
- * @memberOf _.support
- * @type boolean
- */
- try {
- support.dom = document.createDocumentFragment().nodeType === 11;
- } catch(e) {
- support.dom = false;
- }
- /**
- * Detect if `arguments` object indexes are non-enumerable.
- *
- * In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object
- * indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat
- * `arguments` object indexes as non-enumerable and fail `hasOwnProperty`
- * checks for indexes that exceed their function's formal parameters with
- * associated values of `0`.
- *
- * @memberOf _.support
- * @type boolean
- */
- try {
- support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
- } catch(e) {
- support.nonEnumArgs = true;
- }
- }(0, 0));
- module.exports = support;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{}],428:[function(require,module,exports){
- /**
- * Creates a function that returns `value`.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @param {*} value The value to return from the new function.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var object = { 'user': 'fred' };
- * var getter = _.constant(object);
- *
- * getter() === object;
- * // => true
- */
- function constant(value) {
- return function() {
- return value;
- };
- }
- module.exports = constant;
- },{}],429:[function(require,module,exports){
- /**
- * This method returns the first argument provided to it.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'user': 'fred' };
- *
- * _.identity(object) === object;
- * // => true
- */
- function identity(value) {
- return value;
- }
- module.exports = identity;
- },{}],430:[function(require,module,exports){
- (function (process){
- module.exports = minimatch
- minimatch.Minimatch = Minimatch
- var isWindows = false
- if (typeof process !== 'undefined' && process.platform === 'win32')
- isWindows = true
- var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
- , expand = require("brace-expansion")
- // any single thing other than /
- // don't need to escape / when using new RegExp()
- , qmark = "[^/]"
- // * => any number of characters
- , star = qmark + "*?"
- // ** when dots are allowed. Anything goes, except .. and .
- // not (^ or / followed by one or two dots followed by $ or /),
- // followed by anything, any number of times.
- , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?"
- // not a ^ or / followed by a dot,
- // followed by anything, any number of times.
- , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?"
- // characters that need to be escaped in RegExp.
- , reSpecials = charSet("().*{}+?[]^$\\!")
- // "abc" -> { a:true, b:true, c:true }
- function charSet (s) {
- return s.split("").reduce(function (set, c) {
- set[c] = true
- return set
- }, {})
- }
- // normalizes slashes.
- var slashSplit = /\/+/
- minimatch.filter = filter
- function filter (pattern, options) {
- options = options || {}
- return function (p, i, list) {
- return minimatch(p, pattern, options)
- }
- }
- function ext (a, b) {
- a = a || {}
- b = b || {}
- var t = {}
- Object.keys(b).forEach(function (k) {
- t[k] = b[k]
- })
- Object.keys(a).forEach(function (k) {
- t[k] = a[k]
- })
- return t
- }
- minimatch.defaults = function (def) {
- if (!def || !Object.keys(def).length) return minimatch
- var orig = minimatch
- var m = function minimatch (p, pattern, options) {
- return orig.minimatch(p, pattern, ext(def, options))
- }
- m.Minimatch = function Minimatch (pattern, options) {
- return new orig.Minimatch(pattern, ext(def, options))
- }
- return m
- }
- Minimatch.defaults = function (def) {
- if (!def || !Object.keys(def).length) return Minimatch
- return minimatch.defaults(def).Minimatch
- }
- function minimatch (p, pattern, options) {
- if (typeof pattern !== "string") {
- throw new TypeError("glob pattern string required")
- }
- if (!options) options = {}
- // shortcut: comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === "#") {
- return false
- }
- // "" only matches ""
- if (pattern.trim() === "") return p === ""
- return new Minimatch(pattern, options).match(p)
- }
- function Minimatch (pattern, options) {
- if (!(this instanceof Minimatch)) {
- return new Minimatch(pattern, options)
- }
- if (typeof pattern !== "string") {
- throw new TypeError("glob pattern string required")
- }
- if (!options) options = {}
- pattern = pattern.trim()
- // windows support: need to use /, not \
- if (isWindows)
- pattern = pattern.split("\\").join("/")
- this.options = options
- this.set = []
- this.pattern = pattern
- this.regexp = null
- this.negate = false
- this.comment = false
- this.empty = false
- // make the set of regexps etc.
- this.make()
- }
- Minimatch.prototype.debug = function() {}
- Minimatch.prototype.make = make
- function make () {
- // don't do it more than once.
- if (this._made) return
- var pattern = this.pattern
- var options = this.options
- // empty patterns and comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === "#") {
- this.comment = true
- return
- }
- if (!pattern) {
- this.empty = true
- return
- }
- // step 1: figure out negation, etc.
- this.parseNegate()
- // step 2: expand braces
- var set = this.globSet = this.braceExpand()
- if (options.debug) this.debug = console.error
- this.debug(this.pattern, set)
- // step 3: now we have a set, so turn each one into a series of path-portion
- // matching patterns.
- // These will be regexps, except in the case of "**", which is
- // set to the GLOBSTAR object for globstar behavior,
- // and will not contain any / characters
- set = this.globParts = set.map(function (s) {
- return s.split(slashSplit)
- })
- this.debug(this.pattern, set)
- // glob --> regexps
- set = set.map(function (s, si, set) {
- return s.map(this.parse, this)
- }, this)
- this.debug(this.pattern, set)
- // filter out everything that didn't compile properly.
- set = set.filter(function (s) {
- return -1 === s.indexOf(false)
- })
- this.debug(this.pattern, set)
- this.set = set
- }
- Minimatch.prototype.parseNegate = parseNegate
- function parseNegate () {
- var pattern = this.pattern
- , negate = false
- , options = this.options
- , negateOffset = 0
- if (options.nonegate) return
- for ( var i = 0, l = pattern.length
- ; i < l && pattern.charAt(i) === "!"
- ; i ++) {
- negate = !negate
- negateOffset ++
- }
- if (negateOffset) this.pattern = pattern.substr(negateOffset)
- this.negate = negate
- }
- // Brace expansion:
- // a{b,c}d -> abd acd
- // a{b,}c -> abc ac
- // a{0..3}d -> a0d a1d a2d a3d
- // a{b,c{d,e}f}g -> abg acdfg acefg
- // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
- //
- // Invalid sets are not expanded.
- // a{2..}b -> a{2..}b
- // a{b}c -> a{b}c
- minimatch.braceExpand = function (pattern, options) {
- return braceExpand(pattern, options)
- }
- Minimatch.prototype.braceExpand = braceExpand
- function braceExpand (pattern, options) {
- if (!options) {
- if (this instanceof Minimatch)
- options = this.options
- else
- options = {}
- }
- pattern = typeof pattern === "undefined"
- ? this.pattern : pattern
- if (typeof pattern === "undefined") {
- throw new Error("undefined pattern")
- }
- if (options.nobrace ||
- !pattern.match(/\{.*\}/)) {
- // shortcut. no need to expand.
- return [pattern]
- }
- return expand(pattern)
- }
- // parse a component of the expanded set.
- // At this point, no pattern may contain "/" in it
- // so we're going to return a 2d array, where each entry is the full
- // pattern, split on '/', and then turned into a regular expression.
- // A regexp is made at the end which joins each array with an
- // escaped /, and another full one which joins each regexp with |.
- //
- // Following the lead of Bash 4.1, note that "**" only has special meaning
- // when it is the *only* thing in a path portion. Otherwise, any series
- // of * is equivalent to a single *. Globstar behavior is enabled by
- // default, and can be disabled by setting options.noglobstar.
- Minimatch.prototype.parse = parse
- var SUBPARSE = {}
- function parse (pattern, isSub) {
- var options = this.options
- // shortcuts
- if (!options.noglobstar && pattern === "**") return GLOBSTAR
- if (pattern === "") return ""
- var re = ""
- , hasMagic = !!options.nocase
- , escaping = false
- // ? => one single character
- , patternListStack = []
- , plType
- , stateChar
- , inClass = false
- , reClassStart = -1
- , classStart = -1
- // . and .. never match anything that doesn't start with .,
- // even when options.dot is set.
- , patternStart = pattern.charAt(0) === "." ? "" // anything
- // not (start or / followed by . or .. followed by / or end)
- : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))"
- : "(?!\\.)"
- , self = this
- function clearStateChar () {
- if (stateChar) {
- // we had some state-tracking character
- // that wasn't consumed by this pass.
- switch (stateChar) {
- case "*":
- re += star
- hasMagic = true
- break
- case "?":
- re += qmark
- hasMagic = true
- break
- default:
- re += "\\"+stateChar
- break
- }
- self.debug('clearStateChar %j %j', stateChar, re)
- stateChar = false
- }
- }
- for ( var i = 0, len = pattern.length, c
- ; (i < len) && (c = pattern.charAt(i))
- ; i ++ ) {
- this.debug("%s\t%s %s %j", pattern, i, re, c)
- // skip over any that are escaped.
- if (escaping && reSpecials[c]) {
- re += "\\" + c
- escaping = false
- continue
- }
- SWITCH: switch (c) {
- case "/":
- // completely not allowed, even escaped.
- // Should already be path-split by now.
- return false
- case "\\":
- clearStateChar()
- escaping = true
- continue
- // the various stateChar values
- // for the "extglob" stuff.
- case "?":
- case "*":
- case "+":
- case "@":
- case "!":
- this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c)
- // all of those are literals inside a class, except that
- // the glob [!a] means [^a] in regexp
- if (inClass) {
- this.debug(' in class')
- if (c === "!" && i === classStart + 1) c = "^"
- re += c
- continue
- }
- // if we already have a stateChar, then it means
- // that there was something like ** or +? in there.
- // Handle the stateChar, then proceed with this one.
- self.debug('call clearStateChar %j', stateChar)
- clearStateChar()
- stateChar = c
- // if extglob is disabled, then +(asdf|foo) isn't a thing.
- // just clear the statechar *now*, rather than even diving into
- // the patternList stuff.
- if (options.noext) clearStateChar()
- continue
- case "(":
- if (inClass) {
- re += "("
- continue
- }
- if (!stateChar) {
- re += "\\("
- continue
- }
- plType = stateChar
- patternListStack.push({ type: plType
- , start: i - 1
- , reStart: re.length })
- // negation is (?:(?!js)[^/]*)
- re += stateChar === "!" ? "(?:(?!" : "(?:"
- this.debug('plType %j %j', stateChar, re)
- stateChar = false
- continue
- case ")":
- if (inClass || !patternListStack.length) {
- re += "\\)"
- continue
- }
- clearStateChar()
- hasMagic = true
- re += ")"
- plType = patternListStack.pop().type
- // negation is (?:(?!js)[^/]*)
- // The others are (?:<pattern>)<type>
- switch (plType) {
- case "!":
- re += "[^/]*?)"
- break
- case "?":
- case "+":
- case "*": re += plType
- case "@": break // the default anyway
- }
- continue
- case "|":
- if (inClass || !patternListStack.length || escaping) {
- re += "\\|"
- escaping = false
- continue
- }
- clearStateChar()
- re += "|"
- continue
- // these are mostly the same in regexp and glob
- case "[":
- // swallow any state-tracking char before the [
- clearStateChar()
- if (inClass) {
- re += "\\" + c
- continue
- }
- inClass = true
- classStart = i
- reClassStart = re.length
- re += c
- continue
- case "]":
- // a right bracket shall lose its special
- // meaning and represent itself in
- // a bracket expression if it occurs
- // first in the list. -- POSIX.2 2.8.3.2
- if (i === classStart + 1 || !inClass) {
- re += "\\" + c
- escaping = false
- continue
- }
- // handle the case where we left a class open.
- // "[z-a]" is valid, equivalent to "\[z-a\]"
- if (inClass) {
- // split where the last [ was, make sure we don't have
- // an invalid re. if so, re-walk the contents of the
- // would-be class to re-translate any characters that
- // were passed through as-is
- // TODO: It would probably be faster to determine this
- // without a try/catch and a new RegExp, but it's tricky
- // to do safely. For now, this is safe and works.
- var cs = pattern.substring(classStart + 1, i)
- try {
- new RegExp('[' + cs + ']')
- } catch (er) {
- // not a valid class!
- var sp = this.parse(cs, SUBPARSE)
- re = re.substr(0, reClassStart) + "\\[" + sp[0] + '\\]'
- hasMagic = hasMagic || sp[1]
- inClass = false
- continue
- }
- }
- // finish up the class.
- hasMagic = true
- inClass = false
- re += c
- continue
- default:
- // swallow any state char that wasn't consumed
- clearStateChar()
- if (escaping) {
- // no need
- escaping = false
- } else if (reSpecials[c]
- && !(c === "^" && inClass)) {
- re += "\\"
- }
- re += c
- } // switch
- } // for
- // handle the case where we left a class open.
- // "[abc" is valid, equivalent to "\[abc"
- if (inClass) {
- // split where the last [ was, and escape it
- // this is a huge pita. We now have to re-walk
- // the contents of the would-be class to re-translate
- // any characters that were passed through as-is
- var cs = pattern.substr(classStart + 1)
- , sp = this.parse(cs, SUBPARSE)
- re = re.substr(0, reClassStart) + "\\[" + sp[0]
- hasMagic = hasMagic || sp[1]
- }
- // handle the case where we had a +( thing at the *end*
- // of the pattern.
- // each pattern list stack adds 3 chars, and we need to go through
- // and escape any | chars that were passed through as-is for the regexp.
- // Go through and escape them, taking care not to double-escape any
- // | chars that were already escaped.
- var pl
- while (pl = patternListStack.pop()) {
- var tail = re.slice(pl.reStart + 3)
- // maybe some even number of \, then maybe 1 \, followed by a |
- tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
- if (!$2) {
- // the | isn't already escaped, so escape it.
- $2 = "\\"
- }
- // need to escape all those slashes *again*, without escaping the
- // one that we need for escaping the | character. As it works out,
- // escaping an even number of slashes can be done by simply repeating
- // it exactly after itself. That's why this trick works.
- //
- // I am sorry that you have to see this.
- return $1 + $1 + $2 + "|"
- })
- this.debug("tail=%j\n %s", tail, tail)
- var t = pl.type === "*" ? star
- : pl.type === "?" ? qmark
- : "\\" + pl.type
- hasMagic = true
- re = re.slice(0, pl.reStart)
- + t + "\\("
- + tail
- }
- // handle trailing things that only matter at the very end.
- clearStateChar()
- if (escaping) {
- // trailing \\
- re += "\\\\"
- }
- // only need to apply the nodot start if the re starts with
- // something that could conceivably capture a dot
- var addPatternStart = false
- switch (re.charAt(0)) {
- case ".":
- case "[":
- case "(": addPatternStart = true
- }
- // if the re is not "" at this point, then we need to make sure
- // it doesn't match against an empty path part.
- // Otherwise a/* will match a/, which it should not.
- if (re !== "" && hasMagic) re = "(?=.)" + re
- if (addPatternStart) re = patternStart + re
- // parsing just a piece of a larger pattern.
- if (isSub === SUBPARSE) {
- return [ re, hasMagic ]
- }
- // skip the regexp for non-magical patterns
- // unescape anything in it, though, so that it'll be
- // an exact match against a file etc.
- if (!hasMagic) {
- return globUnescape(pattern)
- }
- var flags = options.nocase ? "i" : ""
- , regExp = new RegExp("^" + re + "$", flags)
- regExp._glob = pattern
- regExp._src = re
- return regExp
- }
- minimatch.makeRe = function (pattern, options) {
- return new Minimatch(pattern, options || {}).makeRe()
- }
- Minimatch.prototype.makeRe = makeRe
- function makeRe () {
- if (this.regexp || this.regexp === false) return this.regexp
- // at this point, this.set is a 2d array of partial
- // pattern strings, or "**".
- //
- // It's better to use .match(). This function shouldn't
- // be used, really, but it's pretty convenient sometimes,
- // when you just want to work with a regex.
- var set = this.set
- if (!set.length) return this.regexp = false
- var options = this.options
- var twoStar = options.noglobstar ? star
- : options.dot ? twoStarDot
- : twoStarNoDot
- , flags = options.nocase ? "i" : ""
- var re = set.map(function (pattern) {
- return pattern.map(function (p) {
- return (p === GLOBSTAR) ? twoStar
- : (typeof p === "string") ? regExpEscape(p)
- : p._src
- }).join("\\\/")
- }).join("|")
- // must match entire pattern
- // ending in a * or ** will make it less strict.
- re = "^(?:" + re + ")$"
- // can match anything, as long as it's not this.
- if (this.negate) re = "^(?!" + re + ").*$"
- try {
- return this.regexp = new RegExp(re, flags)
- } catch (ex) {
- return this.regexp = false
- }
- }
- minimatch.match = function (list, pattern, options) {
- options = options || {}
- var mm = new Minimatch(pattern, options)
- list = list.filter(function (f) {
- return mm.match(f)
- })
- if (mm.options.nonull && !list.length) {
- list.push(pattern)
- }
- return list
- }
- Minimatch.prototype.match = match
- function match (f, partial) {
- this.debug("match", f, this.pattern)
- // short-circuit in the case of busted things.
- // comments, etc.
- if (this.comment) return false
- if (this.empty) return f === ""
- if (f === "/" && partial) return true
- var options = this.options
- // windows: need to use /, not \
- if (isWindows)
- f = f.split("\\").join("/")
- // treat the test path as a set of pathparts.
- f = f.split(slashSplit)
- this.debug(this.pattern, "split", f)
- // just ONE of the pattern sets in this.set needs to match
- // in order for it to be valid. If negating, then just one
- // match means that we have failed.
- // Either way, return on the first hit.
- var set = this.set
- this.debug(this.pattern, "set", set)
- // Find the basename of the path by looking for the last non-empty segment
- var filename;
- for (var i = f.length - 1; i >= 0; i--) {
- filename = f[i]
- if (filename) break
- }
- for (var i = 0, l = set.length; i < l; i ++) {
- var pattern = set[i], file = f
- if (options.matchBase && pattern.length === 1) {
- file = [filename]
- }
- var hit = this.matchOne(file, pattern, partial)
- if (hit) {
- if (options.flipNegate) return true
- return !this.negate
- }
- }
- // didn't get any hits. this is success if it's a negative
- // pattern, failure otherwise.
- if (options.flipNegate) return false
- return this.negate
- }
- // set partial to true to test if, for example,
- // "/a/b" matches the start of "/*/b/*/d"
- // Partial means, if you run out of file before you run
- // out of pattern, then that's fine, as long as all
- // the parts match.
- Minimatch.prototype.matchOne = function (file, pattern, partial) {
- var options = this.options
- this.debug("matchOne",
- { "this": this
- , file: file
- , pattern: pattern })
- this.debug("matchOne", file.length, pattern.length)
- for ( var fi = 0
- , pi = 0
- , fl = file.length
- , pl = pattern.length
- ; (fi < fl) && (pi < pl)
- ; fi ++, pi ++ ) {
- this.debug("matchOne loop")
- var p = pattern[pi]
- , f = file[fi]
- this.debug(pattern, p, f)
- // should be impossible.
- // some invalid regexp stuff in the set.
- if (p === false) return false
- if (p === GLOBSTAR) {
- this.debug('GLOBSTAR', [pattern, p, f])
- // "**"
- // a/**/b/**/c would match the following:
- // a/b/x/y/z/c
- // a/x/y/z/b/c
- // a/b/x/b/x/c
- // a/b/c
- // To do this, take the rest of the pattern after
- // the **, and see if it would match the file remainder.
- // If so, return success.
- // If not, the ** "swallows" a segment, and try again.
- // This is recursively awful.
- //
- // a/**/b/**/c matching a/b/x/y/z/c
- // - a matches a
- // - doublestar
- // - matchOne(b/x/y/z/c, b/**/c)
- // - b matches b
- // - doublestar
- // - matchOne(x/y/z/c, c) -> no
- // - matchOne(y/z/c, c) -> no
- // - matchOne(z/c, c) -> no
- // - matchOne(c, c) yes, hit
- var fr = fi
- , pr = pi + 1
- if (pr === pl) {
- this.debug('** at the end')
- // a ** at the end will just swallow the rest.
- // We have found a match.
- // however, it will not swallow /.x, unless
- // options.dot is set.
- // . and .. are *never* matched by **, for explosively
- // exponential reasons.
- for ( ; fi < fl; fi ++) {
- if (file[fi] === "." || file[fi] === ".." ||
- (!options.dot && file[fi].charAt(0) === ".")) return false
- }
- return true
- }
- // ok, let's see if we can swallow whatever we can.
- WHILE: while (fr < fl) {
- var swallowee = file[fr]
- this.debug('\nglobstar while',
- file, fr, pattern, pr, swallowee)
- // XXX remove this slice. Just pass the start index.
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
- this.debug('globstar found match!', fr, fl, swallowee)
- // found a match.
- return true
- } else {
- // can't swallow "." or ".." ever.
- // can only swallow ".foo" when explicitly asked.
- if (swallowee === "." || swallowee === ".." ||
- (!options.dot && swallowee.charAt(0) === ".")) {
- this.debug("dot detected!", file, fr, pattern, pr)
- break WHILE
- }
- // ** swallows a segment, and continue.
- this.debug('globstar swallow a segment, and continue')
- fr ++
- }
- }
- // no match was found.
- // However, in partial mode, we can't say this is necessarily over.
- // If there's more *pattern* left, then
- if (partial) {
- // ran out of file
- this.debug("\n>>> no match, partial?", file, fr, pattern, pr)
- if (fr === fl) return true
- }
- return false
- }
- // something other than **
- // non-magic patterns just have to match exactly
- // patterns with magic have been turned into regexps.
- var hit
- if (typeof p === "string") {
- if (options.nocase) {
- hit = f.toLowerCase() === p.toLowerCase()
- } else {
- hit = f === p
- }
- this.debug("string match", p, f, hit)
- } else {
- hit = f.match(p)
- this.debug("pattern match", p, f, hit)
- }
- if (!hit) return false
- }
- // Note: ending in / means that we'll get a final ""
- // at the end of the pattern. This can only match a
- // corresponding "" at the end of the file.
- // If the file ends in /, then it can only match a
- // a pattern that ends in /, unless the pattern just
- // doesn't have any more for it. But, a/b/ should *not*
- // match "a/b/*", even though "" matches against the
- // [^/]*? pattern, except in partial mode, where it might
- // simply not be reached yet.
- // However, a/b/ should still satisfy a/*
- // now either we fell off the end of the pattern, or we're done.
- if (fi === fl && pi === pl) {
- // ran out of pattern and filename at the same time.
- // an exact hit!
- return true
- } else if (fi === fl) {
- // ran out of file, but still had pattern left.
- // this is ok if we're doing the match as part of
- // a glob fs traversal.
- return partial
- } else if (pi === pl) {
- // ran out of pattern, still have file left.
- // this is only acceptable if we're on the very last
- // empty segment of a file with a trailing slash.
- // a/* should match a/b/
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === "")
- return emptyFileEnd
- }
- // should be unreachable.
- throw new Error("wtf?")
- }
- // replace stuff like \* with *
- function globUnescape (s) {
- return s.replace(/\\(.)/g, "$1")
- }
- function regExpEscape (s) {
- return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
- }
- }).call(this,require('_process'))
- },{"_process":200,"brace-expansion":431}],431:[function(require,module,exports){
- var concatMap = require('concat-map');
- var balanced = require('balanced-match');
- module.exports = expandTop;
- var escSlash = '\0SLASH'+Math.random()+'\0';
- var escOpen = '\0OPEN'+Math.random()+'\0';
- var escClose = '\0CLOSE'+Math.random()+'\0';
- var escComma = '\0COMMA'+Math.random()+'\0';
- var escPeriod = '\0PERIOD'+Math.random()+'\0';
- function numeric(str) {
- return parseInt(str, 10) == str
- ? parseInt(str, 10)
- : str.charCodeAt(0);
- }
- function escapeBraces(str) {
- return str.split('\\\\').join(escSlash)
- .split('\\{').join(escOpen)
- .split('\\}').join(escClose)
- .split('\\,').join(escComma)
- .split('\\.').join(escPeriod);
- }
- function unescapeBraces(str) {
- return str.split(escSlash).join('\\')
- .split(escOpen).join('{')
- .split(escClose).join('}')
- .split(escComma).join(',')
- .split(escPeriod).join('.');
- }
- // Basically just str.split(","), but handling cases
- // where we have nested braced sections, which should be
- // treated as individual members, like {a,{b,c},d}
- function parseCommaParts(str) {
- if (!str)
- return [''];
- var parts = [];
- var m = balanced('{', '}', str);
- if (!m)
- return str.split(',');
- var pre = m.pre;
- var body = m.body;
- var post = m.post;
- var p = pre.split(',');
- p[p.length-1] += '{' + body + '}';
- var postParts = parseCommaParts(post);
- if (post.length) {
- p[p.length-1] += postParts.shift();
- p.push.apply(p, postParts);
- }
- parts.push.apply(parts, p);
- return parts;
- }
- function expandTop(str) {
- if (!str)
- return [];
- return expand(escapeBraces(str), true).map(unescapeBraces);
- }
- function identity(e) {
- return e;
- }
- function embrace(str) {
- return '{' + str + '}';
- }
- function isPadded(el) {
- return /^-?0\d/.test(el);
- }
- function lte(i, y) {
- return i <= y;
- }
- function gte(i, y) {
- return i >= y;
- }
- function expand(str, isTop) {
- var expansions = [];
- var m = balanced('{', '}', str);
- if (!m || /\$$/.test(m.pre)) return [str];
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
- var isSequence = isNumericSequence || isAlphaSequence;
- var isOptions = /^(.*,)+(.+)?$/.test(m.body);
- if (!isSequence && !isOptions) {
- // {a},b}
- if (m.post.match(/,.*}/)) {
- str = m.pre + '{' + m.body + escClose + m.post;
- return expand(str);
- }
- return [str];
- }
- var n;
- if (isSequence) {
- n = m.body.split(/\.\./);
- } else {
- n = parseCommaParts(m.body);
- if (n.length === 1) {
- // x{{a,b}}y ==> x{a}y x{b}y
- n = expand(n[0], false).map(embrace);
- if (n.length === 1) {
- var post = m.post.length
- ? expand(m.post, false)
- : [''];
- return post.map(function(p) {
- return m.pre + n[0] + p;
- });
- }
- }
- }
- // at this point, n is the parts, and we know it's not a comma set
- // with a single entry.
- // no need to expand pre, since it is guaranteed to be free of brace-sets
- var pre = m.pre;
- var post = m.post.length
- ? expand(m.post, false)
- : [''];
- var N;
- if (isSequence) {
- var x = numeric(n[0]);
- var y = numeric(n[1]);
- var width = Math.max(n[0].length, n[1].length)
- var incr = n.length == 3
- ? Math.abs(numeric(n[2]))
- : 1;
- var test = lte;
- var reverse = y < x;
- if (reverse) {
- incr *= -1;
- test = gte;
- }
- var pad = n.some(isPadded);
- N = [];
- for (var i = x; test(i, y); i += incr) {
- var c;
- if (isAlphaSequence) {
- c = String.fromCharCode(i);
- if (c === '\\')
- c = '';
- } else {
- c = String(i);
- if (pad) {
- var need = width - c.length;
- if (need > 0) {
- var z = new Array(need + 1).join('0');
- if (i < 0)
- c = '-' + z + c.slice(1);
- else
- c = z + c;
- }
- }
- }
- N.push(c);
- }
- } else {
- N = concatMap(n, function(el) { return expand(el, false) });
- }
- for (var j = 0; j < N.length; j++) {
- for (var k = 0; k < post.length; k++) {
- var expansion = pre + N[j] + post[k];
- if (!isTop || isSequence || expansion)
- expansions.push(expansion);
- }
- }
- return expansions;
- }
- },{"balanced-match":432,"concat-map":433}],432:[function(require,module,exports){
- module.exports = balanced;
- function balanced(a, b, str) {
- var bal = 0;
- var m = {};
- var ended = false;
- for (var i = 0; i < str.length; i++) {
- if (a == str.substr(i, a.length)) {
- if (!('start' in m)) m.start = i;
- bal++;
- }
- else if (b == str.substr(i, b.length) && 'start' in m) {
- ended = true;
- bal--;
- if (!bal) {
- m.end = i;
- m.pre = str.substr(0, m.start);
- m.body = (m.end - m.start > 1)
- ? str.substring(m.start + a.length, m.end)
- : '';
- m.post = str.slice(m.end + b.length);
- return m;
- }
- }
- }
- // if we opened more than we closed, find the one we closed
- if (bal && ended) {
- var start = m.start + a.length;
- m = balanced(a, b, str.substr(start));
- if (m) {
- m.start += start;
- m.end += start;
- m.pre = str.slice(0, start) + m.pre;
- }
- return m;
- }
- }
- },{}],433:[function(require,module,exports){
- module.exports = function (xs, fn) {
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- var x = fn(xs[i], i);
- if (isArray(x)) res.push.apply(res, x);
- else res.push(x);
- }
- return res;
- };
- var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
- };
- },{}],434:[function(require,module,exports){
- (function (process){
- 'use strict';
- function posix(path) {
- return path.charAt(0) === '/';
- };
- function win32(path) {
- // https://github.com/joyent/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
- var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
- var result = splitDeviceRe.exec(path);
- var device = result[1] || '';
- var isUnc = !!device && device.charAt(1) !== ':';
- // UNC paths are always absolute
- return !!result[2] || isUnc;
- };
- module.exports = process.platform === 'win32' ? win32 : posix;
- module.exports.posix = posix;
- module.exports.win32 = win32;
- }).call(this,require('_process'))
- },{"_process":200}],435:[function(require,module,exports){
- "use strict";
- var originalObject = Object;
- var originalDefProp = Object.defineProperty;
- var originalCreate = Object.create;
- function defProp(obj, name, value) {
- if (originalDefProp) try {
- originalDefProp.call(originalObject, obj, name, { value: value });
- } catch (definePropertyIsBrokenInIE8) {
- obj[name] = value;
- } else {
- obj[name] = value;
- }
- }
- // For functions that will be invoked using .call or .apply, we need to
- // define those methods on the function objects themselves, rather than
- // inheriting them from Function.prototype, so that a malicious or clumsy
- // third party cannot interfere with the functionality of this module by
- // redefining Function.prototype.call or .apply.
- function makeSafeToCall(fun) {
- if (fun) {
- defProp(fun, "call", fun.call);
- defProp(fun, "apply", fun.apply);
- }
- return fun;
- }
- makeSafeToCall(originalDefProp);
- makeSafeToCall(originalCreate);
- var hasOwn = makeSafeToCall(Object.prototype.hasOwnProperty);
- var numToStr = makeSafeToCall(Number.prototype.toString);
- var strSlice = makeSafeToCall(String.prototype.slice);
- var cloner = function(){};
- function create(prototype) {
- if (originalCreate) {
- return originalCreate.call(originalObject, prototype);
- }
- cloner.prototype = prototype || null;
- return new cloner;
- }
- var rand = Math.random;
- var uniqueKeys = create(null);
- function makeUniqueKey() {
- // Collisions are highly unlikely, but this module is in the business of
- // making guarantees rather than safe bets.
- do var uniqueKey = internString(strSlice.call(numToStr.call(rand(), 36), 2));
- while (hasOwn.call(uniqueKeys, uniqueKey));
- return uniqueKeys[uniqueKey] = uniqueKey;
- }
- function internString(str) {
- var obj = {};
- obj[str] = true;
- return Object.keys(obj)[0];
- }
- // External users might find this function useful, but it is not necessary
- // for the typical use of this module.
- defProp(exports, "makeUniqueKey", makeUniqueKey);
- // Object.getOwnPropertyNames is the only way to enumerate non-enumerable
- // properties, so if we wrap it to ignore our secret keys, there should be
- // no way (except guessing) to access those properties.
- var originalGetOPNs = Object.getOwnPropertyNames;
- Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
- for (var names = originalGetOPNs(object),
- src = 0,
- dst = 0,
- len = names.length;
- src < len;
- ++src) {
- if (!hasOwn.call(uniqueKeys, names[src])) {
- if (src > dst) {
- names[dst] = names[src];
- }
- ++dst;
- }
- }
- names.length = dst;
- return names;
- };
- function defaultCreatorFn(object) {
- return create(null);
- }
- function makeAccessor(secretCreatorFn) {
- var brand = makeUniqueKey();
- var passkey = create(null);
- secretCreatorFn = secretCreatorFn || defaultCreatorFn;
- function register(object) {
- var secret; // Created lazily.
- function vault(key, forget) {
- // Only code that has access to the passkey can retrieve (or forget)
- // the secret object.
- if (key === passkey) {
- return forget
- ? secret = null
- : secret || (secret = secretCreatorFn(object));
- }
- }
- defProp(object, brand, vault);
- }
- function accessor(object) {
- if (!hasOwn.call(object, brand))
- register(object);
- return object[brand](passkey);
- }
- accessor.forget = function(object) {
- if (hasOwn.call(object, brand))
- object[brand](passkey, true);
- };
- return accessor;
- }
- defProp(exports, "makeAccessor", makeAccessor);
- },{}],436:[function(require,module,exports){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- var assert = require("assert");
- var types = require("recast").types;
- var isArray = types.builtInTypes.array;
- var b = types.builders;
- var n = types.namedTypes;
- var leap = require("./leap");
- var meta = require("./meta");
- var util = require("./util");
- var runtimeProperty = util.runtimeProperty;
- var hasOwn = Object.prototype.hasOwnProperty;
- function Emitter(contextId) {
- assert.ok(this instanceof Emitter);
- n.Identifier.assert(contextId);
- Object.defineProperties(this, {
- // In order to make sure the context object does not collide with
- // anything in the local scope, we might have to rename it, so we
- // refer to it symbolically instead of just assuming that it will be
- // called "context".
- contextId: { value: contextId },
- // An append-only list of Statements that grows each time this.emit is
- // called.
- listing: { value: [] },
- // A sparse array whose keys correspond to locations in this.listing
- // that have been marked as branch/jump targets.
- marked: { value: [true] },
- // The last location will be marked when this.getDispatchLoop is
- // called.
- finalLoc: { value: loc() },
- // A list of all leap.TryEntry statements emitted.
- tryEntries: { value: [] }
- });
- // The .leapManager property needs to be defined by a separate
- // defineProperties call so that .finalLoc will be visible to the
- // leap.LeapManager constructor.
- Object.defineProperties(this, {
- // Each time we evaluate the body of a loop, we tell this.leapManager
- // to enter a nested loop context that determines the meaning of break
- // and continue statements therein.
- leapManager: { value: new leap.LeapManager(this) }
- });
- }
- var Ep = Emitter.prototype;
- exports.Emitter = Emitter;
- // Offsets into this.listing that could be used as targets for branches or
- // jumps are represented as numeric Literal nodes. This representation has
- // the amazingly convenient benefit of allowing the exact value of the
- // location to be determined at any time, even after generating code that
- // refers to the location.
- function loc() {
- return b.literal(-1);
- }
- // Sets the exact value of the given location to the offset of the next
- // Statement emitted.
- Ep.mark = function(loc) {
- n.Literal.assert(loc);
- var index = this.listing.length;
- if (loc.value === -1) {
- loc.value = index;
- } else {
- // Locations can be marked redundantly, but their values cannot change
- // once set the first time.
- assert.strictEqual(loc.value, index);
- }
- this.marked[index] = true;
- return loc;
- };
- Ep.emit = function(node) {
- if (n.Expression.check(node))
- node = b.expressionStatement(node);
- n.Statement.assert(node);
- this.listing.push(node);
- };
- // Shorthand for emitting assignment statements. This will come in handy
- // for assignments to temporary variables.
- Ep.emitAssign = function(lhs, rhs) {
- this.emit(this.assign(lhs, rhs));
- return lhs;
- };
- // Shorthand for an assignment statement.
- Ep.assign = function(lhs, rhs) {
- return b.expressionStatement(
- b.assignmentExpression("=", lhs, rhs));
- };
- // Convenience function for generating expressions like context.next,
- // context.sent, and context.rval.
- Ep.contextProperty = function(name, computed) {
- return b.memberExpression(
- this.contextId,
- computed ? b.literal(name) : b.identifier(name),
- !!computed
- );
- };
- var volatileContextPropertyNames = {
- prev: true,
- next: true,
- sent: true,
- rval: true
- };
- // A "volatile" context property is a MemberExpression like context.sent
- // that should probably be stored in a temporary variable when there's a
- // possibility the property will get overwritten.
- Ep.isVolatileContextProperty = function(expr) {
- if (n.MemberExpression.check(expr)) {
- if (expr.computed) {
- // If it's a computed property such as context[couldBeAnything],
- // assume the worst in terms of volatility.
- return true;
- }
- if (n.Identifier.check(expr.object) &&
- n.Identifier.check(expr.property) &&
- expr.object.name === this.contextId.name &&
- hasOwn.call(volatileContextPropertyNames,
- expr.property.name)) {
- return true;
- }
- }
- return false;
- };
- // Shorthand for setting context.rval and jumping to `context.stop()`.
- Ep.stop = function(rval) {
- if (rval) {
- this.setReturnValue(rval);
- }
- this.jump(this.finalLoc);
- };
- Ep.setReturnValue = function(valuePath) {
- n.Expression.assert(valuePath.value);
- this.emitAssign(
- this.contextProperty("rval"),
- this.explodeExpression(valuePath)
- );
- };
- Ep.clearPendingException = function(tryLoc, assignee) {
- n.Literal.assert(tryLoc);
- var catchCall = b.callExpression(
- this.contextProperty("catch", true),
- [tryLoc]
- );
- if (assignee) {
- this.emitAssign(assignee, catchCall);
- } else {
- this.emit(catchCall);
- }
- };
- // Emits code for an unconditional jump to the given location, even if the
- // exact value of the location is not yet known.
- Ep.jump = function(toLoc) {
- this.emitAssign(this.contextProperty("next"), toLoc);
- this.emit(b.breakStatement());
- };
- // Conditional jump.
- Ep.jumpIf = function(test, toLoc) {
- n.Expression.assert(test);
- n.Literal.assert(toLoc);
- this.emit(b.ifStatement(
- test,
- b.blockStatement([
- this.assign(this.contextProperty("next"), toLoc),
- b.breakStatement()
- ])
- ));
- };
- // Conditional jump, with the condition negated.
- Ep.jumpIfNot = function(test, toLoc) {
- n.Expression.assert(test);
- n.Literal.assert(toLoc);
- var negatedTest;
- if (n.UnaryExpression.check(test) &&
- test.operator === "!") {
- // Avoid double negation.
- negatedTest = test.argument;
- } else {
- negatedTest = b.unaryExpression("!", test);
- }
- this.emit(b.ifStatement(
- negatedTest,
- b.blockStatement([
- this.assign(this.contextProperty("next"), toLoc),
- b.breakStatement()
- ])
- ));
- };
- // Returns a unique MemberExpression that can be used to store and
- // retrieve temporary values. Since the object of the member expression is
- // the context object, which is presumed to coexist peacefully with all
- // other local variables, and since we just increment `nextTempId`
- // monotonically, uniqueness is assured.
- var nextTempId = 0;
- Ep.makeTempVar = function() {
- return this.contextProperty("t" + nextTempId++);
- };
- Ep.getContextFunction = function(id) {
- return b.functionExpression(
- id || null/*Anonymous*/,
- [this.contextId],
- b.blockStatement([this.getDispatchLoop()]),
- false, // Not a generator anymore!
- false // Nor an expression.
- );
- };
- // Turns this.listing into a loop of the form
- //
- // while (1) switch (context.next) {
- // case 0:
- // ...
- // case n:
- // return context.stop();
- // }
- //
- // Each marked location in this.listing will correspond to one generated
- // case statement.
- Ep.getDispatchLoop = function() {
- var self = this;
- var cases = [];
- var current;
- // If we encounter a break, continue, or return statement in a switch
- // case, we can skip the rest of the statements until the next case.
- var alreadyEnded = false;
- self.listing.forEach(function(stmt, i) {
- if (self.marked.hasOwnProperty(i)) {
- cases.push(b.switchCase(
- b.literal(i),
- current = []));
- alreadyEnded = false;
- }
- if (!alreadyEnded) {
- current.push(stmt);
- if (isSwitchCaseEnder(stmt))
- alreadyEnded = true;
- }
- });
- // Now that we know how many statements there will be in this.listing,
- // we can finally resolve this.finalLoc.value.
- this.finalLoc.value = this.listing.length;
- cases.push(
- b.switchCase(this.finalLoc, [
- // Intentionally fall through to the "end" case...
- ]),
- // So that the runtime can jump to the final location without having
- // to know its offset, we provide the "end" case as a synonym.
- b.switchCase(b.literal("end"), [
- // This will check/clear both context.thrown and context.rval.
- b.returnStatement(
- b.callExpression(this.contextProperty("stop"), [])
- )
- ])
- );
- return b.whileStatement(
- b.literal(1),
- b.switchStatement(
- b.assignmentExpression(
- "=",
- this.contextProperty("prev"),
- this.contextProperty("next")
- ),
- cases
- )
- );
- };
- // See comment above re: alreadyEnded.
- function isSwitchCaseEnder(stmt) {
- return n.BreakStatement.check(stmt)
- || n.ContinueStatement.check(stmt)
- || n.ReturnStatement.check(stmt)
- || n.ThrowStatement.check(stmt);
- }
- Ep.getTryLocsList = function() {
- if (this.tryEntries.length === 0) {
- // To avoid adding a needless [] to the majority of runtime.wrap
- // argument lists, force the caller to handle this case specially.
- return null;
- }
- var lastLocValue = 0;
- return b.arrayExpression(
- this.tryEntries.map(function(tryEntry) {
- var thisLocValue = tryEntry.firstLoc.value;
- assert.ok(thisLocValue >= lastLocValue, "try entries out of order");
- lastLocValue = thisLocValue;
- var ce = tryEntry.catchEntry;
- var fe = tryEntry.finallyEntry;
- var locs = [
- tryEntry.firstLoc,
- // The null here makes a hole in the array.
- ce ? ce.firstLoc : null
- ];
- if (fe) {
- locs[2] = fe.firstLoc;
- locs[3] = fe.afterLoc;
- }
- return b.arrayExpression(locs);
- })
- );
- };
- // All side effects must be realized in order.
- // If any subexpression harbors a leap, all subexpressions must be
- // neutered of side effects.
- // No destructive modification of AST nodes.
- Ep.explode = function(path, ignoreResult) {
- assert.ok(path instanceof types.NodePath);
- var node = path.value;
- var self = this;
- n.Node.assert(node);
- if (n.Statement.check(node))
- return self.explodeStatement(path);
- if (n.Expression.check(node))
- return self.explodeExpression(path, ignoreResult);
- if (n.Declaration.check(node))
- throw getDeclError(node);
- switch (node.type) {
- case "Program":
- return path.get("body").map(
- self.explodeStatement,
- self
- );
- case "VariableDeclarator":
- throw getDeclError(node);
- // These node types should be handled by their parent nodes
- // (ObjectExpression, SwitchStatement, and TryStatement, respectively).
- case "Property":
- case "SwitchCase":
- case "CatchClause":
- throw new Error(
- node.type + " nodes should be handled by their parents");
- default:
- throw new Error(
- "unknown Node of type " +
- JSON.stringify(node.type));
- }
- };
- function getDeclError(node) {
- return new Error(
- "all declarations should have been transformed into " +
- "assignments before the Exploder began its work: " +
- JSON.stringify(node));
- }
- Ep.explodeStatement = function(path, labelId) {
- assert.ok(path instanceof types.NodePath);
- var stmt = path.value;
- var self = this;
- n.Statement.assert(stmt);
- if (labelId) {
- n.Identifier.assert(labelId);
- } else {
- labelId = null;
- }
- // Explode BlockStatement nodes even if they do not contain a yield,
- // because we don't want or need the curly braces.
- if (n.BlockStatement.check(stmt)) {
- return path.get("body").each(
- self.explodeStatement,
- self
- );
- }
- if (!meta.containsLeap(stmt)) {
- // Technically we should be able to avoid emitting the statement
- // altogether if !meta.hasSideEffects(stmt), but that leads to
- // confusing generated code (for instance, `while (true) {}` just
- // disappears) and is probably a more appropriate job for a dedicated
- // dead code elimination pass.
- self.emit(stmt);
- return;
- }
- switch (stmt.type) {
- case "ExpressionStatement":
- self.explodeExpression(path.get("expression"), true);
- break;
- case "LabeledStatement":
- var after = loc();
- // Did you know you can break from any labeled block statement or
- // control structure? Well, you can! Note: when a labeled loop is
- // encountered, the leap.LabeledEntry created here will immediately
- // enclose a leap.LoopEntry on the leap manager's stack, and both
- // entries will have the same label. Though this works just fine, it
- // may seem a bit redundant. In theory, we could check here to
- // determine if stmt knows how to handle its own label; for example,
- // stmt happens to be a WhileStatement and so we know it's going to
- // establish its own LoopEntry when we explode it (below). Then this
- // LabeledEntry would be unnecessary. Alternatively, we might be
- // tempted not to pass stmt.label down into self.explodeStatement,
- // because we've handled the label here, but that's a mistake because
- // labeled loops may contain labeled continue statements, which is not
- // something we can handle in this generic case. All in all, I think a
- // little redundancy greatly simplifies the logic of this case, since
- // it's clear that we handle all possible LabeledStatements correctly
- // here, regardless of whether they interact with the leap manager
- // themselves. Also remember that labels and break/continue-to-label
- // statements are rare, and all of this logic happens at transform
- // time, so it has no additional runtime cost.
- self.leapManager.withEntry(
- new leap.LabeledEntry(after, stmt.label),
- function() {
- self.explodeStatement(path.get("body"), stmt.label);
- }
- );
- self.mark(after);
- break;
- case "WhileStatement":
- var before = loc();
- var after = loc();
- self.mark(before);
- self.jumpIfNot(self.explodeExpression(path.get("test")), after);
- self.leapManager.withEntry(
- new leap.LoopEntry(after, before, labelId),
- function() { self.explodeStatement(path.get("body")); }
- );
- self.jump(before);
- self.mark(after);
- break;
- case "DoWhileStatement":
- var first = loc();
- var test = loc();
- var after = loc();
- self.mark(first);
- self.leapManager.withEntry(
- new leap.LoopEntry(after, test, labelId),
- function() { self.explode(path.get("body")); }
- );
- self.mark(test);
- self.jumpIf(self.explodeExpression(path.get("test")), first);
- self.mark(after);
- break;
- case "ForStatement":
- var head = loc();
- var update = loc();
- var after = loc();
- if (stmt.init) {
- // We pass true here to indicate that if stmt.init is an expression
- // then we do not care about its result.
- self.explode(path.get("init"), true);
- }
- self.mark(head);
- if (stmt.test) {
- self.jumpIfNot(self.explodeExpression(path.get("test")), after);
- } else {
- // No test means continue unconditionally.
- }
- self.leapManager.withEntry(
- new leap.LoopEntry(after, update, labelId),
- function() { self.explodeStatement(path.get("body")); }
- );
- self.mark(update);
- if (stmt.update) {
- // We pass true here to indicate that if stmt.update is an
- // expression then we do not care about its result.
- self.explode(path.get("update"), true);
- }
- self.jump(head);
- self.mark(after);
- break;
- case "ForInStatement":
- n.Identifier.assert(stmt.left);
- var head = loc();
- var after = loc();
- var keyIterNextFn = self.makeTempVar();
- self.emitAssign(
- keyIterNextFn,
- b.callExpression(
- runtimeProperty("keys"),
- [self.explodeExpression(path.get("right"))]
- )
- );
- self.mark(head);
- var keyInfoTmpVar = self.makeTempVar();
- self.jumpIf(
- b.memberExpression(
- b.assignmentExpression(
- "=",
- keyInfoTmpVar,
- b.callExpression(keyIterNextFn, [])
- ),
- b.identifier("done"),
- false
- ),
- after
- );
- self.emitAssign(
- stmt.left,
- b.memberExpression(
- keyInfoTmpVar,
- b.identifier("value"),
- false
- )
- );
- self.leapManager.withEntry(
- new leap.LoopEntry(after, head, labelId),
- function() { self.explodeStatement(path.get("body")); }
- );
- self.jump(head);
- self.mark(after);
- break;
- case "BreakStatement":
- self.emitAbruptCompletion({
- type: "break",
- target: self.leapManager.getBreakLoc(stmt.label)
- });
- break;
- case "ContinueStatement":
- self.emitAbruptCompletion({
- type: "continue",
- target: self.leapManager.getContinueLoc(stmt.label)
- });
- break;
- case "SwitchStatement":
- // Always save the discriminant into a temporary variable in case the
- // test expressions overwrite values like context.sent.
- var disc = self.emitAssign(
- self.makeTempVar(),
- self.explodeExpression(path.get("discriminant"))
- );
- var after = loc();
- var defaultLoc = loc();
- var condition = defaultLoc;
- var caseLocs = [];
- // If there are no cases, .cases might be undefined.
- var cases = stmt.cases || [];
- for (var i = cases.length - 1; i >= 0; --i) {
- var c = cases[i];
- n.SwitchCase.assert(c);
- if (c.test) {
- condition = b.conditionalExpression(
- b.binaryExpression("===", disc, c.test),
- caseLocs[i] = loc(),
- condition
- );
- } else {
- caseLocs[i] = defaultLoc;
- }
- }
- self.jump(self.explodeExpression(
- new types.NodePath(condition, path, "discriminant")
- ));
- self.leapManager.withEntry(
- new leap.SwitchEntry(after),
- function() {
- path.get("cases").each(function(casePath) {
- var c = casePath.value;
- var i = casePath.name;
- self.mark(caseLocs[i]);
- casePath.get("consequent").each(
- self.explodeStatement,
- self
- );
- });
- }
- );
- self.mark(after);
- if (defaultLoc.value === -1) {
- self.mark(defaultLoc);
- assert.strictEqual(after.value, defaultLoc.value);
- }
- break;
- case "IfStatement":
- var elseLoc = stmt.alternate && loc();
- var after = loc();
- self.jumpIfNot(
- self.explodeExpression(path.get("test")),
- elseLoc || after
- );
- self.explodeStatement(path.get("consequent"));
- if (elseLoc) {
- self.jump(after);
- self.mark(elseLoc);
- self.explodeStatement(path.get("alternate"));
- }
- self.mark(after);
- break;
- case "ReturnStatement":
- self.emitAbruptCompletion({
- type: "return",
- value: self.explodeExpression(path.get("argument"))
- });
- break;
- case "WithStatement":
- throw new Error(
- node.type + " not supported in generator functions.");
- case "TryStatement":
- var after = loc();
- var handler = stmt.handler;
- if (!handler && stmt.handlers) {
- handler = stmt.handlers[0] || null;
- }
- var catchLoc = handler && loc();
- var catchEntry = catchLoc && new leap.CatchEntry(
- catchLoc,
- handler.param
- );
- var finallyLoc = stmt.finalizer && loc();
- var finallyEntry = finallyLoc &&
- new leap.FinallyEntry(finallyLoc, after);
- var tryEntry = new leap.TryEntry(
- self.getUnmarkedCurrentLoc(),
- catchEntry,
- finallyEntry
- );
- self.tryEntries.push(tryEntry);
- self.updateContextPrevLoc(tryEntry.firstLoc);
- self.leapManager.withEntry(tryEntry, function() {
- self.explodeStatement(path.get("block"));
- if (catchLoc) {
- if (finallyLoc) {
- // If we have both a catch block and a finally block, then
- // because we emit the catch block first, we need to jump over
- // it to the finally block.
- self.jump(finallyLoc);
- } else {
- // If there is no finally block, then we need to jump over the
- // catch block to the fall-through location.
- self.jump(after);
- }
- self.updateContextPrevLoc(self.mark(catchLoc));
- var bodyPath = path.get("handler", "body");
- var safeParam = self.makeTempVar();
- self.clearPendingException(tryEntry.firstLoc, safeParam);
- var catchScope = bodyPath.scope;
- var catchParamName = handler.param.name;
- n.CatchClause.assert(catchScope.node);
- assert.strictEqual(catchScope.lookup(catchParamName), catchScope);
- types.visit(bodyPath, {
- visitIdentifier: function(path) {
- if (util.isReference(path, catchParamName) &&
- path.scope.lookup(catchParamName) === catchScope) {
- return safeParam;
- }
- this.traverse(path);
- },
- visitFunction: function(path) {
- if (path.scope.declares(catchParamName)) {
- // Don't descend into nested scopes that shadow the catch
- // parameter with their own declarations. This isn't
- // logically necessary because of the path.scope.lookup we
- // do in visitIdentifier, but it saves time.
- return false;
- }
- this.traverse(path);
- }
- });
- self.leapManager.withEntry(catchEntry, function() {
- self.explodeStatement(bodyPath);
- });
- }
- if (finallyLoc) {
- self.updateContextPrevLoc(self.mark(finallyLoc));
- self.leapManager.withEntry(finallyEntry, function() {
- self.explodeStatement(path.get("finalizer"));
- });
- self.emit(b.returnStatement(b.callExpression(
- self.contextProperty("finish"),
- [finallyEntry.firstLoc]
- )));
- }
- });
- self.mark(after);
- break;
- case "ThrowStatement":
- self.emit(b.throwStatement(
- self.explodeExpression(path.get("argument"))
- ));
- break;
- default:
- throw new Error(
- "unknown Statement of type " +
- JSON.stringify(stmt.type));
- }
- };
- Ep.emitAbruptCompletion = function(record) {
- if (!isValidCompletion(record)) {
- assert.ok(
- false,
- "invalid completion record: " +
- JSON.stringify(record)
- );
- }
- assert.notStrictEqual(
- record.type, "normal",
- "normal completions are not abrupt"
- );
- var abruptArgs = [b.literal(record.type)];
- if (record.type === "break" ||
- record.type === "continue") {
- n.Literal.assert(record.target);
- abruptArgs[1] = record.target;
- } else if (record.type === "return" ||
- record.type === "throw") {
- if (record.value) {
- n.Expression.assert(record.value);
- abruptArgs[1] = record.value;
- }
- }
- this.emit(
- b.returnStatement(
- b.callExpression(
- this.contextProperty("abrupt"),
- abruptArgs
- )
- )
- );
- };
- function isValidCompletion(record) {
- var type = record.type;
- if (type === "normal") {
- return !hasOwn.call(record, "target");
- }
- if (type === "break" ||
- type === "continue") {
- return !hasOwn.call(record, "value")
- && n.Literal.check(record.target);
- }
- if (type === "return" ||
- type === "throw") {
- return hasOwn.call(record, "value")
- && !hasOwn.call(record, "target");
- }
- return false;
- }
- // Not all offsets into emitter.listing are potential jump targets. For
- // example, execution typically falls into the beginning of a try block
- // without jumping directly there. This method returns the current offset
- // without marking it, so that a switch case will not necessarily be
- // generated for this offset (I say "not necessarily" because the same
- // location might end up being marked in the process of emitting other
- // statements). There's no logical harm in marking such locations as jump
- // targets, but minimizing the number of switch cases keeps the generated
- // code shorter.
- Ep.getUnmarkedCurrentLoc = function() {
- return b.literal(this.listing.length);
- };
- // The context.prev property takes the value of context.next whenever we
- // evaluate the switch statement discriminant, which is generally good
- // enough for tracking the last location we jumped to, but sometimes
- // context.prev needs to be more precise, such as when we fall
- // successfully out of a try block and into a finally block without
- // jumping. This method exists to update context.prev to the freshest
- // available location. If we were implementing a full interpreter, we
- // would know the location of the current instruction with complete
- // precision at all times, but we don't have that luxury here, as it would
- // be costly and verbose to set context.prev before every statement.
- Ep.updateContextPrevLoc = function(loc) {
- if (loc) {
- n.Literal.assert(loc);
- if (loc.value === -1) {
- // If an uninitialized location literal was passed in, set its value
- // to the current this.listing.length.
- loc.value = this.listing.length;
- } else {
- // Otherwise assert that the location matches the current offset.
- assert.strictEqual(loc.value, this.listing.length);
- }
- } else {
- loc = this.getUnmarkedCurrentLoc();
- }
- // Make sure context.prev is up to date in case we fell into this try
- // statement without jumping to it. TODO Consider avoiding this
- // assignment when we know control must have jumped here.
- this.emitAssign(this.contextProperty("prev"), loc);
- };
- Ep.explodeExpression = function(path, ignoreResult) {
- assert.ok(path instanceof types.NodePath);
- var expr = path.value;
- if (expr) {
- n.Expression.assert(expr);
- } else {
- return expr;
- }
- var self = this;
- var result; // Used optionally by several cases below.
- function finish(expr) {
- n.Expression.assert(expr);
- if (ignoreResult) {
- self.emit(expr);
- } else {
- return expr;
- }
- }
- // If the expression does not contain a leap, then we either emit the
- // expression as a standalone statement or return it whole.
- if (!meta.containsLeap(expr)) {
- return finish(expr);
- }
- // If any child contains a leap (such as a yield or labeled continue or
- // break statement), then any sibling subexpressions will almost
- // certainly have to be exploded in order to maintain the order of their
- // side effects relative to the leaping child(ren).
- var hasLeapingChildren = meta.containsLeap.onlyChildren(expr);
- // In order to save the rest of explodeExpression from a combinatorial
- // trainwreck of special cases, explodeViaTempVar is responsible for
- // deciding when a subexpression needs to be "exploded," which is my
- // very technical term for emitting the subexpression as an assignment
- // to a temporary variable and the substituting the temporary variable
- // for the original subexpression. Think of exploded view diagrams, not
- // Michael Bay movies. The point of exploding subexpressions is to
- // control the precise order in which the generated code realizes the
- // side effects of those subexpressions.
- function explodeViaTempVar(tempVar, childPath, ignoreChildResult) {
- assert.ok(childPath instanceof types.NodePath);
- assert.ok(
- !ignoreChildResult || !tempVar,
- "Ignoring the result of a child expression but forcing it to " +
- "be assigned to a temporary variable?"
- );
- var result = self.explodeExpression(childPath, ignoreChildResult);
- if (ignoreChildResult) {
- // Side effects already emitted above.
- } else if (tempVar || (hasLeapingChildren &&
- (self.isVolatileContextProperty(result) ||
- meta.hasSideEffects(result)))) {
- // If tempVar was provided, then the result will always be assigned
- // to it, even if the result does not otherwise need to be assigned
- // to a temporary variable. When no tempVar is provided, we have
- // the flexibility to decide whether a temporary variable is really
- // necessary. In general, temporary assignment is required only
- // when some other child contains a leap and the child in question
- // is a context property like $ctx.sent that might get overwritten
- // or an expression with side effects that need to occur in proper
- // sequence relative to the leap.
- result = self.emitAssign(
- tempVar || self.makeTempVar(),
- result
- );
- }
- return result;
- }
- // If ignoreResult is true, then we must take full responsibility for
- // emitting the expression with all its side effects, and we should not
- // return a result.
- switch (expr.type) {
- case "MemberExpression":
- return finish(b.memberExpression(
- self.explodeExpression(path.get("object")),
- expr.computed
- ? explodeViaTempVar(null, path.get("property"))
- : expr.property,
- expr.computed
- ));
- case "CallExpression":
- var oldCalleePath = path.get("callee");
- var newCallee = self.explodeExpression(oldCalleePath);
- // If the callee was not previously a MemberExpression, then the
- // CallExpression was "unqualified," meaning its `this` object should
- // be the global object. If the exploded expression has become a
- // MemberExpression, then we need to force it to be unqualified by
- // using the (0, object.property)(...) trick; otherwise, it will
- // receive the object of the MemberExpression as its `this` object.
- if (!n.MemberExpression.check(oldCalleePath.node) &&
- n.MemberExpression.check(newCallee)) {
- newCallee = b.sequenceExpression([
- b.literal(0),
- newCallee
- ]);
- }
- return finish(b.callExpression(
- newCallee,
- path.get("arguments").map(function(argPath) {
- return explodeViaTempVar(null, argPath);
- })
- ));
- case "NewExpression":
- return finish(b.newExpression(
- explodeViaTempVar(null, path.get("callee")),
- path.get("arguments").map(function(argPath) {
- return explodeViaTempVar(null, argPath);
- })
- ));
- case "ObjectExpression":
- return finish(b.objectExpression(
- path.get("properties").map(function(propPath) {
- return b.property(
- propPath.value.kind,
- propPath.value.key,
- explodeViaTempVar(null, propPath.get("value"))
- );
- })
- ));
- case "ArrayExpression":
- return finish(b.arrayExpression(
- path.get("elements").map(function(elemPath) {
- return explodeViaTempVar(null, elemPath);
- })
- ));
- case "SequenceExpression":
- var lastIndex = expr.expressions.length - 1;
- path.get("expressions").each(function(exprPath) {
- if (exprPath.name === lastIndex) {
- result = self.explodeExpression(exprPath, ignoreResult);
- } else {
- self.explodeExpression(exprPath, true);
- }
- });
- return result;
- case "LogicalExpression":
- var after = loc();
- if (!ignoreResult) {
- result = self.makeTempVar();
- }
- var left = explodeViaTempVar(result, path.get("left"));
- if (expr.operator === "&&") {
- self.jumpIfNot(left, after);
- } else {
- assert.strictEqual(expr.operator, "||");
- self.jumpIf(left, after);
- }
- explodeViaTempVar(result, path.get("right"), ignoreResult);
- self.mark(after);
- return result;
- case "ConditionalExpression":
- var elseLoc = loc();
- var after = loc();
- var test = self.explodeExpression(path.get("test"));
- self.jumpIfNot(test, elseLoc);
- if (!ignoreResult) {
- result = self.makeTempVar();
- }
- explodeViaTempVar(result, path.get("consequent"), ignoreResult);
- self.jump(after);
- self.mark(elseLoc);
- explodeViaTempVar(result, path.get("alternate"), ignoreResult);
- self.mark(after);
- return result;
- case "UnaryExpression":
- return finish(b.unaryExpression(
- expr.operator,
- // Can't (and don't need to) break up the syntax of the argument.
- // Think about delete a[b].
- self.explodeExpression(path.get("argument")),
- !!expr.prefix
- ));
- case "BinaryExpression":
- return finish(b.binaryExpression(
- expr.operator,
- explodeViaTempVar(null, path.get("left")),
- explodeViaTempVar(null, path.get("right"))
- ));
- case "AssignmentExpression":
- return finish(b.assignmentExpression(
- expr.operator,
- self.explodeExpression(path.get("left")),
- self.explodeExpression(path.get("right"))
- ));
- case "UpdateExpression":
- return finish(b.updateExpression(
- expr.operator,
- self.explodeExpression(path.get("argument")),
- expr.prefix
- ));
- case "YieldExpression":
- var after = loc();
- var arg = expr.argument && self.explodeExpression(path.get("argument"));
- if (arg && expr.delegate) {
- var result = self.makeTempVar();
- self.emit(b.returnStatement(b.callExpression(
- self.contextProperty("delegateYield"), [
- arg,
- b.literal(result.property.name),
- after
- ]
- )));
- self.mark(after);
- return result;
- }
- self.emitAssign(self.contextProperty("next"), after);
- self.emit(b.returnStatement(arg || null));
- self.mark(after);
- return self.contextProperty("sent");
- default:
- throw new Error(
- "unknown Expression of type " +
- JSON.stringify(expr.type));
- }
- };
- },{"./leap":438,"./meta":439,"./util":440,"assert":190,"recast":469}],437:[function(require,module,exports){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- var assert = require("assert");
- var types = require("recast").types;
- var n = types.namedTypes;
- var b = types.builders;
- var hasOwn = Object.prototype.hasOwnProperty;
- // The hoist function takes a FunctionExpression or FunctionDeclaration
- // and replaces any Declaration nodes in its body with assignments, then
- // returns a VariableDeclaration containing just the names of the removed
- // declarations.
- exports.hoist = function(funPath) {
- assert.ok(funPath instanceof types.NodePath);
- n.Function.assert(funPath.value);
- var vars = {};
- function varDeclToExpr(vdec, includeIdentifiers) {
- n.VariableDeclaration.assert(vdec);
- var exprs = [];
- vdec.declarations.forEach(function(dec) {
- vars[dec.id.name] = dec.id;
- if (dec.init) {
- exprs.push(b.assignmentExpression(
- "=", dec.id, dec.init
- ));
- } else if (includeIdentifiers) {
- exprs.push(dec.id);
- }
- });
- if (exprs.length === 0)
- return null;
- if (exprs.length === 1)
- return exprs[0];
- return b.sequenceExpression(exprs);
- }
- types.visit(funPath.get("body"), {
- visitVariableDeclaration: function(path) {
- var expr = varDeclToExpr(path.value, false);
- if (expr === null) {
- path.replace();
- } else {
- // We don't need to traverse this expression any further because
- // there can't be any new declarations inside an expression.
- return b.expressionStatement(expr);
- }
- // Since the original node has been either removed or replaced,
- // avoid traversing it any further.
- return false;
- },
- visitForStatement: function(path) {
- var init = path.value.init;
- if (n.VariableDeclaration.check(init)) {
- path.get("init").replace(varDeclToExpr(init, false));
- }
- this.traverse(path);
- },
- visitForInStatement: function(path) {
- var left = path.value.left;
- if (n.VariableDeclaration.check(left)) {
- path.get("left").replace(varDeclToExpr(left, true));
- }
- this.traverse(path);
- },
- visitFunctionDeclaration: function(path) {
- var node = path.value;
- vars[node.id.name] = node.id;
- var parentNode = path.parent.node;
- var assignment = b.expressionStatement(
- b.assignmentExpression(
- "=",
- node.id,
- b.functionExpression(
- node.id,
- node.params,
- node.body,
- node.generator,
- node.expression
- )
- )
- );
- if (n.BlockStatement.check(path.parent.node)) {
- // Insert the assignment form before the first statement in the
- // enclosing block.
- path.parent.get("body").unshift(assignment);
- // Remove the function declaration now that we've inserted the
- // equivalent assignment form at the beginning of the block.
- path.replace();
- } else {
- // If the parent node is not a block statement, then we can just
- // replace the declaration with the equivalent assignment form
- // without worrying about hoisting it.
- path.replace(assignment);
- }
- // Don't hoist variables out of inner functions.
- return false;
- },
- visitFunctionExpression: function(path) {
- // Don't descend into nested function expressions.
- return false;
- }
- });
- var paramNames = {};
- funPath.get("params").each(function(paramPath) {
- var param = paramPath.value;
- if (n.Identifier.check(param)) {
- paramNames[param.name] = param;
- } else {
- // Variables declared by destructuring parameter patterns will be
- // harmlessly re-declared.
- }
- });
- var declarations = [];
- Object.keys(vars).forEach(function(name) {
- if (!hasOwn.call(paramNames, name)) {
- declarations.push(b.variableDeclarator(vars[name], null));
- }
- });
- if (declarations.length === 0) {
- return null; // Be sure to handle this case!
- }
- return b.variableDeclaration("var", declarations);
- };
- },{"assert":190,"recast":469}],438:[function(require,module,exports){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- var assert = require("assert");
- var types = require("recast").types;
- var n = types.namedTypes;
- var b = types.builders;
- var inherits = require("util").inherits;
- var hasOwn = Object.prototype.hasOwnProperty;
- function Entry() {
- assert.ok(this instanceof Entry);
- }
- function FunctionEntry(returnLoc) {
- Entry.call(this);
- n.Literal.assert(returnLoc);
- this.returnLoc = returnLoc;
- }
- inherits(FunctionEntry, Entry);
- exports.FunctionEntry = FunctionEntry;
- function LoopEntry(breakLoc, continueLoc, label) {
- Entry.call(this);
- n.Literal.assert(breakLoc);
- n.Literal.assert(continueLoc);
- if (label) {
- n.Identifier.assert(label);
- } else {
- label = null;
- }
- this.breakLoc = breakLoc;
- this.continueLoc = continueLoc;
- this.label = label;
- }
- inherits(LoopEntry, Entry);
- exports.LoopEntry = LoopEntry;
- function SwitchEntry(breakLoc) {
- Entry.call(this);
- n.Literal.assert(breakLoc);
- this.breakLoc = breakLoc;
- }
- inherits(SwitchEntry, Entry);
- exports.SwitchEntry = SwitchEntry;
- function TryEntry(firstLoc, catchEntry, finallyEntry) {
- Entry.call(this);
- n.Literal.assert(firstLoc);
- if (catchEntry) {
- assert.ok(catchEntry instanceof CatchEntry);
- } else {
- catchEntry = null;
- }
- if (finallyEntry) {
- assert.ok(finallyEntry instanceof FinallyEntry);
- } else {
- finallyEntry = null;
- }
- // Have to have one or the other (or both).
- assert.ok(catchEntry || finallyEntry);
- this.firstLoc = firstLoc;
- this.catchEntry = catchEntry;
- this.finallyEntry = finallyEntry;
- }
- inherits(TryEntry, Entry);
- exports.TryEntry = TryEntry;
- function CatchEntry(firstLoc, paramId) {
- Entry.call(this);
- n.Literal.assert(firstLoc);
- n.Identifier.assert(paramId);
- this.firstLoc = firstLoc;
- this.paramId = paramId;
- }
- inherits(CatchEntry, Entry);
- exports.CatchEntry = CatchEntry;
- function FinallyEntry(firstLoc, afterLoc) {
- Entry.call(this);
- n.Literal.assert(firstLoc);
- n.Literal.assert(afterLoc);
- this.firstLoc = firstLoc;
- this.afterLoc = afterLoc;
- }
- inherits(FinallyEntry, Entry);
- exports.FinallyEntry = FinallyEntry;
- function LabeledEntry(breakLoc, label) {
- Entry.call(this);
- n.Literal.assert(breakLoc);
- n.Identifier.assert(label);
- this.breakLoc = breakLoc;
- this.label = label;
- }
- inherits(LabeledEntry, Entry);
- exports.LabeledEntry = LabeledEntry;
- function LeapManager(emitter) {
- assert.ok(this instanceof LeapManager);
- var Emitter = require("./emit").Emitter;
- assert.ok(emitter instanceof Emitter);
- this.emitter = emitter;
- this.entryStack = [new FunctionEntry(emitter.finalLoc)];
- }
- var LMp = LeapManager.prototype;
- exports.LeapManager = LeapManager;
- LMp.withEntry = function(entry, callback) {
- assert.ok(entry instanceof Entry);
- this.entryStack.push(entry);
- try {
- callback.call(this.emitter);
- } finally {
- var popped = this.entryStack.pop();
- assert.strictEqual(popped, entry);
- }
- };
- LMp._findLeapLocation = function(property, label) {
- for (var i = this.entryStack.length - 1; i >= 0; --i) {
- var entry = this.entryStack[i];
- var loc = entry[property];
- if (loc) {
- if (label) {
- if (entry.label &&
- entry.label.name === label.name) {
- return loc;
- }
- } else if (entry instanceof LabeledEntry) {
- // Ignore LabeledEntry entries unless we are actually breaking to
- // a label.
- } else {
- return loc;
- }
- }
- }
- return null;
- };
- LMp.getBreakLoc = function(label) {
- return this._findLeapLocation("breakLoc", label);
- };
- LMp.getContinueLoc = function(label) {
- return this._findLeapLocation("continueLoc", label);
- };
- },{"./emit":436,"assert":190,"recast":469,"util":216}],439:[function(require,module,exports){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- var assert = require("assert");
- var m = require("private").makeAccessor();
- var types = require("recast").types;
- var isArray = types.builtInTypes.array;
- var n = types.namedTypes;
- var hasOwn = Object.prototype.hasOwnProperty;
- function makePredicate(propertyName, knownTypes) {
- function onlyChildren(node) {
- n.Node.assert(node);
- // Assume no side effects until we find out otherwise.
- var result = false;
- function check(child) {
- if (result) {
- // Do nothing.
- } else if (isArray.check(child)) {
- child.some(check);
- } else if (n.Node.check(child)) {
- assert.strictEqual(result, false);
- result = predicate(child);
- }
- return result;
- }
- types.eachField(node, function(name, child) {
- check(child);
- });
- return result;
- }
- function predicate(node) {
- n.Node.assert(node);
- var meta = m(node);
- if (hasOwn.call(meta, propertyName))
- return meta[propertyName];
- // Certain types are "opaque," which means they have no side
- // effects or leaps and we don't care about their subexpressions.
- if (hasOwn.call(opaqueTypes, node.type))
- return meta[propertyName] = false;
- if (hasOwn.call(knownTypes, node.type))
- return meta[propertyName] = true;
- return meta[propertyName] = onlyChildren(node);
- }
- predicate.onlyChildren = onlyChildren;
- return predicate;
- }
- var opaqueTypes = {
- FunctionExpression: true
- };
- // These types potentially have side effects regardless of what side
- // effects their subexpressions have.
- var sideEffectTypes = {
- CallExpression: true, // Anything could happen!
- ForInStatement: true, // Modifies the key variable.
- UnaryExpression: true, // Think delete.
- BinaryExpression: true, // Might invoke .toString() or .valueOf().
- AssignmentExpression: true, // Side-effecting by definition.
- UpdateExpression: true, // Updates are essentially assignments.
- NewExpression: true // Similar to CallExpression.
- };
- // These types are the direct cause of all leaps in control flow.
- var leapTypes = {
- YieldExpression: true,
- BreakStatement: true,
- ContinueStatement: true,
- ReturnStatement: true,
- ThrowStatement: true
- };
- // All leap types are also side effect types.
- for (var type in leapTypes) {
- if (hasOwn.call(leapTypes, type)) {
- sideEffectTypes[type] = leapTypes[type];
- }
- }
- exports.hasSideEffects = makePredicate("hasSideEffects", sideEffectTypes);
- exports.containsLeap = makePredicate("containsLeap", leapTypes);
- },{"assert":190,"private":435,"recast":469}],440:[function(require,module,exports){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- var assert = require("assert");
- var types = require("recast").types;
- var n = types.namedTypes;
- var b = types.builders;
- var hasOwn = Object.prototype.hasOwnProperty;
- exports.defaults = function(obj) {
- var len = arguments.length;
- var extension;
- for (var i = 1; i < len; ++i) {
- if ((extension = arguments[i])) {
- for (var key in extension) {
- if (hasOwn.call(extension, key) && !hasOwn.call(obj, key)) {
- obj[key] = extension[key];
- }
- }
- }
- }
- return obj;
- };
- exports.runtimeProperty = function(name) {
- return b.memberExpression(
- b.identifier("regeneratorRuntime"),
- b.identifier(name),
- false
- );
- };
- // Inspired by the isReference function from ast-util:
- // https://github.com/eventualbuddha/ast-util/blob/9bf91c5ce8/lib/index.js#L466-L506
- exports.isReference = function(path, name) {
- var node = path.value;
- if (!n.Identifier.check(node)) {
- return false;
- }
- if (name && node.name !== name) {
- return false;
- }
- var parent = path.parent.value;
- switch (parent.type) {
- case "VariableDeclarator":
- return path.name === "init";
- case "MemberExpression":
- return path.name === "object" || (
- parent.computed && path.name === "property"
- );
- case "FunctionExpression":
- case "FunctionDeclaration":
- case "ArrowFunctionExpression":
- if (path.name === "id") {
- return false;
- }
- if (parent.params === path.parentPath &&
- parent.params[path.name] === node) {
- return false;
- }
- return true;
- case "ClassDeclaration":
- case "ClassExpression":
- return path.name !== "id";
- case "CatchClause":
- return path.name !== "param";
- case "Property":
- case "MethodDefinition":
- return path.name !== "key";
- case "ImportSpecifier":
- case "ImportDefaultSpecifier":
- case "ImportNamespaceSpecifier":
- case "LabeledStatement":
- return false;
- default:
- return true;
- }
- };
- },{"assert":190,"recast":469}],441:[function(require,module,exports){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- var assert = require("assert");
- var fs = require("fs");
- var recast = require("recast");
- var types = recast.types;
- var n = types.namedTypes;
- var b = types.builders;
- var isArray = types.builtInTypes.array;
- var isObject = types.builtInTypes.object;
- var NodePath = types.NodePath;
- var hoist = require("./hoist").hoist;
- var Emitter = require("./emit").Emitter;
- var runtimeProperty = require("./util").runtimeProperty;
- var getMarkInfo = require("private").makeAccessor();
- exports.transform = function transform(node, options) {
- options = options || {};
- var path = node instanceof NodePath ? node : new NodePath(node);
- visitor.visit(path, options);
- node = path.value;
- if (options.includeRuntime === true ||
- (options.includeRuntime === 'if used' && visitor.wasChangeReported())) {
- injectRuntime(n.File.check(node) ? node.program : node);
- }
- options.madeChanges = visitor.wasChangeReported();
- return node;
- };
- function injectRuntime(program) {
- n.Program.assert(program);
- // Include the runtime by modifying the AST rather than by concatenating
- // strings. This technique will allow for more accurate source mapping.
- var runtimePath = require("..").runtime.path;
- var runtime = fs.readFileSync(runtimePath, "utf8");
- var runtimeBody = recast.parse(runtime, {
- sourceFileName: runtimePath
- }).program.body;
- var body = program.body;
- body.unshift.apply(body, runtimeBody);
- }
- var visitor = types.PathVisitor.fromMethodsObject({
- reset: function(node, options) {
- this.options = options;
- },
- visitFunction: function(path) {
- // Calling this.traverse(path) first makes for a post-order traversal.
- this.traverse(path);
- var node = path.value;
- var shouldTransformAsync = node.async && !this.options.disableAsync;
- if (!node.generator && !shouldTransformAsync) {
- return;
- }
- this.reportChanged();
- node.generator = false;
- if (node.expression) {
- // Transform expression lambdas into normal functions.
- node.expression = false;
- node.body = b.blockStatement([
- b.returnStatement(node.body)
- ]);
- }
- if (shouldTransformAsync) {
- awaitVisitor.visit(path.get("body"));
- }
- var outerBody = [];
- var innerBody = [];
- var bodyPath = path.get("body", "body");
- bodyPath.each(function(childPath) {
- var node = childPath.value;
- if (node && node._blockHoist != null) {
- outerBody.push(node);
- } else {
- innerBody.push(node);
- }
- });
- if (outerBody.length > 0) {
- // Only replace the inner body if we actually hoisted any statements
- // to the outer body.
- bodyPath.replace(innerBody);
- }
- var outerFnExpr = getOuterFnExpr(path);
- // Note that getOuterFnExpr has the side-effect of ensuring that the
- // function has a name (so node.id will always be an Identifier), even
- // if a temporary name has to be synthesized.
- n.Identifier.assert(node.id);
- var innerFnId = b.identifier(node.id.name + "$");
- var contextId = path.scope.declareTemporary("context$");
- var argsId = path.scope.declareTemporary("args$");
- var shouldAliasArguments = renameArguments(path, argsId);
- var vars = hoist(path);
- if (shouldAliasArguments) {
- vars = vars || b.variableDeclaration("var", []);
- vars.declarations.push(b.variableDeclarator(
- argsId, b.identifier("arguments")
- ));
- }
- var emitter = new Emitter(contextId);
- emitter.explode(path.get("body"));
- if (vars && vars.declarations.length > 0) {
- outerBody.push(vars);
- }
- var wrapArgs = [
- emitter.getContextFunction(innerFnId),
- // Async functions don't care about the outer function because they
- // don't need it to be marked and don't inherit from its .prototype.
- shouldTransformAsync ? b.literal(null) : outerFnExpr,
- b.thisExpression()
- ];
- var tryLocsList = emitter.getTryLocsList();
- if (tryLocsList) {
- wrapArgs.push(tryLocsList);
- }
- var wrapCall = b.callExpression(
- runtimeProperty(shouldTransformAsync ? "async" : "wrap"),
- wrapArgs
- );
- outerBody.push(b.returnStatement(wrapCall));
- node.body = b.blockStatement(outerBody);
- if (shouldTransformAsync) {
- node.async = false;
- return;
- }
- if (n.Expression.check(node)) {
- return b.callExpression(runtimeProperty("mark"), [node]);
- }
- },
- visitForOfStatement: function(path) {
- this.traverse(path);
- var node = path.value;
- var tempIterId = path.scope.declareTemporary("t$");
- var tempIterDecl = b.variableDeclarator(
- tempIterId,
- b.callExpression(
- runtimeProperty("values"),
- [node.right]
- )
- );
- var tempInfoId = path.scope.declareTemporary("t$");
- var tempInfoDecl = b.variableDeclarator(tempInfoId, null);
- var init = node.left;
- var loopId;
- if (n.VariableDeclaration.check(init)) {
- loopId = init.declarations[0].id;
- init.declarations.push(tempIterDecl, tempInfoDecl);
- } else {
- loopId = init;
- init = b.variableDeclaration("var", [
- tempIterDecl,
- tempInfoDecl
- ]);
- }
- n.Identifier.assert(loopId);
- var loopIdAssignExprStmt = b.expressionStatement(
- b.assignmentExpression(
- "=",
- loopId,
- b.memberExpression(
- tempInfoId,
- b.identifier("value"),
- false
- )
- )
- );
- if (n.BlockStatement.check(node.body)) {
- node.body.body.unshift(loopIdAssignExprStmt);
- } else {
- node.body = b.blockStatement([
- loopIdAssignExprStmt,
- node.body
- ]);
- }
- return b.forStatement(
- init,
- b.unaryExpression(
- "!",
- b.memberExpression(
- b.assignmentExpression(
- "=",
- tempInfoId,
- b.callExpression(
- b.memberExpression(
- tempIterId,
- b.identifier("next"),
- false
- ),
- []
- )
- ),
- b.identifier("done"),
- false
- )
- ),
- null,
- node.body
- );
- }
- });
- // Given a NodePath for a Function, return an Expression node that can be
- // used to refer reliably to the function object from inside the function.
- // This expression is essentially a replacement for arguments.callee, with
- // the key advantage that it works in strict mode.
- function getOuterFnExpr(funPath) {
- var node = funPath.value;
- n.Function.assert(node);
- if (!node.async && // Async functions don't need to be marked.
- n.FunctionDeclaration.check(node)) {
- var pp = funPath.parent;
- while (pp && !(n.BlockStatement.check(pp.value) ||
- n.Program.check(pp.value))) {
- pp = pp.parent;
- }
- if (!pp) {
- return node.id;
- }
- var markDecl = getRuntimeMarkDecl(pp);
- var markedArray = markDecl.declarations[0].id;
- var funDeclIdArray = markDecl.declarations[0].init.callee.object;
- n.ArrayExpression.assert(funDeclIdArray);
- var index = funDeclIdArray.elements.length;
- funDeclIdArray.elements.push(node.id);
- return b.memberExpression(
- markedArray,
- b.literal(index),
- true
- );
- }
- return node.id || (
- node.id = funPath.scope.parent.declareTemporary("callee$")
- );
- }
- function getRuntimeMarkDecl(blockPath) {
- assert.ok(blockPath instanceof NodePath);
- var block = blockPath.node;
- isArray.assert(block.body);
- var info = getMarkInfo(block);
- if (info.decl) {
- return info.decl;
- }
- info.decl = b.variableDeclaration("var", [
- b.variableDeclarator(
- blockPath.scope.declareTemporary("marked"),
- b.callExpression(
- b.memberExpression(
- b.arrayExpression([]),
- b.identifier("map"),
- false
- ),
- [runtimeProperty("mark")]
- )
- )
- ]);
- for (var i = 0; i < block.body.length; ++i) {
- if (!shouldNotHoistAbove(blockPath.get("body", i))) {
- break;
- }
- }
- blockPath.get("body").insertAt(i, info.decl);
- return info.decl;
- }
- function shouldNotHoistAbove(stmtPath) {
- var value = stmtPath.value;
- n.Statement.assert(value);
- // If the first statement is a "use strict" declaration, make sure to
- // insert hoisted declarations afterwards.
- return n.ExpressionStatement.check(value) &&
- n.Literal.check(value.expression) &&
- value.expression.value === "use strict";
- }
- function renameArguments(funcPath, argsId) {
- assert.ok(funcPath instanceof types.NodePath);
- var func = funcPath.value;
- var didReplaceArguments = false;
- var hasImplicitArguments = false;
- recast.visit(funcPath, {
- visitFunction: function(path) {
- if (path.value === func) {
- hasImplicitArguments = !path.scope.lookup("arguments");
- this.traverse(path);
- } else {
- return false;
- }
- },
- visitIdentifier: function(path) {
- if (path.value.name === "arguments") {
- var isMemberProperty =
- n.MemberExpression.check(path.parent.node) &&
- path.name === "property" &&
- !path.parent.node.computed;
- if (!isMemberProperty) {
- path.replace(argsId);
- didReplaceArguments = true;
- return false;
- }
- }
- this.traverse(path);
- }
- });
- // If the traversal replaced any arguments identifiers, and those
- // identifiers were free variables, then we need to alias the outer
- // function's arguments object to the variable named by argsId.
- return didReplaceArguments && hasImplicitArguments;
- }
- var awaitVisitor = types.PathVisitor.fromMethodsObject({
- visitFunction: function(path) {
- return false; // Don't descend into nested function scopes.
- },
- visitAwaitExpression: function(path) {
- // Convert await and await* expressions to yield expressions.
- var argument = path.value.argument;
- // If the parser supports await* syntax using a boolean .all property
- // (#171), desugar that syntax to yield Promise.all(argument).
- if (path.value.all) {
- argument = b.callExpression(
- b.memberExpression(
- b.identifier("Promise"),
- b.identifier("all"),
- false
- ),
- [argument]
- );
- }
- return b.yieldExpression(argument, false);
- }
- });
- },{"..":442,"./emit":436,"./hoist":437,"./util":440,"assert":190,"fs":189,"private":435,"recast":469}],442:[function(require,module,exports){
- (function (__dirname){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- var assert = require("assert");
- var path = require("path");
- var fs = require("fs");
- var through = require("through");
- var transform = require("./lib/visit").transform;
- var utils = require("./lib/util");
- var recast = require("recast");
- var types = recast.types;
- var genOrAsyncFunExp = /\bfunction\s*\*|\basync\b/;
- var blockBindingExp = /\b(let|const)\s+/;
- function exports(file, options) {
- var data = [];
- return through(write, end);
- function write(buf) {
- data.push(buf);
- }
- function end() {
- this.queue(compile(data.join(""), options).code);
- this.queue(null);
- }
- }
- // To get a writable stream for use as a browserify transform, call
- // require("regenerator")().
- module.exports = exports;
- // To include the runtime globally in the current node process, call
- // require("regenerator").runtime().
- function runtime() {
- require("./runtime");
- }
- exports.runtime = runtime;
- runtime.path = path.join(__dirname, "runtime.js");
- function compile(source, options) {
- options = normalizeOptions(options);
- if (!genOrAsyncFunExp.test(source)) {
- return {
- // Shortcut: no generators or async functions to transform.
- code: (options.includeRuntime === true ? fs.readFileSync(
- path.join(__dirname, "runtime.js"), "utf-8"
- ) + "\n" : "") + source
- };
- }
- var recastOptions = getRecastOptions(options);
- var ast = recast.parse(source, recastOptions);
- var nodePath = new types.NodePath(ast);
- var programPath = nodePath.get("program");
- if (shouldVarify(source, options)) {
- // Transpile let/const into var declarations.
- varifyAst(programPath.node);
- }
- transform(programPath, options);
- return recast.print(nodePath, recastOptions);
- }
- function normalizeOptions(options) {
- options = utils.defaults(options || {}, {
- includeRuntime: false,
- supportBlockBinding: true
- });
- if (!options.esprima) {
- options.esprima = require("esprima-fb");
- }
- assert.ok(
- /harmony/.test(options.esprima.version),
- "Bad esprima version: " + options.esprima.version
- );
- return options;
- }
- function getRecastOptions(options) {
- var recastOptions = {
- range: true
- };
- function copy(name) {
- if (name in options) {
- recastOptions[name] = options[name];
- }
- }
- copy("esprima");
- copy("sourceFileName");
- copy("sourceMapName");
- copy("inputSourceMap");
- copy("sourceRoot");
- return recastOptions;
- }
- function shouldVarify(source, options) {
- var supportBlockBinding = !!options.supportBlockBinding;
- if (supportBlockBinding) {
- if (!blockBindingExp.test(source)) {
- supportBlockBinding = false;
- }
- }
- return supportBlockBinding;
- }
- function varify(source, options) {
- var recastOptions = getRecastOptions(normalizeOptions(options));
- var ast = recast.parse(source, recastOptions);
- varifyAst(ast.program);
- return recast.print(ast, recastOptions).code;
- }
- function varifyAst(ast) {
- types.namedTypes.Program.assert(ast);
- var defsResult = require("defs")(ast, {
- ast: true,
- disallowUnknownReferences: false,
- disallowDuplicated: false,
- disallowVars: false,
- loopClosures: "iife"
- });
- if (defsResult.errors) {
- throw new Error(defsResult.errors.join("\n"))
- }
- return ast;
- }
- // Convenience for just translating let/const to var declarations.
- exports.varify = varify;
- // Transforms a string of source code, returning the { code, map? } result
- // from recast.print.
- exports.compile = compile;
- // To modify an AST directly, call require("regenerator").transform(ast).
- exports.transform = transform;
- }).call(this,"/node_modules/regenerator")
- },{"./lib/util":440,"./lib/visit":441,"./runtime":472,"assert":190,"defs":443,"esprima-fb":458,"fs":189,"path":199,"recast":469,"through":471}],443:[function(require,module,exports){
- "use strict";
- var assert = require("assert");
- var is = require("simple-is");
- var fmt = require("simple-fmt");
- var stringmap = require("stringmap");
- var stringset = require("stringset");
- var alter = require("alter");
- var traverse = require("ast-traverse");
- var breakable = require("breakable");
- var Scope = require("./scope");
- var error = require("./error");
- var getline = error.getline;
- var options = require("./options");
- var Stats = require("./stats");
- var jshint_vars = require("./jshint_globals/vars.js");
- function isConstLet(kind) {
- return is.someof(kind, ["const", "let"]);
- }
- function isVarConstLet(kind) {
- return is.someof(kind, ["var", "const", "let"]);
- }
- function isNonFunctionBlock(node) {
- return node.type === "BlockStatement" && is.noneof(node.$parent.type, ["FunctionDeclaration", "FunctionExpression"]);
- }
- function isForWithConstLet(node) {
- return node.type === "ForStatement" && node.init && node.init.type === "VariableDeclaration" && isConstLet(node.init.kind);
- }
- function isForInOfWithConstLet(node) {
- return isForInOf(node) && node.left.type === "VariableDeclaration" && isConstLet(node.left.kind);
- }
- function isForInOf(node) {
- return is.someof(node.type, ["ForInStatement", "ForOfStatement"]);
- }
- function isFunction(node) {
- return is.someof(node.type, ["FunctionDeclaration", "FunctionExpression"]);
- }
- function isLoop(node) {
- return is.someof(node.type, ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement"]);
- }
- function isReference(node) {
- var parent = node.$parent;
- return node.$refToScope ||
- node.type === "Identifier" &&
- !(parent.type === "VariableDeclarator" && parent.id === node) && // var|let|const $
- !(parent.type === "MemberExpression" && parent.computed === false && parent.property === node) && // obj.$
- !(parent.type === "Property" && parent.key === node) && // {$: ...}
- !(parent.type === "LabeledStatement" && parent.label === node) && // $: ...
- !(parent.type === "CatchClause" && parent.param === node) && // catch($)
- !(isFunction(parent) && parent.id === node) && // function $(..
- !(isFunction(parent) && is.someof(node, parent.params)) && // function f($)..
- true;
- }
- function isLvalue(node) {
- return isReference(node) &&
- ((node.$parent.type === "AssignmentExpression" && node.$parent.left === node) ||
- (node.$parent.type === "UpdateExpression" && node.$parent.argument === node));
- }
- function createScopes(node, parent) {
- assert(!node.$scope);
- node.$parent = parent;
- node.$scope = node.$parent ? node.$parent.$scope : null; // may be overridden
- if (node.type === "Program") {
- // Top-level program is a scope
- // There's no block-scope under it
- node.$scope = new Scope({
- kind: "hoist",
- node: node,
- parent: null,
- });
- } else if (isFunction(node)) {
- // Function is a scope, with params in it
- // There's no block-scope under it
- node.$scope = new Scope({
- kind: "hoist",
- node: node,
- parent: node.$parent.$scope,
- });
- // function has a name
- if (node.id) {
- assert(node.id.type === "Identifier");
- if (node.type === "FunctionDeclaration") {
- // Function name goes in parent scope for declared functions
- node.$parent.$scope.add(node.id.name, "fun", node.id, null);
- } else if (node.type === "FunctionExpression") {
- // Function name goes in function's scope for named function expressions
- node.$scope.add(node.id.name, "fun", node.id, null);
- } else {
- assert(false);
- }
- }
- node.params.forEach(function(param) {
- node.$scope.add(param.name, "param", param, null);
- });
- } else if (node.type === "VariableDeclaration") {
- // Variable declarations names goes in current scope
- assert(isVarConstLet(node.kind));
- node.declarations.forEach(function(declarator) {
- assert(declarator.type === "VariableDeclarator");
- var name = declarator.id.name;
- if (options.disallowVars && node.kind === "var") {
- error(getline(declarator), "var {0} is not allowed (use let or const)", name);
- }
- node.$scope.add(name, node.kind, declarator.id, declarator.range[1]);
- });
- } else if (isForWithConstLet(node) || isForInOfWithConstLet(node)) {
- // For(In/Of) loop with const|let declaration is a scope, with declaration in it
- // There may be a block-scope under it
- node.$scope = new Scope({
- kind: "block",
- node: node,
- parent: node.$parent.$scope,
- });
- } else if (isNonFunctionBlock(node)) {
- // A block node is a scope unless parent is a function
- node.$scope = new Scope({
- kind: "block",
- node: node,
- parent: node.$parent.$scope,
- });
- } else if (node.type === "CatchClause") {
- var identifier = node.param;
- node.$scope = new Scope({
- kind: "catch-block",
- node: node,
- parent: node.$parent.$scope,
- });
- node.$scope.add(identifier.name, "caught", identifier, null);
- // All hoist-scope keeps track of which variables that are propagated through,
- // i.e. an reference inside the scope points to a declaration outside the scope.
- // This is used to mark "taint" the name since adding a new variable in the scope,
- // with a propagated name, would change the meaning of the existing references.
- //
- // catch(e) is special because even though e is a variable in its own scope,
- // we want to make sure that catch(e){let e} is never transformed to
- // catch(e){var e} (but rather var e$0). For that reason we taint the use of e
- // in the closest hoist-scope, i.e. where var e$0 belongs.
- node.$scope.closestHoistScope().markPropagates(identifier.name);
- }
- }
- function createTopScope(programScope, environments, globals) {
- function inject(obj) {
- for (var name in obj) {
- var writeable = obj[name];
- var kind = (writeable ? "var" : "const");
- if (topScope.hasOwn(name)) {
- topScope.remove(name);
- }
- topScope.add(name, kind, {loc: {start: {line: -1}}}, -1);
- }
- }
- var topScope = new Scope({
- kind: "hoist",
- node: {},
- parent: null,
- });
- var complementary = {
- undefined: false,
- Infinity: false,
- console: false,
- };
- inject(complementary);
- inject(jshint_vars.reservedVars);
- inject(jshint_vars.ecmaIdentifiers);
- if (environments) {
- environments.forEach(function(env) {
- if (!jshint_vars[env]) {
- error(-1, 'environment "{0}" not found', env);
- } else {
- inject(jshint_vars[env]);
- }
- });
- }
- if (globals) {
- inject(globals);
- }
- // link it in
- programScope.parent = topScope;
- topScope.children.push(programScope);
- return topScope;
- }
- function setupReferences(ast, allIdentifiers, opts) {
- var analyze = (is.own(opts, "analyze") ? opts.analyze : true);
- function visit(node) {
- if (!isReference(node)) {
- return;
- }
- allIdentifiers.add(node.name);
- var scope = node.$scope.lookup(node.name);
- if (analyze && !scope && options.disallowUnknownReferences) {
- error(getline(node), "reference to unknown global variable {0}", node.name);
- }
- // check const and let for referenced-before-declaration
- if (analyze && scope && is.someof(scope.getKind(node.name), ["const", "let"])) {
- var allowedFromPos = scope.getFromPos(node.name);
- var referencedAtPos = node.range[0];
- assert(is.finitenumber(allowedFromPos));
- assert(is.finitenumber(referencedAtPos));
- if (referencedAtPos < allowedFromPos) {
- if (!node.$scope.hasFunctionScopeBetween(scope)) {
- error(getline(node), "{0} is referenced before its declaration", node.name);
- }
- }
- }
- node.$refToScope = scope;
- }
- traverse(ast, {pre: visit});
- }
- // TODO for loops init and body props are parallel to each other but init scope is outer that of body
- // TODO is this a problem?
- function varify(ast, stats, allIdentifiers, changes) {
- function unique(name) {
- assert(allIdentifiers.has(name));
- for (var cnt = 0; ; cnt++) {
- var genName = name + "$" + String(cnt);
- if (!allIdentifiers.has(genName)) {
- return genName;
- }
- }
- }
- function renameDeclarations(node) {
- if (node.type === "VariableDeclaration" && isConstLet(node.kind)) {
- var hoistScope = node.$scope.closestHoistScope();
- var origScope = node.$scope;
- // text change const|let => var
- changes.push({
- start: node.range[0],
- end: node.range[0] + node.kind.length,
- str: "var",
- });
- node.declarations.forEach(function(declarator) {
- assert(declarator.type === "VariableDeclarator");
- var name = declarator.id.name;
- stats.declarator(node.kind);
- // rename if
- // 1) name already exists in hoistScope, or
- // 2) name is already propagated (passed) through hoistScope or manually tainted
- var rename = (origScope !== hoistScope &&
- (hoistScope.hasOwn(name) || hoistScope.doesPropagate(name)));
- var newName = (rename ? unique(name) : name);
- origScope.remove(name);
- hoistScope.add(newName, "var", declarator.id, declarator.range[1]);
- origScope.moves = origScope.moves || stringmap();
- origScope.moves.set(name, {
- name: newName,
- scope: hoistScope,
- });
- allIdentifiers.add(newName);
- if (newName !== name) {
- stats.rename(name, newName, getline(declarator));
- declarator.id.originalName = name;
- declarator.id.name = newName;
- // textchange var x => var x$1
- changes.push({
- start: declarator.id.range[0],
- end: declarator.id.range[1],
- str: newName,
- });
- }
- });
- // ast change const|let => var
- node.kind = "var";
- }
- }
- function renameReferences(node) {
- if (!node.$refToScope) {
- return;
- }
- var move = node.$refToScope.moves && node.$refToScope.moves.get(node.name);
- if (!move) {
- return;
- }
- node.$refToScope = move.scope;
- if (node.name !== move.name) {
- node.originalName = node.name;
- node.name = move.name;
- if (node.alterop) {
- // node has no range because it is the result of another alter operation
- var existingOp = null;
- for (var i = 0; i < changes.length; i++) {
- var op = changes[i];
- if (op.node === node) {
- existingOp = op;
- break;
- }
- }
- assert(existingOp);
- // modify op
- existingOp.str = move.name;
- } else {
- changes.push({
- start: node.range[0],
- end: node.range[1],
- str: move.name,
- });
- }
- }
- }
- traverse(ast, {pre: renameDeclarations});
- traverse(ast, {pre: renameReferences});
- ast.$scope.traverse({pre: function(scope) {
- delete scope.moves;
- }});
- }
- function detectLoopClosures(ast) {
- traverse(ast, {pre: visit});
- function detectIifyBodyBlockers(body, node) {
- return breakable(function(brk) {
- traverse(body, {pre: function(n) {
- // if we hit an inner function of the loop body, don't traverse further
- if (isFunction(n)) {
- return false;
- }
- var err = true; // reset to false in else-statement below
- var msg = "loop-variable {0} is captured by a loop-closure that can't be transformed due to use of {1} at line {2}";
- if (n.type === "BreakStatement") {
- error(getline(node), msg, node.name, "break", getline(n));
- } else if (n.type === "ContinueStatement") {
- error(getline(node), msg, node.name, "continue", getline(n));
- } else if (n.type === "ReturnStatement") {
- error(getline(node), msg, node.name, "return", getline(n));
- } else if (n.type === "YieldExpression") {
- error(getline(node), msg, node.name, "yield", getline(n));
- } else if (n.type === "Identifier" && n.name === "arguments") {
- error(getline(node), msg, node.name, "arguments", getline(n));
- } else if (n.type === "VariableDeclaration" && n.kind === "var") {
- error(getline(node), msg, node.name, "var", getline(n));
- } else {
- err = false;
- }
- if (err) {
- brk(true); // break traversal
- }
- }});
- return false;
- });
- }
- function visit(node) {
- // forbidden pattern:
- // <any>* <loop> <non-fn>* <constlet-def> <any>* <fn> <any>* <constlet-ref>
- var loopNode = null;
- if (isReference(node) && node.$refToScope && isConstLet(node.$refToScope.getKind(node.name))) {
- // traverse nodes up towards root from constlet-def
- // if we hit a function (before a loop) - ok!
- // if we hit a loop - maybe-ouch
- // if we reach root - ok!
- for (var n = node.$refToScope.node; ; ) {
- if (isFunction(n)) {
- // we're ok (function-local)
- return;
- } else if (isLoop(n)) {
- loopNode = n;
- // maybe not ok (between loop and function)
- break;
- }
- n = n.$parent;
- if (!n) {
- // ok (reached root)
- return;
- }
- }
- assert(isLoop(loopNode));
- // traverse scopes from reference-scope up towards definition-scope
- // if we hit a function, ouch!
- var defScope = node.$refToScope;
- var generateIIFE = (options.loopClosures === "iife");
- for (var s = node.$scope; s; s = s.parent) {
- if (s === defScope) {
- // we're ok
- return;
- } else if (isFunction(s.node)) {
- // not ok (there's a function between the reference and definition)
- // may be transformable via IIFE
- if (!generateIIFE) {
- var msg = "loop-variable {0} is captured by a loop-closure. Tried \"loopClosures\": \"iife\" in defs-config.json?";
- return error(getline(node), msg, node.name);
- }
- // here be dragons
- // for (let x = ..; .. ; ..) { (function(){x})() } is forbidden because of current
- // spec and VM status
- if (loopNode.type === "ForStatement" && defScope.node === loopNode) {
- var declarationNode = defScope.getNode(node.name);
- return error(getline(declarationNode), "Not yet specced ES6 feature. {0} is declared in for-loop header and then captured in loop closure", declarationNode.name);
- }
- // speak now or forever hold your peace
- if (detectIifyBodyBlockers(loopNode.body, node)) {
- // error already generated
- return;
- }
- // mark loop for IIFE-insertion
- loopNode.$iify = true;
- }
- }
- }
- }
- }
- function transformLoopClosures(root, ops, options) {
- function insertOp(pos, str, node) {
- var op = {
- start: pos,
- end: pos,
- str: str,
- }
- if (node) {
- op.node = node;
- }
- ops.push(op);
- }
- traverse(root, {pre: function(node) {
- if (!node.$iify) {
- return;
- }
- var hasBlock = (node.body.type === "BlockStatement");
- var insertHead = (hasBlock ?
- node.body.range[0] + 1 : // just after body {
- node.body.range[0]); // just before existing expression
- var insertFoot = (hasBlock ?
- node.body.range[1] - 1 : // just before body }
- node.body.range[1]); // just after existing expression
- var forInName = (isForInOf(node) && node.left.declarations[0].id.name);;
- var iifeHead = fmt("(function({0}){", forInName ? forInName : "");
- var iifeTail = fmt("}).call(this{0});", forInName ? ", " + forInName : "");
- // modify AST
- var iifeFragment = options.parse(iifeHead + iifeTail);
- var iifeExpressionStatement = iifeFragment.body[0];
- var iifeBlockStatement = iifeExpressionStatement.expression.callee.object.body;
- if (hasBlock) {
- var forBlockStatement = node.body;
- var tmp = forBlockStatement.body;
- forBlockStatement.body = [iifeExpressionStatement];
- iifeBlockStatement.body = tmp;
- } else {
- var tmp$0 = node.body;
- node.body = iifeExpressionStatement;
- iifeBlockStatement.body[0] = tmp$0;
- }
- // create ops
- insertOp(insertHead, iifeHead);
- if (forInName) {
- insertOp(insertFoot, "}).call(this, ");
- var args = iifeExpressionStatement.expression.arguments;
- var iifeArgumentIdentifier = args[1];
- iifeArgumentIdentifier.alterop = true;
- insertOp(insertFoot, forInName, iifeArgumentIdentifier);
- insertOp(insertFoot, ");");
- } else {
- insertOp(insertFoot, iifeTail);
- }
- }});
- }
- function detectConstAssignment(ast) {
- traverse(ast, {pre: function(node) {
- if (isLvalue(node)) {
- var scope = node.$scope.lookup(node.name);
- if (scope && scope.getKind(node.name) === "const") {
- error(getline(node), "can't assign to const variable {0}", node.name);
- }
- }
- }});
- }
- function detectConstantLets(ast) {
- traverse(ast, {pre: function(node) {
- if (isLvalue(node)) {
- var scope = node.$scope.lookup(node.name);
- if (scope) {
- scope.markWrite(node.name);
- }
- }
- }});
- ast.$scope.detectUnmodifiedLets();
- }
- function setupScopeAndReferences(root, opts) {
- // setup scopes
- traverse(root, {pre: createScopes});
- var topScope = createTopScope(root.$scope, options.environments, options.globals);
- // allIdentifiers contains all declared and referenced vars
- // collect all declaration names (including those in topScope)
- var allIdentifiers = stringset();
- topScope.traverse({pre: function(scope) {
- allIdentifiers.addMany(scope.decls.keys());
- }});
- // setup node.$refToScope, check for errors.
- // also collects all referenced names to allIdentifiers
- setupReferences(root, allIdentifiers, opts);
- return allIdentifiers;
- }
- function cleanupTree(root) {
- traverse(root, {pre: function(node) {
- for (var prop in node) {
- if (prop[0] === "$") {
- delete node[prop];
- }
- }
- }});
- }
- function run(src, config) {
- // alter the options singleton with user configuration
- for (var key in config) {
- options[key] = config[key];
- }
- var parsed;
- if (is.object(src)) {
- if (!options.ast) {
- return {
- errors: [
- "Can't produce string output when input is an AST. " +
- "Did you forget to set options.ast = true?"
- ],
- };
- }
- // Received an AST object as src, so no need to parse it.
- parsed = src;
- } else if (is.string(src)) {
- try {
- parsed = options.parse(src, {
- loc: true,
- range: true,
- });
- } catch (e) {
- return {
- errors: [
- fmt("line {0} column {1}: Error during input file parsing\n{2}\n{3}",
- e.lineNumber,
- e.column,
- src.split("\n")[e.lineNumber - 1],
- fmt.repeat(" ", e.column - 1) + "^")
- ],
- };
- }
- } else {
- return {
- errors: ["Input was neither an AST object nor a string."],
- };
- }
- var ast = parsed;
- // TODO detect unused variables (never read)
- error.reset();
- var allIdentifiers = setupScopeAndReferences(ast, {});
- // static analysis passes
- detectLoopClosures(ast);
- detectConstAssignment(ast);
- //detectConstantLets(ast);
- var changes = [];
- transformLoopClosures(ast, changes, options);
- //ast.$scope.print(); process.exit(-1);
- if (error.errors.length >= 1) {
- return {
- errors: error.errors,
- };
- }
- if (changes.length > 0) {
- cleanupTree(ast);
- allIdentifiers = setupScopeAndReferences(ast, {analyze: false});
- }
- assert(error.errors.length === 0);
- // change constlet declarations to var, renamed if needed
- // varify modifies the scopes and AST accordingly and
- // returns a list of change fragments (to use with alter)
- var stats = new Stats();
- varify(ast, stats, allIdentifiers, changes);
- if (options.ast) {
- // return the modified AST instead of src code
- // get rid of all added $ properties first, such as $parent and $scope
- cleanupTree(ast);
- return {
- stats: stats,
- ast: ast,
- };
- } else {
- // apply changes produced by varify and return the transformed src
- var transformedSrc = alter(src, changes);
- return {
- stats: stats,
- src: transformedSrc,
- };
- }
- }
- module.exports = run;
- },{"./error":444,"./jshint_globals/vars.js":445,"./options":446,"./scope":447,"./stats":448,"alter":449,"assert":190,"ast-traverse":451,"breakable":452,"simple-fmt":454,"simple-is":455,"stringmap":456,"stringset":457}],444:[function(require,module,exports){
- "use strict";
- var fmt = require("simple-fmt");
- var assert = require("assert");
- function error(line, var_args) {
- assert(arguments.length >= 2);
- var msg = (arguments.length === 2 ?
- String(var_args) : fmt.apply(fmt, Array.prototype.slice.call(arguments, 1)));
- error.errors.push(line === -1 ? msg : fmt("line {0}: {1}", line, msg));
- }
- error.reset = function() {
- error.errors = [];
- };
- error.getline = function(node) {
- if (node && node.loc && node.loc.start) {
- return node.loc.start.line;
- }
- return -1;
- };
- error.reset();
- module.exports = error;
- },{"assert":190,"simple-fmt":454}],445:[function(require,module,exports){
- // jshint -W001
- "use strict";
- // Identifiers provided by the ECMAScript standard.
- exports.reservedVars = {
- arguments : false,
- NaN : false
- };
- exports.ecmaIdentifiers = {
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- "eval" : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Map : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- Set : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false,
- WeakMap : false
- };
- // Global variables commonly provided by a web browser environment.
- exports.browser = {
- ArrayBuffer : false,
- ArrayBufferView : false,
- Audio : false,
- Blob : false,
- addEventListener : false,
- applicationCache : false,
- atob : false,
- blur : false,
- btoa : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- DataView : false,
- DOMParser : false,
- defaultStatus : false,
- document : false,
- Element : false,
- event : false,
- FileReader : false,
- Float32Array : false,
- Float64Array : false,
- FormData : false,
- focus : false,
- frames : false,
- getComputedStyle : false,
- HTMLElement : false,
- HTMLAnchorElement : false,
- HTMLBaseElement : false,
- HTMLBlockquoteElement: false,
- HTMLBodyElement : false,
- HTMLBRElement : false,
- HTMLButtonElement : false,
- HTMLCanvasElement : false,
- HTMLDirectoryElement : false,
- HTMLDivElement : false,
- HTMLDListElement : false,
- HTMLFieldSetElement : false,
- HTMLFontElement : false,
- HTMLFormElement : false,
- HTMLFrameElement : false,
- HTMLFrameSetElement : false,
- HTMLHeadElement : false,
- HTMLHeadingElement : false,
- HTMLHRElement : false,
- HTMLHtmlElement : false,
- HTMLIFrameElement : false,
- HTMLImageElement : false,
- HTMLInputElement : false,
- HTMLIsIndexElement : false,
- HTMLLabelElement : false,
- HTMLLayerElement : false,
- HTMLLegendElement : false,
- HTMLLIElement : false,
- HTMLLinkElement : false,
- HTMLMapElement : false,
- HTMLMenuElement : false,
- HTMLMetaElement : false,
- HTMLModElement : false,
- HTMLObjectElement : false,
- HTMLOListElement : false,
- HTMLOptGroupElement : false,
- HTMLOptionElement : false,
- HTMLParagraphElement : false,
- HTMLParamElement : false,
- HTMLPreElement : false,
- HTMLQuoteElement : false,
- HTMLScriptElement : false,
- HTMLSelectElement : false,
- HTMLStyleElement : false,
- HTMLTableCaptionElement: false,
- HTMLTableCellElement : false,
- HTMLTableColElement : false,
- HTMLTableElement : false,
- HTMLTableRowElement : false,
- HTMLTableSectionElement: false,
- HTMLTextAreaElement : false,
- HTMLTitleElement : false,
- HTMLUListElement : false,
- HTMLVideoElement : false,
- history : false,
- Int16Array : false,
- Int32Array : false,
- Int8Array : false,
- Image : false,
- length : false,
- localStorage : false,
- location : false,
- MessageChannel : false,
- MessageEvent : false,
- MessagePort : false,
- moveBy : false,
- moveTo : false,
- MutationObserver : false,
- name : false,
- Node : false,
- NodeFilter : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- openDatabase : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener : false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- sessionStorage : false,
- setInterval : false,
- setTimeout : false,
- SharedWorker : false,
- status : false,
- top : false,
- Uint16Array : false,
- Uint32Array : false,
- Uint8Array : false,
- Uint8ClampedArray : false,
- WebSocket : false,
- window : false,
- Worker : false,
- XMLHttpRequest : false,
- XMLSerializer : false,
- XPathEvaluator : false,
- XPathException : false,
- XPathExpression : false,
- XPathNamespace : false,
- XPathNSResolver : false,
- XPathResult : false
- };
- exports.devel = {
- alert : false,
- confirm: false,
- console: false,
- Debug : false,
- opera : false,
- prompt : false
- };
- exports.worker = {
- importScripts: true,
- postMessage : true,
- self : true
- };
- // Widely adopted global names that are not part of ECMAScript standard
- exports.nonstandard = {
- escape : false,
- unescape: false
- };
- // Globals provided by popular JavaScript environments.
- exports.couch = {
- "require" : false,
- respond : false,
- getRow : false,
- emit : false,
- send : false,
- start : false,
- sum : false,
- log : false,
- exports : false,
- module : false,
- provides : false
- };
- exports.node = {
- __filename : false,
- __dirname : false,
- Buffer : false,
- DataView : false,
- console : false,
- exports : true, // In Node it is ok to exports = module.exports = foo();
- GLOBAL : false,
- global : false,
- module : false,
- process : false,
- require : false,
- setTimeout : false,
- clearTimeout : false,
- setInterval : false,
- clearInterval: false
- };
- exports.phantom = {
- phantom : true,
- require : true,
- WebPage : true
- };
- exports.rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- importPackage: false,
- "java" : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- };
- exports.wsh = {
- ActiveXObject : true,
- Enumerator : true,
- GetObject : true,
- ScriptEngine : true,
- ScriptEngineBuildVersion : true,
- ScriptEngineMajorVersion : true,
- ScriptEngineMinorVersion : true,
- VBArray : true,
- WSH : true,
- WScript : true,
- XDomainRequest : true
- };
- // Globals provided by popular JavaScript libraries.
- exports.dojo = {
- dojo : false,
- dijit : false,
- dojox : false,
- define : false,
- "require": false
- };
- exports.jquery = {
- "$" : false,
- jQuery : false
- };
- exports.mootools = {
- "$" : false,
- "$$" : false,
- Asset : false,
- Browser : false,
- Chain : false,
- Class : false,
- Color : false,
- Cookie : false,
- Core : false,
- Document : false,
- DomReady : false,
- DOMEvent : false,
- DOMReady : false,
- Drag : false,
- Element : false,
- Elements : false,
- Event : false,
- Events : false,
- Fx : false,
- Group : false,
- Hash : false,
- HtmlTable : false,
- Iframe : false,
- IframeShim : false,
- InputValidator: false,
- instanceOf : false,
- Keyboard : false,
- Locale : false,
- Mask : false,
- MooTools : false,
- Native : false,
- Options : false,
- OverText : false,
- Request : false,
- Scroller : false,
- Slick : false,
- Slider : false,
- Sortables : false,
- Spinner : false,
- Swiff : false,
- Tips : false,
- Type : false,
- typeOf : false,
- URI : false,
- Window : false
- };
- exports.prototypejs = {
- "$" : false,
- "$$" : false,
- "$A" : false,
- "$F" : false,
- "$H" : false,
- "$R" : false,
- "$break" : false,
- "$continue" : false,
- "$w" : false,
- Abstract : false,
- Ajax : false,
- Class : false,
- Enumerable : false,
- Element : false,
- Event : false,
- Field : false,
- Form : false,
- Hash : false,
- Insertion : false,
- ObjectRange : false,
- PeriodicalExecuter: false,
- Position : false,
- Prototype : false,
- Selector : false,
- Template : false,
- Toggle : false,
- Try : false,
- Autocompleter : false,
- Builder : false,
- Control : false,
- Draggable : false,
- Draggables : false,
- Droppables : false,
- Effect : false,
- Sortable : false,
- SortableObserver : false,
- Sound : false,
- Scriptaculous : false
- };
- exports.yui = {
- YUI : false,
- Y : false,
- YUI_config: false
- };
- },{}],446:[function(require,module,exports){
- // default configuration
- module.exports = {
- disallowVars: false,
- disallowDuplicated: true,
- disallowUnknownReferences: true,
- parse: require("esprima-fb").parse,
- };
- },{"esprima-fb":453}],447:[function(require,module,exports){
- "use strict";
- var assert = require("assert");
- var stringmap = require("stringmap");
- var stringset = require("stringset");
- var is = require("simple-is");
- var fmt = require("simple-fmt");
- var error = require("./error");
- var getline = error.getline;
- var options = require("./options");
- function Scope(args) {
- assert(is.someof(args.kind, ["hoist", "block", "catch-block"]));
- assert(is.object(args.node));
- assert(args.parent === null || is.object(args.parent));
- // kind === "hoist": function scopes, program scope, injected globals
- // kind === "block": ES6 block scopes
- // kind === "catch-block": catch block scopes
- this.kind = args.kind;
- // the AST node the block corresponds to
- this.node = args.node;
- // parent scope
- this.parent = args.parent;
- // children scopes for easier traversal (populated internally)
- this.children = [];
- // scope declarations. decls[variable_name] = {
- // kind: "fun" for functions,
- // "param" for function parameters,
- // "caught" for catch parameter
- // "var",
- // "const",
- // "let"
- // node: the AST node the declaration corresponds to
- // from: source code index from which it is visible at earliest
- // (only stored for "const", "let" [and "var"] nodes)
- // }
- this.decls = stringmap();
- // names of all declarations within this scope that was ever written
- // TODO move to decls.w?
- // TODO create corresponding read?
- this.written = stringset();
- // names of all variables declared outside this hoist scope but
- // referenced in this scope (immediately or in child).
- // only stored on hoist scopes for efficiency
- // (because we currently generate lots of empty block scopes)
- this.propagates = (this.kind === "hoist" ? stringset() : null);
- // scopes register themselves with their parents for easier traversal
- if (this.parent) {
- this.parent.children.push(this);
- }
- }
- Scope.prototype.print = function(indent) {
- indent = indent || 0;
- var scope = this;
- var names = this.decls.keys().map(function(name) {
- return fmt("{0} [{1}]", name, scope.decls.get(name).kind);
- }).join(", ");
- var propagates = this.propagates ? this.propagates.items().join(", ") : "";
- console.log(fmt("{0}{1}: {2}. propagates: {3}", fmt.repeat(" ", indent), this.node.type, names, propagates));
- this.children.forEach(function(c) {
- c.print(indent + 2);
- });
- };
- Scope.prototype.add = function(name, kind, node, referableFromPos) {
- assert(is.someof(kind, ["fun", "param", "var", "caught", "const", "let"]));
- function isConstLet(kind) {
- return is.someof(kind, ["const", "let"]);
- }
- var scope = this;
- // search nearest hoist-scope for fun, param and var's
- // const, let and caught variables go directly in the scope (which may be hoist, block or catch-block)
- if (is.someof(kind, ["fun", "param", "var"])) {
- while (scope.kind !== "hoist") {
- if (scope.decls.has(name) && isConstLet(scope.decls.get(name).kind)) { // could be caught
- return error(getline(node), "{0} is already declared", name);
- }
- scope = scope.parent;
- }
- }
- // name exists in scope and either new or existing kind is const|let => error
- if (scope.decls.has(name) && (options.disallowDuplicated || isConstLet(scope.decls.get(name).kind) || isConstLet(kind))) {
- return error(getline(node), "{0} is already declared", name);
- }
- var declaration = {
- kind: kind,
- node: node,
- };
- if (referableFromPos) {
- assert(is.someof(kind, ["var", "const", "let"]));
- declaration.from = referableFromPos;
- }
- scope.decls.set(name, declaration);
- };
- Scope.prototype.getKind = function(name) {
- assert(is.string(name));
- var decl = this.decls.get(name);
- return decl ? decl.kind : null;
- };
- Scope.prototype.getNode = function(name) {
- assert(is.string(name));
- var decl = this.decls.get(name);
- return decl ? decl.node : null;
- };
- Scope.prototype.getFromPos = function(name) {
- assert(is.string(name));
- var decl = this.decls.get(name);
- return decl ? decl.from : null;
- };
- Scope.prototype.hasOwn = function(name) {
- return this.decls.has(name);
- };
- Scope.prototype.remove = function(name) {
- return this.decls.remove(name);
- };
- Scope.prototype.doesPropagate = function(name) {
- return this.propagates.has(name);
- };
- Scope.prototype.markPropagates = function(name) {
- this.propagates.add(name);
- };
- Scope.prototype.closestHoistScope = function() {
- var scope = this;
- while (scope.kind !== "hoist") {
- scope = scope.parent;
- }
- return scope;
- };
- Scope.prototype.hasFunctionScopeBetween = function(outer) {
- function isFunction(node) {
- return is.someof(node.type, ["FunctionDeclaration", "FunctionExpression"]);
- }
- for (var scope = this; scope; scope = scope.parent) {
- if (scope === outer) {
- return false;
- }
- if (isFunction(scope.node)) {
- return true;
- }
- }
- throw new Error("wasn't inner scope of outer");
- };
- Scope.prototype.lookup = function(name) {
- for (var scope = this; scope; scope = scope.parent) {
- if (scope.decls.has(name)) {
- return scope;
- } else if (scope.kind === "hoist") {
- scope.propagates.add(name);
- }
- }
- return null;
- };
- Scope.prototype.markWrite = function(name) {
- assert(is.string(name));
- this.written.add(name);
- };
- // detects let variables that are never modified (ignores top-level)
- Scope.prototype.detectUnmodifiedLets = function() {
- var outmost = this;
- function detect(scope) {
- if (scope !== outmost) {
- scope.decls.keys().forEach(function(name) {
- if (scope.getKind(name) === "let" && !scope.written.has(name)) {
- return error(getline(scope.getNode(name)), "{0} is declared as let but never modified so could be const", name);
- }
- });
- }
- scope.children.forEach(function(childScope) {
- detect(childScope);
- });
- }
- detect(this);
- };
- Scope.prototype.traverse = function(options) {
- options = options || {};
- var pre = options.pre;
- var post = options.post;
- function visit(scope) {
- if (pre) {
- pre(scope);
- }
- scope.children.forEach(function(childScope) {
- visit(childScope);
- });
- if (post) {
- post(scope);
- }
- }
- visit(this);
- };
- module.exports = Scope;
- },{"./error":444,"./options":446,"assert":190,"simple-fmt":454,"simple-is":455,"stringmap":456,"stringset":457}],448:[function(require,module,exports){
- var fmt = require("simple-fmt");
- var is = require("simple-is");
- var assert = require("assert");
- function Stats() {
- this.lets = 0;
- this.consts = 0;
- this.renames = [];
- }
- Stats.prototype.declarator = function(kind) {
- assert(is.someof(kind, ["const", "let"]));
- if (kind === "const") {
- this.consts++;
- } else {
- this.lets++;
- }
- };
- Stats.prototype.rename = function(oldName, newName, line) {
- this.renames.push({
- oldName: oldName,
- newName: newName,
- line: line,
- });
- };
- Stats.prototype.toString = function() {
- // console.log("defs.js stats for file {0}:", filename)
- var renames = this.renames.map(function(r) {
- return r;
- }).sort(function(a, b) {
- return a.line - b.line;
- }); // sort a copy of renames
- var renameStr = renames.map(function(rename) {
- return fmt("\nline {0}: {1} => {2}", rename.line, rename.oldName, rename.newName);
- }).join("");
- var sum = this.consts + this.lets;
- var constlets = (sum === 0 ?
- "can't calculate const coverage (0 consts, 0 lets)" :
- fmt("{0}% const coverage ({1} consts, {2} lets)",
- Math.floor(100 * this.consts / sum), this.consts, this.lets));
- return constlets + renameStr + "\n";
- };
- module.exports = Stats;
- },{"assert":190,"simple-fmt":454,"simple-is":455}],449:[function(require,module,exports){
- // alter.js
- // MIT licensed, see LICENSE file
- // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
- var assert = require("assert");
- var stableSort = require("stable");
- // fragments is a list of {start: index, end: index, str: string to replace with}
- function alter(str, fragments) {
- "use strict";
- var isArray = Array.isArray || function(v) {
- return Object.prototype.toString.call(v) === "[object Array]";
- };;
- assert(typeof str === "string");
- assert(isArray(fragments));
- // stableSort isn't in-place so no need to copy array first
- var sortedFragments = stableSort(fragments, function(a, b) {
- return a.start - b.start;
- });
- var outs = [];
- var pos = 0;
- for (var i = 0; i < sortedFragments.length; i++) {
- var frag = sortedFragments[i];
- assert(pos <= frag.start);
- assert(frag.start <= frag.end);
- outs.push(str.slice(pos, frag.start));
- outs.push(frag.str);
- pos = frag.end;
- }
- if (pos < str.length) {
- outs.push(str.slice(pos));
- }
- return outs.join("");
- }
- if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
- module.exports = alter;
- }
- },{"assert":190,"stable":450}],450:[function(require,module,exports){
- //! stable.js 0.1.5, https://github.com/Two-Screen/stable
- //! © 2014 Angry Bytes and contributors. MIT licensed.
- (function() {
- // A stable array sort, because `Array#sort()` is not guaranteed stable.
- // This is an implementation of merge sort, without recursion.
- var stable = function(arr, comp) {
- return exec(arr.slice(), comp);
- };
- stable.inplace = function(arr, comp) {
- var result = exec(arr, comp);
- // This simply copies back if the result isn't in the original array,
- // which happens on an odd number of passes.
- if (result !== arr) {
- pass(result, null, arr.length, arr);
- }
- return arr;
- };
- // Execute the sort using the input array and a second buffer as work space.
- // Returns one of those two, containing the final result.
- function exec(arr, comp) {
- if (typeof(comp) !== 'function') {
- comp = function(a, b) {
- return String(a).localeCompare(b);
- };
- }
- // Short-circuit when there's nothing to sort.
- var len = arr.length;
- if (len <= 1) {
- return arr;
- }
- // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc.
- // Chunks are the size of the left or right hand in merge sort.
- // Stop when the left-hand covers all of the array.
- var buffer = new Array(len);
- for (var chk = 1; chk < len; chk *= 2) {
- pass(arr, comp, chk, buffer);
- var tmp = arr;
- arr = buffer;
- buffer = tmp;
- }
- return arr;
- }
- // Run a single pass with the given chunk size.
- var pass = function(arr, comp, chk, result) {
- var len = arr.length;
- var i = 0;
- // Step size / double chunk size.
- var dbl = chk * 2;
- // Bounds of the left and right chunks.
- var l, r, e;
- // Iterators over the left and right chunk.
- var li, ri;
- // Iterate over pairs of chunks.
- for (l = 0; l < len; l += dbl) {
- r = l + chk;
- e = r + chk;
- if (r > len) r = len;
- if (e > len) e = len;
- // Iterate both chunks in parallel.
- li = l;
- ri = r;
- while (true) {
- // Compare the chunks.
- if (li < r && ri < e) {
- // This works for a regular `sort()` compatible comparator,
- // but also for a simple comparator like: `a > b`
- if (comp(arr[li], arr[ri]) <= 0) {
- result[i++] = arr[li++];
- }
- else {
- result[i++] = arr[ri++];
- }
- }
- // Nothing to compare, just flush what's left.
- else if (li < r) {
- result[i++] = arr[li++];
- }
- else if (ri < e) {
- result[i++] = arr[ri++];
- }
- // Both iterators are at the chunk ends.
- else {
- break;
- }
- }
- }
- };
- // Export using CommonJS or to the window.
- if (typeof(module) !== 'undefined') {
- module.exports = stable;
- }
- else {
- window.stable = stable;
- }
- })();
- },{}],451:[function(require,module,exports){
- function traverse(root, options) {
- "use strict";
- options = options || {};
- var pre = options.pre;
- var post = options.post;
- var skipProperty = options.skipProperty;
- function visit(node, parent, prop, idx) {
- if (!node || typeof node.type !== "string") {
- return;
- }
- var res = undefined;
- if (pre) {
- res = pre(node, parent, prop, idx);
- }
- if (res !== false) {
- for (var prop in node) {
- if (skipProperty ? skipProperty(prop, node) : prop[0] === "$") {
- continue;
- }
- var child = node[prop];
- if (Array.isArray(child)) {
- for (var i = 0; i < child.length; i++) {
- visit(child[i], node, prop, i);
- }
- } else {
- visit(child, node, prop);
- }
- }
- }
- if (post) {
- post(node, parent, prop, idx);
- }
- }
- visit(root, null);
- };
- if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
- module.exports = traverse;
- }
- },{}],452:[function(require,module,exports){
- // breakable.js
- // MIT licensed, see LICENSE file
- // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
- var breakable = (function() {
- "use strict";
- function Val(val, brk) {
- this.val = val;
- this.brk = brk;
- }
- function make_brk() {
- return function brk(val) {
- throw new Val(val, brk);
- };
- }
- function breakable(fn) {
- var brk = make_brk();
- try {
- return fn(brk);
- } catch (e) {
- if (e instanceof Val && e.brk === brk) {
- return e.val;
- }
- throw e;
- }
- }
- return breakable;
- })();
- if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
- module.exports = breakable;
- }
- },{}],453:[function(require,module,exports){
- /*
- Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
- Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
- Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
- Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
- Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
- Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
- Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
- Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- /*jslint bitwise:true plusplus:true */
- /*global esprima:true, define:true, exports:true, window: true,
- throwError: true, generateStatement: true, peek: true,
- parseAssignmentExpression: true, parseBlock: true,
- parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
- parseDeclareClass: true, parseDeclareFunction: true,
- parseDeclareModule: true, parseDeclareVariable: true,
- parseForStatement: true,
- parseFunctionDeclaration: true, parseFunctionExpression: true,
- parseFunctionSourceElements: true, parseVariableIdentifier: true,
- parseImportSpecifier: true, parseInterface: true,
- parseLeftHandSideExpression: true, parseParams: true, validateParam: true,
- parseSpreadOrAssignmentExpression: true,
- parseStatement: true, parseSourceElement: true, parseConciseBody: true,
- advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
- scanXJSStringLiteral: true, scanXJSIdentifier: true,
- parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
- parseFunctionTypeParam: true,
- parsePrimaryType: true,
- parseTypeAlias: true,
- parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
- parseYieldExpression: true, parseAwaitExpression: true
- */
- (function (root, factory) {
- 'use strict';
- // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
- // Rhino, and plain browser loading.
- if (typeof define === 'function' && define.amd) {
- define(['exports'], factory);
- } else if (typeof exports !== 'undefined') {
- factory(exports);
- } else {
- factory((root.esprima = {}));
- }
- }(this, function (exports) {
- 'use strict';
- var Token,
- TokenName,
- FnExprTokens,
- Syntax,
- PropertyKind,
- Messages,
- Regex,
- SyntaxTreeDelegate,
- XHTMLEntities,
- ClassPropertyType,
- source,
- strict,
- index,
- lineNumber,
- lineStart,
- length,
- delegate,
- lookahead,
- state,
- extra;
- Token = {
- BooleanLiteral: 1,
- EOF: 2,
- Identifier: 3,
- Keyword: 4,
- NullLiteral: 5,
- NumericLiteral: 6,
- Punctuator: 7,
- StringLiteral: 8,
- RegularExpression: 9,
- Template: 10,
- XJSIdentifier: 11,
- XJSText: 12
- };
- TokenName = {};
- TokenName[Token.BooleanLiteral] = 'Boolean';
- TokenName[Token.EOF] = '<end>';
- TokenName[Token.Identifier] = 'Identifier';
- TokenName[Token.Keyword] = 'Keyword';
- TokenName[Token.NullLiteral] = 'Null';
- TokenName[Token.NumericLiteral] = 'Numeric';
- TokenName[Token.Punctuator] = 'Punctuator';
- TokenName[Token.StringLiteral] = 'String';
- TokenName[Token.XJSIdentifier] = 'XJSIdentifier';
- TokenName[Token.XJSText] = 'XJSText';
- TokenName[Token.RegularExpression] = 'RegularExpression';
- // A function following one of those tokens is an expression.
- FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
- 'return', 'case', 'delete', 'throw', 'void',
- // assignment operators
- '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',
- '&=', '|=', '^=', ',',
- // binary/unary operators
- '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
- '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
- '<=', '<', '>', '!=', '!=='];
- Syntax = {
- AnyTypeAnnotation: 'AnyTypeAnnotation',
- ArrayExpression: 'ArrayExpression',
- ArrayPattern: 'ArrayPattern',
- ArrayTypeAnnotation: 'ArrayTypeAnnotation',
- ArrowFunctionExpression: 'ArrowFunctionExpression',
- AssignmentExpression: 'AssignmentExpression',
- BinaryExpression: 'BinaryExpression',
- BlockStatement: 'BlockStatement',
- BooleanTypeAnnotation: 'BooleanTypeAnnotation',
- BreakStatement: 'BreakStatement',
- CallExpression: 'CallExpression',
- CatchClause: 'CatchClause',
- ClassBody: 'ClassBody',
- ClassDeclaration: 'ClassDeclaration',
- ClassExpression: 'ClassExpression',
- ClassImplements: 'ClassImplements',
- ClassProperty: 'ClassProperty',
- ComprehensionBlock: 'ComprehensionBlock',
- ComprehensionExpression: 'ComprehensionExpression',
- ConditionalExpression: 'ConditionalExpression',
- ContinueStatement: 'ContinueStatement',
- DebuggerStatement: 'DebuggerStatement',
- DeclareClass: 'DeclareClass',
- DeclareFunction: 'DeclareFunction',
- DeclareModule: 'DeclareModule',
- DeclareVariable: 'DeclareVariable',
- DoWhileStatement: 'DoWhileStatement',
- EmptyStatement: 'EmptyStatement',
- ExportDeclaration: 'ExportDeclaration',
- ExportBatchSpecifier: 'ExportBatchSpecifier',
- ExportSpecifier: 'ExportSpecifier',
- ExpressionStatement: 'ExpressionStatement',
- ForInStatement: 'ForInStatement',
- ForOfStatement: 'ForOfStatement',
- ForStatement: 'ForStatement',
- FunctionDeclaration: 'FunctionDeclaration',
- FunctionExpression: 'FunctionExpression',
- FunctionTypeAnnotation: 'FunctionTypeAnnotation',
- FunctionTypeParam: 'FunctionTypeParam',
- GenericTypeAnnotation: 'GenericTypeAnnotation',
- Identifier: 'Identifier',
- IfStatement: 'IfStatement',
- ImportDeclaration: 'ImportDeclaration',
- ImportDefaultSpecifier: 'ImportDefaultSpecifier',
- ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
- ImportSpecifier: 'ImportSpecifier',
- InterfaceDeclaration: 'InterfaceDeclaration',
- InterfaceExtends: 'InterfaceExtends',
- IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
- LabeledStatement: 'LabeledStatement',
- Literal: 'Literal',
- LogicalExpression: 'LogicalExpression',
- MemberExpression: 'MemberExpression',
- MethodDefinition: 'MethodDefinition',
- ModuleSpecifier: 'ModuleSpecifier',
- NewExpression: 'NewExpression',
- NullableTypeAnnotation: 'NullableTypeAnnotation',
- NumberTypeAnnotation: 'NumberTypeAnnotation',
- ObjectExpression: 'ObjectExpression',
- ObjectPattern: 'ObjectPattern',
- ObjectTypeAnnotation: 'ObjectTypeAnnotation',
- ObjectTypeCallProperty: 'ObjectTypeCallProperty',
- ObjectTypeIndexer: 'ObjectTypeIndexer',
- ObjectTypeProperty: 'ObjectTypeProperty',
- Program: 'Program',
- Property: 'Property',
- QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
- ReturnStatement: 'ReturnStatement',
- SequenceExpression: 'SequenceExpression',
- SpreadElement: 'SpreadElement',
- SpreadProperty: 'SpreadProperty',
- StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
- StringTypeAnnotation: 'StringTypeAnnotation',
- SwitchCase: 'SwitchCase',
- SwitchStatement: 'SwitchStatement',
- TaggedTemplateExpression: 'TaggedTemplateExpression',
- TemplateElement: 'TemplateElement',
- TemplateLiteral: 'TemplateLiteral',
- ThisExpression: 'ThisExpression',
- ThrowStatement: 'ThrowStatement',
- TupleTypeAnnotation: 'TupleTypeAnnotation',
- TryStatement: 'TryStatement',
- TypeAlias: 'TypeAlias',
- TypeAnnotation: 'TypeAnnotation',
- TypeofTypeAnnotation: 'TypeofTypeAnnotation',
- TypeParameterDeclaration: 'TypeParameterDeclaration',
- TypeParameterInstantiation: 'TypeParameterInstantiation',
- UnaryExpression: 'UnaryExpression',
- UnionTypeAnnotation: 'UnionTypeAnnotation',
- UpdateExpression: 'UpdateExpression',
- VariableDeclaration: 'VariableDeclaration',
- VariableDeclarator: 'VariableDeclarator',
- VoidTypeAnnotation: 'VoidTypeAnnotation',
- WhileStatement: 'WhileStatement',
- WithStatement: 'WithStatement',
- XJSIdentifier: 'XJSIdentifier',
- XJSNamespacedName: 'XJSNamespacedName',
- XJSMemberExpression: 'XJSMemberExpression',
- XJSEmptyExpression: 'XJSEmptyExpression',
- XJSExpressionContainer: 'XJSExpressionContainer',
- XJSElement: 'XJSElement',
- XJSClosingElement: 'XJSClosingElement',
- XJSOpeningElement: 'XJSOpeningElement',
- XJSAttribute: 'XJSAttribute',
- XJSSpreadAttribute: 'XJSSpreadAttribute',
- XJSText: 'XJSText',
- YieldExpression: 'YieldExpression',
- AwaitExpression: 'AwaitExpression'
- };
- PropertyKind = {
- Data: 1,
- Get: 2,
- Set: 4
- };
- ClassPropertyType = {
- 'static': 'static',
- prototype: 'prototype'
- };
- // Error messages should be identical to V8.
- Messages = {
- UnexpectedToken: 'Unexpected token %0',
- UnexpectedNumber: 'Unexpected number',
- UnexpectedString: 'Unexpected string',
- UnexpectedIdentifier: 'Unexpected identifier',
- UnexpectedReserved: 'Unexpected reserved word',
- UnexpectedTemplate: 'Unexpected quasi %0',
- UnexpectedEOS: 'Unexpected end of input',
- NewlineAfterThrow: 'Illegal newline after throw',
- InvalidRegExp: 'Invalid regular expression',
- UnterminatedRegExp: 'Invalid regular expression: missing /',
- InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
- InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
- InvalidLHSInForIn: 'Invalid left-hand side in for-in',
- MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
- NoCatchOrFinally: 'Missing catch or finally after try',
- UnknownLabel: 'Undefined label \'%0\'',
- Redeclaration: '%0 \'%1\' has already been declared',
- IllegalContinue: 'Illegal continue statement',
- IllegalBreak: 'Illegal break statement',
- IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
- IllegalReturn: 'Illegal return statement',
- IllegalSpread: 'Illegal spread element',
- StrictModeWith: 'Strict mode code may not include a with statement',
- StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
- StrictVarName: 'Variable name may not be eval or arguments in strict mode',
- StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
- StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
- ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
- DefaultRestParameter: 'Rest parameter can not have a default value',
- ElementAfterSpreadElement: 'Spread must be the final element of an element list',
- PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
- ObjectPatternAsRestParameter: 'Invalid rest parameter',
- ObjectPatternAsSpread: 'Invalid spread argument',
- StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
- StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
- StrictDelete: 'Delete of an unqualified identifier in strict mode.',
- StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
- AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
- AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
- StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
- StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
- StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
- StrictReservedWord: 'Use of future reserved word in strict mode',
- MissingFromClause: 'Missing from clause',
- NoAsAfterImportNamespace: 'Missing as after import *',
- InvalidModuleSpecifier: 'Invalid module specifier',
- NoUnintializedConst: 'Const must be initialized',
- ComprehensionRequiresBlock: 'Comprehension must have at least one block',
- ComprehensionError: 'Comprehension Error',
- EachNotAllowed: 'Each is not supported',
- InvalidXJSAttributeValue: 'XJS value should be either an expression or a quoted XJS text',
- ExpectedXJSClosingTag: 'Expected corresponding XJS closing tag for %0',
- AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag',
- ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
- 'you are trying to write a function type, but you ended up ' +
- 'writing a grouped type followed by an =>, which is a syntax ' +
- 'error. Remember, function type parameters are named so function ' +
- 'types look like (name1: type1, name2: type2) => returnType. You ' +
- 'probably wrote (type1) => returnType'
- };
- // See also tools/generate-unicode-regex.py.
- Regex = {
- NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
- NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
- LeadingZeros: new RegExp('^0+(?!$)')
- };
- // Ensure the condition is true, otherwise throw an error.
- // This is only to have a better contract semantic, i.e. another safety net
- // to catch a logic error. The condition shall be fulfilled in normal case.
- // Do NOT use this to enforce a certain condition on any user input.
- function assert(condition, message) {
- if (!condition) {
- throw new Error('ASSERT: ' + message);
- }
- }
- function isDecimalDigit(ch) {
- return (ch >= 48 && ch <= 57); // 0..9
- }
- function isHexDigit(ch) {
- return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
- }
- function isOctalDigit(ch) {
- return '01234567'.indexOf(ch) >= 0;
- }
- // 7.2 White Space
- function isWhiteSpace(ch) {
- return (ch === 32) || // space
- (ch === 9) || // tab
- (ch === 0xB) ||
- (ch === 0xC) ||
- (ch === 0xA0) ||
- (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
- }
- // 7.3 Line Terminators
- function isLineTerminator(ch) {
- return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
- }
- // 7.6 Identifier Names and Identifiers
- function isIdentifierStart(ch) {
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
- (ch >= 65 && ch <= 90) || // A..Z
- (ch >= 97 && ch <= 122) || // a..z
- (ch === 92) || // \ (backslash)
- ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));
- }
- function isIdentifierPart(ch) {
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
- (ch >= 65 && ch <= 90) || // A..Z
- (ch >= 97 && ch <= 122) || // a..z
- (ch >= 48 && ch <= 57) || // 0..9
- (ch === 92) || // \ (backslash)
- ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
- }
- // 7.6.1.2 Future Reserved Words
- function isFutureReservedWord(id) {
- switch (id) {
- case 'class':
- case 'enum':
- case 'export':
- case 'extends':
- case 'import':
- case 'super':
- return true;
- default:
- return false;
- }
- }
- function isStrictModeReservedWord(id) {
- switch (id) {
- case 'implements':
- case 'interface':
- case 'package':
- case 'private':
- case 'protected':
- case 'public':
- case 'static':
- case 'yield':
- case 'let':
- return true;
- default:
- return false;
- }
- }
- function isRestrictedWord(id) {
- return id === 'eval' || id === 'arguments';
- }
- // 7.6.1.1 Keywords
- function isKeyword(id) {
- if (strict && isStrictModeReservedWord(id)) {
- return true;
- }
- // 'const' is specialized as Keyword in V8.
- // 'yield' is only treated as a keyword in strict mode.
- // 'let' is for compatiblity with SpiderMonkey and ES.next.
- // Some others are from future reserved words.
- switch (id.length) {
- case 2:
- return (id === 'if') || (id === 'in') || (id === 'do');
- case 3:
- return (id === 'var') || (id === 'for') || (id === 'new') ||
- (id === 'try') || (id === 'let');
- case 4:
- return (id === 'this') || (id === 'else') || (id === 'case') ||
- (id === 'void') || (id === 'with') || (id === 'enum');
- case 5:
- return (id === 'while') || (id === 'break') || (id === 'catch') ||
- (id === 'throw') || (id === 'const') ||
- (id === 'class') || (id === 'super');
- case 6:
- return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
- (id === 'switch') || (id === 'export') || (id === 'import');
- case 7:
- return (id === 'default') || (id === 'finally') || (id === 'extends');
- case 8:
- return (id === 'function') || (id === 'continue') || (id === 'debugger');
- case 10:
- return (id === 'instanceof');
- default:
- return false;
- }
- }
- // 7.4 Comments
- function skipComment() {
- var ch, blockComment, lineComment;
- blockComment = false;
- lineComment = false;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (lineComment) {
- ++index;
- if (isLineTerminator(ch)) {
- lineComment = false;
- if (ch === 13 && source.charCodeAt(index) === 10) {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- }
- } else if (blockComment) {
- if (isLineTerminator(ch)) {
- if (ch === 13) {
- ++index;
- }
- if (ch !== 13 || source.charCodeAt(index) === 10) {
- ++lineNumber;
- ++index;
- lineStart = index;
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- } else {
- ch = source.charCodeAt(index++);
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- // Block comment ends with '*/' (char #42, char #47).
- if (ch === 42) {
- ch = source.charCodeAt(index);
- if (ch === 47) {
- ++index;
- blockComment = false;
- }
- }
- }
- } else if (ch === 47) {
- ch = source.charCodeAt(index + 1);
- // Line comment starts with '//' (char #47, char #47).
- if (ch === 47) {
- index += 2;
- lineComment = true;
- } else if (ch === 42) {
- // Block comment starts with '/*' (char #47, char #42).
- index += 2;
- blockComment = true;
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- } else {
- break;
- }
- } else if (isWhiteSpace(ch)) {
- ++index;
- } else if (isLineTerminator(ch)) {
- ++index;
- if (ch === 13 && source.charCodeAt(index) === 10) {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- } else {
- break;
- }
- }
- }
- function scanHexEscape(prefix) {
- var i, len, ch, code = 0;
- len = (prefix === 'u') ? 4 : 2;
- for (i = 0; i < len; ++i) {
- if (index < length && isHexDigit(source[index])) {
- ch = source[index++];
- code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
- } else {
- return '';
- }
- }
- return String.fromCharCode(code);
- }
- function scanUnicodeCodePointEscape() {
- var ch, code, cu1, cu2;
- ch = source[index];
- code = 0;
- // At least, one hex digit is required.
- if (ch === '}') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- while (index < length) {
- ch = source[index++];
- if (!isHexDigit(ch)) {
- break;
- }
- code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
- }
- if (code > 0x10FFFF || ch !== '}') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- // UTF-16 Encoding
- if (code <= 0xFFFF) {
- return String.fromCharCode(code);
- }
- cu1 = ((code - 0x10000) >> 10) + 0xD800;
- cu2 = ((code - 0x10000) & 1023) + 0xDC00;
- return String.fromCharCode(cu1, cu2);
- }
- function getEscapedIdentifier() {
- var ch, id;
- ch = source.charCodeAt(index++);
- id = String.fromCharCode(ch);
- // '\u' (char #92, char #117) denotes an escaped character.
- if (ch === 92) {
- if (source.charCodeAt(index) !== 117) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- ch = scanHexEscape('u');
- if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- id = ch;
- }
- while (index < length) {
- ch = source.charCodeAt(index);
- if (!isIdentifierPart(ch)) {
- break;
- }
- ++index;
- id += String.fromCharCode(ch);
- // '\u' (char #92, char #117) denotes an escaped character.
- if (ch === 92) {
- id = id.substr(0, id.length - 1);
- if (source.charCodeAt(index) !== 117) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- ch = scanHexEscape('u');
- if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- id += ch;
- }
- }
- return id;
- }
- function getIdentifier() {
- var start, ch;
- start = index++;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (ch === 92) {
- // Blackslash (char #92) marks Unicode escape sequence.
- index = start;
- return getEscapedIdentifier();
- }
- if (isIdentifierPart(ch)) {
- ++index;
- } else {
- break;
- }
- }
- return source.slice(start, index);
- }
- function scanIdentifier() {
- var start, id, type;
- start = index;
- // Backslash (char #92) starts an escaped character.
- id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier();
- // There is no keyword or literal with only one character.
- // Thus, it must be an identifier.
- if (id.length === 1) {
- type = Token.Identifier;
- } else if (isKeyword(id)) {
- type = Token.Keyword;
- } else if (id === 'null') {
- type = Token.NullLiteral;
- } else if (id === 'true' || id === 'false') {
- type = Token.BooleanLiteral;
- } else {
- type = Token.Identifier;
- }
- return {
- type: type,
- value: id,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // 7.7 Punctuators
- function scanPunctuator() {
- var start = index,
- code = source.charCodeAt(index),
- code2,
- ch1 = source[index],
- ch2,
- ch3,
- ch4;
- switch (code) {
- // Check for most common single-character punctuators.
- case 40: // ( open bracket
- case 41: // ) close bracket
- case 59: // ; semicolon
- case 44: // , comma
- case 123: // { open curly brace
- case 125: // } close curly brace
- case 91: // [
- case 93: // ]
- case 58: // :
- case 63: // ?
- case 126: // ~
- ++index;
- if (extra.tokenize) {
- if (code === 40) {
- extra.openParenToken = extra.tokens.length;
- } else if (code === 123) {
- extra.openCurlyToken = extra.tokens.length;
- }
- }
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- default:
- code2 = source.charCodeAt(index + 1);
- // '=' (char #61) marks an assignment or comparison operator.
- if (code2 === 61) {
- switch (code) {
- case 37: // %
- case 38: // &
- case 42: // *:
- case 43: // +
- case 45: // -
- case 47: // /
- case 60: // <
- case 62: // >
- case 94: // ^
- case 124: // |
- index += 2;
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code) + String.fromCharCode(code2),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- case 33: // !
- case 61: // =
- index += 2;
- // !== and ===
- if (source.charCodeAt(index) === 61) {
- ++index;
- }
- return {
- type: Token.Punctuator,
- value: source.slice(start, index),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- default:
- break;
- }
- }
- break;
- }
- // Peek more characters.
- ch2 = source[index + 1];
- ch3 = source[index + 2];
- ch4 = source[index + 3];
- // 4-character punctuator: >>>=
- if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
- if (ch4 === '=') {
- index += 4;
- return {
- type: Token.Punctuator,
- value: '>>>=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- }
- // 3-character punctuators: === !== >>> <<= >>=
- if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '>>>',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '<' && ch2 === '<' && ch3 === '=') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '<<=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '>' && ch2 === '>' && ch3 === '=') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '>>=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '.' && ch2 === '.' && ch3 === '.') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '...',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // Other 2-character punctuators: ++ -- << >> && ||
- // Don't match these tokens if we're in a type, since they never can
- // occur and can mess up types like Map<string, Array<string>>
- if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
- index += 2;
- return {
- type: Token.Punctuator,
- value: ch1 + ch2,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '=' && ch2 === '>') {
- index += 2;
- return {
- type: Token.Punctuator,
- value: '=>',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
- ++index;
- return {
- type: Token.Punctuator,
- value: ch1,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '.') {
- ++index;
- return {
- type: Token.Punctuator,
- value: ch1,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- // 7.8.3 Numeric Literals
- function scanHexLiteral(start) {
- var number = '';
- while (index < length) {
- if (!isHexDigit(source[index])) {
- break;
- }
- number += source[index++];
- }
- if (number.length === 0) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (isIdentifierStart(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt('0x' + number, 16),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanOctalLiteral(prefix, start) {
- var number, octal;
- if (isOctalDigit(prefix)) {
- octal = true;
- number = '0' + source[index++];
- } else {
- octal = false;
- ++index;
- number = '';
- }
- while (index < length) {
- if (!isOctalDigit(source[index])) {
- break;
- }
- number += source[index++];
- }
- if (!octal && number.length === 0) {
- // only 0o or 0O
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt(number, 8),
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanNumericLiteral() {
- var number, start, ch, octal;
- ch = source[index];
- assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
- 'Numeric literal must start with a decimal digit or a decimal point');
- start = index;
- number = '';
- if (ch !== '.') {
- number = source[index++];
- ch = source[index];
- // Hex number starts with '0x'.
- // Octal number starts with '0'.
- // Octal number in ES6 starts with '0o'.
- // Binary number in ES6 starts with '0b'.
- if (number === '0') {
- if (ch === 'x' || ch === 'X') {
- ++index;
- return scanHexLiteral(start);
- }
- if (ch === 'b' || ch === 'B') {
- ++index;
- number = '';
- while (index < length) {
- ch = source[index];
- if (ch !== '0' && ch !== '1') {
- break;
- }
- number += source[index++];
- }
- if (number.length === 0) {
- // only 0b or 0B
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (index < length) {
- ch = source.charCodeAt(index);
- if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt(number, 2),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
- return scanOctalLiteral(ch, start);
- }
- // decimal number starts with '0' such as '09' is illegal.
- if (ch && isDecimalDigit(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- ch = source[index];
- }
- if (ch === '.') {
- number += source[index++];
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- ch = source[index];
- }
- if (ch === 'e' || ch === 'E') {
- number += source[index++];
- ch = source[index];
- if (ch === '+' || ch === '-') {
- number += source[index++];
- }
- if (isDecimalDigit(source.charCodeAt(index))) {
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- } else {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- if (isIdentifierStart(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseFloat(number),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // 7.8.4 String Literals
- function scanStringLiteral() {
- var str = '', quote, start, ch, code, unescaped, restore, octal = false;
- quote = source[index];
- assert((quote === '\'' || quote === '"'),
- 'String literal must starts with a quote');
- start = index;
- ++index;
- while (index < length) {
- ch = source[index++];
- if (ch === quote) {
- quote = '';
- break;
- } else if (ch === '\\') {
- ch = source[index++];
- if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
- switch (ch) {
- case 'n':
- str += '\n';
- break;
- case 'r':
- str += '\r';
- break;
- case 't':
- str += '\t';
- break;
- case 'u':
- case 'x':
- if (source[index] === '{') {
- ++index;
- str += scanUnicodeCodePointEscape();
- } else {
- restore = index;
- unescaped = scanHexEscape(ch);
- if (unescaped) {
- str += unescaped;
- } else {
- index = restore;
- str += ch;
- }
- }
- break;
- case 'b':
- str += '\b';
- break;
- case 'f':
- str += '\f';
- break;
- case 'v':
- str += '\x0B';
- break;
- default:
- if (isOctalDigit(ch)) {
- code = '01234567'.indexOf(ch);
- // \0 is not octal escape sequence
- if (code !== 0) {
- octal = true;
- }
- if (index < length && isOctalDigit(source[index])) {
- octal = true;
- code = code * 8 + '01234567'.indexOf(source[index++]);
- // 3 digits are only allowed when string starts
- // with 0, 1, 2, 3
- if ('0123'.indexOf(ch) >= 0 &&
- index < length &&
- isOctalDigit(source[index])) {
- code = code * 8 + '01234567'.indexOf(source[index++]);
- }
- }
- str += String.fromCharCode(code);
- } else {
- str += ch;
- }
- break;
- }
- } else {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- }
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- break;
- } else {
- str += ch;
- }
- }
- if (quote !== '') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.StringLiteral,
- value: str,
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanTemplate() {
- var cooked = '', ch, start, terminated, tail, restore, unescaped, code, octal;
- terminated = false;
- tail = false;
- start = index;
- ++index;
- while (index < length) {
- ch = source[index++];
- if (ch === '`') {
- tail = true;
- terminated = true;
- break;
- } else if (ch === '$') {
- if (source[index] === '{') {
- ++index;
- terminated = true;
- break;
- }
- cooked += ch;
- } else if (ch === '\\') {
- ch = source[index++];
- if (!isLineTerminator(ch.charCodeAt(0))) {
- switch (ch) {
- case 'n':
- cooked += '\n';
- break;
- case 'r':
- cooked += '\r';
- break;
- case 't':
- cooked += '\t';
- break;
- case 'u':
- case 'x':
- if (source[index] === '{') {
- ++index;
- cooked += scanUnicodeCodePointEscape();
- } else {
- restore = index;
- unescaped = scanHexEscape(ch);
- if (unescaped) {
- cooked += unescaped;
- } else {
- index = restore;
- cooked += ch;
- }
- }
- break;
- case 'b':
- cooked += '\b';
- break;
- case 'f':
- cooked += '\f';
- break;
- case 'v':
- cooked += '\v';
- break;
- default:
- if (isOctalDigit(ch)) {
- code = '01234567'.indexOf(ch);
- // \0 is not octal escape sequence
- if (code !== 0) {
- octal = true;
- }
- if (index < length && isOctalDigit(source[index])) {
- octal = true;
- code = code * 8 + '01234567'.indexOf(source[index++]);
- // 3 digits are only allowed when string starts
- // with 0, 1, 2, 3
- if ('0123'.indexOf(ch) >= 0 &&
- index < length &&
- isOctalDigit(source[index])) {
- code = code * 8 + '01234567'.indexOf(source[index++]);
- }
- }
- cooked += String.fromCharCode(code);
- } else {
- cooked += ch;
- }
- break;
- }
- } else {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- }
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- cooked += '\n';
- } else {
- cooked += ch;
- }
- }
- if (!terminated) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.Template,
- value: {
- cooked: cooked,
- raw: source.slice(start + 1, index - ((tail) ? 1 : 2))
- },
- tail: tail,
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanTemplateElement(option) {
- var startsWith, template;
- lookahead = null;
- skipComment();
- startsWith = (option.head) ? '`' : '}';
- if (source[index] !== startsWith) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- template = scanTemplate();
- peek();
- return template;
- }
- function scanRegExp() {
- var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false, tmp;
- lookahead = null;
- skipComment();
- start = index;
- ch = source[index];
- assert(ch === '/', 'Regular expression literal must start with a slash');
- str = source[index++];
- while (index < length) {
- ch = source[index++];
- str += ch;
- if (classMarker) {
- if (ch === ']') {
- classMarker = false;
- }
- } else {
- if (ch === '\\') {
- ch = source[index++];
- // ECMA-262 7.8.5
- if (isLineTerminator(ch.charCodeAt(0))) {
- throwError({}, Messages.UnterminatedRegExp);
- }
- str += ch;
- } else if (ch === '/') {
- terminated = true;
- break;
- } else if (ch === '[') {
- classMarker = true;
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- throwError({}, Messages.UnterminatedRegExp);
- }
- }
- }
- if (!terminated) {
- throwError({}, Messages.UnterminatedRegExp);
- }
- // Exclude leading and trailing slash.
- pattern = str.substr(1, str.length - 2);
- flags = '';
- while (index < length) {
- ch = source[index];
- if (!isIdentifierPart(ch.charCodeAt(0))) {
- break;
- }
- ++index;
- if (ch === '\\' && index < length) {
- ch = source[index];
- if (ch === 'u') {
- ++index;
- restore = index;
- ch = scanHexEscape('u');
- if (ch) {
- flags += ch;
- for (str += '\\u'; restore < index; ++restore) {
- str += source[restore];
- }
- } else {
- index = restore;
- flags += 'u';
- str += '\\u';
- }
- } else {
- str += '\\';
- }
- } else {
- flags += ch;
- str += ch;
- }
- }
- tmp = pattern;
- if (flags.indexOf('u') >= 0) {
- // Replace each astral symbol and every Unicode code point
- // escape sequence that represents such a symbol with a single
- // ASCII symbol to avoid throwing on regular expressions that
- // are only valid in combination with the `/u` flag.
- tmp = tmp
- .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
- .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
- }
- // First, detect invalid regular expressions.
- try {
- value = new RegExp(tmp);
- } catch (e) {
- throwError({}, Messages.InvalidRegExp);
- }
- // Return a regular expression object for this pattern-flag pair, or
- // `null` in case the current environment doesn't support the flags it
- // uses.
- try {
- value = new RegExp(pattern, flags);
- } catch (exception) {
- value = null;
- }
- peek();
- if (extra.tokenize) {
- return {
- type: Token.RegularExpression,
- value: value,
- regex: {
- pattern: pattern,
- flags: flags
- },
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- return {
- literal: str,
- value: value,
- regex: {
- pattern: pattern,
- flags: flags
- },
- range: [start, index]
- };
- }
- function isIdentifierName(token) {
- return token.type === Token.Identifier ||
- token.type === Token.Keyword ||
- token.type === Token.BooleanLiteral ||
- token.type === Token.NullLiteral;
- }
- function advanceSlash() {
- var prevToken,
- checkToken;
- // Using the following algorithm:
- // https://github.com/mozilla/sweet.js/wiki/design
- prevToken = extra.tokens[extra.tokens.length - 1];
- if (!prevToken) {
- // Nothing before that: it cannot be a division.
- return scanRegExp();
- }
- if (prevToken.type === 'Punctuator') {
- if (prevToken.value === ')') {
- checkToken = extra.tokens[extra.openParenToken - 1];
- if (checkToken &&
- checkToken.type === 'Keyword' &&
- (checkToken.value === 'if' ||
- checkToken.value === 'while' ||
- checkToken.value === 'for' ||
- checkToken.value === 'with')) {
- return scanRegExp();
- }
- return scanPunctuator();
- }
- if (prevToken.value === '}') {
- // Dividing a function by anything makes little sense,
- // but we have to check for that.
- if (extra.tokens[extra.openCurlyToken - 3] &&
- extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {
- // Anonymous function.
- checkToken = extra.tokens[extra.openCurlyToken - 4];
- if (!checkToken) {
- return scanPunctuator();
- }
- } else if (extra.tokens[extra.openCurlyToken - 4] &&
- extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {
- // Named function.
- checkToken = extra.tokens[extra.openCurlyToken - 5];
- if (!checkToken) {
- return scanRegExp();
- }
- } else {
- return scanPunctuator();
- }
- // checkToken determines whether the function is
- // a declaration or an expression.
- if (FnExprTokens.indexOf(checkToken.value) >= 0) {
- // It is an expression.
- return scanPunctuator();
- }
- // It is a declaration.
- return scanRegExp();
- }
- return scanRegExp();
- }
- if (prevToken.type === 'Keyword') {
- return scanRegExp();
- }
- return scanPunctuator();
- }
- function advance() {
- var ch;
- if (!state.inXJSChild) {
- skipComment();
- }
- if (index >= length) {
- return {
- type: Token.EOF,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [index, index]
- };
- }
- if (state.inXJSChild) {
- return advanceXJSChild();
- }
- ch = source.charCodeAt(index);
- // Very common: ( and ) and ;
- if (ch === 40 || ch === 41 || ch === 58) {
- return scanPunctuator();
- }
- // String literal starts with single quote (#39) or double quote (#34).
- if (ch === 39 || ch === 34) {
- if (state.inXJSTag) {
- return scanXJSStringLiteral();
- }
- return scanStringLiteral();
- }
- if (state.inXJSTag && isXJSIdentifierStart(ch)) {
- return scanXJSIdentifier();
- }
- if (ch === 96) {
- return scanTemplate();
- }
- if (isIdentifierStart(ch)) {
- return scanIdentifier();
- }
- // Dot (.) char #46 can also start a floating-point number, hence the need
- // to check the next character.
- if (ch === 46) {
- if (isDecimalDigit(source.charCodeAt(index + 1))) {
- return scanNumericLiteral();
- }
- return scanPunctuator();
- }
- if (isDecimalDigit(ch)) {
- return scanNumericLiteral();
- }
- // Slash (/) char #47 can also start a regex.
- if (extra.tokenize && ch === 47) {
- return advanceSlash();
- }
- return scanPunctuator();
- }
- function lex() {
- var token;
- token = lookahead;
- index = token.range[1];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- lookahead = advance();
- index = token.range[1];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- return token;
- }
- function peek() {
- var pos, line, start;
- pos = index;
- line = lineNumber;
- start = lineStart;
- lookahead = advance();
- index = pos;
- lineNumber = line;
- lineStart = start;
- }
- function lookahead2() {
- var adv, pos, line, start, result;
- // If we are collecting the tokens, don't grab the next one yet.
- adv = (typeof extra.advance === 'function') ? extra.advance : advance;
- pos = index;
- line = lineNumber;
- start = lineStart;
- // Scan for the next immediate token.
- if (lookahead === null) {
- lookahead = adv();
- }
- index = lookahead.range[1];
- lineNumber = lookahead.lineNumber;
- lineStart = lookahead.lineStart;
- // Grab the token right after.
- result = adv();
- index = pos;
- lineNumber = line;
- lineStart = start;
- return result;
- }
- function rewind(token) {
- index = token.range[0];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- lookahead = token;
- }
- function markerCreate() {
- if (!extra.loc && !extra.range) {
- return undefined;
- }
- skipComment();
- return {offset: index, line: lineNumber, col: index - lineStart};
- }
- function markerCreatePreserveWhitespace() {
- if (!extra.loc && !extra.range) {
- return undefined;
- }
- return {offset: index, line: lineNumber, col: index - lineStart};
- }
- function processComment(node) {
- var lastChild,
- trailingComments,
- bottomRight = extra.bottomRightStack,
- last = bottomRight[bottomRight.length - 1];
- if (node.type === Syntax.Program) {
- if (node.body.length > 0) {
- return;
- }
- }
- if (extra.trailingComments.length > 0) {
- if (extra.trailingComments[0].range[0] >= node.range[1]) {
- trailingComments = extra.trailingComments;
- extra.trailingComments = [];
- } else {
- extra.trailingComments.length = 0;
- }
- } else {
- if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
- trailingComments = last.trailingComments;
- delete last.trailingComments;
- }
- }
- // Eating the stack.
- if (last) {
- while (last && last.range[0] >= node.range[0]) {
- lastChild = last;
- last = bottomRight.pop();
- }
- }
- if (lastChild) {
- if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
- node.leadingComments = lastChild.leadingComments;
- delete lastChild.leadingComments;
- }
- } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
- node.leadingComments = extra.leadingComments;
- extra.leadingComments = [];
- }
- if (trailingComments) {
- node.trailingComments = trailingComments;
- }
- bottomRight.push(node);
- }
- function markerApply(marker, node) {
- if (extra.range) {
- node.range = [marker.offset, index];
- }
- if (extra.loc) {
- node.loc = {
- start: {
- line: marker.line,
- column: marker.col
- },
- end: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- node = delegate.postProcess(node);
- }
- if (extra.attachComment) {
- processComment(node);
- }
- return node;
- }
- SyntaxTreeDelegate = {
- name: 'SyntaxTree',
- postProcess: function (node) {
- return node;
- },
- createArrayExpression: function (elements) {
- return {
- type: Syntax.ArrayExpression,
- elements: elements
- };
- },
- createAssignmentExpression: function (operator, left, right) {
- return {
- type: Syntax.AssignmentExpression,
- operator: operator,
- left: left,
- right: right
- };
- },
- createBinaryExpression: function (operator, left, right) {
- var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :
- Syntax.BinaryExpression;
- return {
- type: type,
- operator: operator,
- left: left,
- right: right
- };
- },
- createBlockStatement: function (body) {
- return {
- type: Syntax.BlockStatement,
- body: body
- };
- },
- createBreakStatement: function (label) {
- return {
- type: Syntax.BreakStatement,
- label: label
- };
- },
- createCallExpression: function (callee, args) {
- return {
- type: Syntax.CallExpression,
- callee: callee,
- 'arguments': args
- };
- },
- createCatchClause: function (param, body) {
- return {
- type: Syntax.CatchClause,
- param: param,
- body: body
- };
- },
- createConditionalExpression: function (test, consequent, alternate) {
- return {
- type: Syntax.ConditionalExpression,
- test: test,
- consequent: consequent,
- alternate: alternate
- };
- },
- createContinueStatement: function (label) {
- return {
- type: Syntax.ContinueStatement,
- label: label
- };
- },
- createDebuggerStatement: function () {
- return {
- type: Syntax.DebuggerStatement
- };
- },
- createDoWhileStatement: function (body, test) {
- return {
- type: Syntax.DoWhileStatement,
- body: body,
- test: test
- };
- },
- createEmptyStatement: function () {
- return {
- type: Syntax.EmptyStatement
- };
- },
- createExpressionStatement: function (expression) {
- return {
- type: Syntax.ExpressionStatement,
- expression: expression
- };
- },
- createForStatement: function (init, test, update, body) {
- return {
- type: Syntax.ForStatement,
- init: init,
- test: test,
- update: update,
- body: body
- };
- },
- createForInStatement: function (left, right, body) {
- return {
- type: Syntax.ForInStatement,
- left: left,
- right: right,
- body: body,
- each: false
- };
- },
- createForOfStatement: function (left, right, body) {
- return {
- type: Syntax.ForOfStatement,
- left: left,
- right: right,
- body: body
- };
- },
- createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
- isAsync, returnType, typeParameters) {
- var funDecl = {
- type: Syntax.FunctionDeclaration,
- id: id,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: generator,
- expression: expression,
- returnType: returnType,
- typeParameters: typeParameters
- };
- if (isAsync) {
- funDecl.async = true;
- }
- return funDecl;
- },
- createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
- isAsync, returnType, typeParameters) {
- var funExpr = {
- type: Syntax.FunctionExpression,
- id: id,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: generator,
- expression: expression,
- returnType: returnType,
- typeParameters: typeParameters
- };
- if (isAsync) {
- funExpr.async = true;
- }
- return funExpr;
- },
- createIdentifier: function (name) {
- return {
- type: Syntax.Identifier,
- name: name,
- // Only here to initialize the shape of the object to ensure
- // that the 'typeAnnotation' key is ordered before others that
- // are added later (like 'loc' and 'range'). This just helps
- // keep the shape of Identifier nodes consistent with everything
- // else.
- typeAnnotation: undefined,
- optional: undefined
- };
- },
- createTypeAnnotation: function (typeAnnotation) {
- return {
- type: Syntax.TypeAnnotation,
- typeAnnotation: typeAnnotation
- };
- },
- createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
- return {
- type: Syntax.FunctionTypeAnnotation,
- params: params,
- returnType: returnType,
- rest: rest,
- typeParameters: typeParameters
- };
- },
- createFunctionTypeParam: function (name, typeAnnotation, optional) {
- return {
- type: Syntax.FunctionTypeParam,
- name: name,
- typeAnnotation: typeAnnotation,
- optional: optional
- };
- },
- createNullableTypeAnnotation: function (typeAnnotation) {
- return {
- type: Syntax.NullableTypeAnnotation,
- typeAnnotation: typeAnnotation
- };
- },
- createArrayTypeAnnotation: function (elementType) {
- return {
- type: Syntax.ArrayTypeAnnotation,
- elementType: elementType
- };
- },
- createGenericTypeAnnotation: function (id, typeParameters) {
- return {
- type: Syntax.GenericTypeAnnotation,
- id: id,
- typeParameters: typeParameters
- };
- },
- createQualifiedTypeIdentifier: function (qualification, id) {
- return {
- type: Syntax.QualifiedTypeIdentifier,
- qualification: qualification,
- id: id
- };
- },
- createTypeParameterDeclaration: function (params) {
- return {
- type: Syntax.TypeParameterDeclaration,
- params: params
- };
- },
- createTypeParameterInstantiation: function (params) {
- return {
- type: Syntax.TypeParameterInstantiation,
- params: params
- };
- },
- createAnyTypeAnnotation: function () {
- return {
- type: Syntax.AnyTypeAnnotation
- };
- },
- createBooleanTypeAnnotation: function () {
- return {
- type: Syntax.BooleanTypeAnnotation
- };
- },
- createNumberTypeAnnotation: function () {
- return {
- type: Syntax.NumberTypeAnnotation
- };
- },
- createStringTypeAnnotation: function () {
- return {
- type: Syntax.StringTypeAnnotation
- };
- },
- createStringLiteralTypeAnnotation: function (token) {
- return {
- type: Syntax.StringLiteralTypeAnnotation,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- },
- createVoidTypeAnnotation: function () {
- return {
- type: Syntax.VoidTypeAnnotation
- };
- },
- createTypeofTypeAnnotation: function (argument) {
- return {
- type: Syntax.TypeofTypeAnnotation,
- argument: argument
- };
- },
- createTupleTypeAnnotation: function (types) {
- return {
- type: Syntax.TupleTypeAnnotation,
- types: types
- };
- },
- createObjectTypeAnnotation: function (properties, indexers, callProperties) {
- return {
- type: Syntax.ObjectTypeAnnotation,
- properties: properties,
- indexers: indexers,
- callProperties: callProperties
- };
- },
- createObjectTypeIndexer: function (id, key, value, isStatic) {
- return {
- type: Syntax.ObjectTypeIndexer,
- id: id,
- key: key,
- value: value,
- static: isStatic
- };
- },
- createObjectTypeCallProperty: function (value, isStatic) {
- return {
- type: Syntax.ObjectTypeCallProperty,
- value: value,
- static: isStatic
- };
- },
- createObjectTypeProperty: function (key, value, optional, isStatic) {
- return {
- type: Syntax.ObjectTypeProperty,
- key: key,
- value: value,
- optional: optional,
- static: isStatic
- };
- },
- createUnionTypeAnnotation: function (types) {
- return {
- type: Syntax.UnionTypeAnnotation,
- types: types
- };
- },
- createIntersectionTypeAnnotation: function (types) {
- return {
- type: Syntax.IntersectionTypeAnnotation,
- types: types
- };
- },
- createTypeAlias: function (id, typeParameters, right) {
- return {
- type: Syntax.TypeAlias,
- id: id,
- typeParameters: typeParameters,
- right: right
- };
- },
- createInterface: function (id, typeParameters, body, extended) {
- return {
- type: Syntax.InterfaceDeclaration,
- id: id,
- typeParameters: typeParameters,
- body: body,
- extends: extended
- };
- },
- createInterfaceExtends: function (id, typeParameters) {
- return {
- type: Syntax.InterfaceExtends,
- id: id,
- typeParameters: typeParameters
- };
- },
- createDeclareFunction: function (id) {
- return {
- type: Syntax.DeclareFunction,
- id: id
- };
- },
- createDeclareVariable: function (id) {
- return {
- type: Syntax.DeclareVariable,
- id: id
- };
- },
- createDeclareModule: function (id, body) {
- return {
- type: Syntax.DeclareModule,
- id: id,
- body: body
- };
- },
- createXJSAttribute: function (name, value) {
- return {
- type: Syntax.XJSAttribute,
- name: name,
- value: value || null
- };
- },
- createXJSSpreadAttribute: function (argument) {
- return {
- type: Syntax.XJSSpreadAttribute,
- argument: argument
- };
- },
- createXJSIdentifier: function (name) {
- return {
- type: Syntax.XJSIdentifier,
- name: name
- };
- },
- createXJSNamespacedName: function (namespace, name) {
- return {
- type: Syntax.XJSNamespacedName,
- namespace: namespace,
- name: name
- };
- },
- createXJSMemberExpression: function (object, property) {
- return {
- type: Syntax.XJSMemberExpression,
- object: object,
- property: property
- };
- },
- createXJSElement: function (openingElement, closingElement, children) {
- return {
- type: Syntax.XJSElement,
- openingElement: openingElement,
- closingElement: closingElement,
- children: children
- };
- },
- createXJSEmptyExpression: function () {
- return {
- type: Syntax.XJSEmptyExpression
- };
- },
- createXJSExpressionContainer: function (expression) {
- return {
- type: Syntax.XJSExpressionContainer,
- expression: expression
- };
- },
- createXJSOpeningElement: function (name, attributes, selfClosing) {
- return {
- type: Syntax.XJSOpeningElement,
- name: name,
- selfClosing: selfClosing,
- attributes: attributes
- };
- },
- createXJSClosingElement: function (name) {
- return {
- type: Syntax.XJSClosingElement,
- name: name
- };
- },
- createIfStatement: function (test, consequent, alternate) {
- return {
- type: Syntax.IfStatement,
- test: test,
- consequent: consequent,
- alternate: alternate
- };
- },
- createLabeledStatement: function (label, body) {
- return {
- type: Syntax.LabeledStatement,
- label: label,
- body: body
- };
- },
- createLiteral: function (token) {
- var object = {
- type: Syntax.Literal,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- if (token.regex) {
- object.regex = token.regex;
- }
- return object;
- },
- createMemberExpression: function (accessor, object, property) {
- return {
- type: Syntax.MemberExpression,
- computed: accessor === '[',
- object: object,
- property: property
- };
- },
- createNewExpression: function (callee, args) {
- return {
- type: Syntax.NewExpression,
- callee: callee,
- 'arguments': args
- };
- },
- createObjectExpression: function (properties) {
- return {
- type: Syntax.ObjectExpression,
- properties: properties
- };
- },
- createPostfixExpression: function (operator, argument) {
- return {
- type: Syntax.UpdateExpression,
- operator: operator,
- argument: argument,
- prefix: false
- };
- },
- createProgram: function (body) {
- return {
- type: Syntax.Program,
- body: body
- };
- },
- createProperty: function (kind, key, value, method, shorthand, computed) {
- return {
- type: Syntax.Property,
- key: key,
- value: value,
- kind: kind,
- method: method,
- shorthand: shorthand,
- computed: computed
- };
- },
- createReturnStatement: function (argument) {
- return {
- type: Syntax.ReturnStatement,
- argument: argument
- };
- },
- createSequenceExpression: function (expressions) {
- return {
- type: Syntax.SequenceExpression,
- expressions: expressions
- };
- },
- createSwitchCase: function (test, consequent) {
- return {
- type: Syntax.SwitchCase,
- test: test,
- consequent: consequent
- };
- },
- createSwitchStatement: function (discriminant, cases) {
- return {
- type: Syntax.SwitchStatement,
- discriminant: discriminant,
- cases: cases
- };
- },
- createThisExpression: function () {
- return {
- type: Syntax.ThisExpression
- };
- },
- createThrowStatement: function (argument) {
- return {
- type: Syntax.ThrowStatement,
- argument: argument
- };
- },
- createTryStatement: function (block, guardedHandlers, handlers, finalizer) {
- return {
- type: Syntax.TryStatement,
- block: block,
- guardedHandlers: guardedHandlers,
- handlers: handlers,
- finalizer: finalizer
- };
- },
- createUnaryExpression: function (operator, argument) {
- if (operator === '++' || operator === '--') {
- return {
- type: Syntax.UpdateExpression,
- operator: operator,
- argument: argument,
- prefix: true
- };
- }
- return {
- type: Syntax.UnaryExpression,
- operator: operator,
- argument: argument,
- prefix: true
- };
- },
- createVariableDeclaration: function (declarations, kind) {
- return {
- type: Syntax.VariableDeclaration,
- declarations: declarations,
- kind: kind
- };
- },
- createVariableDeclarator: function (id, init) {
- return {
- type: Syntax.VariableDeclarator,
- id: id,
- init: init
- };
- },
- createWhileStatement: function (test, body) {
- return {
- type: Syntax.WhileStatement,
- test: test,
- body: body
- };
- },
- createWithStatement: function (object, body) {
- return {
- type: Syntax.WithStatement,
- object: object,
- body: body
- };
- },
- createTemplateElement: function (value, tail) {
- return {
- type: Syntax.TemplateElement,
- value: value,
- tail: tail
- };
- },
- createTemplateLiteral: function (quasis, expressions) {
- return {
- type: Syntax.TemplateLiteral,
- quasis: quasis,
- expressions: expressions
- };
- },
- createSpreadElement: function (argument) {
- return {
- type: Syntax.SpreadElement,
- argument: argument
- };
- },
- createSpreadProperty: function (argument) {
- return {
- type: Syntax.SpreadProperty,
- argument: argument
- };
- },
- createTaggedTemplateExpression: function (tag, quasi) {
- return {
- type: Syntax.TaggedTemplateExpression,
- tag: tag,
- quasi: quasi
- };
- },
- createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
- var arrowExpr = {
- type: Syntax.ArrowFunctionExpression,
- id: null,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: false,
- expression: expression
- };
- if (isAsync) {
- arrowExpr.async = true;
- }
- return arrowExpr;
- },
- createMethodDefinition: function (propertyType, kind, key, value) {
- return {
- type: Syntax.MethodDefinition,
- key: key,
- value: value,
- kind: kind,
- 'static': propertyType === ClassPropertyType.static
- };
- },
- createClassProperty: function (key, typeAnnotation, computed, isStatic) {
- return {
- type: Syntax.ClassProperty,
- key: key,
- typeAnnotation: typeAnnotation,
- computed: computed,
- static: isStatic
- };
- },
- createClassBody: function (body) {
- return {
- type: Syntax.ClassBody,
- body: body
- };
- },
- createClassImplements: function (id, typeParameters) {
- return {
- type: Syntax.ClassImplements,
- id: id,
- typeParameters: typeParameters
- };
- },
- createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
- return {
- type: Syntax.ClassExpression,
- id: id,
- superClass: superClass,
- body: body,
- typeParameters: typeParameters,
- superTypeParameters: superTypeParameters,
- implements: implemented
- };
- },
- createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
- return {
- type: Syntax.ClassDeclaration,
- id: id,
- superClass: superClass,
- body: body,
- typeParameters: typeParameters,
- superTypeParameters: superTypeParameters,
- implements: implemented
- };
- },
- createModuleSpecifier: function (token) {
- return {
- type: Syntax.ModuleSpecifier,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- },
- createExportSpecifier: function (id, name) {
- return {
- type: Syntax.ExportSpecifier,
- id: id,
- name: name
- };
- },
- createExportBatchSpecifier: function () {
- return {
- type: Syntax.ExportBatchSpecifier
- };
- },
- createImportDefaultSpecifier: function (id) {
- return {
- type: Syntax.ImportDefaultSpecifier,
- id: id
- };
- },
- createImportNamespaceSpecifier: function (id) {
- return {
- type: Syntax.ImportNamespaceSpecifier,
- id: id
- };
- },
- createExportDeclaration: function (isDefault, declaration, specifiers, source) {
- return {
- type: Syntax.ExportDeclaration,
- 'default': !!isDefault,
- declaration: declaration,
- specifiers: specifiers,
- source: source
- };
- },
- createImportSpecifier: function (id, name) {
- return {
- type: Syntax.ImportSpecifier,
- id: id,
- name: name
- };
- },
- createImportDeclaration: function (specifiers, source) {
- return {
- type: Syntax.ImportDeclaration,
- specifiers: specifiers,
- source: source
- };
- },
- createYieldExpression: function (argument, delegate) {
- return {
- type: Syntax.YieldExpression,
- argument: argument,
- delegate: delegate
- };
- },
- createAwaitExpression: function (argument) {
- return {
- type: Syntax.AwaitExpression,
- argument: argument
- };
- },
- createComprehensionExpression: function (filter, blocks, body) {
- return {
- type: Syntax.ComprehensionExpression,
- filter: filter,
- blocks: blocks,
- body: body
- };
- }
- };
- // Return true if there is a line terminator before the next token.
- function peekLineTerminator() {
- var pos, line, start, found;
- pos = index;
- line = lineNumber;
- start = lineStart;
- skipComment();
- found = lineNumber !== line;
- index = pos;
- lineNumber = line;
- lineStart = start;
- return found;
- }
- // Throw an exception
- function throwError(token, messageFormat) {
- var error,
- args = Array.prototype.slice.call(arguments, 2),
- msg = messageFormat.replace(
- /%(\d)/g,
- function (whole, index) {
- assert(index < args.length, 'Message reference must be in range');
- return args[index];
- }
- );
- if (typeof token.lineNumber === 'number') {
- error = new Error('Line ' + token.lineNumber + ': ' + msg);
- error.index = token.range[0];
- error.lineNumber = token.lineNumber;
- error.column = token.range[0] - lineStart + 1;
- } else {
- error = new Error('Line ' + lineNumber + ': ' + msg);
- error.index = index;
- error.lineNumber = lineNumber;
- error.column = index - lineStart + 1;
- }
- error.description = msg;
- throw error;
- }
- function throwErrorTolerant() {
- try {
- throwError.apply(null, arguments);
- } catch (e) {
- if (extra.errors) {
- extra.errors.push(e);
- } else {
- throw e;
- }
- }
- }
- // Throw an exception because of the token.
- function throwUnexpected(token) {
- if (token.type === Token.EOF) {
- throwError(token, Messages.UnexpectedEOS);
- }
- if (token.type === Token.NumericLiteral) {
- throwError(token, Messages.UnexpectedNumber);
- }
- if (token.type === Token.StringLiteral || token.type === Token.XJSText) {
- throwError(token, Messages.UnexpectedString);
- }
- if (token.type === Token.Identifier) {
- throwError(token, Messages.UnexpectedIdentifier);
- }
- if (token.type === Token.Keyword) {
- if (isFutureReservedWord(token.value)) {
- throwError(token, Messages.UnexpectedReserved);
- } else if (strict && isStrictModeReservedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictReservedWord);
- return;
- }
- throwError(token, Messages.UnexpectedToken, token.value);
- }
- if (token.type === Token.Template) {
- throwError(token, Messages.UnexpectedTemplate, token.value.raw);
- }
- // BooleanLiteral, NullLiteral, or Punctuator.
- throwError(token, Messages.UnexpectedToken, token.value);
- }
- // Expect the next token to match the specified punctuator.
- // If not, an exception will be thrown.
- function expect(value) {
- var token = lex();
- if (token.type !== Token.Punctuator || token.value !== value) {
- throwUnexpected(token);
- }
- }
- // Expect the next token to match the specified keyword.
- // If not, an exception will be thrown.
- function expectKeyword(keyword, contextual) {
- var token = lex();
- if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
- token.value !== keyword) {
- throwUnexpected(token);
- }
- }
- // Expect the next token to match the specified contextual keyword.
- // If not, an exception will be thrown.
- function expectContextualKeyword(keyword) {
- return expectKeyword(keyword, true);
- }
- // Return true if the next token matches the specified punctuator.
- function match(value) {
- return lookahead.type === Token.Punctuator && lookahead.value === value;
- }
- // Return true if the next token matches the specified keyword
- function matchKeyword(keyword, contextual) {
- var expectedType = contextual ? Token.Identifier : Token.Keyword;
- return lookahead.type === expectedType && lookahead.value === keyword;
- }
- // Return true if the next token matches the specified contextual keyword
- function matchContextualKeyword(keyword) {
- return matchKeyword(keyword, true);
- }
- // Return true if the next token is an assignment operator
- function matchAssign() {
- var op;
- if (lookahead.type !== Token.Punctuator) {
- return false;
- }
- op = lookahead.value;
- return op === '=' ||
- op === '*=' ||
- op === '/=' ||
- op === '%=' ||
- op === '+=' ||
- op === '-=' ||
- op === '<<=' ||
- op === '>>=' ||
- op === '>>>=' ||
- op === '&=' ||
- op === '^=' ||
- op === '|=';
- }
- // Note that 'yield' is treated as a keyword in strict mode, but a
- // contextual keyword (identifier) in non-strict mode, so we need to
- // use matchKeyword('yield', false) and matchKeyword('yield', true)
- // (i.e. matchContextualKeyword) appropriately.
- function matchYield() {
- return state.yieldAllowed && matchKeyword('yield', !strict);
- }
- function matchAsync() {
- var backtrackToken = lookahead, matches = false;
- if (matchContextualKeyword('async')) {
- lex(); // Make sure peekLineTerminator() starts after 'async'.
- matches = !peekLineTerminator();
- rewind(backtrackToken); // Revert the lex().
- }
- return matches;
- }
- function matchAwait() {
- return state.awaitAllowed && matchContextualKeyword('await');
- }
- function consumeSemicolon() {
- var line, oldIndex = index, oldLineNumber = lineNumber,
- oldLineStart = lineStart, oldLookahead = lookahead;
- // Catch the very common case first: immediately a semicolon (char #59).
- if (source.charCodeAt(index) === 59) {
- lex();
- return;
- }
- line = lineNumber;
- skipComment();
- if (lineNumber !== line) {
- index = oldIndex;
- lineNumber = oldLineNumber;
- lineStart = oldLineStart;
- lookahead = oldLookahead;
- return;
- }
- if (match(';')) {
- lex();
- return;
- }
- if (lookahead.type !== Token.EOF && !match('}')) {
- throwUnexpected(lookahead);
- }
- }
- // Return true if provided expression is LeftHandSideExpression
- function isLeftHandSide(expr) {
- return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;
- }
- function isAssignableLeftHandSide(expr) {
- return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern;
- }
- // 11.1.4 Array Initialiser
- function parseArrayInitialiser() {
- var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true, body,
- marker = markerCreate();
- expect('[');
- while (!match(']')) {
- if (lookahead.value === 'for' &&
- lookahead.type === Token.Keyword) {
- if (!possiblecomprehension) {
- throwError({}, Messages.ComprehensionError);
- }
- matchKeyword('for');
- tmp = parseForStatement({ignoreBody: true});
- tmp.of = tmp.type === Syntax.ForOfStatement;
- tmp.type = Syntax.ComprehensionBlock;
- if (tmp.left.kind) { // can't be let or const
- throwError({}, Messages.ComprehensionError);
- }
- blocks.push(tmp);
- } else if (lookahead.value === 'if' &&
- lookahead.type === Token.Keyword) {
- if (!possiblecomprehension) {
- throwError({}, Messages.ComprehensionError);
- }
- expectKeyword('if');
- expect('(');
- filter = parseExpression();
- expect(')');
- } else if (lookahead.value === ',' &&
- lookahead.type === Token.Punctuator) {
- possiblecomprehension = false; // no longer allowed.
- lex();
- elements.push(null);
- } else {
- tmp = parseSpreadOrAssignmentExpression();
- elements.push(tmp);
- if (tmp && tmp.type === Syntax.SpreadElement) {
- if (!match(']')) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) {
- expect(','); // this lexes.
- possiblecomprehension = false;
- }
- }
- }
- expect(']');
- if (filter && !blocks.length) {
- throwError({}, Messages.ComprehensionRequiresBlock);
- }
- if (blocks.length) {
- if (elements.length !== 1) {
- throwError({}, Messages.ComprehensionError);
- }
- return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0]));
- }
- return markerApply(marker, delegate.createArrayExpression(elements));
- }
- // 11.1.5 Object Initialiser
- function parsePropertyFunction(options) {
- var previousStrict, previousYieldAllowed, previousAwaitAllowed,
- params, defaults, body, marker = markerCreate();
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = options.generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = options.async;
- params = options.params || [];
- defaults = options.defaults || [];
- body = parseConciseBody();
- if (options.name && strict && isRestrictedWord(params[0].name)) {
- throwErrorTolerant(options.name, Messages.StrictParamName);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createFunctionExpression(
- null,
- params,
- defaults,
- body,
- options.rest || null,
- options.generator,
- body.type !== Syntax.BlockStatement,
- options.async,
- options.returnType,
- options.typeParameters
- ));
- }
- function parsePropertyMethodFunction(options) {
- var previousStrict, tmp, method;
- previousStrict = strict;
- strict = true;
- tmp = parseParams();
- if (tmp.stricted) {
- throwErrorTolerant(tmp.stricted, tmp.message);
- }
- method = parsePropertyFunction({
- params: tmp.params,
- defaults: tmp.defaults,
- rest: tmp.rest,
- generator: options.generator,
- async: options.async,
- returnType: tmp.returnType,
- typeParameters: options.typeParameters
- });
- strict = previousStrict;
- return method;
- }
- function parseObjectPropertyKey() {
- var marker = markerCreate(),
- token = lex(),
- propertyKey,
- result;
- // Note: This function is called only from parseObjectProperty(), where
- // EOF and Punctuator tokens are already filtered out.
- if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {
- if (strict && token.octal) {
- throwErrorTolerant(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (token.type === Token.Punctuator && token.value === '[') {
- // For computed properties we should skip the [ and ], and
- // capture in marker only the assignment expression itself.
- marker = markerCreate();
- propertyKey = parseAssignmentExpression();
- result = markerApply(marker, propertyKey);
- expect(']');
- return result;
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseObjectProperty() {
- var token, key, id, value, param, expr, computed,
- marker = markerCreate(), returnType;
- token = lookahead;
- computed = (token.value === '[');
- if (token.type === Token.Identifier || computed || matchAsync()) {
- id = parseObjectPropertyKey();
- if (match(':')) {
- lex();
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- id,
- parseAssignmentExpression(),
- false,
- false,
- computed
- )
- );
- }
- if (match('(')) {
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- id,
- parsePropertyMethodFunction({
- generator: false,
- async: false
- }),
- true,
- false,
- computed
- )
- );
- }
- // Property Assignment: Getter and Setter.
- if (token.value === 'get') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- expect('(');
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'get',
- key,
- parsePropertyFunction({
- generator: false,
- async: false,
- returnType: returnType
- }),
- false,
- false,
- computed
- )
- );
- }
- if (token.value === 'set') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- expect('(');
- token = lookahead;
- param = [ parseTypeAnnotatableIdentifier() ];
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'set',
- key,
- parsePropertyFunction({
- params: param,
- generator: false,
- async: false,
- name: token,
- returnType: returnType
- }),
- false,
- false,
- computed
- )
- );
- }
- if (token.value === 'async') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- key,
- parsePropertyMethodFunction({
- generator: false,
- async: true
- }),
- true,
- false,
- computed
- )
- );
- }
- if (computed) {
- // Computed properties can only be used with full notation.
- throwUnexpected(lookahead);
- }
- return markerApply(
- marker,
- delegate.createProperty('init', id, id, false, true, false)
- );
- }
- if (token.type === Token.EOF || token.type === Token.Punctuator) {
- if (!match('*')) {
- throwUnexpected(token);
- }
- lex();
- computed = (lookahead.type === Token.Punctuator && lookahead.value === '[');
- id = parseObjectPropertyKey();
- if (!match('(')) {
- throwUnexpected(lex());
- }
- return markerApply(marker, delegate.createProperty('init', id, parsePropertyMethodFunction({ generator: true }), true, false, computed));
- }
- key = parseObjectPropertyKey();
- if (match(':')) {
- lex();
- return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
- }
- if (match('(')) {
- return markerApply(marker, delegate.createProperty('init', key, parsePropertyMethodFunction({ generator: false }), true, false, false));
- }
- throwUnexpected(lex());
- }
- function parseObjectSpreadProperty() {
- var marker = markerCreate();
- expect('...');
- return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
- }
- function parseObjectInitialiser() {
- var properties = [], property, name, key, kind, map = {}, toString = String,
- marker = markerCreate();
- expect('{');
- while (!match('}')) {
- if (match('...')) {
- property = parseObjectSpreadProperty();
- } else {
- property = parseObjectProperty();
- if (property.key.type === Syntax.Identifier) {
- name = property.key.name;
- } else {
- name = toString(property.key.value);
- }
- kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
- key = '$' + name;
- if (Object.prototype.hasOwnProperty.call(map, key)) {
- if (map[key] === PropertyKind.Data) {
- if (strict && kind === PropertyKind.Data) {
- throwErrorTolerant({}, Messages.StrictDuplicateProperty);
- } else if (kind !== PropertyKind.Data) {
- throwErrorTolerant({}, Messages.AccessorDataProperty);
- }
- } else {
- if (kind === PropertyKind.Data) {
- throwErrorTolerant({}, Messages.AccessorDataProperty);
- } else if (map[key] & kind) {
- throwErrorTolerant({}, Messages.AccessorGetSet);
- }
- }
- map[key] |= kind;
- } else {
- map[key] = kind;
- }
- }
- properties.push(property);
- if (!match('}')) {
- expect(',');
- }
- }
- expect('}');
- return markerApply(marker, delegate.createObjectExpression(properties));
- }
- function parseTemplateElement(option) {
- var marker = markerCreate(),
- token = scanTemplateElement(option);
- if (strict && token.octal) {
- throwError(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail));
- }
- function parseTemplateLiteral() {
- var quasi, quasis, expressions, marker = markerCreate();
- quasi = parseTemplateElement({ head: true });
- quasis = [ quasi ];
- expressions = [];
- while (!quasi.tail) {
- expressions.push(parseExpression());
- quasi = parseTemplateElement({ head: false });
- quasis.push(quasi);
- }
- return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions));
- }
- // 11.1.6 The Grouping Operator
- function parseGroupExpression() {
- var expr;
- expect('(');
- ++state.parenthesizedCount;
- expr = parseExpression();
- expect(')');
- return expr;
- }
- function matchAsyncFuncExprOrDecl() {
- var token;
- if (matchAsync()) {
- token = lookahead2();
- if (token.type === Token.Keyword && token.value === 'function') {
- return true;
- }
- }
- return false;
- }
- // 11.1 Primary Expressions
- function parsePrimaryExpression() {
- var marker, type, token, expr;
- type = lookahead.type;
- if (type === Token.Identifier) {
- marker = markerCreate();
- return markerApply(marker, delegate.createIdentifier(lex().value));
- }
- if (type === Token.StringLiteral || type === Token.NumericLiteral) {
- if (strict && lookahead.octal) {
- throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
- }
- marker = markerCreate();
- return markerApply(marker, delegate.createLiteral(lex()));
- }
- if (type === Token.Keyword) {
- if (matchKeyword('this')) {
- marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createThisExpression());
- }
- if (matchKeyword('function')) {
- return parseFunctionExpression();
- }
- if (matchKeyword('class')) {
- return parseClassExpression();
- }
- if (matchKeyword('super')) {
- marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createIdentifier('super'));
- }
- }
- if (type === Token.BooleanLiteral) {
- marker = markerCreate();
- token = lex();
- token.value = (token.value === 'true');
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (type === Token.NullLiteral) {
- marker = markerCreate();
- token = lex();
- token.value = null;
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (match('[')) {
- return parseArrayInitialiser();
- }
- if (match('{')) {
- return parseObjectInitialiser();
- }
- if (match('(')) {
- return parseGroupExpression();
- }
- if (match('/') || match('/=')) {
- marker = markerCreate();
- return markerApply(marker, delegate.createLiteral(scanRegExp()));
- }
- if (type === Token.Template) {
- return parseTemplateLiteral();
- }
- if (match('<')) {
- return parseXJSElement();
- }
- throwUnexpected(lex());
- }
- // 11.2 Left-Hand-Side Expressions
- function parseArguments() {
- var args = [], arg;
- expect('(');
- if (!match(')')) {
- while (index < length) {
- arg = parseSpreadOrAssignmentExpression();
- args.push(arg);
- if (match(')')) {
- break;
- } else if (arg.type === Syntax.SpreadElement) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- expect(',');
- }
- }
- expect(')');
- return args;
- }
- function parseSpreadOrAssignmentExpression() {
- if (match('...')) {
- var marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression()));
- }
- return parseAssignmentExpression();
- }
- function parseNonComputedProperty() {
- var marker = markerCreate(),
- token = lex();
- if (!isIdentifierName(token)) {
- throwUnexpected(token);
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseNonComputedMember() {
- expect('.');
- return parseNonComputedProperty();
- }
- function parseComputedMember() {
- var expr;
- expect('[');
- expr = parseExpression();
- expect(']');
- return expr;
- }
- function parseNewExpression() {
- var callee, args, marker = markerCreate();
- expectKeyword('new');
- callee = parseLeftHandSideExpression();
- args = match('(') ? parseArguments() : [];
- return markerApply(marker, delegate.createNewExpression(callee, args));
- }
- function parseLeftHandSideExpressionAllowCall() {
- var expr, args, marker = markerCreate();
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
- while (match('.') || match('[') || match('(') || lookahead.type === Token.Template) {
- if (match('(')) {
- args = parseArguments();
- expr = markerApply(marker, delegate.createCallExpression(expr, args));
- } else if (match('[')) {
- expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
- } else if (match('.')) {
- expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
- } else {
- expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
- }
- }
- return expr;
- }
- function parseLeftHandSideExpression() {
- var expr, marker = markerCreate();
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
- while (match('.') || match('[') || lookahead.type === Token.Template) {
- if (match('[')) {
- expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
- } else if (match('.')) {
- expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
- } else {
- expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
- }
- }
- return expr;
- }
- // 11.3 Postfix Expressions
- function parsePostfixExpression() {
- var marker = markerCreate(),
- expr = parseLeftHandSideExpressionAllowCall(),
- token;
- if (lookahead.type !== Token.Punctuator) {
- return expr;
- }
- if ((match('++') || match('--')) && !peekLineTerminator()) {
- // 11.3.1, 11.3.2
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant({}, Messages.StrictLHSPostfix);
- }
- if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- token = lex();
- expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr));
- }
- return expr;
- }
- // 11.4 Unary Operators
- function parseUnaryExpression() {
- var marker, token, expr;
- if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
- return parsePostfixExpression();
- }
- if (match('++') || match('--')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- // 11.4.4, 11.4.5
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant({}, Messages.StrictLHSPrefix);
- }
- if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- }
- if (match('+') || match('-') || match('~') || match('!')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- }
- if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
- throwErrorTolerant({}, Messages.StrictDelete);
- }
- return expr;
- }
- return parsePostfixExpression();
- }
- function binaryPrecedence(token, allowIn) {
- var prec = 0;
- if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
- return 0;
- }
- switch (token.value) {
- case '||':
- prec = 1;
- break;
- case '&&':
- prec = 2;
- break;
- case '|':
- prec = 3;
- break;
- case '^':
- prec = 4;
- break;
- case '&':
- prec = 5;
- break;
- case '==':
- case '!=':
- case '===':
- case '!==':
- prec = 6;
- break;
- case '<':
- case '>':
- case '<=':
- case '>=':
- case 'instanceof':
- prec = 7;
- break;
- case 'in':
- prec = allowIn ? 7 : 0;
- break;
- case '<<':
- case '>>':
- case '>>>':
- prec = 8;
- break;
- case '+':
- case '-':
- prec = 9;
- break;
- case '*':
- case '/':
- case '%':
- prec = 11;
- break;
- default:
- break;
- }
- return prec;
- }
- // 11.5 Multiplicative Operators
- // 11.6 Additive Operators
- // 11.7 Bitwise Shift Operators
- // 11.8 Relational Operators
- // 11.9 Equality Operators
- // 11.10 Binary Bitwise Operators
- // 11.11 Binary Logical Operators
- function parseBinaryExpression() {
- var expr, token, prec, previousAllowIn, stack, right, operator, left, i,
- marker, markers;
- previousAllowIn = state.allowIn;
- state.allowIn = true;
- marker = markerCreate();
- left = parseUnaryExpression();
- token = lookahead;
- prec = binaryPrecedence(token, previousAllowIn);
- if (prec === 0) {
- return left;
- }
- token.prec = prec;
- lex();
- markers = [marker, markerCreate()];
- right = parseUnaryExpression();
- stack = [left, token, right];
- while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) {
- // Reduce: make a binary expression from the three topmost entries.
- while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
- right = stack.pop();
- operator = stack.pop().value;
- left = stack.pop();
- expr = delegate.createBinaryExpression(operator, left, right);
- markers.pop();
- marker = markers.pop();
- markerApply(marker, expr);
- stack.push(expr);
- markers.push(marker);
- }
- // Shift.
- token = lex();
- token.prec = prec;
- stack.push(token);
- markers.push(markerCreate());
- expr = parseUnaryExpression();
- stack.push(expr);
- }
- state.allowIn = previousAllowIn;
- // Final reduce to clean-up the stack.
- i = stack.length - 1;
- expr = stack[i];
- markers.pop();
- while (i > 1) {
- expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
- i -= 2;
- marker = markers.pop();
- markerApply(marker, expr);
- }
- return expr;
- }
- // 11.12 Conditional Operator
- function parseConditionalExpression() {
- var expr, previousAllowIn, consequent, alternate, marker = markerCreate();
- expr = parseBinaryExpression();
- if (match('?')) {
- lex();
- previousAllowIn = state.allowIn;
- state.allowIn = true;
- consequent = parseAssignmentExpression();
- state.allowIn = previousAllowIn;
- expect(':');
- alternate = parseAssignmentExpression();
- expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate));
- }
- return expr;
- }
- // 11.13 Assignment Operators
- function reinterpretAsAssignmentBindingPattern(expr) {
- var i, len, property, element;
- if (expr.type === Syntax.ObjectExpression) {
- expr.type = Syntax.ObjectPattern;
- for (i = 0, len = expr.properties.length; i < len; i += 1) {
- property = expr.properties[i];
- if (property.type === Syntax.SpreadProperty) {
- if (i < len - 1) {
- throwError({}, Messages.PropertyAfterSpreadProperty);
- }
- reinterpretAsAssignmentBindingPattern(property.argument);
- } else {
- if (property.kind !== 'init') {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- reinterpretAsAssignmentBindingPattern(property.value);
- }
- }
- } else if (expr.type === Syntax.ArrayExpression) {
- expr.type = Syntax.ArrayPattern;
- for (i = 0, len = expr.elements.length; i < len; i += 1) {
- element = expr.elements[i];
- if (element) {
- reinterpretAsAssignmentBindingPattern(element);
- }
- }
- } else if (expr.type === Syntax.Identifier) {
- if (isRestrictedWord(expr.name)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- } else if (expr.type === Syntax.SpreadElement) {
- reinterpretAsAssignmentBindingPattern(expr.argument);
- if (expr.argument.type === Syntax.ObjectPattern) {
- throwError({}, Messages.ObjectPatternAsSpread);
- }
- } else {
- if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- }
- }
- function reinterpretAsDestructuredParameter(options, expr) {
- var i, len, property, element;
- if (expr.type === Syntax.ObjectExpression) {
- expr.type = Syntax.ObjectPattern;
- for (i = 0, len = expr.properties.length; i < len; i += 1) {
- property = expr.properties[i];
- if (property.type === Syntax.SpreadProperty) {
- if (i < len - 1) {
- throwError({}, Messages.PropertyAfterSpreadProperty);
- }
- reinterpretAsDestructuredParameter(options, property.argument);
- } else {
- if (property.kind !== 'init') {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- reinterpretAsDestructuredParameter(options, property.value);
- }
- }
- } else if (expr.type === Syntax.ArrayExpression) {
- expr.type = Syntax.ArrayPattern;
- for (i = 0, len = expr.elements.length; i < len; i += 1) {
- element = expr.elements[i];
- if (element) {
- reinterpretAsDestructuredParameter(options, element);
- }
- }
- } else if (expr.type === Syntax.Identifier) {
- validateParam(options, expr, expr.name);
- } else {
- if (expr.type !== Syntax.MemberExpression) {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- }
- }
- function reinterpretAsCoverFormalsList(expressions) {
- var i, len, param, params, defaults, defaultCount, options, rest;
- params = [];
- defaults = [];
- defaultCount = 0;
- rest = null;
- options = {
- paramSet: {}
- };
- for (i = 0, len = expressions.length; i < len; i += 1) {
- param = expressions[i];
- if (param.type === Syntax.Identifier) {
- params.push(param);
- defaults.push(null);
- validateParam(options, param, param.name);
- } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) {
- reinterpretAsDestructuredParameter(options, param);
- params.push(param);
- defaults.push(null);
- } else if (param.type === Syntax.SpreadElement) {
- assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
- reinterpretAsDestructuredParameter(options, param.argument);
- rest = param.argument;
- } else if (param.type === Syntax.AssignmentExpression) {
- params.push(param.left);
- defaults.push(param.right);
- ++defaultCount;
- validateParam(options, param.left, param.left.name);
- } else {
- return null;
- }
- }
- if (options.message === Messages.StrictParamDupe) {
- throwError(
- strict ? options.stricted : options.firstRestricted,
- options.message
- );
- }
- if (defaultCount === 0) {
- defaults = [];
- }
- return {
- params: params,
- defaults: defaults,
- rest: rest,
- stricted: options.stricted,
- firstRestricted: options.firstRestricted,
- message: options.message
- };
- }
- function parseArrowFunctionExpression(options, marker) {
- var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
- expect('=>');
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = !!options.async;
- body = parseConciseBody();
- if (strict && options.firstRestricted) {
- throwError(options.firstRestricted, options.message);
- }
- if (strict && options.stricted) {
- throwErrorTolerant(options.stricted, options.message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createArrowFunctionExpression(
- options.params,
- options.defaults,
- body,
- options.rest,
- body.type !== Syntax.BlockStatement,
- !!options.async
- ));
- }
- function parseAssignmentExpression() {
- var marker, expr, token, params, oldParenthesizedCount,
- backtrackToken = lookahead, possiblyAsync = false;
- if (matchYield()) {
- return parseYieldExpression();
- }
- if (matchAwait()) {
- return parseAwaitExpression();
- }
- oldParenthesizedCount = state.parenthesizedCount;
- marker = markerCreate();
- if (matchAsyncFuncExprOrDecl()) {
- return parseFunctionExpression();
- }
- if (matchAsync()) {
- // We can't be completely sure that this 'async' token is
- // actually a contextual keyword modifying a function
- // expression, so we might have to un-lex() it later by
- // calling rewind(backtrackToken).
- possiblyAsync = true;
- lex();
- }
- if (match('(')) {
- token = lookahead2();
- if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
- params = parseParams();
- if (!match('=>')) {
- throwUnexpected(lex());
- }
- params.async = possiblyAsync;
- return parseArrowFunctionExpression(params, marker);
- }
- }
- token = lookahead;
- // If the 'async' keyword is not followed by a '(' character or an
- // identifier, then it can't be an arrow function modifier, and we
- // should interpret it as a normal identifer.
- if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
- possiblyAsync = false;
- rewind(backtrackToken);
- }
- expr = parseConditionalExpression();
- if (match('=>') &&
- (state.parenthesizedCount === oldParenthesizedCount ||
- state.parenthesizedCount === (oldParenthesizedCount + 1))) {
- if (expr.type === Syntax.Identifier) {
- params = reinterpretAsCoverFormalsList([ expr ]);
- } else if (expr.type === Syntax.SequenceExpression) {
- params = reinterpretAsCoverFormalsList(expr.expressions);
- }
- if (params) {
- params.async = possiblyAsync;
- return parseArrowFunctionExpression(params, marker);
- }
- }
- // If we haven't returned by now, then the 'async' keyword was not
- // a function modifier, and we should rewind and interpret it as a
- // normal identifier.
- if (possiblyAsync) {
- possiblyAsync = false;
- rewind(backtrackToken);
- expr = parseConditionalExpression();
- }
- if (matchAssign()) {
- // 11.13.1
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant(token, Messages.StrictLHSAssignment);
- }
- // ES.next draf 11.13 Runtime Semantics step 1
- if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) {
- reinterpretAsAssignmentBindingPattern(expr);
- } else if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression()));
- }
- return expr;
- }
- // 11.14 Comma Operator
- function parseExpression() {
- var marker, expr, expressions, sequence, coverFormalsList, spreadFound, oldParenthesizedCount;
- oldParenthesizedCount = state.parenthesizedCount;
- marker = markerCreate();
- expr = parseAssignmentExpression();
- expressions = [ expr ];
- if (match(',')) {
- while (index < length) {
- if (!match(',')) {
- break;
- }
- lex();
- expr = parseSpreadOrAssignmentExpression();
- expressions.push(expr);
- if (expr.type === Syntax.SpreadElement) {
- spreadFound = true;
- if (!match(')')) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- break;
- }
- }
- sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
- }
- if (match('=>')) {
- // Do not allow nested parentheses on the LHS of the =>.
- if (state.parenthesizedCount === oldParenthesizedCount || state.parenthesizedCount === (oldParenthesizedCount + 1)) {
- expr = expr.type === Syntax.SequenceExpression ? expr.expressions : expressions;
- coverFormalsList = reinterpretAsCoverFormalsList(expr);
- if (coverFormalsList) {
- return parseArrowFunctionExpression(coverFormalsList, marker);
- }
- }
- throwUnexpected(lex());
- }
- if (spreadFound && lookahead2().value !== '=>') {
- throwError({}, Messages.IllegalSpread);
- }
- return sequence || expr;
- }
- // 12.1 Block
- function parseStatementList() {
- var list = [],
- statement;
- while (index < length) {
- if (match('}')) {
- break;
- }
- statement = parseSourceElement();
- if (typeof statement === 'undefined') {
- break;
- }
- list.push(statement);
- }
- return list;
- }
- function parseBlock() {
- var block, marker = markerCreate();
- expect('{');
- block = parseStatementList();
- expect('}');
- return markerApply(marker, delegate.createBlockStatement(block));
- }
- // 12.2 Variable Statement
- function parseTypeParameterDeclaration() {
- var marker = markerCreate(), paramTypes = [];
- expect('<');
- while (!match('>')) {
- paramTypes.push(parseVariableIdentifier());
- if (!match('>')) {
- expect(',');
- }
- }
- expect('>');
- return markerApply(marker, delegate.createTypeParameterDeclaration(
- paramTypes
- ));
- }
- function parseTypeParameterInstantiation() {
- var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
- state.inType = true;
- expect('<');
- while (!match('>')) {
- paramTypes.push(parseType());
- if (!match('>')) {
- expect(',');
- }
- }
- expect('>');
- state.inType = oldInType;
- return markerApply(marker, delegate.createTypeParameterInstantiation(
- paramTypes
- ));
- }
- function parseObjectTypeIndexer(marker, isStatic) {
- var id, key, value;
- expect('[');
- id = parseObjectPropertyKey();
- expect(':');
- key = parseType();
- expect(']');
- expect(':');
- value = parseType();
- return markerApply(marker, delegate.createObjectTypeIndexer(
- id,
- key,
- value,
- isStatic
- ));
- }
- function parseObjectTypeMethodish(marker) {
- var params = [], rest = null, returnType, typeParameters = null;
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('(');
- while (lookahead.type === Token.Identifier) {
- params.push(parseFunctionTypeParam());
- if (!match(')')) {
- expect(',');
- }
- }
- if (match('...')) {
- lex();
- rest = parseFunctionTypeParam();
- }
- expect(')');
- expect(':');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- }
- function parseObjectTypeMethod(marker, isStatic, key) {
- var optional = false, value;
- value = parseObjectTypeMethodish(marker);
- return markerApply(marker, delegate.createObjectTypeProperty(
- key,
- value,
- optional,
- isStatic
- ));
- }
- function parseObjectTypeCallProperty(marker, isStatic) {
- var valueMarker = markerCreate();
- return markerApply(marker, delegate.createObjectTypeCallProperty(
- parseObjectTypeMethodish(valueMarker),
- isStatic
- ));
- }
- function parseObjectType(allowStatic) {
- var callProperties = [], indexers = [], marker, optional = false,
- properties = [], property, propertyKey, propertyTypeAnnotation,
- token, isStatic;
- expect('{');
- while (!match('}')) {
- marker = markerCreate();
- if (allowStatic && matchContextualKeyword('static')) {
- token = lex();
- isStatic = true;
- }
- if (match('[')) {
- indexers.push(parseObjectTypeIndexer(marker, isStatic));
- } else if (match('(') || match('<')) {
- callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
- } else {
- if (isStatic && match(':')) {
- propertyKey = markerApply(marker, delegate.createIdentifier(token));
- throwErrorTolerant(token, Messages.StrictReservedWord);
- } else {
- propertyKey = parseObjectPropertyKey();
- }
- if (match('<') || match('(')) {
- // This is a method property
- properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
- } else {
- if (match('?')) {
- lex();
- optional = true;
- }
- expect(':');
- propertyTypeAnnotation = parseType();
- properties.push(markerApply(marker, delegate.createObjectTypeProperty(
- propertyKey,
- propertyTypeAnnotation,
- optional,
- isStatic
- )));
- }
- }
- if (match(';')) {
- lex();
- } else if (!match('}')) {
- throwUnexpected(lookahead);
- }
- }
- expect('}');
- return delegate.createObjectTypeAnnotation(
- properties,
- indexers,
- callProperties
- );
- }
- function parseGenericType() {
- var marker = markerCreate(), returnType = null,
- typeParameters = null, typeIdentifier,
- typeIdentifierMarker = markerCreate;
- typeIdentifier = parseVariableIdentifier();
- while (match('.')) {
- expect('.');
- typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
- typeIdentifier,
- parseVariableIdentifier()
- ));
- }
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- }
- return markerApply(marker, delegate.createGenericTypeAnnotation(
- typeIdentifier,
- typeParameters
- ));
- }
- function parseVoidType() {
- var marker = markerCreate();
- expectKeyword('void');
- return markerApply(marker, delegate.createVoidTypeAnnotation());
- }
- function parseTypeofType() {
- var argument, marker = markerCreate();
- expectKeyword('typeof');
- argument = parsePrimaryType();
- return markerApply(marker, delegate.createTypeofTypeAnnotation(
- argument
- ));
- }
- function parseTupleType() {
- var marker = markerCreate(), types = [];
- expect('[');
- // We allow trailing commas
- while (index < length && !match(']')) {
- types.push(parseType());
- if (match(']')) {
- break;
- }
- expect(',');
- }
- expect(']');
- return markerApply(marker, delegate.createTupleTypeAnnotation(
- types
- ));
- }
- function parseFunctionTypeParam() {
- var marker = markerCreate(), name, optional = false, typeAnnotation;
- name = parseVariableIdentifier();
- if (match('?')) {
- lex();
- optional = true;
- }
- expect(':');
- typeAnnotation = parseType();
- return markerApply(marker, delegate.createFunctionTypeParam(
- name,
- typeAnnotation,
- optional
- ));
- }
- function parseFunctionTypeParams() {
- var ret = { params: [], rest: null };
- while (lookahead.type === Token.Identifier) {
- ret.params.push(parseFunctionTypeParam());
- if (!match(')')) {
- expect(',');
- }
- }
- if (match('...')) {
- lex();
- ret.rest = parseFunctionTypeParam();
- }
- return ret;
- }
- // The parsing of types roughly parallels the parsing of expressions, and
- // primary types are kind of like primary expressions...they're the
- // primitives with which other types are constructed.
- function parsePrimaryType() {
- var typeIdentifier = null, params = null, returnType = null,
- marker = markerCreate(), rest = null, tmp,
- typeParameters, token, type, isGroupedType = false;
- switch (lookahead.type) {
- case Token.Identifier:
- switch (lookahead.value) {
- case 'any':
- lex();
- return markerApply(marker, delegate.createAnyTypeAnnotation());
- case 'bool': // fallthrough
- case 'boolean':
- lex();
- return markerApply(marker, delegate.createBooleanTypeAnnotation());
- case 'number':
- lex();
- return markerApply(marker, delegate.createNumberTypeAnnotation());
- case 'string':
- lex();
- return markerApply(marker, delegate.createStringTypeAnnotation());
- }
- return markerApply(marker, parseGenericType());
- case Token.Punctuator:
- switch (lookahead.value) {
- case '{':
- return markerApply(marker, parseObjectType());
- case '[':
- return parseTupleType();
- case '<':
- typeParameters = parseTypeParameterDeclaration();
- expect('(');
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect('=>');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- case '(':
- lex();
- // Check to see if this is actually a grouped type
- if (!match(')') && !match('...')) {
- if (lookahead.type === Token.Identifier) {
- token = lookahead2();
- isGroupedType = token.value !== '?' && token.value !== ':';
- } else {
- isGroupedType = true;
- }
- }
- if (isGroupedType) {
- type = parseType();
- expect(')');
- // If we see a => next then someone was probably confused about
- // function types, so we can provide a better error message
- if (match('=>')) {
- throwError({}, Messages.ConfusedAboutFunctionType);
- }
- return type;
- }
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect('=>');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- null /* typeParameters */
- ));
- }
- break;
- case Token.Keyword:
- switch (lookahead.value) {
- case 'void':
- return markerApply(marker, parseVoidType());
- case 'typeof':
- return markerApply(marker, parseTypeofType());
- }
- break;
- case Token.StringLiteral:
- token = lex();
- if (token.octal) {
- throwError(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
- token
- ));
- }
- throwUnexpected(lookahead);
- }
- function parsePostfixType() {
- var marker = markerCreate(), t = parsePrimaryType();
- if (match('[')) {
- expect('[');
- expect(']');
- return markerApply(marker, delegate.createArrayTypeAnnotation(t));
- }
- return t;
- }
- function parsePrefixType() {
- var marker = markerCreate();
- if (match('?')) {
- lex();
- return markerApply(marker, delegate.createNullableTypeAnnotation(
- parsePrefixType()
- ));
- }
- return parsePostfixType();
- }
- function parseIntersectionType() {
- var marker = markerCreate(), type, types;
- type = parsePrefixType();
- types = [type];
- while (match('&')) {
- lex();
- types.push(parsePrefixType());
- }
- return types.length === 1 ?
- type :
- markerApply(marker, delegate.createIntersectionTypeAnnotation(
- types
- ));
- }
- function parseUnionType() {
- var marker = markerCreate(), type, types;
- type = parseIntersectionType();
- types = [type];
- while (match('|')) {
- lex();
- types.push(parseIntersectionType());
- }
- return types.length === 1 ?
- type :
- markerApply(marker, delegate.createUnionTypeAnnotation(
- types
- ));
- }
- function parseType() {
- var oldInType = state.inType, type;
- state.inType = true;
- type = parseUnionType();
- state.inType = oldInType;
- return type;
- }
- function parseTypeAnnotation() {
- var marker = markerCreate(), type;
- expect(':');
- type = parseType();
- return markerApply(marker, delegate.createTypeAnnotation(type));
- }
- function parseVariableIdentifier() {
- var marker = markerCreate(),
- token = lex();
- if (token.type !== Token.Identifier) {
- throwUnexpected(token);
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) {
- var marker = markerCreate(),
- ident = parseVariableIdentifier(),
- isOptionalParam = false;
- if (canBeOptionalParam && match('?')) {
- expect('?');
- isOptionalParam = true;
- }
- if (requireTypeAnnotation || match(':')) {
- ident.typeAnnotation = parseTypeAnnotation();
- ident = markerApply(marker, ident);
- }
- if (isOptionalParam) {
- ident.optional = true;
- ident = markerApply(marker, ident);
- }
- return ident;
- }
- function parseVariableDeclaration(kind) {
- var id,
- marker = markerCreate(),
- init = null,
- typeAnnotationMarker = markerCreate();
- if (match('{')) {
- id = parseObjectInitialiser();
- reinterpretAsAssignmentBindingPattern(id);
- if (match(':')) {
- id.typeAnnotation = parseTypeAnnotation();
- markerApply(typeAnnotationMarker, id);
- }
- } else if (match('[')) {
- id = parseArrayInitialiser();
- reinterpretAsAssignmentBindingPattern(id);
- if (match(':')) {
- id.typeAnnotation = parseTypeAnnotation();
- markerApply(typeAnnotationMarker, id);
- }
- } else {
- id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
- // 12.2.1
- if (strict && isRestrictedWord(id.name)) {
- throwErrorTolerant({}, Messages.StrictVarName);
- }
- }
- if (kind === 'const') {
- if (!match('=')) {
- throwError({}, Messages.NoUnintializedConst);
- }
- expect('=');
- init = parseAssignmentExpression();
- } else if (match('=')) {
- lex();
- init = parseAssignmentExpression();
- }
- return markerApply(marker, delegate.createVariableDeclarator(id, init));
- }
- function parseVariableDeclarationList(kind) {
- var list = [];
- do {
- list.push(parseVariableDeclaration(kind));
- if (!match(',')) {
- break;
- }
- lex();
- } while (index < length);
- return list;
- }
- function parseVariableStatement() {
- var declarations, marker = markerCreate();
- expectKeyword('var');
- declarations = parseVariableDeclarationList();
- consumeSemicolon();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var'));
- }
- // kind may be `const` or `let`
- // Both are experimental and not in the specification yet.
- // see http://wiki.ecmascript.org/doku.php?id=harmony:const
- // and http://wiki.ecmascript.org/doku.php?id=harmony:let
- function parseConstLetDeclaration(kind) {
- var declarations, marker = markerCreate();
- expectKeyword(kind);
- declarations = parseVariableDeclarationList(kind);
- consumeSemicolon();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
- }
- // people.mozilla.org/~jorendorff/es6-draft.html
- function parseModuleSpecifier() {
- var marker = markerCreate(),
- specifier;
- if (lookahead.type !== Token.StringLiteral) {
- throwError({}, Messages.InvalidModuleSpecifier);
- }
- specifier = delegate.createModuleSpecifier(lookahead);
- lex();
- return markerApply(marker, specifier);
- }
- function parseExportBatchSpecifier() {
- var marker = markerCreate();
- expect('*');
- return markerApply(marker, delegate.createExportBatchSpecifier());
- }
- function parseExportSpecifier() {
- var id, name = null, marker = markerCreate(), from;
- if (matchKeyword('default')) {
- lex();
- id = markerApply(marker, delegate.createIdentifier('default'));
- // export {default} from "something";
- } else {
- id = parseVariableIdentifier();
- }
- if (matchContextualKeyword('as')) {
- lex();
- name = parseNonComputedProperty();
- }
- return markerApply(marker, delegate.createExportSpecifier(id, name));
- }
- function parseExportDeclaration() {
- var backtrackToken, id, previousAllowKeyword, declaration = null,
- isExportFromIdentifier,
- src = null, specifiers = [],
- marker = markerCreate();
- expectKeyword('export');
- if (matchKeyword('default')) {
- // covers:
- // export default ...
- lex();
- if (matchKeyword('function') || matchKeyword('class')) {
- backtrackToken = lookahead;
- lex();
- if (isIdentifierName(lookahead)) {
- // covers:
- // export default function foo () {}
- // export default class foo {}
- id = parseNonComputedProperty();
- rewind(backtrackToken);
- return markerApply(marker, delegate.createExportDeclaration(true, parseSourceElement(), [id], null));
- }
- // covers:
- // export default function () {}
- // export default class {}
- rewind(backtrackToken);
- switch (lookahead.value) {
- case 'class':
- return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
- case 'function':
- return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
- }
- }
- if (matchContextualKeyword('from')) {
- throwError({}, Messages.UnexpectedToken, lookahead.value);
- }
- // covers:
- // export default {};
- // export default [];
- if (match('{')) {
- declaration = parseObjectInitialiser();
- } else if (match('[')) {
- declaration = parseArrayInitialiser();
- } else {
- declaration = parseAssignmentExpression();
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
- }
- // non-default export
- if (lookahead.type === Token.Keyword) {
- // covers:
- // export var f = 1;
- switch (lookahead.value) {
- case 'let':
- case 'const':
- case 'var':
- case 'class':
- case 'function':
- return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
- }
- }
- if (match('*')) {
- // covers:
- // export * from "foo";
- specifiers.push(parseExportBatchSpecifier());
- if (!matchContextualKeyword('from')) {
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- }
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
- }
- expect('{');
- do {
- isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
- specifiers.push(parseExportSpecifier());
- } while (match(',') && lex());
- expect('}');
- if (matchContextualKeyword('from')) {
- // covering:
- // export {default} from "foo";
- // export {foo} from "foo";
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- } else if (isExportFromIdentifier) {
- // covering:
- // export {default}; // missing fromClause
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- } else {
- // cover
- // export {foo};
- consumeSemicolon();
- }
- return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
- }
- function parseImportSpecifier() {
- // import {<foo as bar>} ...;
- var id, name = null, marker = markerCreate();
- id = parseNonComputedProperty();
- if (matchContextualKeyword('as')) {
- lex();
- name = parseVariableIdentifier();
- }
- return markerApply(marker, delegate.createImportSpecifier(id, name));
- }
- function parseNamedImports() {
- var specifiers = [];
- // {foo, bar as bas}
- expect('{');
- do {
- specifiers.push(parseImportSpecifier());
- } while (match(',') && lex());
- expect('}');
- return specifiers;
- }
- function parseImportDefaultSpecifier() {
- // import <foo> ...;
- var id, marker = markerCreate();
- id = parseNonComputedProperty();
- return markerApply(marker, delegate.createImportDefaultSpecifier(id));
- }
- function parseImportNamespaceSpecifier() {
- // import <* as foo> ...;
- var id, marker = markerCreate();
- expect('*');
- if (!matchContextualKeyword('as')) {
- throwError({}, Messages.NoAsAfterImportNamespace);
- }
- lex();
- id = parseNonComputedProperty();
- return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
- }
- function parseImportDeclaration() {
- var specifiers, src, marker = markerCreate();
- expectKeyword('import');
- specifiers = [];
- if (lookahead.type === Token.StringLiteral) {
- // covers:
- // import "foo";
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
- }
- if (!matchKeyword('default') && isIdentifierName(lookahead)) {
- // covers:
- // import foo
- // import foo, ...
- specifiers.push(parseImportDefaultSpecifier());
- if (match(',')) {
- lex();
- }
- }
- if (match('*')) {
- // covers:
- // import foo, * as foo
- // import * as foo
- specifiers.push(parseImportNamespaceSpecifier());
- } else if (match('{')) {
- // covers:
- // import foo, {bar}
- // import {bar}
- specifiers = specifiers.concat(parseNamedImports());
- }
- if (!matchContextualKeyword('from')) {
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- }
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
- }
- // 12.3 Empty Statement
- function parseEmptyStatement() {
- var marker = markerCreate();
- expect(';');
- return markerApply(marker, delegate.createEmptyStatement());
- }
- // 12.4 Expression Statement
- function parseExpressionStatement() {
- var marker = markerCreate(), expr = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createExpressionStatement(expr));
- }
- // 12.5 If statement
- function parseIfStatement() {
- var test, consequent, alternate, marker = markerCreate();
- expectKeyword('if');
- expect('(');
- test = parseExpression();
- expect(')');
- consequent = parseStatement();
- if (matchKeyword('else')) {
- lex();
- alternate = parseStatement();
- } else {
- alternate = null;
- }
- return markerApply(marker, delegate.createIfStatement(test, consequent, alternate));
- }
- // 12.6 Iteration Statements
- function parseDoWhileStatement() {
- var body, test, oldInIteration, marker = markerCreate();
- expectKeyword('do');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- body = parseStatement();
- state.inIteration = oldInIteration;
- expectKeyword('while');
- expect('(');
- test = parseExpression();
- expect(')');
- if (match(';')) {
- lex();
- }
- return markerApply(marker, delegate.createDoWhileStatement(body, test));
- }
- function parseWhileStatement() {
- var test, body, oldInIteration, marker = markerCreate();
- expectKeyword('while');
- expect('(');
- test = parseExpression();
- expect(')');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- body = parseStatement();
- state.inIteration = oldInIteration;
- return markerApply(marker, delegate.createWhileStatement(test, body));
- }
- function parseForVariableDeclaration() {
- var marker = markerCreate(),
- token = lex(),
- declarations = parseVariableDeclarationList();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value));
- }
- function parseForStatement(opts) {
- var init, test, update, left, right, body, operator, oldInIteration,
- marker = markerCreate();
- init = test = update = null;
- expectKeyword('for');
- // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each
- if (matchContextualKeyword('each')) {
- throwError({}, Messages.EachNotAllowed);
- }
- expect('(');
- if (match(';')) {
- lex();
- } else {
- if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) {
- state.allowIn = false;
- init = parseForVariableDeclaration();
- state.allowIn = true;
- if (init.declarations.length === 1) {
- if (matchKeyword('in') || matchContextualKeyword('of')) {
- operator = lookahead;
- if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) {
- lex();
- left = init;
- right = parseExpression();
- init = null;
- }
- }
- }
- } else {
- state.allowIn = false;
- init = parseExpression();
- state.allowIn = true;
- if (matchContextualKeyword('of')) {
- operator = lex();
- left = init;
- right = parseExpression();
- init = null;
- } else if (matchKeyword('in')) {
- // LeftHandSideExpression
- if (!isAssignableLeftHandSide(init)) {
- throwError({}, Messages.InvalidLHSInForIn);
- }
- operator = lex();
- left = init;
- right = parseExpression();
- init = null;
- }
- }
- if (typeof left === 'undefined') {
- expect(';');
- }
- }
- if (typeof left === 'undefined') {
- if (!match(';')) {
- test = parseExpression();
- }
- expect(';');
- if (!match(')')) {
- update = parseExpression();
- }
- }
- expect(')');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- if (!(opts !== undefined && opts.ignoreBody)) {
- body = parseStatement();
- }
- state.inIteration = oldInIteration;
- if (typeof left === 'undefined') {
- return markerApply(marker, delegate.createForStatement(init, test, update, body));
- }
- if (operator.value === 'in') {
- return markerApply(marker, delegate.createForInStatement(left, right, body));
- }
- return markerApply(marker, delegate.createForOfStatement(left, right, body));
- }
- // 12.7 The continue statement
- function parseContinueStatement() {
- var label = null, key, marker = markerCreate();
- expectKeyword('continue');
- // Optimize the most common form: 'continue;'.
- if (source.charCodeAt(index) === 59) {
- lex();
- if (!state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(null));
- }
- if (peekLineTerminator()) {
- if (!state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(null));
- }
- if (lookahead.type === Token.Identifier) {
- label = parseVariableIdentifier();
- key = '$' + label.name;
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
- throwError({}, Messages.UnknownLabel, label.name);
- }
- }
- consumeSemicolon();
- if (label === null && !state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(label));
- }
- // 12.8 The break statement
- function parseBreakStatement() {
- var label = null, key, marker = markerCreate();
- expectKeyword('break');
- // Catch the very common case first: immediately a semicolon (char #59).
- if (source.charCodeAt(index) === 59) {
- lex();
- if (!(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(null));
- }
- if (peekLineTerminator()) {
- if (!(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(null));
- }
- if (lookahead.type === Token.Identifier) {
- label = parseVariableIdentifier();
- key = '$' + label.name;
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
- throwError({}, Messages.UnknownLabel, label.name);
- }
- }
- consumeSemicolon();
- if (label === null && !(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(label));
- }
- // 12.9 The return statement
- function parseReturnStatement() {
- var argument = null, marker = markerCreate();
- expectKeyword('return');
- if (!state.inFunctionBody) {
- throwErrorTolerant({}, Messages.IllegalReturn);
- }
- // 'return' followed by a space and an identifier is very common.
- if (source.charCodeAt(index) === 32) {
- if (isIdentifierStart(source.charCodeAt(index + 1))) {
- argument = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createReturnStatement(argument));
- }
- }
- if (peekLineTerminator()) {
- return markerApply(marker, delegate.createReturnStatement(null));
- }
- if (!match(';')) {
- if (!match('}') && lookahead.type !== Token.EOF) {
- argument = parseExpression();
- }
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createReturnStatement(argument));
- }
- // 12.10 The with statement
- function parseWithStatement() {
- var object, body, marker = markerCreate();
- if (strict) {
- throwErrorTolerant({}, Messages.StrictModeWith);
- }
- expectKeyword('with');
- expect('(');
- object = parseExpression();
- expect(')');
- body = parseStatement();
- return markerApply(marker, delegate.createWithStatement(object, body));
- }
- // 12.10 The swith statement
- function parseSwitchCase() {
- var test,
- consequent = [],
- sourceElement,
- marker = markerCreate();
- if (matchKeyword('default')) {
- lex();
- test = null;
- } else {
- expectKeyword('case');
- test = parseExpression();
- }
- expect(':');
- while (index < length) {
- if (match('}') || matchKeyword('default') || matchKeyword('case')) {
- break;
- }
- sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- consequent.push(sourceElement);
- }
- return markerApply(marker, delegate.createSwitchCase(test, consequent));
- }
- function parseSwitchStatement() {
- var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate();
- expectKeyword('switch');
- expect('(');
- discriminant = parseExpression();
- expect(')');
- expect('{');
- cases = [];
- if (match('}')) {
- lex();
- return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
- }
- oldInSwitch = state.inSwitch;
- state.inSwitch = true;
- defaultFound = false;
- while (index < length) {
- if (match('}')) {
- break;
- }
- clause = parseSwitchCase();
- if (clause.test === null) {
- if (defaultFound) {
- throwError({}, Messages.MultipleDefaultsInSwitch);
- }
- defaultFound = true;
- }
- cases.push(clause);
- }
- state.inSwitch = oldInSwitch;
- expect('}');
- return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
- }
- // 12.13 The throw statement
- function parseThrowStatement() {
- var argument, marker = markerCreate();
- expectKeyword('throw');
- if (peekLineTerminator()) {
- throwError({}, Messages.NewlineAfterThrow);
- }
- argument = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createThrowStatement(argument));
- }
- // 12.14 The try statement
- function parseCatchClause() {
- var param, body, marker = markerCreate();
- expectKeyword('catch');
- expect('(');
- if (match(')')) {
- throwUnexpected(lookahead);
- }
- param = parseExpression();
- // 12.14.1
- if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) {
- throwErrorTolerant({}, Messages.StrictCatchVariable);
- }
- expect(')');
- body = parseBlock();
- return markerApply(marker, delegate.createCatchClause(param, body));
- }
- function parseTryStatement() {
- var block, handlers = [], finalizer = null, marker = markerCreate();
- expectKeyword('try');
- block = parseBlock();
- if (matchKeyword('catch')) {
- handlers.push(parseCatchClause());
- }
- if (matchKeyword('finally')) {
- lex();
- finalizer = parseBlock();
- }
- if (handlers.length === 0 && !finalizer) {
- throwError({}, Messages.NoCatchOrFinally);
- }
- return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer));
- }
- // 12.15 The debugger statement
- function parseDebuggerStatement() {
- var marker = markerCreate();
- expectKeyword('debugger');
- consumeSemicolon();
- return markerApply(marker, delegate.createDebuggerStatement());
- }
- // 12 Statements
- function parseStatement() {
- var type = lookahead.type,
- marker,
- expr,
- labeledBody,
- key;
- if (type === Token.EOF) {
- throwUnexpected(lookahead);
- }
- if (type === Token.Punctuator) {
- switch (lookahead.value) {
- case ';':
- return parseEmptyStatement();
- case '{':
- return parseBlock();
- case '(':
- return parseExpressionStatement();
- default:
- break;
- }
- }
- if (type === Token.Keyword) {
- switch (lookahead.value) {
- case 'break':
- return parseBreakStatement();
- case 'continue':
- return parseContinueStatement();
- case 'debugger':
- return parseDebuggerStatement();
- case 'do':
- return parseDoWhileStatement();
- case 'for':
- return parseForStatement();
- case 'function':
- return parseFunctionDeclaration();
- case 'class':
- return parseClassDeclaration();
- case 'if':
- return parseIfStatement();
- case 'return':
- return parseReturnStatement();
- case 'switch':
- return parseSwitchStatement();
- case 'throw':
- return parseThrowStatement();
- case 'try':
- return parseTryStatement();
- case 'var':
- return parseVariableStatement();
- case 'while':
- return parseWhileStatement();
- case 'with':
- return parseWithStatement();
- default:
- break;
- }
- }
- if (matchAsyncFuncExprOrDecl()) {
- return parseFunctionDeclaration();
- }
- marker = markerCreate();
- expr = parseExpression();
- // 12.12 Labelled Statements
- if ((expr.type === Syntax.Identifier) && match(':')) {
- lex();
- key = '$' + expr.name;
- if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
- throwError({}, Messages.Redeclaration, 'Label', expr.name);
- }
- state.labelSet[key] = true;
- labeledBody = parseStatement();
- delete state.labelSet[key];
- return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createExpressionStatement(expr));
- }
- // 13 Function Definition
- function parseConciseBody() {
- if (match('{')) {
- return parseFunctionSourceElements();
- }
- return parseAssignmentExpression();
- }
- function parseFunctionSourceElements() {
- var sourceElement, sourceElements = [], token, directive, firstRestricted,
- oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount,
- marker = markerCreate();
- expect('{');
- while (index < length) {
- if (lookahead.type !== Token.StringLiteral) {
- break;
- }
- token = lookahead;
- sourceElement = parseSourceElement();
- sourceElements.push(sourceElement);
- if (sourceElement.expression.type !== Syntax.Literal) {
- // this is not directive
- break;
- }
- directive = source.slice(token.range[0] + 1, token.range[1] - 1);
- if (directive === 'use strict') {
- strict = true;
- if (firstRestricted) {
- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
- }
- } else {
- if (!firstRestricted && token.octal) {
- firstRestricted = token;
- }
- }
- }
- oldLabelSet = state.labelSet;
- oldInIteration = state.inIteration;
- oldInSwitch = state.inSwitch;
- oldInFunctionBody = state.inFunctionBody;
- oldParenthesizedCount = state.parenthesizedCount;
- state.labelSet = {};
- state.inIteration = false;
- state.inSwitch = false;
- state.inFunctionBody = true;
- state.parenthesizedCount = 0;
- while (index < length) {
- if (match('}')) {
- break;
- }
- sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- sourceElements.push(sourceElement);
- }
- expect('}');
- state.labelSet = oldLabelSet;
- state.inIteration = oldInIteration;
- state.inSwitch = oldInSwitch;
- state.inFunctionBody = oldInFunctionBody;
- state.parenthesizedCount = oldParenthesizedCount;
- return markerApply(marker, delegate.createBlockStatement(sourceElements));
- }
- function validateParam(options, param, name) {
- var key = '$' + name;
- if (strict) {
- if (isRestrictedWord(name)) {
- options.stricted = param;
- options.message = Messages.StrictParamName;
- }
- if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
- options.stricted = param;
- options.message = Messages.StrictParamDupe;
- }
- } else if (!options.firstRestricted) {
- if (isRestrictedWord(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictParamName;
- } else if (isStrictModeReservedWord(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictReservedWord;
- } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
- options.firstRestricted = param;
- options.message = Messages.StrictParamDupe;
- }
- }
- options.paramSet[key] = true;
- }
- function parseParam(options) {
- var marker, token, rest, param, def;
- token = lookahead;
- if (token.value === '...') {
- token = lex();
- rest = true;
- }
- if (match('[')) {
- marker = markerCreate();
- param = parseArrayInitialiser();
- reinterpretAsDestructuredParameter(options, param);
- if (match(':')) {
- param.typeAnnotation = parseTypeAnnotation();
- markerApply(marker, param);
- }
- } else if (match('{')) {
- marker = markerCreate();
- if (rest) {
- throwError({}, Messages.ObjectPatternAsRestParameter);
- }
- param = parseObjectInitialiser();
- reinterpretAsDestructuredParameter(options, param);
- if (match(':')) {
- param.typeAnnotation = parseTypeAnnotation();
- markerApply(marker, param);
- }
- } else {
- param =
- rest
- ? parseTypeAnnotatableIdentifier(
- false, /* requireTypeAnnotation */
- false /* canBeOptionalParam */
- )
- : parseTypeAnnotatableIdentifier(
- false, /* requireTypeAnnotation */
- true /* canBeOptionalParam */
- );
- validateParam(options, token, token.value);
- }
- if (match('=')) {
- if (rest) {
- throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
- }
- lex();
- def = parseAssignmentExpression();
- ++options.defaultCount;
- }
- if (rest) {
- if (!match(')')) {
- throwError({}, Messages.ParameterAfterRestParameter);
- }
- options.rest = param;
- return false;
- }
- options.params.push(param);
- options.defaults.push(def);
- return !match(')');
- }
- function parseParams(firstRestricted) {
- var options, marker = markerCreate();
- options = {
- params: [],
- defaultCount: 0,
- defaults: [],
- rest: null,
- firstRestricted: firstRestricted
- };
- expect('(');
- if (!match(')')) {
- options.paramSet = {};
- while (index < length) {
- if (!parseParam(options)) {
- break;
- }
- expect(',');
- }
- }
- expect(')');
- if (options.defaultCount === 0) {
- options.defaults = [];
- }
- if (match(':')) {
- options.returnType = parseTypeAnnotation();
- }
- return markerApply(marker, options);
- }
- function parseFunctionDeclaration() {
- var id, body, token, tmp, firstRestricted, message, generator, isAsync,
- previousStrict, previousYieldAllowed, previousAwaitAllowed,
- marker = markerCreate(), typeParameters;
- isAsync = false;
- if (matchAsync()) {
- lex();
- isAsync = true;
- }
- expectKeyword('function');
- generator = false;
- if (match('*')) {
- lex();
- generator = true;
- }
- token = lookahead;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (strict) {
- if (isRestrictedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictFunctionName);
- }
- } else {
- if (isRestrictedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictFunctionName;
- } else if (isStrictModeReservedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictReservedWord;
- }
- }
- tmp = parseParams(firstRestricted);
- firstRestricted = tmp.firstRestricted;
- if (tmp.message) {
- message = tmp.message;
- }
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = isAsync;
- body = parseFunctionSourceElements();
- if (strict && firstRestricted) {
- throwError(firstRestricted, message);
- }
- if (strict && tmp.stricted) {
- throwErrorTolerant(tmp.stricted, message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(
- marker,
- delegate.createFunctionDeclaration(
- id,
- tmp.params,
- tmp.defaults,
- body,
- tmp.rest,
- generator,
- false,
- isAsync,
- tmp.returnType,
- typeParameters
- )
- );
- }
- function parseFunctionExpression() {
- var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
- previousStrict, previousYieldAllowed, previousAwaitAllowed,
- marker = markerCreate(), typeParameters;
- isAsync = false;
- if (matchAsync()) {
- lex();
- isAsync = true;
- }
- expectKeyword('function');
- generator = false;
- if (match('*')) {
- lex();
- generator = true;
- }
- if (!match('(')) {
- if (!match('<')) {
- token = lookahead;
- id = parseVariableIdentifier();
- if (strict) {
- if (isRestrictedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictFunctionName);
- }
- } else {
- if (isRestrictedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictFunctionName;
- } else if (isStrictModeReservedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictReservedWord;
- }
- }
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- }
- tmp = parseParams(firstRestricted);
- firstRestricted = tmp.firstRestricted;
- if (tmp.message) {
- message = tmp.message;
- }
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = isAsync;
- body = parseFunctionSourceElements();
- if (strict && firstRestricted) {
- throwError(firstRestricted, message);
- }
- if (strict && tmp.stricted) {
- throwErrorTolerant(tmp.stricted, message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(
- marker,
- delegate.createFunctionExpression(
- id,
- tmp.params,
- tmp.defaults,
- body,
- tmp.rest,
- generator,
- false,
- isAsync,
- tmp.returnType,
- typeParameters
- )
- );
- }
- function parseYieldExpression() {
- var delegateFlag, expr, marker = markerCreate();
- expectKeyword('yield', !strict);
- delegateFlag = false;
- if (match('*')) {
- lex();
- delegateFlag = true;
- }
- expr = parseAssignmentExpression();
- return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
- }
- function parseAwaitExpression() {
- var expr, marker = markerCreate();
- expectContextualKeyword('await');
- expr = parseAssignmentExpression();
- return markerApply(marker, delegate.createAwaitExpression(expr));
- }
- // 14 Classes
- function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
- var token, param, propType, isValidDuplicateProp = false,
- isAsync, typeParameters, tokenValue, returnType,
- annotationMarker;
- propType = isStatic ? ClassPropertyType.static : ClassPropertyType.prototype;
- if (generator) {
- return delegate.createMethodDefinition(
- propType,
- '',
- key,
- parsePropertyMethodFunction({ generator: true })
- );
- }
- tokenValue = key.type === 'Identifier' && key.name;
- if (tokenValue === 'get' && !match('(')) {
- key = parseObjectPropertyKey();
- // It is a syntax error if any other properties have a name
- // duplicating this one unless they are a setter
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
- isValidDuplicateProp =
- // There isn't already a getter for this prop
- existingPropNames[propType][key.name].get === undefined
- // There isn't already a data prop by this name
- && existingPropNames[propType][key.name].data === undefined
- // The only existing prop by this name is a setter
- && existingPropNames[propType][key.name].set !== undefined;
- if (!isValidDuplicateProp) {
- throwError(key, Messages.IllegalDuplicateClassProperty);
- }
- } else {
- existingPropNames[propType][key.name] = {};
- }
- existingPropNames[propType][key.name].get = true;
- expect('(');
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return delegate.createMethodDefinition(
- propType,
- 'get',
- key,
- parsePropertyFunction({ generator: false, returnType: returnType })
- );
- }
- if (tokenValue === 'set' && !match('(')) {
- key = parseObjectPropertyKey();
- // It is a syntax error if any other properties have a name
- // duplicating this one unless they are a getter
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
- isValidDuplicateProp =
- // There isn't already a setter for this prop
- existingPropNames[propType][key.name].set === undefined
- // There isn't already a data prop by this name
- && existingPropNames[propType][key.name].data === undefined
- // The only existing prop by this name is a getter
- && existingPropNames[propType][key.name].get !== undefined;
- if (!isValidDuplicateProp) {
- throwError(key, Messages.IllegalDuplicateClassProperty);
- }
- } else {
- existingPropNames[propType][key.name] = {};
- }
- existingPropNames[propType][key.name].set = true;
- expect('(');
- token = lookahead;
- param = [ parseTypeAnnotatableIdentifier() ];
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return delegate.createMethodDefinition(
- propType,
- 'set',
- key,
- parsePropertyFunction({
- params: param,
- generator: false,
- name: token,
- returnType: returnType
- })
- );
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- isAsync = tokenValue === 'async' && !match('(');
- if (isAsync) {
- key = parseObjectPropertyKey();
- }
- // It is a syntax error if any other properties have the same name as a
- // non-getter, non-setter method
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
- throwError(key, Messages.IllegalDuplicateClassProperty);
- } else {
- existingPropNames[propType][key.name] = {};
- }
- existingPropNames[propType][key.name].data = true;
- return delegate.createMethodDefinition(
- propType,
- '',
- key,
- parsePropertyMethodFunction({
- generator: false,
- async: isAsync,
- typeParameters: typeParameters
- })
- );
- }
- function parseClassProperty(existingPropNames, key, computed, isStatic) {
- var typeAnnotation;
- typeAnnotation = parseTypeAnnotation();
- expect(';');
- return delegate.createClassProperty(
- key,
- typeAnnotation,
- computed,
- isStatic
- );
- }
- function parseClassElement(existingProps) {
- var computed, generator = false, key, marker = markerCreate(),
- isStatic = false;
- if (match(';')) {
- lex();
- return;
- }
- if (lookahead.value === 'static') {
- lex();
- isStatic = true;
- }
- if (match('*')) {
- lex();
- generator = true;
- }
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- if (!generator && lookahead.value === ':') {
- return markerApply(marker, parseClassProperty(existingProps, key, computed, isStatic));
- }
- return markerApply(marker, parseMethodDefinition(
- existingProps,
- key,
- isStatic,
- generator,
- computed
- ));
- }
- function parseClassBody() {
- var classElement, classElements = [], existingProps = {}, marker = markerCreate();
- existingProps[ClassPropertyType.static] = {};
- existingProps[ClassPropertyType.prototype] = {};
- expect('{');
- while (index < length) {
- if (match('}')) {
- break;
- }
- classElement = parseClassElement(existingProps);
- if (typeof classElement !== 'undefined') {
- classElements.push(classElement);
- }
- }
- expect('}');
- return markerApply(marker, delegate.createClassBody(classElements));
- }
- function parseClassImplements() {
- var id, implemented = [], marker, typeParameters;
- expectContextualKeyword('implements');
- while (index < length) {
- marker = markerCreate();
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- } else {
- typeParameters = null;
- }
- implemented.push(markerApply(marker, delegate.createClassImplements(
- id,
- typeParameters
- )));
- if (!match(',')) {
- break;
- }
- expect(',');
- }
- return implemented;
- }
- function parseClassExpression() {
- var id, implemented, previousYieldAllowed, superClass = null,
- superTypeParameters, marker = markerCreate(), typeParameters;
- expectKeyword('class');
- if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
- id = parseVariableIdentifier();
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- superClass = parseLeftHandSideExpressionAllowCall();
- if (match('<')) {
- superTypeParameters = parseTypeParameterInstantiation();
- }
- state.yieldAllowed = previousYieldAllowed;
- }
- if (matchContextualKeyword('implements')) {
- implemented = parseClassImplements();
- }
- return markerApply(marker, delegate.createClassExpression(
- id,
- superClass,
- parseClassBody(),
- typeParameters,
- superTypeParameters,
- implemented
- ));
- }
- function parseClassDeclaration() {
- var id, implemented, previousYieldAllowed, superClass = null,
- superTypeParameters, marker = markerCreate(), typeParameters;
- expectKeyword('class');
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- superClass = parseLeftHandSideExpressionAllowCall();
- if (match('<')) {
- superTypeParameters = parseTypeParameterInstantiation();
- }
- state.yieldAllowed = previousYieldAllowed;
- }
- if (matchContextualKeyword('implements')) {
- implemented = parseClassImplements();
- }
- return markerApply(marker, delegate.createClassDeclaration(
- id,
- superClass,
- parseClassBody(),
- typeParameters,
- superTypeParameters,
- implemented
- ));
- }
- // 15 Program
- function parseSourceElement() {
- var token;
- if (lookahead.type === Token.Keyword) {
- switch (lookahead.value) {
- case 'const':
- case 'let':
- return parseConstLetDeclaration(lookahead.value);
- case 'function':
- return parseFunctionDeclaration();
- default:
- return parseStatement();
- }
- }
- if (matchContextualKeyword('type')
- && lookahead2().type === Token.Identifier) {
- return parseTypeAlias();
- }
- if (matchContextualKeyword('interface')
- && lookahead2().type === Token.Identifier) {
- return parseInterface();
- }
- if (matchContextualKeyword('declare')) {
- token = lookahead2();
- if (token.type === Token.Keyword) {
- switch (token.value) {
- case 'class':
- return parseDeclareClass();
- case 'function':
- return parseDeclareFunction();
- case 'var':
- return parseDeclareVariable();
- }
- } else if (token.type === Token.Identifier
- && token.value === 'module') {
- return parseDeclareModule();
- }
- }
- if (lookahead.type !== Token.EOF) {
- return parseStatement();
- }
- }
- function parseProgramElement() {
- if (lookahead.type === Token.Keyword) {
- switch (lookahead.value) {
- case 'export':
- return parseExportDeclaration();
- case 'import':
- return parseImportDeclaration();
- }
- }
- return parseSourceElement();
- }
- function parseProgramElements() {
- var sourceElement, sourceElements = [], token, directive, firstRestricted;
- while (index < length) {
- token = lookahead;
- if (token.type !== Token.StringLiteral) {
- break;
- }
- sourceElement = parseProgramElement();
- sourceElements.push(sourceElement);
- if (sourceElement.expression.type !== Syntax.Literal) {
- // this is not directive
- break;
- }
- directive = source.slice(token.range[0] + 1, token.range[1] - 1);
- if (directive === 'use strict') {
- strict = true;
- if (firstRestricted) {
- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
- }
- } else {
- if (!firstRestricted && token.octal) {
- firstRestricted = token;
- }
- }
- }
- while (index < length) {
- sourceElement = parseProgramElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- sourceElements.push(sourceElement);
- }
- return sourceElements;
- }
- function parseProgram() {
- var body, marker = markerCreate();
- strict = false;
- peek();
- body = parseProgramElements();
- return markerApply(marker, delegate.createProgram(body));
- }
- // The following functions are needed only when the option to preserve
- // the comments is active.
- function addComment(type, value, start, end, loc) {
- var comment;
- assert(typeof start === 'number', 'Comment must have valid position');
- // Because the way the actual token is scanned, often the comments
- // (if any) are skipped twice during the lexical analysis.
- // Thus, we need to skip adding a comment if the comment array already
- // handled it.
- if (state.lastCommentStart >= start) {
- return;
- }
- state.lastCommentStart = start;
- comment = {
- type: type,
- value: value
- };
- if (extra.range) {
- comment.range = [start, end];
- }
- if (extra.loc) {
- comment.loc = loc;
- }
- extra.comments.push(comment);
- if (extra.attachComment) {
- extra.leadingComments.push(comment);
- extra.trailingComments.push(comment);
- }
- }
- function scanComment() {
- var comment, ch, loc, start, blockComment, lineComment;
- comment = '';
- blockComment = false;
- lineComment = false;
- while (index < length) {
- ch = source[index];
- if (lineComment) {
- ch = source[index++];
- if (isLineTerminator(ch.charCodeAt(0))) {
- loc.end = {
- line: lineNumber,
- column: index - lineStart - 1
- };
- lineComment = false;
- addComment('Line', comment, start, index - 1, loc);
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- comment = '';
- } else if (index >= length) {
- lineComment = false;
- comment += ch;
- loc.end = {
- line: lineNumber,
- column: length - lineStart
- };
- addComment('Line', comment, start, length, loc);
- } else {
- comment += ch;
- }
- } else if (blockComment) {
- if (isLineTerminator(ch.charCodeAt(0))) {
- if (ch === '\r') {
- ++index;
- comment += '\r';
- }
- if (ch !== '\r' || source[index] === '\n') {
- comment += source[index];
- ++lineNumber;
- ++index;
- lineStart = index;
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- } else {
- ch = source[index++];
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- comment += ch;
- if (ch === '*') {
- ch = source[index];
- if (ch === '/') {
- comment = comment.substr(0, comment.length - 1);
- blockComment = false;
- ++index;
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- addComment('Block', comment, start, index, loc);
- comment = '';
- }
- }
- }
- } else if (ch === '/') {
- ch = source[index + 1];
- if (ch === '/') {
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- start = index;
- index += 2;
- lineComment = true;
- if (index >= length) {
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- lineComment = false;
- addComment('Line', comment, start, index, loc);
- }
- } else if (ch === '*') {
- start = index;
- index += 2;
- blockComment = true;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart - 2
- }
- };
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- } else {
- break;
- }
- } else if (isWhiteSpace(ch.charCodeAt(0))) {
- ++index;
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- ++index;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- } else {
- break;
- }
- }
- }
- // 16 XJS
- XHTMLEntities = {
- quot: '\u0022',
- amp: '&',
- apos: '\u0027',
- lt: '<',
- gt: '>',
- nbsp: '\u00A0',
- iexcl: '\u00A1',
- cent: '\u00A2',
- pound: '\u00A3',
- curren: '\u00A4',
- yen: '\u00A5',
- brvbar: '\u00A6',
- sect: '\u00A7',
- uml: '\u00A8',
- copy: '\u00A9',
- ordf: '\u00AA',
- laquo: '\u00AB',
- not: '\u00AC',
- shy: '\u00AD',
- reg: '\u00AE',
- macr: '\u00AF',
- deg: '\u00B0',
- plusmn: '\u00B1',
- sup2: '\u00B2',
- sup3: '\u00B3',
- acute: '\u00B4',
- micro: '\u00B5',
- para: '\u00B6',
- middot: '\u00B7',
- cedil: '\u00B8',
- sup1: '\u00B9',
- ordm: '\u00BA',
- raquo: '\u00BB',
- frac14: '\u00BC',
- frac12: '\u00BD',
- frac34: '\u00BE',
- iquest: '\u00BF',
- Agrave: '\u00C0',
- Aacute: '\u00C1',
- Acirc: '\u00C2',
- Atilde: '\u00C3',
- Auml: '\u00C4',
- Aring: '\u00C5',
- AElig: '\u00C6',
- Ccedil: '\u00C7',
- Egrave: '\u00C8',
- Eacute: '\u00C9',
- Ecirc: '\u00CA',
- Euml: '\u00CB',
- Igrave: '\u00CC',
- Iacute: '\u00CD',
- Icirc: '\u00CE',
- Iuml: '\u00CF',
- ETH: '\u00D0',
- Ntilde: '\u00D1',
- Ograve: '\u00D2',
- Oacute: '\u00D3',
- Ocirc: '\u00D4',
- Otilde: '\u00D5',
- Ouml: '\u00D6',
- times: '\u00D7',
- Oslash: '\u00D8',
- Ugrave: '\u00D9',
- Uacute: '\u00DA',
- Ucirc: '\u00DB',
- Uuml: '\u00DC',
- Yacute: '\u00DD',
- THORN: '\u00DE',
- szlig: '\u00DF',
- agrave: '\u00E0',
- aacute: '\u00E1',
- acirc: '\u00E2',
- atilde: '\u00E3',
- auml: '\u00E4',
- aring: '\u00E5',
- aelig: '\u00E6',
- ccedil: '\u00E7',
- egrave: '\u00E8',
- eacute: '\u00E9',
- ecirc: '\u00EA',
- euml: '\u00EB',
- igrave: '\u00EC',
- iacute: '\u00ED',
- icirc: '\u00EE',
- iuml: '\u00EF',
- eth: '\u00F0',
- ntilde: '\u00F1',
- ograve: '\u00F2',
- oacute: '\u00F3',
- ocirc: '\u00F4',
- otilde: '\u00F5',
- ouml: '\u00F6',
- divide: '\u00F7',
- oslash: '\u00F8',
- ugrave: '\u00F9',
- uacute: '\u00FA',
- ucirc: '\u00FB',
- uuml: '\u00FC',
- yacute: '\u00FD',
- thorn: '\u00FE',
- yuml: '\u00FF',
- OElig: '\u0152',
- oelig: '\u0153',
- Scaron: '\u0160',
- scaron: '\u0161',
- Yuml: '\u0178',
- fnof: '\u0192',
- circ: '\u02C6',
- tilde: '\u02DC',
- Alpha: '\u0391',
- Beta: '\u0392',
- Gamma: '\u0393',
- Delta: '\u0394',
- Epsilon: '\u0395',
- Zeta: '\u0396',
- Eta: '\u0397',
- Theta: '\u0398',
- Iota: '\u0399',
- Kappa: '\u039A',
- Lambda: '\u039B',
- Mu: '\u039C',
- Nu: '\u039D',
- Xi: '\u039E',
- Omicron: '\u039F',
- Pi: '\u03A0',
- Rho: '\u03A1',
- Sigma: '\u03A3',
- Tau: '\u03A4',
- Upsilon: '\u03A5',
- Phi: '\u03A6',
- Chi: '\u03A7',
- Psi: '\u03A8',
- Omega: '\u03A9',
- alpha: '\u03B1',
- beta: '\u03B2',
- gamma: '\u03B3',
- delta: '\u03B4',
- epsilon: '\u03B5',
- zeta: '\u03B6',
- eta: '\u03B7',
- theta: '\u03B8',
- iota: '\u03B9',
- kappa: '\u03BA',
- lambda: '\u03BB',
- mu: '\u03BC',
- nu: '\u03BD',
- xi: '\u03BE',
- omicron: '\u03BF',
- pi: '\u03C0',
- rho: '\u03C1',
- sigmaf: '\u03C2',
- sigma: '\u03C3',
- tau: '\u03C4',
- upsilon: '\u03C5',
- phi: '\u03C6',
- chi: '\u03C7',
- psi: '\u03C8',
- omega: '\u03C9',
- thetasym: '\u03D1',
- upsih: '\u03D2',
- piv: '\u03D6',
- ensp: '\u2002',
- emsp: '\u2003',
- thinsp: '\u2009',
- zwnj: '\u200C',
- zwj: '\u200D',
- lrm: '\u200E',
- rlm: '\u200F',
- ndash: '\u2013',
- mdash: '\u2014',
- lsquo: '\u2018',
- rsquo: '\u2019',
- sbquo: '\u201A',
- ldquo: '\u201C',
- rdquo: '\u201D',
- bdquo: '\u201E',
- dagger: '\u2020',
- Dagger: '\u2021',
- bull: '\u2022',
- hellip: '\u2026',
- permil: '\u2030',
- prime: '\u2032',
- Prime: '\u2033',
- lsaquo: '\u2039',
- rsaquo: '\u203A',
- oline: '\u203E',
- frasl: '\u2044',
- euro: '\u20AC',
- image: '\u2111',
- weierp: '\u2118',
- real: '\u211C',
- trade: '\u2122',
- alefsym: '\u2135',
- larr: '\u2190',
- uarr: '\u2191',
- rarr: '\u2192',
- darr: '\u2193',
- harr: '\u2194',
- crarr: '\u21B5',
- lArr: '\u21D0',
- uArr: '\u21D1',
- rArr: '\u21D2',
- dArr: '\u21D3',
- hArr: '\u21D4',
- forall: '\u2200',
- part: '\u2202',
- exist: '\u2203',
- empty: '\u2205',
- nabla: '\u2207',
- isin: '\u2208',
- notin: '\u2209',
- ni: '\u220B',
- prod: '\u220F',
- sum: '\u2211',
- minus: '\u2212',
- lowast: '\u2217',
- radic: '\u221A',
- prop: '\u221D',
- infin: '\u221E',
- ang: '\u2220',
- and: '\u2227',
- or: '\u2228',
- cap: '\u2229',
- cup: '\u222A',
- 'int': '\u222B',
- there4: '\u2234',
- sim: '\u223C',
- cong: '\u2245',
- asymp: '\u2248',
- ne: '\u2260',
- equiv: '\u2261',
- le: '\u2264',
- ge: '\u2265',
- sub: '\u2282',
- sup: '\u2283',
- nsub: '\u2284',
- sube: '\u2286',
- supe: '\u2287',
- oplus: '\u2295',
- otimes: '\u2297',
- perp: '\u22A5',
- sdot: '\u22C5',
- lceil: '\u2308',
- rceil: '\u2309',
- lfloor: '\u230A',
- rfloor: '\u230B',
- lang: '\u2329',
- rang: '\u232A',
- loz: '\u25CA',
- spades: '\u2660',
- clubs: '\u2663',
- hearts: '\u2665',
- diams: '\u2666'
- };
- function getQualifiedXJSName(object) {
- if (object.type === Syntax.XJSIdentifier) {
- return object.name;
- }
- if (object.type === Syntax.XJSNamespacedName) {
- return object.namespace.name + ':' + object.name.name;
- }
- if (object.type === Syntax.XJSMemberExpression) {
- return (
- getQualifiedXJSName(object.object) + '.' +
- getQualifiedXJSName(object.property)
- );
- }
- }
- function isXJSIdentifierStart(ch) {
- // exclude backslash (\)
- return (ch !== 92) && isIdentifierStart(ch);
- }
- function isXJSIdentifierPart(ch) {
- // exclude backslash (\) and add hyphen (-)
- return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
- }
- function scanXJSIdentifier() {
- var ch, start, value = '';
- start = index;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (!isXJSIdentifierPart(ch)) {
- break;
- }
- value += source[index++];
- }
- return {
- type: Token.XJSIdentifier,
- value: value,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanXJSEntity() {
- var ch, str = '', start = index, count = 0, code;
- ch = source[index];
- assert(ch === '&', 'Entity must start with an ampersand');
- index++;
- while (index < length && count++ < 10) {
- ch = source[index++];
- if (ch === ';') {
- break;
- }
- str += ch;
- }
- // Well-formed entity (ending was found).
- if (ch === ';') {
- // Numeric entity.
- if (str[0] === '#') {
- if (str[1] === 'x') {
- code = +('0' + str.substr(1));
- } else {
- // Removing leading zeros in order to avoid treating as octal in old browsers.
- code = +str.substr(1).replace(Regex.LeadingZeros, '');
- }
- if (!isNaN(code)) {
- return String.fromCharCode(code);
- }
- } else if (XHTMLEntities[str]) {
- return XHTMLEntities[str];
- }
- }
- // Treat non-entity sequences as regular text.
- index = start + 1;
- return '&';
- }
- function scanXJSText(stopChars) {
- var ch, str = '', start;
- start = index;
- while (index < length) {
- ch = source[index];
- if (stopChars.indexOf(ch) !== -1) {
- break;
- }
- if (ch === '&') {
- str += scanXJSEntity();
- } else {
- index++;
- if (ch === '\r' && source[index] === '\n') {
- str += ch;
- ch = source[index];
- index++;
- }
- if (isLineTerminator(ch.charCodeAt(0))) {
- ++lineNumber;
- lineStart = index;
- }
- str += ch;
- }
- }
- return {
- type: Token.XJSText,
- value: str,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanXJSStringLiteral() {
- var innerToken, quote, start;
- quote = source[index];
- assert((quote === '\'' || quote === '"'),
- 'String literal must starts with a quote');
- start = index;
- ++index;
- innerToken = scanXJSText([quote]);
- if (quote !== source[index]) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- innerToken.range = [start, index];
- return innerToken;
- }
- /**
- * Between XJS opening and closing tags (e.g. <foo>HERE</foo>), anything that
- * is not another XJS tag and is not an expression wrapped by {} is text.
- */
- function advanceXJSChild() {
- var ch = source.charCodeAt(index);
- // { (123) and < (60)
- if (ch !== 123 && ch !== 60) {
- return scanXJSText(['<', '{']);
- }
- return scanPunctuator();
- }
- function parseXJSIdentifier() {
- var token, marker = markerCreate();
- if (lookahead.type !== Token.XJSIdentifier) {
- throwUnexpected(lookahead);
- }
- token = lex();
- return markerApply(marker, delegate.createXJSIdentifier(token.value));
- }
- function parseXJSNamespacedName() {
- var namespace, name, marker = markerCreate();
- namespace = parseXJSIdentifier();
- expect(':');
- name = parseXJSIdentifier();
- return markerApply(marker, delegate.createXJSNamespacedName(namespace, name));
- }
- function parseXJSMemberExpression() {
- var marker = markerCreate(),
- expr = parseXJSIdentifier();
- while (match('.')) {
- lex();
- expr = markerApply(marker, delegate.createXJSMemberExpression(expr, parseXJSIdentifier()));
- }
- return expr;
- }
- function parseXJSElementName() {
- if (lookahead2().value === ':') {
- return parseXJSNamespacedName();
- }
- if (lookahead2().value === '.') {
- return parseXJSMemberExpression();
- }
- return parseXJSIdentifier();
- }
- function parseXJSAttributeName() {
- if (lookahead2().value === ':') {
- return parseXJSNamespacedName();
- }
- return parseXJSIdentifier();
- }
- function parseXJSAttributeValue() {
- var value, marker;
- if (match('{')) {
- value = parseXJSExpressionContainer();
- if (value.expression.type === Syntax.XJSEmptyExpression) {
- throwError(
- value,
- 'XJS attributes must only be assigned a non-empty ' +
- 'expression'
- );
- }
- } else if (match('<')) {
- value = parseXJSElement();
- } else if (lookahead.type === Token.XJSText) {
- marker = markerCreate();
- value = markerApply(marker, delegate.createLiteral(lex()));
- } else {
- throwError({}, Messages.InvalidXJSAttributeValue);
- }
- return value;
- }
- function parseXJSEmptyExpression() {
- var marker = markerCreatePreserveWhitespace();
- while (source.charAt(index) !== '}') {
- index++;
- }
- return markerApply(marker, delegate.createXJSEmptyExpression());
- }
- function parseXJSExpressionContainer() {
- var expression, origInXJSChild, origInXJSTag, marker = markerCreate();
- origInXJSChild = state.inXJSChild;
- origInXJSTag = state.inXJSTag;
- state.inXJSChild = false;
- state.inXJSTag = false;
- expect('{');
- if (match('}')) {
- expression = parseXJSEmptyExpression();
- } else {
- expression = parseExpression();
- }
- state.inXJSChild = origInXJSChild;
- state.inXJSTag = origInXJSTag;
- expect('}');
- return markerApply(marker, delegate.createXJSExpressionContainer(expression));
- }
- function parseXJSSpreadAttribute() {
- var expression, origInXJSChild, origInXJSTag, marker = markerCreate();
- origInXJSChild = state.inXJSChild;
- origInXJSTag = state.inXJSTag;
- state.inXJSChild = false;
- state.inXJSTag = false;
- expect('{');
- expect('...');
- expression = parseAssignmentExpression();
- state.inXJSChild = origInXJSChild;
- state.inXJSTag = origInXJSTag;
- expect('}');
- return markerApply(marker, delegate.createXJSSpreadAttribute(expression));
- }
- function parseXJSAttribute() {
- var name, marker;
- if (match('{')) {
- return parseXJSSpreadAttribute();
- }
- marker = markerCreate();
- name = parseXJSAttributeName();
- // HTML empty attribute
- if (match('=')) {
- lex();
- return markerApply(marker, delegate.createXJSAttribute(name, parseXJSAttributeValue()));
- }
- return markerApply(marker, delegate.createXJSAttribute(name));
- }
- function parseXJSChild() {
- var token, marker;
- if (match('{')) {
- token = parseXJSExpressionContainer();
- } else if (lookahead.type === Token.XJSText) {
- marker = markerCreatePreserveWhitespace();
- token = markerApply(marker, delegate.createLiteral(lex()));
- } else {
- token = parseXJSElement();
- }
- return token;
- }
- function parseXJSClosingElement() {
- var name, origInXJSChild, origInXJSTag, marker = markerCreate();
- origInXJSChild = state.inXJSChild;
- origInXJSTag = state.inXJSTag;
- state.inXJSChild = false;
- state.inXJSTag = true;
- expect('<');
- expect('/');
- name = parseXJSElementName();
- // Because advance() (called by lex() called by expect()) expects there
- // to be a valid token after >, it needs to know whether to look for a
- // standard JS token or an XJS text node
- state.inXJSChild = origInXJSChild;
- state.inXJSTag = origInXJSTag;
- expect('>');
- return markerApply(marker, delegate.createXJSClosingElement(name));
- }
- function parseXJSOpeningElement() {
- var name, attribute, attributes = [], selfClosing = false, origInXJSChild, origInXJSTag, marker = markerCreate();
- origInXJSChild = state.inXJSChild;
- origInXJSTag = state.inXJSTag;
- state.inXJSChild = false;
- state.inXJSTag = true;
- expect('<');
- name = parseXJSElementName();
- while (index < length &&
- lookahead.value !== '/' &&
- lookahead.value !== '>') {
- attributes.push(parseXJSAttribute());
- }
- state.inXJSTag = origInXJSTag;
- if (lookahead.value === '/') {
- expect('/');
- // Because advance() (called by lex() called by expect()) expects
- // there to be a valid token after >, it needs to know whether to
- // look for a standard JS token or an XJS text node
- state.inXJSChild = origInXJSChild;
- expect('>');
- selfClosing = true;
- } else {
- state.inXJSChild = true;
- expect('>');
- }
- return markerApply(marker, delegate.createXJSOpeningElement(name, attributes, selfClosing));
- }
- function parseXJSElement() {
- var openingElement, closingElement = null, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
- origInXJSChild = state.inXJSChild;
- origInXJSTag = state.inXJSTag;
- openingElement = parseXJSOpeningElement();
- if (!openingElement.selfClosing) {
- while (index < length) {
- state.inXJSChild = false; // Call lookahead2() with inXJSChild = false because </ should not be considered in the child
- if (lookahead.value === '<' && lookahead2().value === '/') {
- break;
- }
- state.inXJSChild = true;
- children.push(parseXJSChild());
- }
- state.inXJSChild = origInXJSChild;
- state.inXJSTag = origInXJSTag;
- closingElement = parseXJSClosingElement();
- if (getQualifiedXJSName(closingElement.name) !== getQualifiedXJSName(openingElement.name)) {
- throwError({}, Messages.ExpectedXJSClosingTag, getQualifiedXJSName(openingElement.name));
- }
- }
- // When (erroneously) writing two adjacent tags like
- //
- // var x = <div>one</div><div>two</div>;
- //
- // the default error message is a bit incomprehensible. Since it's
- // rarely (never?) useful to write a less-than sign after an XJS
- // element, we disallow it here in the parser in order to provide a
- // better error message. (In the rare case that the less-than operator
- // was intended, the left tag can be wrapped in parentheses.)
- if (!origInXJSChild && match('<')) {
- throwError(lookahead, Messages.AdjacentXJSElements);
- }
- return markerApply(marker, delegate.createXJSElement(openingElement, closingElement, children));
- }
- function parseTypeAlias() {
- var id, marker = markerCreate(), typeParameters = null, right;
- expectContextualKeyword('type');
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('=');
- right = parseType();
- consumeSemicolon();
- return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
- }
- function parseInterfaceExtends() {
- var marker = markerCreate(), id, typeParameters = null;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- }
- return markerApply(marker, delegate.createInterfaceExtends(
- id,
- typeParameters
- ));
- }
- function parseInterfaceish(marker, allowStatic) {
- var body, bodyMarker, extended = [], id,
- typeParameters = null;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- while (index < length) {
- extended.push(parseInterfaceExtends());
- if (!match(',')) {
- break;
- }
- expect(',');
- }
- }
- bodyMarker = markerCreate();
- body = markerApply(bodyMarker, parseObjectType(allowStatic));
- return markerApply(marker, delegate.createInterface(
- id,
- typeParameters,
- body,
- extended
- ));
- }
- function parseInterface() {
- var body, bodyMarker, extended = [], id, marker = markerCreate(),
- typeParameters = null;
- expectContextualKeyword('interface');
- return parseInterfaceish(marker, /* allowStatic */false);
- }
- function parseDeclareClass() {
- var marker = markerCreate(), ret;
- expectContextualKeyword('declare');
- expectKeyword('class');
- ret = parseInterfaceish(marker, /* allowStatic */true);
- ret.type = Syntax.DeclareClass;
- return ret;
- }
- function parseDeclareFunction() {
- var id, idMarker,
- marker = markerCreate(), params, returnType, rest, tmp,
- typeParameters = null, value, valueMarker;
- expectContextualKeyword('declare');
- expectKeyword('function');
- idMarker = markerCreate();
- id = parseVariableIdentifier();
- valueMarker = markerCreate();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('(');
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect(':');
- returnType = parseType();
- value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
- value
- ));
- markerApply(idMarker, id);
- consumeSemicolon();
- return markerApply(marker, delegate.createDeclareFunction(
- id
- ));
- }
- function parseDeclareVariable() {
- var id, marker = markerCreate();
- expectContextualKeyword('declare');
- expectKeyword('var');
- id = parseTypeAnnotatableIdentifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createDeclareVariable(
- id
- ));
- }
- function parseDeclareModule() {
- var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
- expectContextualKeyword('declare');
- expectContextualKeyword('module');
- if (lookahead.type === Token.StringLiteral) {
- if (strict && lookahead.octal) {
- throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
- }
- idMarker = markerCreate();
- id = markerApply(idMarker, delegate.createLiteral(lex()));
- } else {
- id = parseVariableIdentifier();
- }
- bodyMarker = markerCreate();
- expect('{');
- while (index < length && !match('}')) {
- token = lookahead2();
- switch (token.value) {
- case 'class':
- body.push(parseDeclareClass());
- break;
- case 'function':
- body.push(parseDeclareFunction());
- break;
- case 'var':
- body.push(parseDeclareVariable());
- break;
- default:
- throwUnexpected(lookahead);
- }
- }
- expect('}');
- return markerApply(marker, delegate.createDeclareModule(
- id,
- markerApply(bodyMarker, delegate.createBlockStatement(body))
- ));
- }
- function collectToken() {
- var start, loc, token, range, value, entry;
- if (!state.inXJSChild) {
- skipComment();
- }
- start = index;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- token = extra.advance();
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- if (token.type !== Token.EOF) {
- range = [token.range[0], token.range[1]];
- value = source.slice(token.range[0], token.range[1]);
- entry = {
- type: TokenName[token.type],
- value: value,
- range: range,
- loc: loc
- };
- if (token.regex) {
- entry.regex = {
- pattern: token.regex.pattern,
- flags: token.regex.flags
- };
- }
- extra.tokens.push(entry);
- }
- return token;
- }
- function collectRegex() {
- var pos, loc, regex, token;
- skipComment();
- pos = index;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- regex = extra.scanRegExp();
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- if (!extra.tokenize) {
- // Pop the previous token, which is likely '/' or '/='
- if (extra.tokens.length > 0) {
- token = extra.tokens[extra.tokens.length - 1];
- if (token.range[0] === pos && token.type === 'Punctuator') {
- if (token.value === '/' || token.value === '/=') {
- extra.tokens.pop();
- }
- }
- }
- extra.tokens.push({
- type: 'RegularExpression',
- value: regex.literal,
- regex: regex.regex,
- range: [pos, index],
- loc: loc
- });
- }
- return regex;
- }
- function filterTokenLocation() {
- var i, entry, token, tokens = [];
- for (i = 0; i < extra.tokens.length; ++i) {
- entry = extra.tokens[i];
- token = {
- type: entry.type,
- value: entry.value
- };
- if (entry.regex) {
- token.regex = {
- pattern: entry.regex.pattern,
- flags: entry.regex.flags
- };
- }
- if (extra.range) {
- token.range = entry.range;
- }
- if (extra.loc) {
- token.loc = entry.loc;
- }
- tokens.push(token);
- }
- extra.tokens = tokens;
- }
- function patch() {
- if (extra.comments) {
- extra.skipComment = skipComment;
- skipComment = scanComment;
- }
- if (typeof extra.tokens !== 'undefined') {
- extra.advance = advance;
- extra.scanRegExp = scanRegExp;
- advance = collectToken;
- scanRegExp = collectRegex;
- }
- }
- function unpatch() {
- if (typeof extra.skipComment === 'function') {
- skipComment = extra.skipComment;
- }
- if (typeof extra.scanRegExp === 'function') {
- advance = extra.advance;
- scanRegExp = extra.scanRegExp;
- }
- }
- // This is used to modify the delegate.
- function extend(object, properties) {
- var entry, result = {};
- for (entry in object) {
- if (object.hasOwnProperty(entry)) {
- result[entry] = object[entry];
- }
- }
- for (entry in properties) {
- if (properties.hasOwnProperty(entry)) {
- result[entry] = properties[entry];
- }
- }
- return result;
- }
- function tokenize(code, options) {
- var toString,
- token,
- tokens;
- toString = String;
- if (typeof code !== 'string' && !(code instanceof String)) {
- code = toString(code);
- }
- delegate = SyntaxTreeDelegate;
- source = code;
- index = 0;
- lineNumber = (source.length > 0) ? 1 : 0;
- lineStart = 0;
- length = source.length;
- lookahead = null;
- state = {
- allowKeyword: true,
- allowIn: true,
- labelSet: {},
- inFunctionBody: false,
- inIteration: false,
- inSwitch: false,
- lastCommentStart: -1
- };
- extra = {};
- // Options matching.
- options = options || {};
- // Of course we collect tokens here.
- options.tokens = true;
- extra.tokens = [];
- extra.tokenize = true;
- // The following two fields are necessary to compute the Regex tokens.
- extra.openParenToken = -1;
- extra.openCurlyToken = -1;
- extra.range = (typeof options.range === 'boolean') && options.range;
- extra.loc = (typeof options.loc === 'boolean') && options.loc;
- if (typeof options.comment === 'boolean' && options.comment) {
- extra.comments = [];
- }
- if (typeof options.tolerant === 'boolean' && options.tolerant) {
- extra.errors = [];
- }
- if (length > 0) {
- if (typeof source[0] === 'undefined') {
- // Try first to convert to a string. This is good as fast path
- // for old IE which understands string indexing for string
- // literals only and not for string object.
- if (code instanceof String) {
- source = code.valueOf();
- }
- }
- }
- patch();
- try {
- peek();
- if (lookahead.type === Token.EOF) {
- return extra.tokens;
- }
- token = lex();
- while (lookahead.type !== Token.EOF) {
- try {
- token = lex();
- } catch (lexError) {
- token = lookahead;
- if (extra.errors) {
- extra.errors.push(lexError);
- // We have to break on the first error
- // to avoid infinite loops.
- break;
- } else {
- throw lexError;
- }
- }
- }
- filterTokenLocation();
- tokens = extra.tokens;
- if (typeof extra.comments !== 'undefined') {
- tokens.comments = extra.comments;
- }
- if (typeof extra.errors !== 'undefined') {
- tokens.errors = extra.errors;
- }
- } catch (e) {
- throw e;
- } finally {
- unpatch();
- extra = {};
- }
- return tokens;
- }
- function parse(code, options) {
- var program, toString;
- toString = String;
- if (typeof code !== 'string' && !(code instanceof String)) {
- code = toString(code);
- }
- delegate = SyntaxTreeDelegate;
- source = code;
- index = 0;
- lineNumber = (source.length > 0) ? 1 : 0;
- lineStart = 0;
- length = source.length;
- lookahead = null;
- state = {
- allowKeyword: false,
- allowIn: true,
- labelSet: {},
- parenthesizedCount: 0,
- inFunctionBody: false,
- inIteration: false,
- inSwitch: false,
- inXJSChild: false,
- inXJSTag: false,
- inType: false,
- lastCommentStart: -1,
- yieldAllowed: false,
- awaitAllowed: false
- };
- extra = {};
- if (typeof options !== 'undefined') {
- extra.range = (typeof options.range === 'boolean') && options.range;
- extra.loc = (typeof options.loc === 'boolean') && options.loc;
- extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
- if (extra.loc && options.source !== null && options.source !== undefined) {
- delegate = extend(delegate, {
- 'postProcess': function (node) {
- node.loc.source = toString(options.source);
- return node;
- }
- });
- }
- if (typeof options.tokens === 'boolean' && options.tokens) {
- extra.tokens = [];
- }
- if (typeof options.comment === 'boolean' && options.comment) {
- extra.comments = [];
- }
- if (typeof options.tolerant === 'boolean' && options.tolerant) {
- extra.errors = [];
- }
- if (extra.attachComment) {
- extra.range = true;
- extra.comments = [];
- extra.bottomRightStack = [];
- extra.trailingComments = [];
- extra.leadingComments = [];
- }
- }
- if (length > 0) {
- if (typeof source[0] === 'undefined') {
- // Try first to convert to a string. This is good as fast path
- // for old IE which understands string indexing for string
- // literals only and not for string object.
- if (code instanceof String) {
- source = code.valueOf();
- }
- }
- }
- patch();
- try {
- program = parseProgram();
- if (typeof extra.comments !== 'undefined') {
- program.comments = extra.comments;
- }
- if (typeof extra.tokens !== 'undefined') {
- filterTokenLocation();
- program.tokens = extra.tokens;
- }
- if (typeof extra.errors !== 'undefined') {
- program.errors = extra.errors;
- }
- } catch (e) {
- throw e;
- } finally {
- unpatch();
- extra = {};
- }
- return program;
- }
- // Sync with *.json manifests.
- exports.version = '8001.1001.0-dev-harmony-fb';
- exports.tokenize = tokenize;
- exports.parse = parse;
- // Deep copy.
- exports.Syntax = (function () {
- var name, types = {};
- if (typeof Object.create === 'function') {
- types = Object.create(null);
- }
- for (name in Syntax) {
- if (Syntax.hasOwnProperty(name)) {
- types[name] = Syntax[name];
- }
- }
- if (typeof Object.freeze === 'function') {
- Object.freeze(types);
- }
- return types;
- }());
- }));
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{}],454:[function(require,module,exports){
- // simple-fmt.js
- // MIT licensed, see LICENSE file
- // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
- var fmt = (function() {
- "use strict";
- function fmt(str, var_args) {
- var args = Array.prototype.slice.call(arguments, 1);
- return str.replace(/\{(\d+)\}/g, function(s, match) {
- return (match in args ? args[match] : s);
- });
- }
- function obj(str, obj) {
- return str.replace(/\{([_$a-zA-Z0-9][_$a-zA-Z0-9]*)\}/g, function(s, match) {
- return (match in obj ? obj[match] : s);
- });
- }
- function repeat(str, n) {
- return (new Array(n + 1)).join(str);
- }
- fmt.fmt = fmt;
- fmt.obj = obj;
- fmt.repeat = repeat;
- return fmt;
- })();
- if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
- module.exports = fmt;
- }
- },{}],455:[function(require,module,exports){
- // simple-is.js
- // MIT licensed, see LICENSE file
- // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
- var is = (function() {
- "use strict";
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var toString = Object.prototype.toString;
- var _undefined = void 0;
- return {
- nan: function(v) {
- return v !== v;
- },
- boolean: function(v) {
- return typeof v === "boolean";
- },
- number: function(v) {
- return typeof v === "number";
- },
- string: function(v) {
- return typeof v === "string";
- },
- fn: function(v) {
- return typeof v === "function";
- },
- object: function(v) {
- return v !== null && typeof v === "object";
- },
- primitive: function(v) {
- var t = typeof v;
- return v === null || v === _undefined ||
- t === "boolean" || t === "number" || t === "string";
- },
- array: Array.isArray || function(v) {
- return toString.call(v) === "[object Array]";
- },
- finitenumber: function(v) {
- return typeof v === "number" && isFinite(v);
- },
- someof: function(v, values) {
- return values.indexOf(v) >= 0;
- },
- noneof: function(v, values) {
- return values.indexOf(v) === -1;
- },
- own: function(obj, prop) {
- return hasOwnProperty.call(obj, prop);
- },
- };
- })();
- if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
- module.exports = is;
- }
- },{}],456:[function(require,module,exports){
- // stringmap.js
- // MIT licensed, see LICENSE file
- // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
- var StringMap = (function() {
- "use strict";
- // to save us a few characters
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var create = (function() {
- function hasOwnEnumerableProps(obj) {
- for (var prop in obj) {
- if (hasOwnProperty.call(obj, prop)) {
- return true;
- }
- }
- return false;
- }
- // FF <= 3.6:
- // o = {}; o.hasOwnProperty("__proto__" or "__count__" or "__parent__") => true
- // o = {"__proto__": null}; Object.prototype.hasOwnProperty.call(o, "__proto__" or "__count__" or "__parent__") => false
- function hasOwnPollutedProps(obj) {
- return hasOwnProperty.call(obj, "__count__") || hasOwnProperty.call(obj, "__parent__");
- }
- var useObjectCreate = false;
- if (typeof Object.create === "function") {
- if (!hasOwnEnumerableProps(Object.create(null))) {
- useObjectCreate = true;
- }
- }
- if (useObjectCreate === false) {
- if (hasOwnEnumerableProps({})) {
- throw new Error("StringMap environment error 0, please file a bug at https://github.com/olov/stringmap/issues");
- }
- }
- // no throw yet means we can create objects without own enumerable props (safe-guard against VMs and shims)
- var o = (useObjectCreate ? Object.create(null) : {});
- var useProtoClear = false;
- if (hasOwnPollutedProps(o)) {
- o.__proto__ = null;
- if (hasOwnEnumerableProps(o) || hasOwnPollutedProps(o)) {
- throw new Error("StringMap environment error 1, please file a bug at https://github.com/olov/stringmap/issues");
- }
- useProtoClear = true;
- }
- // no throw yet means we can create objects without own polluted props (safe-guard against VMs and shims)
- return function() {
- var o = (useObjectCreate ? Object.create(null) : {});
- if (useProtoClear) {
- o.__proto__ = null;
- }
- return o;
- };
- })();
- // stringmap ctor
- function stringmap(optional_object) {
- // use with or without new
- if (!(this instanceof stringmap)) {
- return new stringmap(optional_object);
- }
- this.obj = create();
- this.hasProto = false; // false (no __proto__ key) or true (has __proto__ key)
- this.proto = undefined; // value for __proto__ key when hasProto is true, undefined otherwise
- if (optional_object) {
- this.setMany(optional_object);
- }
- };
- // primitive methods that deals with data representation
- stringmap.prototype.has = function(key) {
- // The type-check of key in has, get, set and delete is important because otherwise an object
- // {toString: function() { return "__proto__"; }} can avoid the key === "__proto__" test.
- // The alternative to type-checking would be to force string conversion, i.e. key = String(key);
- if (typeof key !== "string") {
- throw new Error("StringMap expected string key");
- }
- return (key === "__proto__" ?
- this.hasProto :
- hasOwnProperty.call(this.obj, key));
- };
- stringmap.prototype.get = function(key) {
- if (typeof key !== "string") {
- throw new Error("StringMap expected string key");
- }
- return (key === "__proto__" ?
- this.proto :
- (hasOwnProperty.call(this.obj, key) ? this.obj[key] : undefined));
- };
- stringmap.prototype.set = function(key, value) {
- if (typeof key !== "string") {
- throw new Error("StringMap expected string key");
- }
- if (key === "__proto__") {
- this.hasProto = true;
- this.proto = value;
- } else {
- this.obj[key] = value;
- }
- };
- stringmap.prototype.remove = function(key) {
- if (typeof key !== "string") {
- throw new Error("StringMap expected string key");
- }
- var didExist = this.has(key);
- if (key === "__proto__") {
- this.hasProto = false;
- this.proto = undefined;
- } else {
- delete this.obj[key];
- }
- return didExist;
- };
- // alias remove to delete but beware:
- // sm.delete("key"); // OK in ES5 and later
- // sm['delete']("key"); // OK in all ES versions
- // sm.remove("key"); // OK in all ES versions
- stringmap.prototype['delete'] = stringmap.prototype.remove;
- stringmap.prototype.isEmpty = function() {
- for (var key in this.obj) {
- if (hasOwnProperty.call(this.obj, key)) {
- return false;
- }
- }
- return !this.hasProto;
- };
- stringmap.prototype.size = function() {
- var len = 0;
- for (var key in this.obj) {
- if (hasOwnProperty.call(this.obj, key)) {
- ++len;
- }
- }
- return (this.hasProto ? len + 1 : len);
- };
- stringmap.prototype.keys = function() {
- var keys = [];
- for (var key in this.obj) {
- if (hasOwnProperty.call(this.obj, key)) {
- keys.push(key);
- }
- }
- if (this.hasProto) {
- keys.push("__proto__");
- }
- return keys;
- };
- stringmap.prototype.values = function() {
- var values = [];
- for (var key in this.obj) {
- if (hasOwnProperty.call(this.obj, key)) {
- values.push(this.obj[key]);
- }
- }
- if (this.hasProto) {
- values.push(this.proto);
- }
- return values;
- };
- stringmap.prototype.items = function() {
- var items = [];
- for (var key in this.obj) {
- if (hasOwnProperty.call(this.obj, key)) {
- items.push([key, this.obj[key]]);
- }
- }
- if (this.hasProto) {
- items.push(["__proto__", this.proto]);
- }
- return items;
- };
- // methods that rely on the above primitives
- stringmap.prototype.setMany = function(object) {
- if (object === null || (typeof object !== "object" && typeof object !== "function")) {
- throw new Error("StringMap expected Object");
- }
- for (var key in object) {
- if (hasOwnProperty.call(object, key)) {
- this.set(key, object[key]);
- }
- }
- return this;
- };
- stringmap.prototype.merge = function(other) {
- var keys = other.keys();
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- this.set(key, other.get(key));
- }
- return this;
- };
- stringmap.prototype.map = function(fn) {
- var keys = this.keys();
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- keys[i] = fn(this.get(key), key); // re-use keys array for results
- }
- return keys;
- };
- stringmap.prototype.forEach = function(fn) {
- var keys = this.keys();
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- fn(this.get(key), key);
- }
- };
- stringmap.prototype.clone = function() {
- var other = stringmap();
- return other.merge(this);
- };
- stringmap.prototype.toString = function() {
- var self = this;
- return "{" + this.keys().map(function(key) {
- return JSON.stringify(key) + ":" + JSON.stringify(self.get(key));
- }).join(",") + "}";
- };
- return stringmap;
- })();
- if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
- module.exports = StringMap;
- }
- },{}],457:[function(require,module,exports){
- // stringset.js
- // MIT licensed, see LICENSE file
- // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
- var StringSet = (function() {
- "use strict";
- // to save us a few characters
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var create = (function() {
- function hasOwnEnumerableProps(obj) {
- for (var prop in obj) {
- if (hasOwnProperty.call(obj, prop)) {
- return true;
- }
- }
- return false;
- }
- // FF <= 3.6:
- // o = {}; o.hasOwnProperty("__proto__" or "__count__" or "__parent__") => true
- // o = {"__proto__": null}; Object.prototype.hasOwnProperty.call(o, "__proto__" or "__count__" or "__parent__") => false
- function hasOwnPollutedProps(obj) {
- return hasOwnProperty.call(obj, "__count__") || hasOwnProperty.call(obj, "__parent__");
- }
- var useObjectCreate = false;
- if (typeof Object.create === "function") {
- if (!hasOwnEnumerableProps(Object.create(null))) {
- useObjectCreate = true;
- }
- }
- if (useObjectCreate === false) {
- if (hasOwnEnumerableProps({})) {
- throw new Error("StringSet environment error 0, please file a bug at https://github.com/olov/stringset/issues");
- }
- }
- // no throw yet means we can create objects without own enumerable props (safe-guard against VMs and shims)
- var o = (useObjectCreate ? Object.create(null) : {});
- var useProtoClear = false;
- if (hasOwnPollutedProps(o)) {
- o.__proto__ = null;
- if (hasOwnEnumerableProps(o) || hasOwnPollutedProps(o)) {
- throw new Error("StringSet environment error 1, please file a bug at https://github.com/olov/stringset/issues");
- }
- useProtoClear = true;
- }
- // no throw yet means we can create objects without own polluted props (safe-guard against VMs and shims)
- return function() {
- var o = (useObjectCreate ? Object.create(null) : {});
- if (useProtoClear) {
- o.__proto__ = null;
- }
- return o;
- };
- })();
- // stringset ctor
- function stringset(optional_array) {
- // use with or without new
- if (!(this instanceof stringset)) {
- return new stringset(optional_array);
- }
- this.obj = create();
- this.hasProto = false; // false (no __proto__ item) or true (has __proto__ item)
- if (optional_array) {
- this.addMany(optional_array);
- }
- };
- // primitive methods that deals with data representation
- stringset.prototype.has = function(item) {
- // The type-check of item in has, get, set and delete is important because otherwise an object
- // {toString: function() { return "__proto__"; }} can avoid the item === "__proto__" test.
- // The alternative to type-checking would be to force string conversion, i.e. item = String(item);
- if (typeof item !== "string") {
- throw new Error("StringSet expected string item");
- }
- return (item === "__proto__" ?
- this.hasProto :
- hasOwnProperty.call(this.obj, item));
- };
- stringset.prototype.add = function(item) {
- if (typeof item !== "string") {
- throw new Error("StringSet expected string item");
- }
- if (item === "__proto__") {
- this.hasProto = true;
- } else {
- this.obj[item] = true;
- }
- };
- stringset.prototype.remove = function(item) {
- if (typeof item !== "string") {
- throw new Error("StringSet expected string item");
- }
- var didExist = this.has(item);
- if (item === "__proto__") {
- this.hasProto = false;
- } else {
- delete this.obj[item];
- }
- return didExist;
- };
- // alias remove to delete but beware:
- // ss.delete("key"); // OK in ES5 and later
- // ss['delete']("key"); // OK in all ES versions
- // ss.remove("key"); // OK in all ES versions
- stringset.prototype['delete'] = stringset.prototype.remove;
- stringset.prototype.isEmpty = function() {
- for (var item in this.obj) {
- if (hasOwnProperty.call(this.obj, item)) {
- return false;
- }
- }
- return !this.hasProto;
- };
- stringset.prototype.size = function() {
- var len = 0;
- for (var item in this.obj) {
- if (hasOwnProperty.call(this.obj, item)) {
- ++len;
- }
- }
- return (this.hasProto ? len + 1 : len);
- };
- stringset.prototype.items = function() {
- var items = [];
- for (var item in this.obj) {
- if (hasOwnProperty.call(this.obj, item)) {
- items.push(item);
- }
- }
- if (this.hasProto) {
- items.push("__proto__");
- }
- return items;
- };
- // methods that rely on the above primitives
- stringset.prototype.addMany = function(items) {
- if (!Array.isArray(items)) {
- throw new Error("StringSet expected array");
- }
- for (var i = 0; i < items.length; i++) {
- this.add(items[i]);
- }
- return this;
- };
- stringset.prototype.merge = function(other) {
- this.addMany(other.items());
- return this;
- };
- stringset.prototype.clone = function() {
- var other = stringset();
- return other.merge(this);
- };
- stringset.prototype.toString = function() {
- return "{" + this.items().map(JSON.stringify).join(",") + "}";
- };
- return stringset;
- })();
- if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
- module.exports = StringSet;
- }
- },{}],458:[function(require,module,exports){
- /*
- Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
- Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
- Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
- Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
- Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
- Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
- Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
- Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- (function (root, factory) {
- 'use strict';
- // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
- // Rhino, and plain browser loading.
- /* istanbul ignore next */
- if (typeof define === 'function' && define.amd) {
- define(['exports'], factory);
- } else if (typeof exports !== 'undefined') {
- factory(exports);
- } else {
- factory((root.esprima = {}));
- }
- }(this, function (exports) {
- 'use strict';
- var Token,
- TokenName,
- FnExprTokens,
- Syntax,
- PropertyKind,
- Messages,
- Regex,
- SyntaxTreeDelegate,
- XHTMLEntities,
- ClassPropertyType,
- source,
- strict,
- index,
- lineNumber,
- lineStart,
- length,
- delegate,
- lookahead,
- state,
- extra;
- Token = {
- BooleanLiteral: 1,
- EOF: 2,
- Identifier: 3,
- Keyword: 4,
- NullLiteral: 5,
- NumericLiteral: 6,
- Punctuator: 7,
- StringLiteral: 8,
- RegularExpression: 9,
- Template: 10,
- JSXIdentifier: 11,
- JSXText: 12
- };
- TokenName = {};
- TokenName[Token.BooleanLiteral] = 'Boolean';
- TokenName[Token.EOF] = '<end>';
- TokenName[Token.Identifier] = 'Identifier';
- TokenName[Token.Keyword] = 'Keyword';
- TokenName[Token.NullLiteral] = 'Null';
- TokenName[Token.NumericLiteral] = 'Numeric';
- TokenName[Token.Punctuator] = 'Punctuator';
- TokenName[Token.StringLiteral] = 'String';
- TokenName[Token.JSXIdentifier] = 'JSXIdentifier';
- TokenName[Token.JSXText] = 'JSXText';
- TokenName[Token.RegularExpression] = 'RegularExpression';
- // A function following one of those tokens is an expression.
- FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
- 'return', 'case', 'delete', 'throw', 'void',
- // assignment operators
- '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',
- '&=', '|=', '^=', ',',
- // binary/unary operators
- '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
- '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
- '<=', '<', '>', '!=', '!=='];
- Syntax = {
- AnyTypeAnnotation: 'AnyTypeAnnotation',
- ArrayExpression: 'ArrayExpression',
- ArrayPattern: 'ArrayPattern',
- ArrayTypeAnnotation: 'ArrayTypeAnnotation',
- ArrowFunctionExpression: 'ArrowFunctionExpression',
- AssignmentExpression: 'AssignmentExpression',
- BinaryExpression: 'BinaryExpression',
- BlockStatement: 'BlockStatement',
- BooleanTypeAnnotation: 'BooleanTypeAnnotation',
- BreakStatement: 'BreakStatement',
- CallExpression: 'CallExpression',
- CatchClause: 'CatchClause',
- ClassBody: 'ClassBody',
- ClassDeclaration: 'ClassDeclaration',
- ClassExpression: 'ClassExpression',
- ClassImplements: 'ClassImplements',
- ClassProperty: 'ClassProperty',
- ComprehensionBlock: 'ComprehensionBlock',
- ComprehensionExpression: 'ComprehensionExpression',
- ConditionalExpression: 'ConditionalExpression',
- ContinueStatement: 'ContinueStatement',
- DebuggerStatement: 'DebuggerStatement',
- DeclareClass: 'DeclareClass',
- DeclareFunction: 'DeclareFunction',
- DeclareModule: 'DeclareModule',
- DeclareVariable: 'DeclareVariable',
- DoWhileStatement: 'DoWhileStatement',
- EmptyStatement: 'EmptyStatement',
- ExportDeclaration: 'ExportDeclaration',
- ExportBatchSpecifier: 'ExportBatchSpecifier',
- ExportSpecifier: 'ExportSpecifier',
- ExpressionStatement: 'ExpressionStatement',
- ForInStatement: 'ForInStatement',
- ForOfStatement: 'ForOfStatement',
- ForStatement: 'ForStatement',
- FunctionDeclaration: 'FunctionDeclaration',
- FunctionExpression: 'FunctionExpression',
- FunctionTypeAnnotation: 'FunctionTypeAnnotation',
- FunctionTypeParam: 'FunctionTypeParam',
- GenericTypeAnnotation: 'GenericTypeAnnotation',
- Identifier: 'Identifier',
- IfStatement: 'IfStatement',
- ImportDeclaration: 'ImportDeclaration',
- ImportDefaultSpecifier: 'ImportDefaultSpecifier',
- ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
- ImportSpecifier: 'ImportSpecifier',
- InterfaceDeclaration: 'InterfaceDeclaration',
- InterfaceExtends: 'InterfaceExtends',
- IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
- LabeledStatement: 'LabeledStatement',
- Literal: 'Literal',
- LogicalExpression: 'LogicalExpression',
- MemberExpression: 'MemberExpression',
- MethodDefinition: 'MethodDefinition',
- ModuleSpecifier: 'ModuleSpecifier',
- NewExpression: 'NewExpression',
- NullableTypeAnnotation: 'NullableTypeAnnotation',
- NumberTypeAnnotation: 'NumberTypeAnnotation',
- ObjectExpression: 'ObjectExpression',
- ObjectPattern: 'ObjectPattern',
- ObjectTypeAnnotation: 'ObjectTypeAnnotation',
- ObjectTypeCallProperty: 'ObjectTypeCallProperty',
- ObjectTypeIndexer: 'ObjectTypeIndexer',
- ObjectTypeProperty: 'ObjectTypeProperty',
- Program: 'Program',
- Property: 'Property',
- QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
- ReturnStatement: 'ReturnStatement',
- SequenceExpression: 'SequenceExpression',
- SpreadElement: 'SpreadElement',
- SpreadProperty: 'SpreadProperty',
- StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
- StringTypeAnnotation: 'StringTypeAnnotation',
- SwitchCase: 'SwitchCase',
- SwitchStatement: 'SwitchStatement',
- TaggedTemplateExpression: 'TaggedTemplateExpression',
- TemplateElement: 'TemplateElement',
- TemplateLiteral: 'TemplateLiteral',
- ThisExpression: 'ThisExpression',
- ThrowStatement: 'ThrowStatement',
- TupleTypeAnnotation: 'TupleTypeAnnotation',
- TryStatement: 'TryStatement',
- TypeAlias: 'TypeAlias',
- TypeAnnotation: 'TypeAnnotation',
- TypeCastExpression: 'TypeCastExpression',
- TypeofTypeAnnotation: 'TypeofTypeAnnotation',
- TypeParameterDeclaration: 'TypeParameterDeclaration',
- TypeParameterInstantiation: 'TypeParameterInstantiation',
- UnaryExpression: 'UnaryExpression',
- UnionTypeAnnotation: 'UnionTypeAnnotation',
- UpdateExpression: 'UpdateExpression',
- VariableDeclaration: 'VariableDeclaration',
- VariableDeclarator: 'VariableDeclarator',
- VoidTypeAnnotation: 'VoidTypeAnnotation',
- WhileStatement: 'WhileStatement',
- WithStatement: 'WithStatement',
- JSXIdentifier: 'JSXIdentifier',
- JSXNamespacedName: 'JSXNamespacedName',
- JSXMemberExpression: 'JSXMemberExpression',
- JSXEmptyExpression: 'JSXEmptyExpression',
- JSXExpressionContainer: 'JSXExpressionContainer',
- JSXElement: 'JSXElement',
- JSXClosingElement: 'JSXClosingElement',
- JSXOpeningElement: 'JSXOpeningElement',
- JSXAttribute: 'JSXAttribute',
- JSXSpreadAttribute: 'JSXSpreadAttribute',
- JSXText: 'JSXText',
- YieldExpression: 'YieldExpression',
- AwaitExpression: 'AwaitExpression'
- };
- PropertyKind = {
- Data: 1,
- Get: 2,
- Set: 4
- };
- ClassPropertyType = {
- 'static': 'static',
- prototype: 'prototype'
- };
- // Error messages should be identical to V8.
- Messages = {
- UnexpectedToken: 'Unexpected token %0',
- UnexpectedNumber: 'Unexpected number',
- UnexpectedString: 'Unexpected string',
- UnexpectedIdentifier: 'Unexpected identifier',
- UnexpectedReserved: 'Unexpected reserved word',
- UnexpectedTemplate: 'Unexpected quasi %0',
- UnexpectedEOS: 'Unexpected end of input',
- NewlineAfterThrow: 'Illegal newline after throw',
- InvalidRegExp: 'Invalid regular expression',
- UnterminatedRegExp: 'Invalid regular expression: missing /',
- InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
- InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
- InvalidLHSInForIn: 'Invalid left-hand side in for-in',
- MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
- NoCatchOrFinally: 'Missing catch or finally after try',
- UnknownLabel: 'Undefined label \'%0\'',
- Redeclaration: '%0 \'%1\' has already been declared',
- IllegalContinue: 'Illegal continue statement',
- IllegalBreak: 'Illegal break statement',
- IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
- IllegalClassConstructorProperty: 'Illegal constructor property in class definition',
- IllegalReturn: 'Illegal return statement',
- IllegalSpread: 'Illegal spread element',
- StrictModeWith: 'Strict mode code may not include a with statement',
- StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
- StrictVarName: 'Variable name may not be eval or arguments in strict mode',
- StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
- StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
- ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
- DefaultRestParameter: 'Rest parameter can not have a default value',
- ElementAfterSpreadElement: 'Spread must be the final element of an element list',
- PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
- ObjectPatternAsRestParameter: 'Invalid rest parameter',
- ObjectPatternAsSpread: 'Invalid spread argument',
- StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
- StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
- StrictDelete: 'Delete of an unqualified identifier in strict mode.',
- StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
- AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
- AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
- StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
- StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
- StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
- StrictReservedWord: 'Use of future reserved word in strict mode',
- MissingFromClause: 'Missing from clause',
- NoAsAfterImportNamespace: 'Missing as after import *',
- InvalidModuleSpecifier: 'Invalid module specifier',
- IllegalImportDeclaration: 'Illegal import declaration',
- IllegalExportDeclaration: 'Illegal export declaration',
- NoUninitializedConst: 'Const must be initialized',
- ComprehensionRequiresBlock: 'Comprehension must have at least one block',
- ComprehensionError: 'Comprehension Error',
- EachNotAllowed: 'Each is not supported',
- InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text',
- ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0',
- AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag',
- ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
- 'you are trying to write a function type, but you ended up ' +
- 'writing a grouped type followed by an =>, which is a syntax ' +
- 'error. Remember, function type parameters are named so function ' +
- 'types look like (name1: type1, name2: type2) => returnType. You ' +
- 'probably wrote (type1) => returnType'
- };
- // See also tools/generate-unicode-regex.py.
- Regex = {
- NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
- NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
- LeadingZeros: new RegExp('^0+(?!$)')
- };
- // Ensure the condition is true, otherwise throw an error.
- // This is only to have a better contract semantic, i.e. another safety net
- // to catch a logic error. The condition shall be fulfilled in normal case.
- // Do NOT use this to enforce a certain condition on any user input.
- function assert(condition, message) {
- /* istanbul ignore if */
- if (!condition) {
- throw new Error('ASSERT: ' + message);
- }
- }
- function StringMap() {
- this.$data = {};
- }
- StringMap.prototype.get = function (key) {
- key = '$' + key;
- return this.$data[key];
- };
- StringMap.prototype.set = function (key, value) {
- key = '$' + key;
- this.$data[key] = value;
- return this;
- };
- StringMap.prototype.has = function (key) {
- key = '$' + key;
- return Object.prototype.hasOwnProperty.call(this.$data, key);
- };
- StringMap.prototype.delete = function (key) {
- key = '$' + key;
- return delete this.$data[key];
- };
- function isDecimalDigit(ch) {
- return (ch >= 48 && ch <= 57); // 0..9
- }
- function isHexDigit(ch) {
- return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
- }
- function isOctalDigit(ch) {
- return '01234567'.indexOf(ch) >= 0;
- }
- // 7.2 White Space
- function isWhiteSpace(ch) {
- return (ch === 32) || // space
- (ch === 9) || // tab
- (ch === 0xB) ||
- (ch === 0xC) ||
- (ch === 0xA0) ||
- (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
- }
- // 7.3 Line Terminators
- function isLineTerminator(ch) {
- return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
- }
- // 7.6 Identifier Names and Identifiers
- function isIdentifierStart(ch) {
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
- (ch >= 65 && ch <= 90) || // A..Z
- (ch >= 97 && ch <= 122) || // a..z
- (ch === 92) || // \ (backslash)
- ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));
- }
- function isIdentifierPart(ch) {
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
- (ch >= 65 && ch <= 90) || // A..Z
- (ch >= 97 && ch <= 122) || // a..z
- (ch >= 48 && ch <= 57) || // 0..9
- (ch === 92) || // \ (backslash)
- ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
- }
- // 7.6.1.2 Future Reserved Words
- function isFutureReservedWord(id) {
- switch (id) {
- case 'class':
- case 'enum':
- case 'export':
- case 'extends':
- case 'import':
- case 'super':
- return true;
- default:
- return false;
- }
- }
- function isStrictModeReservedWord(id) {
- switch (id) {
- case 'implements':
- case 'interface':
- case 'package':
- case 'private':
- case 'protected':
- case 'public':
- case 'static':
- case 'yield':
- case 'let':
- return true;
- default:
- return false;
- }
- }
- function isRestrictedWord(id) {
- return id === 'eval' || id === 'arguments';
- }
- // 7.6.1.1 Keywords
- function isKeyword(id) {
- if (strict && isStrictModeReservedWord(id)) {
- return true;
- }
- // 'const' is specialized as Keyword in V8.
- // 'yield' is only treated as a keyword in strict mode.
- // 'let' is for compatiblity with SpiderMonkey and ES.next.
- // Some others are from future reserved words.
- switch (id.length) {
- case 2:
- return (id === 'if') || (id === 'in') || (id === 'do');
- case 3:
- return (id === 'var') || (id === 'for') || (id === 'new') ||
- (id === 'try') || (id === 'let');
- case 4:
- return (id === 'this') || (id === 'else') || (id === 'case') ||
- (id === 'void') || (id === 'with') || (id === 'enum');
- case 5:
- return (id === 'while') || (id === 'break') || (id === 'catch') ||
- (id === 'throw') || (id === 'const') ||
- (id === 'class') || (id === 'super');
- case 6:
- return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
- (id === 'switch') || (id === 'export') || (id === 'import');
- case 7:
- return (id === 'default') || (id === 'finally') || (id === 'extends');
- case 8:
- return (id === 'function') || (id === 'continue') || (id === 'debugger');
- case 10:
- return (id === 'instanceof');
- default:
- return false;
- }
- }
- // 7.4 Comments
- function addComment(type, value, start, end, loc) {
- var comment;
- assert(typeof start === 'number', 'Comment must have valid position');
- // Because the way the actual token is scanned, often the comments
- // (if any) are skipped twice during the lexical analysis.
- // Thus, we need to skip adding a comment if the comment array already
- // handled it.
- if (state.lastCommentStart >= start) {
- return;
- }
- state.lastCommentStart = start;
- comment = {
- type: type,
- value: value
- };
- if (extra.range) {
- comment.range = [start, end];
- }
- if (extra.loc) {
- comment.loc = loc;
- }
- extra.comments.push(comment);
- if (extra.attachComment) {
- extra.leadingComments.push(comment);
- extra.trailingComments.push(comment);
- }
- }
- function skipSingleLineComment() {
- var start, loc, ch, comment;
- start = index - 2;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart - 2
- }
- };
- while (index < length) {
- ch = source.charCodeAt(index);
- ++index;
- if (isLineTerminator(ch)) {
- if (extra.comments) {
- comment = source.slice(start + 2, index - 1);
- loc.end = {
- line: lineNumber,
- column: index - lineStart - 1
- };
- addComment('Line', comment, start, index - 1, loc);
- }
- if (ch === 13 && source.charCodeAt(index) === 10) {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- return;
- }
- }
- if (extra.comments) {
- comment = source.slice(start + 2, index);
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- addComment('Line', comment, start, index, loc);
- }
- }
- function skipMultiLineComment() {
- var start, loc, ch, comment;
- if (extra.comments) {
- start = index - 2;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart - 2
- }
- };
- }
- while (index < length) {
- ch = source.charCodeAt(index);
- if (isLineTerminator(ch)) {
- if (ch === 13 && source.charCodeAt(index + 1) === 10) {
- ++index;
- }
- ++lineNumber;
- ++index;
- lineStart = index;
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- } else if (ch === 42) {
- // Block comment ends with '*/' (char #42, char #47).
- if (source.charCodeAt(index + 1) === 47) {
- ++index;
- ++index;
- if (extra.comments) {
- comment = source.slice(start + 2, index - 2);
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- addComment('Block', comment, start, index, loc);
- }
- return;
- }
- ++index;
- } else {
- ++index;
- }
- }
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- function skipComment() {
- var ch;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (isWhiteSpace(ch)) {
- ++index;
- } else if (isLineTerminator(ch)) {
- ++index;
- if (ch === 13 && source.charCodeAt(index) === 10) {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- } else if (ch === 47) { // 47 is '/'
- ch = source.charCodeAt(index + 1);
- if (ch === 47) {
- ++index;
- ++index;
- skipSingleLineComment();
- } else if (ch === 42) { // 42 is '*'
- ++index;
- ++index;
- skipMultiLineComment();
- } else {
- break;
- }
- } else {
- break;
- }
- }
- }
- function scanHexEscape(prefix) {
- var i, len, ch, code = 0;
- len = (prefix === 'u') ? 4 : 2;
- for (i = 0; i < len; ++i) {
- if (index < length && isHexDigit(source[index])) {
- ch = source[index++];
- code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
- } else {
- return '';
- }
- }
- return String.fromCharCode(code);
- }
- function scanUnicodeCodePointEscape() {
- var ch, code, cu1, cu2;
- ch = source[index];
- code = 0;
- // At least, one hex digit is required.
- if (ch === '}') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- while (index < length) {
- ch = source[index++];
- if (!isHexDigit(ch)) {
- break;
- }
- code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
- }
- if (code > 0x10FFFF || ch !== '}') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- // UTF-16 Encoding
- if (code <= 0xFFFF) {
- return String.fromCharCode(code);
- }
- cu1 = ((code - 0x10000) >> 10) + 0xD800;
- cu2 = ((code - 0x10000) & 1023) + 0xDC00;
- return String.fromCharCode(cu1, cu2);
- }
- function getEscapedIdentifier() {
- var ch, id;
- ch = source.charCodeAt(index++);
- id = String.fromCharCode(ch);
- // '\u' (char #92, char #117) denotes an escaped character.
- if (ch === 92) {
- if (source.charCodeAt(index) !== 117) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- ch = scanHexEscape('u');
- if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- id = ch;
- }
- while (index < length) {
- ch = source.charCodeAt(index);
- if (!isIdentifierPart(ch)) {
- break;
- }
- ++index;
- id += String.fromCharCode(ch);
- // '\u' (char #92, char #117) denotes an escaped character.
- if (ch === 92) {
- id = id.substr(0, id.length - 1);
- if (source.charCodeAt(index) !== 117) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- ch = scanHexEscape('u');
- if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- id += ch;
- }
- }
- return id;
- }
- function getIdentifier() {
- var start, ch;
- start = index++;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (ch === 92) {
- // Blackslash (char #92) marks Unicode escape sequence.
- index = start;
- return getEscapedIdentifier();
- }
- if (isIdentifierPart(ch)) {
- ++index;
- } else {
- break;
- }
- }
- return source.slice(start, index);
- }
- function scanIdentifier() {
- var start, id, type;
- start = index;
- // Backslash (char #92) starts an escaped character.
- id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier();
- // There is no keyword or literal with only one character.
- // Thus, it must be an identifier.
- if (id.length === 1) {
- type = Token.Identifier;
- } else if (isKeyword(id)) {
- type = Token.Keyword;
- } else if (id === 'null') {
- type = Token.NullLiteral;
- } else if (id === 'true' || id === 'false') {
- type = Token.BooleanLiteral;
- } else {
- type = Token.Identifier;
- }
- return {
- type: type,
- value: id,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // 7.7 Punctuators
- function scanPunctuator() {
- var start = index,
- code = source.charCodeAt(index),
- code2,
- ch1 = source[index],
- ch2,
- ch3,
- ch4;
- if (state.inJSXTag || state.inJSXChild) {
- // Don't need to check for '{' and '}' as it's already handled
- // correctly by default.
- switch (code) {
- case 60: // <
- case 62: // >
- ++index;
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- }
- switch (code) {
- // Check for most common single-character punctuators.
- case 40: // ( open bracket
- case 41: // ) close bracket
- case 59: // ; semicolon
- case 44: // , comma
- case 123: // { open curly brace
- case 125: // } close curly brace
- case 91: // [
- case 93: // ]
- case 58: // :
- case 63: // ?
- case 126: // ~
- ++index;
- if (extra.tokenize) {
- if (code === 40) {
- extra.openParenToken = extra.tokens.length;
- } else if (code === 123) {
- extra.openCurlyToken = extra.tokens.length;
- }
- }
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- default:
- code2 = source.charCodeAt(index + 1);
- // '=' (char #61) marks an assignment or comparison operator.
- if (code2 === 61) {
- switch (code) {
- case 37: // %
- case 38: // &
- case 42: // *:
- case 43: // +
- case 45: // -
- case 47: // /
- case 60: // <
- case 62: // >
- case 94: // ^
- case 124: // |
- index += 2;
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code) + String.fromCharCode(code2),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- case 33: // !
- case 61: // =
- index += 2;
- // !== and ===
- if (source.charCodeAt(index) === 61) {
- ++index;
- }
- return {
- type: Token.Punctuator,
- value: source.slice(start, index),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- default:
- break;
- }
- }
- break;
- }
- // Peek more characters.
- ch2 = source[index + 1];
- ch3 = source[index + 2];
- ch4 = source[index + 3];
- // 4-character punctuator: >>>=
- if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
- if (ch4 === '=') {
- index += 4;
- return {
- type: Token.Punctuator,
- value: '>>>=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- }
- // 3-character punctuators: === !== >>> <<= >>=
- if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '>>>',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '<' && ch2 === '<' && ch3 === '=') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '<<=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '>' && ch2 === '>' && ch3 === '=') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '>>=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '.' && ch2 === '.' && ch3 === '.') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '...',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // Other 2-character punctuators: ++ -- << >> && ||
- // Don't match these tokens if we're in a type, since they never can
- // occur and can mess up types like Map<string, Array<string>>
- if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
- index += 2;
- return {
- type: Token.Punctuator,
- value: ch1 + ch2,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '=' && ch2 === '>') {
- index += 2;
- return {
- type: Token.Punctuator,
- value: '=>',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
- ++index;
- return {
- type: Token.Punctuator,
- value: ch1,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '.') {
- ++index;
- return {
- type: Token.Punctuator,
- value: ch1,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- // 7.8.3 Numeric Literals
- function scanHexLiteral(start) {
- var number = '';
- while (index < length) {
- if (!isHexDigit(source[index])) {
- break;
- }
- number += source[index++];
- }
- if (number.length === 0) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (isIdentifierStart(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt('0x' + number, 16),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanBinaryLiteral(start) {
- var ch, number;
- number = '';
- while (index < length) {
- ch = source[index];
- if (ch !== '0' && ch !== '1') {
- break;
- }
- number += source[index++];
- }
- if (number.length === 0) {
- // only 0b or 0B
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (index < length) {
- ch = source.charCodeAt(index);
- /* istanbul ignore else */
- if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt(number, 2),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanOctalLiteral(prefix, start) {
- var number, octal;
- if (isOctalDigit(prefix)) {
- octal = true;
- number = '0' + source[index++];
- } else {
- octal = false;
- ++index;
- number = '';
- }
- while (index < length) {
- if (!isOctalDigit(source[index])) {
- break;
- }
- number += source[index++];
- }
- if (!octal && number.length === 0) {
- // only 0o or 0O
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt(number, 8),
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanNumericLiteral() {
- var number, start, ch;
- ch = source[index];
- assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
- 'Numeric literal must start with a decimal digit or a decimal point');
- start = index;
- number = '';
- if (ch !== '.') {
- number = source[index++];
- ch = source[index];
- // Hex number starts with '0x'.
- // Octal number starts with '0'.
- // Octal number in ES6 starts with '0o'.
- // Binary number in ES6 starts with '0b'.
- if (number === '0') {
- if (ch === 'x' || ch === 'X') {
- ++index;
- return scanHexLiteral(start);
- }
- if (ch === 'b' || ch === 'B') {
- ++index;
- return scanBinaryLiteral(start);
- }
- if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
- return scanOctalLiteral(ch, start);
- }
- // decimal number starts with '0' such as '09' is illegal.
- if (ch && isDecimalDigit(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- ch = source[index];
- }
- if (ch === '.') {
- number += source[index++];
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- ch = source[index];
- }
- if (ch === 'e' || ch === 'E') {
- number += source[index++];
- ch = source[index];
- if (ch === '+' || ch === '-') {
- number += source[index++];
- }
- if (isDecimalDigit(source.charCodeAt(index))) {
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- } else {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- if (isIdentifierStart(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseFloat(number),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // 7.8.4 String Literals
- function scanStringLiteral() {
- var str = '', quote, start, ch, code, unescaped, restore, octal = false;
- quote = source[index];
- assert((quote === '\'' || quote === '"'),
- 'String literal must starts with a quote');
- start = index;
- ++index;
- while (index < length) {
- ch = source[index++];
- if (ch === quote) {
- quote = '';
- break;
- } else if (ch === '\\') {
- ch = source[index++];
- if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
- switch (ch) {
- case 'n':
- str += '\n';
- break;
- case 'r':
- str += '\r';
- break;
- case 't':
- str += '\t';
- break;
- case 'u':
- case 'x':
- if (source[index] === '{') {
- ++index;
- str += scanUnicodeCodePointEscape();
- } else {
- restore = index;
- unescaped = scanHexEscape(ch);
- if (unescaped) {
- str += unescaped;
- } else {
- index = restore;
- str += ch;
- }
- }
- break;
- case 'b':
- str += '\b';
- break;
- case 'f':
- str += '\f';
- break;
- case 'v':
- str += '\x0B';
- break;
- default:
- if (isOctalDigit(ch)) {
- code = '01234567'.indexOf(ch);
- // \0 is not octal escape sequence
- if (code !== 0) {
- octal = true;
- }
- /* istanbul ignore else */
- if (index < length && isOctalDigit(source[index])) {
- octal = true;
- code = code * 8 + '01234567'.indexOf(source[index++]);
- // 3 digits are only allowed when string starts
- // with 0, 1, 2, 3
- if ('0123'.indexOf(ch) >= 0 &&
- index < length &&
- isOctalDigit(source[index])) {
- code = code * 8 + '01234567'.indexOf(source[index++]);
- }
- }
- str += String.fromCharCode(code);
- } else {
- str += ch;
- }
- break;
- }
- } else {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- }
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- break;
- } else {
- str += ch;
- }
- }
- if (quote !== '') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.StringLiteral,
- value: str,
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanTemplate() {
- var cooked = '', ch, start, terminated, tail, restore, unescaped, code, octal;
- terminated = false;
- tail = false;
- start = index;
- ++index;
- while (index < length) {
- ch = source[index++];
- if (ch === '`') {
- tail = true;
- terminated = true;
- break;
- } else if (ch === '$') {
- if (source[index] === '{') {
- ++index;
- terminated = true;
- break;
- }
- cooked += ch;
- } else if (ch === '\\') {
- ch = source[index++];
- if (!isLineTerminator(ch.charCodeAt(0))) {
- switch (ch) {
- case 'n':
- cooked += '\n';
- break;
- case 'r':
- cooked += '\r';
- break;
- case 't':
- cooked += '\t';
- break;
- case 'u':
- case 'x':
- if (source[index] === '{') {
- ++index;
- cooked += scanUnicodeCodePointEscape();
- } else {
- restore = index;
- unescaped = scanHexEscape(ch);
- if (unescaped) {
- cooked += unescaped;
- } else {
- index = restore;
- cooked += ch;
- }
- }
- break;
- case 'b':
- cooked += '\b';
- break;
- case 'f':
- cooked += '\f';
- break;
- case 'v':
- cooked += '\v';
- break;
- default:
- if (isOctalDigit(ch)) {
- code = '01234567'.indexOf(ch);
- // \0 is not octal escape sequence
- if (code !== 0) {
- octal = true;
- }
- /* istanbul ignore else */
- if (index < length && isOctalDigit(source[index])) {
- octal = true;
- code = code * 8 + '01234567'.indexOf(source[index++]);
- // 3 digits are only allowed when string starts
- // with 0, 1, 2, 3
- if ('0123'.indexOf(ch) >= 0 &&
- index < length &&
- isOctalDigit(source[index])) {
- code = code * 8 + '01234567'.indexOf(source[index++]);
- }
- }
- cooked += String.fromCharCode(code);
- } else {
- cooked += ch;
- }
- break;
- }
- } else {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- }
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- cooked += '\n';
- } else {
- cooked += ch;
- }
- }
- if (!terminated) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.Template,
- value: {
- cooked: cooked,
- raw: source.slice(start + 1, index - ((tail) ? 1 : 2))
- },
- tail: tail,
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanTemplateElement(option) {
- var startsWith, template;
- lookahead = null;
- skipComment();
- startsWith = (option.head) ? '`' : '}';
- if (source[index] !== startsWith) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- template = scanTemplate();
- peek();
- return template;
- }
- function testRegExp(pattern, flags) {
- var tmp = pattern,
- value;
- if (flags.indexOf('u') >= 0) {
- // Replace each astral symbol and every Unicode code point
- // escape sequence with a single ASCII symbol to avoid throwing on
- // regular expressions that are only valid in combination with the
- // `/u` flag.
- // Note: replacing with the ASCII symbol `x` might cause false
- // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
- // perfectly valid pattern that is equivalent to `[a-b]`, but it
- // would be replaced by `[x-b]` which throws an error.
- tmp = tmp
- .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
- if (parseInt($1, 16) <= 0x10FFFF) {
- return 'x';
- }
- throwError({}, Messages.InvalidRegExp);
- })
- .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
- }
- // First, detect invalid regular expressions.
- try {
- value = new RegExp(tmp);
- } catch (e) {
- throwError({}, Messages.InvalidRegExp);
- }
- // Return a regular expression object for this pattern-flag pair, or
- // `null` in case the current environment doesn't support the flags it
- // uses.
- try {
- return new RegExp(pattern, flags);
- } catch (exception) {
- return null;
- }
- }
- function scanRegExpBody() {
- var ch, str, classMarker, terminated, body;
- ch = source[index];
- assert(ch === '/', 'Regular expression literal must start with a slash');
- str = source[index++];
- classMarker = false;
- terminated = false;
- while (index < length) {
- ch = source[index++];
- str += ch;
- if (ch === '\\') {
- ch = source[index++];
- // ECMA-262 7.8.5
- if (isLineTerminator(ch.charCodeAt(0))) {
- throwError({}, Messages.UnterminatedRegExp);
- }
- str += ch;
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- throwError({}, Messages.UnterminatedRegExp);
- } else if (classMarker) {
- if (ch === ']') {
- classMarker = false;
- }
- } else {
- if (ch === '/') {
- terminated = true;
- break;
- } else if (ch === '[') {
- classMarker = true;
- }
- }
- }
- if (!terminated) {
- throwError({}, Messages.UnterminatedRegExp);
- }
- // Exclude leading and trailing slash.
- body = str.substr(1, str.length - 2);
- return {
- value: body,
- literal: str
- };
- }
- function scanRegExpFlags() {
- var ch, str, flags, restore;
- str = '';
- flags = '';
- while (index < length) {
- ch = source[index];
- if (!isIdentifierPart(ch.charCodeAt(0))) {
- break;
- }
- ++index;
- if (ch === '\\' && index < length) {
- ch = source[index];
- if (ch === 'u') {
- ++index;
- restore = index;
- ch = scanHexEscape('u');
- if (ch) {
- flags += ch;
- for (str += '\\u'; restore < index; ++restore) {
- str += source[restore];
- }
- } else {
- index = restore;
- flags += 'u';
- str += '\\u';
- }
- throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
- } else {
- str += '\\';
- throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- } else {
- flags += ch;
- str += ch;
- }
- }
- return {
- value: flags,
- literal: str
- };
- }
- function scanRegExp() {
- var start, body, flags, value;
- lookahead = null;
- skipComment();
- start = index;
- body = scanRegExpBody();
- flags = scanRegExpFlags();
- value = testRegExp(body.value, flags.value);
- if (extra.tokenize) {
- return {
- type: Token.RegularExpression,
- value: value,
- regex: {
- pattern: body.value,
- flags: flags.value
- },
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- return {
- literal: body.literal + flags.literal,
- value: value,
- regex: {
- pattern: body.value,
- flags: flags.value
- },
- range: [start, index]
- };
- }
- function isIdentifierName(token) {
- return token.type === Token.Identifier ||
- token.type === Token.Keyword ||
- token.type === Token.BooleanLiteral ||
- token.type === Token.NullLiteral;
- }
- function advanceSlash() {
- var prevToken,
- checkToken;
- // Using the following algorithm:
- // https://github.com/mozilla/sweet.js/wiki/design
- prevToken = extra.tokens[extra.tokens.length - 1];
- if (!prevToken) {
- // Nothing before that: it cannot be a division.
- return scanRegExp();
- }
- if (prevToken.type === 'Punctuator') {
- if (prevToken.value === ')') {
- checkToken = extra.tokens[extra.openParenToken - 1];
- if (checkToken &&
- checkToken.type === 'Keyword' &&
- (checkToken.value === 'if' ||
- checkToken.value === 'while' ||
- checkToken.value === 'for' ||
- checkToken.value === 'with')) {
- return scanRegExp();
- }
- return scanPunctuator();
- }
- if (prevToken.value === '}') {
- // Dividing a function by anything makes little sense,
- // but we have to check for that.
- if (extra.tokens[extra.openCurlyToken - 3] &&
- extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {
- // Anonymous function.
- checkToken = extra.tokens[extra.openCurlyToken - 4];
- if (!checkToken) {
- return scanPunctuator();
- }
- } else if (extra.tokens[extra.openCurlyToken - 4] &&
- extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {
- // Named function.
- checkToken = extra.tokens[extra.openCurlyToken - 5];
- if (!checkToken) {
- return scanRegExp();
- }
- } else {
- return scanPunctuator();
- }
- // checkToken determines whether the function is
- // a declaration or an expression.
- if (FnExprTokens.indexOf(checkToken.value) >= 0) {
- // It is an expression.
- return scanPunctuator();
- }
- // It is a declaration.
- return scanRegExp();
- }
- return scanRegExp();
- }
- if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
- return scanRegExp();
- }
- return scanPunctuator();
- }
- function advance() {
- var ch;
- if (!state.inJSXChild) {
- skipComment();
- }
- if (index >= length) {
- return {
- type: Token.EOF,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [index, index]
- };
- }
- if (state.inJSXChild) {
- return advanceJSXChild();
- }
- ch = source.charCodeAt(index);
- // Very common: ( and ) and ;
- if (ch === 40 || ch === 41 || ch === 58) {
- return scanPunctuator();
- }
- // String literal starts with single quote (#39) or double quote (#34).
- if (ch === 39 || ch === 34) {
- if (state.inJSXTag) {
- return scanJSXStringLiteral();
- }
- return scanStringLiteral();
- }
- if (state.inJSXTag && isJSXIdentifierStart(ch)) {
- return scanJSXIdentifier();
- }
- if (ch === 96) {
- return scanTemplate();
- }
- if (isIdentifierStart(ch)) {
- return scanIdentifier();
- }
- // Dot (.) char #46 can also start a floating-point number, hence the need
- // to check the next character.
- if (ch === 46) {
- if (isDecimalDigit(source.charCodeAt(index + 1))) {
- return scanNumericLiteral();
- }
- return scanPunctuator();
- }
- if (isDecimalDigit(ch)) {
- return scanNumericLiteral();
- }
- // Slash (/) char #47 can also start a regex.
- if (extra.tokenize && ch === 47) {
- return advanceSlash();
- }
- return scanPunctuator();
- }
- function lex() {
- var token;
- token = lookahead;
- index = token.range[1];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- lookahead = advance();
- index = token.range[1];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- return token;
- }
- function peek() {
- var pos, line, start;
- pos = index;
- line = lineNumber;
- start = lineStart;
- lookahead = advance();
- index = pos;
- lineNumber = line;
- lineStart = start;
- }
- function lookahead2() {
- var adv, pos, line, start, result;
- // If we are collecting the tokens, don't grab the next one yet.
- /* istanbul ignore next */
- adv = (typeof extra.advance === 'function') ? extra.advance : advance;
- pos = index;
- line = lineNumber;
- start = lineStart;
- // Scan for the next immediate token.
- /* istanbul ignore if */
- if (lookahead === null) {
- lookahead = adv();
- }
- index = lookahead.range[1];
- lineNumber = lookahead.lineNumber;
- lineStart = lookahead.lineStart;
- // Grab the token right after.
- result = adv();
- index = pos;
- lineNumber = line;
- lineStart = start;
- return result;
- }
- function rewind(token) {
- index = token.range[0];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- lookahead = token;
- }
- function markerCreate() {
- if (!extra.loc && !extra.range) {
- return undefined;
- }
- skipComment();
- return {offset: index, line: lineNumber, col: index - lineStart};
- }
- function markerCreatePreserveWhitespace() {
- if (!extra.loc && !extra.range) {
- return undefined;
- }
- return {offset: index, line: lineNumber, col: index - lineStart};
- }
- function processComment(node) {
- var lastChild,
- trailingComments,
- bottomRight = extra.bottomRightStack,
- last = bottomRight[bottomRight.length - 1];
- if (node.type === Syntax.Program) {
- /* istanbul ignore else */
- if (node.body.length > 0) {
- return;
- }
- }
- if (extra.trailingComments.length > 0) {
- if (extra.trailingComments[0].range[0] >= node.range[1]) {
- trailingComments = extra.trailingComments;
- extra.trailingComments = [];
- } else {
- extra.trailingComments.length = 0;
- }
- } else {
- if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
- trailingComments = last.trailingComments;
- delete last.trailingComments;
- }
- }
- // Eating the stack.
- if (last) {
- while (last && last.range[0] >= node.range[0]) {
- lastChild = last;
- last = bottomRight.pop();
- }
- }
- if (lastChild) {
- if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
- node.leadingComments = lastChild.leadingComments;
- delete lastChild.leadingComments;
- }
- } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
- node.leadingComments = extra.leadingComments;
- extra.leadingComments = [];
- }
- if (trailingComments) {
- node.trailingComments = trailingComments;
- }
- bottomRight.push(node);
- }
- function markerApply(marker, node) {
- if (extra.range) {
- node.range = [marker.offset, index];
- }
- if (extra.loc) {
- node.loc = {
- start: {
- line: marker.line,
- column: marker.col
- },
- end: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- node = delegate.postProcess(node);
- }
- if (extra.attachComment) {
- processComment(node);
- }
- return node;
- }
- SyntaxTreeDelegate = {
- name: 'SyntaxTree',
- postProcess: function (node) {
- return node;
- },
- createArrayExpression: function (elements) {
- return {
- type: Syntax.ArrayExpression,
- elements: elements
- };
- },
- createAssignmentExpression: function (operator, left, right) {
- return {
- type: Syntax.AssignmentExpression,
- operator: operator,
- left: left,
- right: right
- };
- },
- createBinaryExpression: function (operator, left, right) {
- var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :
- Syntax.BinaryExpression;
- return {
- type: type,
- operator: operator,
- left: left,
- right: right
- };
- },
- createBlockStatement: function (body) {
- return {
- type: Syntax.BlockStatement,
- body: body
- };
- },
- createBreakStatement: function (label) {
- return {
- type: Syntax.BreakStatement,
- label: label
- };
- },
- createCallExpression: function (callee, args) {
- return {
- type: Syntax.CallExpression,
- callee: callee,
- 'arguments': args
- };
- },
- createCatchClause: function (param, body) {
- return {
- type: Syntax.CatchClause,
- param: param,
- body: body
- };
- },
- createConditionalExpression: function (test, consequent, alternate) {
- return {
- type: Syntax.ConditionalExpression,
- test: test,
- consequent: consequent,
- alternate: alternate
- };
- },
- createContinueStatement: function (label) {
- return {
- type: Syntax.ContinueStatement,
- label: label
- };
- },
- createDebuggerStatement: function () {
- return {
- type: Syntax.DebuggerStatement
- };
- },
- createDoWhileStatement: function (body, test) {
- return {
- type: Syntax.DoWhileStatement,
- body: body,
- test: test
- };
- },
- createEmptyStatement: function () {
- return {
- type: Syntax.EmptyStatement
- };
- },
- createExpressionStatement: function (expression) {
- return {
- type: Syntax.ExpressionStatement,
- expression: expression
- };
- },
- createForStatement: function (init, test, update, body) {
- return {
- type: Syntax.ForStatement,
- init: init,
- test: test,
- update: update,
- body: body
- };
- },
- createForInStatement: function (left, right, body) {
- return {
- type: Syntax.ForInStatement,
- left: left,
- right: right,
- body: body,
- each: false
- };
- },
- createForOfStatement: function (left, right, body) {
- return {
- type: Syntax.ForOfStatement,
- left: left,
- right: right,
- body: body
- };
- },
- createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
- isAsync, returnType, typeParameters) {
- var funDecl = {
- type: Syntax.FunctionDeclaration,
- id: id,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: generator,
- expression: expression,
- returnType: returnType,
- typeParameters: typeParameters
- };
- if (isAsync) {
- funDecl.async = true;
- }
- return funDecl;
- },
- createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
- isAsync, returnType, typeParameters) {
- var funExpr = {
- type: Syntax.FunctionExpression,
- id: id,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: generator,
- expression: expression,
- returnType: returnType,
- typeParameters: typeParameters
- };
- if (isAsync) {
- funExpr.async = true;
- }
- return funExpr;
- },
- createIdentifier: function (name) {
- return {
- type: Syntax.Identifier,
- name: name,
- // Only here to initialize the shape of the object to ensure
- // that the 'typeAnnotation' key is ordered before others that
- // are added later (like 'loc' and 'range'). This just helps
- // keep the shape of Identifier nodes consistent with everything
- // else.
- typeAnnotation: undefined,
- optional: undefined
- };
- },
- createTypeAnnotation: function (typeAnnotation) {
- return {
- type: Syntax.TypeAnnotation,
- typeAnnotation: typeAnnotation
- };
- },
- createTypeCast: function (expression, typeAnnotation) {
- return {
- type: Syntax.TypeCastExpression,
- expression: expression,
- typeAnnotation: typeAnnotation
- };
- },
- createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
- return {
- type: Syntax.FunctionTypeAnnotation,
- params: params,
- returnType: returnType,
- rest: rest,
- typeParameters: typeParameters
- };
- },
- createFunctionTypeParam: function (name, typeAnnotation, optional) {
- return {
- type: Syntax.FunctionTypeParam,
- name: name,
- typeAnnotation: typeAnnotation,
- optional: optional
- };
- },
- createNullableTypeAnnotation: function (typeAnnotation) {
- return {
- type: Syntax.NullableTypeAnnotation,
- typeAnnotation: typeAnnotation
- };
- },
- createArrayTypeAnnotation: function (elementType) {
- return {
- type: Syntax.ArrayTypeAnnotation,
- elementType: elementType
- };
- },
- createGenericTypeAnnotation: function (id, typeParameters) {
- return {
- type: Syntax.GenericTypeAnnotation,
- id: id,
- typeParameters: typeParameters
- };
- },
- createQualifiedTypeIdentifier: function (qualification, id) {
- return {
- type: Syntax.QualifiedTypeIdentifier,
- qualification: qualification,
- id: id
- };
- },
- createTypeParameterDeclaration: function (params) {
- return {
- type: Syntax.TypeParameterDeclaration,
- params: params
- };
- },
- createTypeParameterInstantiation: function (params) {
- return {
- type: Syntax.TypeParameterInstantiation,
- params: params
- };
- },
- createAnyTypeAnnotation: function () {
- return {
- type: Syntax.AnyTypeAnnotation
- };
- },
- createBooleanTypeAnnotation: function () {
- return {
- type: Syntax.BooleanTypeAnnotation
- };
- },
- createNumberTypeAnnotation: function () {
- return {
- type: Syntax.NumberTypeAnnotation
- };
- },
- createStringTypeAnnotation: function () {
- return {
- type: Syntax.StringTypeAnnotation
- };
- },
- createStringLiteralTypeAnnotation: function (token) {
- return {
- type: Syntax.StringLiteralTypeAnnotation,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- },
- createVoidTypeAnnotation: function () {
- return {
- type: Syntax.VoidTypeAnnotation
- };
- },
- createTypeofTypeAnnotation: function (argument) {
- return {
- type: Syntax.TypeofTypeAnnotation,
- argument: argument
- };
- },
- createTupleTypeAnnotation: function (types) {
- return {
- type: Syntax.TupleTypeAnnotation,
- types: types
- };
- },
- createObjectTypeAnnotation: function (properties, indexers, callProperties) {
- return {
- type: Syntax.ObjectTypeAnnotation,
- properties: properties,
- indexers: indexers,
- callProperties: callProperties
- };
- },
- createObjectTypeIndexer: function (id, key, value, isStatic) {
- return {
- type: Syntax.ObjectTypeIndexer,
- id: id,
- key: key,
- value: value,
- static: isStatic
- };
- },
- createObjectTypeCallProperty: function (value, isStatic) {
- return {
- type: Syntax.ObjectTypeCallProperty,
- value: value,
- static: isStatic
- };
- },
- createObjectTypeProperty: function (key, value, optional, isStatic) {
- return {
- type: Syntax.ObjectTypeProperty,
- key: key,
- value: value,
- optional: optional,
- static: isStatic
- };
- },
- createUnionTypeAnnotation: function (types) {
- return {
- type: Syntax.UnionTypeAnnotation,
- types: types
- };
- },
- createIntersectionTypeAnnotation: function (types) {
- return {
- type: Syntax.IntersectionTypeAnnotation,
- types: types
- };
- },
- createTypeAlias: function (id, typeParameters, right) {
- return {
- type: Syntax.TypeAlias,
- id: id,
- typeParameters: typeParameters,
- right: right
- };
- },
- createInterface: function (id, typeParameters, body, extended) {
- return {
- type: Syntax.InterfaceDeclaration,
- id: id,
- typeParameters: typeParameters,
- body: body,
- extends: extended
- };
- },
- createInterfaceExtends: function (id, typeParameters) {
- return {
- type: Syntax.InterfaceExtends,
- id: id,
- typeParameters: typeParameters
- };
- },
- createDeclareFunction: function (id) {
- return {
- type: Syntax.DeclareFunction,
- id: id
- };
- },
- createDeclareVariable: function (id) {
- return {
- type: Syntax.DeclareVariable,
- id: id
- };
- },
- createDeclareModule: function (id, body) {
- return {
- type: Syntax.DeclareModule,
- id: id,
- body: body
- };
- },
- createJSXAttribute: function (name, value) {
- return {
- type: Syntax.JSXAttribute,
- name: name,
- value: value || null
- };
- },
- createJSXSpreadAttribute: function (argument) {
- return {
- type: Syntax.JSXSpreadAttribute,
- argument: argument
- };
- },
- createJSXIdentifier: function (name) {
- return {
- type: Syntax.JSXIdentifier,
- name: name
- };
- },
- createJSXNamespacedName: function (namespace, name) {
- return {
- type: Syntax.JSXNamespacedName,
- namespace: namespace,
- name: name
- };
- },
- createJSXMemberExpression: function (object, property) {
- return {
- type: Syntax.JSXMemberExpression,
- object: object,
- property: property
- };
- },
- createJSXElement: function (openingElement, closingElement, children) {
- return {
- type: Syntax.JSXElement,
- openingElement: openingElement,
- closingElement: closingElement,
- children: children
- };
- },
- createJSXEmptyExpression: function () {
- return {
- type: Syntax.JSXEmptyExpression
- };
- },
- createJSXExpressionContainer: function (expression) {
- return {
- type: Syntax.JSXExpressionContainer,
- expression: expression
- };
- },
- createJSXOpeningElement: function (name, attributes, selfClosing) {
- return {
- type: Syntax.JSXOpeningElement,
- name: name,
- selfClosing: selfClosing,
- attributes: attributes
- };
- },
- createJSXClosingElement: function (name) {
- return {
- type: Syntax.JSXClosingElement,
- name: name
- };
- },
- createIfStatement: function (test, consequent, alternate) {
- return {
- type: Syntax.IfStatement,
- test: test,
- consequent: consequent,
- alternate: alternate
- };
- },
- createLabeledStatement: function (label, body) {
- return {
- type: Syntax.LabeledStatement,
- label: label,
- body: body
- };
- },
- createLiteral: function (token) {
- var object = {
- type: Syntax.Literal,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- if (token.regex) {
- object.regex = token.regex;
- }
- return object;
- },
- createMemberExpression: function (accessor, object, property) {
- return {
- type: Syntax.MemberExpression,
- computed: accessor === '[',
- object: object,
- property: property
- };
- },
- createNewExpression: function (callee, args) {
- return {
- type: Syntax.NewExpression,
- callee: callee,
- 'arguments': args
- };
- },
- createObjectExpression: function (properties) {
- return {
- type: Syntax.ObjectExpression,
- properties: properties
- };
- },
- createPostfixExpression: function (operator, argument) {
- return {
- type: Syntax.UpdateExpression,
- operator: operator,
- argument: argument,
- prefix: false
- };
- },
- createProgram: function (body) {
- return {
- type: Syntax.Program,
- body: body
- };
- },
- createProperty: function (kind, key, value, method, shorthand, computed) {
- return {
- type: Syntax.Property,
- key: key,
- value: value,
- kind: kind,
- method: method,
- shorthand: shorthand,
- computed: computed
- };
- },
- createReturnStatement: function (argument) {
- return {
- type: Syntax.ReturnStatement,
- argument: argument
- };
- },
- createSequenceExpression: function (expressions) {
- return {
- type: Syntax.SequenceExpression,
- expressions: expressions
- };
- },
- createSwitchCase: function (test, consequent) {
- return {
- type: Syntax.SwitchCase,
- test: test,
- consequent: consequent
- };
- },
- createSwitchStatement: function (discriminant, cases) {
- return {
- type: Syntax.SwitchStatement,
- discriminant: discriminant,
- cases: cases
- };
- },
- createThisExpression: function () {
- return {
- type: Syntax.ThisExpression
- };
- },
- createThrowStatement: function (argument) {
- return {
- type: Syntax.ThrowStatement,
- argument: argument
- };
- },
- createTryStatement: function (block, guardedHandlers, handlers, finalizer) {
- return {
- type: Syntax.TryStatement,
- block: block,
- guardedHandlers: guardedHandlers,
- handlers: handlers,
- finalizer: finalizer
- };
- },
- createUnaryExpression: function (operator, argument) {
- if (operator === '++' || operator === '--') {
- return {
- type: Syntax.UpdateExpression,
- operator: operator,
- argument: argument,
- prefix: true
- };
- }
- return {
- type: Syntax.UnaryExpression,
- operator: operator,
- argument: argument,
- prefix: true
- };
- },
- createVariableDeclaration: function (declarations, kind) {
- return {
- type: Syntax.VariableDeclaration,
- declarations: declarations,
- kind: kind
- };
- },
- createVariableDeclarator: function (id, init) {
- return {
- type: Syntax.VariableDeclarator,
- id: id,
- init: init
- };
- },
- createWhileStatement: function (test, body) {
- return {
- type: Syntax.WhileStatement,
- test: test,
- body: body
- };
- },
- createWithStatement: function (object, body) {
- return {
- type: Syntax.WithStatement,
- object: object,
- body: body
- };
- },
- createTemplateElement: function (value, tail) {
- return {
- type: Syntax.TemplateElement,
- value: value,
- tail: tail
- };
- },
- createTemplateLiteral: function (quasis, expressions) {
- return {
- type: Syntax.TemplateLiteral,
- quasis: quasis,
- expressions: expressions
- };
- },
- createSpreadElement: function (argument) {
- return {
- type: Syntax.SpreadElement,
- argument: argument
- };
- },
- createSpreadProperty: function (argument) {
- return {
- type: Syntax.SpreadProperty,
- argument: argument
- };
- },
- createTaggedTemplateExpression: function (tag, quasi) {
- return {
- type: Syntax.TaggedTemplateExpression,
- tag: tag,
- quasi: quasi
- };
- },
- createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
- var arrowExpr = {
- type: Syntax.ArrowFunctionExpression,
- id: null,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: false,
- expression: expression
- };
- if (isAsync) {
- arrowExpr.async = true;
- }
- return arrowExpr;
- },
- createMethodDefinition: function (propertyType, kind, key, value, computed) {
- return {
- type: Syntax.MethodDefinition,
- key: key,
- value: value,
- kind: kind,
- 'static': propertyType === ClassPropertyType.static,
- computed: computed
- };
- },
- createClassProperty: function (key, typeAnnotation, computed, isStatic) {
- return {
- type: Syntax.ClassProperty,
- key: key,
- typeAnnotation: typeAnnotation,
- computed: computed,
- static: isStatic
- };
- },
- createClassBody: function (body) {
- return {
- type: Syntax.ClassBody,
- body: body
- };
- },
- createClassImplements: function (id, typeParameters) {
- return {
- type: Syntax.ClassImplements,
- id: id,
- typeParameters: typeParameters
- };
- },
- createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
- return {
- type: Syntax.ClassExpression,
- id: id,
- superClass: superClass,
- body: body,
- typeParameters: typeParameters,
- superTypeParameters: superTypeParameters,
- implements: implemented
- };
- },
- createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
- return {
- type: Syntax.ClassDeclaration,
- id: id,
- superClass: superClass,
- body: body,
- typeParameters: typeParameters,
- superTypeParameters: superTypeParameters,
- implements: implemented
- };
- },
- createModuleSpecifier: function (token) {
- return {
- type: Syntax.ModuleSpecifier,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- },
- createExportSpecifier: function (id, name) {
- return {
- type: Syntax.ExportSpecifier,
- id: id,
- name: name
- };
- },
- createExportBatchSpecifier: function () {
- return {
- type: Syntax.ExportBatchSpecifier
- };
- },
- createImportDefaultSpecifier: function (id) {
- return {
- type: Syntax.ImportDefaultSpecifier,
- id: id
- };
- },
- createImportNamespaceSpecifier: function (id) {
- return {
- type: Syntax.ImportNamespaceSpecifier,
- id: id
- };
- },
- createExportDeclaration: function (isDefault, declaration, specifiers, src) {
- return {
- type: Syntax.ExportDeclaration,
- 'default': !!isDefault,
- declaration: declaration,
- specifiers: specifiers,
- source: src
- };
- },
- createImportSpecifier: function (id, name) {
- return {
- type: Syntax.ImportSpecifier,
- id: id,
- name: name
- };
- },
- createImportDeclaration: function (specifiers, src, isType) {
- return {
- type: Syntax.ImportDeclaration,
- specifiers: specifiers,
- source: src,
- isType: isType
- };
- },
- createYieldExpression: function (argument, dlg) {
- return {
- type: Syntax.YieldExpression,
- argument: argument,
- delegate: dlg
- };
- },
- createAwaitExpression: function (argument) {
- return {
- type: Syntax.AwaitExpression,
- argument: argument
- };
- },
- createComprehensionExpression: function (filter, blocks, body) {
- return {
- type: Syntax.ComprehensionExpression,
- filter: filter,
- blocks: blocks,
- body: body
- };
- }
- };
- // Return true if there is a line terminator before the next token.
- function peekLineTerminator() {
- var pos, line, start, found;
- pos = index;
- line = lineNumber;
- start = lineStart;
- skipComment();
- found = lineNumber !== line;
- index = pos;
- lineNumber = line;
- lineStart = start;
- return found;
- }
- // Throw an exception
- function throwError(token, messageFormat) {
- var error,
- args = Array.prototype.slice.call(arguments, 2),
- msg = messageFormat.replace(
- /%(\d)/g,
- function (whole, idx) {
- assert(idx < args.length, 'Message reference must be in range');
- return args[idx];
- }
- );
- if (typeof token.lineNumber === 'number') {
- error = new Error('Line ' + token.lineNumber + ': ' + msg);
- error.index = token.range[0];
- error.lineNumber = token.lineNumber;
- error.column = token.range[0] - lineStart + 1;
- } else {
- error = new Error('Line ' + lineNumber + ': ' + msg);
- error.index = index;
- error.lineNumber = lineNumber;
- error.column = index - lineStart + 1;
- }
- error.description = msg;
- throw error;
- }
- function throwErrorTolerant() {
- try {
- throwError.apply(null, arguments);
- } catch (e) {
- if (extra.errors) {
- extra.errors.push(e);
- } else {
- throw e;
- }
- }
- }
- // Throw an exception because of the token.
- function throwUnexpected(token) {
- if (token.type === Token.EOF) {
- throwError(token, Messages.UnexpectedEOS);
- }
- if (token.type === Token.NumericLiteral) {
- throwError(token, Messages.UnexpectedNumber);
- }
- if (token.type === Token.StringLiteral || token.type === Token.JSXText) {
- throwError(token, Messages.UnexpectedString);
- }
- if (token.type === Token.Identifier) {
- throwError(token, Messages.UnexpectedIdentifier);
- }
- if (token.type === Token.Keyword) {
- if (isFutureReservedWord(token.value)) {
- throwError(token, Messages.UnexpectedReserved);
- } else if (strict && isStrictModeReservedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictReservedWord);
- return;
- }
- throwError(token, Messages.UnexpectedToken, token.value);
- }
- if (token.type === Token.Template) {
- throwError(token, Messages.UnexpectedTemplate, token.value.raw);
- }
- // BooleanLiteral, NullLiteral, or Punctuator.
- throwError(token, Messages.UnexpectedToken, token.value);
- }
- // Expect the next token to match the specified punctuator.
- // If not, an exception will be thrown.
- function expect(value) {
- var token = lex();
- if (token.type !== Token.Punctuator || token.value !== value) {
- throwUnexpected(token);
- }
- }
- // Expect the next token to match the specified keyword.
- // If not, an exception will be thrown.
- function expectKeyword(keyword, contextual) {
- var token = lex();
- if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
- token.value !== keyword) {
- throwUnexpected(token);
- }
- }
- // Expect the next token to match the specified contextual keyword.
- // If not, an exception will be thrown.
- function expectContextualKeyword(keyword) {
- return expectKeyword(keyword, true);
- }
- // Return true if the next token matches the specified punctuator.
- function match(value) {
- return lookahead.type === Token.Punctuator && lookahead.value === value;
- }
- // Return true if the next token matches the specified keyword
- function matchKeyword(keyword, contextual) {
- var expectedType = contextual ? Token.Identifier : Token.Keyword;
- return lookahead.type === expectedType && lookahead.value === keyword;
- }
- // Return true if the next token matches the specified contextual keyword
- function matchContextualKeyword(keyword) {
- return matchKeyword(keyword, true);
- }
- // Return true if the next token is an assignment operator
- function matchAssign() {
- var op;
- if (lookahead.type !== Token.Punctuator) {
- return false;
- }
- op = lookahead.value;
- return op === '=' ||
- op === '*=' ||
- op === '/=' ||
- op === '%=' ||
- op === '+=' ||
- op === '-=' ||
- op === '<<=' ||
- op === '>>=' ||
- op === '>>>=' ||
- op === '&=' ||
- op === '^=' ||
- op === '|=';
- }
- // Note that 'yield' is treated as a keyword in strict mode, but a
- // contextual keyword (identifier) in non-strict mode, so we need to
- // use matchKeyword('yield', false) and matchKeyword('yield', true)
- // (i.e. matchContextualKeyword) appropriately.
- function matchYield() {
- return state.yieldAllowed && matchKeyword('yield', !strict);
- }
- function matchAsync() {
- var backtrackToken = lookahead, matches = false;
- if (matchContextualKeyword('async')) {
- lex(); // Make sure peekLineTerminator() starts after 'async'.
- matches = !peekLineTerminator();
- rewind(backtrackToken); // Revert the lex().
- }
- return matches;
- }
- function matchAwait() {
- return state.awaitAllowed && matchContextualKeyword('await');
- }
- function consumeSemicolon() {
- var line, oldIndex = index, oldLineNumber = lineNumber,
- oldLineStart = lineStart, oldLookahead = lookahead;
- // Catch the very common case first: immediately a semicolon (char #59).
- if (source.charCodeAt(index) === 59) {
- lex();
- return;
- }
- line = lineNumber;
- skipComment();
- if (lineNumber !== line) {
- index = oldIndex;
- lineNumber = oldLineNumber;
- lineStart = oldLineStart;
- lookahead = oldLookahead;
- return;
- }
- if (match(';')) {
- lex();
- return;
- }
- if (lookahead.type !== Token.EOF && !match('}')) {
- throwUnexpected(lookahead);
- }
- }
- // Return true if provided expression is LeftHandSideExpression
- function isLeftHandSide(expr) {
- return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;
- }
- function isAssignableLeftHandSide(expr) {
- return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern;
- }
- // 11.1.4 Array Initialiser
- function parseArrayInitialiser() {
- var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
- marker = markerCreate();
- expect('[');
- while (!match(']')) {
- if (lookahead.value === 'for' &&
- lookahead.type === Token.Keyword) {
- if (!possiblecomprehension) {
- throwError({}, Messages.ComprehensionError);
- }
- matchKeyword('for');
- tmp = parseForStatement({ignoreBody: true});
- tmp.of = tmp.type === Syntax.ForOfStatement;
- tmp.type = Syntax.ComprehensionBlock;
- if (tmp.left.kind) { // can't be let or const
- throwError({}, Messages.ComprehensionError);
- }
- blocks.push(tmp);
- } else if (lookahead.value === 'if' &&
- lookahead.type === Token.Keyword) {
- if (!possiblecomprehension) {
- throwError({}, Messages.ComprehensionError);
- }
- expectKeyword('if');
- expect('(');
- filter = parseExpression();
- expect(')');
- } else if (lookahead.value === ',' &&
- lookahead.type === Token.Punctuator) {
- possiblecomprehension = false; // no longer allowed.
- lex();
- elements.push(null);
- } else {
- tmp = parseSpreadOrAssignmentExpression();
- elements.push(tmp);
- if (tmp && tmp.type === Syntax.SpreadElement) {
- if (!match(']')) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) {
- expect(','); // this lexes.
- possiblecomprehension = false;
- }
- }
- }
- expect(']');
- if (filter && !blocks.length) {
- throwError({}, Messages.ComprehensionRequiresBlock);
- }
- if (blocks.length) {
- if (elements.length !== 1) {
- throwError({}, Messages.ComprehensionError);
- }
- return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0]));
- }
- return markerApply(marker, delegate.createArrayExpression(elements));
- }
- // 11.1.5 Object Initialiser
- function parsePropertyFunction(options) {
- var previousStrict, previousYieldAllowed, previousAwaitAllowed,
- params, defaults, body, marker = markerCreate();
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = options.generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = options.async;
- params = options.params || [];
- defaults = options.defaults || [];
- body = parseConciseBody();
- if (options.name && strict && isRestrictedWord(params[0].name)) {
- throwErrorTolerant(options.name, Messages.StrictParamName);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createFunctionExpression(
- null,
- params,
- defaults,
- body,
- options.rest || null,
- options.generator,
- body.type !== Syntax.BlockStatement,
- options.async,
- options.returnType,
- options.typeParameters
- ));
- }
- function parsePropertyMethodFunction(options) {
- var previousStrict, tmp, method;
- previousStrict = strict;
- strict = true;
- tmp = parseParams();
- if (tmp.stricted) {
- throwErrorTolerant(tmp.stricted, tmp.message);
- }
- method = parsePropertyFunction({
- params: tmp.params,
- defaults: tmp.defaults,
- rest: tmp.rest,
- generator: options.generator,
- async: options.async,
- returnType: tmp.returnType,
- typeParameters: options.typeParameters
- });
- strict = previousStrict;
- return method;
- }
- function parseObjectPropertyKey() {
- var marker = markerCreate(),
- token = lex(),
- propertyKey,
- result;
- // Note: This function is called only from parseObjectProperty(), where
- // EOF and Punctuator tokens are already filtered out.
- if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {
- if (strict && token.octal) {
- throwErrorTolerant(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (token.type === Token.Punctuator && token.value === '[') {
- // For computed properties we should skip the [ and ], and
- // capture in marker only the assignment expression itself.
- marker = markerCreate();
- propertyKey = parseAssignmentExpression();
- result = markerApply(marker, propertyKey);
- expect(']');
- return result;
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseObjectProperty() {
- var token, key, id, param, computed,
- marker = markerCreate(), returnType, typeParameters;
- token = lookahead;
- computed = (token.value === '[' && token.type === Token.Punctuator);
- if (token.type === Token.Identifier || computed || matchAsync()) {
- id = parseObjectPropertyKey();
- if (match(':')) {
- lex();
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- id,
- parseAssignmentExpression(),
- false,
- false,
- computed
- )
- );
- }
- if (match('(') || match('<')) {
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- id,
- parsePropertyMethodFunction({
- generator: false,
- async: false,
- typeParameters: typeParameters
- }),
- true,
- false,
- computed
- )
- );
- }
- // Property Assignment: Getter and Setter.
- if (token.value === 'get') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- expect('(');
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'get',
- key,
- parsePropertyFunction({
- generator: false,
- async: false,
- returnType: returnType
- }),
- false,
- false,
- computed
- )
- );
- }
- if (token.value === 'set') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- expect('(');
- token = lookahead;
- param = [ parseTypeAnnotatableIdentifier() ];
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'set',
- key,
- parsePropertyFunction({
- params: param,
- generator: false,
- async: false,
- name: token,
- returnType: returnType
- }),
- false,
- false,
- computed
- )
- );
- }
- if (token.value === 'async') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- key,
- parsePropertyMethodFunction({
- generator: false,
- async: true,
- typeParameters: typeParameters
- }),
- true,
- false,
- computed
- )
- );
- }
- if (computed) {
- // Computed properties can only be used with full notation.
- throwUnexpected(lookahead);
- }
- return markerApply(
- marker,
- delegate.createProperty('init', id, id, false, true, false)
- );
- }
- if (token.type === Token.EOF || token.type === Token.Punctuator) {
- if (!match('*')) {
- throwUnexpected(token);
- }
- lex();
- computed = (lookahead.type === Token.Punctuator && lookahead.value === '[');
- id = parseObjectPropertyKey();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (!match('(')) {
- throwUnexpected(lex());
- }
- return markerApply(marker, delegate.createProperty(
- 'init',
- id,
- parsePropertyMethodFunction({
- generator: true,
- typeParameters: typeParameters
- }),
- true,
- false,
- computed
- ));
- }
- key = parseObjectPropertyKey();
- if (match(':')) {
- lex();
- return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
- }
- if (match('(') || match('<')) {
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- return markerApply(marker, delegate.createProperty(
- 'init',
- key,
- parsePropertyMethodFunction({
- generator: false,
- typeParameters: typeParameters
- }),
- true,
- false,
- false
- ));
- }
- throwUnexpected(lex());
- }
- function parseObjectSpreadProperty() {
- var marker = markerCreate();
- expect('...');
- return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
- }
- function getFieldName(key) {
- var toString = String;
- if (key.type === Syntax.Identifier) {
- return key.name;
- }
- return toString(key.value);
- }
- function parseObjectInitialiser() {
- var properties = [], property, name, kind, storedKind, map = new StringMap(),
- marker = markerCreate(), toString = String;
- expect('{');
- while (!match('}')) {
- if (match('...')) {
- property = parseObjectSpreadProperty();
- } else {
- property = parseObjectProperty();
- if (property.key.type === Syntax.Identifier) {
- name = property.key.name;
- } else {
- name = toString(property.key.value);
- }
- kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
- if (map.has(name)) {
- storedKind = map.get(name);
- if (storedKind === PropertyKind.Data) {
- if (strict && kind === PropertyKind.Data) {
- throwErrorTolerant({}, Messages.StrictDuplicateProperty);
- } else if (kind !== PropertyKind.Data) {
- throwErrorTolerant({}, Messages.AccessorDataProperty);
- }
- } else {
- if (kind === PropertyKind.Data) {
- throwErrorTolerant({}, Messages.AccessorDataProperty);
- } else if (storedKind & kind) {
- throwErrorTolerant({}, Messages.AccessorGetSet);
- }
- }
- map.set(name, storedKind | kind);
- } else {
- map.set(name, kind);
- }
- }
- properties.push(property);
- if (!match('}')) {
- expect(',');
- }
- }
- expect('}');
- return markerApply(marker, delegate.createObjectExpression(properties));
- }
- function parseTemplateElement(option) {
- var marker = markerCreate(),
- token = scanTemplateElement(option);
- if (strict && token.octal) {
- throwError(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail));
- }
- function parseTemplateLiteral() {
- var quasi, quasis, expressions, marker = markerCreate();
- quasi = parseTemplateElement({ head: true });
- quasis = [ quasi ];
- expressions = [];
- while (!quasi.tail) {
- expressions.push(parseExpression());
- quasi = parseTemplateElement({ head: false });
- quasis.push(quasi);
- }
- return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions));
- }
- // 11.1.6 The Grouping Operator
- function parseGroupExpression() {
- var expr, marker, typeAnnotation;
- expect('(');
- ++state.parenthesizedCount;
- marker = markerCreate();
- expr = parseExpression();
- if (match(':')) {
- typeAnnotation = parseTypeAnnotation();
- expr = markerApply(marker, delegate.createTypeCast(
- expr,
- typeAnnotation
- ));
- }
- expect(')');
- return expr;
- }
- function matchAsyncFuncExprOrDecl() {
- var token;
- if (matchAsync()) {
- token = lookahead2();
- if (token.type === Token.Keyword && token.value === 'function') {
- return true;
- }
- }
- return false;
- }
- // 11.1 Primary Expressions
- function parsePrimaryExpression() {
- var marker, type, token, expr;
- type = lookahead.type;
- if (type === Token.Identifier) {
- marker = markerCreate();
- return markerApply(marker, delegate.createIdentifier(lex().value));
- }
- if (type === Token.StringLiteral || type === Token.NumericLiteral) {
- if (strict && lookahead.octal) {
- throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
- }
- marker = markerCreate();
- return markerApply(marker, delegate.createLiteral(lex()));
- }
- if (type === Token.Keyword) {
- if (matchKeyword('this')) {
- marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createThisExpression());
- }
- if (matchKeyword('function')) {
- return parseFunctionExpression();
- }
- if (matchKeyword('class')) {
- return parseClassExpression();
- }
- if (matchKeyword('super')) {
- marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createIdentifier('super'));
- }
- }
- if (type === Token.BooleanLiteral) {
- marker = markerCreate();
- token = lex();
- token.value = (token.value === 'true');
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (type === Token.NullLiteral) {
- marker = markerCreate();
- token = lex();
- token.value = null;
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (match('[')) {
- return parseArrayInitialiser();
- }
- if (match('{')) {
- return parseObjectInitialiser();
- }
- if (match('(')) {
- return parseGroupExpression();
- }
- if (match('/') || match('/=')) {
- marker = markerCreate();
- expr = delegate.createLiteral(scanRegExp());
- peek();
- return markerApply(marker, expr);
- }
- if (type === Token.Template) {
- return parseTemplateLiteral();
- }
- if (match('<')) {
- return parseJSXElement();
- }
- throwUnexpected(lex());
- }
- // 11.2 Left-Hand-Side Expressions
- function parseArguments() {
- var args = [], arg;
- expect('(');
- if (!match(')')) {
- while (index < length) {
- arg = parseSpreadOrAssignmentExpression();
- args.push(arg);
- if (match(')')) {
- break;
- } else if (arg.type === Syntax.SpreadElement) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- expect(',');
- }
- }
- expect(')');
- return args;
- }
- function parseSpreadOrAssignmentExpression() {
- if (match('...')) {
- var marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression()));
- }
- return parseAssignmentExpression();
- }
- function parseNonComputedProperty() {
- var marker = markerCreate(),
- token = lex();
- if (!isIdentifierName(token)) {
- throwUnexpected(token);
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseNonComputedMember() {
- expect('.');
- return parseNonComputedProperty();
- }
- function parseComputedMember() {
- var expr;
- expect('[');
- expr = parseExpression();
- expect(']');
- return expr;
- }
- function parseNewExpression() {
- var callee, args, marker = markerCreate();
- expectKeyword('new');
- callee = parseLeftHandSideExpression();
- args = match('(') ? parseArguments() : [];
- return markerApply(marker, delegate.createNewExpression(callee, args));
- }
- function parseLeftHandSideExpressionAllowCall() {
- var expr, args, marker = markerCreate();
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
- while (match('.') || match('[') || match('(') || lookahead.type === Token.Template) {
- if (match('(')) {
- args = parseArguments();
- expr = markerApply(marker, delegate.createCallExpression(expr, args));
- } else if (match('[')) {
- expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
- } else if (match('.')) {
- expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
- } else {
- expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
- }
- }
- return expr;
- }
- function parseLeftHandSideExpression() {
- var expr, marker = markerCreate();
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
- while (match('.') || match('[') || lookahead.type === Token.Template) {
- if (match('[')) {
- expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
- } else if (match('.')) {
- expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
- } else {
- expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
- }
- }
- return expr;
- }
- // 11.3 Postfix Expressions
- function parsePostfixExpression() {
- var marker = markerCreate(),
- expr = parseLeftHandSideExpressionAllowCall(),
- token;
- if (lookahead.type !== Token.Punctuator) {
- return expr;
- }
- if ((match('++') || match('--')) && !peekLineTerminator()) {
- // 11.3.1, 11.3.2
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant({}, Messages.StrictLHSPostfix);
- }
- if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- token = lex();
- expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr));
- }
- return expr;
- }
- // 11.4 Unary Operators
- function parseUnaryExpression() {
- var marker, token, expr;
- if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
- return parsePostfixExpression();
- }
- if (match('++') || match('--')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- // 11.4.4, 11.4.5
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant({}, Messages.StrictLHSPrefix);
- }
- if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- }
- if (match('+') || match('-') || match('~') || match('!')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- }
- if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
- throwErrorTolerant({}, Messages.StrictDelete);
- }
- return expr;
- }
- return parsePostfixExpression();
- }
- function binaryPrecedence(token, allowIn) {
- var prec = 0;
- if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
- return 0;
- }
- switch (token.value) {
- case '||':
- prec = 1;
- break;
- case '&&':
- prec = 2;
- break;
- case '|':
- prec = 3;
- break;
- case '^':
- prec = 4;
- break;
- case '&':
- prec = 5;
- break;
- case '==':
- case '!=':
- case '===':
- case '!==':
- prec = 6;
- break;
- case '<':
- case '>':
- case '<=':
- case '>=':
- case 'instanceof':
- prec = 7;
- break;
- case 'in':
- prec = allowIn ? 7 : 0;
- break;
- case '<<':
- case '>>':
- case '>>>':
- prec = 8;
- break;
- case '+':
- case '-':
- prec = 9;
- break;
- case '*':
- case '/':
- case '%':
- prec = 11;
- break;
- default:
- break;
- }
- return prec;
- }
- // 11.5 Multiplicative Operators
- // 11.6 Additive Operators
- // 11.7 Bitwise Shift Operators
- // 11.8 Relational Operators
- // 11.9 Equality Operators
- // 11.10 Binary Bitwise Operators
- // 11.11 Binary Logical Operators
- function parseBinaryExpression() {
- var expr, token, prec, previousAllowIn, stack, right, operator, left, i,
- marker, markers;
- previousAllowIn = state.allowIn;
- state.allowIn = true;
- marker = markerCreate();
- left = parseUnaryExpression();
- token = lookahead;
- prec = binaryPrecedence(token, previousAllowIn);
- if (prec === 0) {
- return left;
- }
- token.prec = prec;
- lex();
- markers = [marker, markerCreate()];
- right = parseUnaryExpression();
- stack = [left, token, right];
- while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) {
- // Reduce: make a binary expression from the three topmost entries.
- while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
- right = stack.pop();
- operator = stack.pop().value;
- left = stack.pop();
- expr = delegate.createBinaryExpression(operator, left, right);
- markers.pop();
- marker = markers.pop();
- markerApply(marker, expr);
- stack.push(expr);
- markers.push(marker);
- }
- // Shift.
- token = lex();
- token.prec = prec;
- stack.push(token);
- markers.push(markerCreate());
- expr = parseUnaryExpression();
- stack.push(expr);
- }
- state.allowIn = previousAllowIn;
- // Final reduce to clean-up the stack.
- i = stack.length - 1;
- expr = stack[i];
- markers.pop();
- while (i > 1) {
- expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
- i -= 2;
- marker = markers.pop();
- markerApply(marker, expr);
- }
- return expr;
- }
- // 11.12 Conditional Operator
- function parseConditionalExpression() {
- var expr, previousAllowIn, consequent, alternate, marker = markerCreate();
- expr = parseBinaryExpression();
- if (match('?')) {
- lex();
- previousAllowIn = state.allowIn;
- state.allowIn = true;
- consequent = parseAssignmentExpression();
- state.allowIn = previousAllowIn;
- expect(':');
- alternate = parseAssignmentExpression();
- expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate));
- }
- return expr;
- }
- // 11.13 Assignment Operators
- // 12.14.5 AssignmentPattern
- function reinterpretAsAssignmentBindingPattern(expr) {
- var i, len, property, element;
- if (expr.type === Syntax.ObjectExpression) {
- expr.type = Syntax.ObjectPattern;
- for (i = 0, len = expr.properties.length; i < len; i += 1) {
- property = expr.properties[i];
- if (property.type === Syntax.SpreadProperty) {
- if (i < len - 1) {
- throwError({}, Messages.PropertyAfterSpreadProperty);
- }
- reinterpretAsAssignmentBindingPattern(property.argument);
- } else {
- if (property.kind !== 'init') {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- reinterpretAsAssignmentBindingPattern(property.value);
- }
- }
- } else if (expr.type === Syntax.ArrayExpression) {
- expr.type = Syntax.ArrayPattern;
- for (i = 0, len = expr.elements.length; i < len; i += 1) {
- element = expr.elements[i];
- /* istanbul ignore else */
- if (element) {
- reinterpretAsAssignmentBindingPattern(element);
- }
- }
- } else if (expr.type === Syntax.Identifier) {
- if (isRestrictedWord(expr.name)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- } else if (expr.type === Syntax.SpreadElement) {
- reinterpretAsAssignmentBindingPattern(expr.argument);
- if (expr.argument.type === Syntax.ObjectPattern) {
- throwError({}, Messages.ObjectPatternAsSpread);
- }
- } else {
- /* istanbul ignore else */
- if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- }
- }
- // 13.2.3 BindingPattern
- function reinterpretAsDestructuredParameter(options, expr) {
- var i, len, property, element;
- if (expr.type === Syntax.ObjectExpression) {
- expr.type = Syntax.ObjectPattern;
- for (i = 0, len = expr.properties.length; i < len; i += 1) {
- property = expr.properties[i];
- if (property.type === Syntax.SpreadProperty) {
- if (i < len - 1) {
- throwError({}, Messages.PropertyAfterSpreadProperty);
- }
- reinterpretAsDestructuredParameter(options, property.argument);
- } else {
- if (property.kind !== 'init') {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- reinterpretAsDestructuredParameter(options, property.value);
- }
- }
- } else if (expr.type === Syntax.ArrayExpression) {
- expr.type = Syntax.ArrayPattern;
- for (i = 0, len = expr.elements.length; i < len; i += 1) {
- element = expr.elements[i];
- if (element) {
- reinterpretAsDestructuredParameter(options, element);
- }
- }
- } else if (expr.type === Syntax.Identifier) {
- validateParam(options, expr, expr.name);
- } else if (expr.type === Syntax.SpreadElement) {
- // BindingRestElement only allows BindingIdentifier
- if (expr.argument.type !== Syntax.Identifier) {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- validateParam(options, expr.argument, expr.argument.name);
- } else {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- }
- function reinterpretAsCoverFormalsList(expressions) {
- var i, len, param, params, defaults, defaultCount, options, rest;
- params = [];
- defaults = [];
- defaultCount = 0;
- rest = null;
- options = {
- paramSet: new StringMap()
- };
- for (i = 0, len = expressions.length; i < len; i += 1) {
- param = expressions[i];
- if (param.type === Syntax.Identifier) {
- params.push(param);
- defaults.push(null);
- validateParam(options, param, param.name);
- } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) {
- reinterpretAsDestructuredParameter(options, param);
- params.push(param);
- defaults.push(null);
- } else if (param.type === Syntax.SpreadElement) {
- assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
- if (param.argument.type !== Syntax.Identifier) {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- reinterpretAsDestructuredParameter(options, param.argument);
- rest = param.argument;
- } else if (param.type === Syntax.AssignmentExpression) {
- params.push(param.left);
- defaults.push(param.right);
- ++defaultCount;
- validateParam(options, param.left, param.left.name);
- } else {
- return null;
- }
- }
- if (options.message === Messages.StrictParamDupe) {
- throwError(
- strict ? options.stricted : options.firstRestricted,
- options.message
- );
- }
- if (defaultCount === 0) {
- defaults = [];
- }
- return {
- params: params,
- defaults: defaults,
- rest: rest,
- stricted: options.stricted,
- firstRestricted: options.firstRestricted,
- message: options.message
- };
- }
- function parseArrowFunctionExpression(options, marker) {
- var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
- expect('=>');
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = !!options.async;
- body = parseConciseBody();
- if (strict && options.firstRestricted) {
- throwError(options.firstRestricted, options.message);
- }
- if (strict && options.stricted) {
- throwErrorTolerant(options.stricted, options.message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createArrowFunctionExpression(
- options.params,
- options.defaults,
- body,
- options.rest,
- body.type !== Syntax.BlockStatement,
- !!options.async
- ));
- }
- function parseAssignmentExpression() {
- var marker, expr, token, params, oldParenthesizedCount,
- startsWithParen = false, backtrackToken = lookahead,
- possiblyAsync = false;
- if (matchYield()) {
- return parseYieldExpression();
- }
- if (matchAwait()) {
- return parseAwaitExpression();
- }
- oldParenthesizedCount = state.parenthesizedCount;
- marker = markerCreate();
- if (matchAsyncFuncExprOrDecl()) {
- return parseFunctionExpression();
- }
- if (matchAsync()) {
- // We can't be completely sure that this 'async' token is
- // actually a contextual keyword modifying a function
- // expression, so we might have to un-lex() it later by
- // calling rewind(backtrackToken).
- possiblyAsync = true;
- lex();
- }
- if (match('(')) {
- token = lookahead2();
- if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
- params = parseParams();
- if (!match('=>')) {
- throwUnexpected(lex());
- }
- params.async = possiblyAsync;
- return parseArrowFunctionExpression(params, marker);
- }
- startsWithParen = true;
- }
- token = lookahead;
- // If the 'async' keyword is not followed by a '(' character or an
- // identifier, then it can't be an arrow function modifier, and we
- // should interpret it as a normal identifer.
- if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
- possiblyAsync = false;
- rewind(backtrackToken);
- }
- expr = parseConditionalExpression();
- if (match('=>') &&
- (state.parenthesizedCount === oldParenthesizedCount ||
- state.parenthesizedCount === (oldParenthesizedCount + 1))) {
- if (expr.type === Syntax.Identifier) {
- params = reinterpretAsCoverFormalsList([ expr ]);
- } else if (expr.type === Syntax.AssignmentExpression ||
- expr.type === Syntax.ArrayExpression ||
- expr.type === Syntax.ObjectExpression) {
- if (!startsWithParen) {
- throwUnexpected(lex());
- }
- params = reinterpretAsCoverFormalsList([ expr ]);
- } else if (expr.type === Syntax.SequenceExpression) {
- params = reinterpretAsCoverFormalsList(expr.expressions);
- }
- if (params) {
- params.async = possiblyAsync;
- return parseArrowFunctionExpression(params, marker);
- }
- }
- // If we haven't returned by now, then the 'async' keyword was not
- // a function modifier, and we should rewind and interpret it as a
- // normal identifier.
- if (possiblyAsync) {
- possiblyAsync = false;
- rewind(backtrackToken);
- expr = parseConditionalExpression();
- }
- if (matchAssign()) {
- // 11.13.1
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant(token, Messages.StrictLHSAssignment);
- }
- // ES.next draf 11.13 Runtime Semantics step 1
- if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) {
- reinterpretAsAssignmentBindingPattern(expr);
- } else if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression()));
- }
- return expr;
- }
- // 11.14 Comma Operator
- function parseExpression() {
- var marker, expr, expressions, sequence, spreadFound;
- marker = markerCreate();
- expr = parseAssignmentExpression();
- expressions = [ expr ];
- if (match(',')) {
- while (index < length) {
- if (!match(',')) {
- break;
- }
- lex();
- expr = parseSpreadOrAssignmentExpression();
- expressions.push(expr);
- if (expr.type === Syntax.SpreadElement) {
- spreadFound = true;
- if (!match(')')) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- break;
- }
- }
- sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
- }
- if (spreadFound && lookahead2().value !== '=>') {
- throwError({}, Messages.IllegalSpread);
- }
- return sequence || expr;
- }
- // 12.1 Block
- function parseStatementList() {
- var list = [],
- statement;
- while (index < length) {
- if (match('}')) {
- break;
- }
- statement = parseSourceElement();
- if (typeof statement === 'undefined') {
- break;
- }
- list.push(statement);
- }
- return list;
- }
- function parseBlock() {
- var block, marker = markerCreate();
- expect('{');
- block = parseStatementList();
- expect('}');
- return markerApply(marker, delegate.createBlockStatement(block));
- }
- // 12.2 Variable Statement
- function parseTypeParameterDeclaration() {
- var marker = markerCreate(), paramTypes = [];
- expect('<');
- while (!match('>')) {
- paramTypes.push(parseVariableIdentifier());
- if (!match('>')) {
- expect(',');
- }
- }
- expect('>');
- return markerApply(marker, delegate.createTypeParameterDeclaration(
- paramTypes
- ));
- }
- function parseTypeParameterInstantiation() {
- var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
- state.inType = true;
- expect('<');
- while (!match('>')) {
- paramTypes.push(parseType());
- if (!match('>')) {
- expect(',');
- }
- }
- expect('>');
- state.inType = oldInType;
- return markerApply(marker, delegate.createTypeParameterInstantiation(
- paramTypes
- ));
- }
- function parseObjectTypeIndexer(marker, isStatic) {
- var id, key, value;
- expect('[');
- id = parseObjectPropertyKey();
- expect(':');
- key = parseType();
- expect(']');
- expect(':');
- value = parseType();
- return markerApply(marker, delegate.createObjectTypeIndexer(
- id,
- key,
- value,
- isStatic
- ));
- }
- function parseObjectTypeMethodish(marker) {
- var params = [], rest = null, returnType, typeParameters = null;
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('(');
- while (lookahead.type === Token.Identifier) {
- params.push(parseFunctionTypeParam());
- if (!match(')')) {
- expect(',');
- }
- }
- if (match('...')) {
- lex();
- rest = parseFunctionTypeParam();
- }
- expect(')');
- expect(':');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- }
- function parseObjectTypeMethod(marker, isStatic, key) {
- var optional = false, value;
- value = parseObjectTypeMethodish(marker);
- return markerApply(marker, delegate.createObjectTypeProperty(
- key,
- value,
- optional,
- isStatic
- ));
- }
- function parseObjectTypeCallProperty(marker, isStatic) {
- var valueMarker = markerCreate();
- return markerApply(marker, delegate.createObjectTypeCallProperty(
- parseObjectTypeMethodish(valueMarker),
- isStatic
- ));
- }
- function parseObjectType(allowStatic) {
- var callProperties = [], indexers = [], marker, optional = false,
- properties = [], propertyKey, propertyTypeAnnotation,
- token, isStatic, matchStatic;
- expect('{');
- while (!match('}')) {
- marker = markerCreate();
- matchStatic =
- strict
- ? matchKeyword('static')
- : matchContextualKeyword('static');
- if (allowStatic && matchStatic) {
- token = lex();
- isStatic = true;
- }
- if (match('[')) {
- indexers.push(parseObjectTypeIndexer(marker, isStatic));
- } else if (match('(') || match('<')) {
- callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
- } else {
- if (isStatic && match(':')) {
- propertyKey = markerApply(marker, delegate.createIdentifier(token));
- throwErrorTolerant(token, Messages.StrictReservedWord);
- } else {
- propertyKey = parseObjectPropertyKey();
- }
- if (match('<') || match('(')) {
- // This is a method property
- properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
- } else {
- if (match('?')) {
- lex();
- optional = true;
- }
- expect(':');
- propertyTypeAnnotation = parseType();
- properties.push(markerApply(marker, delegate.createObjectTypeProperty(
- propertyKey,
- propertyTypeAnnotation,
- optional,
- isStatic
- )));
- }
- }
- if (match(';')) {
- lex();
- } else if (!match('}')) {
- throwUnexpected(lookahead);
- }
- }
- expect('}');
- return delegate.createObjectTypeAnnotation(
- properties,
- indexers,
- callProperties
- );
- }
- function parseGenericType() {
- var marker = markerCreate(),
- typeParameters = null, typeIdentifier;
- typeIdentifier = parseVariableIdentifier();
- while (match('.')) {
- expect('.');
- typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
- typeIdentifier,
- parseVariableIdentifier()
- ));
- }
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- }
- return markerApply(marker, delegate.createGenericTypeAnnotation(
- typeIdentifier,
- typeParameters
- ));
- }
- function parseVoidType() {
- var marker = markerCreate();
- expectKeyword('void');
- return markerApply(marker, delegate.createVoidTypeAnnotation());
- }
- function parseTypeofType() {
- var argument, marker = markerCreate();
- expectKeyword('typeof');
- argument = parsePrimaryType();
- return markerApply(marker, delegate.createTypeofTypeAnnotation(
- argument
- ));
- }
- function parseTupleType() {
- var marker = markerCreate(), types = [];
- expect('[');
- // We allow trailing commas
- while (index < length && !match(']')) {
- types.push(parseType());
- if (match(']')) {
- break;
- }
- expect(',');
- }
- expect(']');
- return markerApply(marker, delegate.createTupleTypeAnnotation(
- types
- ));
- }
- function parseFunctionTypeParam() {
- var marker = markerCreate(), name, optional = false, typeAnnotation;
- name = parseVariableIdentifier();
- if (match('?')) {
- lex();
- optional = true;
- }
- expect(':');
- typeAnnotation = parseType();
- return markerApply(marker, delegate.createFunctionTypeParam(
- name,
- typeAnnotation,
- optional
- ));
- }
- function parseFunctionTypeParams() {
- var ret = { params: [], rest: null };
- while (lookahead.type === Token.Identifier) {
- ret.params.push(parseFunctionTypeParam());
- if (!match(')')) {
- expect(',');
- }
- }
- if (match('...')) {
- lex();
- ret.rest = parseFunctionTypeParam();
- }
- return ret;
- }
- // The parsing of types roughly parallels the parsing of expressions, and
- // primary types are kind of like primary expressions...they're the
- // primitives with which other types are constructed.
- function parsePrimaryType() {
- var params = null, returnType = null,
- marker = markerCreate(), rest = null, tmp,
- typeParameters, token, type, isGroupedType = false;
- switch (lookahead.type) {
- case Token.Identifier:
- switch (lookahead.value) {
- case 'any':
- lex();
- return markerApply(marker, delegate.createAnyTypeAnnotation());
- case 'bool': // fallthrough
- case 'boolean':
- lex();
- return markerApply(marker, delegate.createBooleanTypeAnnotation());
- case 'number':
- lex();
- return markerApply(marker, delegate.createNumberTypeAnnotation());
- case 'string':
- lex();
- return markerApply(marker, delegate.createStringTypeAnnotation());
- }
- return markerApply(marker, parseGenericType());
- case Token.Punctuator:
- switch (lookahead.value) {
- case '{':
- return markerApply(marker, parseObjectType());
- case '[':
- return parseTupleType();
- case '<':
- typeParameters = parseTypeParameterDeclaration();
- expect('(');
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect('=>');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- case '(':
- lex();
- // Check to see if this is actually a grouped type
- if (!match(')') && !match('...')) {
- if (lookahead.type === Token.Identifier) {
- token = lookahead2();
- isGroupedType = token.value !== '?' && token.value !== ':';
- } else {
- isGroupedType = true;
- }
- }
- if (isGroupedType) {
- type = parseType();
- expect(')');
- // If we see a => next then someone was probably confused about
- // function types, so we can provide a better error message
- if (match('=>')) {
- throwError({}, Messages.ConfusedAboutFunctionType);
- }
- return type;
- }
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect('=>');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- null /* typeParameters */
- ));
- }
- break;
- case Token.Keyword:
- switch (lookahead.value) {
- case 'void':
- return markerApply(marker, parseVoidType());
- case 'typeof':
- return markerApply(marker, parseTypeofType());
- }
- break;
- case Token.StringLiteral:
- token = lex();
- if (token.octal) {
- throwError(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
- token
- ));
- }
- throwUnexpected(lookahead);
- }
- function parsePostfixType() {
- var marker = markerCreate(), t = parsePrimaryType();
- if (match('[')) {
- expect('[');
- expect(']');
- return markerApply(marker, delegate.createArrayTypeAnnotation(t));
- }
- return t;
- }
- function parsePrefixType() {
- var marker = markerCreate();
- if (match('?')) {
- lex();
- return markerApply(marker, delegate.createNullableTypeAnnotation(
- parsePrefixType()
- ));
- }
- return parsePostfixType();
- }
- function parseIntersectionType() {
- var marker = markerCreate(), type, types;
- type = parsePrefixType();
- types = [type];
- while (match('&')) {
- lex();
- types.push(parsePrefixType());
- }
- return types.length === 1 ?
- type :
- markerApply(marker, delegate.createIntersectionTypeAnnotation(
- types
- ));
- }
- function parseUnionType() {
- var marker = markerCreate(), type, types;
- type = parseIntersectionType();
- types = [type];
- while (match('|')) {
- lex();
- types.push(parseIntersectionType());
- }
- return types.length === 1 ?
- type :
- markerApply(marker, delegate.createUnionTypeAnnotation(
- types
- ));
- }
- function parseType() {
- var oldInType = state.inType, type;
- state.inType = true;
- type = parseUnionType();
- state.inType = oldInType;
- return type;
- }
- function parseTypeAnnotation() {
- var marker = markerCreate(), type;
- expect(':');
- type = parseType();
- return markerApply(marker, delegate.createTypeAnnotation(type));
- }
- function parseVariableIdentifier() {
- var marker = markerCreate(),
- token = lex();
- if (token.type !== Token.Identifier) {
- throwUnexpected(token);
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) {
- var marker = markerCreate(),
- ident = parseVariableIdentifier(),
- isOptionalParam = false;
- if (canBeOptionalParam && match('?')) {
- expect('?');
- isOptionalParam = true;
- }
- if (requireTypeAnnotation || match(':')) {
- ident.typeAnnotation = parseTypeAnnotation();
- ident = markerApply(marker, ident);
- }
- if (isOptionalParam) {
- ident.optional = true;
- ident = markerApply(marker, ident);
- }
- return ident;
- }
- function parseVariableDeclaration(kind) {
- var id,
- marker = markerCreate(),
- init = null,
- typeAnnotationMarker = markerCreate();
- if (match('{')) {
- id = parseObjectInitialiser();
- reinterpretAsAssignmentBindingPattern(id);
- if (match(':')) {
- id.typeAnnotation = parseTypeAnnotation();
- markerApply(typeAnnotationMarker, id);
- }
- } else if (match('[')) {
- id = parseArrayInitialiser();
- reinterpretAsAssignmentBindingPattern(id);
- if (match(':')) {
- id.typeAnnotation = parseTypeAnnotation();
- markerApply(typeAnnotationMarker, id);
- }
- } else {
- /* istanbul ignore next */
- id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
- // 12.2.1
- if (strict && isRestrictedWord(id.name)) {
- throwErrorTolerant({}, Messages.StrictVarName);
- }
- }
- if (kind === 'const') {
- if (!match('=')) {
- throwError({}, Messages.NoUninitializedConst);
- }
- expect('=');
- init = parseAssignmentExpression();
- } else if (match('=')) {
- lex();
- init = parseAssignmentExpression();
- }
- return markerApply(marker, delegate.createVariableDeclarator(id, init));
- }
- function parseVariableDeclarationList(kind) {
- var list = [];
- do {
- list.push(parseVariableDeclaration(kind));
- if (!match(',')) {
- break;
- }
- lex();
- } while (index < length);
- return list;
- }
- function parseVariableStatement() {
- var declarations, marker = markerCreate();
- expectKeyword('var');
- declarations = parseVariableDeclarationList();
- consumeSemicolon();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var'));
- }
- // kind may be `const` or `let`
- // Both are experimental and not in the specification yet.
- // see http://wiki.ecmascript.org/doku.php?id=harmony:const
- // and http://wiki.ecmascript.org/doku.php?id=harmony:let
- function parseConstLetDeclaration(kind) {
- var declarations, marker = markerCreate();
- expectKeyword(kind);
- declarations = parseVariableDeclarationList(kind);
- consumeSemicolon();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
- }
- // people.mozilla.org/~jorendorff/es6-draft.html
- function parseModuleSpecifier() {
- var marker = markerCreate(),
- specifier;
- if (lookahead.type !== Token.StringLiteral) {
- throwError({}, Messages.InvalidModuleSpecifier);
- }
- specifier = delegate.createModuleSpecifier(lookahead);
- lex();
- return markerApply(marker, specifier);
- }
- function parseExportBatchSpecifier() {
- var marker = markerCreate();
- expect('*');
- return markerApply(marker, delegate.createExportBatchSpecifier());
- }
- function parseExportSpecifier() {
- var id, name = null, marker = markerCreate(), from;
- if (matchKeyword('default')) {
- lex();
- id = markerApply(marker, delegate.createIdentifier('default'));
- // export {default} from "something";
- } else {
- id = parseVariableIdentifier();
- }
- if (matchContextualKeyword('as')) {
- lex();
- name = parseNonComputedProperty();
- }
- return markerApply(marker, delegate.createExportSpecifier(id, name));
- }
- function parseExportDeclaration() {
- var declaration = null,
- possibleIdentifierToken, sourceElement,
- isExportFromIdentifier,
- src = null, specifiers = [],
- marker = markerCreate();
- expectKeyword('export');
- if (matchKeyword('default')) {
- // covers:
- // export default ...
- lex();
- if (matchKeyword('function') || matchKeyword('class')) {
- possibleIdentifierToken = lookahead2();
- if (isIdentifierName(possibleIdentifierToken)) {
- // covers:
- // export default function foo () {}
- // export default class foo {}
- sourceElement = parseSourceElement();
- return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null));
- }
- // covers:
- // export default function () {}
- // export default class {}
- switch (lookahead.value) {
- case 'class':
- return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
- case 'function':
- return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
- }
- }
- if (matchContextualKeyword('from')) {
- throwError({}, Messages.UnexpectedToken, lookahead.value);
- }
- // covers:
- // export default {};
- // export default [];
- if (match('{')) {
- declaration = parseObjectInitialiser();
- } else if (match('[')) {
- declaration = parseArrayInitialiser();
- } else {
- declaration = parseAssignmentExpression();
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
- }
- // non-default export
- if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
- // covers:
- // export var f = 1;
- switch (lookahead.value) {
- case 'type':
- case 'let':
- case 'const':
- case 'var':
- case 'class':
- case 'function':
- return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
- }
- }
- if (match('*')) {
- // covers:
- // export * from "foo";
- specifiers.push(parseExportBatchSpecifier());
- if (!matchContextualKeyword('from')) {
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- }
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
- }
- expect('{');
- if (!match('}')) {
- do {
- isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
- specifiers.push(parseExportSpecifier());
- } while (match(',') && lex());
- }
- expect('}');
- if (matchContextualKeyword('from')) {
- // covering:
- // export {default} from "foo";
- // export {foo} from "foo";
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- } else if (isExportFromIdentifier) {
- // covering:
- // export {default}; // missing fromClause
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- } else {
- // cover
- // export {foo};
- consumeSemicolon();
- }
- return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
- }
- function parseImportSpecifier() {
- // import {<foo as bar>} ...;
- var id, name = null, marker = markerCreate();
- id = parseNonComputedProperty();
- if (matchContextualKeyword('as')) {
- lex();
- name = parseVariableIdentifier();
- }
- return markerApply(marker, delegate.createImportSpecifier(id, name));
- }
- function parseNamedImports() {
- var specifiers = [];
- // {foo, bar as bas}
- expect('{');
- if (!match('}')) {
- do {
- specifiers.push(parseImportSpecifier());
- } while (match(',') && lex());
- }
- expect('}');
- return specifiers;
- }
- function parseImportDefaultSpecifier() {
- // import <foo> ...;
- var id, marker = markerCreate();
- id = parseNonComputedProperty();
- return markerApply(marker, delegate.createImportDefaultSpecifier(id));
- }
- function parseImportNamespaceSpecifier() {
- // import <* as foo> ...;
- var id, marker = markerCreate();
- expect('*');
- if (!matchContextualKeyword('as')) {
- throwError({}, Messages.NoAsAfterImportNamespace);
- }
- lex();
- id = parseNonComputedProperty();
- return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
- }
- function parseImportDeclaration() {
- var specifiers, src, marker = markerCreate(), isType = false, token2;
- expectKeyword('import');
- if (matchContextualKeyword('type')) {
- token2 = lookahead2();
- if ((token2.type === Token.Identifier && token2.value !== 'from') ||
- (token2.type === Token.Punctuator &&
- (token2.value === '{' || token2.value === '*'))) {
- isType = true;
- lex();
- }
- }
- specifiers = [];
- if (lookahead.type === Token.StringLiteral) {
- // covers:
- // import "foo";
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
- }
- if (!matchKeyword('default') && isIdentifierName(lookahead)) {
- // covers:
- // import foo
- // import foo, ...
- specifiers.push(parseImportDefaultSpecifier());
- if (match(',')) {
- lex();
- }
- }
- if (match('*')) {
- // covers:
- // import foo, * as foo
- // import * as foo
- specifiers.push(parseImportNamespaceSpecifier());
- } else if (match('{')) {
- // covers:
- // import foo, {bar}
- // import {bar}
- specifiers = specifiers.concat(parseNamedImports());
- }
- if (!matchContextualKeyword('from')) {
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- }
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
- }
- // 12.3 Empty Statement
- function parseEmptyStatement() {
- var marker = markerCreate();
- expect(';');
- return markerApply(marker, delegate.createEmptyStatement());
- }
- // 12.4 Expression Statement
- function parseExpressionStatement() {
- var marker = markerCreate(), expr = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createExpressionStatement(expr));
- }
- // 12.5 If statement
- function parseIfStatement() {
- var test, consequent, alternate, marker = markerCreate();
- expectKeyword('if');
- expect('(');
- test = parseExpression();
- expect(')');
- consequent = parseStatement();
- if (matchKeyword('else')) {
- lex();
- alternate = parseStatement();
- } else {
- alternate = null;
- }
- return markerApply(marker, delegate.createIfStatement(test, consequent, alternate));
- }
- // 12.6 Iteration Statements
- function parseDoWhileStatement() {
- var body, test, oldInIteration, marker = markerCreate();
- expectKeyword('do');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- body = parseStatement();
- state.inIteration = oldInIteration;
- expectKeyword('while');
- expect('(');
- test = parseExpression();
- expect(')');
- if (match(';')) {
- lex();
- }
- return markerApply(marker, delegate.createDoWhileStatement(body, test));
- }
- function parseWhileStatement() {
- var test, body, oldInIteration, marker = markerCreate();
- expectKeyword('while');
- expect('(');
- test = parseExpression();
- expect(')');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- body = parseStatement();
- state.inIteration = oldInIteration;
- return markerApply(marker, delegate.createWhileStatement(test, body));
- }
- function parseForVariableDeclaration() {
- var marker = markerCreate(),
- token = lex(),
- declarations = parseVariableDeclarationList();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value));
- }
- function parseForStatement(opts) {
- var init, test, update, left, right, body, operator, oldInIteration,
- marker = markerCreate();
- init = test = update = null;
- expectKeyword('for');
- // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each
- if (matchContextualKeyword('each')) {
- throwError({}, Messages.EachNotAllowed);
- }
- expect('(');
- if (match(';')) {
- lex();
- } else {
- if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) {
- state.allowIn = false;
- init = parseForVariableDeclaration();
- state.allowIn = true;
- if (init.declarations.length === 1) {
- if (matchKeyword('in') || matchContextualKeyword('of')) {
- operator = lookahead;
- if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) {
- lex();
- left = init;
- right = parseExpression();
- init = null;
- }
- }
- }
- } else {
- state.allowIn = false;
- init = parseExpression();
- state.allowIn = true;
- if (matchContextualKeyword('of')) {
- operator = lex();
- left = init;
- right = parseExpression();
- init = null;
- } else if (matchKeyword('in')) {
- // LeftHandSideExpression
- if (!isAssignableLeftHandSide(init)) {
- throwError({}, Messages.InvalidLHSInForIn);
- }
- operator = lex();
- left = init;
- right = parseExpression();
- init = null;
- }
- }
- if (typeof left === 'undefined') {
- expect(';');
- }
- }
- if (typeof left === 'undefined') {
- if (!match(';')) {
- test = parseExpression();
- }
- expect(';');
- if (!match(')')) {
- update = parseExpression();
- }
- }
- expect(')');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- if (!(opts !== undefined && opts.ignoreBody)) {
- body = parseStatement();
- }
- state.inIteration = oldInIteration;
- if (typeof left === 'undefined') {
- return markerApply(marker, delegate.createForStatement(init, test, update, body));
- }
- if (operator.value === 'in') {
- return markerApply(marker, delegate.createForInStatement(left, right, body));
- }
- return markerApply(marker, delegate.createForOfStatement(left, right, body));
- }
- // 12.7 The continue statement
- function parseContinueStatement() {
- var label = null, marker = markerCreate();
- expectKeyword('continue');
- // Optimize the most common form: 'continue;'.
- if (source.charCodeAt(index) === 59) {
- lex();
- if (!state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(null));
- }
- if (peekLineTerminator()) {
- if (!state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(null));
- }
- if (lookahead.type === Token.Identifier) {
- label = parseVariableIdentifier();
- if (!state.labelSet.has(label.name)) {
- throwError({}, Messages.UnknownLabel, label.name);
- }
- }
- consumeSemicolon();
- if (label === null && !state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(label));
- }
- // 12.8 The break statement
- function parseBreakStatement() {
- var label = null, marker = markerCreate();
- expectKeyword('break');
- // Catch the very common case first: immediately a semicolon (char #59).
- if (source.charCodeAt(index) === 59) {
- lex();
- if (!(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(null));
- }
- if (peekLineTerminator()) {
- if (!(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(null));
- }
- if (lookahead.type === Token.Identifier) {
- label = parseVariableIdentifier();
- if (!state.labelSet.has(label.name)) {
- throwError({}, Messages.UnknownLabel, label.name);
- }
- }
- consumeSemicolon();
- if (label === null && !(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(label));
- }
- // 12.9 The return statement
- function parseReturnStatement() {
- var argument = null, marker = markerCreate();
- expectKeyword('return');
- if (!state.inFunctionBody) {
- throwErrorTolerant({}, Messages.IllegalReturn);
- }
- // 'return' followed by a space and an identifier is very common.
- if (source.charCodeAt(index) === 32) {
- if (isIdentifierStart(source.charCodeAt(index + 1))) {
- argument = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createReturnStatement(argument));
- }
- }
- if (peekLineTerminator()) {
- return markerApply(marker, delegate.createReturnStatement(null));
- }
- if (!match(';')) {
- if (!match('}') && lookahead.type !== Token.EOF) {
- argument = parseExpression();
- }
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createReturnStatement(argument));
- }
- // 12.10 The with statement
- function parseWithStatement() {
- var object, body, marker = markerCreate();
- if (strict) {
- throwErrorTolerant({}, Messages.StrictModeWith);
- }
- expectKeyword('with');
- expect('(');
- object = parseExpression();
- expect(')');
- body = parseStatement();
- return markerApply(marker, delegate.createWithStatement(object, body));
- }
- // 12.10 The swith statement
- function parseSwitchCase() {
- var test,
- consequent = [],
- sourceElement,
- marker = markerCreate();
- if (matchKeyword('default')) {
- lex();
- test = null;
- } else {
- expectKeyword('case');
- test = parseExpression();
- }
- expect(':');
- while (index < length) {
- if (match('}') || matchKeyword('default') || matchKeyword('case')) {
- break;
- }
- sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- consequent.push(sourceElement);
- }
- return markerApply(marker, delegate.createSwitchCase(test, consequent));
- }
- function parseSwitchStatement() {
- var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate();
- expectKeyword('switch');
- expect('(');
- discriminant = parseExpression();
- expect(')');
- expect('{');
- cases = [];
- if (match('}')) {
- lex();
- return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
- }
- oldInSwitch = state.inSwitch;
- state.inSwitch = true;
- defaultFound = false;
- while (index < length) {
- if (match('}')) {
- break;
- }
- clause = parseSwitchCase();
- if (clause.test === null) {
- if (defaultFound) {
- throwError({}, Messages.MultipleDefaultsInSwitch);
- }
- defaultFound = true;
- }
- cases.push(clause);
- }
- state.inSwitch = oldInSwitch;
- expect('}');
- return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
- }
- // 12.13 The throw statement
- function parseThrowStatement() {
- var argument, marker = markerCreate();
- expectKeyword('throw');
- if (peekLineTerminator()) {
- throwError({}, Messages.NewlineAfterThrow);
- }
- argument = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createThrowStatement(argument));
- }
- // 12.14 The try statement
- function parseCatchClause() {
- var param, body, marker = markerCreate();
- expectKeyword('catch');
- expect('(');
- if (match(')')) {
- throwUnexpected(lookahead);
- }
- param = parseExpression();
- // 12.14.1
- if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) {
- throwErrorTolerant({}, Messages.StrictCatchVariable);
- }
- expect(')');
- body = parseBlock();
- return markerApply(marker, delegate.createCatchClause(param, body));
- }
- function parseTryStatement() {
- var block, handlers = [], finalizer = null, marker = markerCreate();
- expectKeyword('try');
- block = parseBlock();
- if (matchKeyword('catch')) {
- handlers.push(parseCatchClause());
- }
- if (matchKeyword('finally')) {
- lex();
- finalizer = parseBlock();
- }
- if (handlers.length === 0 && !finalizer) {
- throwError({}, Messages.NoCatchOrFinally);
- }
- return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer));
- }
- // 12.15 The debugger statement
- function parseDebuggerStatement() {
- var marker = markerCreate();
- expectKeyword('debugger');
- consumeSemicolon();
- return markerApply(marker, delegate.createDebuggerStatement());
- }
- // 12 Statements
- function parseStatement() {
- var type = lookahead.type,
- marker,
- expr,
- labeledBody;
- if (type === Token.EOF) {
- throwUnexpected(lookahead);
- }
- if (type === Token.Punctuator) {
- switch (lookahead.value) {
- case ';':
- return parseEmptyStatement();
- case '{':
- return parseBlock();
- case '(':
- return parseExpressionStatement();
- default:
- break;
- }
- }
- if (type === Token.Keyword) {
- switch (lookahead.value) {
- case 'break':
- return parseBreakStatement();
- case 'continue':
- return parseContinueStatement();
- case 'debugger':
- return parseDebuggerStatement();
- case 'do':
- return parseDoWhileStatement();
- case 'for':
- return parseForStatement();
- case 'function':
- return parseFunctionDeclaration();
- case 'class':
- return parseClassDeclaration();
- case 'if':
- return parseIfStatement();
- case 'return':
- return parseReturnStatement();
- case 'switch':
- return parseSwitchStatement();
- case 'throw':
- return parseThrowStatement();
- case 'try':
- return parseTryStatement();
- case 'var':
- return parseVariableStatement();
- case 'while':
- return parseWhileStatement();
- case 'with':
- return parseWithStatement();
- default:
- break;
- }
- }
- if (matchAsyncFuncExprOrDecl()) {
- return parseFunctionDeclaration();
- }
- marker = markerCreate();
- expr = parseExpression();
- // 12.12 Labelled Statements
- if ((expr.type === Syntax.Identifier) && match(':')) {
- lex();
- if (state.labelSet.has(expr.name)) {
- throwError({}, Messages.Redeclaration, 'Label', expr.name);
- }
- state.labelSet.set(expr.name, true);
- labeledBody = parseStatement();
- state.labelSet.delete(expr.name);
- return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createExpressionStatement(expr));
- }
- // 13 Function Definition
- function parseConciseBody() {
- if (match('{')) {
- return parseFunctionSourceElements();
- }
- return parseAssignmentExpression();
- }
- function parseFunctionSourceElements() {
- var sourceElement, sourceElements = [], token, directive, firstRestricted,
- oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount,
- marker = markerCreate();
- expect('{');
- while (index < length) {
- if (lookahead.type !== Token.StringLiteral) {
- break;
- }
- token = lookahead;
- sourceElement = parseSourceElement();
- sourceElements.push(sourceElement);
- if (sourceElement.expression.type !== Syntax.Literal) {
- // this is not directive
- break;
- }
- directive = source.slice(token.range[0] + 1, token.range[1] - 1);
- if (directive === 'use strict') {
- strict = true;
- if (firstRestricted) {
- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
- }
- } else {
- if (!firstRestricted && token.octal) {
- firstRestricted = token;
- }
- }
- }
- oldLabelSet = state.labelSet;
- oldInIteration = state.inIteration;
- oldInSwitch = state.inSwitch;
- oldInFunctionBody = state.inFunctionBody;
- oldParenthesizedCount = state.parenthesizedCount;
- state.labelSet = new StringMap();
- state.inIteration = false;
- state.inSwitch = false;
- state.inFunctionBody = true;
- state.parenthesizedCount = 0;
- while (index < length) {
- if (match('}')) {
- break;
- }
- sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- sourceElements.push(sourceElement);
- }
- expect('}');
- state.labelSet = oldLabelSet;
- state.inIteration = oldInIteration;
- state.inSwitch = oldInSwitch;
- state.inFunctionBody = oldInFunctionBody;
- state.parenthesizedCount = oldParenthesizedCount;
- return markerApply(marker, delegate.createBlockStatement(sourceElements));
- }
- function validateParam(options, param, name) {
- if (strict) {
- if (isRestrictedWord(name)) {
- options.stricted = param;
- options.message = Messages.StrictParamName;
- }
- if (options.paramSet.has(name)) {
- options.stricted = param;
- options.message = Messages.StrictParamDupe;
- }
- } else if (!options.firstRestricted) {
- if (isRestrictedWord(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictParamName;
- } else if (isStrictModeReservedWord(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictReservedWord;
- } else if (options.paramSet.has(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictParamDupe;
- }
- }
- options.paramSet.set(name, true);
- }
- function parseParam(options) {
- var marker, token, rest, param, def;
- token = lookahead;
- if (token.value === '...') {
- token = lex();
- rest = true;
- }
- if (match('[')) {
- marker = markerCreate();
- param = parseArrayInitialiser();
- reinterpretAsDestructuredParameter(options, param);
- if (match(':')) {
- param.typeAnnotation = parseTypeAnnotation();
- markerApply(marker, param);
- }
- } else if (match('{')) {
- marker = markerCreate();
- if (rest) {
- throwError({}, Messages.ObjectPatternAsRestParameter);
- }
- param = parseObjectInitialiser();
- reinterpretAsDestructuredParameter(options, param);
- if (match(':')) {
- param.typeAnnotation = parseTypeAnnotation();
- markerApply(marker, param);
- }
- } else {
- param =
- rest
- ? parseTypeAnnotatableIdentifier(
- false, /* requireTypeAnnotation */
- false /* canBeOptionalParam */
- )
- : parseTypeAnnotatableIdentifier(
- false, /* requireTypeAnnotation */
- true /* canBeOptionalParam */
- );
- validateParam(options, token, token.value);
- }
- if (match('=')) {
- if (rest) {
- throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
- }
- lex();
- def = parseAssignmentExpression();
- ++options.defaultCount;
- }
- if (rest) {
- if (!match(')')) {
- throwError({}, Messages.ParameterAfterRestParameter);
- }
- options.rest = param;
- return false;
- }
- options.params.push(param);
- options.defaults.push(def);
- return !match(')');
- }
- function parseParams(firstRestricted) {
- var options, marker = markerCreate();
- options = {
- params: [],
- defaultCount: 0,
- defaults: [],
- rest: null,
- firstRestricted: firstRestricted
- };
- expect('(');
- if (!match(')')) {
- options.paramSet = new StringMap();
- while (index < length) {
- if (!parseParam(options)) {
- break;
- }
- expect(',');
- }
- }
- expect(')');
- if (options.defaultCount === 0) {
- options.defaults = [];
- }
- if (match(':')) {
- options.returnType = parseTypeAnnotation();
- }
- return markerApply(marker, options);
- }
- function parseFunctionDeclaration() {
- var id, body, token, tmp, firstRestricted, message, generator, isAsync,
- previousStrict, previousYieldAllowed, previousAwaitAllowed,
- marker = markerCreate(), typeParameters;
- isAsync = false;
- if (matchAsync()) {
- lex();
- isAsync = true;
- }
- expectKeyword('function');
- generator = false;
- if (match('*')) {
- lex();
- generator = true;
- }
- token = lookahead;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (strict) {
- if (isRestrictedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictFunctionName);
- }
- } else {
- if (isRestrictedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictFunctionName;
- } else if (isStrictModeReservedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictReservedWord;
- }
- }
- tmp = parseParams(firstRestricted);
- firstRestricted = tmp.firstRestricted;
- if (tmp.message) {
- message = tmp.message;
- }
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = isAsync;
- body = parseFunctionSourceElements();
- if (strict && firstRestricted) {
- throwError(firstRestricted, message);
- }
- if (strict && tmp.stricted) {
- throwErrorTolerant(tmp.stricted, message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(
- marker,
- delegate.createFunctionDeclaration(
- id,
- tmp.params,
- tmp.defaults,
- body,
- tmp.rest,
- generator,
- false,
- isAsync,
- tmp.returnType,
- typeParameters
- )
- );
- }
- function parseFunctionExpression() {
- var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
- previousStrict, previousYieldAllowed, previousAwaitAllowed,
- marker = markerCreate(), typeParameters;
- isAsync = false;
- if (matchAsync()) {
- lex();
- isAsync = true;
- }
- expectKeyword('function');
- generator = false;
- if (match('*')) {
- lex();
- generator = true;
- }
- if (!match('(')) {
- if (!match('<')) {
- token = lookahead;
- id = parseVariableIdentifier();
- if (strict) {
- if (isRestrictedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictFunctionName);
- }
- } else {
- if (isRestrictedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictFunctionName;
- } else if (isStrictModeReservedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictReservedWord;
- }
- }
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- }
- tmp = parseParams(firstRestricted);
- firstRestricted = tmp.firstRestricted;
- if (tmp.message) {
- message = tmp.message;
- }
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = isAsync;
- body = parseFunctionSourceElements();
- if (strict && firstRestricted) {
- throwError(firstRestricted, message);
- }
- if (strict && tmp.stricted) {
- throwErrorTolerant(tmp.stricted, message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(
- marker,
- delegate.createFunctionExpression(
- id,
- tmp.params,
- tmp.defaults,
- body,
- tmp.rest,
- generator,
- false,
- isAsync,
- tmp.returnType,
- typeParameters
- )
- );
- }
- function parseYieldExpression() {
- var delegateFlag, expr, marker = markerCreate();
- expectKeyword('yield', !strict);
- delegateFlag = false;
- if (match('*')) {
- lex();
- delegateFlag = true;
- }
- expr = parseAssignmentExpression();
- return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
- }
- function parseAwaitExpression() {
- var expr, marker = markerCreate();
- expectContextualKeyword('await');
- expr = parseAssignmentExpression();
- return markerApply(marker, delegate.createAwaitExpression(expr));
- }
- // 14 Functions and classes
- // 14.1 Functions is defined above (13 in ES5)
- // 14.2 Arrow Functions Definitions is defined in (7.3 assignments)
- // 14.3 Method Definitions
- // 14.3.7
- function specialMethod(methodDefinition) {
- return methodDefinition.kind === 'get' ||
- methodDefinition.kind === 'set' ||
- methodDefinition.value.generator;
- }
- function parseMethodDefinition(key, isStatic, generator, computed) {
- var token, param, propType,
- isAsync, typeParameters, tokenValue, returnType;
- propType = isStatic ? ClassPropertyType.static : ClassPropertyType.prototype;
- if (generator) {
- return delegate.createMethodDefinition(
- propType,
- '',
- key,
- parsePropertyMethodFunction({ generator: true }),
- computed
- );
- }
- tokenValue = key.type === 'Identifier' && key.name;
- if (tokenValue === 'get' && !match('(')) {
- key = parseObjectPropertyKey();
- expect('(');
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return delegate.createMethodDefinition(
- propType,
- 'get',
- key,
- parsePropertyFunction({ generator: false, returnType: returnType }),
- computed
- );
- }
- if (tokenValue === 'set' && !match('(')) {
- key = parseObjectPropertyKey();
- expect('(');
- token = lookahead;
- param = [ parseTypeAnnotatableIdentifier() ];
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return delegate.createMethodDefinition(
- propType,
- 'set',
- key,
- parsePropertyFunction({
- params: param,
- generator: false,
- name: token,
- returnType: returnType
- }),
- computed
- );
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- isAsync = tokenValue === 'async' && !match('(');
- if (isAsync) {
- key = parseObjectPropertyKey();
- }
- return delegate.createMethodDefinition(
- propType,
- '',
- key,
- parsePropertyMethodFunction({
- generator: false,
- async: isAsync,
- typeParameters: typeParameters
- }),
- computed
- );
- }
- function parseClassProperty(key, computed, isStatic) {
- var typeAnnotation;
- typeAnnotation = parseTypeAnnotation();
- expect(';');
- return delegate.createClassProperty(
- key,
- typeAnnotation,
- computed,
- isStatic
- );
- }
- function parseClassElement() {
- var computed = false, generator = false, key, marker = markerCreate(),
- isStatic = false, possiblyOpenBracketToken;
- if (match(';')) {
- lex();
- return undefined;
- }
- if (lookahead.value === 'static') {
- lex();
- isStatic = true;
- }
- if (match('*')) {
- lex();
- generator = true;
- }
- possiblyOpenBracketToken = lookahead;
- if (matchContextualKeyword('get') || matchContextualKeyword('set')) {
- possiblyOpenBracketToken = lookahead2();
- }
- if (possiblyOpenBracketToken.type === Token.Punctuator
- && possiblyOpenBracketToken.value === '[') {
- computed = true;
- }
- key = parseObjectPropertyKey();
- if (!generator && lookahead.value === ':') {
- return markerApply(marker, parseClassProperty(key, computed, isStatic));
- }
- return markerApply(marker, parseMethodDefinition(
- key,
- isStatic,
- generator,
- computed
- ));
- }
- function parseClassBody() {
- var classElement, classElements = [], existingProps = {},
- marker = markerCreate(), propName, propType;
- existingProps[ClassPropertyType.static] = new StringMap();
- existingProps[ClassPropertyType.prototype] = new StringMap();
- expect('{');
- while (index < length) {
- if (match('}')) {
- break;
- }
- classElement = parseClassElement(existingProps);
- if (typeof classElement !== 'undefined') {
- classElements.push(classElement);
- propName = !classElement.computed && getFieldName(classElement.key);
- if (propName !== false) {
- propType = classElement.static ?
- ClassPropertyType.static :
- ClassPropertyType.prototype;
- if (classElement.type === Syntax.MethodDefinition) {
- if (propName === 'constructor' && !classElement.static) {
- if (specialMethod(classElement)) {
- throwError(classElement, Messages.IllegalClassConstructorProperty);
- }
- if (existingProps[ClassPropertyType.prototype].has('constructor')) {
- throwError(classElement.key, Messages.IllegalDuplicateClassProperty);
- }
- }
- existingProps[propType].set(propName, true);
- }
- }
- }
- }
- expect('}');
- return markerApply(marker, delegate.createClassBody(classElements));
- }
- function parseClassImplements() {
- var id, implemented = [], marker, typeParameters;
- if (strict) {
- expectKeyword('implements');
- } else {
- expectContextualKeyword('implements');
- }
- while (index < length) {
- marker = markerCreate();
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- } else {
- typeParameters = null;
- }
- implemented.push(markerApply(marker, delegate.createClassImplements(
- id,
- typeParameters
- )));
- if (!match(',')) {
- break;
- }
- expect(',');
- }
- return implemented;
- }
- function parseClassExpression() {
- var id, implemented, previousYieldAllowed, superClass = null,
- superTypeParameters, marker = markerCreate(), typeParameters,
- matchImplements;
- expectKeyword('class');
- matchImplements =
- strict
- ? matchKeyword('implements')
- : matchContextualKeyword('implements');
- if (!matchKeyword('extends') && !matchImplements && !match('{')) {
- id = parseVariableIdentifier();
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- superClass = parseLeftHandSideExpressionAllowCall();
- if (match('<')) {
- superTypeParameters = parseTypeParameterInstantiation();
- }
- state.yieldAllowed = previousYieldAllowed;
- }
- if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
- implemented = parseClassImplements();
- }
- return markerApply(marker, delegate.createClassExpression(
- id,
- superClass,
- parseClassBody(),
- typeParameters,
- superTypeParameters,
- implemented
- ));
- }
- function parseClassDeclaration() {
- var id, implemented, previousYieldAllowed, superClass = null,
- superTypeParameters, marker = markerCreate(), typeParameters;
- expectKeyword('class');
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- superClass = parseLeftHandSideExpressionAllowCall();
- if (match('<')) {
- superTypeParameters = parseTypeParameterInstantiation();
- }
- state.yieldAllowed = previousYieldAllowed;
- }
- if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
- implemented = parseClassImplements();
- }
- return markerApply(marker, delegate.createClassDeclaration(
- id,
- superClass,
- parseClassBody(),
- typeParameters,
- superTypeParameters,
- implemented
- ));
- }
- // 15 Program
- function parseSourceElement() {
- var token;
- if (lookahead.type === Token.Keyword) {
- switch (lookahead.value) {
- case 'const':
- case 'let':
- return parseConstLetDeclaration(lookahead.value);
- case 'function':
- return parseFunctionDeclaration();
- case 'export':
- throwErrorTolerant({}, Messages.IllegalExportDeclaration);
- return parseExportDeclaration();
- case 'import':
- throwErrorTolerant({}, Messages.IllegalImportDeclaration);
- return parseImportDeclaration();
- case 'interface':
- if (lookahead2().type === Token.Identifier) {
- return parseInterface();
- }
- return parseStatement();
- default:
- return parseStatement();
- }
- }
- if (matchContextualKeyword('type')
- && lookahead2().type === Token.Identifier) {
- return parseTypeAlias();
- }
- if (matchContextualKeyword('interface')
- && lookahead2().type === Token.Identifier) {
- return parseInterface();
- }
- if (matchContextualKeyword('declare')) {
- token = lookahead2();
- if (token.type === Token.Keyword) {
- switch (token.value) {
- case 'class':
- return parseDeclareClass();
- case 'function':
- return parseDeclareFunction();
- case 'var':
- return parseDeclareVariable();
- }
- } else if (token.type === Token.Identifier
- && token.value === 'module') {
- return parseDeclareModule();
- }
- }
- if (lookahead.type !== Token.EOF) {
- return parseStatement();
- }
- }
- function parseProgramElement() {
- var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule';
- if (isModule && lookahead.type === Token.Keyword) {
- switch (lookahead.value) {
- case 'export':
- return parseExportDeclaration();
- case 'import':
- return parseImportDeclaration();
- }
- }
- return parseSourceElement();
- }
- function parseProgramElements() {
- var sourceElement, sourceElements = [], token, directive, firstRestricted;
- while (index < length) {
- token = lookahead;
- if (token.type !== Token.StringLiteral) {
- break;
- }
- sourceElement = parseProgramElement();
- sourceElements.push(sourceElement);
- if (sourceElement.expression.type !== Syntax.Literal) {
- // this is not directive
- break;
- }
- directive = source.slice(token.range[0] + 1, token.range[1] - 1);
- if (directive === 'use strict') {
- strict = true;
- if (firstRestricted) {
- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
- }
- } else {
- if (!firstRestricted && token.octal) {
- firstRestricted = token;
- }
- }
- }
- while (index < length) {
- sourceElement = parseProgramElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- sourceElements.push(sourceElement);
- }
- return sourceElements;
- }
- function parseProgram() {
- var body, marker = markerCreate();
- strict = extra.sourceType === 'module';
- peek();
- body = parseProgramElements();
- return markerApply(marker, delegate.createProgram(body));
- }
- // 16 JSX
- XHTMLEntities = {
- quot: '\u0022',
- amp: '&',
- apos: '\u0027',
- lt: '<',
- gt: '>',
- nbsp: '\u00A0',
- iexcl: '\u00A1',
- cent: '\u00A2',
- pound: '\u00A3',
- curren: '\u00A4',
- yen: '\u00A5',
- brvbar: '\u00A6',
- sect: '\u00A7',
- uml: '\u00A8',
- copy: '\u00A9',
- ordf: '\u00AA',
- laquo: '\u00AB',
- not: '\u00AC',
- shy: '\u00AD',
- reg: '\u00AE',
- macr: '\u00AF',
- deg: '\u00B0',
- plusmn: '\u00B1',
- sup2: '\u00B2',
- sup3: '\u00B3',
- acute: '\u00B4',
- micro: '\u00B5',
- para: '\u00B6',
- middot: '\u00B7',
- cedil: '\u00B8',
- sup1: '\u00B9',
- ordm: '\u00BA',
- raquo: '\u00BB',
- frac14: '\u00BC',
- frac12: '\u00BD',
- frac34: '\u00BE',
- iquest: '\u00BF',
- Agrave: '\u00C0',
- Aacute: '\u00C1',
- Acirc: '\u00C2',
- Atilde: '\u00C3',
- Auml: '\u00C4',
- Aring: '\u00C5',
- AElig: '\u00C6',
- Ccedil: '\u00C7',
- Egrave: '\u00C8',
- Eacute: '\u00C9',
- Ecirc: '\u00CA',
- Euml: '\u00CB',
- Igrave: '\u00CC',
- Iacute: '\u00CD',
- Icirc: '\u00CE',
- Iuml: '\u00CF',
- ETH: '\u00D0',
- Ntilde: '\u00D1',
- Ograve: '\u00D2',
- Oacute: '\u00D3',
- Ocirc: '\u00D4',
- Otilde: '\u00D5',
- Ouml: '\u00D6',
- times: '\u00D7',
- Oslash: '\u00D8',
- Ugrave: '\u00D9',
- Uacute: '\u00DA',
- Ucirc: '\u00DB',
- Uuml: '\u00DC',
- Yacute: '\u00DD',
- THORN: '\u00DE',
- szlig: '\u00DF',
- agrave: '\u00E0',
- aacute: '\u00E1',
- acirc: '\u00E2',
- atilde: '\u00E3',
- auml: '\u00E4',
- aring: '\u00E5',
- aelig: '\u00E6',
- ccedil: '\u00E7',
- egrave: '\u00E8',
- eacute: '\u00E9',
- ecirc: '\u00EA',
- euml: '\u00EB',
- igrave: '\u00EC',
- iacute: '\u00ED',
- icirc: '\u00EE',
- iuml: '\u00EF',
- eth: '\u00F0',
- ntilde: '\u00F1',
- ograve: '\u00F2',
- oacute: '\u00F3',
- ocirc: '\u00F4',
- otilde: '\u00F5',
- ouml: '\u00F6',
- divide: '\u00F7',
- oslash: '\u00F8',
- ugrave: '\u00F9',
- uacute: '\u00FA',
- ucirc: '\u00FB',
- uuml: '\u00FC',
- yacute: '\u00FD',
- thorn: '\u00FE',
- yuml: '\u00FF',
- OElig: '\u0152',
- oelig: '\u0153',
- Scaron: '\u0160',
- scaron: '\u0161',
- Yuml: '\u0178',
- fnof: '\u0192',
- circ: '\u02C6',
- tilde: '\u02DC',
- Alpha: '\u0391',
- Beta: '\u0392',
- Gamma: '\u0393',
- Delta: '\u0394',
- Epsilon: '\u0395',
- Zeta: '\u0396',
- Eta: '\u0397',
- Theta: '\u0398',
- Iota: '\u0399',
- Kappa: '\u039A',
- Lambda: '\u039B',
- Mu: '\u039C',
- Nu: '\u039D',
- Xi: '\u039E',
- Omicron: '\u039F',
- Pi: '\u03A0',
- Rho: '\u03A1',
- Sigma: '\u03A3',
- Tau: '\u03A4',
- Upsilon: '\u03A5',
- Phi: '\u03A6',
- Chi: '\u03A7',
- Psi: '\u03A8',
- Omega: '\u03A9',
- alpha: '\u03B1',
- beta: '\u03B2',
- gamma: '\u03B3',
- delta: '\u03B4',
- epsilon: '\u03B5',
- zeta: '\u03B6',
- eta: '\u03B7',
- theta: '\u03B8',
- iota: '\u03B9',
- kappa: '\u03BA',
- lambda: '\u03BB',
- mu: '\u03BC',
- nu: '\u03BD',
- xi: '\u03BE',
- omicron: '\u03BF',
- pi: '\u03C0',
- rho: '\u03C1',
- sigmaf: '\u03C2',
- sigma: '\u03C3',
- tau: '\u03C4',
- upsilon: '\u03C5',
- phi: '\u03C6',
- chi: '\u03C7',
- psi: '\u03C8',
- omega: '\u03C9',
- thetasym: '\u03D1',
- upsih: '\u03D2',
- piv: '\u03D6',
- ensp: '\u2002',
- emsp: '\u2003',
- thinsp: '\u2009',
- zwnj: '\u200C',
- zwj: '\u200D',
- lrm: '\u200E',
- rlm: '\u200F',
- ndash: '\u2013',
- mdash: '\u2014',
- lsquo: '\u2018',
- rsquo: '\u2019',
- sbquo: '\u201A',
- ldquo: '\u201C',
- rdquo: '\u201D',
- bdquo: '\u201E',
- dagger: '\u2020',
- Dagger: '\u2021',
- bull: '\u2022',
- hellip: '\u2026',
- permil: '\u2030',
- prime: '\u2032',
- Prime: '\u2033',
- lsaquo: '\u2039',
- rsaquo: '\u203A',
- oline: '\u203E',
- frasl: '\u2044',
- euro: '\u20AC',
- image: '\u2111',
- weierp: '\u2118',
- real: '\u211C',
- trade: '\u2122',
- alefsym: '\u2135',
- larr: '\u2190',
- uarr: '\u2191',
- rarr: '\u2192',
- darr: '\u2193',
- harr: '\u2194',
- crarr: '\u21B5',
- lArr: '\u21D0',
- uArr: '\u21D1',
- rArr: '\u21D2',
- dArr: '\u21D3',
- hArr: '\u21D4',
- forall: '\u2200',
- part: '\u2202',
- exist: '\u2203',
- empty: '\u2205',
- nabla: '\u2207',
- isin: '\u2208',
- notin: '\u2209',
- ni: '\u220B',
- prod: '\u220F',
- sum: '\u2211',
- minus: '\u2212',
- lowast: '\u2217',
- radic: '\u221A',
- prop: '\u221D',
- infin: '\u221E',
- ang: '\u2220',
- and: '\u2227',
- or: '\u2228',
- cap: '\u2229',
- cup: '\u222A',
- 'int': '\u222B',
- there4: '\u2234',
- sim: '\u223C',
- cong: '\u2245',
- asymp: '\u2248',
- ne: '\u2260',
- equiv: '\u2261',
- le: '\u2264',
- ge: '\u2265',
- sub: '\u2282',
- sup: '\u2283',
- nsub: '\u2284',
- sube: '\u2286',
- supe: '\u2287',
- oplus: '\u2295',
- otimes: '\u2297',
- perp: '\u22A5',
- sdot: '\u22C5',
- lceil: '\u2308',
- rceil: '\u2309',
- lfloor: '\u230A',
- rfloor: '\u230B',
- lang: '\u2329',
- rang: '\u232A',
- loz: '\u25CA',
- spades: '\u2660',
- clubs: '\u2663',
- hearts: '\u2665',
- diams: '\u2666'
- };
- function getQualifiedJSXName(object) {
- if (object.type === Syntax.JSXIdentifier) {
- return object.name;
- }
- if (object.type === Syntax.JSXNamespacedName) {
- return object.namespace.name + ':' + object.name.name;
- }
- /* istanbul ignore else */
- if (object.type === Syntax.JSXMemberExpression) {
- return (
- getQualifiedJSXName(object.object) + '.' +
- getQualifiedJSXName(object.property)
- );
- }
- /* istanbul ignore next */
- throwUnexpected(object);
- }
- function isJSXIdentifierStart(ch) {
- // exclude backslash (\)
- return (ch !== 92) && isIdentifierStart(ch);
- }
- function isJSXIdentifierPart(ch) {
- // exclude backslash (\) and add hyphen (-)
- return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
- }
- function scanJSXIdentifier() {
- var ch, start, value = '';
- start = index;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (!isJSXIdentifierPart(ch)) {
- break;
- }
- value += source[index++];
- }
- return {
- type: Token.JSXIdentifier,
- value: value,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanJSXEntity() {
- var ch, str = '', start = index, count = 0, code;
- ch = source[index];
- assert(ch === '&', 'Entity must start with an ampersand');
- index++;
- while (index < length && count++ < 10) {
- ch = source[index++];
- if (ch === ';') {
- break;
- }
- str += ch;
- }
- // Well-formed entity (ending was found).
- if (ch === ';') {
- // Numeric entity.
- if (str[0] === '#') {
- if (str[1] === 'x') {
- code = +('0' + str.substr(1));
- } else {
- // Removing leading zeros in order to avoid treating as octal in old browsers.
- code = +str.substr(1).replace(Regex.LeadingZeros, '');
- }
- if (!isNaN(code)) {
- return String.fromCharCode(code);
- }
- /* istanbul ignore else */
- } else if (XHTMLEntities[str]) {
- return XHTMLEntities[str];
- }
- }
- // Treat non-entity sequences as regular text.
- index = start + 1;
- return '&';
- }
- function scanJSXText(stopChars) {
- var ch, str = '', start;
- start = index;
- while (index < length) {
- ch = source[index];
- if (stopChars.indexOf(ch) !== -1) {
- break;
- }
- if (ch === '&') {
- str += scanJSXEntity();
- } else {
- index++;
- if (ch === '\r' && source[index] === '\n') {
- str += ch;
- ch = source[index];
- index++;
- }
- if (isLineTerminator(ch.charCodeAt(0))) {
- ++lineNumber;
- lineStart = index;
- }
- str += ch;
- }
- }
- return {
- type: Token.JSXText,
- value: str,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanJSXStringLiteral() {
- var innerToken, quote, start;
- quote = source[index];
- assert((quote === '\'' || quote === '"'),
- 'String literal must starts with a quote');
- start = index;
- ++index;
- innerToken = scanJSXText([quote]);
- if (quote !== source[index]) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- innerToken.range = [start, index];
- return innerToken;
- }
- /**
- * Between JSX opening and closing tags (e.g. <foo>HERE</foo>), anything that
- * is not another JSX tag and is not an expression wrapped by {} is text.
- */
- function advanceJSXChild() {
- var ch = source.charCodeAt(index);
- // '<' 60, '>' 62, '{' 123, '}' 125
- if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
- return scanJSXText(['<', '>', '{', '}']);
- }
- return scanPunctuator();
- }
- function parseJSXIdentifier() {
- var token, marker = markerCreate();
- if (lookahead.type !== Token.JSXIdentifier) {
- throwUnexpected(lookahead);
- }
- token = lex();
- return markerApply(marker, delegate.createJSXIdentifier(token.value));
- }
- function parseJSXNamespacedName() {
- var namespace, name, marker = markerCreate();
- namespace = parseJSXIdentifier();
- expect(':');
- name = parseJSXIdentifier();
- return markerApply(marker, delegate.createJSXNamespacedName(namespace, name));
- }
- function parseJSXMemberExpression() {
- var marker = markerCreate(),
- expr = parseJSXIdentifier();
- while (match('.')) {
- lex();
- expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier()));
- }
- return expr;
- }
- function parseJSXElementName() {
- if (lookahead2().value === ':') {
- return parseJSXNamespacedName();
- }
- if (lookahead2().value === '.') {
- return parseJSXMemberExpression();
- }
- return parseJSXIdentifier();
- }
- function parseJSXAttributeName() {
- if (lookahead2().value === ':') {
- return parseJSXNamespacedName();
- }
- return parseJSXIdentifier();
- }
- function parseJSXAttributeValue() {
- var value, marker;
- if (match('{')) {
- value = parseJSXExpressionContainer();
- if (value.expression.type === Syntax.JSXEmptyExpression) {
- throwError(
- value,
- 'JSX attributes must only be assigned a non-empty ' +
- 'expression'
- );
- }
- } else if (match('<')) {
- value = parseJSXElement();
- } else if (lookahead.type === Token.JSXText) {
- marker = markerCreate();
- value = markerApply(marker, delegate.createLiteral(lex()));
- } else {
- throwError({}, Messages.InvalidJSXAttributeValue);
- }
- return value;
- }
- function parseJSXEmptyExpression() {
- var marker = markerCreatePreserveWhitespace();
- while (source.charAt(index) !== '}') {
- index++;
- }
- return markerApply(marker, delegate.createJSXEmptyExpression());
- }
- function parseJSXExpressionContainer() {
- var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = false;
- expect('{');
- if (match('}')) {
- expression = parseJSXEmptyExpression();
- } else {
- expression = parseExpression();
- }
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- expect('}');
- return markerApply(marker, delegate.createJSXExpressionContainer(expression));
- }
- function parseJSXSpreadAttribute() {
- var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = false;
- expect('{');
- expect('...');
- expression = parseAssignmentExpression();
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- expect('}');
- return markerApply(marker, delegate.createJSXSpreadAttribute(expression));
- }
- function parseJSXAttribute() {
- var name, marker;
- if (match('{')) {
- return parseJSXSpreadAttribute();
- }
- marker = markerCreate();
- name = parseJSXAttributeName();
- // HTML empty attribute
- if (match('=')) {
- lex();
- return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue()));
- }
- return markerApply(marker, delegate.createJSXAttribute(name));
- }
- function parseJSXChild() {
- var token, marker;
- if (match('{')) {
- token = parseJSXExpressionContainer();
- } else if (lookahead.type === Token.JSXText) {
- marker = markerCreatePreserveWhitespace();
- token = markerApply(marker, delegate.createLiteral(lex()));
- } else if (match('<')) {
- token = parseJSXElement();
- } else {
- throwUnexpected(lookahead);
- }
- return token;
- }
- function parseJSXClosingElement() {
- var name, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = true;
- expect('<');
- expect('/');
- name = parseJSXElementName();
- // Because advance() (called by lex() called by expect()) expects there
- // to be a valid token after >, it needs to know whether to look for a
- // standard JS token or an JSX text node
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- expect('>');
- return markerApply(marker, delegate.createJSXClosingElement(name));
- }
- function parseJSXOpeningElement() {
- var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = true;
- expect('<');
- name = parseJSXElementName();
- while (index < length &&
- lookahead.value !== '/' &&
- lookahead.value !== '>') {
- attributes.push(parseJSXAttribute());
- }
- state.inJSXTag = origInJSXTag;
- if (lookahead.value === '/') {
- expect('/');
- // Because advance() (called by lex() called by expect()) expects
- // there to be a valid token after >, it needs to know whether to
- // look for a standard JS token or an JSX text node
- state.inJSXChild = origInJSXChild;
- expect('>');
- selfClosing = true;
- } else {
- state.inJSXChild = true;
- expect('>');
- }
- return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing));
- }
- function parseJSXElement() {
- var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- openingElement = parseJSXOpeningElement();
- if (!openingElement.selfClosing) {
- while (index < length) {
- state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because </ should not be considered in the child
- if (lookahead.value === '<' && lookahead2().value === '/') {
- break;
- }
- state.inJSXChild = true;
- children.push(parseJSXChild());
- }
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- closingElement = parseJSXClosingElement();
- if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
- throwError({}, Messages.ExpectedJSXClosingTag, getQualifiedJSXName(openingElement.name));
- }
- }
- // When (erroneously) writing two adjacent tags like
- //
- // var x = <div>one</div><div>two</div>;
- //
- // the default error message is a bit incomprehensible. Since it's
- // rarely (never?) useful to write a less-than sign after an JSX
- // element, we disallow it here in the parser in order to provide a
- // better error message. (In the rare case that the less-than operator
- // was intended, the left tag can be wrapped in parentheses.)
- if (!origInJSXChild && match('<')) {
- throwError(lookahead, Messages.AdjacentJSXElements);
- }
- return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children));
- }
- function parseTypeAlias() {
- var id, marker = markerCreate(), typeParameters = null, right;
- expectContextualKeyword('type');
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('=');
- right = parseType();
- consumeSemicolon();
- return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
- }
- function parseInterfaceExtends() {
- var marker = markerCreate(), id, typeParameters = null;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- }
- return markerApply(marker, delegate.createInterfaceExtends(
- id,
- typeParameters
- ));
- }
- function parseInterfaceish(marker, allowStatic) {
- var body, bodyMarker, extended = [], id,
- typeParameters = null;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- while (index < length) {
- extended.push(parseInterfaceExtends());
- if (!match(',')) {
- break;
- }
- expect(',');
- }
- }
- bodyMarker = markerCreate();
- body = markerApply(bodyMarker, parseObjectType(allowStatic));
- return markerApply(marker, delegate.createInterface(
- id,
- typeParameters,
- body,
- extended
- ));
- }
- function parseInterface() {
- var marker = markerCreate();
- if (strict) {
- expectKeyword('interface');
- } else {
- expectContextualKeyword('interface');
- }
- return parseInterfaceish(marker, /* allowStatic */false);
- }
- function parseDeclareClass() {
- var marker = markerCreate(), ret;
- expectContextualKeyword('declare');
- expectKeyword('class');
- ret = parseInterfaceish(marker, /* allowStatic */true);
- ret.type = Syntax.DeclareClass;
- return ret;
- }
- function parseDeclareFunction() {
- var id, idMarker,
- marker = markerCreate(), params, returnType, rest, tmp,
- typeParameters = null, value, valueMarker;
- expectContextualKeyword('declare');
- expectKeyword('function');
- idMarker = markerCreate();
- id = parseVariableIdentifier();
- valueMarker = markerCreate();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('(');
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect(':');
- returnType = parseType();
- value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
- value
- ));
- markerApply(idMarker, id);
- consumeSemicolon();
- return markerApply(marker, delegate.createDeclareFunction(
- id
- ));
- }
- function parseDeclareVariable() {
- var id, marker = markerCreate();
- expectContextualKeyword('declare');
- expectKeyword('var');
- id = parseTypeAnnotatableIdentifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createDeclareVariable(
- id
- ));
- }
- function parseDeclareModule() {
- var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
- expectContextualKeyword('declare');
- expectContextualKeyword('module');
- if (lookahead.type === Token.StringLiteral) {
- if (strict && lookahead.octal) {
- throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
- }
- idMarker = markerCreate();
- id = markerApply(idMarker, delegate.createLiteral(lex()));
- } else {
- id = parseVariableIdentifier();
- }
- bodyMarker = markerCreate();
- expect('{');
- while (index < length && !match('}')) {
- token = lookahead2();
- switch (token.value) {
- case 'class':
- body.push(parseDeclareClass());
- break;
- case 'function':
- body.push(parseDeclareFunction());
- break;
- case 'var':
- body.push(parseDeclareVariable());
- break;
- default:
- throwUnexpected(lookahead);
- }
- }
- expect('}');
- return markerApply(marker, delegate.createDeclareModule(
- id,
- markerApply(bodyMarker, delegate.createBlockStatement(body))
- ));
- }
- function collectToken() {
- var loc, token, range, value, entry;
- /* istanbul ignore else */
- if (!state.inJSXChild) {
- skipComment();
- }
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- token = extra.advance();
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- if (token.type !== Token.EOF) {
- range = [token.range[0], token.range[1]];
- value = source.slice(token.range[0], token.range[1]);
- entry = {
- type: TokenName[token.type],
- value: value,
- range: range,
- loc: loc
- };
- if (token.regex) {
- entry.regex = {
- pattern: token.regex.pattern,
- flags: token.regex.flags
- };
- }
- extra.tokens.push(entry);
- }
- return token;
- }
- function collectRegex() {
- var pos, loc, regex, token;
- skipComment();
- pos = index;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- regex = extra.scanRegExp();
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- if (!extra.tokenize) {
- /* istanbul ignore next */
- // Pop the previous token, which is likely '/' or '/='
- if (extra.tokens.length > 0) {
- token = extra.tokens[extra.tokens.length - 1];
- if (token.range[0] === pos && token.type === 'Punctuator') {
- if (token.value === '/' || token.value === '/=') {
- extra.tokens.pop();
- }
- }
- }
- extra.tokens.push({
- type: 'RegularExpression',
- value: regex.literal,
- regex: regex.regex,
- range: [pos, index],
- loc: loc
- });
- }
- return regex;
- }
- function filterTokenLocation() {
- var i, entry, token, tokens = [];
- for (i = 0; i < extra.tokens.length; ++i) {
- entry = extra.tokens[i];
- token = {
- type: entry.type,
- value: entry.value
- };
- if (entry.regex) {
- token.regex = {
- pattern: entry.regex.pattern,
- flags: entry.regex.flags
- };
- }
- if (extra.range) {
- token.range = entry.range;
- }
- if (extra.loc) {
- token.loc = entry.loc;
- }
- tokens.push(token);
- }
- extra.tokens = tokens;
- }
- function patch() {
- if (typeof extra.tokens !== 'undefined') {
- extra.advance = advance;
- extra.scanRegExp = scanRegExp;
- advance = collectToken;
- scanRegExp = collectRegex;
- }
- }
- function unpatch() {
- if (typeof extra.scanRegExp === 'function') {
- advance = extra.advance;
- scanRegExp = extra.scanRegExp;
- }
- }
- // This is used to modify the delegate.
- function extend(object, properties) {
- var entry, result = {};
- for (entry in object) {
- /* istanbul ignore else */
- if (object.hasOwnProperty(entry)) {
- result[entry] = object[entry];
- }
- }
- for (entry in properties) {
- /* istanbul ignore else */
- if (properties.hasOwnProperty(entry)) {
- result[entry] = properties[entry];
- }
- }
- return result;
- }
- function tokenize(code, options) {
- var toString,
- token,
- tokens;
- toString = String;
- if (typeof code !== 'string' && !(code instanceof String)) {
- code = toString(code);
- }
- delegate = SyntaxTreeDelegate;
- source = code;
- index = 0;
- lineNumber = (source.length > 0) ? 1 : 0;
- lineStart = 0;
- length = source.length;
- lookahead = null;
- state = {
- allowKeyword: true,
- allowIn: true,
- labelSet: new StringMap(),
- inFunctionBody: false,
- inIteration: false,
- inSwitch: false,
- lastCommentStart: -1
- };
- extra = {};
- // Options matching.
- options = options || {};
- // Of course we collect tokens here.
- options.tokens = true;
- extra.tokens = [];
- extra.tokenize = true;
- // The following two fields are necessary to compute the Regex tokens.
- extra.openParenToken = -1;
- extra.openCurlyToken = -1;
- extra.range = (typeof options.range === 'boolean') && options.range;
- extra.loc = (typeof options.loc === 'boolean') && options.loc;
- if (typeof options.comment === 'boolean' && options.comment) {
- extra.comments = [];
- }
- if (typeof options.tolerant === 'boolean' && options.tolerant) {
- extra.errors = [];
- }
- patch();
- try {
- peek();
- if (lookahead.type === Token.EOF) {
- return extra.tokens;
- }
- token = lex();
- while (lookahead.type !== Token.EOF) {
- try {
- token = lex();
- } catch (lexError) {
- token = lookahead;
- if (extra.errors) {
- extra.errors.push(lexError);
- // We have to break on the first error
- // to avoid infinite loops.
- break;
- } else {
- throw lexError;
- }
- }
- }
- filterTokenLocation();
- tokens = extra.tokens;
- if (typeof extra.comments !== 'undefined') {
- tokens.comments = extra.comments;
- }
- if (typeof extra.errors !== 'undefined') {
- tokens.errors = extra.errors;
- }
- } catch (e) {
- throw e;
- } finally {
- unpatch();
- extra = {};
- }
- return tokens;
- }
- function parse(code, options) {
- var program, toString;
- toString = String;
- if (typeof code !== 'string' && !(code instanceof String)) {
- code = toString(code);
- }
- delegate = SyntaxTreeDelegate;
- source = code;
- index = 0;
- lineNumber = (source.length > 0) ? 1 : 0;
- lineStart = 0;
- length = source.length;
- lookahead = null;
- state = {
- allowKeyword: false,
- allowIn: true,
- labelSet: new StringMap(),
- parenthesizedCount: 0,
- inFunctionBody: false,
- inIteration: false,
- inSwitch: false,
- inJSXChild: false,
- inJSXTag: false,
- inType: false,
- lastCommentStart: -1,
- yieldAllowed: false,
- awaitAllowed: false
- };
- extra = {};
- if (typeof options !== 'undefined') {
- extra.range = (typeof options.range === 'boolean') && options.range;
- extra.loc = (typeof options.loc === 'boolean') && options.loc;
- extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
- if (extra.loc && options.source !== null && options.source !== undefined) {
- delegate = extend(delegate, {
- 'postProcess': function (node) {
- node.loc.source = toString(options.source);
- return node;
- }
- });
- }
- extra.sourceType = options.sourceType;
- if (typeof options.tokens === 'boolean' && options.tokens) {
- extra.tokens = [];
- }
- if (typeof options.comment === 'boolean' && options.comment) {
- extra.comments = [];
- }
- if (typeof options.tolerant === 'boolean' && options.tolerant) {
- extra.errors = [];
- }
- if (extra.attachComment) {
- extra.range = true;
- extra.comments = [];
- extra.bottomRightStack = [];
- extra.trailingComments = [];
- extra.leadingComments = [];
- }
- }
- patch();
- try {
- program = parseProgram();
- if (typeof extra.comments !== 'undefined') {
- program.comments = extra.comments;
- }
- if (typeof extra.tokens !== 'undefined') {
- filterTokenLocation();
- program.tokens = extra.tokens;
- }
- if (typeof extra.errors !== 'undefined') {
- program.errors = extra.errors;
- }
- } catch (e) {
- throw e;
- } finally {
- unpatch();
- extra = {};
- }
- return program;
- }
- // Sync with *.json manifests.
- exports.version = '13001.1.0-dev-harmony-fb';
- exports.tokenize = tokenize;
- exports.parse = parse;
- // Deep copy.
- /* istanbul ignore next */
- exports.Syntax = (function () {
- var name, types = {};
- if (typeof Object.create === 'function') {
- types = Object.create(null);
- }
- for (name in Syntax) {
- if (Syntax.hasOwnProperty(name)) {
- types[name] = Syntax[name];
- }
- }
- if (typeof Object.freeze === 'function') {
- Object.freeze(types);
- }
- return types;
- }());
- }));
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{}],459:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var n = types.namedTypes;
- var isArray = types.builtInTypes.array;
- var isObject = types.builtInTypes.object;
- var linesModule = require("./lines");
- var fromString = linesModule.fromString;
- var Lines = linesModule.Lines;
- var concat = linesModule.concat;
- var util = require("./util");
- var comparePos = util.comparePos;
- var childNodesCacheKey = require("private").makeUniqueKey();
- // TODO Move a non-caching implementation of this function into ast-types,
- // and implement a caching wrapper function here.
- function getSortedChildNodes(node, resultArray) {
- if (!node) {
- return;
- }
- // The .loc checks below are sensitive to some of the problems that
- // are fixed by this utility function. Specifically, if it decides to
- // set node.loc to null, indicating that the node's .loc information
- // is unreliable, then we don't want to add node to the resultArray.
- util.fixFaultyLocations(node);
- if (resultArray) {
- if (n.Node.check(node) &&
- n.SourceLocation.check(node.loc)) {
- // This reverse insertion sort almost always takes constant
- // time because we almost always (maybe always?) append the
- // nodes in order anyway.
- for (var i = resultArray.length - 1; i >= 0; --i) {
- if (comparePos(resultArray[i].loc.end,
- node.loc.start) <= 0) {
- break;
- }
- }
- resultArray.splice(i + 1, 0, node);
- return;
- }
- } else if (node[childNodesCacheKey]) {
- return node[childNodesCacheKey];
- }
- var names;
- if (isArray.check(node)) {
- names = Object.keys(node);
- } else if (isObject.check(node)) {
- names = types.getFieldNames(node);
- } else {
- return;
- }
- if (!resultArray) {
- Object.defineProperty(node, childNodesCacheKey, {
- value: resultArray = [],
- enumerable: false
- });
- }
- for (var i = 0, nameCount = names.length; i < nameCount; ++i) {
- getSortedChildNodes(node[names[i]], resultArray);
- }
- return resultArray;
- }
- // As efficiently as possible, decorate the comment object with
- // .precedingNode, .enclosingNode, and/or .followingNode properties, at
- // least one of which is guaranteed to be defined.
- function decorateComment(node, comment) {
- var childNodes = getSortedChildNodes(node);
- // Time to dust off the old binary search robes and wizard hat.
- var left = 0, right = childNodes.length;
- while (left < right) {
- var middle = (left + right) >> 1;
- var child = childNodes[middle];
- if (comparePos(child.loc.start, comment.loc.start) <= 0 &&
- comparePos(comment.loc.end, child.loc.end) <= 0) {
- // The comment is completely contained by this child node.
- decorateComment(comment.enclosingNode = child, comment);
- return; // Abandon the binary search at this level.
- }
- if (comparePos(child.loc.end, comment.loc.start) <= 0) {
- // This child node falls completely before the comment.
- // Because we will never consider this node or any nodes
- // before it again, this node must be the closest preceding
- // node we have encountered so far.
- var precedingNode = child;
- left = middle + 1;
- continue;
- }
- if (comparePos(comment.loc.end, child.loc.start) <= 0) {
- // This child node falls completely after the comment.
- // Because we will never consider this node or any nodes after
- // it again, this node must be the closest following node we
- // have encountered so far.
- var followingNode = child;
- right = middle;
- continue;
- }
- throw new Error("Comment location overlaps with node location");
- }
- if (precedingNode) {
- comment.precedingNode = precedingNode;
- }
- if (followingNode) {
- comment.followingNode = followingNode;
- }
- }
- exports.attach = function(comments, ast, lines) {
- if (!isArray.check(comments)) {
- return;
- }
- var tiesToBreak = [];
- comments.forEach(function(comment) {
- comment.loc.lines = lines;
- decorateComment(ast, comment);
- var pn = comment.precedingNode;
- var en = comment.enclosingNode;
- var fn = comment.followingNode;
- if (pn && fn) {
- var tieCount = tiesToBreak.length;
- if (tieCount > 0) {
- var lastTie = tiesToBreak[tieCount - 1];
- assert.strictEqual(
- lastTie.precedingNode === comment.precedingNode,
- lastTie.followingNode === comment.followingNode
- );
- if (lastTie.followingNode !== comment.followingNode) {
- breakTies(tiesToBreak, lines);
- }
- }
- tiesToBreak.push(comment);
- } else if (pn) {
- // No contest: we have a trailing comment.
- breakTies(tiesToBreak, lines);
- addTrailingComment(pn, comment);
- } else if (fn) {
- // No contest: we have a leading comment.
- breakTies(tiesToBreak, lines);
- addLeadingComment(fn, comment);
- } else if (en) {
- // The enclosing node has no child nodes at all, so what we
- // have here is a dangling comment, e.g. [/* crickets */].
- breakTies(tiesToBreak, lines);
- addDanglingComment(en, comment);
- } else {
- throw new Error("AST contains no nodes at all?");
- }
- });
- breakTies(tiesToBreak, lines);
- comments.forEach(function(comment) {
- // These node references were useful for breaking ties, but we
- // don't need them anymore, and they create cycles in the AST that
- // may lead to infinite recursion if we don't delete them here.
- delete comment.precedingNode;
- delete comment.enclosingNode;
- delete comment.followingNode;
- });
- };
- function breakTies(tiesToBreak, lines) {
- var tieCount = tiesToBreak.length;
- if (tieCount === 0) {
- return;
- }
- var pn = tiesToBreak[0].precedingNode;
- var fn = tiesToBreak[0].followingNode;
- var gapEndPos = fn.loc.start;
- // Iterate backwards through tiesToBreak, examining the gaps
- // between the tied comments. In order to qualify as leading, a
- // comment must be separated from fn by an unbroken series of
- // whitespace-only gaps (or other comments).
- for (var indexOfFirstLeadingComment = tieCount;
- indexOfFirstLeadingComment > 0;
- --indexOfFirstLeadingComment) {
- var comment = tiesToBreak[indexOfFirstLeadingComment - 1];
- assert.strictEqual(comment.precedingNode, pn);
- assert.strictEqual(comment.followingNode, fn);
- var gap = lines.sliceString(comment.loc.end, gapEndPos);
- if (/\S/.test(gap)) {
- // The gap string contained something other than whitespace.
- break;
- }
- gapEndPos = comment.loc.start;
- }
- while (indexOfFirstLeadingComment <= tieCount &&
- (comment = tiesToBreak[indexOfFirstLeadingComment]) &&
- // If the comment is a //-style comment and indented more
- // deeply than the node itself, reconsider it as trailing.
- comment.type === "Line" &&
- comment.loc.start.column > fn.loc.start.column) {
- ++indexOfFirstLeadingComment;
- }
- tiesToBreak.forEach(function(comment, i) {
- if (i < indexOfFirstLeadingComment) {
- addTrailingComment(pn, comment);
- } else {
- addLeadingComment(fn, comment);
- }
- });
- tiesToBreak.length = 0;
- }
- function addCommentHelper(node, comment) {
- var comments = node.comments || (node.comments = []);
- comments.push(comment);
- }
- function addLeadingComment(node, comment) {
- comment.leading = true;
- comment.trailing = false;
- addCommentHelper(node, comment);
- }
- function addDanglingComment(node, comment) {
- comment.leading = false;
- comment.trailing = false;
- addCommentHelper(node, comment);
- }
- function addTrailingComment(node, comment) {
- comment.leading = false;
- comment.trailing = true;
- addCommentHelper(node, comment);
- }
- function printLeadingComment(commentPath, print) {
- var comment = commentPath.getValue();
- n.Comment.assert(comment);
- var loc = comment.loc;
- var lines = loc && loc.lines;
- var parts = [print(commentPath)];
- if (comment.trailing) {
- // When we print trailing comments as leading comments, we don't
- // want to bring any trailing spaces along.
- parts.push("\n");
- } else if (lines instanceof Lines) {
- var trailingSpace = lines.slice(
- loc.end,
- lines.skipSpaces(loc.end)
- );
- if (trailingSpace.length === 1) {
- // If the trailing space contains no newlines, then we want to
- // preserve it exactly as we found it.
- parts.push(trailingSpace);
- } else {
- // If the trailing space contains newlines, then replace it
- // with just that many newlines, with all other spaces removed.
- parts.push(new Array(trailingSpace.length).join("\n"));
- }
- } else {
- parts.push("\n");
- }
- return concat(parts);
- }
- function printTrailingComment(commentPath, print) {
- var comment = commentPath.getValue(commentPath);
- n.Comment.assert(comment);
- var loc = comment.loc;
- var lines = loc && loc.lines;
- var parts = [];
- if (lines instanceof Lines) {
- var fromPos = lines.skipSpaces(loc.start, true) || lines.firstPos();
- var leadingSpace = lines.slice(fromPos, loc.start);
- if (leadingSpace.length === 1) {
- // If the leading space contains no newlines, then we want to
- // preserve it exactly as we found it.
- parts.push(leadingSpace);
- } else {
- // If the leading space contains newlines, then replace it
- // with just that many newlines, sans all other spaces.
- parts.push(new Array(leadingSpace.length).join("\n"));
- }
- }
- parts.push(print(commentPath));
- return concat(parts);
- }
- exports.printComments = function(path, print) {
- var value = path.getValue();
- var innerLines = print(path);
- var comments = n.Node.check(value) &&
- types.getFieldValue(value, "comments");
- if (!comments || comments.length === 0) {
- return innerLines;
- }
- var leadingParts = [];
- var trailingParts = [innerLines];
- path.each(function(commentPath) {
- var comment = commentPath.getValue();
- var leading = types.getFieldValue(comment, "leading");
- var trailing = types.getFieldValue(comment, "trailing");
- if (leading || (trailing && comment.type !== "Block")) {
- leadingParts.push(printLeadingComment(commentPath, print));
- } else if (trailing) {
- assert.strictEqual(comment.type, "Block");
- trailingParts.push(printTrailingComment(commentPath, print));
- }
- }, "comments");
- leadingParts.push.apply(leadingParts, trailingParts);
- return concat(leadingParts);
- };
- },{"./lines":461,"./types":467,"./util":468,"assert":190,"private":435}],460:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var n = types.namedTypes;
- var Node = n.Node;
- var isArray = types.builtInTypes.array;
- var isNumber = types.builtInTypes.number;
- function FastPath(value) {
- assert.ok(this instanceof FastPath);
- this.stack = [value];
- }
- var FPp = FastPath.prototype;
- module.exports = FastPath;
- // Static convenience function for coercing a value to a FastPath.
- FastPath.from = function(obj) {
- if (obj instanceof FastPath) {
- // Return a defensive copy of any existing FastPath instances.
- return obj.copy();
- }
- if (obj instanceof types.NodePath) {
- // For backwards compatibility, unroll NodePath instances into
- // lightweight FastPath [..., name, value] stacks.
- var copy = Object.create(FastPath.prototype);
- var stack = [obj.value];
- for (var pp; (pp = obj.parentPath); obj = pp)
- stack.push(obj.name, pp.value);
- copy.stack = stack.reverse();
- return copy;
- }
- // Otherwise use obj as the value of the new FastPath instance.
- return new FastPath(obj);
- };
- FPp.copy = function copy() {
- var copy = Object.create(FastPath.prototype);
- copy.stack = this.stack.slice(0);
- return copy;
- };
- // The name of the current property is always the penultimate element of
- // this.stack, and always a String.
- FPp.getName = function getName() {
- var s = this.stack;
- var len = s.length;
- if (len > 1) {
- return s[len - 2];
- }
- // Since the name is always a string, null is a safe sentinel value to
- // return if we do not know the name of the (root) value.
- return null;
- };
- // The value of the current property is always the final element of
- // this.stack.
- FPp.getValue = function getValue() {
- var s = this.stack;
- return s[s.length - 1];
- };
- function getNodeHelper(path, count) {
- var s = path.stack;
- for (var i = s.length - 1; i >= 0; i -= 2) {
- var value = s[i];
- if (n.Node.check(value) && --count < 0) {
- return value;
- }
- }
- return null;
- }
- FPp.getNode = function getNode(count) {
- return getNodeHelper(this, ~~count);
- };
- FPp.getParentNode = function getParentNode(count) {
- return getNodeHelper(this, ~~count + 1);
- };
- // The length of the stack can be either even or odd, depending on whether
- // or not we have a name for the root value. The difference between the
- // index of the root value and the index of the final value is always
- // even, though, which allows us to return the root value in constant time
- // (i.e. without iterating backwards through the stack).
- FPp.getRootValue = function getRootValue() {
- var s = this.stack;
- if (s.length % 2 === 0) {
- return s[1];
- }
- return s[0];
- };
- // Temporarily push properties named by string arguments given after the
- // callback function onto this.stack, then call the callback with a
- // reference to this (modified) FastPath object. Note that the stack will
- // be restored to its original state after the callback is finished, so it
- // is probably a mistake to retain a reference to the path.
- FPp.call = function call(callback/*, name1, name2, ... */) {
- var s = this.stack;
- var origLen = s.length;
- var value = s[origLen - 1];
- var argc = arguments.length;
- for (var i = 1; i < argc; ++i) {
- var name = arguments[i];
- value = value[name];
- s.push(name, value);
- }
- var result = callback(this);
- s.length = origLen;
- return result;
- };
- // Similar to FastPath.prototype.call, except that the value obtained by
- // accessing this.getValue()[name1][name2]... should be array-like. The
- // callback will be called with a reference to this path object for each
- // element of the array.
- FPp.each = function each(callback/*, name1, name2, ... */) {
- var s = this.stack;
- var origLen = s.length;
- var value = s[origLen - 1];
- var argc = arguments.length;
- for (var i = 1; i < argc; ++i) {
- var name = arguments[i];
- value = value[name];
- s.push(name, value);
- }
- for (var i = 0; i < value.length; ++i) {
- if (i in value) {
- s.push(i, value[i]);
- // If the callback needs to know the value of i, call
- // path.getName(), assuming path is the parameter name.
- callback(this);
- s.length -= 2;
- }
- }
- s.length = origLen;
- };
- // Similar to FastPath.prototype.each, except that the results of the
- // callback function invocations are stored in an array and returned at
- // the end of the iteration.
- FPp.map = function map(callback/*, name1, name2, ... */) {
- var s = this.stack;
- var origLen = s.length;
- var value = s[origLen - 1];
- var argc = arguments.length;
- for (var i = 1; i < argc; ++i) {
- var name = arguments[i];
- value = value[name];
- s.push(name, value);
- }
- var result = new Array(value.length);
- for (var i = 0; i < value.length; ++i) {
- if (i in value) {
- s.push(i, value[i]);
- result[i] = callback(this, i);
- s.length -= 2;
- }
- }
- s.length = origLen;
- return result;
- };
- // Inspired by require("ast-types").NodePath.prototype.needsParens, but
- // more efficient because we're iterating backwards through a stack.
- FPp.needsParens = function(assumeExpressionContext) {
- var parent = this.getParentNode();
- if (!parent) {
- return false;
- }
- var name = this.getName();
- var node = this.getNode();
- // If the value of this path is some child of a Node and not a Node
- // itself, then it doesn't need parentheses. Only Node objects (in
- // fact, only Expression nodes) need parentheses.
- if (this.getValue() !== node) {
- return false;
- }
- // Only expressions need parentheses.
- if (!n.Expression.check(node)) {
- return false;
- }
- // Identifiers never need parentheses.
- if (node.type === "Identifier") {
- return false;
- }
- switch (node.type) {
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- return parent.type === "MemberExpression"
- && name === "object"
- && parent.object === node;
- case "BinaryExpression":
- case "LogicalExpression":
- switch (parent.type) {
- case "CallExpression":
- return name === "callee"
- && parent.callee === node;
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- return true;
- case "MemberExpression":
- return name === "object"
- && parent.object === node;
- case "BinaryExpression":
- case "LogicalExpression":
- var po = parent.operator;
- var pp = PRECEDENCE[po];
- var no = node.operator;
- var np = PRECEDENCE[no];
- if (pp > np) {
- return true;
- }
- if (pp === np && name === "right") {
- assert.strictEqual(parent.right, node);
- return true;
- }
- default:
- return false;
- }
- case "SequenceExpression":
- switch (parent.type) {
- case "ForStatement":
- // Although parentheses wouldn't hurt around sequence
- // expressions in the head of for loops, traditional style
- // dictates that e.g. i++, j++ should not be wrapped with
- // parentheses.
- return false;
- case "ExpressionStatement":
- return name !== "expression";
- default:
- // Otherwise err on the side of overparenthesization, adding
- // explicit exceptions above if this proves overzealous.
- return true;
- }
- case "YieldExpression":
- switch (parent.type) {
- case "BinaryExpression":
- case "LogicalExpression":
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- case "CallExpression":
- case "MemberExpression":
- case "NewExpression":
- case "ConditionalExpression":
- case "YieldExpression":
- return true;
- default:
- return false;
- }
- case "Literal":
- return parent.type === "MemberExpression"
- && isNumber.check(node.value)
- && name === "object"
- && parent.object === node;
- case "AssignmentExpression":
- case "ConditionalExpression":
- switch (parent.type) {
- case "UnaryExpression":
- case "SpreadElement":
- case "SpreadProperty":
- case "BinaryExpression":
- case "LogicalExpression":
- return true;
- case "CallExpression":
- return name === "callee"
- && parent.callee === node;
- case "ConditionalExpression":
- return name === "test"
- && parent.test === node;
- case "MemberExpression":
- return name === "object"
- && parent.object === node;
- default:
- return false;
- }
- case "ArrowFunctionExpression":
- return isBinary(parent);
- case "ObjectExpression":
- if (parent.type === "ArrowFunctionExpression" &&
- name === "body") {
- return true;
- }
- default:
- if (parent.type === "NewExpression" &&
- name === "callee" &&
- parent.callee === node) {
- return containsCallExpression(node);
- }
- }
- if (assumeExpressionContext !== true &&
- !this.canBeFirstInStatement() &&
- this.firstInStatement())
- return true;
- return false;
- };
- function isBinary(node) {
- return n.BinaryExpression.check(node)
- || n.LogicalExpression.check(node);
- }
- function isUnaryLike(node) {
- return n.UnaryExpression.check(node)
- // I considered making SpreadElement and SpreadProperty subtypes
- // of UnaryExpression, but they're not really Expression nodes.
- || (n.SpreadElement && n.SpreadElement.check(node))
- || (n.SpreadProperty && n.SpreadProperty.check(node));
- }
- var PRECEDENCE = {};
- [["||"],
- ["&&"],
- ["|"],
- ["^"],
- ["&"],
- ["==", "===", "!=", "!=="],
- ["<", ">", "<=", ">=", "in", "instanceof"],
- [">>", "<<", ">>>"],
- ["+", "-"],
- ["*", "/", "%"]
- ].forEach(function(tier, i) {
- tier.forEach(function(op) {
- PRECEDENCE[op] = i;
- });
- });
- function containsCallExpression(node) {
- if (n.CallExpression.check(node)) {
- return true;
- }
- if (isArray.check(node)) {
- return node.some(containsCallExpression);
- }
- if (n.Node.check(node)) {
- return types.someField(node, function(name, child) {
- return containsCallExpression(child);
- });
- }
- return false;
- }
- FPp.canBeFirstInStatement = function() {
- var node = this.getNode();
- return !n.FunctionExpression.check(node)
- && !n.ObjectExpression.check(node);
- };
- FPp.firstInStatement = function() {
- var s = this.stack;
- var parentName, parent;
- var childName, child;
- for (var i = s.length - 1; i >= 0; i -= 2) {
- if (n.Node.check(s[i])) {
- childName = parentName;
- child = parent;
- parentName = s[i - 1];
- parent = s[i];
- }
- if (!parent || !child) {
- continue;
- }
- if (n.BlockStatement.check(parent) &&
- parentName === "body" &&
- childName === 0) {
- assert.strictEqual(parent.body[0], child);
- return true;
- }
- if (n.ExpressionStatement.check(parent) &&
- childName === "expression") {
- assert.strictEqual(parent.expression, child);
- return true;
- }
- if (n.SequenceExpression.check(parent) &&
- parentName === "expressions" &&
- childName === 0) {
- assert.strictEqual(parent.expressions[0], child);
- continue;
- }
- if (n.CallExpression.check(parent) &&
- childName === "callee") {
- assert.strictEqual(parent.callee, child);
- continue;
- }
- if (n.MemberExpression.check(parent) &&
- childName === "object") {
- assert.strictEqual(parent.object, child);
- continue;
- }
- if (n.ConditionalExpression.check(parent) &&
- childName === "test") {
- assert.strictEqual(parent.test, child);
- continue;
- }
- if (isBinary(parent) &&
- childName === "left") {
- assert.strictEqual(parent.left, child);
- continue;
- }
- if (n.UnaryExpression.check(parent) &&
- !parent.prefix &&
- childName === "argument") {
- assert.strictEqual(parent.argument, child);
- continue;
- }
- return false;
- }
- return true;
- };
- },{"./types":467,"assert":190}],461:[function(require,module,exports){
- var assert = require("assert");
- var sourceMap = require("source-map");
- var normalizeOptions = require("./options").normalize;
- var secretKey = require("private").makeUniqueKey();
- var types = require("./types");
- var isString = types.builtInTypes.string;
- var comparePos = require("./util").comparePos;
- var Mapping = require("./mapping");
- // Goals:
- // 1. Minimize new string creation.
- // 2. Keep (de)identation O(lines) time.
- // 3. Permit negative indentations.
- // 4. Enforce immutability.
- // 5. No newline characters.
- function getSecret(lines) {
- return lines[secretKey];
- }
- function Lines(infos, sourceFileName) {
- assert.ok(this instanceof Lines);
- assert.ok(infos.length > 0);
- if (sourceFileName) {
- isString.assert(sourceFileName);
- } else {
- sourceFileName = null;
- }
- Object.defineProperty(this, secretKey, {
- value: {
- infos: infos,
- mappings: [],
- name: sourceFileName,
- cachedSourceMap: null
- }
- });
- if (sourceFileName) {
- getSecret(this).mappings.push(new Mapping(this, {
- start: this.firstPos(),
- end: this.lastPos()
- }));
- }
- }
- // Exposed for instanceof checks. The fromString function should be used
- // to create new Lines objects.
- exports.Lines = Lines;
- var Lp = Lines.prototype;
- // These properties used to be assigned to each new object in the Lines
- // constructor, but we can more efficiently stuff them into the secret and
- // let these lazy accessors compute their values on-the-fly.
- Object.defineProperties(Lp, {
- length: {
- get: function() {
- return getSecret(this).infos.length;
- }
- },
- name: {
- get: function() {
- return getSecret(this).name;
- }
- }
- });
- function copyLineInfo(info) {
- return {
- line: info.line,
- indent: info.indent,
- sliceStart: info.sliceStart,
- sliceEnd: info.sliceEnd
- };
- }
- var fromStringCache = {};
- var hasOwn = fromStringCache.hasOwnProperty;
- var maxCacheKeyLen = 10;
- function countSpaces(spaces, tabWidth) {
- var count = 0;
- var len = spaces.length;
- for (var i = 0; i < len; ++i) {
- switch (spaces.charCodeAt(i)) {
- case 9: // '\t'
- assert.strictEqual(typeof tabWidth, "number");
- assert.ok(tabWidth > 0);
- var next = Math.ceil(count / tabWidth) * tabWidth;
- if (next === count) {
- count += tabWidth;
- } else {
- count = next;
- }
- break;
- case 11: // '\v'
- case 12: // '\f'
- case 13: // '\r'
- case 0xfeff: // zero-width non-breaking space
- // These characters contribute nothing to indentation.
- break;
- case 32: // ' '
- default: // Treat all other whitespace like ' '.
- count += 1;
- break;
- }
- }
- return count;
- }
- exports.countSpaces = countSpaces;
- var leadingSpaceExp = /^\s*/;
- /**
- * @param {Object} options - Options object that configures printing.
- */
- function fromString(string, options) {
- if (string instanceof Lines)
- return string;
- string += "";
- var tabWidth = options && options.tabWidth;
- var tabless = string.indexOf("\t") < 0;
- var cacheable = !options && tabless && (string.length <= maxCacheKeyLen);
- assert.ok(tabWidth || tabless, "No tab width specified but encountered tabs in string\n" + string);
- if (cacheable && hasOwn.call(fromStringCache, string))
- return fromStringCache[string];
- var lines = new Lines(string.split("\n").map(function(line) {
- var spaces = leadingSpaceExp.exec(line)[0];
- return {
- line: line,
- indent: countSpaces(spaces, tabWidth),
- sliceStart: spaces.length,
- sliceEnd: line.length
- };
- }), normalizeOptions(options).sourceFileName);
- if (cacheable)
- fromStringCache[string] = lines;
- return lines;
- }
- exports.fromString = fromString;
- function isOnlyWhitespace(string) {
- return !/\S/.test(string);
- }
- Lp.toString = function(options) {
- return this.sliceString(this.firstPos(), this.lastPos(), options);
- };
- Lp.getSourceMap = function(sourceMapName, sourceRoot) {
- if (!sourceMapName) {
- // Although we could make up a name or generate an anonymous
- // source map, instead we assume that any consumer who does not
- // provide a name does not actually want a source map.
- return null;
- }
- var targetLines = this;
- function updateJSON(json) {
- json = json || {};
- isString.assert(sourceMapName);
- json.file = sourceMapName;
- if (sourceRoot) {
- isString.assert(sourceRoot);
- json.sourceRoot = sourceRoot;
- }
- return json;
- }
- var secret = getSecret(targetLines);
- if (secret.cachedSourceMap) {
- // Since Lines objects are immutable, we can reuse any source map
- // that was previously generated. Nevertheless, we return a new
- // JSON object here to protect the cached source map from outside
- // modification.
- return updateJSON(secret.cachedSourceMap.toJSON());
- }
- var smg = new sourceMap.SourceMapGenerator(updateJSON());
- var sourcesToContents = {};
- secret.mappings.forEach(function(mapping) {
- var sourceCursor = mapping.sourceLines.skipSpaces(
- mapping.sourceLoc.start
- ) || mapping.sourceLines.lastPos();
- var targetCursor = targetLines.skipSpaces(
- mapping.targetLoc.start
- ) || targetLines.lastPos();
- while (comparePos(sourceCursor, mapping.sourceLoc.end) < 0 &&
- comparePos(targetCursor, mapping.targetLoc.end) < 0) {
- var sourceChar = mapping.sourceLines.charAt(sourceCursor);
- var targetChar = targetLines.charAt(targetCursor);
- assert.strictEqual(sourceChar, targetChar);
- var sourceName = mapping.sourceLines.name;
- // Add mappings one character at a time for maximum resolution.
- smg.addMapping({
- source: sourceName,
- original: { line: sourceCursor.line,
- column: sourceCursor.column },
- generated: { line: targetCursor.line,
- column: targetCursor.column }
- });
- if (!hasOwn.call(sourcesToContents, sourceName)) {
- var sourceContent = mapping.sourceLines.toString();
- smg.setSourceContent(sourceName, sourceContent);
- sourcesToContents[sourceName] = sourceContent;
- }
- targetLines.nextPos(targetCursor, true);
- mapping.sourceLines.nextPos(sourceCursor, true);
- }
- });
- secret.cachedSourceMap = smg;
- return smg.toJSON();
- };
- Lp.bootstrapCharAt = function(pos) {
- assert.strictEqual(typeof pos, "object");
- assert.strictEqual(typeof pos.line, "number");
- assert.strictEqual(typeof pos.column, "number");
- var line = pos.line,
- column = pos.column,
- strings = this.toString().split("\n"),
- string = strings[line - 1];
- if (typeof string === "undefined")
- return "";
- if (column === string.length &&
- line < strings.length)
- return "\n";
- if (column >= string.length)
- return "";
- return string.charAt(column);
- };
- Lp.charAt = function(pos) {
- assert.strictEqual(typeof pos, "object");
- assert.strictEqual(typeof pos.line, "number");
- assert.strictEqual(typeof pos.column, "number");
- var line = pos.line,
- column = pos.column,
- secret = getSecret(this),
- infos = secret.infos,
- info = infos[line - 1],
- c = column;
- if (typeof info === "undefined" || c < 0)
- return "";
- var indent = this.getIndentAt(line);
- if (c < indent)
- return " ";
- c += info.sliceStart - indent;
- if (c === info.sliceEnd &&
- line < this.length)
- return "\n";
- if (c >= info.sliceEnd)
- return "";
- return info.line.charAt(c);
- };
- Lp.stripMargin = function(width, skipFirstLine) {
- if (width === 0)
- return this;
- assert.ok(width > 0, "negative margin: " + width);
- if (skipFirstLine && this.length === 1)
- return this;
- var secret = getSecret(this);
- var lines = new Lines(secret.infos.map(function(info, i) {
- if (info.line && (i > 0 || !skipFirstLine)) {
- info = copyLineInfo(info);
- info.indent = Math.max(0, info.indent - width);
- }
- return info;
- }));
- if (secret.mappings.length > 0) {
- var newMappings = getSecret(lines).mappings;
- assert.strictEqual(newMappings.length, 0);
- secret.mappings.forEach(function(mapping) {
- newMappings.push(mapping.indent(width, skipFirstLine, true));
- });
- }
- return lines;
- };
- Lp.indent = function(by) {
- if (by === 0)
- return this;
- var secret = getSecret(this);
- var lines = new Lines(secret.infos.map(function(info) {
- if (info.line) {
- info = copyLineInfo(info);
- info.indent += by;
- }
- return info
- }));
- if (secret.mappings.length > 0) {
- var newMappings = getSecret(lines).mappings;
- assert.strictEqual(newMappings.length, 0);
- secret.mappings.forEach(function(mapping) {
- newMappings.push(mapping.indent(by));
- });
- }
- return lines;
- };
- Lp.indentTail = function(by) {
- if (by === 0)
- return this;
- if (this.length < 2)
- return this;
- var secret = getSecret(this);
- var lines = new Lines(secret.infos.map(function(info, i) {
- if (i > 0 && info.line) {
- info = copyLineInfo(info);
- info.indent += by;
- }
- return info;
- }));
- if (secret.mappings.length > 0) {
- var newMappings = getSecret(lines).mappings;
- assert.strictEqual(newMappings.length, 0);
- secret.mappings.forEach(function(mapping) {
- newMappings.push(mapping.indent(by, true));
- });
- }
- return lines;
- };
- Lp.getIndentAt = function(line) {
- assert.ok(line >= 1, "no line " + line + " (line numbers start from 1)");
- var secret = getSecret(this),
- info = secret.infos[line - 1];
- return Math.max(info.indent, 0);
- };
- Lp.guessTabWidth = function() {
- var secret = getSecret(this);
- if (hasOwn.call(secret, "cachedTabWidth")) {
- return secret.cachedTabWidth;
- }
- var counts = []; // Sparse array.
- var lastIndent = 0;
- for (var line = 1, last = this.length; line <= last; ++line) {
- var info = secret.infos[line - 1];
- var sliced = info.line.slice(info.sliceStart, info.sliceEnd);
- // Whitespace-only lines don't tell us much about the likely tab
- // width of this code.
- if (isOnlyWhitespace(sliced)) {
- continue;
- }
- var diff = Math.abs(info.indent - lastIndent);
- counts[diff] = ~~counts[diff] + 1;
- lastIndent = info.indent;
- }
- var maxCount = -1;
- var result = 2;
- for (var tabWidth = 1;
- tabWidth < counts.length;
- tabWidth += 1) {
- if (hasOwn.call(counts, tabWidth) &&
- counts[tabWidth] > maxCount) {
- maxCount = counts[tabWidth];
- result = tabWidth;
- }
- }
- return secret.cachedTabWidth = result;
- };
- Lp.isOnlyWhitespace = function() {
- return isOnlyWhitespace(this.toString());
- };
- Lp.isPrecededOnlyByWhitespace = function(pos) {
- var secret = getSecret(this);
- var info = secret.infos[pos.line - 1];
- var indent = Math.max(info.indent, 0);
- var diff = pos.column - indent;
- if (diff <= 0) {
- // If pos.column does not exceed the indentation amount, then
- // there must be only whitespace before it.
- return true;
- }
- var start = info.sliceStart;
- var end = Math.min(start + diff, info.sliceEnd);
- var prefix = info.line.slice(start, end);
- return isOnlyWhitespace(prefix);
- };
- Lp.getLineLength = function(line) {
- var secret = getSecret(this),
- info = secret.infos[line - 1];
- return this.getIndentAt(line) + info.sliceEnd - info.sliceStart;
- };
- Lp.nextPos = function(pos, skipSpaces) {
- var l = Math.max(pos.line, 0),
- c = Math.max(pos.column, 0);
- if (c < this.getLineLength(l)) {
- pos.column += 1;
- return skipSpaces
- ? !!this.skipSpaces(pos, false, true)
- : true;
- }
- if (l < this.length) {
- pos.line += 1;
- pos.column = 0;
- return skipSpaces
- ? !!this.skipSpaces(pos, false, true)
- : true;
- }
- return false;
- };
- Lp.prevPos = function(pos, skipSpaces) {
- var l = pos.line,
- c = pos.column;
- if (c < 1) {
- l -= 1;
- if (l < 1)
- return false;
- c = this.getLineLength(l);
- } else {
- c = Math.min(c - 1, this.getLineLength(l));
- }
- pos.line = l;
- pos.column = c;
- return skipSpaces
- ? !!this.skipSpaces(pos, true, true)
- : true;
- };
- Lp.firstPos = function() {
- // Trivial, but provided for completeness.
- return { line: 1, column: 0 };
- };
- Lp.lastPos = function() {
- return {
- line: this.length,
- column: this.getLineLength(this.length)
- };
- };
- Lp.skipSpaces = function(pos, backward, modifyInPlace) {
- if (pos) {
- pos = modifyInPlace ? pos : {
- line: pos.line,
- column: pos.column
- };
- } else if (backward) {
- pos = this.lastPos();
- } else {
- pos = this.firstPos();
- }
- if (backward) {
- while (this.prevPos(pos)) {
- if (!isOnlyWhitespace(this.charAt(pos)) &&
- this.nextPos(pos)) {
- return pos;
- }
- }
- return null;
- } else {
- while (isOnlyWhitespace(this.charAt(pos))) {
- if (!this.nextPos(pos)) {
- return null;
- }
- }
- return pos;
- }
- };
- Lp.trimLeft = function() {
- var pos = this.skipSpaces(this.firstPos(), false, true);
- return pos ? this.slice(pos) : emptyLines;
- };
- Lp.trimRight = function() {
- var pos = this.skipSpaces(this.lastPos(), true, true);
- return pos ? this.slice(this.firstPos(), pos) : emptyLines;
- };
- Lp.trim = function() {
- var start = this.skipSpaces(this.firstPos(), false, true);
- if (start === null)
- return emptyLines;
- var end = this.skipSpaces(this.lastPos(), true, true);
- assert.notStrictEqual(end, null);
- return this.slice(start, end);
- };
- Lp.eachPos = function(callback, startPos, skipSpaces) {
- var pos = this.firstPos();
- if (startPos) {
- pos.line = startPos.line,
- pos.column = startPos.column
- }
- if (skipSpaces && !this.skipSpaces(pos, false, true)) {
- return; // Encountered nothing but spaces.
- }
- do callback.call(this, pos);
- while (this.nextPos(pos, skipSpaces));
- };
- Lp.bootstrapSlice = function(start, end) {
- var strings = this.toString().split("\n").slice(
- start.line - 1, end.line);
- strings.push(strings.pop().slice(0, end.column));
- strings[0] = strings[0].slice(start.column);
- return fromString(strings.join("\n"));
- };
- Lp.slice = function(start, end) {
- if (!end) {
- if (!start) {
- // The client seems to want a copy of this Lines object, but
- // Lines objects are immutable, so it's perfectly adequate to
- // return the same object.
- return this;
- }
- // Slice to the end if no end position was provided.
- end = this.lastPos();
- }
- var secret = getSecret(this);
- var sliced = secret.infos.slice(start.line - 1, end.line);
- if (start.line === end.line) {
- sliced[0] = sliceInfo(sliced[0], start.column, end.column);
- } else {
- assert.ok(start.line < end.line);
- sliced[0] = sliceInfo(sliced[0], start.column);
- sliced.push(sliceInfo(sliced.pop(), 0, end.column));
- }
- var lines = new Lines(sliced);
- if (secret.mappings.length > 0) {
- var newMappings = getSecret(lines).mappings;
- assert.strictEqual(newMappings.length, 0);
- secret.mappings.forEach(function(mapping) {
- var sliced = mapping.slice(this, start, end);
- if (sliced) {
- newMappings.push(sliced);
- }
- }, this);
- }
- return lines;
- };
- function sliceInfo(info, startCol, endCol) {
- var sliceStart = info.sliceStart;
- var sliceEnd = info.sliceEnd;
- var indent = Math.max(info.indent, 0);
- var lineLength = indent + sliceEnd - sliceStart;
- if (typeof endCol === "undefined") {
- endCol = lineLength;
- }
- startCol = Math.max(startCol, 0);
- endCol = Math.min(endCol, lineLength);
- endCol = Math.max(endCol, startCol);
- if (endCol < indent) {
- indent = endCol;
- sliceEnd = sliceStart;
- } else {
- sliceEnd -= lineLength - endCol;
- }
- lineLength = endCol;
- lineLength -= startCol;
- if (startCol < indent) {
- indent -= startCol;
- } else {
- startCol -= indent;
- indent = 0;
- sliceStart += startCol;
- }
- assert.ok(indent >= 0);
- assert.ok(sliceStart <= sliceEnd);
- assert.strictEqual(lineLength, indent + sliceEnd - sliceStart);
- if (info.indent === indent &&
- info.sliceStart === sliceStart &&
- info.sliceEnd === sliceEnd) {
- return info;
- }
- return {
- line: info.line,
- indent: indent,
- sliceStart: sliceStart,
- sliceEnd: sliceEnd
- };
- }
- Lp.bootstrapSliceString = function(start, end, options) {
- return this.slice(start, end).toString(options);
- };
- Lp.sliceString = function(start, end, options) {
- if (!end) {
- if (!start) {
- // The client seems to want a copy of this Lines object, but
- // Lines objects are immutable, so it's perfectly adequate to
- // return the same object.
- return this;
- }
- // Slice to the end if no end position was provided.
- end = this.lastPos();
- }
- options = normalizeOptions(options);
- var infos = getSecret(this).infos;
- var parts = [];
- var tabWidth = options.tabWidth;
- for (var line = start.line; line <= end.line; ++line) {
- var info = infos[line - 1];
- if (line === start.line) {
- if (line === end.line) {
- info = sliceInfo(info, start.column, end.column);
- } else {
- info = sliceInfo(info, start.column);
- }
- } else if (line === end.line) {
- info = sliceInfo(info, 0, end.column);
- }
- var indent = Math.max(info.indent, 0);
- var before = info.line.slice(0, info.sliceStart);
- if (options.reuseWhitespace &&
- isOnlyWhitespace(before) &&
- countSpaces(before, options.tabWidth) === indent) {
- // Reuse original spaces if the indentation is correct.
- parts.push(info.line.slice(0, info.sliceEnd));
- continue;
- }
- var tabs = 0;
- var spaces = indent;
- if (options.useTabs) {
- tabs = Math.floor(indent / tabWidth);
- spaces -= tabs * tabWidth;
- }
- var result = "";
- if (tabs > 0) {
- result += new Array(tabs + 1).join("\t");
- }
- if (spaces > 0) {
- result += new Array(spaces + 1).join(" ");
- }
- result += info.line.slice(info.sliceStart, info.sliceEnd);
- parts.push(result);
- }
- return parts.join("\n");
- };
- Lp.isEmpty = function() {
- return this.length < 2 && this.getLineLength(1) < 1;
- };
- Lp.join = function(elements) {
- var separator = this;
- var separatorSecret = getSecret(separator);
- var infos = [];
- var mappings = [];
- var prevInfo;
- function appendSecret(secret) {
- if (secret === null)
- return;
- if (prevInfo) {
- var info = secret.infos[0];
- var indent = new Array(info.indent + 1).join(" ");
- var prevLine = infos.length;
- var prevColumn = Math.max(prevInfo.indent, 0) +
- prevInfo.sliceEnd - prevInfo.sliceStart;
- prevInfo.line = prevInfo.line.slice(
- 0, prevInfo.sliceEnd) + indent + info.line.slice(
- info.sliceStart, info.sliceEnd);
- prevInfo.sliceEnd = prevInfo.line.length;
- if (secret.mappings.length > 0) {
- secret.mappings.forEach(function(mapping) {
- mappings.push(mapping.add(prevLine, prevColumn));
- });
- }
- } else if (secret.mappings.length > 0) {
- mappings.push.apply(mappings, secret.mappings);
- }
- secret.infos.forEach(function(info, i) {
- if (!prevInfo || i > 0) {
- prevInfo = copyLineInfo(info);
- infos.push(prevInfo);
- }
- });
- }
- function appendWithSeparator(secret, i) {
- if (i > 0)
- appendSecret(separatorSecret);
- appendSecret(secret);
- }
- elements.map(function(elem) {
- var lines = fromString(elem);
- if (lines.isEmpty())
- return null;
- return getSecret(lines);
- }).forEach(separator.isEmpty()
- ? appendSecret
- : appendWithSeparator);
- if (infos.length < 1)
- return emptyLines;
- var lines = new Lines(infos);
- getSecret(lines).mappings = mappings;
- return lines;
- };
- exports.concat = function(elements) {
- return emptyLines.join(elements);
- };
- Lp.concat = function(other) {
- var args = arguments,
- list = [this];
- list.push.apply(list, args);
- assert.strictEqual(list.length, args.length + 1);
- return emptyLines.join(list);
- };
- // The emptyLines object needs to be created all the way down here so that
- // Lines.prototype will be fully populated.
- var emptyLines = fromString("");
- },{"./mapping":462,"./options":463,"./types":467,"./util":468,"assert":190,"private":435,"source-map":483}],462:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var isString = types.builtInTypes.string;
- var isNumber = types.builtInTypes.number;
- var SourceLocation = types.namedTypes.SourceLocation;
- var Position = types.namedTypes.Position;
- var linesModule = require("./lines");
- var comparePos = require("./util").comparePos;
- function Mapping(sourceLines, sourceLoc, targetLoc) {
- assert.ok(this instanceof Mapping);
- assert.ok(sourceLines instanceof linesModule.Lines);
- SourceLocation.assert(sourceLoc);
- if (targetLoc) {
- // In certain cases it's possible for targetLoc.{start,end}.column
- // values to be negative, which technically makes them no longer
- // valid SourceLocation nodes, so we need to be more forgiving.
- assert.ok(
- isNumber.check(targetLoc.start.line) &&
- isNumber.check(targetLoc.start.column) &&
- isNumber.check(targetLoc.end.line) &&
- isNumber.check(targetLoc.end.column)
- );
- } else {
- // Assume identity mapping if no targetLoc specified.
- targetLoc = sourceLoc;
- }
- Object.defineProperties(this, {
- sourceLines: { value: sourceLines },
- sourceLoc: { value: sourceLoc },
- targetLoc: { value: targetLoc }
- });
- }
- var Mp = Mapping.prototype;
- module.exports = Mapping;
- Mp.slice = function(lines, start, end) {
- assert.ok(lines instanceof linesModule.Lines);
- Position.assert(start);
- if (end) {
- Position.assert(end);
- } else {
- end = lines.lastPos();
- }
- var sourceLines = this.sourceLines;
- var sourceLoc = this.sourceLoc;
- var targetLoc = this.targetLoc;
- function skip(name) {
- var sourceFromPos = sourceLoc[name];
- var targetFromPos = targetLoc[name];
- var targetToPos = start;
- if (name === "end") {
- targetToPos = end;
- } else {
- assert.strictEqual(name, "start");
- }
- return skipChars(
- sourceLines, sourceFromPos,
- lines, targetFromPos, targetToPos
- );
- }
- if (comparePos(start, targetLoc.start) <= 0) {
- if (comparePos(targetLoc.end, end) <= 0) {
- targetLoc = {
- start: subtractPos(targetLoc.start, start.line, start.column),
- end: subtractPos(targetLoc.end, start.line, start.column)
- };
- // The sourceLoc can stay the same because the contents of the
- // targetLoc have not changed.
- } else if (comparePos(end, targetLoc.start) <= 0) {
- return null;
- } else {
- sourceLoc = {
- start: sourceLoc.start,
- end: skip("end")
- };
- targetLoc = {
- start: subtractPos(targetLoc.start, start.line, start.column),
- end: subtractPos(end, start.line, start.column)
- };
- }
- } else {
- if (comparePos(targetLoc.end, start) <= 0) {
- return null;
- }
- if (comparePos(targetLoc.end, end) <= 0) {
- sourceLoc = {
- start: skip("start"),
- end: sourceLoc.end
- };
- targetLoc = {
- // Same as subtractPos(start, start.line, start.column):
- start: { line: 1, column: 0 },
- end: subtractPos(targetLoc.end, start.line, start.column)
- };
- } else {
- sourceLoc = {
- start: skip("start"),
- end: skip("end")
- };
- targetLoc = {
- // Same as subtractPos(start, start.line, start.column):
- start: { line: 1, column: 0 },
- end: subtractPos(end, start.line, start.column)
- };
- }
- }
- return new Mapping(this.sourceLines, sourceLoc, targetLoc);
- };
- Mp.add = function(line, column) {
- return new Mapping(this.sourceLines, this.sourceLoc, {
- start: addPos(this.targetLoc.start, line, column),
- end: addPos(this.targetLoc.end, line, column)
- });
- };
- function addPos(toPos, line, column) {
- return {
- line: toPos.line + line - 1,
- column: (toPos.line === 1)
- ? toPos.column + column
- : toPos.column
- };
- }
- Mp.subtract = function(line, column) {
- return new Mapping(this.sourceLines, this.sourceLoc, {
- start: subtractPos(this.targetLoc.start, line, column),
- end: subtractPos(this.targetLoc.end, line, column)
- });
- };
- function subtractPos(fromPos, line, column) {
- return {
- line: fromPos.line - line + 1,
- column: (fromPos.line === line)
- ? fromPos.column - column
- : fromPos.column
- };
- }
- Mp.indent = function(by, skipFirstLine, noNegativeColumns) {
- if (by === 0) {
- return this;
- }
- var targetLoc = this.targetLoc;
- var startLine = targetLoc.start.line;
- var endLine = targetLoc.end.line;
- if (skipFirstLine && startLine === 1 && endLine === 1) {
- return this;
- }
- targetLoc = {
- start: targetLoc.start,
- end: targetLoc.end
- };
- if (!skipFirstLine || startLine > 1) {
- var startColumn = targetLoc.start.column + by;
- targetLoc.start = {
- line: startLine,
- column: noNegativeColumns
- ? Math.max(0, startColumn)
- : startColumn
- };
- }
- if (!skipFirstLine || endLine > 1) {
- var endColumn = targetLoc.end.column + by;
- targetLoc.end = {
- line: endLine,
- column: noNegativeColumns
- ? Math.max(0, endColumn)
- : endColumn
- };
- }
- return new Mapping(this.sourceLines, this.sourceLoc, targetLoc);
- };
- function skipChars(
- sourceLines, sourceFromPos,
- targetLines, targetFromPos, targetToPos
- ) {
- assert.ok(sourceLines instanceof linesModule.Lines);
- assert.ok(targetLines instanceof linesModule.Lines);
- Position.assert(sourceFromPos);
- Position.assert(targetFromPos);
- Position.assert(targetToPos);
- var targetComparison = comparePos(targetFromPos, targetToPos);
- if (targetComparison === 0) {
- // Trivial case: no characters to skip.
- return sourceFromPos;
- }
- if (targetComparison < 0) {
- // Skipping forward.
- var sourceCursor = sourceLines.skipSpaces(sourceFromPos);
- var targetCursor = targetLines.skipSpaces(targetFromPos);
- var lineDiff = targetToPos.line - targetCursor.line;
- sourceCursor.line += lineDiff;
- targetCursor.line += lineDiff;
- if (lineDiff > 0) {
- // If jumping to later lines, reset columns to the beginnings
- // of those lines.
- sourceCursor.column = 0;
- targetCursor.column = 0;
- } else {
- assert.strictEqual(lineDiff, 0);
- }
- while (comparePos(targetCursor, targetToPos) < 0 &&
- targetLines.nextPos(targetCursor, true)) {
- assert.ok(sourceLines.nextPos(sourceCursor, true));
- assert.strictEqual(
- sourceLines.charAt(sourceCursor),
- targetLines.charAt(targetCursor)
- );
- }
- } else {
- // Skipping backward.
- var sourceCursor = sourceLines.skipSpaces(sourceFromPos, true);
- var targetCursor = targetLines.skipSpaces(targetFromPos, true);
- var lineDiff = targetToPos.line - targetCursor.line;
- sourceCursor.line += lineDiff;
- targetCursor.line += lineDiff;
- if (lineDiff < 0) {
- // If jumping to earlier lines, reset columns to the ends of
- // those lines.
- sourceCursor.column = sourceLines.getLineLength(sourceCursor.line);
- targetCursor.column = targetLines.getLineLength(targetCursor.line);
- } else {
- assert.strictEqual(lineDiff, 0);
- }
- while (comparePos(targetToPos, targetCursor) < 0 &&
- targetLines.prevPos(targetCursor, true)) {
- assert.ok(sourceLines.prevPos(sourceCursor, true));
- assert.strictEqual(
- sourceLines.charAt(sourceCursor),
- targetLines.charAt(targetCursor)
- );
- }
- }
- return sourceCursor;
- }
- },{"./lines":461,"./types":467,"./util":468,"assert":190}],463:[function(require,module,exports){
- var defaults = {
- // If you want to use a different branch of esprima, or any other
- // module that supports a .parse function, pass that module object to
- // recast.parse as options.esprima.
- esprima: require("esprima-fb"),
- // Number of spaces the pretty-printer should use per tab for
- // indentation. If you do not pass this option explicitly, it will be
- // (quite reliably!) inferred from the original code.
- tabWidth: 4,
- // If you really want the pretty-printer to use tabs instead of
- // spaces, make this option true.
- useTabs: false,
- // The reprinting code leaves leading whitespace untouched unless it
- // has to reindent a line, or you pass false for this option.
- reuseWhitespace: true,
- // Some of the pretty-printer code (such as that for printing function
- // parameter lists) makes a valiant attempt to prevent really long
- // lines. You can adjust the limit by changing this option; however,
- // there is no guarantee that line length will fit inside this limit.
- wrapColumn: 74, // Aspirational for now.
- // Pass a string as options.sourceFileName to recast.parse to tell the
- // reprinter to keep track of reused code so that it can construct a
- // source map automatically.
- sourceFileName: null,
- // Pass a string as options.sourceMapName to recast.print, and
- // (provided you passed options.sourceFileName earlier) the
- // PrintResult of recast.print will have a .map property for the
- // generated source map.
- sourceMapName: null,
- // If provided, this option will be passed along to the source map
- // generator as a root directory for relative source file paths.
- sourceRoot: null,
- // If you provide a source map that was generated from a previous call
- // to recast.print as options.inputSourceMap, the old source map will
- // be composed with the new source map.
- inputSourceMap: null,
- // If you want esprima to generate .range information (recast only
- // uses .loc internally), pass true for this option.
- range: false,
- // If you want esprima not to throw exceptions when it encounters
- // non-fatal errors, keep this option true.
- tolerant: true,
-
- // If you want to override the quotes used in string literals, specify
- // either "single", "double", or "auto" here ("auto" will select the one
- // which results in the shorter literal)
- // Otherwise, the input marks will be preserved
- quote: null,
- }, hasOwn = defaults.hasOwnProperty;
- // Copy options and fill in default values.
- exports.normalize = function(options) {
- options = options || defaults;
- function get(key) {
- return hasOwn.call(options, key)
- ? options[key]
- : defaults[key];
- }
- return {
- tabWidth: +get("tabWidth"),
- useTabs: !!get("useTabs"),
- reuseWhitespace: !!get("reuseWhitespace"),
- wrapColumn: Math.max(get("wrapColumn"), 0),
- sourceFileName: get("sourceFileName"),
- sourceMapName: get("sourceMapName"),
- sourceRoot: get("sourceRoot"),
- inputSourceMap: get("inputSourceMap"),
- esprima: get("esprima"),
- range: get("range"),
- tolerant: get("tolerant"),
- quote: get("quote"),
- };
- };
- },{"esprima-fb":470}],464:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var n = types.namedTypes;
- var b = types.builders;
- var isObject = types.builtInTypes.object;
- var isArray = types.builtInTypes.array;
- var isFunction = types.builtInTypes.function;
- var Patcher = require("./patcher").Patcher;
- var normalizeOptions = require("./options").normalize;
- var fromString = require("./lines").fromString;
- var attachComments = require("./comments").attach;
- var util = require("./util");
- exports.parse = function parse(source, options) {
- options = normalizeOptions(options);
- var lines = fromString(source, options);
- var sourceWithoutTabs = lines.toString({
- tabWidth: options.tabWidth,
- reuseWhitespace: false,
- useTabs: false
- });
- var program = options.esprima.parse(sourceWithoutTabs, {
- loc: true,
- range: options.range,
- comment: true,
- tolerant: options.tolerant,
- sourceType: 'module'
- });
- // Expand the Program node's .loc to include all comments, since
- // typically its .loc.start and .loc.end will coincide with those of
- // the first and last statements, respectively, excluding any comments
- // that fall outside that region.
- program.loc = util.getTrueLoc(program);
- var comments = program.comments;
- delete program.comments;
- // In order to ensure we reprint leading and trailing program
- // comments, wrap the original Program node with a File node.
- var file = b.file(program);
- file.loc = {
- lines: lines,
- indent: 0,
- start: lines.firstPos(),
- end: lines.lastPos()
- };
- // Passing file.program here instead of just file means that initial
- // comments will be attached to program.body[0] instead of program.
- attachComments(
- comments,
- program.body.length ? file.program : file,
- lines
- );
- // Return a copy of the original AST so that any changes made may be
- // compared to the original.
- return new TreeCopier(lines).copy(file);
- };
- function TreeCopier(lines) {
- assert.ok(this instanceof TreeCopier);
- this.lines = lines;
- this.indent = 0;
- }
- var TCp = TreeCopier.prototype;
- TCp.copy = function(node) {
- if (isArray.check(node)) {
- return node.map(this.copy, this);
- }
- if (!isObject.check(node)) {
- return node;
- }
- util.fixFaultyLocations(node);
- var copy = Object.create(Object.getPrototypeOf(node), {
- original: { // Provide a link from the copy to the original.
- value: node,
- configurable: false,
- enumerable: false,
- writable: true
- }
- });
- var loc = node.loc;
- var oldIndent = this.indent;
- var newIndent = oldIndent;
- if (loc) {
- // When node is a comment, we set node.loc.indent to
- // node.loc.start.column so that, when/if we print the comment by
- // itself, we can strip that much whitespace from the left margin
- // of the comment. This only really matters for multiline Block
- // comments, but it doesn't hurt for Line comments.
- if (node.type === "Block" || node.type === "Line" ||
- this.lines.isPrecededOnlyByWhitespace(loc.start)) {
- newIndent = this.indent = loc.start.column;
- }
- loc.lines = this.lines;
- loc.indent = newIndent;
- }
- var keys = Object.keys(node);
- var keyCount = keys.length;
- for (var i = 0; i < keyCount; ++i) {
- var key = keys[i];
- if (key === "loc") {
- copy[key] = node[key];
- } else {
- copy[key] = this.copy(node[key]);
- }
- }
- this.indent = oldIndent;
- return copy;
- };
- },{"./comments":459,"./lines":461,"./options":463,"./patcher":465,"./types":467,"./util":468,"assert":190}],465:[function(require,module,exports){
- var assert = require("assert");
- var linesModule = require("./lines");
- var types = require("./types");
- var getFieldValue = types.getFieldValue;
- var Printable = types.namedTypes.Printable;
- var Expression = types.namedTypes.Expression;
- var SourceLocation = types.namedTypes.SourceLocation;
- var util = require("./util");
- var comparePos = util.comparePos;
- var FastPath = require("./fast-path");
- var isObject = types.builtInTypes.object;
- var isArray = types.builtInTypes.array;
- var isString = types.builtInTypes.string;
- var riskyAdjoiningCharExp = /[0-9a-z_$]/i;
- function Patcher(lines) {
- assert.ok(this instanceof Patcher);
- assert.ok(lines instanceof linesModule.Lines);
- var self = this,
- replacements = [];
- self.replace = function(loc, lines) {
- if (isString.check(lines))
- lines = linesModule.fromString(lines);
- replacements.push({
- lines: lines,
- start: loc.start,
- end: loc.end
- });
- };
- self.get = function(loc) {
- // If no location is provided, return the complete Lines object.
- loc = loc || {
- start: { line: 1, column: 0 },
- end: { line: lines.length,
- column: lines.getLineLength(lines.length) }
- };
- var sliceFrom = loc.start,
- toConcat = [];
- function pushSlice(from, to) {
- assert.ok(comparePos(from, to) <= 0);
- toConcat.push(lines.slice(from, to));
- }
- replacements.sort(function(a, b) {
- return comparePos(a.start, b.start);
- }).forEach(function(rep) {
- if (comparePos(sliceFrom, rep.start) > 0) {
- // Ignore nested replacement ranges.
- } else {
- pushSlice(sliceFrom, rep.start);
- toConcat.push(rep.lines);
- sliceFrom = rep.end;
- }
- });
- pushSlice(sliceFrom, loc.end);
- return linesModule.concat(toConcat);
- };
- }
- exports.Patcher = Patcher;
- var Pp = Patcher.prototype;
- Pp.tryToReprintComments = function(newNode, oldNode, print) {
- var patcher = this;
- if (!newNode.comments &&
- !oldNode.comments) {
- // We were (vacuously) able to reprint all the comments!
- return true;
- }
- var newPath = FastPath.from(newNode);
- var oldPath = FastPath.from(oldNode);
- newPath.stack.push("comments", getSurroundingComments(newNode));
- oldPath.stack.push("comments", getSurroundingComments(oldNode));
- var reprints = [];
- var ableToReprintComments =
- findArrayReprints(newPath, oldPath, reprints);
- // No need to pop anything from newPath.stack or oldPath.stack, since
- // newPath and oldPath are fresh local variables.
- if (ableToReprintComments && reprints.length > 0) {
- reprints.forEach(function(reprint) {
- var oldComment = reprint.oldPath.getValue();
- assert.ok(oldComment.leading || oldComment.trailing);
- patcher.replace(
- oldComment.loc,
- // Comments can't have .comments, so it doesn't matter
- // whether we print with comments or without.
- print(reprint.newPath).indentTail(oldComment.loc.indent)
- );
- });
- }
- return ableToReprintComments;
- };
- // Get all comments that are either leading or trailing, ignoring any
- // comments that occur inside node.loc. Returns an empty array for nodes
- // with no leading or trailing comments.
- function getSurroundingComments(node) {
- var result = [];
- if (node.comments &&
- node.comments.length > 0) {
- node.comments.forEach(function(comment) {
- if (comment.leading || comment.trailing) {
- result.push(comment);
- }
- });
- }
- return result;
- }
- Pp.deleteComments = function(node) {
- if (!node.comments) {
- return;
- }
- var patcher = this;
- node.comments.forEach(function(comment) {
- if (comment.leading) {
- // Delete leading comments along with any trailing whitespace
- // they might have.
- patcher.replace({
- start: comment.loc.start,
- end: node.loc.lines.skipSpaces(
- comment.loc.end, false, false)
- }, "");
- } else if (comment.trailing) {
- // Delete trailing comments along with any leading whitespace
- // they might have.
- patcher.replace({
- start: node.loc.lines.skipSpaces(
- comment.loc.start, true, false),
- end: comment.loc.end
- }, "");
- }
- });
- };
- exports.getReprinter = function(path) {
- assert.ok(path instanceof FastPath);
- // Make sure that this path refers specifically to a Node, rather than
- // some non-Node subproperty of a Node.
- var node = path.getValue();
- if (!Printable.check(node))
- return;
- var orig = node.original;
- var origLoc = orig && orig.loc;
- var lines = origLoc && origLoc.lines;
- var reprints = [];
- if (!lines || !findReprints(path, reprints))
- return;
- return function(print) {
- var patcher = new Patcher(lines);
- reprints.forEach(function(reprint) {
- var newNode = reprint.newPath.getValue();
- var oldNode = reprint.oldPath.getValue();
- SourceLocation.assert(oldNode.loc, true);
- var needToPrintNewPathWithComments =
- !patcher.tryToReprintComments(newNode, oldNode, print)
- if (needToPrintNewPathWithComments) {
- // Since we were not able to preserve all leading/trailing
- // comments, we delete oldNode's comments, print newPath
- // with comments, and then patch the resulting lines where
- // oldNode used to be.
- patcher.deleteComments(oldNode);
- }
- var pos = util.copyPos(oldNode.loc.start);
- var needsLeadingSpace = lines.prevPos(pos) &&
- riskyAdjoiningCharExp.test(lines.charAt(pos));
- var newLines = print(
- reprint.newPath,
- needToPrintNewPathWithComments
- ).indentTail(oldNode.loc.indent);
- var needsTrailingSpace =
- riskyAdjoiningCharExp.test(lines.charAt(oldNode.loc.end));
- // If we try to replace the argument of a ReturnStatement like
- // return"asdf" with e.g. a literal null expression, we run
- // the risk of ending up with returnnull, so we need to add an
- // extra leading space in situations where that might
- // happen. Likewise for "asdf"in obj. See #170.
- if (needsLeadingSpace || needsTrailingSpace) {
- var newParts = [];
- needsLeadingSpace && newParts.push(" ");
- newParts.push(newLines);
- needsTrailingSpace && newParts.push(" ");
- newLines = linesModule.concat(newParts);
- }
- patcher.replace(oldNode.loc, newLines);
- });
- // Recall that origLoc is the .loc of an ancestor node that is
- // guaranteed to contain all the reprinted nodes and comments.
- return patcher.get(origLoc).indentTail(-orig.loc.indent);
- };
- };
- function findReprints(newPath, reprints) {
- var newNode = newPath.getValue();
- Printable.assert(newNode);
- var oldNode = newNode.original;
- Printable.assert(oldNode);
- assert.deepEqual(reprints, []);
- if (newNode.type !== oldNode.type) {
- return false;
- }
- var oldPath = new FastPath(oldNode);
- var canReprint = findChildReprints(newPath, oldPath, reprints);
- if (!canReprint) {
- // Make absolutely sure the calling code does not attempt to reprint
- // any nodes.
- reprints.length = 0;
- }
- return canReprint;
- }
- function findAnyReprints(newPath, oldPath, reprints) {
- var newNode = newPath.getValue();
- var oldNode = oldPath.getValue();
- if (newNode === oldNode)
- return true;
- if (isArray.check(newNode))
- return findArrayReprints(newPath, oldPath, reprints);
- if (isObject.check(newNode))
- return findObjectReprints(newPath, oldPath, reprints);
- return false;
- }
- function findArrayReprints(newPath, oldPath, reprints) {
- var newNode = newPath.getValue();
- var oldNode = oldPath.getValue();
- isArray.assert(newNode);
- var len = newNode.length;
- if (!(isArray.check(oldNode) &&
- oldNode.length === len))
- return false;
- for (var i = 0; i < len; ++i) {
- newPath.stack.push(i, newNode[i]);
- oldPath.stack.push(i, oldNode[i]);
- var canReprint = findAnyReprints(newPath, oldPath, reprints);
- newPath.stack.length -= 2;
- oldPath.stack.length -= 2;
- if (!canReprint) {
- return false;
- }
- }
- return true;
- }
- function findObjectReprints(newPath, oldPath, reprints) {
- var newNode = newPath.getValue();
- isObject.assert(newNode);
- if (newNode.original === null) {
- // If newNode.original node was set to null, reprint the node.
- return false;
- }
- var oldNode = oldPath.getValue();
- if (!isObject.check(oldNode))
- return false;
- if (Printable.check(newNode)) {
- if (!Printable.check(oldNode)) {
- return false;
- }
- // Here we need to decide whether the reprinted code for newNode
- // is appropriate for patching into the location of oldNode.
- if (newNode.type === oldNode.type) {
- var childReprints = [];
- if (findChildReprints(newPath, oldPath, childReprints)) {
- reprints.push.apply(reprints, childReprints);
- } else if (oldNode.loc) {
- // If we have no .loc information for oldNode, then we
- // won't be able to reprint it.
- reprints.push({
- oldPath: oldPath.copy(),
- newPath: newPath.copy()
- });
- } else {
- return false;
- }
- return true;
- }
- if (Expression.check(newNode) &&
- Expression.check(oldNode) &&
- // If we have no .loc information for oldNode, then we won't
- // be able to reprint it.
- oldNode.loc) {
- // If both nodes are subtypes of Expression, then we should be
- // able to fill the location occupied by the old node with
- // code printed for the new node with no ill consequences.
- reprints.push({
- oldPath: oldPath.copy(),
- newPath: newPath.copy()
- });
- return true;
- }
- // The nodes have different types, and at least one of the types
- // is not a subtype of the Expression type, so we cannot safely
- // assume the nodes are syntactically interchangeable.
- return false;
- }
- return findChildReprints(newPath, oldPath, reprints);
- }
- // This object is reused in hasOpeningParen and hasClosingParen to avoid
- // having to allocate a temporary object.
- var reusablePos = { line: 1, column: 0 };
- var nonSpaceExp = /\S/;
- function hasOpeningParen(oldPath) {
- var oldNode = oldPath.getValue();
- var loc = oldNode.loc;
- var lines = loc && loc.lines;
- if (lines) {
- var pos = reusablePos;
- pos.line = loc.start.line;
- pos.column = loc.start.column;
- while (lines.prevPos(pos)) {
- var ch = lines.charAt(pos);
- if (ch === "(") {
- // If we found an opening parenthesis but it occurred before
- // the start of the original subtree for this reprinting, then
- // we must not return true for hasOpeningParen(oldPath).
- return comparePos(oldPath.getRootValue().loc.start, pos) <= 0;
- }
- if (nonSpaceExp.test(ch)) {
- return false;
- }
- }
- }
- return false;
- }
- function hasClosingParen(oldPath) {
- var oldNode = oldPath.getValue();
- var loc = oldNode.loc;
- var lines = loc && loc.lines;
- if (lines) {
- var pos = reusablePos;
- pos.line = loc.end.line;
- pos.column = loc.end.column;
- do {
- var ch = lines.charAt(pos);
- if (ch === ")") {
- // If we found a closing parenthesis but it occurred after the
- // end of the original subtree for this reprinting, then we
- // must not return true for hasClosingParen(oldPath).
- return comparePos(pos, oldPath.getRootValue().loc.end) <= 0;
- }
- if (nonSpaceExp.test(ch)) {
- return false;
- }
- } while (lines.nextPos(pos));
- }
- return false;
- }
- function hasParens(oldPath) {
- // This logic can technically be fooled if the node has parentheses
- // but there are comments intervening between the parentheses and the
- // node. In such cases the node will be harmlessly wrapped in an
- // additional layer of parentheses.
- return hasOpeningParen(oldPath) && hasClosingParen(oldPath);
- }
- function findChildReprints(newPath, oldPath, reprints) {
- var newNode = newPath.getValue();
- var oldNode = oldPath.getValue();
- isObject.assert(newNode);
- isObject.assert(oldNode);
- if (newNode.original === null) {
- // If newNode.original node was set to null, reprint the node.
- return false;
- }
- // If this type of node cannot come lexically first in its enclosing
- // statement (e.g. a function expression or object literal), and it
- // seems to be doing so, then the only way we can ignore this problem
- // and save ourselves from falling back to the pretty printer is if an
- // opening parenthesis happens to precede the node. For example,
- // (function(){ ... }()); does not need to be reprinted, even though
- // the FunctionExpression comes lexically first in the enclosing
- // ExpressionStatement and fails the hasParens test, because the
- // parent CallExpression passes the hasParens test. If we relied on
- // the path.needsParens() && !hasParens(oldNode) check below, the
- // absence of a closing parenthesis after the FunctionExpression would
- // trigger pretty-printing unnecessarily.
- if (!newPath.canBeFirstInStatement() &&
- newPath.firstInStatement() &&
- !hasOpeningParen(oldPath))
- return false;
- // If this node needs parentheses and will not be wrapped with
- // parentheses when reprinted, then return false to skip reprinting
- // and let it be printed generically.
- if (newPath.needsParens(true) && !hasParens(oldPath)) {
- return false;
- }
- for (var k in util.getUnionOfKeys(newNode, oldNode)) {
- if (k === "loc")
- continue;
- newPath.stack.push(k, types.getFieldValue(newNode, k));
- oldPath.stack.push(k, types.getFieldValue(oldNode, k));
- var canReprint = findAnyReprints(newPath, oldPath, reprints);
- newPath.stack.length -= 2;
- oldPath.stack.length -= 2;
- if (!canReprint) {
- return false;
- }
- }
- return true;
- }
- },{"./fast-path":460,"./lines":461,"./types":467,"./util":468,"assert":190}],466:[function(require,module,exports){
- var assert = require("assert");
- var sourceMap = require("source-map");
- var printComments = require("./comments").printComments;
- var linesModule = require("./lines");
- var fromString = linesModule.fromString;
- var concat = linesModule.concat;
- var normalizeOptions = require("./options").normalize;
- var getReprinter = require("./patcher").getReprinter;
- var types = require("./types");
- var namedTypes = types.namedTypes;
- var isString = types.builtInTypes.string;
- var isObject = types.builtInTypes.object;
- var FastPath = require("./fast-path");
- var util = require("./util");
- function PrintResult(code, sourceMap) {
- assert.ok(this instanceof PrintResult);
- isString.assert(code);
- this.code = code;
- if (sourceMap) {
- isObject.assert(sourceMap);
- this.map = sourceMap;
- }
- }
- var PRp = PrintResult.prototype;
- var warnedAboutToString = false;
- PRp.toString = function() {
- if (!warnedAboutToString) {
- console.warn(
- "Deprecation warning: recast.print now returns an object with " +
- "a .code property. You appear to be treating the object as a " +
- "string, which might still work but is strongly discouraged."
- );
- warnedAboutToString = true;
- }
- return this.code;
- };
- var emptyPrintResult = new PrintResult("");
- function Printer(originalOptions) {
- assert.ok(this instanceof Printer);
- var explicitTabWidth = originalOptions && originalOptions.tabWidth;
- var options = normalizeOptions(originalOptions);
- assert.notStrictEqual(options, originalOptions);
- // It's common for client code to pass the same options into both
- // recast.parse and recast.print, but the Printer doesn't need (and
- // can be confused by) options.sourceFileName, so we null it out.
- options.sourceFileName = null;
- function printWithComments(path) {
- assert.ok(path instanceof FastPath);
- return printComments(path, print);
- }
- function print(path, includeComments) {
- if (includeComments)
- return printWithComments(path);
- assert.ok(path instanceof FastPath);
- if (!explicitTabWidth) {
- var oldTabWidth = options.tabWidth;
- var loc = path.getNode().loc;
- if (loc && loc.lines && loc.lines.guessTabWidth) {
- options.tabWidth = loc.lines.guessTabWidth();
- var lines = maybeReprint(path);
- options.tabWidth = oldTabWidth;
- return lines;
- }
- }
- return maybeReprint(path);
- }
- function maybeReprint(path) {
- var reprinter = getReprinter(path);
- if (reprinter)
- return maybeAddParens(path, reprinter(print));
- return printRootGenerically(path);
- }
- // Print the root node generically, but then resume reprinting its
- // children non-generically.
- function printRootGenerically(path) {
- return genericPrint(path, options, printWithComments);
- }
- // Print the entire AST generically.
- function printGenerically(path) {
- return genericPrint(path, options, printGenerically);
- }
- this.print = function(ast) {
- if (!ast) {
- return emptyPrintResult;
- }
- var lines = print(FastPath.from(ast), true);
- return new PrintResult(
- lines.toString(options),
- util.composeSourceMaps(
- options.inputSourceMap,
- lines.getSourceMap(
- options.sourceMapName,
- options.sourceRoot
- )
- )
- );
- };
- this.printGenerically = function(ast) {
- if (!ast) {
- return emptyPrintResult;
- }
- var path = FastPath.from(ast);
- var oldReuseWhitespace = options.reuseWhitespace;
- // Do not reuse whitespace (or anything else, for that matter)
- // when printing generically.
- options.reuseWhitespace = false;
- // TODO Allow printing of comments?
- var pr = new PrintResult(printGenerically(path).toString(options));
- options.reuseWhitespace = oldReuseWhitespace;
- return pr;
- };
- }
- exports.Printer = Printer;
- function maybeAddParens(path, lines) {
- return path.needsParens() ? concat(["(", lines, ")"]) : lines;
- }
- function genericPrint(path, options, printPath) {
- assert.ok(path instanceof FastPath);
- return maybeAddParens(path, genericPrintNoParens(path, options, printPath));
- }
- function genericPrintNoParens(path, options, print) {
- var n = path.getValue();
- if (!n) {
- return fromString("");
- }
- if (typeof n === "string") {
- return fromString(n, options);
- }
- namedTypes.Printable.assert(n);
- switch (n.type) {
- case "File":
- return path.call(print, "program");
- case "Program":
- return maybeAddSemicolon(path.call(function(bodyPath) {
- return printStatementSequence(bodyPath, options, print);
- }, "body"));
- case "EmptyStatement":
- return fromString("");
- case "ExpressionStatement":
- return concat([path.call(print, "expression"), ";"]);
- case "BinaryExpression":
- case "LogicalExpression":
- case "AssignmentExpression":
- return fromString(" ").join([
- path.call(print, "left"),
- n.operator,
- path.call(print, "right")
- ]);
- case "AssignmentPattern":
- return concat([
- path.call(print, "left"),
- "=",
- path.call(print, "right")
- ]);
- case "MemberExpression":
- var parts = [path.call(print, "object")];
- var property = path.call(print, "property");
- if (n.computed) {
- parts.push("[", property, "]");
- } else {
- parts.push(".", property);
- }
- return concat(parts);
- case "Path":
- return fromString(".").join(n.body);
- case "Identifier":
- return concat([
- fromString(n.name, options),
- path.call(print, "typeAnnotation")
- ]);
- case "SpreadElement":
- case "SpreadElementPattern":
- case "SpreadProperty":
- case "SpreadPropertyPattern":
- case "RestElement":
- return concat(["...", path.call(print, "argument")]);
- case "FunctionDeclaration":
- case "FunctionExpression":
- var parts = [];
- if (n.async)
- parts.push("async ");
- parts.push("function");
- if (n.generator)
- parts.push("*");
- if (n.id) {
- parts.push(
- " ",
- path.call(print, "id"),
- path.call(print, "typeParameters")
- );
- }
- parts.push(
- "(",
- printFunctionParams(path, options, print),
- ")",
- path.call(print, "returnType"),
- " ",
- path.call(print, "body")
- );
- return concat(parts);
- case "ArrowFunctionExpression":
- var parts = [];
- if (n.async)
- parts.push("async ");
- if (n.params.length === 1 && !n.rest) {
- parts.push(path.call(print, "params", 0));
- } else {
- parts.push(
- "(",
- printFunctionParams(path, options, print),
- ")"
- );
- }
- parts.push(" => ", path.call(print, "body"));
- return concat(parts);
- case "MethodDefinition":
- var parts = [];
- if (n.static) {
- parts.push("static ");
- }
- parts.push(printMethod(path, options, print));
- return concat(parts);
- case "YieldExpression":
- var parts = ["yield"];
- if (n.delegate)
- parts.push("*");
- if (n.argument)
- parts.push(" ", path.call(print, "argument"));
- return concat(parts);
- case "AwaitExpression":
- var parts = ["await"];
- if (n.all)
- parts.push("*");
- if (n.argument)
- parts.push(" ", path.call(print, "argument"));
- return concat(parts);
- case "ModuleDeclaration":
- var parts = ["module", path.call(print, "id")];
- if (n.source) {
- assert.ok(!n.body);
- parts.push("from", path.call(print, "source"));
- } else {
- parts.push(path.call(print, "body"));
- }
- return fromString(" ").join(parts);
- case "ImportSpecifier":
- case "ExportSpecifier":
- var parts = [path.call(print, "id")];
- if (n.name)
- parts.push(" as ", path.call(print, "name"));
- return concat(parts);
- case "ExportBatchSpecifier":
- return fromString("*");
- case "ImportNamespaceSpecifier":
- return concat(["* as ", path.call(print, "id")]);
- case "ImportDefaultSpecifier":
- return path.call(print, "id");
- case "ExportDeclaration":
- var parts = ["export"];
- if (n["default"]) {
- parts.push(" default");
- } else if (n.specifiers &&
- n.specifiers.length > 0) {
- if (n.specifiers.length === 1 &&
- n.specifiers[0].type === "ExportBatchSpecifier") {
- parts.push(" *");
- } else {
- parts.push(
- " { ",
- fromString(", ").join(path.map(print, "specifiers")),
- " }"
- );
- }
- if (n.source)
- parts.push(" from ", path.call(print, "source"));
- parts.push(";");
- return concat(parts);
- }
- if (n.declaration) {
- if (!namedTypes.Node.check(n.declaration)) {
- console.log(JSON.stringify(n, null, 2));
- }
- var decLines = path.call(print, "declaration");
- parts.push(" ", decLines);
- if (lastNonSpaceCharacter(decLines) !== ";") {
- parts.push(";");
- }
- }
- return concat(parts);
- case "ImportDeclaration":
- var parts = ["import "];
- if (n.specifiers &&
- n.specifiers.length > 0) {
- var foundImportSpecifier = false;
- path.each(function(specifierPath) {
- var i = specifierPath.getName();
- if (i > 0) {
- parts.push(", ");
- }
- var value = specifierPath.getValue();
- if (namedTypes.ImportDefaultSpecifier.check(value) ||
- namedTypes.ImportNamespaceSpecifier.check(value)) {
- assert.strictEqual(foundImportSpecifier, false);
- } else {
- namedTypes.ImportSpecifier.assert(value);
- if (!foundImportSpecifier) {
- foundImportSpecifier = true;
- parts.push("{");
- }
- }
- parts.push(print(specifierPath));
- }, "specifiers");
- if (foundImportSpecifier) {
- parts.push("}");
- }
- parts.push(" from ");
- }
- parts.push(path.call(print, "source"), ";");
- return concat(parts);
- case "BlockStatement":
- var naked = path.call(function(bodyPath) {
- return printStatementSequence(bodyPath, options, print);
- }, "body");
- if (naked.isEmpty()) {
- return fromString("{}");
- }
- return concat([
- "{\n",
- naked.indent(options.tabWidth),
- "\n}"
- ]);
- case "ReturnStatement":
- var parts = ["return"];
- if (n.argument) {
- var argLines = path.call(print, "argument");
- if (argLines.length > 1 &&
- (namedTypes.XJSElement &&
- namedTypes.XJSElement.check(n.argument) ||
- namedTypes.JSXElement &&
- namedTypes.JSXElement.check(n.argument))) {
- parts.push(
- " (\n",
- argLines.indent(options.tabWidth),
- "\n)"
- );
- } else {
- parts.push(" ", argLines);
- }
- }
- parts.push(";");
- return concat(parts);
- case "CallExpression":
- return concat([
- path.call(print, "callee"),
- printArgumentsList(path, options, print)
- ]);
- case "ObjectExpression":
- case "ObjectPattern":
- case "ObjectTypeAnnotation":
- var allowBreak = false;
- var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
- var separator = isTypeAnnotation ? ';' : ',';
- var fields = [];
- if (isTypeAnnotation) {
- fields.push("indexers", "callProperties");
- }
- fields.push("properties");
- var len = 0;
- fields.forEach(function(field) {
- len += n[field].length;
- });
- var oneLine = (isTypeAnnotation && len === 1) || len === 0;
- var parts = [oneLine ? "{" : "{\n"];
- fields.forEach(function(field) {
- path.map(function(childPath) {
- var i = childPath.getName();
- var prop = childPath.getValue();
- var lines = print(childPath);
- if (!oneLine) {
- lines = lines.indent(options.tabWidth);
- }
- var multiLine = !isTypeAnnotation && lines.length > 1;
- if (multiLine && allowBreak) {
- // Similar to the logic for BlockStatement.
- parts.push("\n");
- }
- parts.push(lines);
- if (i < len - 1) {
- // Add an extra line break if the previous object property
- // had a multi-line value.
- parts.push(separator + (multiLine ? "\n\n" : "\n"));
- allowBreak = !multiLine;
- } else if (len !== 1 && isTypeAnnotation) {
- parts.push(separator);
- }
- }, field);
- });
- parts.push(oneLine ? "}" : "\n}");
- return concat(parts);
- case "PropertyPattern":
- return concat([
- path.call(print, "key"),
- ": ",
- path.call(print, "pattern")
- ]);
- case "Property": // Non-standard AST node type.
- if (n.method || n.kind === "get" || n.kind === "set") {
- return printMethod(path, options, print);
- }
- var key = path.call(print, "key");
- if (n.computed) {
- key = concat(["[", key, "]"]);
- }
- if (n.shorthand) {
- return key;
- }
- return concat([key, ": ", path.call(print, "value")]);
- case "ArrayExpression":
- case "ArrayPattern":
- var elems = n.elements,
- len = elems.length,
- parts = ["["];
- path.each(function(elemPath) {
- var i = elemPath.getName();
- var elem = elemPath.getValue();
- if (!elem) {
- // If the array expression ends with a hole, that hole
- // will be ignored by the interpreter, but if it ends with
- // two (or more) holes, we need to write out two (or more)
- // commas so that the resulting code is interpreted with
- // both (all) of the holes.
- parts.push(",");
- } else {
- if (i > 0)
- parts.push(" ");
- parts.push(print(elemPath));
- if (i < len - 1)
- parts.push(",");
- }
- }, "elements");
- parts.push("]");
- return concat(parts);
- case "SequenceExpression":
- return fromString(", ").join(path.map(print, "expressions"));
- case "ThisExpression":
- return fromString("this");
- case "Literal":
- if (typeof n.value !== "string")
- return fromString(n.value, options);
- // intentionally fall through...
- case "ModuleSpecifier":
- return fromString(nodeStr(n.value, options), options);
- case "UnaryExpression":
- var parts = [n.operator];
- if (/[a-z]$/.test(n.operator))
- parts.push(" ");
- parts.push(path.call(print, "argument"));
- return concat(parts);
- case "UpdateExpression":
- var parts = [path.call(print, "argument"), n.operator];
- if (n.prefix)
- parts.reverse();
- return concat(parts);
- case "ConditionalExpression":
- return concat([
- "(", path.call(print, "test"),
- " ? ", path.call(print, "consequent"),
- " : ", path.call(print, "alternate"), ")"
- ]);
- case "NewExpression":
- var parts = ["new ", path.call(print, "callee")];
- var args = n.arguments;
- if (args) {
- parts.push(printArgumentsList(path, options, print));
- }
- return concat(parts);
- case "VariableDeclaration":
- var parts = [n.kind, " "];
- var maxLen = 0;
- var printed = path.map(function(childPath) {
- var lines = print(childPath);
- maxLen = Math.max(lines.length, maxLen);
- return lines;
- }, "declarations");
- if (maxLen === 1) {
- parts.push(fromString(", ").join(printed));
- } else if (printed.length > 1 ) {
- parts.push(
- fromString(",\n").join(printed)
- .indentTail(n.kind.length + 1)
- );
- } else {
- parts.push(printed[0]);
- }
- // We generally want to terminate all variable declarations with a
- // semicolon, except when they are children of for loops.
- var parentNode = path.getParentNode();
- if (!namedTypes.ForStatement.check(parentNode) &&
- !namedTypes.ForInStatement.check(parentNode) &&
- !(namedTypes.ForOfStatement &&
- namedTypes.ForOfStatement.check(parentNode))) {
- parts.push(";");
- }
- return concat(parts);
- case "VariableDeclarator":
- return n.init ? fromString(" = ").join([
- path.call(print, "id"),
- path.call(print, "init")
- ]) : path.call(print, "id");
- case "WithStatement":
- return concat([
- "with (",
- path.call(print, "object"),
- ") ",
- path.call(print, "body")
- ]);
- case "IfStatement":
- var con = adjustClause(path.call(print, "consequent"), options),
- parts = ["if (", path.call(print, "test"), ")", con];
- if (n.alternate)
- parts.push(
- endsWithBrace(con) ? " else" : "\nelse",
- adjustClause(path.call(print, "alternate"), options));
- return concat(parts);
- case "ForStatement":
- // TODO Get the for (;;) case right.
- var init = path.call(print, "init"),
- sep = init.length > 1 ? ";\n" : "; ",
- forParen = "for (",
- indented = fromString(sep).join([
- init,
- path.call(print, "test"),
- path.call(print, "update")
- ]).indentTail(forParen.length),
- head = concat([forParen, indented, ")"]),
- clause = adjustClause(path.call(print, "body"), options),
- parts = [head];
- if (head.length > 1) {
- parts.push("\n");
- clause = clause.trimLeft();
- }
- parts.push(clause);
- return concat(parts);
- case "WhileStatement":
- return concat([
- "while (",
- path.call(print, "test"),
- ")",
- adjustClause(path.call(print, "body"), options)
- ]);
- case "ForInStatement":
- // Note: esprima can't actually parse "for each (".
- return concat([
- n.each ? "for each (" : "for (",
- path.call(print, "left"),
- " in ",
- path.call(print, "right"),
- ")",
- adjustClause(path.call(print, "body"), options)
- ]);
- case "ForOfStatement":
- return concat([
- "for (",
- path.call(print, "left"),
- " of ",
- path.call(print, "right"),
- ")",
- adjustClause(path.call(print, "body"), options)
- ]);
- case "DoWhileStatement":
- var doBody = concat([
- "do",
- adjustClause(path.call(print, "body"), options)
- ]), parts = [doBody];
- if (endsWithBrace(doBody))
- parts.push(" while");
- else
- parts.push("\nwhile");
- parts.push(" (", path.call(print, "test"), ");");
- return concat(parts);
- case "BreakStatement":
- var parts = ["break"];
- if (n.label)
- parts.push(" ", path.call(print, "label"));
- parts.push(";");
- return concat(parts);
- case "ContinueStatement":
- var parts = ["continue"];
- if (n.label)
- parts.push(" ", path.call(print, "label"));
- parts.push(";");
- return concat(parts);
- case "LabeledStatement":
- return concat([
- path.call(print, "label"),
- ":\n",
- path.call(print, "body")
- ]);
- case "TryStatement":
- var parts = [
- "try ",
- path.call(print, "block")
- ];
- if (n.handler) {
- parts.push(" ", path.call(print, "handler"));
- } else if (n.handlers) {
- path.each(function(handlerPath) {
- parts.push(" ", print(handlerPath));
- }, "handlers");
- }
- if (n.finalizer) {
- parts.push(" finally ", path.call(print, "finalizer"));
- }
- return concat(parts);
- case "CatchClause":
- var parts = ["catch (", path.call(print, "param")];
- if (n.guard)
- // Note: esprima does not recognize conditional catch clauses.
- parts.push(" if ", path.call(print, "guard"));
- parts.push(") ", path.call(print, "body"));
- return concat(parts);
- case "ThrowStatement":
- return concat(["throw ", path.call(print, "argument"), ";"]);
- case "SwitchStatement":
- return concat([
- "switch (",
- path.call(print, "discriminant"),
- ") {\n",
- fromString("\n").join(path.map(print, "cases")),
- "\n}"
- ]);
- // Note: ignoring n.lexical because it has no printing consequences.
- case "SwitchCase":
- var parts = [];
- if (n.test)
- parts.push("case ", path.call(print, "test"), ":");
- else
- parts.push("default:");
- if (n.consequent.length > 0) {
- parts.push("\n", path.call(function(consequentPath) {
- return printStatementSequence(consequentPath, options, print);
- }, "consequent").indent(options.tabWidth));
- }
- return concat(parts);
- case "DebuggerStatement":
- return fromString("debugger;");
- // JSX extensions below.
- case "XJSAttribute":
- case "JSXAttribute":
- var parts = [path.call(print, "name")];
- if (n.value)
- parts.push("=", path.call(print, "value"));
- return concat(parts);
- case "XJSIdentifier":
- case "JSXIdentifier":
- return fromString(n.name, options);
- case "XJSNamespacedName":
- case "JSXNamespacedName":
- return fromString(":").join([
- path.call(print, "namespace"),
- path.call(print, "name")
- ]);
- case "XJSMemberExpression":
- case "JSXMemberExpression":
- return fromString(".").join([
- path.call(print, "object"),
- path.call(print, "property")
- ]);
- case "XJSSpreadAttribute":
- case "JSXSpreadAttribute":
- return concat(["{...", path.call(print, "argument"), "}"]);
- case "XJSExpressionContainer":
- case "JSXExpressionContainer":
- return concat(["{", path.call(print, "expression"), "}"]);
- case "XJSElement":
- case "JSXElement":
- var openingLines = path.call(print, "openingElement");
- if (n.openingElement.selfClosing) {
- assert.ok(!n.closingElement);
- return openingLines;
- }
- var childLines = concat(
- path.map(function(childPath) {
- var child = childPath.getValue();
- if (namedTypes.Literal.check(child) &&
- typeof child.value === "string") {
- if (/\S/.test(child.value)) {
- return child.value.replace(/^\s+|\s+$/g, "");
- } else if (/\n/.test(child.value)) {
- return "\n";
- }
- }
- return print(childPath);
- }, "children")
- ).indentTail(options.tabWidth);
- var closingLines = path.call(print, "closingElement");
- return concat([
- openingLines,
- childLines,
- closingLines
- ]);
- case "XJSOpeningElement":
- case "JSXOpeningElement":
- var parts = ["<", path.call(print, "name")];
- var attrParts = [];
- path.each(function(attrPath) {
- attrParts.push(" ", print(attrPath));
- }, "attributes");
- var attrLines = concat(attrParts);
- var needLineWrap = (
- attrLines.length > 1 ||
- attrLines.getLineLength(1) > options.wrapColumn
- );
- if (needLineWrap) {
- attrParts.forEach(function(part, i) {
- if (part === " ") {
- assert.strictEqual(i % 2, 0);
- attrParts[i] = "\n";
- }
- });
- attrLines = concat(attrParts).indentTail(options.tabWidth);
- }
- parts.push(attrLines, n.selfClosing ? " />" : ">");
- return concat(parts);
- case "XJSClosingElement":
- case "JSXClosingElement":
- return concat(["</", path.call(print, "name"), ">"]);
- case "XJSText":
- case "JSXText":
- return fromString(n.value, options);
- case "XJSEmptyExpression":
- case "JSXEmptyExpression":
- return fromString("");
- case "TypeAnnotatedIdentifier":
- return concat([
- path.call(print, "annotation"),
- " ",
- path.call(print, "identifier")
- ]);
- case "ClassBody":
- if (n.body.length === 0) {
- return fromString("{}");
- }
- return concat([
- "{\n",
- path.call(function(bodyPath) {
- return printStatementSequence(bodyPath, options, print);
- }, "body").indent(options.tabWidth),
- "\n}"
- ]);
- case "ClassPropertyDefinition":
- var parts = ["static ", path.call(print, "definition")];
- if (!namedTypes.MethodDefinition.check(n.definition))
- parts.push(";");
- return concat(parts);
- case "ClassProperty":
- return concat([
- path.call(print, "key"),
- path.call(print, "typeAnnotation"),
- ";"
- ]);
- case "ClassDeclaration":
- case "ClassExpression":
- var parts = ["class"];
- if (n.id) {
- parts.push(
- " ",
- path.call(print, "id"),
- path.call(print, "typeParameters")
- );
- }
- if (n.superClass) {
- parts.push(
- " extends ",
- path.call(print, "superClass"),
- path.call(print, "superTypeParameters")
- );
- }
- if (n["implements"]) {
- parts.push(
- " implements ",
- fromString(", ").join(path.map(print, "implements"))
- );
- }
- parts.push(" ", path.call(print, "body"));
- return concat(parts);
- // These types are unprintable because they serve as abstract
- // supertypes for other (printable) types.
- case "Node":
- case "Printable":
- case "SourceLocation":
- case "Position":
- case "Statement":
- case "Function":
- case "Pattern":
- case "Expression":
- case "Declaration":
- case "Specifier":
- case "NamedSpecifier":
- case "Comment": // Supertype of Block and Line.
- case "MemberTypeAnnotation": // Flow
- case "TupleTypeAnnotation": // Flow
- case "Type": // Flow
- throw new Error("unprintable type: " + JSON.stringify(n.type));
- case "Block": // Block comment.
- return concat(["/*", fromString(n.value, options), "*/"]);
- case "Line": // Line comment.
- return concat(["//", fromString(n.value, options)]);
- // Type Annotations for Facebook Flow, typically stripped out or
- // transformed away before printing.
- case "TypeAnnotation":
- var parts = [];
- if (n.typeAnnotation) {
- if (n.typeAnnotation.type !== "FunctionTypeAnnotation") {
- parts.push(": ");
- }
- parts.push(path.call(print, "typeAnnotation"));
- return concat(parts);
- }
- return fromString("");
- case "AnyTypeAnnotation":
- return fromString("any", options);
- case "ArrayTypeAnnotation":
- return concat([
- path.call(print, "elementType"),
- "[]"
- ]);
- case "BooleanTypeAnnotation":
- return fromString("boolean", options);
- case "DeclareClass":
- return concat([
- fromString("declare class ", options),
- path.call(print, "id"),
- " ",
- path.call(print, "body"),
- ]);
- case "DeclareFunction":
- return concat([
- fromString("declare function ", options),
- path.call(print, "id")
- ]);
- case "DeclareModule":
- return concat([
- fromString("declare module ", options),
- path.call(print, "id"),
- " ",
- path.call(print, "body"),
- ]);
- case "DeclareVariable":
- return concat([
- fromString("declare var ", options),
- path.call(print, "id")
- ]);
- case "FunctionTypeAnnotation":
- // FunctionTypeAnnotation is ambiguous:
- // declare function(a: B): void; OR
- // var A: (a: B) => void;
- var parts = [];
- var parent = path.getParentNode(0);
- var isArrowFunctionTypeAnnotation = !(
- namedTypes.ObjectTypeCallProperty.check(parent) ||
- namedTypes.DeclareFunction.check(path.getParentNode(2))
- );
- var needsColon =
- isArrowFunctionTypeAnnotation &&
- !namedTypes.FunctionTypeParam.check(parent);
- if (needsColon) {
- parts.push(": ");
- }
- parts.push(
- "(",
- fromString(", ").join(path.map(print, "params")),
- ")"
- );
- // The returnType is not wrapped in a TypeAnnotation, so the colon
- // needs to be added separately.
- if (n.returnType) {
- parts.push(
- isArrowFunctionTypeAnnotation ? " => " : ": ",
- path.call(print, "returnType")
- );
- }
- return concat(parts);
- case "FunctionTypeParam":
- return concat([
- path.call(print, "name"),
- ": ",
- path.call(print, "typeAnnotation"),
- ]);
- case "GenericTypeAnnotation":
- return concat([
- path.call(print, "id"),
- path.call(print, "typeParameters")
- ]);
- case "InterfaceDeclaration":
- var parts = [
- fromString("interface ", options),
- path.call(print, "id"),
- path.call(print, "typeParameters"),
- " "
- ];
- if (n["extends"]) {
- parts.push(
- "extends ",
- fromString(", ").join(path.map(print, "extends"))
- );
- }
- parts.push(path.call(print, "body"));
- return concat(parts);
- case "ClassImplements":
- case "InterfaceExtends":
- return concat([
- path.call(print, "id"),
- path.call(print, "typeParameters")
- ]);
- case "IntersectionTypeAnnotation":
- return fromString(" & ").join(path.map(print, "types"));
- case "NullableTypeAnnotation":
- return concat([
- "?",
- path.call(print, "typeAnnotation")
- ]);
- case "NumberTypeAnnotation":
- return fromString("number", options);
- case "ObjectTypeCallProperty":
- return path.call(print, "value");
- case "ObjectTypeIndexer":
- return concat([
- "[",
- path.call(print, "id"),
- ": ",
- path.call(print, "key"),
- "]: ",
- path.call(print, "value")
- ]);
- case "ObjectTypeProperty":
- return concat([
- path.call(print, "key"),
- ": ",
- path.call(print, "value")
- ]);
- case "QualifiedTypeIdentifier":
- return concat([
- path.call(print, "qualification"),
- ".",
- path.call(print, "id")
- ]);
- case "StringLiteralTypeAnnotation":
- return fromString(nodeStr(n.value, options), options);
- case "StringTypeAnnotation":
- return fromString("string", options);
- case "TypeAlias":
- return concat([
- "type ",
- path.call(print, "id"),
- " = ",
- path.call(print, "right")
- ]);
- case "TypeCastExpression":
- return concat([
- "(",
- path.call(print, "expression"),
- path.call(print, "typeAnnotation"),
- ")"
- ]);
- case "TypeParameterDeclaration":
- case "TypeParameterInstantiation":
- return concat([
- "<",
- fromString(", ").join(path.map(print, "params")),
- ">"
- ]);
- case "TypeofTypeAnnotation":
- return concat([
- fromString("typeof ", options),
- path.call(print, "argument")
- ]);
- case "UnionTypeAnnotation":
- return fromString(" | ").join(path.map(print, "types"));
- case "VoidTypeAnnotation":
- return fromString("void", options);
- // Unhandled types below. If encountered, nodes of these types should
- // be either left alone or desugared into AST types that are fully
- // supported by the pretty-printer.
- case "ClassHeritage": // TODO
- case "ComprehensionBlock": // TODO
- case "ComprehensionExpression": // TODO
- case "Glob": // TODO
- case "TaggedTemplateExpression": // TODO
- case "TemplateElement": // TODO
- case "TemplateLiteral": // TODO
- case "GeneratorExpression": // TODO
- case "LetStatement": // TODO
- case "LetExpression": // TODO
- case "GraphExpression": // TODO
- case "GraphIndexExpression": // TODO
- // XML types that nobody cares about or needs to print.
- case "XMLDefaultDeclaration":
- case "XMLAnyName":
- case "XMLQualifiedIdentifier":
- case "XMLFunctionQualifiedIdentifier":
- case "XMLAttributeSelector":
- case "XMLFilterExpression":
- case "XML":
- case "XMLElement":
- case "XMLList":
- case "XMLEscape":
- case "XMLText":
- case "XMLStartTag":
- case "XMLEndTag":
- case "XMLPointTag":
- case "XMLName":
- case "XMLAttribute":
- case "XMLCdata":
- case "XMLComment":
- case "XMLProcessingInstruction":
- default:
- debugger;
- throw new Error("unknown type: " + JSON.stringify(n.type));
- }
- return p;
- }
- function printStatementSequence(path, options, print) {
- var inClassBody =
- namedTypes.ClassBody &&
- namedTypes.ClassBody.check(path.getParentNode());
- var filtered = [];
- path.each(function(stmtPath) {
- var i = stmtPath.getName();
- var stmt = stmtPath.getValue();
- // Just in case the AST has been modified to contain falsy
- // "statements," it's safer simply to skip them.
- if (!stmt) {
- return;
- }
- // Skip printing EmptyStatement nodes to avoid leaving stray
- // semicolons lying around.
- if (stmt.type === "EmptyStatement") {
- return;
- }
- if (!inClassBody) {
- namedTypes.Statement.assert(stmt);
- }
- // We can't hang onto stmtPath outside of this function, because
- // it's just a reference to a mutable FastPath object, so we have
- // to go ahead and print it here.
- filtered.push({
- node: stmt,
- printed: print(stmtPath)
- });
- });
- var prevTrailingSpace = null;
- var len = filtered.length;
- var parts = [];
- filtered.forEach(function(info, i) {
- var printed = info.printed;
- var stmt = info.node;
- var needSemicolon = true;
- var multiLine = printed.length > 1;
- var notFirst = i > 0;
- var notLast = i < len - 1;
- var leadingSpace;
- var trailingSpace;
- if (inClassBody) {
- if (namedTypes.MethodDefinition.check(stmt) ||
- (namedTypes.ClassPropertyDefinition.check(stmt) &&
- namedTypes.MethodDefinition.check(stmt.definition))) {
- needSemicolon = false;
- }
- }
- if (needSemicolon) {
- // Try to add a semicolon to anything that isn't a method in a
- // class body.
- printed = maybeAddSemicolon(printed);
- }
- var trueLoc = options.reuseWhitespace && util.getTrueLoc(stmt);
- var lines = trueLoc && trueLoc.lines;
- if (notFirst) {
- if (lines) {
- var beforeStart = lines.skipSpaces(trueLoc.start, true);
- var beforeStartLine = beforeStart ? beforeStart.line : 1;
- var leadingGap = trueLoc.start.line - beforeStartLine;
- leadingSpace = Array(leadingGap + 1).join("\n");
- } else {
- leadingSpace = multiLine ? "\n\n" : "\n";
- }
- } else {
- leadingSpace = "";
- }
- if (notLast) {
- if (lines) {
- var afterEnd = lines.skipSpaces(trueLoc.end);
- var afterEndLine = afterEnd ? afterEnd.line : lines.length;
- var trailingGap = afterEndLine - trueLoc.end.line;
- trailingSpace = Array(trailingGap + 1).join("\n");
- } else {
- trailingSpace = multiLine ? "\n\n" : "\n";
- }
- } else {
- trailingSpace = "";
- }
- parts.push(
- maxSpace(prevTrailingSpace, leadingSpace),
- printed
- );
- if (notLast) {
- prevTrailingSpace = trailingSpace;
- } else if (trailingSpace) {
- parts.push(trailingSpace);
- }
- });
- return concat(parts);
- }
- function maxSpace(s1, s2) {
- if (!s1 && !s2) {
- return fromString("");
- }
- if (!s1) {
- return fromString(s2);
- }
- if (!s2) {
- return fromString(s1);
- }
- var spaceLines1 = fromString(s1);
- var spaceLines2 = fromString(s2);
- if (spaceLines2.length > spaceLines1.length) {
- return spaceLines2;
- }
- return spaceLines1;
- }
- function printMethod(path, options, print) {
- var node = path.getNode();
- var kind = node.kind;
- var parts = [];
- namedTypes.FunctionExpression.assert(node.value);
- if (node.value.async) {
- parts.push("async ");
- }
- if (!kind || kind === "init") {
- if (node.value.generator) {
- parts.push("*");
- }
- } else {
- assert.ok(kind === "get" || kind === "set");
- parts.push(kind, " ");
- }
- var key = path.call(print, "key");
- if (node.computed) {
- key = concat(["[", key, "]"]);
- }
- parts.push(
- key,
- path.call(print, "value", "typeParameters"),
- "(",
- path.call(function(valuePath) {
- return printFunctionParams(valuePath, options, print);
- }, "value"),
- ")",
- path.call(print, "value", "returnType"),
- " ",
- path.call(print, "value", "body")
- );
- return concat(parts);
- }
- function printArgumentsList(path, options, print) {
- var printed = path.map(print, "arguments");
- var joined = fromString(", ").join(printed);
- if (joined.getLineLength(1) > options.wrapColumn) {
- joined = fromString(",\n").join(printed);
- return concat(["(\n", joined.indent(options.tabWidth), "\n)"]);
- }
- return concat(["(", joined, ")"]);
- }
- function printFunctionParams(path, options, print) {
- var fun = path.getValue();
- namedTypes.Function.assert(fun);
- var printed = path.map(print, "params");
- if (fun.defaults) {
- path.each(function(defExprPath) {
- var i = defExprPath.getName();
- var p = printed[i];
- if (p && defExprPath.getValue()) {
- printed[i] = concat([p, "=", print(defExprPath)]);
- }
- }, "defaults");
- }
- if (fun.rest) {
- printed.push(concat(["...", path.call(print, "rest")]));
- }
- var joined = fromString(", ").join(printed);
- if (joined.length > 1 ||
- joined.getLineLength(1) > options.wrapColumn) {
- joined = fromString(",\n").join(printed);
- return concat(["\n", joined.indent(options.tabWidth)]);
- }
- return joined;
- }
- function adjustClause(clause, options) {
- if (clause.length > 1)
- return concat([" ", clause]);
- return concat([
- "\n",
- maybeAddSemicolon(clause).indent(options.tabWidth)
- ]);
- }
- function lastNonSpaceCharacter(lines) {
- var pos = lines.lastPos();
- do {
- var ch = lines.charAt(pos);
- if (/\S/.test(ch))
- return ch;
- } while (lines.prevPos(pos));
- }
- function endsWithBrace(lines) {
- return lastNonSpaceCharacter(lines) === "}";
- }
- function swapQuotes(str) {
- return str.replace(/['"]/g, function(m) {
- return m === '"' ? '\'' : '"';
- });
- }
- function nodeStr(str, options) {
- isString.assert(str);
- switch (options.quote) {
- case "auto":
- var double = JSON.stringify(str);
- var single = swapQuotes(JSON.stringify(swapQuotes(str)));
- return double.length > single.length ? single : double;
- case "single":
- return swapQuotes(JSON.stringify(swapQuotes(str)));
- case "double":
- default:
- return JSON.stringify(str);
- }
- }
- function maybeAddSemicolon(lines) {
- var eoc = lastNonSpaceCharacter(lines);
- if (!eoc || "\n};".indexOf(eoc) < 0)
- return concat([lines, ";"]);
- return lines;
- }
- },{"./comments":459,"./fast-path":460,"./lines":461,"./options":463,"./patcher":465,"./types":467,"./util":468,"assert":190,"source-map":483}],467:[function(require,module,exports){
- var types = require("ast-types");
- var def = types.Type.def;
- def("File")
- .bases("Node")
- .build("program")
- .field("program", def("Program"));
- types.finalize();
- module.exports = types;
- },{"ast-types":188}],468:[function(require,module,exports){
- var assert = require("assert");
- var types = require("./types");
- var getFieldValue = types.getFieldValue;
- var n = types.namedTypes;
- var sourceMap = require("source-map");
- var SourceMapConsumer = sourceMap.SourceMapConsumer;
- var SourceMapGenerator = sourceMap.SourceMapGenerator;
- var hasOwn = Object.prototype.hasOwnProperty;
- function getUnionOfKeys() {
- var result = {};
- var argc = arguments.length;
- for (var i = 0; i < argc; ++i) {
- var keys = Object.keys(arguments[i]);
- var keyCount = keys.length;
- for (var j = 0; j < keyCount; ++j) {
- result[keys[j]] = true;
- }
- }
- return result;
- }
- exports.getUnionOfKeys = getUnionOfKeys;
- function comparePos(pos1, pos2) {
- return (pos1.line - pos2.line) || (pos1.column - pos2.column);
- }
- exports.comparePos = comparePos;
- function copyPos(pos) {
- return {
- line: pos.line,
- column: pos.column
- };
- }
- exports.copyPos = copyPos;
- exports.composeSourceMaps = function(formerMap, latterMap) {
- if (formerMap) {
- if (!latterMap) {
- return formerMap;
- }
- } else {
- return latterMap || null;
- }
- var smcFormer = new SourceMapConsumer(formerMap);
- var smcLatter = new SourceMapConsumer(latterMap);
- var smg = new SourceMapGenerator({
- file: latterMap.file,
- sourceRoot: latterMap.sourceRoot
- });
- var sourcesToContents = {};
- smcLatter.eachMapping(function(mapping) {
- var origPos = smcFormer.originalPositionFor({
- line: mapping.originalLine,
- column: mapping.originalColumn
- });
- var sourceName = origPos.source;
- if (sourceName === null) {
- return;
- }
- smg.addMapping({
- source: sourceName,
- original: copyPos(origPos),
- generated: {
- line: mapping.generatedLine,
- column: mapping.generatedColumn
- },
- name: mapping.name
- });
- var sourceContent = smcFormer.sourceContentFor(sourceName);
- if (sourceContent && !hasOwn.call(sourcesToContents, sourceName)) {
- sourcesToContents[sourceName] = sourceContent;
- smg.setSourceContent(sourceName, sourceContent);
- }
- });
- return smg.toJSON();
- };
- exports.getTrueLoc = function(node) {
- // It's possible that node is newly-created (not parsed by Esprima),
- // in which case it probably won't have a .loc property (or an
- // .original property for that matter). That's fine; we'll just
- // pretty-print it as usual.
- if (!node.loc) {
- return null;
- }
- if (!node.comments) {
- // If the node has no comments, regard node.loc as true.
- return node.loc;
- }
- var start = node.loc.start;
- var end = node.loc.end;
- // If the node has any comments, their locations might contribute to
- // the true start/end positions of the node.
- node.comments.forEach(function(comment) {
- if (comment.loc) {
- if (comparePos(comment.loc.start, start) < 0) {
- start = comment.loc.start;
- }
- if (comparePos(end, comment.loc.end) < 0) {
- end = comment.loc.end;
- }
- }
- });
- return {
- lines: node.loc.lines,
- start: start,
- end: end
- };
- };
- exports.fixFaultyLocations = function(node) {
- if ((n.MethodDefinition && n.MethodDefinition.check(node)) ||
- (n.Property.check(node) && (node.method || node.shorthand))) {
- // If the node is a MethodDefinition or a .method or .shorthand
- // Property, then the location information stored in
- // node.value.loc is very likely untrustworthy (just the {body}
- // part of a method, or nothing in the case of shorthand
- // properties), so we null out that information to prevent
- // accidental reuse of bogus source code during reprinting.
- node.value.loc = null;
- if (n.FunctionExpression.check(node.value)) {
- // FunctionExpression method values should be anonymous,
- // because their .id fields are ignored anyway.
- node.value.id = null;
- }
- }
- var loc = node.loc;
- if (loc) {
- if (loc.start.line < 1) {
- loc.start.line = 1;
- }
- if (loc.end.line < 1) {
- loc.end.line = 1;
- }
- }
- };
- },{"./types":467,"assert":190,"source-map":483}],469:[function(require,module,exports){
- (function (process){
- var types = require("./lib/types");
- var parse = require("./lib/parser").parse;
- var Printer = require("./lib/printer").Printer;
- function print(node, options) {
- return new Printer(options).print(node);
- }
- function prettyPrint(node, options) {
- return new Printer(options).printGenerically(node);
- }
- function run(transformer, options) {
- return runFile(process.argv[2], transformer, options);
- }
- function runFile(path, transformer, options) {
- require("fs").readFile(path, "utf-8", function(err, code) {
- if (err) {
- console.error(err);
- return;
- }
- runString(code, transformer, options);
- });
- }
- function defaultWriteback(output) {
- process.stdout.write(output);
- }
- function runString(code, transformer, options) {
- var writeback = options && options.writeback || defaultWriteback;
- transformer(parse(code, options), function(node) {
- writeback(print(node, options).code);
- });
- }
- Object.defineProperties(exports, {
- /**
- * Parse a string of code into an augmented syntax tree suitable for
- * arbitrary modification and reprinting.
- */
- parse: {
- enumerable: true,
- value: parse
- },
- /**
- * Traverse and potentially modify an abstract syntax tree using a
- * convenient visitor syntax:
- *
- * recast.visit(ast, {
- * names: [],
- * visitIdentifier: function(path) {
- * var node = path.value;
- * this.visitor.names.push(node.name);
- * this.traverse(path);
- * }
- * });
- */
- visit: {
- enumerable: true,
- value: types.visit
- },
- /**
- * Reprint a modified syntax tree using as much of the original source
- * code as possible.
- */
- print: {
- enumerable: true,
- value: print
- },
- /**
- * Print without attempting to reuse any original source code.
- */
- prettyPrint: {
- enumerable: false,
- value: prettyPrint
- },
- /**
- * Customized version of require("ast-types").
- */
- types: {
- enumerable: false,
- value: types
- },
- /**
- * Convenient command-line interface (see e.g. example/add-braces).
- */
- run: {
- enumerable: false,
- value: run
- }
- });
- }).call(this,require('_process'))
- },{"./lib/parser":464,"./lib/printer":466,"./lib/types":467,"_process":200,"fs":189}],470:[function(require,module,exports){
- /*
- Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
- Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
- Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
- Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
- Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
- Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
- Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
- Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- (function (root, factory) {
- 'use strict';
- // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
- // Rhino, and plain browser loading.
- /* istanbul ignore next */
- if (typeof define === 'function' && define.amd) {
- define(['exports'], factory);
- } else if (typeof exports !== 'undefined') {
- factory(exports);
- } else {
- factory((root.esprima = {}));
- }
- }(this, function (exports) {
- 'use strict';
- var Token,
- TokenName,
- FnExprTokens,
- Syntax,
- PropertyKind,
- Messages,
- Regex,
- SyntaxTreeDelegate,
- XHTMLEntities,
- ClassPropertyType,
- source,
- strict,
- index,
- lineNumber,
- lineStart,
- length,
- delegate,
- lookahead,
- state,
- extra;
- Token = {
- BooleanLiteral: 1,
- EOF: 2,
- Identifier: 3,
- Keyword: 4,
- NullLiteral: 5,
- NumericLiteral: 6,
- Punctuator: 7,
- StringLiteral: 8,
- RegularExpression: 9,
- Template: 10,
- JSXIdentifier: 11,
- JSXText: 12
- };
- TokenName = {};
- TokenName[Token.BooleanLiteral] = 'Boolean';
- TokenName[Token.EOF] = '<end>';
- TokenName[Token.Identifier] = 'Identifier';
- TokenName[Token.Keyword] = 'Keyword';
- TokenName[Token.NullLiteral] = 'Null';
- TokenName[Token.NumericLiteral] = 'Numeric';
- TokenName[Token.Punctuator] = 'Punctuator';
- TokenName[Token.StringLiteral] = 'String';
- TokenName[Token.JSXIdentifier] = 'JSXIdentifier';
- TokenName[Token.JSXText] = 'JSXText';
- TokenName[Token.RegularExpression] = 'RegularExpression';
- TokenName[Token.Template] = 'Template';
- // A function following one of those tokens is an expression.
- FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
- 'return', 'case', 'delete', 'throw', 'void',
- // assignment operators
- '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',
- '&=', '|=', '^=', ',',
- // binary/unary operators
- '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
- '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
- '<=', '<', '>', '!=', '!=='];
- Syntax = {
- AnyTypeAnnotation: 'AnyTypeAnnotation',
- ArrayExpression: 'ArrayExpression',
- ArrayPattern: 'ArrayPattern',
- ArrayTypeAnnotation: 'ArrayTypeAnnotation',
- ArrowFunctionExpression: 'ArrowFunctionExpression',
- AssignmentExpression: 'AssignmentExpression',
- BinaryExpression: 'BinaryExpression',
- BlockStatement: 'BlockStatement',
- BooleanTypeAnnotation: 'BooleanTypeAnnotation',
- BreakStatement: 'BreakStatement',
- CallExpression: 'CallExpression',
- CatchClause: 'CatchClause',
- ClassBody: 'ClassBody',
- ClassDeclaration: 'ClassDeclaration',
- ClassExpression: 'ClassExpression',
- ClassImplements: 'ClassImplements',
- ClassProperty: 'ClassProperty',
- ComprehensionBlock: 'ComprehensionBlock',
- ComprehensionExpression: 'ComprehensionExpression',
- ConditionalExpression: 'ConditionalExpression',
- ContinueStatement: 'ContinueStatement',
- DebuggerStatement: 'DebuggerStatement',
- DeclareClass: 'DeclareClass',
- DeclareFunction: 'DeclareFunction',
- DeclareModule: 'DeclareModule',
- DeclareVariable: 'DeclareVariable',
- DoWhileStatement: 'DoWhileStatement',
- EmptyStatement: 'EmptyStatement',
- ExportDeclaration: 'ExportDeclaration',
- ExportBatchSpecifier: 'ExportBatchSpecifier',
- ExportSpecifier: 'ExportSpecifier',
- ExpressionStatement: 'ExpressionStatement',
- ForInStatement: 'ForInStatement',
- ForOfStatement: 'ForOfStatement',
- ForStatement: 'ForStatement',
- FunctionDeclaration: 'FunctionDeclaration',
- FunctionExpression: 'FunctionExpression',
- FunctionTypeAnnotation: 'FunctionTypeAnnotation',
- FunctionTypeParam: 'FunctionTypeParam',
- GenericTypeAnnotation: 'GenericTypeAnnotation',
- Identifier: 'Identifier',
- IfStatement: 'IfStatement',
- ImportDeclaration: 'ImportDeclaration',
- ImportDefaultSpecifier: 'ImportDefaultSpecifier',
- ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
- ImportSpecifier: 'ImportSpecifier',
- InterfaceDeclaration: 'InterfaceDeclaration',
- InterfaceExtends: 'InterfaceExtends',
- IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
- LabeledStatement: 'LabeledStatement',
- Literal: 'Literal',
- LogicalExpression: 'LogicalExpression',
- MemberExpression: 'MemberExpression',
- MethodDefinition: 'MethodDefinition',
- NewExpression: 'NewExpression',
- NullableTypeAnnotation: 'NullableTypeAnnotation',
- NumberTypeAnnotation: 'NumberTypeAnnotation',
- ObjectExpression: 'ObjectExpression',
- ObjectPattern: 'ObjectPattern',
- ObjectTypeAnnotation: 'ObjectTypeAnnotation',
- ObjectTypeCallProperty: 'ObjectTypeCallProperty',
- ObjectTypeIndexer: 'ObjectTypeIndexer',
- ObjectTypeProperty: 'ObjectTypeProperty',
- Program: 'Program',
- Property: 'Property',
- QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
- ReturnStatement: 'ReturnStatement',
- SequenceExpression: 'SequenceExpression',
- SpreadElement: 'SpreadElement',
- SpreadProperty: 'SpreadProperty',
- StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
- StringTypeAnnotation: 'StringTypeAnnotation',
- SwitchCase: 'SwitchCase',
- SwitchStatement: 'SwitchStatement',
- TaggedTemplateExpression: 'TaggedTemplateExpression',
- TemplateElement: 'TemplateElement',
- TemplateLiteral: 'TemplateLiteral',
- ThisExpression: 'ThisExpression',
- ThrowStatement: 'ThrowStatement',
- TupleTypeAnnotation: 'TupleTypeAnnotation',
- TryStatement: 'TryStatement',
- TypeAlias: 'TypeAlias',
- TypeAnnotation: 'TypeAnnotation',
- TypeCastExpression: 'TypeCastExpression',
- TypeofTypeAnnotation: 'TypeofTypeAnnotation',
- TypeParameterDeclaration: 'TypeParameterDeclaration',
- TypeParameterInstantiation: 'TypeParameterInstantiation',
- UnaryExpression: 'UnaryExpression',
- UnionTypeAnnotation: 'UnionTypeAnnotation',
- UpdateExpression: 'UpdateExpression',
- VariableDeclaration: 'VariableDeclaration',
- VariableDeclarator: 'VariableDeclarator',
- VoidTypeAnnotation: 'VoidTypeAnnotation',
- WhileStatement: 'WhileStatement',
- WithStatement: 'WithStatement',
- JSXIdentifier: 'JSXIdentifier',
- JSXNamespacedName: 'JSXNamespacedName',
- JSXMemberExpression: 'JSXMemberExpression',
- JSXEmptyExpression: 'JSXEmptyExpression',
- JSXExpressionContainer: 'JSXExpressionContainer',
- JSXElement: 'JSXElement',
- JSXClosingElement: 'JSXClosingElement',
- JSXOpeningElement: 'JSXOpeningElement',
- JSXAttribute: 'JSXAttribute',
- JSXSpreadAttribute: 'JSXSpreadAttribute',
- JSXText: 'JSXText',
- YieldExpression: 'YieldExpression',
- AwaitExpression: 'AwaitExpression'
- };
- PropertyKind = {
- Data: 1,
- Get: 2,
- Set: 4
- };
- ClassPropertyType = {
- 'static': 'static',
- prototype: 'prototype'
- };
- // Error messages should be identical to V8.
- Messages = {
- UnexpectedToken: 'Unexpected token %0',
- UnexpectedNumber: 'Unexpected number',
- UnexpectedString: 'Unexpected string',
- UnexpectedIdentifier: 'Unexpected identifier',
- UnexpectedReserved: 'Unexpected reserved word',
- UnexpectedTemplate: 'Unexpected quasi %0',
- UnexpectedEOS: 'Unexpected end of input',
- NewlineAfterThrow: 'Illegal newline after throw',
- InvalidRegExp: 'Invalid regular expression',
- UnterminatedRegExp: 'Invalid regular expression: missing /',
- InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
- InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
- InvalidLHSInForIn: 'Invalid left-hand side in for-in',
- MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
- NoCatchOrFinally: 'Missing catch or finally after try',
- UnknownLabel: 'Undefined label \'%0\'',
- Redeclaration: '%0 \'%1\' has already been declared',
- IllegalContinue: 'Illegal continue statement',
- IllegalBreak: 'Illegal break statement',
- IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
- IllegalClassConstructorProperty: 'Illegal constructor property in class definition',
- IllegalReturn: 'Illegal return statement',
- IllegalSpread: 'Illegal spread element',
- StrictModeWith: 'Strict mode code may not include a with statement',
- StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
- StrictVarName: 'Variable name may not be eval or arguments in strict mode',
- StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
- StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
- ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
- DefaultRestParameter: 'Rest parameter can not have a default value',
- ElementAfterSpreadElement: 'Spread must be the final element of an element list',
- PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
- ObjectPatternAsRestParameter: 'Invalid rest parameter',
- ObjectPatternAsSpread: 'Invalid spread argument',
- StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
- StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
- StrictDelete: 'Delete of an unqualified identifier in strict mode.',
- StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
- AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
- AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
- StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
- StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
- StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
- StrictReservedWord: 'Use of future reserved word in strict mode',
- MissingFromClause: 'Missing from clause',
- NoAsAfterImportNamespace: 'Missing as after import *',
- InvalidModuleSpecifier: 'Invalid module specifier',
- IllegalImportDeclaration: 'Illegal import declaration',
- IllegalExportDeclaration: 'Illegal export declaration',
- NoUninitializedConst: 'Const must be initialized',
- ComprehensionRequiresBlock: 'Comprehension must have at least one block',
- ComprehensionError: 'Comprehension Error',
- EachNotAllowed: 'Each is not supported',
- InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text',
- ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0',
- AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag',
- ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
- 'you are trying to write a function type, but you ended up ' +
- 'writing a grouped type followed by an =>, which is a syntax ' +
- 'error. Remember, function type parameters are named so function ' +
- 'types look like (name1: type1, name2: type2) => returnType. You ' +
- 'probably wrote (type1) => returnType'
- };
- // See also tools/generate-unicode-regex.py.
- Regex = {
- NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
- NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
- LeadingZeros: new RegExp('^0+(?!$)')
- };
- // Ensure the condition is true, otherwise throw an error.
- // This is only to have a better contract semantic, i.e. another safety net
- // to catch a logic error. The condition shall be fulfilled in normal case.
- // Do NOT use this to enforce a certain condition on any user input.
- function assert(condition, message) {
- /* istanbul ignore if */
- if (!condition) {
- throw new Error('ASSERT: ' + message);
- }
- }
- function StringMap() {
- this.$data = {};
- }
- StringMap.prototype.get = function (key) {
- key = '$' + key;
- return this.$data[key];
- };
- StringMap.prototype.set = function (key, value) {
- key = '$' + key;
- this.$data[key] = value;
- return this;
- };
- StringMap.prototype.has = function (key) {
- key = '$' + key;
- return Object.prototype.hasOwnProperty.call(this.$data, key);
- };
- StringMap.prototype.delete = function (key) {
- key = '$' + key;
- return delete this.$data[key];
- };
- function isDecimalDigit(ch) {
- return (ch >= 48 && ch <= 57); // 0..9
- }
- function isHexDigit(ch) {
- return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
- }
- function isOctalDigit(ch) {
- return '01234567'.indexOf(ch) >= 0;
- }
- // 7.2 White Space
- function isWhiteSpace(ch) {
- return (ch === 32) || // space
- (ch === 9) || // tab
- (ch === 0xB) ||
- (ch === 0xC) ||
- (ch === 0xA0) ||
- (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
- }
- // 7.3 Line Terminators
- function isLineTerminator(ch) {
- return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
- }
- // 7.6 Identifier Names and Identifiers
- function isIdentifierStart(ch) {
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
- (ch >= 65 && ch <= 90) || // A..Z
- (ch >= 97 && ch <= 122) || // a..z
- (ch === 92) || // \ (backslash)
- ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));
- }
- function isIdentifierPart(ch) {
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
- (ch >= 65 && ch <= 90) || // A..Z
- (ch >= 97 && ch <= 122) || // a..z
- (ch >= 48 && ch <= 57) || // 0..9
- (ch === 92) || // \ (backslash)
- ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
- }
- // 7.6.1.2 Future Reserved Words
- function isFutureReservedWord(id) {
- switch (id) {
- case 'class':
- case 'enum':
- case 'export':
- case 'extends':
- case 'import':
- case 'super':
- return true;
- default:
- return false;
- }
- }
- function isStrictModeReservedWord(id) {
- switch (id) {
- case 'implements':
- case 'interface':
- case 'package':
- case 'private':
- case 'protected':
- case 'public':
- case 'static':
- case 'yield':
- case 'let':
- return true;
- default:
- return false;
- }
- }
- function isRestrictedWord(id) {
- return id === 'eval' || id === 'arguments';
- }
- // 7.6.1.1 Keywords
- function isKeyword(id) {
- if (strict && isStrictModeReservedWord(id)) {
- return true;
- }
- // 'const' is specialized as Keyword in V8.
- // 'yield' is only treated as a keyword in strict mode.
- // 'let' is for compatiblity with SpiderMonkey and ES.next.
- // Some others are from future reserved words.
- switch (id.length) {
- case 2:
- return (id === 'if') || (id === 'in') || (id === 'do');
- case 3:
- return (id === 'var') || (id === 'for') || (id === 'new') ||
- (id === 'try') || (id === 'let');
- case 4:
- return (id === 'this') || (id === 'else') || (id === 'case') ||
- (id === 'void') || (id === 'with') || (id === 'enum');
- case 5:
- return (id === 'while') || (id === 'break') || (id === 'catch') ||
- (id === 'throw') || (id === 'const') ||
- (id === 'class') || (id === 'super');
- case 6:
- return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
- (id === 'switch') || (id === 'export') || (id === 'import');
- case 7:
- return (id === 'default') || (id === 'finally') || (id === 'extends');
- case 8:
- return (id === 'function') || (id === 'continue') || (id === 'debugger');
- case 10:
- return (id === 'instanceof');
- default:
- return false;
- }
- }
- // 7.4 Comments
- function addComment(type, value, start, end, loc) {
- var comment;
- assert(typeof start === 'number', 'Comment must have valid position');
- // Because the way the actual token is scanned, often the comments
- // (if any) are skipped twice during the lexical analysis.
- // Thus, we need to skip adding a comment if the comment array already
- // handled it.
- if (state.lastCommentStart >= start) {
- return;
- }
- state.lastCommentStart = start;
- comment = {
- type: type,
- value: value
- };
- if (extra.range) {
- comment.range = [start, end];
- }
- if (extra.loc) {
- comment.loc = loc;
- }
- extra.comments.push(comment);
- if (extra.attachComment) {
- extra.leadingComments.push(comment);
- extra.trailingComments.push(comment);
- }
- }
- function skipSingleLineComment() {
- var start, loc, ch, comment;
- start = index - 2;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart - 2
- }
- };
- while (index < length) {
- ch = source.charCodeAt(index);
- ++index;
- if (isLineTerminator(ch)) {
- if (extra.comments) {
- comment = source.slice(start + 2, index - 1);
- loc.end = {
- line: lineNumber,
- column: index - lineStart - 1
- };
- addComment('Line', comment, start, index - 1, loc);
- }
- if (ch === 13 && source.charCodeAt(index) === 10) {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- return;
- }
- }
- if (extra.comments) {
- comment = source.slice(start + 2, index);
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- addComment('Line', comment, start, index, loc);
- }
- }
- function skipMultiLineComment() {
- var start, loc, ch, comment;
- if (extra.comments) {
- start = index - 2;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart - 2
- }
- };
- }
- while (index < length) {
- ch = source.charCodeAt(index);
- if (isLineTerminator(ch)) {
- if (ch === 13 && source.charCodeAt(index + 1) === 10) {
- ++index;
- }
- ++lineNumber;
- ++index;
- lineStart = index;
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- } else if (ch === 42) {
- // Block comment ends with '*/' (char #42, char #47).
- if (source.charCodeAt(index + 1) === 47) {
- ++index;
- ++index;
- if (extra.comments) {
- comment = source.slice(start + 2, index - 2);
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- addComment('Block', comment, start, index, loc);
- }
- return;
- }
- ++index;
- } else {
- ++index;
- }
- }
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- function skipComment() {
- var ch;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (isWhiteSpace(ch)) {
- ++index;
- } else if (isLineTerminator(ch)) {
- ++index;
- if (ch === 13 && source.charCodeAt(index) === 10) {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- } else if (ch === 47) { // 47 is '/'
- ch = source.charCodeAt(index + 1);
- if (ch === 47) {
- ++index;
- ++index;
- skipSingleLineComment();
- } else if (ch === 42) { // 42 is '*'
- ++index;
- ++index;
- skipMultiLineComment();
- } else {
- break;
- }
- } else {
- break;
- }
- }
- }
- function scanHexEscape(prefix) {
- var i, len, ch, code = 0;
- len = (prefix === 'u') ? 4 : 2;
- for (i = 0; i < len; ++i) {
- if (index < length && isHexDigit(source[index])) {
- ch = source[index++];
- code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
- } else {
- return '';
- }
- }
- return String.fromCharCode(code);
- }
- function scanUnicodeCodePointEscape() {
- var ch, code, cu1, cu2;
- ch = source[index];
- code = 0;
- // At least, one hex digit is required.
- if (ch === '}') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- while (index < length) {
- ch = source[index++];
- if (!isHexDigit(ch)) {
- break;
- }
- code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
- }
- if (code > 0x10FFFF || ch !== '}') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- // UTF-16 Encoding
- if (code <= 0xFFFF) {
- return String.fromCharCode(code);
- }
- cu1 = ((code - 0x10000) >> 10) + 0xD800;
- cu2 = ((code - 0x10000) & 1023) + 0xDC00;
- return String.fromCharCode(cu1, cu2);
- }
- function getEscapedIdentifier() {
- var ch, id;
- ch = source.charCodeAt(index++);
- id = String.fromCharCode(ch);
- // '\u' (char #92, char #117) denotes an escaped character.
- if (ch === 92) {
- if (source.charCodeAt(index) !== 117) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- ch = scanHexEscape('u');
- if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- id = ch;
- }
- while (index < length) {
- ch = source.charCodeAt(index);
- if (!isIdentifierPart(ch)) {
- break;
- }
- ++index;
- id += String.fromCharCode(ch);
- // '\u' (char #92, char #117) denotes an escaped character.
- if (ch === 92) {
- id = id.substr(0, id.length - 1);
- if (source.charCodeAt(index) !== 117) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- ch = scanHexEscape('u');
- if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- id += ch;
- }
- }
- return id;
- }
- function getIdentifier() {
- var start, ch;
- start = index++;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (ch === 92) {
- // Blackslash (char #92) marks Unicode escape sequence.
- index = start;
- return getEscapedIdentifier();
- }
- if (isIdentifierPart(ch)) {
- ++index;
- } else {
- break;
- }
- }
- return source.slice(start, index);
- }
- function scanIdentifier() {
- var start, id, type;
- start = index;
- // Backslash (char #92) starts an escaped character.
- id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier();
- // There is no keyword or literal with only one character.
- // Thus, it must be an identifier.
- if (id.length === 1) {
- type = Token.Identifier;
- } else if (isKeyword(id)) {
- type = Token.Keyword;
- } else if (id === 'null') {
- type = Token.NullLiteral;
- } else if (id === 'true' || id === 'false') {
- type = Token.BooleanLiteral;
- } else {
- type = Token.Identifier;
- }
- return {
- type: type,
- value: id,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // 7.7 Punctuators
- function scanPunctuator() {
- var start = index,
- code = source.charCodeAt(index),
- code2,
- ch1 = source[index],
- ch2,
- ch3,
- ch4;
- if (state.inJSXTag || state.inJSXChild) {
- // Don't need to check for '{' and '}' as it's already handled
- // correctly by default.
- switch (code) {
- case 60: // <
- case 62: // >
- ++index;
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- }
- switch (code) {
- // Check for most common single-character punctuators.
- case 40: // ( open bracket
- case 41: // ) close bracket
- case 59: // ; semicolon
- case 44: // , comma
- case 91: // [
- case 93: // ]
- case 58: // :
- case 63: // ?
- case 126: // ~
- ++index;
- if (extra.tokenize && code === 40) {
- extra.openParenToken = extra.tokens.length;
- }
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- case 123: // { open curly brace
- case 125: // } close curly brace
- ++index;
- if (extra.tokenize && code === 123) {
- extra.openCurlyToken = extra.tokens.length;
- }
- // lookahead2 function can cause tokens to be scanned twice and in doing so
- // would wreck the curly stack by pushing the same token onto the stack twice.
- // curlyLastIndex ensures each token is pushed or popped exactly once
- if (index > state.curlyLastIndex) {
- state.curlyLastIndex = index;
- if (code === 123) {
- state.curlyStack.push('{');
- } else {
- state.curlyStack.pop();
- }
- }
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- default:
- code2 = source.charCodeAt(index + 1);
- // '=' (char #61) marks an assignment or comparison operator.
- if (code2 === 61) {
- switch (code) {
- case 37: // %
- case 38: // &
- case 42: // *:
- case 43: // +
- case 45: // -
- case 47: // /
- case 60: // <
- case 62: // >
- case 94: // ^
- case 124: // |
- index += 2;
- return {
- type: Token.Punctuator,
- value: String.fromCharCode(code) + String.fromCharCode(code2),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- case 33: // !
- case 61: // =
- index += 2;
- // !== and ===
- if (source.charCodeAt(index) === 61) {
- ++index;
- }
- return {
- type: Token.Punctuator,
- value: source.slice(start, index),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- default:
- break;
- }
- }
- break;
- }
- // Peek more characters.
- ch2 = source[index + 1];
- ch3 = source[index + 2];
- ch4 = source[index + 3];
- // 4-character punctuator: >>>=
- if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
- if (ch4 === '=') {
- index += 4;
- return {
- type: Token.Punctuator,
- value: '>>>=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- }
- // 3-character punctuators: === !== >>> <<= >>=
- if (ch1 === '>' && ch2 === '>' && ch3 === '>' && !state.inType) {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '>>>',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '<' && ch2 === '<' && ch3 === '=') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '<<=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '>' && ch2 === '>' && ch3 === '=') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '>>=',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '.' && ch2 === '.' && ch3 === '.') {
- index += 3;
- return {
- type: Token.Punctuator,
- value: '...',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // Other 2-character punctuators: ++ -- << >> && ||
- // Don't match these tokens if we're in a type, since they never can
- // occur and can mess up types like Map<string, Array<string>>
- if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
- index += 2;
- return {
- type: Token.Punctuator,
- value: ch1 + ch2,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '=' && ch2 === '>') {
- index += 2;
- return {
- type: Token.Punctuator,
- value: '=>',
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
- ++index;
- return {
- type: Token.Punctuator,
- value: ch1,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- if (ch1 === '.') {
- ++index;
- return {
- type: Token.Punctuator,
- value: ch1,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- // 7.8.3 Numeric Literals
- function scanHexLiteral(start) {
- var number = '';
- while (index < length) {
- if (!isHexDigit(source[index])) {
- break;
- }
- number += source[index++];
- }
- if (number.length === 0) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (isIdentifierStart(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt('0x' + number, 16),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanBinaryLiteral(start) {
- var ch, number;
- number = '';
- while (index < length) {
- ch = source[index];
- if (ch !== '0' && ch !== '1') {
- break;
- }
- number += source[index++];
- }
- if (number.length === 0) {
- // only 0b or 0B
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (index < length) {
- ch = source.charCodeAt(index);
- /* istanbul ignore else */
- if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt(number, 2),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanOctalLiteral(prefix, start) {
- var number, octal;
- if (isOctalDigit(prefix)) {
- octal = true;
- number = '0' + source[index++];
- } else {
- octal = false;
- ++index;
- number = '';
- }
- while (index < length) {
- if (!isOctalDigit(source[index])) {
- break;
- }
- number += source[index++];
- }
- if (!octal && number.length === 0) {
- // only 0o or 0O
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseInt(number, 8),
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanNumericLiteral() {
- var number, start, ch;
- ch = source[index];
- assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
- 'Numeric literal must start with a decimal digit or a decimal point');
- start = index;
- number = '';
- if (ch !== '.') {
- number = source[index++];
- ch = source[index];
- // Hex number starts with '0x'.
- // Octal number starts with '0'.
- // Octal number in ES6 starts with '0o'.
- // Binary number in ES6 starts with '0b'.
- if (number === '0') {
- if (ch === 'x' || ch === 'X') {
- ++index;
- return scanHexLiteral(start);
- }
- if (ch === 'b' || ch === 'B') {
- ++index;
- return scanBinaryLiteral(start);
- }
- if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
- return scanOctalLiteral(ch, start);
- }
- // decimal number starts with '0' such as '09' is illegal.
- if (ch && isDecimalDigit(ch.charCodeAt(0))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- ch = source[index];
- }
- if (ch === '.') {
- number += source[index++];
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- ch = source[index];
- }
- if (ch === 'e' || ch === 'E') {
- number += source[index++];
- ch = source[index];
- if (ch === '+' || ch === '-') {
- number += source[index++];
- }
- if (isDecimalDigit(source.charCodeAt(index))) {
- while (isDecimalDigit(source.charCodeAt(index))) {
- number += source[index++];
- }
- } else {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- }
- if (isIdentifierStart(source.charCodeAt(index))) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.NumericLiteral,
- value: parseFloat(number),
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- // 7.8.4 String Literals
- function scanStringLiteral() {
- var str = '', quote, start, ch, code, unescaped, restore, octal = false;
- quote = source[index];
- assert((quote === '\'' || quote === '"'),
- 'String literal must starts with a quote');
- start = index;
- ++index;
- while (index < length) {
- ch = source[index++];
- if (ch === quote) {
- quote = '';
- break;
- } else if (ch === '\\') {
- ch = source[index++];
- if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
- switch (ch) {
- case 'n':
- str += '\n';
- break;
- case 'r':
- str += '\r';
- break;
- case 't':
- str += '\t';
- break;
- case 'u':
- case 'x':
- if (source[index] === '{') {
- ++index;
- str += scanUnicodeCodePointEscape();
- } else {
- restore = index;
- unescaped = scanHexEscape(ch);
- if (unescaped) {
- str += unescaped;
- } else {
- index = restore;
- str += ch;
- }
- }
- break;
- case 'b':
- str += '\b';
- break;
- case 'f':
- str += '\f';
- break;
- case 'v':
- str += '\x0B';
- break;
- default:
- if (isOctalDigit(ch)) {
- code = '01234567'.indexOf(ch);
- // \0 is not octal escape sequence
- if (code !== 0) {
- octal = true;
- }
- /* istanbul ignore else */
- if (index < length && isOctalDigit(source[index])) {
- octal = true;
- code = code * 8 + '01234567'.indexOf(source[index++]);
- // 3 digits are only allowed when string starts
- // with 0, 1, 2, 3
- if ('0123'.indexOf(ch) >= 0 &&
- index < length &&
- isOctalDigit(source[index])) {
- code = code * 8 + '01234567'.indexOf(source[index++]);
- }
- }
- str += String.fromCharCode(code);
- } else {
- str += ch;
- }
- break;
- }
- } else {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- }
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- break;
- } else {
- str += ch;
- }
- }
- if (quote !== '') {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- return {
- type: Token.StringLiteral,
- value: str,
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanTemplate() {
- var cooked = '', ch, start, terminated, head, tail, restore, unescaped, code, octal;
- terminated = false;
- tail = false;
- start = index;
- head = (source[index] === '`');
- ++index;
- while (index < length) {
- ch = source[index++];
- if (ch === '`') {
- tail = true;
- terminated = true;
- break;
- } else if (ch === '$') {
- if (source[index] === '{') {
- ++index;
- terminated = true;
- break;
- }
- cooked += ch;
- } else if (ch === '\\') {
- ch = source[index++];
- if (!isLineTerminator(ch.charCodeAt(0))) {
- switch (ch) {
- case 'n':
- cooked += '\n';
- break;
- case 'r':
- cooked += '\r';
- break;
- case 't':
- cooked += '\t';
- break;
- case 'u':
- case 'x':
- if (source[index] === '{') {
- ++index;
- cooked += scanUnicodeCodePointEscape();
- } else {
- restore = index;
- unescaped = scanHexEscape(ch);
- if (unescaped) {
- cooked += unescaped;
- } else {
- index = restore;
- cooked += ch;
- }
- }
- break;
- case 'b':
- cooked += '\b';
- break;
- case 'f':
- cooked += '\f';
- break;
- case 'v':
- cooked += '\v';
- break;
- default:
- if (isOctalDigit(ch)) {
- code = '01234567'.indexOf(ch);
- // \0 is not octal escape sequence
- if (code !== 0) {
- octal = true;
- }
- /* istanbul ignore else */
- if (index < length && isOctalDigit(source[index])) {
- octal = true;
- code = code * 8 + '01234567'.indexOf(source[index++]);
- // 3 digits are only allowed when string starts
- // with 0, 1, 2, 3
- if ('0123'.indexOf(ch) >= 0 &&
- index < length &&
- isOctalDigit(source[index])) {
- code = code * 8 + '01234567'.indexOf(source[index++]);
- }
- }
- cooked += String.fromCharCode(code);
- } else {
- cooked += ch;
- }
- break;
- }
- } else {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- }
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- ++lineNumber;
- if (ch === '\r' && source[index] === '\n') {
- ++index;
- }
- lineStart = index;
- cooked += '\n';
- } else {
- cooked += ch;
- }
- }
- if (!terminated) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- if (index > state.curlyLastIndex) {
- state.curlyLastIndex = index;
- if (!tail) {
- state.curlyStack.push('template');
- }
- if (!head) {
- state.curlyStack.pop();
- }
- }
- return {
- type: Token.Template,
- value: {
- cooked: cooked,
- raw: source.slice(start + 1, index - ((tail) ? 1 : 2))
- },
- head: head,
- tail: tail,
- octal: octal,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function testRegExp(pattern, flags) {
- var tmp = pattern,
- value;
- if (flags.indexOf('u') >= 0) {
- // Replace each astral symbol and every Unicode code point
- // escape sequence with a single ASCII symbol to avoid throwing on
- // regular expressions that are only valid in combination with the
- // `/u` flag.
- // Note: replacing with the ASCII symbol `x` might cause false
- // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
- // perfectly valid pattern that is equivalent to `[a-b]`, but it
- // would be replaced by `[x-b]` which throws an error.
- tmp = tmp
- .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
- if (parseInt($1, 16) <= 0x10FFFF) {
- return 'x';
- }
- throwError({}, Messages.InvalidRegExp);
- })
- .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
- }
- // First, detect invalid regular expressions.
- try {
- value = new RegExp(tmp);
- } catch (e) {
- throwError({}, Messages.InvalidRegExp);
- }
- // Return a regular expression object for this pattern-flag pair, or
- // `null` in case the current environment doesn't support the flags it
- // uses.
- try {
- return new RegExp(pattern, flags);
- } catch (exception) {
- return null;
- }
- }
- function scanRegExpBody() {
- var ch, str, classMarker, terminated, body;
- ch = source[index];
- assert(ch === '/', 'Regular expression literal must start with a slash');
- str = source[index++];
- classMarker = false;
- terminated = false;
- while (index < length) {
- ch = source[index++];
- str += ch;
- if (ch === '\\') {
- ch = source[index++];
- // ECMA-262 7.8.5
- if (isLineTerminator(ch.charCodeAt(0))) {
- throwError({}, Messages.UnterminatedRegExp);
- }
- str += ch;
- } else if (isLineTerminator(ch.charCodeAt(0))) {
- throwError({}, Messages.UnterminatedRegExp);
- } else if (classMarker) {
- if (ch === ']') {
- classMarker = false;
- }
- } else {
- if (ch === '/') {
- terminated = true;
- break;
- } else if (ch === '[') {
- classMarker = true;
- }
- }
- }
- if (!terminated) {
- throwError({}, Messages.UnterminatedRegExp);
- }
- // Exclude leading and trailing slash.
- body = str.substr(1, str.length - 2);
- return {
- value: body,
- literal: str
- };
- }
- function scanRegExpFlags() {
- var ch, str, flags, restore;
- str = '';
- flags = '';
- while (index < length) {
- ch = source[index];
- if (!isIdentifierPart(ch.charCodeAt(0))) {
- break;
- }
- ++index;
- if (ch === '\\' && index < length) {
- ch = source[index];
- if (ch === 'u') {
- ++index;
- restore = index;
- ch = scanHexEscape('u');
- if (ch) {
- flags += ch;
- for (str += '\\u'; restore < index; ++restore) {
- str += source[restore];
- }
- } else {
- index = restore;
- flags += 'u';
- str += '\\u';
- }
- throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
- } else {
- str += '\\';
- throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- } else {
- flags += ch;
- str += ch;
- }
- }
- return {
- value: flags,
- literal: str
- };
- }
- function scanRegExp() {
- var start, body, flags, value;
- lookahead = null;
- skipComment();
- start = index;
- body = scanRegExpBody();
- flags = scanRegExpFlags();
- value = testRegExp(body.value, flags.value);
- if (extra.tokenize) {
- return {
- type: Token.RegularExpression,
- value: value,
- regex: {
- pattern: body.value,
- flags: flags.value
- },
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- return {
- literal: body.literal + flags.literal,
- value: value,
- regex: {
- pattern: body.value,
- flags: flags.value
- },
- range: [start, index]
- };
- }
- function isIdentifierName(token) {
- return token.type === Token.Identifier ||
- token.type === Token.Keyword ||
- token.type === Token.BooleanLiteral ||
- token.type === Token.NullLiteral;
- }
- function advanceSlash() {
- var prevToken,
- checkToken;
- // Using the following algorithm:
- // https://github.com/mozilla/sweet.js/wiki/design
- prevToken = extra.tokens[extra.tokens.length - 1];
- if (!prevToken) {
- // Nothing before that: it cannot be a division.
- return scanRegExp();
- }
- if (prevToken.type === 'Punctuator') {
- if (prevToken.value === ')') {
- checkToken = extra.tokens[extra.openParenToken - 1];
- if (checkToken &&
- checkToken.type === 'Keyword' &&
- (checkToken.value === 'if' ||
- checkToken.value === 'while' ||
- checkToken.value === 'for' ||
- checkToken.value === 'with')) {
- return scanRegExp();
- }
- return scanPunctuator();
- }
- if (prevToken.value === '}') {
- // Dividing a function by anything makes little sense,
- // but we have to check for that.
- if (extra.tokens[extra.openCurlyToken - 3] &&
- extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {
- // Anonymous function.
- checkToken = extra.tokens[extra.openCurlyToken - 4];
- if (!checkToken) {
- return scanPunctuator();
- }
- } else if (extra.tokens[extra.openCurlyToken - 4] &&
- extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {
- // Named function.
- checkToken = extra.tokens[extra.openCurlyToken - 5];
- if (!checkToken) {
- return scanRegExp();
- }
- } else {
- return scanPunctuator();
- }
- // checkToken determines whether the function is
- // a declaration or an expression.
- if (FnExprTokens.indexOf(checkToken.value) >= 0) {
- // It is an expression.
- return scanPunctuator();
- }
- // It is a declaration.
- return scanRegExp();
- }
- return scanRegExp();
- }
- if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
- return scanRegExp();
- }
- return scanPunctuator();
- }
- function advance() {
- var ch;
- if (!state.inJSXChild) {
- skipComment();
- }
- if (index >= length) {
- return {
- type: Token.EOF,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [index, index]
- };
- }
- if (state.inJSXChild) {
- return advanceJSXChild();
- }
- ch = source.charCodeAt(index);
- // Very common: ( and ) and ;
- if (ch === 40 || ch === 41 || ch === 58) {
- return scanPunctuator();
- }
- // String literal starts with single quote (#39) or double quote (#34).
- if (ch === 39 || ch === 34) {
- if (state.inJSXTag) {
- return scanJSXStringLiteral();
- }
- return scanStringLiteral();
- }
- if (state.inJSXTag && isJSXIdentifierStart(ch)) {
- return scanJSXIdentifier();
- }
- // Template literals start with backtick (#96) for template head
- // or close curly (#125) for template middle or template tail.
- if (ch === 96 || (ch === 125 && state.curlyStack[state.curlyStack.length - 1] === 'template')) {
- return scanTemplate();
- }
- if (isIdentifierStart(ch)) {
- return scanIdentifier();
- }
- // Dot (.) char #46 can also start a floating-point number, hence the need
- // to check the next character.
- if (ch === 46) {
- if (isDecimalDigit(source.charCodeAt(index + 1))) {
- return scanNumericLiteral();
- }
- return scanPunctuator();
- }
- if (isDecimalDigit(ch)) {
- return scanNumericLiteral();
- }
- // Slash (/) char #47 can also start a regex.
- if (extra.tokenize && ch === 47) {
- return advanceSlash();
- }
- return scanPunctuator();
- }
- function lex() {
- var token;
- token = lookahead;
- index = token.range[1];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- lookahead = advance();
- index = token.range[1];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- return token;
- }
- function peek() {
- var pos, line, start;
- pos = index;
- line = lineNumber;
- start = lineStart;
- lookahead = advance();
- index = pos;
- lineNumber = line;
- lineStart = start;
- }
- function lookahead2() {
- var adv, pos, line, start, result;
- // If we are collecting the tokens, don't grab the next one yet.
- /* istanbul ignore next */
- adv = (typeof extra.advance === 'function') ? extra.advance : advance;
- pos = index;
- line = lineNumber;
- start = lineStart;
- // Scan for the next immediate token.
- /* istanbul ignore if */
- if (lookahead === null) {
- lookahead = adv();
- }
- index = lookahead.range[1];
- lineNumber = lookahead.lineNumber;
- lineStart = lookahead.lineStart;
- // Grab the token right after.
- result = adv();
- index = pos;
- lineNumber = line;
- lineStart = start;
- return result;
- }
- function rewind(token) {
- index = token.range[0];
- lineNumber = token.lineNumber;
- lineStart = token.lineStart;
- lookahead = token;
- }
- function markerCreate() {
- if (!extra.loc && !extra.range) {
- return undefined;
- }
- skipComment();
- return {offset: index, line: lineNumber, col: index - lineStart};
- }
- function markerCreatePreserveWhitespace() {
- if (!extra.loc && !extra.range) {
- return undefined;
- }
- return {offset: index, line: lineNumber, col: index - lineStart};
- }
- function processComment(node) {
- var lastChild,
- trailingComments,
- bottomRight = extra.bottomRightStack,
- last = bottomRight[bottomRight.length - 1];
- if (node.type === Syntax.Program) {
- /* istanbul ignore else */
- if (node.body.length > 0) {
- return;
- }
- }
- if (extra.trailingComments.length > 0) {
- if (extra.trailingComments[0].range[0] >= node.range[1]) {
- trailingComments = extra.trailingComments;
- extra.trailingComments = [];
- } else {
- extra.trailingComments.length = 0;
- }
- } else {
- if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
- trailingComments = last.trailingComments;
- delete last.trailingComments;
- }
- }
- // Eating the stack.
- if (last) {
- while (last && last.range[0] >= node.range[0]) {
- lastChild = last;
- last = bottomRight.pop();
- }
- }
- if (lastChild) {
- if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
- node.leadingComments = lastChild.leadingComments;
- delete lastChild.leadingComments;
- }
- } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
- node.leadingComments = extra.leadingComments;
- extra.leadingComments = [];
- }
- if (trailingComments) {
- node.trailingComments = trailingComments;
- }
- bottomRight.push(node);
- }
- function markerApply(marker, node) {
- if (extra.range) {
- node.range = [marker.offset, index];
- }
- if (extra.loc) {
- node.loc = {
- start: {
- line: marker.line,
- column: marker.col
- },
- end: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- node = delegate.postProcess(node);
- }
- if (extra.attachComment) {
- processComment(node);
- }
- return node;
- }
- SyntaxTreeDelegate = {
- name: 'SyntaxTree',
- postProcess: function (node) {
- return node;
- },
- createArrayExpression: function (elements) {
- return {
- type: Syntax.ArrayExpression,
- elements: elements
- };
- },
- createAssignmentExpression: function (operator, left, right) {
- return {
- type: Syntax.AssignmentExpression,
- operator: operator,
- left: left,
- right: right
- };
- },
- createBinaryExpression: function (operator, left, right) {
- var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :
- Syntax.BinaryExpression;
- return {
- type: type,
- operator: operator,
- left: left,
- right: right
- };
- },
- createBlockStatement: function (body) {
- return {
- type: Syntax.BlockStatement,
- body: body
- };
- },
- createBreakStatement: function (label) {
- return {
- type: Syntax.BreakStatement,
- label: label
- };
- },
- createCallExpression: function (callee, args) {
- return {
- type: Syntax.CallExpression,
- callee: callee,
- 'arguments': args
- };
- },
- createCatchClause: function (param, body) {
- return {
- type: Syntax.CatchClause,
- param: param,
- body: body
- };
- },
- createConditionalExpression: function (test, consequent, alternate) {
- return {
- type: Syntax.ConditionalExpression,
- test: test,
- consequent: consequent,
- alternate: alternate
- };
- },
- createContinueStatement: function (label) {
- return {
- type: Syntax.ContinueStatement,
- label: label
- };
- },
- createDebuggerStatement: function () {
- return {
- type: Syntax.DebuggerStatement
- };
- },
- createDoWhileStatement: function (body, test) {
- return {
- type: Syntax.DoWhileStatement,
- body: body,
- test: test
- };
- },
- createEmptyStatement: function () {
- return {
- type: Syntax.EmptyStatement
- };
- },
- createExpressionStatement: function (expression) {
- return {
- type: Syntax.ExpressionStatement,
- expression: expression
- };
- },
- createForStatement: function (init, test, update, body) {
- return {
- type: Syntax.ForStatement,
- init: init,
- test: test,
- update: update,
- body: body
- };
- },
- createForInStatement: function (left, right, body) {
- return {
- type: Syntax.ForInStatement,
- left: left,
- right: right,
- body: body,
- each: false
- };
- },
- createForOfStatement: function (left, right, body) {
- return {
- type: Syntax.ForOfStatement,
- left: left,
- right: right,
- body: body
- };
- },
- createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
- isAsync, returnType, typeParameters) {
- var funDecl = {
- type: Syntax.FunctionDeclaration,
- id: id,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: generator,
- expression: expression,
- returnType: returnType,
- typeParameters: typeParameters
- };
- if (isAsync) {
- funDecl.async = true;
- }
- return funDecl;
- },
- createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
- isAsync, returnType, typeParameters) {
- var funExpr = {
- type: Syntax.FunctionExpression,
- id: id,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: generator,
- expression: expression,
- returnType: returnType,
- typeParameters: typeParameters
- };
- if (isAsync) {
- funExpr.async = true;
- }
- return funExpr;
- },
- createIdentifier: function (name) {
- return {
- type: Syntax.Identifier,
- name: name,
- // Only here to initialize the shape of the object to ensure
- // that the 'typeAnnotation' key is ordered before others that
- // are added later (like 'loc' and 'range'). This just helps
- // keep the shape of Identifier nodes consistent with everything
- // else.
- typeAnnotation: undefined,
- optional: undefined
- };
- },
- createTypeAnnotation: function (typeAnnotation) {
- return {
- type: Syntax.TypeAnnotation,
- typeAnnotation: typeAnnotation
- };
- },
- createTypeCast: function (expression, typeAnnotation) {
- return {
- type: Syntax.TypeCastExpression,
- expression: expression,
- typeAnnotation: typeAnnotation
- };
- },
- createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
- return {
- type: Syntax.FunctionTypeAnnotation,
- params: params,
- returnType: returnType,
- rest: rest,
- typeParameters: typeParameters
- };
- },
- createFunctionTypeParam: function (name, typeAnnotation, optional) {
- return {
- type: Syntax.FunctionTypeParam,
- name: name,
- typeAnnotation: typeAnnotation,
- optional: optional
- };
- },
- createNullableTypeAnnotation: function (typeAnnotation) {
- return {
- type: Syntax.NullableTypeAnnotation,
- typeAnnotation: typeAnnotation
- };
- },
- createArrayTypeAnnotation: function (elementType) {
- return {
- type: Syntax.ArrayTypeAnnotation,
- elementType: elementType
- };
- },
- createGenericTypeAnnotation: function (id, typeParameters) {
- return {
- type: Syntax.GenericTypeAnnotation,
- id: id,
- typeParameters: typeParameters
- };
- },
- createQualifiedTypeIdentifier: function (qualification, id) {
- return {
- type: Syntax.QualifiedTypeIdentifier,
- qualification: qualification,
- id: id
- };
- },
- createTypeParameterDeclaration: function (params) {
- return {
- type: Syntax.TypeParameterDeclaration,
- params: params
- };
- },
- createTypeParameterInstantiation: function (params) {
- return {
- type: Syntax.TypeParameterInstantiation,
- params: params
- };
- },
- createAnyTypeAnnotation: function () {
- return {
- type: Syntax.AnyTypeAnnotation
- };
- },
- createBooleanTypeAnnotation: function () {
- return {
- type: Syntax.BooleanTypeAnnotation
- };
- },
- createNumberTypeAnnotation: function () {
- return {
- type: Syntax.NumberTypeAnnotation
- };
- },
- createStringTypeAnnotation: function () {
- return {
- type: Syntax.StringTypeAnnotation
- };
- },
- createStringLiteralTypeAnnotation: function (token) {
- return {
- type: Syntax.StringLiteralTypeAnnotation,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- },
- createVoidTypeAnnotation: function () {
- return {
- type: Syntax.VoidTypeAnnotation
- };
- },
- createTypeofTypeAnnotation: function (argument) {
- return {
- type: Syntax.TypeofTypeAnnotation,
- argument: argument
- };
- },
- createTupleTypeAnnotation: function (types) {
- return {
- type: Syntax.TupleTypeAnnotation,
- types: types
- };
- },
- createObjectTypeAnnotation: function (properties, indexers, callProperties) {
- return {
- type: Syntax.ObjectTypeAnnotation,
- properties: properties,
- indexers: indexers,
- callProperties: callProperties
- };
- },
- createObjectTypeIndexer: function (id, key, value, isStatic) {
- return {
- type: Syntax.ObjectTypeIndexer,
- id: id,
- key: key,
- value: value,
- static: isStatic
- };
- },
- createObjectTypeCallProperty: function (value, isStatic) {
- return {
- type: Syntax.ObjectTypeCallProperty,
- value: value,
- static: isStatic
- };
- },
- createObjectTypeProperty: function (key, value, optional, isStatic) {
- return {
- type: Syntax.ObjectTypeProperty,
- key: key,
- value: value,
- optional: optional,
- static: isStatic
- };
- },
- createUnionTypeAnnotation: function (types) {
- return {
- type: Syntax.UnionTypeAnnotation,
- types: types
- };
- },
- createIntersectionTypeAnnotation: function (types) {
- return {
- type: Syntax.IntersectionTypeAnnotation,
- types: types
- };
- },
- createTypeAlias: function (id, typeParameters, right) {
- return {
- type: Syntax.TypeAlias,
- id: id,
- typeParameters: typeParameters,
- right: right
- };
- },
- createInterface: function (id, typeParameters, body, extended) {
- return {
- type: Syntax.InterfaceDeclaration,
- id: id,
- typeParameters: typeParameters,
- body: body,
- extends: extended
- };
- },
- createInterfaceExtends: function (id, typeParameters) {
- return {
- type: Syntax.InterfaceExtends,
- id: id,
- typeParameters: typeParameters
- };
- },
- createDeclareFunction: function (id) {
- return {
- type: Syntax.DeclareFunction,
- id: id
- };
- },
- createDeclareVariable: function (id) {
- return {
- type: Syntax.DeclareVariable,
- id: id
- };
- },
- createDeclareModule: function (id, body) {
- return {
- type: Syntax.DeclareModule,
- id: id,
- body: body
- };
- },
- createJSXAttribute: function (name, value) {
- return {
- type: Syntax.JSXAttribute,
- name: name,
- value: value || null
- };
- },
- createJSXSpreadAttribute: function (argument) {
- return {
- type: Syntax.JSXSpreadAttribute,
- argument: argument
- };
- },
- createJSXIdentifier: function (name) {
- return {
- type: Syntax.JSXIdentifier,
- name: name
- };
- },
- createJSXNamespacedName: function (namespace, name) {
- return {
- type: Syntax.JSXNamespacedName,
- namespace: namespace,
- name: name
- };
- },
- createJSXMemberExpression: function (object, property) {
- return {
- type: Syntax.JSXMemberExpression,
- object: object,
- property: property
- };
- },
- createJSXElement: function (openingElement, closingElement, children) {
- return {
- type: Syntax.JSXElement,
- openingElement: openingElement,
- closingElement: closingElement,
- children: children
- };
- },
- createJSXEmptyExpression: function () {
- return {
- type: Syntax.JSXEmptyExpression
- };
- },
- createJSXExpressionContainer: function (expression) {
- return {
- type: Syntax.JSXExpressionContainer,
- expression: expression
- };
- },
- createJSXOpeningElement: function (name, attributes, selfClosing) {
- return {
- type: Syntax.JSXOpeningElement,
- name: name,
- selfClosing: selfClosing,
- attributes: attributes
- };
- },
- createJSXClosingElement: function (name) {
- return {
- type: Syntax.JSXClosingElement,
- name: name
- };
- },
- createIfStatement: function (test, consequent, alternate) {
- return {
- type: Syntax.IfStatement,
- test: test,
- consequent: consequent,
- alternate: alternate
- };
- },
- createLabeledStatement: function (label, body) {
- return {
- type: Syntax.LabeledStatement,
- label: label,
- body: body
- };
- },
- createLiteral: function (token) {
- var object = {
- type: Syntax.Literal,
- value: token.value,
- raw: source.slice(token.range[0], token.range[1])
- };
- if (token.regex) {
- object.regex = token.regex;
- }
- return object;
- },
- createMemberExpression: function (accessor, object, property) {
- return {
- type: Syntax.MemberExpression,
- computed: accessor === '[',
- object: object,
- property: property
- };
- },
- createNewExpression: function (callee, args) {
- return {
- type: Syntax.NewExpression,
- callee: callee,
- 'arguments': args
- };
- },
- createObjectExpression: function (properties) {
- return {
- type: Syntax.ObjectExpression,
- properties: properties
- };
- },
- createPostfixExpression: function (operator, argument) {
- return {
- type: Syntax.UpdateExpression,
- operator: operator,
- argument: argument,
- prefix: false
- };
- },
- createProgram: function (body) {
- return {
- type: Syntax.Program,
- body: body
- };
- },
- createProperty: function (kind, key, value, method, shorthand, computed) {
- return {
- type: Syntax.Property,
- key: key,
- value: value,
- kind: kind,
- method: method,
- shorthand: shorthand,
- computed: computed
- };
- },
- createReturnStatement: function (argument) {
- return {
- type: Syntax.ReturnStatement,
- argument: argument
- };
- },
- createSequenceExpression: function (expressions) {
- return {
- type: Syntax.SequenceExpression,
- expressions: expressions
- };
- },
- createSwitchCase: function (test, consequent) {
- return {
- type: Syntax.SwitchCase,
- test: test,
- consequent: consequent
- };
- },
- createSwitchStatement: function (discriminant, cases) {
- return {
- type: Syntax.SwitchStatement,
- discriminant: discriminant,
- cases: cases
- };
- },
- createThisExpression: function () {
- return {
- type: Syntax.ThisExpression
- };
- },
- createThrowStatement: function (argument) {
- return {
- type: Syntax.ThrowStatement,
- argument: argument
- };
- },
- createTryStatement: function (block, guardedHandlers, handlers, finalizer) {
- return {
- type: Syntax.TryStatement,
- block: block,
- guardedHandlers: guardedHandlers,
- handlers: handlers,
- finalizer: finalizer
- };
- },
- createUnaryExpression: function (operator, argument) {
- if (operator === '++' || operator === '--') {
- return {
- type: Syntax.UpdateExpression,
- operator: operator,
- argument: argument,
- prefix: true
- };
- }
- return {
- type: Syntax.UnaryExpression,
- operator: operator,
- argument: argument,
- prefix: true
- };
- },
- createVariableDeclaration: function (declarations, kind) {
- return {
- type: Syntax.VariableDeclaration,
- declarations: declarations,
- kind: kind
- };
- },
- createVariableDeclarator: function (id, init) {
- return {
- type: Syntax.VariableDeclarator,
- id: id,
- init: init
- };
- },
- createWhileStatement: function (test, body) {
- return {
- type: Syntax.WhileStatement,
- test: test,
- body: body
- };
- },
- createWithStatement: function (object, body) {
- return {
- type: Syntax.WithStatement,
- object: object,
- body: body
- };
- },
- createTemplateElement: function (value, tail) {
- return {
- type: Syntax.TemplateElement,
- value: value,
- tail: tail
- };
- },
- createTemplateLiteral: function (quasis, expressions) {
- return {
- type: Syntax.TemplateLiteral,
- quasis: quasis,
- expressions: expressions
- };
- },
- createSpreadElement: function (argument) {
- return {
- type: Syntax.SpreadElement,
- argument: argument
- };
- },
- createSpreadProperty: function (argument) {
- return {
- type: Syntax.SpreadProperty,
- argument: argument
- };
- },
- createTaggedTemplateExpression: function (tag, quasi) {
- return {
- type: Syntax.TaggedTemplateExpression,
- tag: tag,
- quasi: quasi
- };
- },
- createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
- var arrowExpr = {
- type: Syntax.ArrowFunctionExpression,
- id: null,
- params: params,
- defaults: defaults,
- body: body,
- rest: rest,
- generator: false,
- expression: expression
- };
- if (isAsync) {
- arrowExpr.async = true;
- }
- return arrowExpr;
- },
- createMethodDefinition: function (propertyType, kind, key, value, computed) {
- return {
- type: Syntax.MethodDefinition,
- key: key,
- value: value,
- kind: kind,
- 'static': propertyType === ClassPropertyType.static,
- computed: computed
- };
- },
- createClassProperty: function (key, typeAnnotation, computed, isStatic) {
- return {
- type: Syntax.ClassProperty,
- key: key,
- typeAnnotation: typeAnnotation,
- computed: computed,
- static: isStatic
- };
- },
- createClassBody: function (body) {
- return {
- type: Syntax.ClassBody,
- body: body
- };
- },
- createClassImplements: function (id, typeParameters) {
- return {
- type: Syntax.ClassImplements,
- id: id,
- typeParameters: typeParameters
- };
- },
- createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
- return {
- type: Syntax.ClassExpression,
- id: id,
- superClass: superClass,
- body: body,
- typeParameters: typeParameters,
- superTypeParameters: superTypeParameters,
- implements: implemented
- };
- },
- createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
- return {
- type: Syntax.ClassDeclaration,
- id: id,
- superClass: superClass,
- body: body,
- typeParameters: typeParameters,
- superTypeParameters: superTypeParameters,
- implements: implemented
- };
- },
- createExportSpecifier: function (id, name) {
- return {
- type: Syntax.ExportSpecifier,
- id: id,
- name: name
- };
- },
- createExportBatchSpecifier: function () {
- return {
- type: Syntax.ExportBatchSpecifier
- };
- },
- createImportDefaultSpecifier: function (id) {
- return {
- type: Syntax.ImportDefaultSpecifier,
- id: id
- };
- },
- createImportNamespaceSpecifier: function (id) {
- return {
- type: Syntax.ImportNamespaceSpecifier,
- id: id
- };
- },
- createExportDeclaration: function (isDefault, declaration, specifiers, src) {
- return {
- type: Syntax.ExportDeclaration,
- 'default': !!isDefault,
- declaration: declaration,
- specifiers: specifiers,
- source: src
- };
- },
- createImportSpecifier: function (id, name) {
- return {
- type: Syntax.ImportSpecifier,
- id: id,
- name: name
- };
- },
- createImportDeclaration: function (specifiers, src, isType) {
- return {
- type: Syntax.ImportDeclaration,
- specifiers: specifiers,
- source: src,
- isType: isType
- };
- },
- createYieldExpression: function (argument, dlg) {
- return {
- type: Syntax.YieldExpression,
- argument: argument,
- delegate: dlg
- };
- },
- createAwaitExpression: function (argument) {
- return {
- type: Syntax.AwaitExpression,
- argument: argument
- };
- },
- createComprehensionExpression: function (filter, blocks, body) {
- return {
- type: Syntax.ComprehensionExpression,
- filter: filter,
- blocks: blocks,
- body: body
- };
- }
- };
- // Return true if there is a line terminator before the next token.
- function peekLineTerminator() {
- var pos, line, start, found;
- pos = index;
- line = lineNumber;
- start = lineStart;
- skipComment();
- found = lineNumber !== line;
- index = pos;
- lineNumber = line;
- lineStart = start;
- return found;
- }
- // Throw an exception
- function throwError(token, messageFormat) {
- var error,
- args = Array.prototype.slice.call(arguments, 2),
- msg = messageFormat.replace(
- /%(\d)/g,
- function (whole, idx) {
- assert(idx < args.length, 'Message reference must be in range');
- return args[idx];
- }
- );
- if (typeof token.lineNumber === 'number') {
- error = new Error('Line ' + token.lineNumber + ': ' + msg);
- error.index = token.range[0];
- error.lineNumber = token.lineNumber;
- error.column = token.range[0] - lineStart + 1;
- } else {
- error = new Error('Line ' + lineNumber + ': ' + msg);
- error.index = index;
- error.lineNumber = lineNumber;
- error.column = index - lineStart + 1;
- }
- error.description = msg;
- throw error;
- }
- function throwErrorTolerant() {
- try {
- throwError.apply(null, arguments);
- } catch (e) {
- if (extra.errors) {
- extra.errors.push(e);
- } else {
- throw e;
- }
- }
- }
- // Throw an exception because of the token.
- function throwUnexpected(token) {
- if (token.type === Token.EOF) {
- throwError(token, Messages.UnexpectedEOS);
- }
- if (token.type === Token.NumericLiteral) {
- throwError(token, Messages.UnexpectedNumber);
- }
- if (token.type === Token.StringLiteral || token.type === Token.JSXText) {
- throwError(token, Messages.UnexpectedString);
- }
- if (token.type === Token.Identifier) {
- throwError(token, Messages.UnexpectedIdentifier);
- }
- if (token.type === Token.Keyword) {
- if (isFutureReservedWord(token.value)) {
- throwError(token, Messages.UnexpectedReserved);
- } else if (strict && isStrictModeReservedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictReservedWord);
- return;
- }
- throwError(token, Messages.UnexpectedToken, token.value);
- }
- if (token.type === Token.Template) {
- throwError(token, Messages.UnexpectedTemplate, token.value.raw);
- }
- // BooleanLiteral, NullLiteral, or Punctuator.
- throwError(token, Messages.UnexpectedToken, token.value);
- }
- // Expect the next token to match the specified punctuator.
- // If not, an exception will be thrown.
- function expect(value) {
- var token = lex();
- if (token.type !== Token.Punctuator || token.value !== value) {
- throwUnexpected(token);
- }
- }
- // Expect the next token to match the specified keyword.
- // If not, an exception will be thrown.
- function expectKeyword(keyword, contextual) {
- var token = lex();
- if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
- token.value !== keyword) {
- throwUnexpected(token);
- }
- }
- // Expect the next token to match the specified contextual keyword.
- // If not, an exception will be thrown.
- function expectContextualKeyword(keyword) {
- return expectKeyword(keyword, true);
- }
- // Return true if the next token matches the specified punctuator.
- function match(value) {
- return lookahead.type === Token.Punctuator && lookahead.value === value;
- }
- // Return true if the next token matches the specified keyword
- function matchKeyword(keyword, contextual) {
- var expectedType = contextual ? Token.Identifier : Token.Keyword;
- return lookahead.type === expectedType && lookahead.value === keyword;
- }
- // Return true if the next token matches the specified contextual keyword
- function matchContextualKeyword(keyword) {
- return matchKeyword(keyword, true);
- }
- // Return true if the next token is an assignment operator
- function matchAssign() {
- var op;
- if (lookahead.type !== Token.Punctuator) {
- return false;
- }
- op = lookahead.value;
- return op === '=' ||
- op === '*=' ||
- op === '/=' ||
- op === '%=' ||
- op === '+=' ||
- op === '-=' ||
- op === '<<=' ||
- op === '>>=' ||
- op === '>>>=' ||
- op === '&=' ||
- op === '^=' ||
- op === '|=';
- }
- // Note that 'yield' is treated as a keyword in strict mode, but a
- // contextual keyword (identifier) in non-strict mode, so we need to
- // use matchKeyword('yield', false) and matchKeyword('yield', true)
- // (i.e. matchContextualKeyword) appropriately.
- function matchYield() {
- return state.yieldAllowed && matchKeyword('yield', !strict);
- }
- function matchAsync() {
- var backtrackToken = lookahead, matches = false;
- if (matchContextualKeyword('async')) {
- lex(); // Make sure peekLineTerminator() starts after 'async'.
- matches = !peekLineTerminator();
- rewind(backtrackToken); // Revert the lex().
- }
- return matches;
- }
- function matchAwait() {
- return state.awaitAllowed && matchContextualKeyword('await');
- }
- function consumeSemicolon() {
- var line, oldIndex = index, oldLineNumber = lineNumber,
- oldLineStart = lineStart, oldLookahead = lookahead;
- // Catch the very common case first: immediately a semicolon (char #59).
- if (source.charCodeAt(index) === 59) {
- lex();
- return;
- }
- line = lineNumber;
- skipComment();
- if (lineNumber !== line) {
- index = oldIndex;
- lineNumber = oldLineNumber;
- lineStart = oldLineStart;
- lookahead = oldLookahead;
- return;
- }
- if (match(';')) {
- lex();
- return;
- }
- if (lookahead.type !== Token.EOF && !match('}')) {
- throwUnexpected(lookahead);
- }
- }
- // Return true if provided expression is LeftHandSideExpression
- function isLeftHandSide(expr) {
- return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression;
- }
- function isAssignableLeftHandSide(expr) {
- return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern;
- }
- // 11.1.4 Array Initialiser
- function parseArrayInitialiser() {
- var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
- marker = markerCreate();
- expect('[');
- while (!match(']')) {
- if (lookahead.value === 'for' &&
- lookahead.type === Token.Keyword) {
- if (!possiblecomprehension) {
- throwError({}, Messages.ComprehensionError);
- }
- matchKeyword('for');
- tmp = parseForStatement({ignoreBody: true});
- tmp.of = tmp.type === Syntax.ForOfStatement;
- tmp.type = Syntax.ComprehensionBlock;
- if (tmp.left.kind) { // can't be let or const
- throwError({}, Messages.ComprehensionError);
- }
- blocks.push(tmp);
- } else if (lookahead.value === 'if' &&
- lookahead.type === Token.Keyword) {
- if (!possiblecomprehension) {
- throwError({}, Messages.ComprehensionError);
- }
- expectKeyword('if');
- expect('(');
- filter = parseExpression();
- expect(')');
- } else if (lookahead.value === ',' &&
- lookahead.type === Token.Punctuator) {
- possiblecomprehension = false; // no longer allowed.
- lex();
- elements.push(null);
- } else {
- tmp = parseSpreadOrAssignmentExpression();
- elements.push(tmp);
- if (tmp && tmp.type === Syntax.SpreadElement) {
- if (!match(']')) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) {
- expect(','); // this lexes.
- possiblecomprehension = false;
- }
- }
- }
- expect(']');
- if (filter && !blocks.length) {
- throwError({}, Messages.ComprehensionRequiresBlock);
- }
- if (blocks.length) {
- if (elements.length !== 1) {
- throwError({}, Messages.ComprehensionError);
- }
- return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0]));
- }
- return markerApply(marker, delegate.createArrayExpression(elements));
- }
- // 11.1.5 Object Initialiser
- function parsePropertyFunction(options) {
- var previousStrict, previousYieldAllowed, previousAwaitAllowed,
- params, defaults, body, marker = markerCreate();
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = options.generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = options.async;
- params = options.params || [];
- defaults = options.defaults || [];
- body = parseConciseBody();
- if (options.name && strict && isRestrictedWord(params[0].name)) {
- throwErrorTolerant(options.name, Messages.StrictParamName);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createFunctionExpression(
- null,
- params,
- defaults,
- body,
- options.rest || null,
- options.generator,
- body.type !== Syntax.BlockStatement,
- options.async,
- options.returnType,
- options.typeParameters
- ));
- }
- function parsePropertyMethodFunction(options) {
- var previousStrict, tmp, method;
- previousStrict = strict;
- strict = true;
- tmp = parseParams();
- if (tmp.stricted) {
- throwErrorTolerant(tmp.stricted, tmp.message);
- }
- method = parsePropertyFunction({
- params: tmp.params,
- defaults: tmp.defaults,
- rest: tmp.rest,
- generator: options.generator,
- async: options.async,
- returnType: tmp.returnType,
- typeParameters: options.typeParameters
- });
- strict = previousStrict;
- return method;
- }
- function parseObjectPropertyKey() {
- var marker = markerCreate(),
- token = lex(),
- propertyKey,
- result;
- // Note: This function is called only from parseObjectProperty(), where
- // EOF and Punctuator tokens are already filtered out.
- if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {
- if (strict && token.octal) {
- throwErrorTolerant(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (token.type === Token.Punctuator && token.value === '[') {
- // For computed properties we should skip the [ and ], and
- // capture in marker only the assignment expression itself.
- marker = markerCreate();
- propertyKey = parseAssignmentExpression();
- result = markerApply(marker, propertyKey);
- expect(']');
- return result;
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseObjectProperty() {
- var token, key, id, param, computed,
- marker = markerCreate(), returnType, typeParameters;
- token = lookahead;
- computed = (token.value === '[' && token.type === Token.Punctuator);
- if (token.type === Token.Identifier || computed || matchAsync()) {
- id = parseObjectPropertyKey();
- if (match(':')) {
- lex();
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- id,
- parseAssignmentExpression(),
- false,
- false,
- computed
- )
- );
- }
- if (match('(') || match('<')) {
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- id,
- parsePropertyMethodFunction({
- generator: false,
- async: false,
- typeParameters: typeParameters
- }),
- true,
- false,
- computed
- )
- );
- }
- // Property Assignment: Getter and Setter.
- if (token.value === 'get') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- expect('(');
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'get',
- key,
- parsePropertyFunction({
- generator: false,
- async: false,
- returnType: returnType
- }),
- false,
- false,
- computed
- )
- );
- }
- if (token.value === 'set') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- expect('(');
- token = lookahead;
- param = [ parseTypeAnnotatableIdentifier() ];
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'set',
- key,
- parsePropertyFunction({
- params: param,
- generator: false,
- async: false,
- name: token,
- returnType: returnType
- }),
- false,
- false,
- computed
- )
- );
- }
- if (token.value === 'async') {
- computed = (lookahead.value === '[');
- key = parseObjectPropertyKey();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- return markerApply(
- marker,
- delegate.createProperty(
- 'init',
- key,
- parsePropertyMethodFunction({
- generator: false,
- async: true,
- typeParameters: typeParameters
- }),
- true,
- false,
- computed
- )
- );
- }
- if (computed) {
- // Computed properties can only be used with full notation.
- throwUnexpected(lookahead);
- }
- return markerApply(
- marker,
- delegate.createProperty('init', id, id, false, true, false)
- );
- }
- if (token.type === Token.EOF || token.type === Token.Punctuator) {
- if (!match('*')) {
- throwUnexpected(token);
- }
- lex();
- computed = (lookahead.type === Token.Punctuator && lookahead.value === '[');
- id = parseObjectPropertyKey();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (!match('(')) {
- throwUnexpected(lex());
- }
- return markerApply(marker, delegate.createProperty(
- 'init',
- id,
- parsePropertyMethodFunction({
- generator: true,
- typeParameters: typeParameters
- }),
- true,
- false,
- computed
- ));
- }
- key = parseObjectPropertyKey();
- if (match(':')) {
- lex();
- return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
- }
- if (match('(') || match('<')) {
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- return markerApply(marker, delegate.createProperty(
- 'init',
- key,
- parsePropertyMethodFunction({
- generator: false,
- typeParameters: typeParameters
- }),
- true,
- false,
- false
- ));
- }
- throwUnexpected(lex());
- }
- function parseObjectSpreadProperty() {
- var marker = markerCreate();
- expect('...');
- return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
- }
- function getFieldName(key) {
- var toString = String;
- if (key.type === Syntax.Identifier) {
- return key.name;
- }
- return toString(key.value);
- }
- function parseObjectInitialiser() {
- var properties = [], property, name, kind, storedKind, map = new StringMap(),
- marker = markerCreate(), toString = String;
- expect('{');
- while (!match('}')) {
- if (match('...')) {
- property = parseObjectSpreadProperty();
- } else {
- property = parseObjectProperty();
- if (property.key.type === Syntax.Identifier) {
- name = property.key.name;
- } else {
- name = toString(property.key.value);
- }
- kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
- if (map.has(name)) {
- storedKind = map.get(name);
- if (storedKind === PropertyKind.Data) {
- if (strict && kind === PropertyKind.Data) {
- throwErrorTolerant({}, Messages.StrictDuplicateProperty);
- } else if (kind !== PropertyKind.Data) {
- throwErrorTolerant({}, Messages.AccessorDataProperty);
- }
- } else {
- if (kind === PropertyKind.Data) {
- throwErrorTolerant({}, Messages.AccessorDataProperty);
- } else if (storedKind & kind) {
- throwErrorTolerant({}, Messages.AccessorGetSet);
- }
- }
- map.set(name, storedKind | kind);
- } else {
- map.set(name, kind);
- }
- }
- properties.push(property);
- if (!match('}')) {
- expect(',');
- }
- }
- expect('}');
- return markerApply(marker, delegate.createObjectExpression(properties));
- }
- function parseTemplateElement(option) {
- var marker, token;
- if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- marker = markerCreate();
- token = lex();
- if (strict && token.octal) {
- throwError(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail));
- }
- function parseTemplateLiteral() {
- var quasi, quasis, expressions, marker = markerCreate();
- quasi = parseTemplateElement({ head: true });
- quasis = [ quasi ];
- expressions = [];
- while (!quasi.tail) {
- expressions.push(parseExpression());
- quasi = parseTemplateElement({ head: false });
- quasis.push(quasi);
- }
- return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions));
- }
- // 11.1.6 The Grouping Operator
- function parseGroupExpression() {
- var expr, marker, typeAnnotation;
- expect('(');
- ++state.parenthesizedCount;
- marker = markerCreate();
- expr = parseExpression();
- if (match(':')) {
- typeAnnotation = parseTypeAnnotation();
- expr = markerApply(marker, delegate.createTypeCast(
- expr,
- typeAnnotation
- ));
- }
- expect(')');
- return expr;
- }
- function matchAsyncFuncExprOrDecl() {
- var token;
- if (matchAsync()) {
- token = lookahead2();
- if (token.type === Token.Keyword && token.value === 'function') {
- return true;
- }
- }
- return false;
- }
- // 11.1 Primary Expressions
- function parsePrimaryExpression() {
- var marker, type, token, expr;
- type = lookahead.type;
- if (type === Token.Identifier) {
- marker = markerCreate();
- return markerApply(marker, delegate.createIdentifier(lex().value));
- }
- if (type === Token.StringLiteral || type === Token.NumericLiteral) {
- if (strict && lookahead.octal) {
- throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
- }
- marker = markerCreate();
- return markerApply(marker, delegate.createLiteral(lex()));
- }
- if (type === Token.Keyword) {
- if (matchKeyword('this')) {
- marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createThisExpression());
- }
- if (matchKeyword('function')) {
- return parseFunctionExpression();
- }
- if (matchKeyword('class')) {
- return parseClassExpression();
- }
- if (matchKeyword('super')) {
- marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createIdentifier('super'));
- }
- }
- if (type === Token.BooleanLiteral) {
- marker = markerCreate();
- token = lex();
- token.value = (token.value === 'true');
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (type === Token.NullLiteral) {
- marker = markerCreate();
- token = lex();
- token.value = null;
- return markerApply(marker, delegate.createLiteral(token));
- }
- if (match('[')) {
- return parseArrayInitialiser();
- }
- if (match('{')) {
- return parseObjectInitialiser();
- }
- if (match('(')) {
- return parseGroupExpression();
- }
- if (match('/') || match('/=')) {
- marker = markerCreate();
- expr = delegate.createLiteral(scanRegExp());
- peek();
- return markerApply(marker, expr);
- }
- if (type === Token.Template) {
- return parseTemplateLiteral();
- }
- if (match('<')) {
- return parseJSXElement();
- }
- throwUnexpected(lex());
- }
- // 11.2 Left-Hand-Side Expressions
- function parseArguments() {
- var args = [], arg;
- expect('(');
- if (!match(')')) {
- while (index < length) {
- arg = parseSpreadOrAssignmentExpression();
- args.push(arg);
- if (arg.type === Syntax.SpreadElement) {
- if (match(')')) {
- break;
- } else {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- }
- if (match(')')) {
- break;
- } else {
- expect(',');
- if (match(')')) {
- break;
- }
- }
- }
- }
- expect(')');
- return args;
- }
- function parseSpreadOrAssignmentExpression() {
- if (match('...')) {
- var marker = markerCreate();
- lex();
- return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression()));
- }
- return parseAssignmentExpression();
- }
- function parseNonComputedProperty() {
- var marker = markerCreate(),
- token = lex();
- if (!isIdentifierName(token)) {
- throwUnexpected(token);
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseNonComputedMember() {
- expect('.');
- return parseNonComputedProperty();
- }
- function parseComputedMember() {
- var expr;
- expect('[');
- expr = parseExpression();
- expect(']');
- return expr;
- }
- function parseNewExpression() {
- var callee, args, marker = markerCreate();
- expectKeyword('new');
- callee = parseLeftHandSideExpression();
- args = match('(') ? parseArguments() : [];
- return markerApply(marker, delegate.createNewExpression(callee, args));
- }
- function parseLeftHandSideExpressionAllowCall() {
- var expr, args, marker = markerCreate();
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
- while (match('.') || match('[') || match('(') || (lookahead.type === Token.Template && lookahead.head)) {
- if (match('(')) {
- args = parseArguments();
- expr = markerApply(marker, delegate.createCallExpression(expr, args));
- } else if (match('[')) {
- expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
- } else if (match('.')) {
- expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
- } else {
- expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
- }
- }
- return expr;
- }
- function parseLeftHandSideExpression() {
- var expr, marker = markerCreate();
- expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
- while (match('.') || match('[') || (lookahead.type === Token.Template && lookahead.head)) {
- if (match('[')) {
- expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember()));
- } else if (match('.')) {
- expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember()));
- } else {
- expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral()));
- }
- }
- return expr;
- }
- // 11.3 Postfix Expressions
- function parsePostfixExpression() {
- var marker = markerCreate(),
- expr = parseLeftHandSideExpressionAllowCall(),
- token;
- if (lookahead.type !== Token.Punctuator) {
- return expr;
- }
- if ((match('++') || match('--')) && !peekLineTerminator()) {
- // 11.3.1, 11.3.2
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant({}, Messages.StrictLHSPostfix);
- }
- if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- token = lex();
- expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr));
- }
- return expr;
- }
- // 11.4 Unary Operators
- function parseUnaryExpression() {
- var marker, token, expr;
- if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
- return parsePostfixExpression();
- }
- if (match('++') || match('--')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- // 11.4.4, 11.4.5
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant({}, Messages.StrictLHSPrefix);
- }
- if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- }
- if (match('+') || match('-') || match('~') || match('!')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- }
- if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
- marker = markerCreate();
- token = lex();
- expr = parseUnaryExpression();
- expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr));
- if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
- throwErrorTolerant({}, Messages.StrictDelete);
- }
- return expr;
- }
- return parsePostfixExpression();
- }
- function binaryPrecedence(token, allowIn) {
- var prec = 0;
- if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
- return 0;
- }
- switch (token.value) {
- case '||':
- prec = 1;
- break;
- case '&&':
- prec = 2;
- break;
- case '|':
- prec = 3;
- break;
- case '^':
- prec = 4;
- break;
- case '&':
- prec = 5;
- break;
- case '==':
- case '!=':
- case '===':
- case '!==':
- prec = 6;
- break;
- case '<':
- case '>':
- case '<=':
- case '>=':
- case 'instanceof':
- prec = 7;
- break;
- case 'in':
- prec = allowIn ? 7 : 0;
- break;
- case '<<':
- case '>>':
- case '>>>':
- prec = 8;
- break;
- case '+':
- case '-':
- prec = 9;
- break;
- case '*':
- case '/':
- case '%':
- prec = 11;
- break;
- default:
- break;
- }
- return prec;
- }
- // 11.5 Multiplicative Operators
- // 11.6 Additive Operators
- // 11.7 Bitwise Shift Operators
- // 11.8 Relational Operators
- // 11.9 Equality Operators
- // 11.10 Binary Bitwise Operators
- // 11.11 Binary Logical Operators
- function parseBinaryExpression() {
- var expr, token, prec, previousAllowIn, stack, right, operator, left, i,
- marker, markers;
- previousAllowIn = state.allowIn;
- state.allowIn = true;
- marker = markerCreate();
- left = parseUnaryExpression();
- token = lookahead;
- prec = binaryPrecedence(token, previousAllowIn);
- if (prec === 0) {
- return left;
- }
- token.prec = prec;
- lex();
- markers = [marker, markerCreate()];
- right = parseUnaryExpression();
- stack = [left, token, right];
- while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) {
- // Reduce: make a binary expression from the three topmost entries.
- while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
- right = stack.pop();
- operator = stack.pop().value;
- left = stack.pop();
- expr = delegate.createBinaryExpression(operator, left, right);
- markers.pop();
- marker = markers.pop();
- markerApply(marker, expr);
- stack.push(expr);
- markers.push(marker);
- }
- // Shift.
- token = lex();
- token.prec = prec;
- stack.push(token);
- markers.push(markerCreate());
- expr = parseUnaryExpression();
- stack.push(expr);
- }
- state.allowIn = previousAllowIn;
- // Final reduce to clean-up the stack.
- i = stack.length - 1;
- expr = stack[i];
- markers.pop();
- while (i > 1) {
- expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
- i -= 2;
- marker = markers.pop();
- markerApply(marker, expr);
- }
- return expr;
- }
- // 11.12 Conditional Operator
- function parseConditionalExpression() {
- var expr, previousAllowIn, consequent, alternate, marker = markerCreate();
- expr = parseBinaryExpression();
- if (match('?')) {
- lex();
- previousAllowIn = state.allowIn;
- state.allowIn = true;
- consequent = parseAssignmentExpression();
- state.allowIn = previousAllowIn;
- expect(':');
- alternate = parseAssignmentExpression();
- expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate));
- }
- return expr;
- }
- // 11.13 Assignment Operators
- // 12.14.5 AssignmentPattern
- function reinterpretAsAssignmentBindingPattern(expr) {
- var i, len, property, element;
- if (expr.type === Syntax.ObjectExpression) {
- expr.type = Syntax.ObjectPattern;
- for (i = 0, len = expr.properties.length; i < len; i += 1) {
- property = expr.properties[i];
- if (property.type === Syntax.SpreadProperty) {
- if (i < len - 1) {
- throwError({}, Messages.PropertyAfterSpreadProperty);
- }
- reinterpretAsAssignmentBindingPattern(property.argument);
- } else {
- if (property.kind !== 'init') {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- reinterpretAsAssignmentBindingPattern(property.value);
- }
- }
- } else if (expr.type === Syntax.ArrayExpression) {
- expr.type = Syntax.ArrayPattern;
- for (i = 0, len = expr.elements.length; i < len; i += 1) {
- element = expr.elements[i];
- /* istanbul ignore else */
- if (element) {
- reinterpretAsAssignmentBindingPattern(element);
- }
- }
- } else if (expr.type === Syntax.Identifier) {
- if (isRestrictedWord(expr.name)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- } else if (expr.type === Syntax.SpreadElement) {
- reinterpretAsAssignmentBindingPattern(expr.argument);
- if (expr.argument.type === Syntax.ObjectPattern) {
- throwError({}, Messages.ObjectPatternAsSpread);
- }
- } else {
- /* istanbul ignore else */
- if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- }
- }
- // 13.2.3 BindingPattern
- function reinterpretAsDestructuredParameter(options, expr) {
- var i, len, property, element;
- if (expr.type === Syntax.ObjectExpression) {
- expr.type = Syntax.ObjectPattern;
- for (i = 0, len = expr.properties.length; i < len; i += 1) {
- property = expr.properties[i];
- if (property.type === Syntax.SpreadProperty) {
- if (i < len - 1) {
- throwError({}, Messages.PropertyAfterSpreadProperty);
- }
- reinterpretAsDestructuredParameter(options, property.argument);
- } else {
- if (property.kind !== 'init') {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- reinterpretAsDestructuredParameter(options, property.value);
- }
- }
- } else if (expr.type === Syntax.ArrayExpression) {
- expr.type = Syntax.ArrayPattern;
- for (i = 0, len = expr.elements.length; i < len; i += 1) {
- element = expr.elements[i];
- if (element) {
- reinterpretAsDestructuredParameter(options, element);
- }
- }
- } else if (expr.type === Syntax.Identifier) {
- validateParam(options, expr, expr.name);
- } else if (expr.type === Syntax.SpreadElement) {
- // BindingRestElement only allows BindingIdentifier
- if (expr.argument.type !== Syntax.Identifier) {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- validateParam(options, expr.argument, expr.argument.name);
- } else {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- }
- function reinterpretAsCoverFormalsList(expressions) {
- var i, len, param, params, defaults, defaultCount, options, rest;
- params = [];
- defaults = [];
- defaultCount = 0;
- rest = null;
- options = {
- paramSet: new StringMap()
- };
- for (i = 0, len = expressions.length; i < len; i += 1) {
- param = expressions[i];
- if (param.type === Syntax.Identifier) {
- params.push(param);
- defaults.push(null);
- validateParam(options, param, param.name);
- } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) {
- reinterpretAsDestructuredParameter(options, param);
- params.push(param);
- defaults.push(null);
- } else if (param.type === Syntax.SpreadElement) {
- assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
- if (param.argument.type !== Syntax.Identifier) {
- throwError({}, Messages.InvalidLHSInFormalsList);
- }
- reinterpretAsDestructuredParameter(options, param.argument);
- rest = param.argument;
- } else if (param.type === Syntax.AssignmentExpression) {
- params.push(param.left);
- defaults.push(param.right);
- ++defaultCount;
- validateParam(options, param.left, param.left.name);
- } else {
- return null;
- }
- }
- if (options.message === Messages.StrictParamDupe) {
- throwError(
- strict ? options.stricted : options.firstRestricted,
- options.message
- );
- }
- if (defaultCount === 0) {
- defaults = [];
- }
- return {
- params: params,
- defaults: defaults,
- rest: rest,
- stricted: options.stricted,
- firstRestricted: options.firstRestricted,
- message: options.message
- };
- }
- function parseArrowFunctionExpression(options, marker) {
- var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
- expect('=>');
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = !!options.async;
- body = parseConciseBody();
- if (strict && options.firstRestricted) {
- throwError(options.firstRestricted, options.message);
- }
- if (strict && options.stricted) {
- throwErrorTolerant(options.stricted, options.message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createArrowFunctionExpression(
- options.params,
- options.defaults,
- body,
- options.rest,
- body.type !== Syntax.BlockStatement,
- !!options.async
- ));
- }
- function parseAssignmentExpression() {
- var marker, expr, token, params, oldParenthesizedCount,
- startsWithParen = false, backtrackToken = lookahead,
- possiblyAsync = false;
- if (matchYield()) {
- return parseYieldExpression();
- }
- if (matchAwait()) {
- return parseAwaitExpression();
- }
- oldParenthesizedCount = state.parenthesizedCount;
- marker = markerCreate();
- if (matchAsyncFuncExprOrDecl()) {
- return parseFunctionExpression();
- }
- if (matchAsync()) {
- // We can't be completely sure that this 'async' token is
- // actually a contextual keyword modifying a function
- // expression, so we might have to un-lex() it later by
- // calling rewind(backtrackToken).
- possiblyAsync = true;
- lex();
- }
- if (match('(')) {
- token = lookahead2();
- if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
- params = parseParams();
- if (!match('=>')) {
- throwUnexpected(lex());
- }
- params.async = possiblyAsync;
- return parseArrowFunctionExpression(params, marker);
- }
- startsWithParen = true;
- }
- token = lookahead;
- // If the 'async' keyword is not followed by a '(' character or an
- // identifier, then it can't be an arrow function modifier, and we
- // should interpret it as a normal identifer.
- if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
- possiblyAsync = false;
- rewind(backtrackToken);
- }
- expr = parseConditionalExpression();
- if (match('=>') &&
- (state.parenthesizedCount === oldParenthesizedCount ||
- state.parenthesizedCount === (oldParenthesizedCount + 1))) {
- if (expr.type === Syntax.Identifier) {
- params = reinterpretAsCoverFormalsList([ expr ]);
- } else if (expr.type === Syntax.AssignmentExpression ||
- expr.type === Syntax.ArrayExpression ||
- expr.type === Syntax.ObjectExpression) {
- if (!startsWithParen) {
- throwUnexpected(lex());
- }
- params = reinterpretAsCoverFormalsList([ expr ]);
- } else if (expr.type === Syntax.SequenceExpression) {
- params = reinterpretAsCoverFormalsList(expr.expressions);
- }
- if (params) {
- params.async = possiblyAsync;
- return parseArrowFunctionExpression(params, marker);
- }
- }
- // If we haven't returned by now, then the 'async' keyword was not
- // a function modifier, and we should rewind and interpret it as a
- // normal identifier.
- if (possiblyAsync) {
- possiblyAsync = false;
- rewind(backtrackToken);
- expr = parseConditionalExpression();
- }
- if (matchAssign()) {
- // 11.13.1
- if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
- throwErrorTolerant(token, Messages.StrictLHSAssignment);
- }
- // ES.next draf 11.13 Runtime Semantics step 1
- if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) {
- reinterpretAsAssignmentBindingPattern(expr);
- } else if (!isLeftHandSide(expr)) {
- throwError({}, Messages.InvalidLHSInAssignment);
- }
- expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression()));
- }
- return expr;
- }
- // 11.14 Comma Operator
- function parseExpression() {
- var marker, expr, expressions, sequence, spreadFound, possibleArrow;
- marker = markerCreate();
- expr = parseAssignmentExpression();
- expressions = [ expr ];
- if (match(',')) {
- while (index < length) {
- if (!match(',')) {
- break;
- }
- lex();
- if (match(')')) {
- possibleArrow = lookahead2();
- if (
- possibleArrow.type === Token.Punctuator &&
- possibleArrow.value === '=>'
- ) {
- break;
- }
- }
- expr = parseSpreadOrAssignmentExpression();
- expressions.push(expr);
- if (expr.type === Syntax.SpreadElement) {
- spreadFound = true;
- if (!match(')')) {
- throwError({}, Messages.ElementAfterSpreadElement);
- }
- break;
- }
- }
- if (expressions.length > 1) {
- sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
- }
- }
- if (spreadFound && lookahead2().value !== '=>') {
- throwError({}, Messages.IllegalSpread);
- }
- return sequence || expr;
- }
- // 12.1 Block
- function parseStatementList() {
- var list = [],
- statement;
- while (index < length) {
- if (match('}')) {
- break;
- }
- statement = parseSourceElement();
- if (typeof statement === 'undefined') {
- break;
- }
- list.push(statement);
- }
- return list;
- }
- function parseBlock() {
- var block, marker = markerCreate();
- expect('{');
- block = parseStatementList();
- expect('}');
- return markerApply(marker, delegate.createBlockStatement(block));
- }
- // 12.2 Variable Statement
- function parseTypeParameterDeclaration() {
- var marker = markerCreate(), paramTypes = [];
- expect('<');
- while (!match('>')) {
- paramTypes.push(parseTypeAnnotatableIdentifier());
- if (!match('>')) {
- expect(',');
- }
- }
- expect('>');
- return markerApply(marker, delegate.createTypeParameterDeclaration(
- paramTypes
- ));
- }
- function parseTypeParameterInstantiation() {
- var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
- state.inType = true;
- expect('<');
- while (!match('>')) {
- paramTypes.push(parseType());
- if (!match('>')) {
- expect(',');
- }
- }
- expect('>');
- state.inType = oldInType;
- return markerApply(marker, delegate.createTypeParameterInstantiation(
- paramTypes
- ));
- }
- function parseObjectTypeIndexer(marker, isStatic) {
- var id, key, value;
- expect('[');
- id = parseObjectPropertyKey();
- expect(':');
- key = parseType();
- expect(']');
- expect(':');
- value = parseType();
- return markerApply(marker, delegate.createObjectTypeIndexer(
- id,
- key,
- value,
- isStatic
- ));
- }
- function parseObjectTypeMethodish(marker) {
- var params = [], rest = null, returnType, typeParameters = null;
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('(');
- while (lookahead.type === Token.Identifier) {
- params.push(parseFunctionTypeParam());
- if (!match(')')) {
- expect(',');
- }
- }
- if (match('...')) {
- lex();
- rest = parseFunctionTypeParam();
- }
- expect(')');
- expect(':');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- }
- function parseObjectTypeMethod(marker, isStatic, key) {
- var optional = false, value;
- value = parseObjectTypeMethodish(marker);
- return markerApply(marker, delegate.createObjectTypeProperty(
- key,
- value,
- optional,
- isStatic
- ));
- }
- function parseObjectTypeCallProperty(marker, isStatic) {
- var valueMarker = markerCreate();
- return markerApply(marker, delegate.createObjectTypeCallProperty(
- parseObjectTypeMethodish(valueMarker),
- isStatic
- ));
- }
- function parseObjectType(allowStatic) {
- var callProperties = [], indexers = [], marker, optional = false,
- properties = [], propertyKey, propertyTypeAnnotation,
- token, isStatic, matchStatic;
- expect('{');
- while (!match('}')) {
- marker = markerCreate();
- matchStatic =
- strict
- ? matchKeyword('static')
- : matchContextualKeyword('static');
- if (allowStatic && matchStatic) {
- token = lex();
- isStatic = true;
- }
- if (match('[')) {
- indexers.push(parseObjectTypeIndexer(marker, isStatic));
- } else if (match('(') || match('<')) {
- callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
- } else {
- if (isStatic && match(':')) {
- propertyKey = markerApply(marker, delegate.createIdentifier(token));
- throwErrorTolerant(token, Messages.StrictReservedWord);
- } else {
- propertyKey = parseObjectPropertyKey();
- }
- if (match('<') || match('(')) {
- // This is a method property
- properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
- } else {
- if (match('?')) {
- lex();
- optional = true;
- }
- expect(':');
- propertyTypeAnnotation = parseType();
- properties.push(markerApply(marker, delegate.createObjectTypeProperty(
- propertyKey,
- propertyTypeAnnotation,
- optional,
- isStatic
- )));
- }
- }
- if (match(';') || match(',')) {
- lex();
- } else if (!match('}')) {
- throwUnexpected(lookahead);
- }
- }
- expect('}');
- return delegate.createObjectTypeAnnotation(
- properties,
- indexers,
- callProperties
- );
- }
- function parseGenericType() {
- var marker = markerCreate(),
- typeParameters = null, typeIdentifier;
- typeIdentifier = parseVariableIdentifier();
- while (match('.')) {
- expect('.');
- typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
- typeIdentifier,
- parseVariableIdentifier()
- ));
- }
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- }
- return markerApply(marker, delegate.createGenericTypeAnnotation(
- typeIdentifier,
- typeParameters
- ));
- }
- function parseVoidType() {
- var marker = markerCreate();
- expectKeyword('void');
- return markerApply(marker, delegate.createVoidTypeAnnotation());
- }
- function parseTypeofType() {
- var argument, marker = markerCreate();
- expectKeyword('typeof');
- argument = parsePrimaryType();
- return markerApply(marker, delegate.createTypeofTypeAnnotation(
- argument
- ));
- }
- function parseTupleType() {
- var marker = markerCreate(), types = [];
- expect('[');
- // We allow trailing commas
- while (index < length && !match(']')) {
- types.push(parseType());
- if (match(']')) {
- break;
- }
- expect(',');
- }
- expect(']');
- return markerApply(marker, delegate.createTupleTypeAnnotation(
- types
- ));
- }
- function parseFunctionTypeParam() {
- var marker = markerCreate(), name, optional = false, typeAnnotation;
- name = parseVariableIdentifier();
- if (match('?')) {
- lex();
- optional = true;
- }
- expect(':');
- typeAnnotation = parseType();
- return markerApply(marker, delegate.createFunctionTypeParam(
- name,
- typeAnnotation,
- optional
- ));
- }
- function parseFunctionTypeParams() {
- var ret = { params: [], rest: null };
- while (lookahead.type === Token.Identifier) {
- ret.params.push(parseFunctionTypeParam());
- if (!match(')')) {
- expect(',');
- }
- }
- if (match('...')) {
- lex();
- ret.rest = parseFunctionTypeParam();
- }
- return ret;
- }
- // The parsing of types roughly parallels the parsing of expressions, and
- // primary types are kind of like primary expressions...they're the
- // primitives with which other types are constructed.
- function parsePrimaryType() {
- var params = null, returnType = null,
- marker = markerCreate(), rest = null, tmp,
- typeParameters, token, type, isGroupedType = false;
- switch (lookahead.type) {
- case Token.Identifier:
- switch (lookahead.value) {
- case 'any':
- lex();
- return markerApply(marker, delegate.createAnyTypeAnnotation());
- case 'bool': // fallthrough
- case 'boolean':
- lex();
- return markerApply(marker, delegate.createBooleanTypeAnnotation());
- case 'number':
- lex();
- return markerApply(marker, delegate.createNumberTypeAnnotation());
- case 'string':
- lex();
- return markerApply(marker, delegate.createStringTypeAnnotation());
- }
- return markerApply(marker, parseGenericType());
- case Token.Punctuator:
- switch (lookahead.value) {
- case '{':
- return markerApply(marker, parseObjectType());
- case '[':
- return parseTupleType();
- case '<':
- typeParameters = parseTypeParameterDeclaration();
- expect('(');
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect('=>');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- case '(':
- lex();
- // Check to see if this is actually a grouped type
- if (!match(')') && !match('...')) {
- if (lookahead.type === Token.Identifier) {
- token = lookahead2();
- isGroupedType = token.value !== '?' && token.value !== ':';
- } else {
- isGroupedType = true;
- }
- }
- if (isGroupedType) {
- type = parseType();
- expect(')');
- // If we see a => next then someone was probably confused about
- // function types, so we can provide a better error message
- if (match('=>')) {
- throwError({}, Messages.ConfusedAboutFunctionType);
- }
- return type;
- }
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect('=>');
- returnType = parseType();
- return markerApply(marker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- null /* typeParameters */
- ));
- }
- break;
- case Token.Keyword:
- switch (lookahead.value) {
- case 'void':
- return markerApply(marker, parseVoidType());
- case 'typeof':
- return markerApply(marker, parseTypeofType());
- }
- break;
- case Token.StringLiteral:
- token = lex();
- if (token.octal) {
- throwError(token, Messages.StrictOctalLiteral);
- }
- return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
- token
- ));
- }
- throwUnexpected(lookahead);
- }
- function parsePostfixType() {
- var marker = markerCreate(), t = parsePrimaryType();
- if (match('[')) {
- expect('[');
- expect(']');
- return markerApply(marker, delegate.createArrayTypeAnnotation(t));
- }
- return t;
- }
- function parsePrefixType() {
- var marker = markerCreate();
- if (match('?')) {
- lex();
- return markerApply(marker, delegate.createNullableTypeAnnotation(
- parsePrefixType()
- ));
- }
- return parsePostfixType();
- }
- function parseIntersectionType() {
- var marker = markerCreate(), type, types;
- type = parsePrefixType();
- types = [type];
- while (match('&')) {
- lex();
- types.push(parsePrefixType());
- }
- return types.length === 1 ?
- type :
- markerApply(marker, delegate.createIntersectionTypeAnnotation(
- types
- ));
- }
- function parseUnionType() {
- var marker = markerCreate(), type, types;
- type = parseIntersectionType();
- types = [type];
- while (match('|')) {
- lex();
- types.push(parseIntersectionType());
- }
- return types.length === 1 ?
- type :
- markerApply(marker, delegate.createUnionTypeAnnotation(
- types
- ));
- }
- function parseType() {
- var oldInType = state.inType, type;
- state.inType = true;
- type = parseUnionType();
- state.inType = oldInType;
- return type;
- }
- function parseTypeAnnotation() {
- var marker = markerCreate(), type;
- expect(':');
- type = parseType();
- return markerApply(marker, delegate.createTypeAnnotation(type));
- }
- function parseVariableIdentifier() {
- var marker = markerCreate(),
- token = lex();
- if (token.type !== Token.Identifier) {
- throwUnexpected(token);
- }
- return markerApply(marker, delegate.createIdentifier(token.value));
- }
- function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) {
- var marker = markerCreate(),
- ident = parseVariableIdentifier(),
- isOptionalParam = false;
- if (canBeOptionalParam && match('?')) {
- expect('?');
- isOptionalParam = true;
- }
- if (requireTypeAnnotation || match(':')) {
- ident.typeAnnotation = parseTypeAnnotation();
- ident = markerApply(marker, ident);
- }
- if (isOptionalParam) {
- ident.optional = true;
- ident = markerApply(marker, ident);
- }
- return ident;
- }
- function parseVariableDeclaration(kind) {
- var id,
- marker = markerCreate(),
- init = null,
- typeAnnotationMarker = markerCreate();
- if (match('{')) {
- id = parseObjectInitialiser();
- reinterpretAsAssignmentBindingPattern(id);
- if (match(':')) {
- id.typeAnnotation = parseTypeAnnotation();
- markerApply(typeAnnotationMarker, id);
- }
- } else if (match('[')) {
- id = parseArrayInitialiser();
- reinterpretAsAssignmentBindingPattern(id);
- if (match(':')) {
- id.typeAnnotation = parseTypeAnnotation();
- markerApply(typeAnnotationMarker, id);
- }
- } else {
- /* istanbul ignore next */
- id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
- // 12.2.1
- if (strict && isRestrictedWord(id.name)) {
- throwErrorTolerant({}, Messages.StrictVarName);
- }
- }
- if (kind === 'const') {
- if (!match('=')) {
- throwError({}, Messages.NoUninitializedConst);
- }
- expect('=');
- init = parseAssignmentExpression();
- } else if (match('=')) {
- lex();
- init = parseAssignmentExpression();
- }
- return markerApply(marker, delegate.createVariableDeclarator(id, init));
- }
- function parseVariableDeclarationList(kind) {
- var list = [];
- do {
- list.push(parseVariableDeclaration(kind));
- if (!match(',')) {
- break;
- }
- lex();
- } while (index < length);
- return list;
- }
- function parseVariableStatement() {
- var declarations, marker = markerCreate();
- expectKeyword('var');
- declarations = parseVariableDeclarationList();
- consumeSemicolon();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var'));
- }
- // kind may be `const` or `let`
- // Both are experimental and not in the specification yet.
- // see http://wiki.ecmascript.org/doku.php?id=harmony:const
- // and http://wiki.ecmascript.org/doku.php?id=harmony:let
- function parseConstLetDeclaration(kind) {
- var declarations, marker = markerCreate();
- expectKeyword(kind);
- declarations = parseVariableDeclarationList(kind);
- consumeSemicolon();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
- }
- // people.mozilla.org/~jorendorff/es6-draft.html
- function parseModuleSpecifier() {
- var marker = markerCreate(),
- specifier;
- if (lookahead.type !== Token.StringLiteral) {
- throwError({}, Messages.InvalidModuleSpecifier);
- }
- specifier = delegate.createLiteral(lex());
- return markerApply(marker, specifier);
- }
- function parseExportBatchSpecifier() {
- var marker = markerCreate();
- expect('*');
- return markerApply(marker, delegate.createExportBatchSpecifier());
- }
- function parseExportSpecifier() {
- var id, name = null, marker = markerCreate();
- if (matchKeyword('default')) {
- lex();
- id = markerApply(marker, delegate.createIdentifier('default'));
- // export {default} from "something";
- } else {
- id = parseVariableIdentifier();
- }
- if (matchContextualKeyword('as')) {
- lex();
- name = parseNonComputedProperty();
- }
- return markerApply(marker, delegate.createExportSpecifier(id, name));
- }
- function parseExportDeclaration() {
- var declaration = null,
- possibleIdentifierToken, sourceElement,
- isExportFromIdentifier,
- src = null, specifiers = [],
- marker = markerCreate();
- expectKeyword('export');
- if (matchKeyword('default')) {
- // covers:
- // export default ...
- lex();
- if (matchKeyword('function') || matchKeyword('class')) {
- possibleIdentifierToken = lookahead2();
- if (isIdentifierName(possibleIdentifierToken)) {
- // covers:
- // export default function foo () {}
- // export default class foo {}
- sourceElement = parseSourceElement();
- return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null));
- }
- // covers:
- // export default function () {}
- // export default class {}
- switch (lookahead.value) {
- case 'class':
- return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
- case 'function':
- return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
- }
- }
- if (matchContextualKeyword('from')) {
- throwError({}, Messages.UnexpectedToken, lookahead.value);
- }
- // covers:
- // export default {};
- // export default [];
- if (match('{')) {
- declaration = parseObjectInitialiser();
- } else if (match('[')) {
- declaration = parseArrayInitialiser();
- } else {
- declaration = parseAssignmentExpression();
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
- }
- // non-default export
- if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
- // covers:
- // export var f = 1;
- switch (lookahead.value) {
- case 'type':
- case 'let':
- case 'const':
- case 'var':
- case 'class':
- case 'function':
- return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
- }
- }
- if (match('*')) {
- // covers:
- // export * from "foo";
- specifiers.push(parseExportBatchSpecifier());
- if (!matchContextualKeyword('from')) {
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- }
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
- }
- expect('{');
- if (!match('}')) {
- do {
- isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
- specifiers.push(parseExportSpecifier());
- } while (match(',') && lex());
- }
- expect('}');
- if (matchContextualKeyword('from')) {
- // covering:
- // export {default} from "foo";
- // export {foo} from "foo";
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- } else if (isExportFromIdentifier) {
- // covering:
- // export {default}; // missing fromClause
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- } else {
- // cover
- // export {foo};
- consumeSemicolon();
- }
- return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
- }
- function parseImportSpecifier() {
- // import {<foo as bar>} ...;
- var id, name = null, marker = markerCreate();
- id = parseNonComputedProperty();
- if (matchContextualKeyword('as')) {
- lex();
- name = parseVariableIdentifier();
- }
- return markerApply(marker, delegate.createImportSpecifier(id, name));
- }
- function parseNamedImports() {
- var specifiers = [];
- // {foo, bar as bas}
- expect('{');
- if (!match('}')) {
- do {
- specifiers.push(parseImportSpecifier());
- } while (match(',') && lex());
- }
- expect('}');
- return specifiers;
- }
- function parseImportDefaultSpecifier() {
- // import <foo> ...;
- var id, marker = markerCreate();
- id = parseNonComputedProperty();
- return markerApply(marker, delegate.createImportDefaultSpecifier(id));
- }
- function parseImportNamespaceSpecifier() {
- // import <* as foo> ...;
- var id, marker = markerCreate();
- expect('*');
- if (!matchContextualKeyword('as')) {
- throwError({}, Messages.NoAsAfterImportNamespace);
- }
- lex();
- id = parseNonComputedProperty();
- return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
- }
- function parseImportDeclaration() {
- var specifiers, src, marker = markerCreate(), isType = false, token2;
- expectKeyword('import');
- if (matchContextualKeyword('type')) {
- token2 = lookahead2();
- if ((token2.type === Token.Identifier && token2.value !== 'from') ||
- (token2.type === Token.Punctuator &&
- (token2.value === '{' || token2.value === '*'))) {
- isType = true;
- lex();
- }
- }
- specifiers = [];
- if (lookahead.type === Token.StringLiteral) {
- // covers:
- // import "foo";
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
- }
- if (!matchKeyword('default') && isIdentifierName(lookahead)) {
- // covers:
- // import foo
- // import foo, ...
- specifiers.push(parseImportDefaultSpecifier());
- if (match(',')) {
- lex();
- }
- }
- if (match('*')) {
- // covers:
- // import foo, * as foo
- // import * as foo
- specifiers.push(parseImportNamespaceSpecifier());
- } else if (match('{')) {
- // covers:
- // import foo, {bar}
- // import {bar}
- specifiers = specifiers.concat(parseNamedImports());
- }
- if (!matchContextualKeyword('from')) {
- throwError({}, lookahead.value ?
- Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
- }
- lex();
- src = parseModuleSpecifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
- }
- // 12.3 Empty Statement
- function parseEmptyStatement() {
- var marker = markerCreate();
- expect(';');
- return markerApply(marker, delegate.createEmptyStatement());
- }
- // 12.4 Expression Statement
- function parseExpressionStatement() {
- var marker = markerCreate(), expr = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createExpressionStatement(expr));
- }
- // 12.5 If statement
- function parseIfStatement() {
- var test, consequent, alternate, marker = markerCreate();
- expectKeyword('if');
- expect('(');
- test = parseExpression();
- expect(')');
- consequent = parseStatement();
- if (matchKeyword('else')) {
- lex();
- alternate = parseStatement();
- } else {
- alternate = null;
- }
- return markerApply(marker, delegate.createIfStatement(test, consequent, alternate));
- }
- // 12.6 Iteration Statements
- function parseDoWhileStatement() {
- var body, test, oldInIteration, marker = markerCreate();
- expectKeyword('do');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- body = parseStatement();
- state.inIteration = oldInIteration;
- expectKeyword('while');
- expect('(');
- test = parseExpression();
- expect(')');
- if (match(';')) {
- lex();
- }
- return markerApply(marker, delegate.createDoWhileStatement(body, test));
- }
- function parseWhileStatement() {
- var test, body, oldInIteration, marker = markerCreate();
- expectKeyword('while');
- expect('(');
- test = parseExpression();
- expect(')');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- body = parseStatement();
- state.inIteration = oldInIteration;
- return markerApply(marker, delegate.createWhileStatement(test, body));
- }
- function parseForVariableDeclaration() {
- var marker = markerCreate(),
- token = lex(),
- declarations = parseVariableDeclarationList();
- return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value));
- }
- function parseForStatement(opts) {
- var init, test, update, left, right, body, operator, oldInIteration,
- marker = markerCreate();
- init = test = update = null;
- expectKeyword('for');
- // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each
- if (matchContextualKeyword('each')) {
- throwError({}, Messages.EachNotAllowed);
- }
- expect('(');
- if (match(';')) {
- lex();
- } else {
- if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) {
- state.allowIn = false;
- init = parseForVariableDeclaration();
- state.allowIn = true;
- if (init.declarations.length === 1) {
- if (matchKeyword('in') || matchContextualKeyword('of')) {
- operator = lookahead;
- if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) {
- lex();
- left = init;
- right = parseExpression();
- init = null;
- }
- }
- }
- } else {
- state.allowIn = false;
- init = parseExpression();
- state.allowIn = true;
- if (matchContextualKeyword('of')) {
- operator = lex();
- left = init;
- right = parseExpression();
- init = null;
- } else if (matchKeyword('in')) {
- // LeftHandSideExpression
- if (!isAssignableLeftHandSide(init)) {
- throwError({}, Messages.InvalidLHSInForIn);
- }
- operator = lex();
- left = init;
- right = parseExpression();
- init = null;
- }
- }
- if (typeof left === 'undefined') {
- expect(';');
- }
- }
- if (typeof left === 'undefined') {
- if (!match(';')) {
- test = parseExpression();
- }
- expect(';');
- if (!match(')')) {
- update = parseExpression();
- }
- }
- expect(')');
- oldInIteration = state.inIteration;
- state.inIteration = true;
- if (!(opts !== undefined && opts.ignoreBody)) {
- body = parseStatement();
- }
- state.inIteration = oldInIteration;
- if (typeof left === 'undefined') {
- return markerApply(marker, delegate.createForStatement(init, test, update, body));
- }
- if (operator.value === 'in') {
- return markerApply(marker, delegate.createForInStatement(left, right, body));
- }
- return markerApply(marker, delegate.createForOfStatement(left, right, body));
- }
- // 12.7 The continue statement
- function parseContinueStatement() {
- var label = null, marker = markerCreate();
- expectKeyword('continue');
- // Optimize the most common form: 'continue;'.
- if (source.charCodeAt(index) === 59) {
- lex();
- if (!state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(null));
- }
- if (peekLineTerminator()) {
- if (!state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(null));
- }
- if (lookahead.type === Token.Identifier) {
- label = parseVariableIdentifier();
- if (!state.labelSet.has(label.name)) {
- throwError({}, Messages.UnknownLabel, label.name);
- }
- }
- consumeSemicolon();
- if (label === null && !state.inIteration) {
- throwError({}, Messages.IllegalContinue);
- }
- return markerApply(marker, delegate.createContinueStatement(label));
- }
- // 12.8 The break statement
- function parseBreakStatement() {
- var label = null, marker = markerCreate();
- expectKeyword('break');
- // Catch the very common case first: immediately a semicolon (char #59).
- if (source.charCodeAt(index) === 59) {
- lex();
- if (!(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(null));
- }
- if (peekLineTerminator()) {
- if (!(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(null));
- }
- if (lookahead.type === Token.Identifier) {
- label = parseVariableIdentifier();
- if (!state.labelSet.has(label.name)) {
- throwError({}, Messages.UnknownLabel, label.name);
- }
- }
- consumeSemicolon();
- if (label === null && !(state.inIteration || state.inSwitch)) {
- throwError({}, Messages.IllegalBreak);
- }
- return markerApply(marker, delegate.createBreakStatement(label));
- }
- // 12.9 The return statement
- function parseReturnStatement() {
- var argument = null, marker = markerCreate();
- expectKeyword('return');
- if (!state.inFunctionBody) {
- throwErrorTolerant({}, Messages.IllegalReturn);
- }
- // 'return' followed by a space and an identifier is very common.
- if (source.charCodeAt(index) === 32) {
- if (isIdentifierStart(source.charCodeAt(index + 1))) {
- argument = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createReturnStatement(argument));
- }
- }
- if (peekLineTerminator()) {
- return markerApply(marker, delegate.createReturnStatement(null));
- }
- if (!match(';')) {
- if (!match('}') && lookahead.type !== Token.EOF) {
- argument = parseExpression();
- }
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createReturnStatement(argument));
- }
- // 12.10 The with statement
- function parseWithStatement() {
- var object, body, marker = markerCreate();
- if (strict) {
- throwErrorTolerant({}, Messages.StrictModeWith);
- }
- expectKeyword('with');
- expect('(');
- object = parseExpression();
- expect(')');
- body = parseStatement();
- return markerApply(marker, delegate.createWithStatement(object, body));
- }
- // 12.10 The swith statement
- function parseSwitchCase() {
- var test,
- consequent = [],
- sourceElement,
- marker = markerCreate();
- if (matchKeyword('default')) {
- lex();
- test = null;
- } else {
- expectKeyword('case');
- test = parseExpression();
- }
- expect(':');
- while (index < length) {
- if (match('}') || matchKeyword('default') || matchKeyword('case')) {
- break;
- }
- sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- consequent.push(sourceElement);
- }
- return markerApply(marker, delegate.createSwitchCase(test, consequent));
- }
- function parseSwitchStatement() {
- var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate();
- expectKeyword('switch');
- expect('(');
- discriminant = parseExpression();
- expect(')');
- expect('{');
- cases = [];
- if (match('}')) {
- lex();
- return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
- }
- oldInSwitch = state.inSwitch;
- state.inSwitch = true;
- defaultFound = false;
- while (index < length) {
- if (match('}')) {
- break;
- }
- clause = parseSwitchCase();
- if (clause.test === null) {
- if (defaultFound) {
- throwError({}, Messages.MultipleDefaultsInSwitch);
- }
- defaultFound = true;
- }
- cases.push(clause);
- }
- state.inSwitch = oldInSwitch;
- expect('}');
- return markerApply(marker, delegate.createSwitchStatement(discriminant, cases));
- }
- // 12.13 The throw statement
- function parseThrowStatement() {
- var argument, marker = markerCreate();
- expectKeyword('throw');
- if (peekLineTerminator()) {
- throwError({}, Messages.NewlineAfterThrow);
- }
- argument = parseExpression();
- consumeSemicolon();
- return markerApply(marker, delegate.createThrowStatement(argument));
- }
- // 12.14 The try statement
- function parseCatchClause() {
- var param, body, marker = markerCreate();
- expectKeyword('catch');
- expect('(');
- if (match(')')) {
- throwUnexpected(lookahead);
- }
- param = parseExpression();
- // 12.14.1
- if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) {
- throwErrorTolerant({}, Messages.StrictCatchVariable);
- }
- expect(')');
- body = parseBlock();
- return markerApply(marker, delegate.createCatchClause(param, body));
- }
- function parseTryStatement() {
- var block, handlers = [], finalizer = null, marker = markerCreate();
- expectKeyword('try');
- block = parseBlock();
- if (matchKeyword('catch')) {
- handlers.push(parseCatchClause());
- }
- if (matchKeyword('finally')) {
- lex();
- finalizer = parseBlock();
- }
- if (handlers.length === 0 && !finalizer) {
- throwError({}, Messages.NoCatchOrFinally);
- }
- return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer));
- }
- // 12.15 The debugger statement
- function parseDebuggerStatement() {
- var marker = markerCreate();
- expectKeyword('debugger');
- consumeSemicolon();
- return markerApply(marker, delegate.createDebuggerStatement());
- }
- // 12 Statements
- function parseStatement() {
- var type = lookahead.type,
- marker,
- expr,
- labeledBody;
- if (type === Token.EOF) {
- throwUnexpected(lookahead);
- }
- if (type === Token.Punctuator) {
- switch (lookahead.value) {
- case ';':
- return parseEmptyStatement();
- case '{':
- return parseBlock();
- case '(':
- return parseExpressionStatement();
- default:
- break;
- }
- }
- if (type === Token.Keyword) {
- switch (lookahead.value) {
- case 'break':
- return parseBreakStatement();
- case 'continue':
- return parseContinueStatement();
- case 'debugger':
- return parseDebuggerStatement();
- case 'do':
- return parseDoWhileStatement();
- case 'for':
- return parseForStatement();
- case 'function':
- return parseFunctionDeclaration();
- case 'class':
- return parseClassDeclaration();
- case 'if':
- return parseIfStatement();
- case 'return':
- return parseReturnStatement();
- case 'switch':
- return parseSwitchStatement();
- case 'throw':
- return parseThrowStatement();
- case 'try':
- return parseTryStatement();
- case 'var':
- return parseVariableStatement();
- case 'while':
- return parseWhileStatement();
- case 'with':
- return parseWithStatement();
- default:
- break;
- }
- }
- if (matchAsyncFuncExprOrDecl()) {
- return parseFunctionDeclaration();
- }
- marker = markerCreate();
- expr = parseExpression();
- // 12.12 Labelled Statements
- if ((expr.type === Syntax.Identifier) && match(':')) {
- lex();
- if (state.labelSet.has(expr.name)) {
- throwError({}, Messages.Redeclaration, 'Label', expr.name);
- }
- state.labelSet.set(expr.name, true);
- labeledBody = parseStatement();
- state.labelSet.delete(expr.name);
- return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
- }
- consumeSemicolon();
- return markerApply(marker, delegate.createExpressionStatement(expr));
- }
- // 13 Function Definition
- function parseConciseBody() {
- if (match('{')) {
- return parseFunctionSourceElements();
- }
- return parseAssignmentExpression();
- }
- function parseFunctionSourceElements() {
- var sourceElement, sourceElements = [], token, directive, firstRestricted,
- oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount,
- marker = markerCreate();
- expect('{');
- while (index < length) {
- if (lookahead.type !== Token.StringLiteral) {
- break;
- }
- token = lookahead;
- sourceElement = parseSourceElement();
- sourceElements.push(sourceElement);
- if (sourceElement.expression.type !== Syntax.Literal) {
- // this is not directive
- break;
- }
- directive = source.slice(token.range[0] + 1, token.range[1] - 1);
- if (directive === 'use strict') {
- strict = true;
- if (firstRestricted) {
- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
- }
- } else {
- if (!firstRestricted && token.octal) {
- firstRestricted = token;
- }
- }
- }
- oldLabelSet = state.labelSet;
- oldInIteration = state.inIteration;
- oldInSwitch = state.inSwitch;
- oldInFunctionBody = state.inFunctionBody;
- oldParenthesizedCount = state.parenthesizedCount;
- state.labelSet = new StringMap();
- state.inIteration = false;
- state.inSwitch = false;
- state.inFunctionBody = true;
- state.parenthesizedCount = 0;
- while (index < length) {
- if (match('}')) {
- break;
- }
- sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- sourceElements.push(sourceElement);
- }
- expect('}');
- state.labelSet = oldLabelSet;
- state.inIteration = oldInIteration;
- state.inSwitch = oldInSwitch;
- state.inFunctionBody = oldInFunctionBody;
- state.parenthesizedCount = oldParenthesizedCount;
- return markerApply(marker, delegate.createBlockStatement(sourceElements));
- }
- function validateParam(options, param, name) {
- if (strict) {
- if (isRestrictedWord(name)) {
- options.stricted = param;
- options.message = Messages.StrictParamName;
- }
- if (options.paramSet.has(name)) {
- options.stricted = param;
- options.message = Messages.StrictParamDupe;
- }
- } else if (!options.firstRestricted) {
- if (isRestrictedWord(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictParamName;
- } else if (isStrictModeReservedWord(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictReservedWord;
- } else if (options.paramSet.has(name)) {
- options.firstRestricted = param;
- options.message = Messages.StrictParamDupe;
- }
- }
- options.paramSet.set(name, true);
- }
- function parseParam(options) {
- var marker, token, rest, param, def;
- token = lookahead;
- if (token.value === '...') {
- token = lex();
- rest = true;
- }
- if (match('[')) {
- marker = markerCreate();
- param = parseArrayInitialiser();
- reinterpretAsDestructuredParameter(options, param);
- if (match(':')) {
- param.typeAnnotation = parseTypeAnnotation();
- markerApply(marker, param);
- }
- } else if (match('{')) {
- marker = markerCreate();
- if (rest) {
- throwError({}, Messages.ObjectPatternAsRestParameter);
- }
- param = parseObjectInitialiser();
- reinterpretAsDestructuredParameter(options, param);
- if (match(':')) {
- param.typeAnnotation = parseTypeAnnotation();
- markerApply(marker, param);
- }
- } else {
- param =
- rest
- ? parseTypeAnnotatableIdentifier(
- false, /* requireTypeAnnotation */
- false /* canBeOptionalParam */
- )
- : parseTypeAnnotatableIdentifier(
- false, /* requireTypeAnnotation */
- true /* canBeOptionalParam */
- );
- validateParam(options, token, token.value);
- }
- if (match('=')) {
- if (rest) {
- throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
- }
- lex();
- def = parseAssignmentExpression();
- ++options.defaultCount;
- }
- if (rest) {
- if (!match(')')) {
- throwError({}, Messages.ParameterAfterRestParameter);
- }
- options.rest = param;
- return false;
- }
- options.params.push(param);
- options.defaults.push(def);
- return !match(')');
- }
- function parseParams(firstRestricted) {
- var options, marker = markerCreate();
- options = {
- params: [],
- defaultCount: 0,
- defaults: [],
- rest: null,
- firstRestricted: firstRestricted
- };
- expect('(');
- if (!match(')')) {
- options.paramSet = new StringMap();
- while (index < length) {
- if (!parseParam(options)) {
- break;
- }
- expect(',');
- if (!options.rest && match(')')) {
- break;
- }
- }
- }
- expect(')');
- if (options.defaultCount === 0) {
- options.defaults = [];
- }
- if (match(':')) {
- options.returnType = parseTypeAnnotation();
- }
- return markerApply(marker, options);
- }
- function parseFunctionDeclaration() {
- var id, body, token, tmp, firstRestricted, message, generator, isAsync,
- previousStrict, previousYieldAllowed, previousAwaitAllowed,
- marker = markerCreate(), typeParameters;
- isAsync = false;
- if (matchAsync()) {
- lex();
- isAsync = true;
- }
- expectKeyword('function');
- generator = false;
- if (match('*')) {
- lex();
- generator = true;
- }
- token = lookahead;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (strict) {
- if (isRestrictedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictFunctionName);
- }
- } else {
- if (isRestrictedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictFunctionName;
- } else if (isStrictModeReservedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictReservedWord;
- }
- }
- tmp = parseParams(firstRestricted);
- firstRestricted = tmp.firstRestricted;
- if (tmp.message) {
- message = tmp.message;
- }
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = isAsync;
- body = parseFunctionSourceElements();
- if (strict && firstRestricted) {
- throwError(firstRestricted, message);
- }
- if (strict && tmp.stricted) {
- throwErrorTolerant(tmp.stricted, message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(
- marker,
- delegate.createFunctionDeclaration(
- id,
- tmp.params,
- tmp.defaults,
- body,
- tmp.rest,
- generator,
- false,
- isAsync,
- tmp.returnType,
- typeParameters
- )
- );
- }
- function parseFunctionExpression() {
- var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
- previousStrict, previousYieldAllowed, previousAwaitAllowed,
- marker = markerCreate(), typeParameters;
- isAsync = false;
- if (matchAsync()) {
- lex();
- isAsync = true;
- }
- expectKeyword('function');
- generator = false;
- if (match('*')) {
- lex();
- generator = true;
- }
- if (!match('(')) {
- if (!match('<')) {
- token = lookahead;
- id = parseVariableIdentifier();
- if (strict) {
- if (isRestrictedWord(token.value)) {
- throwErrorTolerant(token, Messages.StrictFunctionName);
- }
- } else {
- if (isRestrictedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictFunctionName;
- } else if (isStrictModeReservedWord(token.value)) {
- firstRestricted = token;
- message = Messages.StrictReservedWord;
- }
- }
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- }
- tmp = parseParams(firstRestricted);
- firstRestricted = tmp.firstRestricted;
- if (tmp.message) {
- message = tmp.message;
- }
- previousStrict = strict;
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = generator;
- previousAwaitAllowed = state.awaitAllowed;
- state.awaitAllowed = isAsync;
- body = parseFunctionSourceElements();
- if (strict && firstRestricted) {
- throwError(firstRestricted, message);
- }
- if (strict && tmp.stricted) {
- throwErrorTolerant(tmp.stricted, message);
- }
- strict = previousStrict;
- state.yieldAllowed = previousYieldAllowed;
- state.awaitAllowed = previousAwaitAllowed;
- return markerApply(
- marker,
- delegate.createFunctionExpression(
- id,
- tmp.params,
- tmp.defaults,
- body,
- tmp.rest,
- generator,
- false,
- isAsync,
- tmp.returnType,
- typeParameters
- )
- );
- }
- function parseYieldExpression() {
- var delegateFlag, expr, marker = markerCreate();
- expectKeyword('yield', !strict);
- delegateFlag = false;
- if (match('*')) {
- lex();
- delegateFlag = true;
- }
- expr = parseAssignmentExpression();
- return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
- }
- function parseAwaitExpression() {
- var expr, marker = markerCreate();
- expectContextualKeyword('await');
- expr = parseAssignmentExpression();
- return markerApply(marker, delegate.createAwaitExpression(expr));
- }
- // 14 Functions and classes
- // 14.1 Functions is defined above (13 in ES5)
- // 14.2 Arrow Functions Definitions is defined in (7.3 assignments)
- // 14.3 Method Definitions
- // 14.3.7
- function specialMethod(methodDefinition) {
- return methodDefinition.kind === 'get' ||
- methodDefinition.kind === 'set' ||
- methodDefinition.value.generator;
- }
- function parseMethodDefinition(key, isStatic, generator, computed) {
- var token, param, propType,
- isAsync, typeParameters, tokenValue, returnType;
- propType = isStatic ? ClassPropertyType.static : ClassPropertyType.prototype;
- if (generator) {
- return delegate.createMethodDefinition(
- propType,
- '',
- key,
- parsePropertyMethodFunction({ generator: true }),
- computed
- );
- }
- tokenValue = key.type === 'Identifier' && key.name;
- if (tokenValue === 'get' && !match('(')) {
- key = parseObjectPropertyKey();
- expect('(');
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return delegate.createMethodDefinition(
- propType,
- 'get',
- key,
- parsePropertyFunction({ generator: false, returnType: returnType }),
- computed
- );
- }
- if (tokenValue === 'set' && !match('(')) {
- key = parseObjectPropertyKey();
- expect('(');
- token = lookahead;
- param = [ parseTypeAnnotatableIdentifier() ];
- expect(')');
- if (match(':')) {
- returnType = parseTypeAnnotation();
- }
- return delegate.createMethodDefinition(
- propType,
- 'set',
- key,
- parsePropertyFunction({
- params: param,
- generator: false,
- name: token,
- returnType: returnType
- }),
- computed
- );
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- isAsync = tokenValue === 'async' && !match('(');
- if (isAsync) {
- key = parseObjectPropertyKey();
- }
- return delegate.createMethodDefinition(
- propType,
- '',
- key,
- parsePropertyMethodFunction({
- generator: false,
- async: isAsync,
- typeParameters: typeParameters
- }),
- computed
- );
- }
- function parseClassProperty(key, computed, isStatic) {
- var typeAnnotation;
- typeAnnotation = parseTypeAnnotation();
- expect(';');
- return delegate.createClassProperty(
- key,
- typeAnnotation,
- computed,
- isStatic
- );
- }
- function parseClassElement() {
- var computed = false, generator = false, key, marker = markerCreate(),
- isStatic = false, possiblyOpenBracketToken;
- if (match(';')) {
- lex();
- return undefined;
- }
- if (lookahead.value === 'static') {
- lex();
- isStatic = true;
- }
- if (match('*')) {
- lex();
- generator = true;
- }
- possiblyOpenBracketToken = lookahead;
- if (matchContextualKeyword('get') || matchContextualKeyword('set')) {
- possiblyOpenBracketToken = lookahead2();
- }
- if (possiblyOpenBracketToken.type === Token.Punctuator
- && possiblyOpenBracketToken.value === '[') {
- computed = true;
- }
- key = parseObjectPropertyKey();
- if (!generator && lookahead.value === ':') {
- return markerApply(marker, parseClassProperty(key, computed, isStatic));
- }
- return markerApply(marker, parseMethodDefinition(
- key,
- isStatic,
- generator,
- computed
- ));
- }
- function parseClassBody() {
- var classElement, classElements = [], existingProps = {},
- marker = markerCreate(), propName, propType;
- existingProps[ClassPropertyType.static] = new StringMap();
- existingProps[ClassPropertyType.prototype] = new StringMap();
- expect('{');
- while (index < length) {
- if (match('}')) {
- break;
- }
- classElement = parseClassElement(existingProps);
- if (typeof classElement !== 'undefined') {
- classElements.push(classElement);
- propName = !classElement.computed && getFieldName(classElement.key);
- if (propName !== false) {
- propType = classElement.static ?
- ClassPropertyType.static :
- ClassPropertyType.prototype;
- if (classElement.type === Syntax.MethodDefinition) {
- if (propName === 'constructor' && !classElement.static) {
- if (specialMethod(classElement)) {
- throwError(classElement, Messages.IllegalClassConstructorProperty);
- }
- if (existingProps[ClassPropertyType.prototype].has('constructor')) {
- throwError(classElement.key, Messages.IllegalDuplicateClassProperty);
- }
- }
- existingProps[propType].set(propName, true);
- }
- }
- }
- }
- expect('}');
- return markerApply(marker, delegate.createClassBody(classElements));
- }
- function parseClassImplements() {
- var id, implemented = [], marker, typeParameters;
- if (strict) {
- expectKeyword('implements');
- } else {
- expectContextualKeyword('implements');
- }
- while (index < length) {
- marker = markerCreate();
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- } else {
- typeParameters = null;
- }
- implemented.push(markerApply(marker, delegate.createClassImplements(
- id,
- typeParameters
- )));
- if (!match(',')) {
- break;
- }
- expect(',');
- }
- return implemented;
- }
- function parseClassExpression() {
- var id, implemented, previousYieldAllowed, superClass = null,
- superTypeParameters, marker = markerCreate(), typeParameters,
- matchImplements;
- expectKeyword('class');
- matchImplements =
- strict
- ? matchKeyword('implements')
- : matchContextualKeyword('implements');
- if (!matchKeyword('extends') && !matchImplements && !match('{')) {
- id = parseVariableIdentifier();
- }
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- superClass = parseLeftHandSideExpressionAllowCall();
- if (match('<')) {
- superTypeParameters = parseTypeParameterInstantiation();
- }
- state.yieldAllowed = previousYieldAllowed;
- }
- if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
- implemented = parseClassImplements();
- }
- return markerApply(marker, delegate.createClassExpression(
- id,
- superClass,
- parseClassBody(),
- typeParameters,
- superTypeParameters,
- implemented
- ));
- }
- function parseClassDeclaration() {
- var id, implemented, previousYieldAllowed, superClass = null,
- superTypeParameters, marker = markerCreate(), typeParameters;
- expectKeyword('class');
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- previousYieldAllowed = state.yieldAllowed;
- state.yieldAllowed = false;
- superClass = parseLeftHandSideExpressionAllowCall();
- if (match('<')) {
- superTypeParameters = parseTypeParameterInstantiation();
- }
- state.yieldAllowed = previousYieldAllowed;
- }
- if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
- implemented = parseClassImplements();
- }
- return markerApply(marker, delegate.createClassDeclaration(
- id,
- superClass,
- parseClassBody(),
- typeParameters,
- superTypeParameters,
- implemented
- ));
- }
- // 15 Program
- function parseSourceElement() {
- var token;
- if (lookahead.type === Token.Keyword) {
- switch (lookahead.value) {
- case 'const':
- case 'let':
- return parseConstLetDeclaration(lookahead.value);
- case 'function':
- return parseFunctionDeclaration();
- case 'export':
- throwErrorTolerant({}, Messages.IllegalExportDeclaration);
- return parseExportDeclaration();
- case 'import':
- throwErrorTolerant({}, Messages.IllegalImportDeclaration);
- return parseImportDeclaration();
- case 'interface':
- if (lookahead2().type === Token.Identifier) {
- return parseInterface();
- }
- return parseStatement();
- default:
- return parseStatement();
- }
- }
- if (matchContextualKeyword('type')
- && lookahead2().type === Token.Identifier) {
- return parseTypeAlias();
- }
- if (matchContextualKeyword('interface')
- && lookahead2().type === Token.Identifier) {
- return parseInterface();
- }
- if (matchContextualKeyword('declare')) {
- token = lookahead2();
- if (token.type === Token.Keyword) {
- switch (token.value) {
- case 'class':
- return parseDeclareClass();
- case 'function':
- return parseDeclareFunction();
- case 'var':
- return parseDeclareVariable();
- }
- } else if (token.type === Token.Identifier
- && token.value === 'module') {
- return parseDeclareModule();
- }
- }
- if (lookahead.type !== Token.EOF) {
- return parseStatement();
- }
- }
- function parseProgramElement() {
- var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule';
- if (isModule && lookahead.type === Token.Keyword) {
- switch (lookahead.value) {
- case 'export':
- return parseExportDeclaration();
- case 'import':
- return parseImportDeclaration();
- }
- }
- return parseSourceElement();
- }
- function parseProgramElements() {
- var sourceElement, sourceElements = [], token, directive, firstRestricted;
- while (index < length) {
- token = lookahead;
- if (token.type !== Token.StringLiteral) {
- break;
- }
- sourceElement = parseProgramElement();
- sourceElements.push(sourceElement);
- if (sourceElement.expression.type !== Syntax.Literal) {
- // this is not directive
- break;
- }
- directive = source.slice(token.range[0] + 1, token.range[1] - 1);
- if (directive === 'use strict') {
- strict = true;
- if (firstRestricted) {
- throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
- }
- } else {
- if (!firstRestricted && token.octal) {
- firstRestricted = token;
- }
- }
- }
- while (index < length) {
- sourceElement = parseProgramElement();
- if (typeof sourceElement === 'undefined') {
- break;
- }
- sourceElements.push(sourceElement);
- }
- return sourceElements;
- }
- function parseProgram() {
- var body, marker = markerCreate();
- strict = extra.sourceType === 'module';
- peek();
- body = parseProgramElements();
- return markerApply(marker, delegate.createProgram(body));
- }
- // 16 JSX
- XHTMLEntities = {
- quot: '\u0022',
- amp: '&',
- apos: '\u0027',
- lt: '<',
- gt: '>',
- nbsp: '\u00A0',
- iexcl: '\u00A1',
- cent: '\u00A2',
- pound: '\u00A3',
- curren: '\u00A4',
- yen: '\u00A5',
- brvbar: '\u00A6',
- sect: '\u00A7',
- uml: '\u00A8',
- copy: '\u00A9',
- ordf: '\u00AA',
- laquo: '\u00AB',
- not: '\u00AC',
- shy: '\u00AD',
- reg: '\u00AE',
- macr: '\u00AF',
- deg: '\u00B0',
- plusmn: '\u00B1',
- sup2: '\u00B2',
- sup3: '\u00B3',
- acute: '\u00B4',
- micro: '\u00B5',
- para: '\u00B6',
- middot: '\u00B7',
- cedil: '\u00B8',
- sup1: '\u00B9',
- ordm: '\u00BA',
- raquo: '\u00BB',
- frac14: '\u00BC',
- frac12: '\u00BD',
- frac34: '\u00BE',
- iquest: '\u00BF',
- Agrave: '\u00C0',
- Aacute: '\u00C1',
- Acirc: '\u00C2',
- Atilde: '\u00C3',
- Auml: '\u00C4',
- Aring: '\u00C5',
- AElig: '\u00C6',
- Ccedil: '\u00C7',
- Egrave: '\u00C8',
- Eacute: '\u00C9',
- Ecirc: '\u00CA',
- Euml: '\u00CB',
- Igrave: '\u00CC',
- Iacute: '\u00CD',
- Icirc: '\u00CE',
- Iuml: '\u00CF',
- ETH: '\u00D0',
- Ntilde: '\u00D1',
- Ograve: '\u00D2',
- Oacute: '\u00D3',
- Ocirc: '\u00D4',
- Otilde: '\u00D5',
- Ouml: '\u00D6',
- times: '\u00D7',
- Oslash: '\u00D8',
- Ugrave: '\u00D9',
- Uacute: '\u00DA',
- Ucirc: '\u00DB',
- Uuml: '\u00DC',
- Yacute: '\u00DD',
- THORN: '\u00DE',
- szlig: '\u00DF',
- agrave: '\u00E0',
- aacute: '\u00E1',
- acirc: '\u00E2',
- atilde: '\u00E3',
- auml: '\u00E4',
- aring: '\u00E5',
- aelig: '\u00E6',
- ccedil: '\u00E7',
- egrave: '\u00E8',
- eacute: '\u00E9',
- ecirc: '\u00EA',
- euml: '\u00EB',
- igrave: '\u00EC',
- iacute: '\u00ED',
- icirc: '\u00EE',
- iuml: '\u00EF',
- eth: '\u00F0',
- ntilde: '\u00F1',
- ograve: '\u00F2',
- oacute: '\u00F3',
- ocirc: '\u00F4',
- otilde: '\u00F5',
- ouml: '\u00F6',
- divide: '\u00F7',
- oslash: '\u00F8',
- ugrave: '\u00F9',
- uacute: '\u00FA',
- ucirc: '\u00FB',
- uuml: '\u00FC',
- yacute: '\u00FD',
- thorn: '\u00FE',
- yuml: '\u00FF',
- OElig: '\u0152',
- oelig: '\u0153',
- Scaron: '\u0160',
- scaron: '\u0161',
- Yuml: '\u0178',
- fnof: '\u0192',
- circ: '\u02C6',
- tilde: '\u02DC',
- Alpha: '\u0391',
- Beta: '\u0392',
- Gamma: '\u0393',
- Delta: '\u0394',
- Epsilon: '\u0395',
- Zeta: '\u0396',
- Eta: '\u0397',
- Theta: '\u0398',
- Iota: '\u0399',
- Kappa: '\u039A',
- Lambda: '\u039B',
- Mu: '\u039C',
- Nu: '\u039D',
- Xi: '\u039E',
- Omicron: '\u039F',
- Pi: '\u03A0',
- Rho: '\u03A1',
- Sigma: '\u03A3',
- Tau: '\u03A4',
- Upsilon: '\u03A5',
- Phi: '\u03A6',
- Chi: '\u03A7',
- Psi: '\u03A8',
- Omega: '\u03A9',
- alpha: '\u03B1',
- beta: '\u03B2',
- gamma: '\u03B3',
- delta: '\u03B4',
- epsilon: '\u03B5',
- zeta: '\u03B6',
- eta: '\u03B7',
- theta: '\u03B8',
- iota: '\u03B9',
- kappa: '\u03BA',
- lambda: '\u03BB',
- mu: '\u03BC',
- nu: '\u03BD',
- xi: '\u03BE',
- omicron: '\u03BF',
- pi: '\u03C0',
- rho: '\u03C1',
- sigmaf: '\u03C2',
- sigma: '\u03C3',
- tau: '\u03C4',
- upsilon: '\u03C5',
- phi: '\u03C6',
- chi: '\u03C7',
- psi: '\u03C8',
- omega: '\u03C9',
- thetasym: '\u03D1',
- upsih: '\u03D2',
- piv: '\u03D6',
- ensp: '\u2002',
- emsp: '\u2003',
- thinsp: '\u2009',
- zwnj: '\u200C',
- zwj: '\u200D',
- lrm: '\u200E',
- rlm: '\u200F',
- ndash: '\u2013',
- mdash: '\u2014',
- lsquo: '\u2018',
- rsquo: '\u2019',
- sbquo: '\u201A',
- ldquo: '\u201C',
- rdquo: '\u201D',
- bdquo: '\u201E',
- dagger: '\u2020',
- Dagger: '\u2021',
- bull: '\u2022',
- hellip: '\u2026',
- permil: '\u2030',
- prime: '\u2032',
- Prime: '\u2033',
- lsaquo: '\u2039',
- rsaquo: '\u203A',
- oline: '\u203E',
- frasl: '\u2044',
- euro: '\u20AC',
- image: '\u2111',
- weierp: '\u2118',
- real: '\u211C',
- trade: '\u2122',
- alefsym: '\u2135',
- larr: '\u2190',
- uarr: '\u2191',
- rarr: '\u2192',
- darr: '\u2193',
- harr: '\u2194',
- crarr: '\u21B5',
- lArr: '\u21D0',
- uArr: '\u21D1',
- rArr: '\u21D2',
- dArr: '\u21D3',
- hArr: '\u21D4',
- forall: '\u2200',
- part: '\u2202',
- exist: '\u2203',
- empty: '\u2205',
- nabla: '\u2207',
- isin: '\u2208',
- notin: '\u2209',
- ni: '\u220B',
- prod: '\u220F',
- sum: '\u2211',
- minus: '\u2212',
- lowast: '\u2217',
- radic: '\u221A',
- prop: '\u221D',
- infin: '\u221E',
- ang: '\u2220',
- and: '\u2227',
- or: '\u2228',
- cap: '\u2229',
- cup: '\u222A',
- 'int': '\u222B',
- there4: '\u2234',
- sim: '\u223C',
- cong: '\u2245',
- asymp: '\u2248',
- ne: '\u2260',
- equiv: '\u2261',
- le: '\u2264',
- ge: '\u2265',
- sub: '\u2282',
- sup: '\u2283',
- nsub: '\u2284',
- sube: '\u2286',
- supe: '\u2287',
- oplus: '\u2295',
- otimes: '\u2297',
- perp: '\u22A5',
- sdot: '\u22C5',
- lceil: '\u2308',
- rceil: '\u2309',
- lfloor: '\u230A',
- rfloor: '\u230B',
- lang: '\u2329',
- rang: '\u232A',
- loz: '\u25CA',
- spades: '\u2660',
- clubs: '\u2663',
- hearts: '\u2665',
- diams: '\u2666'
- };
- function getQualifiedJSXName(object) {
- if (object.type === Syntax.JSXIdentifier) {
- return object.name;
- }
- if (object.type === Syntax.JSXNamespacedName) {
- return object.namespace.name + ':' + object.name.name;
- }
- /* istanbul ignore else */
- if (object.type === Syntax.JSXMemberExpression) {
- return (
- getQualifiedJSXName(object.object) + '.' +
- getQualifiedJSXName(object.property)
- );
- }
- /* istanbul ignore next */
- throwUnexpected(object);
- }
- function isJSXIdentifierStart(ch) {
- // exclude backslash (\)
- return (ch !== 92) && isIdentifierStart(ch);
- }
- function isJSXIdentifierPart(ch) {
- // exclude backslash (\) and add hyphen (-)
- return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
- }
- function scanJSXIdentifier() {
- var ch, start, value = '';
- start = index;
- while (index < length) {
- ch = source.charCodeAt(index);
- if (!isJSXIdentifierPart(ch)) {
- break;
- }
- value += source[index++];
- }
- return {
- type: Token.JSXIdentifier,
- value: value,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanJSXEntity() {
- var ch, str = '', start = index, count = 0, code;
- ch = source[index];
- assert(ch === '&', 'Entity must start with an ampersand');
- index++;
- while (index < length && count++ < 10) {
- ch = source[index++];
- if (ch === ';') {
- break;
- }
- str += ch;
- }
- // Well-formed entity (ending was found).
- if (ch === ';') {
- // Numeric entity.
- if (str[0] === '#') {
- if (str[1] === 'x') {
- code = +('0' + str.substr(1));
- } else {
- // Removing leading zeros in order to avoid treating as octal in old browsers.
- code = +str.substr(1).replace(Regex.LeadingZeros, '');
- }
- if (!isNaN(code)) {
- return String.fromCharCode(code);
- }
- /* istanbul ignore else */
- } else if (XHTMLEntities[str]) {
- return XHTMLEntities[str];
- }
- }
- // Treat non-entity sequences as regular text.
- index = start + 1;
- return '&';
- }
- function scanJSXText(stopChars) {
- var ch, str = '', start;
- start = index;
- while (index < length) {
- ch = source[index];
- if (stopChars.indexOf(ch) !== -1) {
- break;
- }
- if (ch === '&') {
- str += scanJSXEntity();
- } else {
- index++;
- if (ch === '\r' && source[index] === '\n') {
- str += ch;
- ch = source[index];
- index++;
- }
- if (isLineTerminator(ch.charCodeAt(0))) {
- ++lineNumber;
- lineStart = index;
- }
- str += ch;
- }
- }
- return {
- type: Token.JSXText,
- value: str,
- lineNumber: lineNumber,
- lineStart: lineStart,
- range: [start, index]
- };
- }
- function scanJSXStringLiteral() {
- var innerToken, quote, start;
- quote = source[index];
- assert((quote === '\'' || quote === '"'),
- 'String literal must starts with a quote');
- start = index;
- ++index;
- innerToken = scanJSXText([quote]);
- if (quote !== source[index]) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
- }
- ++index;
- innerToken.range = [start, index];
- return innerToken;
- }
- /**
- * Between JSX opening and closing tags (e.g. <foo>HERE</foo>), anything that
- * is not another JSX tag and is not an expression wrapped by {} is text.
- */
- function advanceJSXChild() {
- var ch = source.charCodeAt(index);
- // '<' 60, '>' 62, '{' 123, '}' 125
- if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
- return scanJSXText(['<', '>', '{', '}']);
- }
- return scanPunctuator();
- }
- function parseJSXIdentifier() {
- var token, marker = markerCreate();
- if (lookahead.type !== Token.JSXIdentifier) {
- throwUnexpected(lookahead);
- }
- token = lex();
- return markerApply(marker, delegate.createJSXIdentifier(token.value));
- }
- function parseJSXNamespacedName() {
- var namespace, name, marker = markerCreate();
- namespace = parseJSXIdentifier();
- expect(':');
- name = parseJSXIdentifier();
- return markerApply(marker, delegate.createJSXNamespacedName(namespace, name));
- }
- function parseJSXMemberExpression() {
- var marker = markerCreate(),
- expr = parseJSXIdentifier();
- while (match('.')) {
- lex();
- expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier()));
- }
- return expr;
- }
- function parseJSXElementName() {
- if (lookahead2().value === ':') {
- return parseJSXNamespacedName();
- }
- if (lookahead2().value === '.') {
- return parseJSXMemberExpression();
- }
- return parseJSXIdentifier();
- }
- function parseJSXAttributeName() {
- if (lookahead2().value === ':') {
- return parseJSXNamespacedName();
- }
- return parseJSXIdentifier();
- }
- function parseJSXAttributeValue() {
- var value, marker;
- if (match('{')) {
- value = parseJSXExpressionContainer();
- if (value.expression.type === Syntax.JSXEmptyExpression) {
- throwError(
- value,
- 'JSX attributes must only be assigned a non-empty ' +
- 'expression'
- );
- }
- } else if (match('<')) {
- value = parseJSXElement();
- } else if (lookahead.type === Token.JSXText) {
- marker = markerCreate();
- value = markerApply(marker, delegate.createLiteral(lex()));
- } else {
- throwError({}, Messages.InvalidJSXAttributeValue);
- }
- return value;
- }
- function parseJSXEmptyExpression() {
- var ch, marker = markerCreatePreserveWhitespace();
- while (index < length) {
- ch = source.charCodeAt(index);
- if (ch === 125) {
- break;
- } else if (isLineTerminator(ch)) {
- if (ch === 13 && source.charCodeAt(index + 1) === 10) {
- ++index;
- }
- ++lineNumber;
- lineStart = index;
- }
- ++index;
- }
- return markerApply(marker, delegate.createJSXEmptyExpression());
- }
- function parseJSXExpressionContainer() {
- var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = false;
- expect('{');
- if (match('}')) {
- expression = parseJSXEmptyExpression();
- } else {
- expression = parseExpression();
- }
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- expect('}');
- return markerApply(marker, delegate.createJSXExpressionContainer(expression));
- }
- function parseJSXSpreadAttribute() {
- var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = false;
- expect('{');
- expect('...');
- expression = parseAssignmentExpression();
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- expect('}');
- return markerApply(marker, delegate.createJSXSpreadAttribute(expression));
- }
- function parseJSXAttribute() {
- var name, marker;
- if (match('{')) {
- return parseJSXSpreadAttribute();
- }
- marker = markerCreate();
- name = parseJSXAttributeName();
- // HTML empty attribute
- if (match('=')) {
- lex();
- return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue()));
- }
- return markerApply(marker, delegate.createJSXAttribute(name));
- }
- function parseJSXChild() {
- var token, marker;
- if (match('{')) {
- token = parseJSXExpressionContainer();
- } else if (lookahead.type === Token.JSXText) {
- marker = markerCreatePreserveWhitespace();
- token = markerApply(marker, delegate.createLiteral(lex()));
- } else if (match('<')) {
- token = parseJSXElement();
- } else {
- throwUnexpected(lookahead);
- }
- return token;
- }
- function parseJSXClosingElement() {
- var name, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = true;
- expect('<');
- expect('/');
- name = parseJSXElementName();
- // Because advance() (called by lex() called by expect()) expects there
- // to be a valid token after >, it needs to know whether to look for a
- // standard JS token or an JSX text node
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- expect('>');
- return markerApply(marker, delegate.createJSXClosingElement(name));
- }
- function parseJSXOpeningElement() {
- var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- state.inJSXChild = false;
- state.inJSXTag = true;
- expect('<');
- name = parseJSXElementName();
- while (index < length &&
- lookahead.value !== '/' &&
- lookahead.value !== '>') {
- attributes.push(parseJSXAttribute());
- }
- state.inJSXTag = origInJSXTag;
- if (lookahead.value === '/') {
- expect('/');
- // Because advance() (called by lex() called by expect()) expects
- // there to be a valid token after >, it needs to know whether to
- // look for a standard JS token or an JSX text node
- state.inJSXChild = origInJSXChild;
- expect('>');
- selfClosing = true;
- } else {
- state.inJSXChild = true;
- expect('>');
- }
- return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing));
- }
- function parseJSXElement() {
- var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate();
- origInJSXChild = state.inJSXChild;
- origInJSXTag = state.inJSXTag;
- openingElement = parseJSXOpeningElement();
- if (!openingElement.selfClosing) {
- while (index < length) {
- state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because </ should not be considered in the child
- if (lookahead.value === '<' && lookahead2().value === '/') {
- break;
- }
- state.inJSXChild = true;
- children.push(parseJSXChild());
- }
- state.inJSXChild = origInJSXChild;
- state.inJSXTag = origInJSXTag;
- closingElement = parseJSXClosingElement();
- if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
- throwError({}, Messages.ExpectedJSXClosingTag, getQualifiedJSXName(openingElement.name));
- }
- }
- // When (erroneously) writing two adjacent tags like
- //
- // var x = <div>one</div><div>two</div>;
- //
- // the default error message is a bit incomprehensible. Since it's
- // rarely (never?) useful to write a less-than sign after an JSX
- // element, we disallow it here in the parser in order to provide a
- // better error message. (In the rare case that the less-than operator
- // was intended, the left tag can be wrapped in parentheses.)
- if (!origInJSXChild && match('<')) {
- throwError(lookahead, Messages.AdjacentJSXElements);
- }
- return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children));
- }
- function parseTypeAlias() {
- var id, marker = markerCreate(), typeParameters = null, right;
- expectContextualKeyword('type');
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('=');
- right = parseType();
- consumeSemicolon();
- return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
- }
- function parseInterfaceExtends() {
- var marker = markerCreate(), id, typeParameters = null;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterInstantiation();
- }
- return markerApply(marker, delegate.createInterfaceExtends(
- id,
- typeParameters
- ));
- }
- function parseInterfaceish(marker, allowStatic) {
- var body, bodyMarker, extended = [], id,
- typeParameters = null;
- id = parseVariableIdentifier();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- if (matchKeyword('extends')) {
- expectKeyword('extends');
- while (index < length) {
- extended.push(parseInterfaceExtends());
- if (!match(',')) {
- break;
- }
- expect(',');
- }
- }
- bodyMarker = markerCreate();
- body = markerApply(bodyMarker, parseObjectType(allowStatic));
- return markerApply(marker, delegate.createInterface(
- id,
- typeParameters,
- body,
- extended
- ));
- }
- function parseInterface() {
- var marker = markerCreate();
- if (strict) {
- expectKeyword('interface');
- } else {
- expectContextualKeyword('interface');
- }
- return parseInterfaceish(marker, /* allowStatic */false);
- }
- function parseDeclareClass() {
- var marker = markerCreate(), ret;
- expectContextualKeyword('declare');
- expectKeyword('class');
- ret = parseInterfaceish(marker, /* allowStatic */true);
- ret.type = Syntax.DeclareClass;
- return ret;
- }
- function parseDeclareFunction() {
- var id, idMarker,
- marker = markerCreate(), params, returnType, rest, tmp,
- typeParameters = null, value, valueMarker;
- expectContextualKeyword('declare');
- expectKeyword('function');
- idMarker = markerCreate();
- id = parseVariableIdentifier();
- valueMarker = markerCreate();
- if (match('<')) {
- typeParameters = parseTypeParameterDeclaration();
- }
- expect('(');
- tmp = parseFunctionTypeParams();
- params = tmp.params;
- rest = tmp.rest;
- expect(')');
- expect(':');
- returnType = parseType();
- value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
- params,
- returnType,
- rest,
- typeParameters
- ));
- id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
- value
- ));
- markerApply(idMarker, id);
- consumeSemicolon();
- return markerApply(marker, delegate.createDeclareFunction(
- id
- ));
- }
- function parseDeclareVariable() {
- var id, marker = markerCreate();
- expectContextualKeyword('declare');
- expectKeyword('var');
- id = parseTypeAnnotatableIdentifier();
- consumeSemicolon();
- return markerApply(marker, delegate.createDeclareVariable(
- id
- ));
- }
- function parseDeclareModule() {
- var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
- expectContextualKeyword('declare');
- expectContextualKeyword('module');
- if (lookahead.type === Token.StringLiteral) {
- if (strict && lookahead.octal) {
- throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
- }
- idMarker = markerCreate();
- id = markerApply(idMarker, delegate.createLiteral(lex()));
- } else {
- id = parseVariableIdentifier();
- }
- bodyMarker = markerCreate();
- expect('{');
- while (index < length && !match('}')) {
- token = lookahead2();
- switch (token.value) {
- case 'class':
- body.push(parseDeclareClass());
- break;
- case 'function':
- body.push(parseDeclareFunction());
- break;
- case 'var':
- body.push(parseDeclareVariable());
- break;
- default:
- throwUnexpected(lookahead);
- }
- }
- expect('}');
- return markerApply(marker, delegate.createDeclareModule(
- id,
- markerApply(bodyMarker, delegate.createBlockStatement(body))
- ));
- }
- function collectToken() {
- var loc, token, range, value, entry;
- /* istanbul ignore else */
- if (!state.inJSXChild) {
- skipComment();
- }
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- token = extra.advance();
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- if (token.type !== Token.EOF) {
- range = [token.range[0], token.range[1]];
- value = source.slice(token.range[0], token.range[1]);
- entry = {
- type: TokenName[token.type],
- value: value,
- range: range,
- loc: loc
- };
- if (token.regex) {
- entry.regex = {
- pattern: token.regex.pattern,
- flags: token.regex.flags
- };
- }
- extra.tokens.push(entry);
- }
- return token;
- }
- function collectRegex() {
- var pos, loc, regex, token;
- skipComment();
- pos = index;
- loc = {
- start: {
- line: lineNumber,
- column: index - lineStart
- }
- };
- regex = extra.scanRegExp();
- loc.end = {
- line: lineNumber,
- column: index - lineStart
- };
- if (!extra.tokenize) {
- /* istanbul ignore next */
- // Pop the previous token, which is likely '/' or '/='
- if (extra.tokens.length > 0) {
- token = extra.tokens[extra.tokens.length - 1];
- if (token.range[0] === pos && token.type === 'Punctuator') {
- if (token.value === '/' || token.value === '/=') {
- extra.tokens.pop();
- }
- }
- }
- extra.tokens.push({
- type: 'RegularExpression',
- value: regex.literal,
- regex: regex.regex,
- range: [pos, index],
- loc: loc
- });
- }
- return regex;
- }
- function filterTokenLocation() {
- var i, entry, token, tokens = [];
- for (i = 0; i < extra.tokens.length; ++i) {
- entry = extra.tokens[i];
- token = {
- type: entry.type,
- value: entry.value
- };
- if (entry.regex) {
- token.regex = {
- pattern: entry.regex.pattern,
- flags: entry.regex.flags
- };
- }
- if (extra.range) {
- token.range = entry.range;
- }
- if (extra.loc) {
- token.loc = entry.loc;
- }
- tokens.push(token);
- }
- extra.tokens = tokens;
- }
- function patch() {
- if (typeof extra.tokens !== 'undefined') {
- extra.advance = advance;
- extra.scanRegExp = scanRegExp;
- advance = collectToken;
- scanRegExp = collectRegex;
- }
- }
- function unpatch() {
- if (typeof extra.scanRegExp === 'function') {
- advance = extra.advance;
- scanRegExp = extra.scanRegExp;
- }
- }
- // This is used to modify the delegate.
- function extend(object, properties) {
- var entry, result = {};
- for (entry in object) {
- /* istanbul ignore else */
- if (object.hasOwnProperty(entry)) {
- result[entry] = object[entry];
- }
- }
- for (entry in properties) {
- /* istanbul ignore else */
- if (properties.hasOwnProperty(entry)) {
- result[entry] = properties[entry];
- }
- }
- return result;
- }
- function tokenize(code, options) {
- var toString,
- token,
- tokens;
- toString = String;
- if (typeof code !== 'string' && !(code instanceof String)) {
- code = toString(code);
- }
- delegate = SyntaxTreeDelegate;
- source = code;
- index = 0;
- lineNumber = (source.length > 0) ? 1 : 0;
- lineStart = 0;
- length = source.length;
- lookahead = null;
- state = {
- allowKeyword: true,
- allowIn: true,
- labelSet: new StringMap(),
- inFunctionBody: false,
- inIteration: false,
- inSwitch: false,
- lastCommentStart: -1,
- curlyStack: [],
- curlyLastIndex: 0
- };
- extra = {};
- // Options matching.
- options = options || {};
- // Of course we collect tokens here.
- options.tokens = true;
- extra.tokens = [];
- extra.tokenize = true;
- // The following two fields are necessary to compute the Regex tokens.
- extra.openParenToken = -1;
- extra.openCurlyToken = -1;
- extra.range = (typeof options.range === 'boolean') && options.range;
- extra.loc = (typeof options.loc === 'boolean') && options.loc;
- if (typeof options.comment === 'boolean' && options.comment) {
- extra.comments = [];
- }
- if (typeof options.tolerant === 'boolean' && options.tolerant) {
- extra.errors = [];
- }
- patch();
- try {
- peek();
- if (lookahead.type === Token.EOF) {
- return extra.tokens;
- }
- token = lex();
- while (lookahead.type !== Token.EOF) {
- try {
- token = lex();
- } catch (lexError) {
- token = lookahead;
- if (extra.errors) {
- extra.errors.push(lexError);
- // We have to break on the first error
- // to avoid infinite loops.
- break;
- } else {
- throw lexError;
- }
- }
- }
- filterTokenLocation();
- tokens = extra.tokens;
- if (typeof extra.comments !== 'undefined') {
- tokens.comments = extra.comments;
- }
- if (typeof extra.errors !== 'undefined') {
- tokens.errors = extra.errors;
- }
- } catch (e) {
- throw e;
- } finally {
- unpatch();
- extra = {};
- }
- return tokens;
- }
- function parse(code, options) {
- var program, toString;
- toString = String;
- if (typeof code !== 'string' && !(code instanceof String)) {
- code = toString(code);
- }
- delegate = SyntaxTreeDelegate;
- source = code;
- index = 0;
- lineNumber = (source.length > 0) ? 1 : 0;
- lineStart = 0;
- length = source.length;
- lookahead = null;
- state = {
- allowKeyword: false,
- allowIn: true,
- labelSet: new StringMap(),
- parenthesizedCount: 0,
- inFunctionBody: false,
- inIteration: false,
- inSwitch: false,
- inJSXChild: false,
- inJSXTag: false,
- inType: false,
- lastCommentStart: -1,
- yieldAllowed: false,
- awaitAllowed: false,
- curlyPosition: 0,
- curlyStack: [],
- curlyLastIndex: 0
- };
- extra = {};
- if (typeof options !== 'undefined') {
- extra.range = (typeof options.range === 'boolean') && options.range;
- extra.loc = (typeof options.loc === 'boolean') && options.loc;
- extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
- if (extra.loc && options.source !== null && options.source !== undefined) {
- delegate = extend(delegate, {
- 'postProcess': function (node) {
- node.loc.source = toString(options.source);
- return node;
- }
- });
- }
- extra.sourceType = options.sourceType;
- if (typeof options.tokens === 'boolean' && options.tokens) {
- extra.tokens = [];
- }
- if (typeof options.comment === 'boolean' && options.comment) {
- extra.comments = [];
- }
- if (typeof options.tolerant === 'boolean' && options.tolerant) {
- extra.errors = [];
- }
- if (extra.attachComment) {
- extra.range = true;
- extra.comments = [];
- extra.bottomRightStack = [];
- extra.trailingComments = [];
- extra.leadingComments = [];
- }
- }
- patch();
- try {
- program = parseProgram();
- if (typeof extra.comments !== 'undefined') {
- program.comments = extra.comments;
- }
- if (typeof extra.tokens !== 'undefined') {
- filterTokenLocation();
- program.tokens = extra.tokens;
- }
- if (typeof extra.errors !== 'undefined') {
- program.errors = extra.errors;
- }
- } catch (e) {
- throw e;
- } finally {
- unpatch();
- extra = {};
- }
- return program;
- }
- // Sync with *.json manifests.
- exports.version = '14001.1.0-dev-harmony-fb';
- exports.tokenize = tokenize;
- exports.parse = parse;
- // Deep copy.
- /* istanbul ignore next */
- exports.Syntax = (function () {
- var name, types = {};
- if (typeof Object.create === 'function') {
- types = Object.create(null);
- }
- for (name in Syntax) {
- if (Syntax.hasOwnProperty(name)) {
- types[name] = Syntax[name];
- }
- }
- if (typeof Object.freeze === 'function') {
- Object.freeze(types);
- }
- return types;
- }());
- }));
- /* vim: set sw=4 ts=4 et tw=80 : */
- },{}],471:[function(require,module,exports){
- (function (process){
- var Stream = require('stream')
- // through
- //
- // a stream that does nothing but re-emit the input.
- // useful for aggregating a series of changing but not ending streams into one stream)
- exports = module.exports = through
- through.through = through
- //create a readable writable stream.
- function through (write, end, opts) {
- write = write || function (data) { this.queue(data) }
- end = end || function () { this.queue(null) }
- var ended = false, destroyed = false, buffer = [], _ended = false
- var stream = new Stream()
- stream.readable = stream.writable = true
- stream.paused = false
- // stream.autoPause = !(opts && opts.autoPause === false)
- stream.autoDestroy = !(opts && opts.autoDestroy === false)
- stream.write = function (data) {
- write.call(this, data)
- return !stream.paused
- }
- function drain() {
- while(buffer.length && !stream.paused) {
- var data = buffer.shift()
- if(null === data)
- return stream.emit('end')
- else
- stream.emit('data', data)
- }
- }
- stream.queue = stream.push = function (data) {
- // console.error(ended)
- if(_ended) return stream
- if(data === null) _ended = true
- buffer.push(data)
- drain()
- return stream
- }
- //this will be registered as the first 'end' listener
- //must call destroy next tick, to make sure we're after any
- //stream piped from here.
- //this is only a problem if end is not emitted synchronously.
- //a nicer way to do this is to make sure this is the last listener for 'end'
- stream.on('end', function () {
- stream.readable = false
- if(!stream.writable && stream.autoDestroy)
- process.nextTick(function () {
- stream.destroy()
- })
- })
- function _end () {
- stream.writable = false
- end.call(stream)
- if(!stream.readable && stream.autoDestroy)
- stream.destroy()
- }
- stream.end = function (data) {
- if(ended) return
- ended = true
- if(arguments.length) stream.write(data)
- _end() // will emit or queue
- return stream
- }
- stream.destroy = function () {
- if(destroyed) return
- destroyed = true
- ended = true
- buffer.length = 0
- stream.writable = stream.readable = false
- stream.emit('close')
- return stream
- }
- stream.pause = function () {
- if(stream.paused) return
- stream.paused = true
- return stream
- }
- stream.resume = function () {
- if(stream.paused) {
- stream.paused = false
- stream.emit('resume')
- }
- drain()
- //may have become paused again,
- //as drain emits 'data'.
- if(!stream.paused)
- stream.emit('drain')
- return stream
- }
- return stream
- }
- }).call(this,require('_process'))
- },{"_process":200,"stream":212}],472:[function(require,module,exports){
- (function (global){
- /**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- !(function(global) {
- "use strict";
- var hasOwn = Object.prototype.hasOwnProperty;
- var undefined; // More compressible than void 0.
- var iteratorSymbol =
- typeof Symbol === "function" && Symbol.iterator || "@@iterator";
- var inModule = typeof module === "object";
- var runtime = global.regeneratorRuntime;
- if (runtime) {
- if (inModule) {
- // If regeneratorRuntime is defined globally and we're in a module,
- // make the exports object identical to regeneratorRuntime.
- module.exports = runtime;
- }
- // Don't bother evaluating the rest of this file if the runtime was
- // already defined globally.
- return;
- }
- // Define the runtime globally (as expected by generated code) as either
- // module.exports (if we're in a module) or a new, empty object.
- runtime = global.regeneratorRuntime = inModule ? module.exports : {};
- function wrap(innerFn, outerFn, self, tryLocsList) {
- // If outerFn provided, then outerFn.prototype instanceof Generator.
- var generator = Object.create((outerFn || Generator).prototype);
- generator._invoke = makeInvokeMethod(
- innerFn, self || null,
- new Context(tryLocsList || [])
- );
- return generator;
- }
- runtime.wrap = wrap;
- // Try/catch helper to minimize deoptimizations. Returns a completion
- // record like context.tryEntries[i].completion. This interface could
- // have been (and was previously) designed to take a closure to be
- // invoked without arguments, but in all the cases we care about we
- // already have an existing method we want to call, so there's no need
- // to create a new function object. We can even get away with assuming
- // the method takes exactly one argument, since that happens to be true
- // in every case, so we don't have to touch the arguments object. The
- // only additional allocation required is the completion record, which
- // has a stable shape and so hopefully should be cheap to allocate.
- function tryCatch(fn, obj, arg) {
- try {
- return { type: "normal", arg: fn.call(obj, arg) };
- } catch (err) {
- return { type: "throw", arg: err };
- }
- }
- var GenStateSuspendedStart = "suspendedStart";
- var GenStateSuspendedYield = "suspendedYield";
- var GenStateExecuting = "executing";
- var GenStateCompleted = "completed";
- // Returning this object from the innerFn has the same effect as
- // breaking out of the dispatch switch statement.
- var ContinueSentinel = {};
- // Dummy constructor functions that we use as the .constructor and
- // .constructor.prototype properties for functions that return Generator
- // objects. For full spec compliance, you may wish to configure your
- // minifier not to mangle the names of these two functions.
- function Generator() {}
- function GeneratorFunction() {}
- function GeneratorFunctionPrototype() {}
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
- GeneratorFunction.displayName = "GeneratorFunction";
- runtime.isGeneratorFunction = function(genFun) {
- var ctor = typeof genFun === "function" && genFun.constructor;
- return ctor
- ? ctor === GeneratorFunction ||
- // For the native GeneratorFunction constructor, the best we can
- // do is to check its .name property.
- (ctor.displayName || ctor.name) === "GeneratorFunction"
- : false;
- };
- runtime.mark = function(genFun) {
- genFun.__proto__ = GeneratorFunctionPrototype;
- genFun.prototype = Object.create(Gp);
- return genFun;
- };
- runtime.async = function(innerFn, outerFn, self, tryLocsList) {
- return new Promise(function(resolve, reject) {
- var generator = wrap(innerFn, outerFn, self, tryLocsList);
- var callNext = step.bind(generator, "next");
- var callThrow = step.bind(generator, "throw");
- function step(method, arg) {
- var record = tryCatch(generator[method], generator, arg);
- if (record.type === "throw") {
- reject(record.arg);
- return;
- }
- var info = record.arg;
- if (info.done) {
- resolve(info.value);
- } else {
- Promise.resolve(info.value).then(callNext, callThrow);
- }
- }
- callNext();
- });
- };
- function makeInvokeMethod(innerFn, self, context) {
- var state = GenStateSuspendedStart;
- return function invoke(method, arg) {
- if (state === GenStateExecuting) {
- throw new Error("Generator is already running");
- }
- if (state === GenStateCompleted) {
- // Be forgiving, per 25.3.3.3.3 of the spec:
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
- return doneResult();
- }
- while (true) {
- var delegate = context.delegate;
- if (delegate) {
- if (method === "return" ||
- (method === "throw" && delegate.iterator[method] === undefined)) {
- // A return or throw (when the delegate iterator has no throw
- // method) always terminates the yield* loop.
- context.delegate = null;
- // If the delegate iterator has a return method, give it a
- // chance to clean up.
- var returnMethod = delegate.iterator["return"];
- if (returnMethod) {
- var record = tryCatch(returnMethod, delegate.iterator, arg);
- if (record.type === "throw") {
- // If the return method threw an exception, let that
- // exception prevail over the original return or throw.
- method = "throw";
- arg = record.arg;
- continue;
- }
- }
- if (method === "return") {
- // Continue with the outer return, now that the delegate
- // iterator has been terminated.
- continue;
- }
- }
- var record = tryCatch(
- delegate.iterator[method],
- delegate.iterator,
- arg
- );
- if (record.type === "throw") {
- context.delegate = null;
- // Like returning generator.throw(uncaught), but without the
- // overhead of an extra function call.
- method = "throw";
- arg = record.arg;
- continue;
- }
- // Delegate generator ran and handled its own exceptions so
- // regardless of what the method was, we continue as if it is
- // "next" with an undefined arg.
- method = "next";
- arg = undefined;
- var info = record.arg;
- if (info.done) {
- context[delegate.resultName] = info.value;
- context.next = delegate.nextLoc;
- } else {
- state = GenStateSuspendedYield;
- return info;
- }
- context.delegate = null;
- }
- if (method === "next") {
- if (state === GenStateSuspendedYield) {
- context.sent = arg;
- } else {
- delete context.sent;
- }
- } else if (method === "throw") {
- if (state === GenStateSuspendedStart) {
- state = GenStateCompleted;
- throw arg;
- }
- if (context.dispatchException(arg)) {
- // If the dispatched exception was caught by a catch block,
- // then let that catch block handle the exception normally.
- method = "next";
- arg = undefined;
- }
- } else if (method === "return") {
- context.abrupt("return", arg);
- }
- state = GenStateExecuting;
- var record = tryCatch(innerFn, self, context);
- if (record.type === "normal") {
- // If an exception is thrown from innerFn, we leave state ===
- // GenStateExecuting and loop back for another invocation.
- state = context.done
- ? GenStateCompleted
- : GenStateSuspendedYield;
- var info = {
- value: record.arg,
- done: context.done
- };
- if (record.arg === ContinueSentinel) {
- if (context.delegate && method === "next") {
- // Deliberately forget the last sent value so that we don't
- // accidentally pass it on to the delegate.
- arg = undefined;
- }
- } else {
- return info;
- }
- } else if (record.type === "throw") {
- state = GenStateCompleted;
- // Dispatch the exception by looping back around to the
- // context.dispatchException(arg) call above.
- method = "throw";
- arg = record.arg;
- }
- }
- };
- }
- function defineGeneratorMethod(method) {
- Gp[method] = function(arg) {
- return this._invoke(method, arg);
- };
- }
- defineGeneratorMethod("next");
- defineGeneratorMethod("throw");
- defineGeneratorMethod("return");
- Gp[iteratorSymbol] = function() {
- return this;
- };
- Gp.toString = function() {
- return "[object Generator]";
- };
- function pushTryEntry(locs) {
- var entry = { tryLoc: locs[0] };
- if (1 in locs) {
- entry.catchLoc = locs[1];
- }
- if (2 in locs) {
- entry.finallyLoc = locs[2];
- entry.afterLoc = locs[3];
- }
- this.tryEntries.push(entry);
- }
- function resetTryEntry(entry) {
- var record = entry.completion || {};
- record.type = "normal";
- delete record.arg;
- entry.completion = record;
- }
- function Context(tryLocsList) {
- // The root entry object (effectively a try statement without a catch
- // or a finally block) gives us a place to store values thrown from
- // locations where there is no enclosing try statement.
- this.tryEntries = [{ tryLoc: "root" }];
- tryLocsList.forEach(pushTryEntry, this);
- this.reset();
- }
- runtime.keys = function(object) {
- var keys = [];
- for (var key in object) {
- keys.push(key);
- }
- keys.reverse();
- // Rather than returning an object with a next method, we keep
- // things simple and return the next function itself.
- return function next() {
- while (keys.length) {
- var key = keys.pop();
- if (key in object) {
- next.value = key;
- next.done = false;
- return next;
- }
- }
- // To avoid creating an additional object, we just hang the .value
- // and .done properties off the next function object itself. This
- // also ensures that the minifier will not anonymize the function.
- next.done = true;
- return next;
- };
- };
- function values(iterable) {
- if (iterable) {
- var iteratorMethod = iterable[iteratorSymbol];
- if (iteratorMethod) {
- return iteratorMethod.call(iterable);
- }
- if (typeof iterable.next === "function") {
- return iterable;
- }
- if (!isNaN(iterable.length)) {
- var i = -1, next = function next() {
- while (++i < iterable.length) {
- if (hasOwn.call(iterable, i)) {
- next.value = iterable[i];
- next.done = false;
- return next;
- }
- }
- next.value = undefined;
- next.done = true;
- return next;
- };
- return next.next = next;
- }
- }
- // Return an iterator with no values.
- return { next: doneResult };
- }
- runtime.values = values;
- function doneResult() {
- return { value: undefined, done: true };
- }
- Context.prototype = {
- constructor: Context,
- reset: function() {
- this.prev = 0;
- this.next = 0;
- this.sent = undefined;
- this.done = false;
- this.delegate = null;
- this.tryEntries.forEach(resetTryEntry);
- // Pre-initialize at least 20 temporary variables to enable hidden
- // class optimizations for simple generators.
- for (var tempIndex = 0, tempName;
- hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20;
- ++tempIndex) {
- this[tempName] = null;
- }
- },
- stop: function() {
- this.done = true;
- var rootEntry = this.tryEntries[0];
- var rootRecord = rootEntry.completion;
- if (rootRecord.type === "throw") {
- throw rootRecord.arg;
- }
- return this.rval;
- },
- dispatchException: function(exception) {
- if (this.done) {
- throw exception;
- }
- var context = this;
- function handle(loc, caught) {
- record.type = "throw";
- record.arg = exception;
- context.next = loc;
- return !!caught;
- }
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- var record = entry.completion;
- if (entry.tryLoc === "root") {
- // Exception thrown outside of any try block that could handle
- // it, so set the completion value of the entire function to
- // throw the exception.
- return handle("end");
- }
- if (entry.tryLoc <= this.prev) {
- var hasCatch = hasOwn.call(entry, "catchLoc");
- var hasFinally = hasOwn.call(entry, "finallyLoc");
- if (hasCatch && hasFinally) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- } else if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else if (hasCatch) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- }
- } else if (hasFinally) {
- if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else {
- throw new Error("try statement without catch or finally");
- }
- }
- }
- },
- abrupt: function(type, arg) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc) {
- var finallyEntry = entry;
- break;
- }
- }
- if (finallyEntry &&
- (type === "break" ||
- type === "continue") &&
- finallyEntry.tryLoc <= arg &&
- arg <= finallyEntry.finallyLoc) {
- // Ignore the finally entry if control is not jumping to a
- // location outside the try/catch block.
- finallyEntry = null;
- }
- var record = finallyEntry ? finallyEntry.completion : {};
- record.type = type;
- record.arg = arg;
- if (finallyEntry) {
- this.next = finallyEntry.finallyLoc;
- } else {
- this.complete(record);
- }
- return ContinueSentinel;
- },
- complete: function(record, afterLoc) {
- if (record.type === "throw") {
- throw record.arg;
- }
- if (record.type === "break" ||
- record.type === "continue") {
- this.next = record.arg;
- } else if (record.type === "return") {
- this.rval = record.arg;
- this.next = "end";
- } else if (record.type === "normal" && afterLoc) {
- this.next = afterLoc;
- }
- return ContinueSentinel;
- },
- finish: function(finallyLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.finallyLoc === finallyLoc) {
- return this.complete(entry.completion, entry.afterLoc);
- }
- }
- },
- "catch": function(tryLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc === tryLoc) {
- var record = entry.completion;
- if (record.type === "throw") {
- var thrown = record.arg;
- resetTryEntry(entry);
- }
- return thrown;
- }
- }
- // The context.catch method must only be called with a location
- // argument that corresponds to a known catch block.
- throw new Error("illegal catch attempt");
- },
- delegateYield: function(iterable, resultName, nextLoc) {
- this.delegate = {
- iterator: values(iterable),
- resultName: resultName,
- nextLoc: nextLoc
- };
- return ContinueSentinel;
- }
- };
- })(
- // Among the various tricks for obtaining a reference to the global
- // object, this seems to be the most reliable technique that does not
- // use indirect eval (which violates Content Security Policy).
- typeof global === "object" ? global :
- typeof window === "object" ? window :
- typeof self === "object" ? self : this
- );
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{}],473:[function(require,module,exports){
- // Generated by `/scripts/character-class-escape-sets.js`. Do not edit.
- var regenerate = require('regenerate');
- exports.REGULAR = {
- 'd': regenerate()
- .addRange(0x30, 0x39),
- 'D': regenerate()
- .addRange(0x0, 0x2F)
- .addRange(0x3A, 0xFFFF),
- 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF)
- .addRange(0x9, 0xD)
- .addRange(0x2000, 0x200A)
- .addRange(0x2028, 0x2029),
- 'S': regenerate()
- .addRange(0x0, 0x8)
- .addRange(0xE, 0x1F)
- .addRange(0x21, 0x9F)
- .addRange(0xA1, 0x167F)
- .addRange(0x1681, 0x180D)
- .addRange(0x180F, 0x1FFF)
- .addRange(0x200B, 0x2027)
- .addRange(0x202A, 0x202E)
- .addRange(0x2030, 0x205E)
- .addRange(0x2060, 0x2FFF)
- .addRange(0x3001, 0xFEFE)
- .addRange(0xFF00, 0xFFFF),
- 'w': regenerate(0x5F)
- .addRange(0x30, 0x39)
- .addRange(0x41, 0x5A)
- .addRange(0x61, 0x7A),
- 'W': regenerate(0x60)
- .addRange(0x0, 0x2F)
- .addRange(0x3A, 0x40)
- .addRange(0x5B, 0x5E)
- .addRange(0x7B, 0xFFFF)
- };
- exports.UNICODE = {
- 'd': regenerate()
- .addRange(0x30, 0x39),
- 'D': regenerate()
- .addRange(0x0, 0x2F)
- .addRange(0x3A, 0x10FFFF),
- 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF)
- .addRange(0x9, 0xD)
- .addRange(0x2000, 0x200A)
- .addRange(0x2028, 0x2029),
- 'S': regenerate()
- .addRange(0x0, 0x8)
- .addRange(0xE, 0x1F)
- .addRange(0x21, 0x9F)
- .addRange(0xA1, 0x167F)
- .addRange(0x1681, 0x180D)
- .addRange(0x180F, 0x1FFF)
- .addRange(0x200B, 0x2027)
- .addRange(0x202A, 0x202E)
- .addRange(0x2030, 0x205E)
- .addRange(0x2060, 0x2FFF)
- .addRange(0x3001, 0xFEFE)
- .addRange(0xFF00, 0x10FFFF),
- 'w': regenerate(0x5F)
- .addRange(0x30, 0x39)
- .addRange(0x41, 0x5A)
- .addRange(0x61, 0x7A),
- 'W': regenerate(0x60)
- .addRange(0x0, 0x2F)
- .addRange(0x3A, 0x40)
- .addRange(0x5B, 0x5E)
- .addRange(0x7B, 0x10FFFF)
- };
- exports.UNICODE_IGNORE_CASE = {
- 'd': regenerate()
- .addRange(0x30, 0x39),
- 'D': regenerate()
- .addRange(0x0, 0x2F)
- .addRange(0x3A, 0x10FFFF),
- 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF)
- .addRange(0x9, 0xD)
- .addRange(0x2000, 0x200A)
- .addRange(0x2028, 0x2029),
- 'S': regenerate()
- .addRange(0x0, 0x8)
- .addRange(0xE, 0x1F)
- .addRange(0x21, 0x9F)
- .addRange(0xA1, 0x167F)
- .addRange(0x1681, 0x180D)
- .addRange(0x180F, 0x1FFF)
- .addRange(0x200B, 0x2027)
- .addRange(0x202A, 0x202E)
- .addRange(0x2030, 0x205E)
- .addRange(0x2060, 0x2FFF)
- .addRange(0x3001, 0xFEFE)
- .addRange(0xFF00, 0x10FFFF),
- 'w': regenerate(0x5F, 0x17F, 0x212A)
- .addRange(0x30, 0x39)
- .addRange(0x41, 0x5A)
- .addRange(0x61, 0x7A),
- 'W': regenerate(0x4B, 0x53, 0x60)
- .addRange(0x0, 0x2F)
- .addRange(0x3A, 0x40)
- .addRange(0x5B, 0x5E)
- .addRange(0x7B, 0x10FFFF)
- };
- },{"regenerate":475}],474:[function(require,module,exports){
- module.exports={
- "75": 8490,
- "83": 383,
- "107": 8490,
- "115": 383,
- "181": 924,
- "197": 8491,
- "383": 83,
- "452": 453,
- "453": 452,
- "455": 456,
- "456": 455,
- "458": 459,
- "459": 458,
- "497": 498,
- "498": 497,
- "837": 8126,
- "914": 976,
- "917": 1013,
- "920": 1012,
- "921": 8126,
- "922": 1008,
- "924": 181,
- "928": 982,
- "929": 1009,
- "931": 962,
- "934": 981,
- "937": 8486,
- "962": 931,
- "976": 914,
- "977": 1012,
- "981": 934,
- "982": 928,
- "1008": 922,
- "1009": 929,
- "1012": [
- 920,
- 977
- ],
- "1013": 917,
- "7776": 7835,
- "7835": 7776,
- "8126": [
- 837,
- 921
- ],
- "8486": 937,
- "8490": 75,
- "8491": 197,
- "66560": 66600,
- "66561": 66601,
- "66562": 66602,
- "66563": 66603,
- "66564": 66604,
- "66565": 66605,
- "66566": 66606,
- "66567": 66607,
- "66568": 66608,
- "66569": 66609,
- "66570": 66610,
- "66571": 66611,
- "66572": 66612,
- "66573": 66613,
- "66574": 66614,
- "66575": 66615,
- "66576": 66616,
- "66577": 66617,
- "66578": 66618,
- "66579": 66619,
- "66580": 66620,
- "66581": 66621,
- "66582": 66622,
- "66583": 66623,
- "66584": 66624,
- "66585": 66625,
- "66586": 66626,
- "66587": 66627,
- "66588": 66628,
- "66589": 66629,
- "66590": 66630,
- "66591": 66631,
- "66592": 66632,
- "66593": 66633,
- "66594": 66634,
- "66595": 66635,
- "66596": 66636,
- "66597": 66637,
- "66598": 66638,
- "66599": 66639,
- "66600": 66560,
- "66601": 66561,
- "66602": 66562,
- "66603": 66563,
- "66604": 66564,
- "66605": 66565,
- "66606": 66566,
- "66607": 66567,
- "66608": 66568,
- "66609": 66569,
- "66610": 66570,
- "66611": 66571,
- "66612": 66572,
- "66613": 66573,
- "66614": 66574,
- "66615": 66575,
- "66616": 66576,
- "66617": 66577,
- "66618": 66578,
- "66619": 66579,
- "66620": 66580,
- "66621": 66581,
- "66622": 66582,
- "66623": 66583,
- "66624": 66584,
- "66625": 66585,
- "66626": 66586,
- "66627": 66587,
- "66628": 66588,
- "66629": 66589,
- "66630": 66590,
- "66631": 66591,
- "66632": 66592,
- "66633": 66593,
- "66634": 66594,
- "66635": 66595,
- "66636": 66596,
- "66637": 66597,
- "66638": 66598,
- "66639": 66599,
- "71840": 71872,
- "71841": 71873,
- "71842": 71874,
- "71843": 71875,
- "71844": 71876,
- "71845": 71877,
- "71846": 71878,
- "71847": 71879,
- "71848": 71880,
- "71849": 71881,
- "71850": 71882,
- "71851": 71883,
- "71852": 71884,
- "71853": 71885,
- "71854": 71886,
- "71855": 71887,
- "71856": 71888,
- "71857": 71889,
- "71858": 71890,
- "71859": 71891,
- "71860": 71892,
- "71861": 71893,
- "71862": 71894,
- "71863": 71895,
- "71864": 71896,
- "71865": 71897,
- "71866": 71898,
- "71867": 71899,
- "71868": 71900,
- "71869": 71901,
- "71870": 71902,
- "71871": 71903,
- "71872": 71840,
- "71873": 71841,
- "71874": 71842,
- "71875": 71843,
- "71876": 71844,
- "71877": 71845,
- "71878": 71846,
- "71879": 71847,
- "71880": 71848,
- "71881": 71849,
- "71882": 71850,
- "71883": 71851,
- "71884": 71852,
- "71885": 71853,
- "71886": 71854,
- "71887": 71855,
- "71888": 71856,
- "71889": 71857,
- "71890": 71858,
- "71891": 71859,
- "71892": 71860,
- "71893": 71861,
- "71894": 71862,
- "71895": 71863,
- "71896": 71864,
- "71897": 71865,
- "71898": 71866,
- "71899": 71867,
- "71900": 71868,
- "71901": 71869,
- "71902": 71870,
- "71903": 71871
- }
- },{}],475:[function(require,module,exports){
- (function (global){
- /*! https://mths.be/regenerate v1.2.0 by @mathias | MIT license */
- ;(function(root) {
- // Detect free variables `exports`.
- var freeExports = typeof exports == 'object' && exports;
- // Detect free variable `module`.
- var freeModule = typeof module == 'object' && module &&
- module.exports == freeExports && module;
- // Detect free variable `global`, from Node.js or Browserified code,
- // and use it as `root`.
- var freeGlobal = typeof global == 'object' && global;
- if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
- root = freeGlobal;
- }
- /*--------------------------------------------------------------------------*/
- var ERRORS = {
- 'rangeOrder': 'A range\u2019s `stop` value must be greater than or equal ' +
- 'to the `start` value.',
- 'codePointRange': 'Invalid code point value. Code points range from ' +
- 'U+000000 to U+10FFFF.'
- };
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-pairs
- var HIGH_SURROGATE_MIN = 0xD800;
- var HIGH_SURROGATE_MAX = 0xDBFF;
- var LOW_SURROGATE_MIN = 0xDC00;
- var LOW_SURROGATE_MAX = 0xDFFF;
- // In Regenerate output, `\0` will never be preceded by `\` because we sort
- // by code point value, so let’s keep this regular expression simple.
- var regexNull = /\\x00([^0123456789]|$)/g;
- var object = {};
- var hasOwnProperty = object.hasOwnProperty;
- var extend = function(destination, source) {
- var key;
- for (key in source) {
- if (hasOwnProperty.call(source, key)) {
- destination[key] = source[key];
- }
- }
- return destination;
- };
- var forEach = function(array, callback) {
- var index = -1;
- var length = array.length;
- while (++index < length) {
- callback(array[index], index);
- }
- };
- var toString = object.toString;
- var isArray = function(value) {
- return toString.call(value) == '[object Array]';
- };
- var isNumber = function(value) {
- return typeof value == 'number' ||
- toString.call(value) == '[object Number]';
- };
- // This assumes that `number` is a positive integer that `toString()`s nicely
- // (which is the case for all code point values).
- var zeroes = '0000';
- var pad = function(number, totalCharacters) {
- var string = String(number);
- return string.length < totalCharacters
- ? (zeroes + string).slice(-totalCharacters)
- : string;
- };
- var hex = function(number) {
- return Number(number).toString(16).toUpperCase();
- };
- var slice = [].slice;
- /*--------------------------------------------------------------------------*/
- var dataFromCodePoints = function(codePoints) {
- var index = -1;
- var length = codePoints.length;
- var max = length - 1;
- var result = [];
- var isStart = true;
- var tmp;
- var previous = 0;
- while (++index < length) {
- tmp = codePoints[index];
- if (isStart) {
- result.push(tmp);
- previous = tmp;
- isStart = false;
- } else {
- if (tmp == previous + 1) {
- if (index != max) {
- previous = tmp;
- continue;
- } else {
- isStart = true;
- result.push(tmp + 1);
- }
- } else {
- // End the previous range and start a new one.
- result.push(previous + 1, tmp);
- previous = tmp;
- }
- }
- }
- if (!isStart) {
- result.push(tmp + 1);
- }
- return result;
- };
- var dataRemove = function(data, codePoint) {
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- var length = data.length;
- while (index < length) {
- start = data[index];
- end = data[index + 1];
- if (codePoint >= start && codePoint < end) {
- // Modify this pair.
- if (codePoint == start) {
- if (end == start + 1) {
- // Just remove `start` and `end`.
- data.splice(index, 2);
- return data;
- } else {
- // Just replace `start` with a new value.
- data[index] = codePoint + 1;
- return data;
- }
- } else if (codePoint == end - 1) {
- // Just replace `end` with a new value.
- data[index + 1] = codePoint;
- return data;
- } else {
- // Replace `[start, end]` with `[startA, endA, startB, endB]`.
- data.splice(index, 2, start, codePoint, codePoint + 1, end);
- return data;
- }
- }
- index += 2;
- }
- return data;
- };
- var dataRemoveRange = function(data, rangeStart, rangeEnd) {
- if (rangeEnd < rangeStart) {
- throw Error(ERRORS.rangeOrder);
- }
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- while (index < data.length) {
- start = data[index];
- end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive.
- // Exit as soon as no more matching pairs can be found.
- if (start > rangeEnd) {
- return data;
- }
- // Check if this range pair is equal to, or forms a subset of, the range
- // to be removed.
- // E.g. we have `[0, 11, 40, 51]` and want to remove 0-10 → `[40, 51]`.
- // E.g. we have `[40, 51]` and want to remove 0-100 → `[]`.
- if (rangeStart <= start && rangeEnd >= end) {
- // Remove this pair.
- data.splice(index, 2);
- continue;
- }
- // Check if both `rangeStart` and `rangeEnd` are within the bounds of
- // this pair.
- // E.g. we have `[0, 11]` and want to remove 4-6 → `[0, 4, 7, 11]`.
- if (rangeStart >= start && rangeEnd < end) {
- if (rangeStart == start) {
- // Replace `[start, end]` with `[startB, endB]`.
- data[index] = rangeEnd + 1;
- data[index + 1] = end + 1;
- return data;
- }
- // Replace `[start, end]` with `[startA, endA, startB, endB]`.
- data.splice(index, 2, start, rangeStart, rangeEnd + 1, end + 1);
- return data;
- }
- // Check if only `rangeStart` is within the bounds of this pair.
- // E.g. we have `[0, 11]` and want to remove 4-20 → `[0, 4]`.
- if (rangeStart >= start && rangeStart <= end) {
- // Replace `end` with `rangeStart`.
- data[index + 1] = rangeStart;
- // Note: we cannot `return` just yet, in case any following pairs still
- // contain matching code points.
- // E.g. we have `[0, 11, 14, 31]` and want to remove 4-20
- // → `[0, 4, 21, 31]`.
- }
- // Check if only `rangeEnd` is within the bounds of this pair.
- // E.g. we have `[14, 31]` and want to remove 4-20 → `[21, 31]`.
- else if (rangeEnd >= start && rangeEnd <= end) {
- // Just replace `start`.
- data[index] = rangeEnd + 1;
- return data;
- }
- index += 2;
- }
- return data;
- };
- var dataAdd = function(data, codePoint) {
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- var lastIndex = null;
- var length = data.length;
- if (codePoint < 0x0 || codePoint > 0x10FFFF) {
- throw RangeError(ERRORS.codePointRange);
- }
- while (index < length) {
- start = data[index];
- end = data[index + 1];
- // Check if the code point is already in the set.
- if (codePoint >= start && codePoint < end) {
- return data;
- }
- if (codePoint == start - 1) {
- // Just replace `start` with a new value.
- data[index] = codePoint;
- return data;
- }
- // At this point, if `start` is `greater` than `codePoint`, insert a new
- // `[start, end]` pair before the current pair, or after the current pair
- // if there is a known `lastIndex`.
- if (start > codePoint) {
- data.splice(
- lastIndex != null ? lastIndex + 2 : 0,
- 0,
- codePoint,
- codePoint + 1
- );
- return data;
- }
- if (codePoint == end) {
- // Check if adding this code point causes two separate ranges to become
- // a single range, e.g. `dataAdd([0, 4, 5, 10], 4)` → `[0, 10]`.
- if (codePoint + 1 == data[index + 2]) {
- data.splice(index, 4, start, data[index + 3]);
- return data;
- }
- // Else, just replace `end` with a new value.
- data[index + 1] = codePoint + 1;
- return data;
- }
- lastIndex = index;
- index += 2;
- }
- // The loop has finished; add the new pair to the end of the data set.
- data.push(codePoint, codePoint + 1);
- return data;
- };
- var dataAddData = function(dataA, dataB) {
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- var data = dataA.slice();
- var length = dataB.length;
- while (index < length) {
- start = dataB[index];
- end = dataB[index + 1] - 1;
- if (start == end) {
- data = dataAdd(data, start);
- } else {
- data = dataAddRange(data, start, end);
- }
- index += 2;
- }
- return data;
- };
- var dataRemoveData = function(dataA, dataB) {
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- var data = dataA.slice();
- var length = dataB.length;
- while (index < length) {
- start = dataB[index];
- end = dataB[index + 1] - 1;
- if (start == end) {
- data = dataRemove(data, start);
- } else {
- data = dataRemoveRange(data, start, end);
- }
- index += 2;
- }
- return data;
- };
- var dataAddRange = function(data, rangeStart, rangeEnd) {
- if (rangeEnd < rangeStart) {
- throw Error(ERRORS.rangeOrder);
- }
- if (
- rangeStart < 0x0 || rangeStart > 0x10FFFF ||
- rangeEnd < 0x0 || rangeEnd > 0x10FFFF
- ) {
- throw RangeError(ERRORS.codePointRange);
- }
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- var added = false;
- var length = data.length;
- while (index < length) {
- start = data[index];
- end = data[index + 1];
- if (added) {
- // The range has already been added to the set; at this point, we just
- // need to get rid of the following ranges in case they overlap.
- // Check if this range can be combined with the previous range.
- if (start == rangeEnd + 1) {
- data.splice(index - 1, 2);
- return data;
- }
- // Exit as soon as no more possibly overlapping pairs can be found.
- if (start > rangeEnd) {
- return data;
- }
- // E.g. `[0, 11, 12, 16]` and we’ve added 5-15, so we now have
- // `[0, 16, 12, 16]`. Remove the `12,16` part, as it lies within the
- // `0,16` range that was previously added.
- if (start >= rangeStart && start <= rangeEnd) {
- // `start` lies within the range that was previously added.
- if (end > rangeStart && end - 1 <= rangeEnd) {
- // `end` lies within the range that was previously added as well,
- // so remove this pair.
- data.splice(index, 2);
- index -= 2;
- // Note: we cannot `return` just yet, as there may still be other
- // overlapping pairs.
- } else {
- // `start` lies within the range that was previously added, but
- // `end` doesn’t. E.g. `[0, 11, 12, 31]` and we’ve added 5-15, so
- // now we have `[0, 16, 12, 31]`. This must be written as `[0, 31]`.
- // Remove the previously added `end` and the current `start`.
- data.splice(index - 1, 2);
- index -= 2;
- }
- // Note: we cannot return yet.
- }
- }
- else if (start == rangeEnd + 1) {
- data[index] = rangeStart;
- return data;
- }
- // Check if a new pair must be inserted *before* the current one.
- else if (start > rangeEnd) {
- data.splice(index, 0, rangeStart, rangeEnd + 1);
- return data;
- }
- else if (rangeStart >= start && rangeStart < end && rangeEnd + 1 <= end) {
- // The new range lies entirely within an existing range pair. No action
- // needed.
- return data;
- }
- else if (
- // E.g. `[0, 11]` and you add 5-15 → `[0, 16]`.
- (rangeStart >= start && rangeStart < end) ||
- // E.g. `[0, 3]` and you add 3-6 → `[0, 7]`.
- end == rangeStart
- ) {
- // Replace `end` with the new value.
- data[index + 1] = rangeEnd + 1;
- // Make sure the next range pair doesn’t overlap, e.g. `[0, 11, 12, 14]`
- // and you add 5-15 → `[0, 16]`, i.e. remove the `12,14` part.
- added = true;
- // Note: we cannot `return` just yet.
- }
- else if (rangeStart <= start && rangeEnd + 1 >= end) {
- // The new range is a superset of the old range.
- data[index] = rangeStart;
- data[index + 1] = rangeEnd + 1;
- added = true;
- }
- index += 2;
- }
- // The loop has finished without doing anything; add the new pair to the end
- // of the data set.
- if (!added) {
- data.push(rangeStart, rangeEnd + 1);
- }
- return data;
- };
- var dataContains = function(data, codePoint) {
- var index = 0;
- var length = data.length;
- // Exit early if `codePoint` is not within `data`’s overall range.
- var start = data[index];
- var end = data[length - 1];
- if (length >= 2) {
- if (codePoint < start || codePoint > end) {
- return false;
- }
- }
- // Iterate over the data per `(start, end)` pair.
- while (index < length) {
- start = data[index];
- end = data[index + 1];
- if (codePoint >= start && codePoint < end) {
- return true;
- }
- index += 2;
- }
- return false;
- };
- var dataIntersection = function(data, codePoints) {
- var index = 0;
- var length = codePoints.length;
- var codePoint;
- var result = [];
- while (index < length) {
- codePoint = codePoints[index];
- if (dataContains(data, codePoint)) {
- result.push(codePoint);
- }
- ++index;
- }
- return dataFromCodePoints(result);
- };
- var dataIsEmpty = function(data) {
- return !data.length;
- };
- var dataIsSingleton = function(data) {
- // Check if the set only represents a single code point.
- return data.length == 2 && data[0] + 1 == data[1];
- };
- var dataToArray = function(data) {
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- var result = [];
- var length = data.length;
- while (index < length) {
- start = data[index];
- end = data[index + 1];
- while (start < end) {
- result.push(start);
- ++start;
- }
- index += 2;
- }
- return result;
- };
- /*--------------------------------------------------------------------------*/
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- var floor = Math.floor;
- var highSurrogate = function(codePoint) {
- return parseInt(
- floor((codePoint - 0x10000) / 0x400) + HIGH_SURROGATE_MIN,
- 10
- );
- };
- var lowSurrogate = function(codePoint) {
- return parseInt(
- (codePoint - 0x10000) % 0x400 + LOW_SURROGATE_MIN,
- 10
- );
- };
- var stringFromCharCode = String.fromCharCode;
- var codePointToString = function(codePoint) {
- var string;
- // https://mathiasbynens.be/notes/javascript-escapes#single
- // Note: the `\b` escape sequence for U+0008 BACKSPACE in strings has a
- // different meaning in regular expressions (word boundary), so it cannot
- // be used here.
- if (codePoint == 0x09) {
- string = '\\t';
- }
- // Note: IE < 9 treats `'\v'` as `'v'`, so avoid using it.
- // else if (codePoint == 0x0B) {
- // string = '\\v';
- // }
- else if (codePoint == 0x0A) {
- string = '\\n';
- }
- else if (codePoint == 0x0C) {
- string = '\\f';
- }
- else if (codePoint == 0x0D) {
- string = '\\r';
- }
- else if (codePoint == 0x5C) {
- string = '\\\\';
- }
- else if (
- codePoint == 0x24 ||
- (codePoint >= 0x28 && codePoint <= 0x2B) ||
- codePoint == 0x2D || codePoint == 0x2E || codePoint == 0x3F ||
- (codePoint >= 0x5B && codePoint <= 0x5E) ||
- (codePoint >= 0x7B && codePoint <= 0x7D)
- ) {
- // The code point maps to an unsafe printable ASCII character;
- // backslash-escape it. Here’s the list of those symbols:
- //
- // $()*+-.?[\]^{|}
- //
- // See #7 for more info.
- string = '\\' + stringFromCharCode(codePoint);
- }
- else if (codePoint >= 0x20 && codePoint <= 0x7E) {
- // The code point maps to one of these printable ASCII symbols
- // (including the space character):
- //
- // !"#%&',/0123456789:;<=>@ABCDEFGHIJKLMNO
- // PQRSTUVWXYZ_`abcdefghijklmnopqrstuvwxyz~
- //
- // These can safely be used directly.
- string = stringFromCharCode(codePoint);
- }
- else if (codePoint <= 0xFF) {
- // https://mathiasbynens.be/notes/javascript-escapes#hexadecimal
- string = '\\x' + pad(hex(codePoint), 2);
- }
- else { // `codePoint <= 0xFFFF` holds true.
- // https://mathiasbynens.be/notes/javascript-escapes#unicode
- string = '\\u' + pad(hex(codePoint), 4);
- }
- // There’s no need to account for astral symbols / surrogate pairs here,
- // since `codePointToString` is private and only used for BMP code points.
- // But if that’s what you need, just add an `else` block with this code:
- //
- // string = '\\u' + pad(hex(highSurrogate(codePoint)), 4)
- // + '\\u' + pad(hex(lowSurrogate(codePoint)), 4);
- return string;
- };
- var symbolToCodePoint = function(symbol) {
- var length = symbol.length;
- var first = symbol.charCodeAt(0);
- var second;
- if (
- first >= HIGH_SURROGATE_MIN && first <= HIGH_SURROGATE_MAX &&
- length > 1 // There is a next code unit.
- ) {
- // `first` is a high surrogate, and there is a next character. Assume
- // it’s a low surrogate (else it’s invalid usage of Regenerate anyway).
- second = symbol.charCodeAt(1);
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- return (first - HIGH_SURROGATE_MIN) * 0x400 +
- second - LOW_SURROGATE_MIN + 0x10000;
- }
- return first;
- };
- var createBMPCharacterClasses = function(data) {
- // Iterate over the data per `(start, end)` pair.
- var result = '';
- var index = 0;
- var start;
- var end;
- var length = data.length;
- if (dataIsSingleton(data)) {
- return codePointToString(data[0]);
- }
- while (index < length) {
- start = data[index];
- end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive.
- if (start == end) {
- result += codePointToString(start);
- } else if (start + 1 == end) {
- result += codePointToString(start) + codePointToString(end);
- } else {
- result += codePointToString(start) + '-' + codePointToString(end);
- }
- index += 2;
- }
- return '[' + result + ']';
- };
- var splitAtBMP = function(data) {
- // Iterate over the data per `(start, end)` pair.
- var loneHighSurrogates = [];
- var loneLowSurrogates = [];
- var bmp = [];
- var astral = [];
- var index = 0;
- var start;
- var end;
- var length = data.length;
- while (index < length) {
- start = data[index];
- end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive.
- if (start < HIGH_SURROGATE_MIN) {
- // The range starts and ends before the high surrogate range.
- // E.g. (0, 0x10).
- if (end < HIGH_SURROGATE_MIN) {
- bmp.push(start, end + 1);
- }
- // The range starts before the high surrogate range and ends within it.
- // E.g. (0, 0xD855).
- if (end >= HIGH_SURROGATE_MIN && end <= HIGH_SURROGATE_MAX) {
- bmp.push(start, HIGH_SURROGATE_MIN);
- loneHighSurrogates.push(HIGH_SURROGATE_MIN, end + 1);
- }
- // The range starts before the high surrogate range and ends in the low
- // surrogate range. E.g. (0, 0xDCFF).
- if (end >= LOW_SURROGATE_MIN && end <= LOW_SURROGATE_MAX) {
- bmp.push(start, HIGH_SURROGATE_MIN);
- loneHighSurrogates.push(HIGH_SURROGATE_MIN, HIGH_SURROGATE_MAX + 1);
- loneLowSurrogates.push(LOW_SURROGATE_MIN, end + 1);
- }
- // The range starts before the high surrogate range and ends after the
- // low surrogate range. E.g. (0, 0x10FFFF).
- if (end > LOW_SURROGATE_MAX) {
- bmp.push(start, HIGH_SURROGATE_MIN);
- loneHighSurrogates.push(HIGH_SURROGATE_MIN, HIGH_SURROGATE_MAX + 1);
- loneLowSurrogates.push(LOW_SURROGATE_MIN, LOW_SURROGATE_MAX + 1);
- if (end <= 0xFFFF) {
- bmp.push(LOW_SURROGATE_MAX + 1, end + 1);
- } else {
- bmp.push(LOW_SURROGATE_MAX + 1, 0xFFFF + 1);
- astral.push(0xFFFF + 1, end + 1);
- }
- }
- } else if (start >= HIGH_SURROGATE_MIN && start <= HIGH_SURROGATE_MAX) {
- // The range starts and ends in the high surrogate range.
- // E.g. (0xD855, 0xD866).
- if (end >= HIGH_SURROGATE_MIN && end <= HIGH_SURROGATE_MAX) {
- loneHighSurrogates.push(start, end + 1);
- }
- // The range starts in the high surrogate range and ends in the low
- // surrogate range. E.g. (0xD855, 0xDCFF).
- if (end >= LOW_SURROGATE_MIN && end <= LOW_SURROGATE_MAX) {
- loneHighSurrogates.push(start, HIGH_SURROGATE_MAX + 1);
- loneLowSurrogates.push(LOW_SURROGATE_MIN, end + 1);
- }
- // The range starts in the high surrogate range and ends after the low
- // surrogate range. E.g. (0xD855, 0x10FFFF).
- if (end > LOW_SURROGATE_MAX) {
- loneHighSurrogates.push(start, HIGH_SURROGATE_MAX + 1);
- loneLowSurrogates.push(LOW_SURROGATE_MIN, LOW_SURROGATE_MAX + 1);
- if (end <= 0xFFFF) {
- bmp.push(LOW_SURROGATE_MAX + 1, end + 1);
- } else {
- bmp.push(LOW_SURROGATE_MAX + 1, 0xFFFF + 1);
- astral.push(0xFFFF + 1, end + 1);
- }
- }
- } else if (start >= LOW_SURROGATE_MIN && start <= LOW_SURROGATE_MAX) {
- // The range starts and ends in the low surrogate range.
- // E.g. (0xDCFF, 0xDDFF).
- if (end >= LOW_SURROGATE_MIN && end <= LOW_SURROGATE_MAX) {
- loneLowSurrogates.push(start, end + 1);
- }
- // The range starts in the low surrogate range and ends after the low
- // surrogate range. E.g. (0xDCFF, 0x10FFFF).
- if (end > LOW_SURROGATE_MAX) {
- loneLowSurrogates.push(start, LOW_SURROGATE_MAX + 1);
- if (end <= 0xFFFF) {
- bmp.push(LOW_SURROGATE_MAX + 1, end + 1);
- } else {
- bmp.push(LOW_SURROGATE_MAX + 1, 0xFFFF + 1);
- astral.push(0xFFFF + 1, end + 1);
- }
- }
- } else if (start > LOW_SURROGATE_MAX && start <= 0xFFFF) {
- // The range starts and ends after the low surrogate range.
- // E.g. (0xFFAA, 0x10FFFF).
- if (end <= 0xFFFF) {
- bmp.push(start, end + 1);
- } else {
- bmp.push(start, 0xFFFF + 1);
- astral.push(0xFFFF + 1, end + 1);
- }
- } else {
- // The range starts and ends in the astral range.
- astral.push(start, end + 1);
- }
- index += 2;
- }
- return {
- 'loneHighSurrogates': loneHighSurrogates,
- 'loneLowSurrogates': loneLowSurrogates,
- 'bmp': bmp,
- 'astral': astral
- };
- };
- var optimizeSurrogateMappings = function(surrogateMappings) {
- var result = [];
- var tmpLow = [];
- var addLow = false;
- var mapping;
- var nextMapping;
- var highSurrogates;
- var lowSurrogates;
- var nextHighSurrogates;
- var nextLowSurrogates;
- var index = -1;
- var length = surrogateMappings.length;
- while (++index < length) {
- mapping = surrogateMappings[index];
- nextMapping = surrogateMappings[index + 1];
- if (!nextMapping) {
- result.push(mapping);
- continue;
- }
- highSurrogates = mapping[0];
- lowSurrogates = mapping[1];
- nextHighSurrogates = nextMapping[0];
- nextLowSurrogates = nextMapping[1];
- // Check for identical high surrogate ranges.
- tmpLow = lowSurrogates;
- while (
- nextHighSurrogates &&
- highSurrogates[0] == nextHighSurrogates[0] &&
- highSurrogates[1] == nextHighSurrogates[1]
- ) {
- // Merge with the next item.
- if (dataIsSingleton(nextLowSurrogates)) {
- tmpLow = dataAdd(tmpLow, nextLowSurrogates[0]);
- } else {
- tmpLow = dataAddRange(
- tmpLow,
- nextLowSurrogates[0],
- nextLowSurrogates[1] - 1
- );
- }
- ++index;
- mapping = surrogateMappings[index];
- highSurrogates = mapping[0];
- lowSurrogates = mapping[1];
- nextMapping = surrogateMappings[index + 1];
- nextHighSurrogates = nextMapping && nextMapping[0];
- nextLowSurrogates = nextMapping && nextMapping[1];
- addLow = true;
- }
- result.push([
- highSurrogates,
- addLow ? tmpLow : lowSurrogates
- ]);
- addLow = false;
- }
- return optimizeByLowSurrogates(result);
- };
- var optimizeByLowSurrogates = function(surrogateMappings) {
- if (surrogateMappings.length == 1) {
- return surrogateMappings;
- }
- var index = -1;
- var innerIndex = -1;
- while (++index < surrogateMappings.length) {
- var mapping = surrogateMappings[index];
- var lowSurrogates = mapping[1];
- var lowSurrogateStart = lowSurrogates[0];
- var lowSurrogateEnd = lowSurrogates[1];
- innerIndex = index; // Note: the loop starts at the next index.
- while (++innerIndex < surrogateMappings.length) {
- var otherMapping = surrogateMappings[innerIndex];
- var otherLowSurrogates = otherMapping[1];
- var otherLowSurrogateStart = otherLowSurrogates[0];
- var otherLowSurrogateEnd = otherLowSurrogates[1];
- if (
- lowSurrogateStart == otherLowSurrogateStart &&
- lowSurrogateEnd == otherLowSurrogateEnd
- ) {
- // Add the code points in the other item to this one.
- if (dataIsSingleton(otherMapping[0])) {
- mapping[0] = dataAdd(mapping[0], otherMapping[0][0]);
- } else {
- mapping[0] = dataAddRange(
- mapping[0],
- otherMapping[0][0],
- otherMapping[0][1] - 1
- );
- }
- // Remove the other, now redundant, item.
- surrogateMappings.splice(innerIndex, 1);
- --innerIndex;
- }
- }
- }
- return surrogateMappings;
- };
- var surrogateSet = function(data) {
- // Exit early if `data` is an empty set.
- if (!data.length) {
- return [];
- }
- // Iterate over the data per `(start, end)` pair.
- var index = 0;
- var start;
- var end;
- var startHigh;
- var startLow;
- var prevStartHigh = 0;
- var prevEndHigh = 0;
- var tmpLow = [];
- var endHigh;
- var endLow;
- var surrogateMappings = [];
- var length = data.length;
- var dataHigh = [];
- while (index < length) {
- start = data[index];
- end = data[index + 1] - 1;
- startHigh = highSurrogate(start);
- startLow = lowSurrogate(start);
- endHigh = highSurrogate(end);
- endLow = lowSurrogate(end);
- var startsWithLowestLowSurrogate = startLow == LOW_SURROGATE_MIN;
- var endsWithHighestLowSurrogate = endLow == LOW_SURROGATE_MAX;
- var complete = false;
- // Append the previous high-surrogate-to-low-surrogate mappings.
- // Step 1: `(startHigh, startLow)` to `(startHigh, LOW_SURROGATE_MAX)`.
- if (
- startHigh == endHigh ||
- startsWithLowestLowSurrogate && endsWithHighestLowSurrogate
- ) {
- surrogateMappings.push([
- [startHigh, endHigh + 1],
- [startLow, endLow + 1]
- ]);
- complete = true;
- } else {
- surrogateMappings.push([
- [startHigh, startHigh + 1],
- [startLow, LOW_SURROGATE_MAX + 1]
- ]);
- }
- // Step 2: `(startHigh + 1, LOW_SURROGATE_MIN)` to
- // `(endHigh - 1, LOW_SURROGATE_MAX)`.
- if (!complete && startHigh + 1 < endHigh) {
- if (endsWithHighestLowSurrogate) {
- // Combine step 2 and step 3.
- surrogateMappings.push([
- [startHigh + 1, endHigh + 1],
- [LOW_SURROGATE_MIN, endLow + 1]
- ]);
- complete = true;
- } else {
- surrogateMappings.push([
- [startHigh + 1, endHigh],
- [LOW_SURROGATE_MIN, LOW_SURROGATE_MAX + 1]
- ]);
- }
- }
- // Step 3. `(endHigh, LOW_SURROGATE_MIN)` to `(endHigh, endLow)`.
- if (!complete) {
- surrogateMappings.push([
- [endHigh, endHigh + 1],
- [LOW_SURROGATE_MIN, endLow + 1]
- ]);
- }
- prevStartHigh = startHigh;
- prevEndHigh = endHigh;
- index += 2;
- }
- // The format of `surrogateMappings` is as follows:
- //
- // [ surrogateMapping1, surrogateMapping2 ]
- //
- // i.e.:
- //
- // [
- // [ highSurrogates1, lowSurrogates1 ],
- // [ highSurrogates2, lowSurrogates2 ]
- // ]
- return optimizeSurrogateMappings(surrogateMappings);
- };
- var createSurrogateCharacterClasses = function(surrogateMappings) {
- var result = [];
- forEach(surrogateMappings, function(surrogateMapping) {
- var highSurrogates = surrogateMapping[0];
- var lowSurrogates = surrogateMapping[1];
- result.push(
- createBMPCharacterClasses(highSurrogates) +
- createBMPCharacterClasses(lowSurrogates)
- );
- });
- return result.join('|');
- };
- var createCharacterClassesFromData = function(data, bmpOnly) {
- var result = [];
- var parts = splitAtBMP(data);
- var loneHighSurrogates = parts.loneHighSurrogates;
- var loneLowSurrogates = parts.loneLowSurrogates;
- var bmp = parts.bmp;
- var astral = parts.astral;
- var hasAstral = !dataIsEmpty(parts.astral);
- var hasLoneHighSurrogates = !dataIsEmpty(loneHighSurrogates);
- var hasLoneLowSurrogates = !dataIsEmpty(loneLowSurrogates);
- var surrogateMappings = surrogateSet(astral);
- if (bmpOnly) {
- bmp = dataAddData(bmp, loneHighSurrogates);
- hasLoneHighSurrogates = false;
- bmp = dataAddData(bmp, loneLowSurrogates);
- hasLoneLowSurrogates = false;
- }
- if (!dataIsEmpty(bmp)) {
- // The data set contains BMP code points that are not high surrogates
- // needed for astral code points in the set.
- result.push(createBMPCharacterClasses(bmp));
- }
- if (surrogateMappings.length) {
- // The data set contains astral code points; append character classes
- // based on their surrogate pairs.
- result.push(createSurrogateCharacterClasses(surrogateMappings));
- }
- // https://gist.github.com/mathiasbynens/bbe7f870208abcfec860
- if (hasLoneHighSurrogates) {
- result.push(
- createBMPCharacterClasses(loneHighSurrogates) +
- // Make sure the high surrogates aren’t part of a surrogate pair.
- '(?![\\uDC00-\\uDFFF])'
- );
- }
- if (hasLoneLowSurrogates) {
- result.push(
- // Make sure the low surrogates aren’t part of a surrogate pair.
- '(?:[^\\uD800-\\uDBFF]|^)' +
- createBMPCharacterClasses(loneLowSurrogates)
- );
- }
- return result.join('|');
- };
- /*--------------------------------------------------------------------------*/
- // `regenerate` can be used as a constructor (and new methods can be added to
- // its prototype) but also as a regular function, the latter of which is the
- // documented and most common usage. For that reason, it’s not capitalized.
- var regenerate = function(value) {
- if (arguments.length > 1) {
- value = slice.call(arguments);
- }
- if (this instanceof regenerate) {
- this.data = [];
- return value ? this.add(value) : this;
- }
- return (new regenerate).add(value);
- };
- regenerate.version = '1.2.0';
- var proto = regenerate.prototype;
- extend(proto, {
- 'add': function(value) {
- var $this = this;
- if (value == null) {
- return $this;
- }
- if (value instanceof regenerate) {
- // Allow passing other Regenerate instances.
- $this.data = dataAddData($this.data, value.data);
- return $this;
- }
- if (arguments.length > 1) {
- value = slice.call(arguments);
- }
- if (isArray(value)) {
- forEach(value, function(item) {
- $this.add(item);
- });
- return $this;
- }
- $this.data = dataAdd(
- $this.data,
- isNumber(value) ? value : symbolToCodePoint(value)
- );
- return $this;
- },
- 'remove': function(value) {
- var $this = this;
- if (value == null) {
- return $this;
- }
- if (value instanceof regenerate) {
- // Allow passing other Regenerate instances.
- $this.data = dataRemoveData($this.data, value.data);
- return $this;
- }
- if (arguments.length > 1) {
- value = slice.call(arguments);
- }
- if (isArray(value)) {
- forEach(value, function(item) {
- $this.remove(item);
- });
- return $this;
- }
- $this.data = dataRemove(
- $this.data,
- isNumber(value) ? value : symbolToCodePoint(value)
- );
- return $this;
- },
- 'addRange': function(start, end) {
- var $this = this;
- $this.data = dataAddRange($this.data,
- isNumber(start) ? start : symbolToCodePoint(start),
- isNumber(end) ? end : symbolToCodePoint(end)
- );
- return $this;
- },
- 'removeRange': function(start, end) {
- var $this = this;
- var startCodePoint = isNumber(start) ? start : symbolToCodePoint(start);
- var endCodePoint = isNumber(end) ? end : symbolToCodePoint(end);
- $this.data = dataRemoveRange(
- $this.data,
- startCodePoint,
- endCodePoint
- );
- return $this;
- },
- 'intersection': function(argument) {
- var $this = this;
- // Allow passing other Regenerate instances.
- // TODO: Optimize this by writing and using `dataIntersectionData()`.
- var array = argument instanceof regenerate ?
- dataToArray(argument.data) :
- argument;
- $this.data = dataIntersection($this.data, array);
- return $this;
- },
- 'contains': function(codePoint) {
- return dataContains(
- this.data,
- isNumber(codePoint) ? codePoint : symbolToCodePoint(codePoint)
- );
- },
- 'clone': function() {
- var set = new regenerate;
- set.data = this.data.slice(0);
- return set;
- },
- 'toString': function(options) {
- var result = createCharacterClassesFromData(
- this.data,
- options ? options.bmpOnly : false
- );
- // Use `\0` instead of `\x00` where possible.
- return result.replace(regexNull, '\\0$1');
- },
- 'toRegExp': function(flags) {
- return RegExp(this.toString(), flags || '');
- },
- 'valueOf': function() { // Note: `valueOf` is aliased as `toArray`.
- return dataToArray(this.data);
- }
- });
- proto.toArray = proto.valueOf;
- // Some AMD build optimizers, like r.js, check for specific condition patterns
- // like the following:
- if (
- typeof define == 'function' &&
- typeof define.amd == 'object' &&
- define.amd
- ) {
- define(function() {
- return regenerate;
- });
- } else if (freeExports && !freeExports.nodeType) {
- if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
- freeModule.exports = regenerate;
- } else { // in Narwhal or RingoJS v0.7.0-
- freeExports.regenerate = regenerate;
- }
- } else { // in Rhino or a web browser
- root.regenerate = regenerate;
- }
- }(this));
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{}],476:[function(require,module,exports){
- (function (global){
- /*!
- * RegJSGen
- * Copyright 2014 Benjamin Tan <https://d10.github.io/>
- * Available under MIT license <http://d10.mit-license.org/>
- */
- ;(function() {
- 'use strict';
- /** Used to determine if values are of the language type `Object` */
- var objectTypes = {
- 'function': true,
- 'object': true
- };
- /** Used as a reference to the global object */
- var root = (objectTypes[typeof window] && window) || this;
- /** Backup possible global object */
- var oldRoot = root;
- /** Detect free variable `exports` */
- var freeExports = objectTypes[typeof exports] && exports;
- /** Detect free variable `module` */
- var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
- /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */
- var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
- if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
- root = freeGlobal;
- }
- /*--------------------------------------------------------------------------*/
- /*! Based on https://mths.be/fromcodepoint v0.2.0 by @mathias */
- var stringFromCharCode = String.fromCharCode;
- var floor = Math.floor;
- function fromCodePoint() {
- var MAX_SIZE = 0x4000;
- var codeUnits = [];
- var highSurrogate;
- var lowSurrogate;
- var index = -1;
- var length = arguments.length;
- if (!length) {
- return '';
- }
- var result = '';
- while (++index < length) {
- var codePoint = Number(arguments[index]);
- if (
- !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
- codePoint < 0 || // not a valid Unicode code point
- codePoint > 0x10FFFF || // not a valid Unicode code point
- floor(codePoint) != codePoint // not an integer
- ) {
- throw RangeError('Invalid code point: ' + codePoint);
- }
- if (codePoint <= 0xFFFF) {
- // BMP code point
- codeUnits.push(codePoint);
- } else {
- // Astral code point; split in surrogate halves
- // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- codePoint -= 0x10000;
- highSurrogate = (codePoint >> 10) + 0xD800;
- lowSurrogate = (codePoint % 0x400) + 0xDC00;
- codeUnits.push(highSurrogate, lowSurrogate);
- }
- if (index + 1 == length || codeUnits.length > MAX_SIZE) {
- result += stringFromCharCode.apply(null, codeUnits);
- codeUnits.length = 0;
- }
- }
- return result;
- }
- function assertType(type, expected) {
- if (expected.indexOf('|') == -1) {
- if (type == expected) {
- return;
- }
- throw Error('Invalid node type: ' + type);
- }
- expected = assertType.hasOwnProperty(expected)
- ? assertType[expected]
- : (assertType[expected] = RegExp('^(?:' + expected + ')$'));
- if (expected.test(type)) {
- return;
- }
- throw Error('Invalid node type: ' + type);
- }
- /*--------------------------------------------------------------------------*/
- function generate(node) {
- var type = node.type;
- if (generate.hasOwnProperty(type) && typeof generate[type] == 'function') {
- return generate[type](node);
- }
- throw Error('Invalid node type: ' + type);
- }
- /*--------------------------------------------------------------------------*/
- function generateAlternative(node) {
- assertType(node.type, 'alternative');
- var terms = node.body,
- length = terms ? terms.length : 0;
- if (length == 1) {
- return generateTerm(terms[0]);
- } else {
- var i = -1,
- result = '';
- while (++i < length) {
- result += generateTerm(terms[i]);
- }
- return result;
- }
- }
- function generateAnchor(node) {
- assertType(node.type, 'anchor');
- switch (node.kind) {
- case 'start':
- return '^';
- case 'end':
- return '$';
- case 'boundary':
- return '\\b';
- case 'not-boundary':
- return '\\B';
- default:
- throw Error('Invalid assertion');
- }
- }
- function generateAtom(node) {
- assertType(node.type, 'anchor|characterClass|characterClassEscape|dot|group|reference|value');
- return generate(node);
- }
- function generateCharacterClass(node) {
- assertType(node.type, 'characterClass');
- var classRanges = node.body,
- length = classRanges ? classRanges.length : 0;
- var i = -1,
- result = '[';
- if (node.negative) {
- result += '^';
- }
- while (++i < length) {
- result += generateClassAtom(classRanges[i]);
- }
- result += ']';
- return result;
- }
- function generateCharacterClassEscape(node) {
- assertType(node.type, 'characterClassEscape');
- return '\\' + node.value;
- }
- function generateCharacterClassRange(node) {
- assertType(node.type, 'characterClassRange');
- var min = node.min,
- max = node.max;
- if (min.type == 'characterClassRange' || max.type == 'characterClassRange') {
- throw Error('Invalid character class range');
- }
- return generateClassAtom(min) + '-' + generateClassAtom(max);
- }
- function generateClassAtom(node) {
- assertType(node.type, 'anchor|characterClassEscape|characterClassRange|dot|value');
- return generate(node);
- }
- function generateDisjunction(node) {
- assertType(node.type, 'disjunction');
- var body = node.body,
- length = body ? body.length : 0;
- if (length == 0) {
- throw Error('No body');
- } else if (length == 1) {
- return generate(body[0]);
- } else {
- var i = -1,
- result = '';
- while (++i < length) {
- if (i != 0) {
- result += '|';
- }
- result += generate(body[i]);
- }
- return result;
- }
- }
- function generateDot(node) {
- assertType(node.type, 'dot');
- return '.';
- }
- function generateGroup(node) {
- assertType(node.type, 'group');
- var result = '(';
- switch (node.behavior) {
- case 'normal':
- break;
- case 'ignore':
- result += '?:';
- break;
- case 'lookahead':
- result += '?=';
- break;
- case 'negativeLookahead':
- result += '?!';
- break;
- default:
- throw Error('Invalid behaviour: ' + node.behaviour);
- }
- var body = node.body,
- length = body ? body.length : 0;
- if (length == 1) {
- result += generate(body[0]);
- } else {
- var i = -1;
- while (++i < length) {
- result += generate(body[i]);
- }
- }
- result += ')';
- return result;
- }
- function generateQuantifier(node) {
- assertType(node.type, 'quantifier');
- var quantifier = '',
- min = node.min,
- max = node.max;
- switch (max) {
- case undefined:
- case null:
- switch (min) {
- case 0:
- quantifier = '*'
- break;
- case 1:
- quantifier = '+';
- break;
- default:
- quantifier = '{' + min + ',}';
- break;
- }
- break;
- default:
- if (min == max) {
- quantifier = '{' + min + '}';
- }
- else if (min == 0 && max == 1) {
- quantifier = '?';
- } else {
- quantifier = '{' + min + ',' + max + '}';
- }
- break;
- }
- if (!node.greedy) {
- quantifier += '?';
- }
- return generateAtom(node.body[0]) + quantifier;
- }
- function generateReference(node) {
- assertType(node.type, 'reference');
- return '\\' + node.matchIndex;
- }
- function generateTerm(node) {
- assertType(node.type, 'anchor|characterClass|characterClassEscape|empty|group|quantifier|reference|value');
- return generate(node);
- }
- function generateValue(node) {
- assertType(node.type, 'value');
- var kind = node.kind,
- codePoint = node.codePoint;
- switch (kind) {
- case 'controlLetter':
- return '\\c' + fromCodePoint(codePoint + 64);
- case 'hexadecimalEscape':
- return '\\x' + ('00' + codePoint.toString(16).toUpperCase()).slice(-2);
- case 'identifier':
- return '\\' + fromCodePoint(codePoint);
- case 'null':
- return '\\' + codePoint;
- case 'octal':
- return '\\' + codePoint.toString(8);
- case 'singleEscape':
- switch (codePoint) {
- case 0x0008:
- return '\\b';
- case 0x009:
- return '\\t';
- case 0x00A:
- return '\\n';
- case 0x00B:
- return '\\v';
- case 0x00C:
- return '\\f';
- case 0x00D:
- return '\\r';
- default:
- throw Error('Invalid codepoint: ' + codePoint);
- }
- case 'symbol':
- return fromCodePoint(codePoint);
- case 'unicodeEscape':
- return '\\u' + ('0000' + codePoint.toString(16).toUpperCase()).slice(-4);
- case 'unicodeCodePointEscape':
- return '\\u{' + codePoint.toString(16).toUpperCase() + '}';
- default:
- throw Error('Unsupported node kind: ' + kind);
- }
- }
- /*--------------------------------------------------------------------------*/
- generate.alternative = generateAlternative;
- generate.anchor = generateAnchor;
- generate.characterClass = generateCharacterClass;
- generate.characterClassEscape = generateCharacterClassEscape;
- generate.characterClassRange = generateCharacterClassRange;
- generate.disjunction = generateDisjunction;
- generate.dot = generateDot;
- generate.group = generateGroup;
- generate.quantifier = generateQuantifier;
- generate.reference = generateReference;
- generate.value = generateValue;
- /*--------------------------------------------------------------------------*/
- // export regjsgen
- // some AMD build optimizers, like r.js, check for condition patterns like the following:
- if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
- // define as an anonymous module so, through path mapping, it can be aliased
- define(function() {
- return {
- 'generate': generate
- };
- });
- }
- // check for `exports` after `define` in case a build optimizer adds an `exports` object
- else if (freeExports && freeModule) {
- // in Narwhal, Node.js, Rhino -require, or RingoJS
- freeExports.generate = generate;
- }
- // in a browser or Rhino
- else {
- root.regjsgen = {
- 'generate': generate
- };
- }
- }.call(this));
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{}],477:[function(require,module,exports){
- // regjsparser
- //
- // ==================================================================
- //
- // See ECMA-262 Standard: 15.10.1
- //
- // NOTE: The ECMA-262 standard uses the term "Assertion" for /^/. Here the
- // term "Anchor" is used.
- //
- // Pattern ::
- // Disjunction
- //
- // Disjunction ::
- // Alternative
- // Alternative | Disjunction
- //
- // Alternative ::
- // [empty]
- // Alternative Term
- //
- // Term ::
- // Anchor
- // Atom
- // Atom Quantifier
- //
- // Anchor ::
- // ^
- // $
- // \ b
- // \ B
- // ( ? = Disjunction )
- // ( ? ! Disjunction )
- //
- // Quantifier ::
- // QuantifierPrefix
- // QuantifierPrefix ?
- //
- // QuantifierPrefix ::
- // *
- // +
- // ?
- // { DecimalDigits }
- // { DecimalDigits , }
- // { DecimalDigits , DecimalDigits }
- //
- // Atom ::
- // PatternCharacter
- // .
- // \ AtomEscape
- // CharacterClass
- // ( Disjunction )
- // ( ? : Disjunction )
- //
- // PatternCharacter ::
- // SourceCharacter but not any of: ^ $ \ . * + ? ( ) [ ] { } |
- //
- // AtomEscape ::
- // DecimalEscape
- // CharacterEscape
- // CharacterClassEscape
- //
- // CharacterEscape[U] ::
- // ControlEscape
- // c ControlLetter
- // HexEscapeSequence
- // RegExpUnicodeEscapeSequence[?U] (ES6)
- // IdentityEscape[?U]
- //
- // ControlEscape ::
- // one of f n r t v
- // ControlLetter ::
- // one of
- // a b c d e f g h i j k l m n o p q r s t u v w x y z
- // A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
- //
- // IdentityEscape ::
- // SourceCharacter but not IdentifierPart
- // <ZWJ>
- // <ZWNJ>
- //
- // DecimalEscape ::
- // DecimalIntegerLiteral [lookahead ∉ DecimalDigit]
- //
- // CharacterClassEscape ::
- // one of d D s S w W
- //
- // CharacterClass ::
- // [ [lookahead ∉ {^}] ClassRanges ]
- // [ ^ ClassRanges ]
- //
- // ClassRanges ::
- // [empty]
- // NonemptyClassRanges
- //
- // NonemptyClassRanges ::
- // ClassAtom
- // ClassAtom NonemptyClassRangesNoDash
- // ClassAtom - ClassAtom ClassRanges
- //
- // NonemptyClassRangesNoDash ::
- // ClassAtom
- // ClassAtomNoDash NonemptyClassRangesNoDash
- // ClassAtomNoDash - ClassAtom ClassRanges
- //
- // ClassAtom ::
- // -
- // ClassAtomNoDash
- //
- // ClassAtomNoDash ::
- // SourceCharacter but not one of \ or ] or -
- // \ ClassEscape
- //
- // ClassEscape ::
- // DecimalEscape
- // b
- // CharacterEscape
- // CharacterClassEscape
- (function() {
- function parse(str, flags) {
- function addRaw(node) {
- node.raw = str.substring(node.range[0], node.range[1]);
- return node;
- }
- function updateRawStart(node, start) {
- node.range[0] = start;
- return addRaw(node);
- }
- function createAnchor(kind, rawLength) {
- return addRaw({
- type: 'anchor',
- kind: kind,
- range: [
- pos - rawLength,
- pos
- ]
- });
- }
- function createValue(kind, codePoint, from, to) {
- return addRaw({
- type: 'value',
- kind: kind,
- codePoint: codePoint,
- range: [from, to]
- });
- }
- function createEscaped(kind, codePoint, value, fromOffset) {
- fromOffset = fromOffset || 0;
- return createValue(kind, codePoint, pos - (value.length + fromOffset), pos);
- }
- function createCharacter(matches) {
- var _char = matches[0];
- var first = _char.charCodeAt(0);
- if (hasUnicodeFlag) {
- var second;
- if (_char.length === 1 && first >= 0xD800 && first <= 0xDBFF) {
- second = lookahead().charCodeAt(0);
- if (second >= 0xDC00 && second <= 0xDFFF) {
- // Unicode surrogate pair
- pos++;
- return createValue(
- 'symbol',
- (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000,
- pos - 2, pos);
- }
- }
- }
- return createValue('symbol', first, pos - 1, pos);
- }
- function createDisjunction(alternatives, from, to) {
- return addRaw({
- type: 'disjunction',
- body: alternatives,
- range: [
- from,
- to
- ]
- });
- }
- function createDot() {
- return addRaw({
- type: 'dot',
- range: [
- pos - 1,
- pos
- ]
- });
- }
- function createCharacterClassEscape(value) {
- return addRaw({
- type: 'characterClassEscape',
- value: value,
- range: [
- pos - 2,
- pos
- ]
- });
- }
- function createReference(matchIndex) {
- return addRaw({
- type: 'reference',
- matchIndex: parseInt(matchIndex, 10),
- range: [
- pos - 1 - matchIndex.length,
- pos
- ]
- });
- }
- function createGroup(behavior, disjunction, from, to) {
- return addRaw({
- type: 'group',
- behavior: behavior,
- body: disjunction,
- range: [
- from,
- to
- ]
- });
- }
- function createQuantifier(min, max, from, to) {
- if (to == null) {
- from = pos - 1;
- to = pos;
- }
- return addRaw({
- type: 'quantifier',
- min: min,
- max: max,
- greedy: true,
- body: null, // set later on,
- range: [
- from,
- to
- ]
- });
- }
- function createAlternative(terms, from, to) {
- return addRaw({
- type: 'alternative',
- body: terms,
- range: [
- from,
- to
- ]
- });
- }
- function createCharacterClass(classRanges, negative, from, to) {
- return addRaw({
- type: 'characterClass',
- body: classRanges,
- negative: negative,
- range: [
- from,
- to
- ]
- });
- }
- function createClassRange(min, max, from, to) {
- // See 15.10.2.15:
- if (min.codePoint > max.codePoint) {
- throw SyntaxError('invalid range in character class');
- }
- return addRaw({
- type: 'characterClassRange',
- min: min,
- max: max,
- range: [
- from,
- to
- ]
- });
- }
- function flattenBody(body) {
- if (body.type === 'alternative') {
- return body.body;
- } else {
- return [body];
- }
- }
- function isEmpty(obj) {
- return obj.type === 'empty';
- }
- function incr(amount) {
- amount = (amount || 1);
- var res = str.substring(pos, pos + amount);
- pos += (amount || 1);
- return res;
- }
- function skip(value) {
- if (!match(value)) {
- throw SyntaxError('character: ' + value);
- }
- }
- function match(value) {
- if (str.indexOf(value, pos) === pos) {
- return incr(value.length);
- }
- }
- function lookahead() {
- return str[pos];
- }
- function current(value) {
- return str.indexOf(value, pos) === pos;
- }
- function next(value) {
- return str[pos + 1] === value;
- }
- function matchReg(regExp) {
- var subStr = str.substring(pos);
- var res = subStr.match(regExp);
- if (res) {
- res.range = [];
- res.range[0] = pos;
- incr(res[0].length);
- res.range[1] = pos;
- }
- return res;
- }
- function parseDisjunction() {
- // Disjunction ::
- // Alternative
- // Alternative | Disjunction
- var res = [], from = pos;
- res.push(parseAlternative());
- while (match('|')) {
- res.push(parseAlternative());
- }
- if (res.length === 1) {
- return res[0];
- }
- return createDisjunction(res, from, pos);
- }
- function parseAlternative() {
- var res = [], from = pos;
- var term;
- // Alternative ::
- // [empty]
- // Alternative Term
- while (term = parseTerm()) {
- res.push(term);
- }
- if (res.length === 1) {
- return res[0];
- }
- return createAlternative(res, from, pos);
- }
- function parseTerm() {
- // Term ::
- // Anchor
- // Atom
- // Atom Quantifier
- if (pos >= str.length || current('|') || current(')')) {
- return null; /* Means: The term is empty */
- }
- var anchor = parseAnchor();
- if (anchor) {
- return anchor;
- }
- var atom = parseAtom();
- if (!atom) {
- throw SyntaxError('Expected atom')
- }
- var quantifier = parseQuantifier() || false;
- if (quantifier) {
- quantifier.body = flattenBody(atom);
- // The quantifier contains the atom. Therefore, the beginning of the
- // quantifier range is given by the beginning of the atom.
- updateRawStart(quantifier, atom.range[0]);
- return quantifier;
- }
- return atom;
- }
- function parseGroup(matchA, typeA, matchB, typeB) {
- var type = null, from = pos;
- if (match(matchA)) {
- type = typeA;
- } else if (match(matchB)) {
- type = typeB;
- } else {
- return false;
- }
- var body = parseDisjunction();
- if (!body) {
- throw SyntaxError('Expected disjunction');
- }
- skip(')');
- var group = createGroup(type, flattenBody(body), from, pos);
- if (type == 'normal') {
- // Keep track of the number of closed groups. This is required for
- // parseDecimalEscape(). In case the string is parsed a second time the
- // value already holds the total count and no incrementation is required.
- if (firstIteration) {
- closedCaptureCounter++;
- }
- }
- return group;
- }
- function parseAnchor() {
- // Anchor ::
- // ^
- // $
- // \ b
- // \ B
- // ( ? = Disjunction )
- // ( ? ! Disjunction )
- var res, from = pos;
- if (match('^')) {
- return createAnchor('start', 1 /* rawLength */);
- } else if (match('$')) {
- return createAnchor('end', 1 /* rawLength */);
- } else if (match('\\b')) {
- return createAnchor('boundary', 2 /* rawLength */);
- } else if (match('\\B')) {
- return createAnchor('not-boundary', 2 /* rawLength */);
- } else {
- return parseGroup('(?=', 'lookahead', '(?!', 'negativeLookahead');
- }
- }
- function parseQuantifier() {
- // Quantifier ::
- // QuantifierPrefix
- // QuantifierPrefix ?
- //
- // QuantifierPrefix ::
- // *
- // +
- // ?
- // { DecimalDigits }
- // { DecimalDigits , }
- // { DecimalDigits , DecimalDigits }
- var res;
- var quantifier;
- var min, max;
- if (match('*')) {
- quantifier = createQuantifier(0);
- }
- else if (match('+')) {
- quantifier = createQuantifier(1);
- }
- else if (match('?')) {
- quantifier = createQuantifier(0, 1);
- }
- else if (res = matchReg(/^\{([0-9]+)\}/)) {
- min = parseInt(res[1], 10);
- quantifier = createQuantifier(min, min, res.range[0], res.range[1]);
- }
- else if (res = matchReg(/^\{([0-9]+),\}/)) {
- min = parseInt(res[1], 10);
- quantifier = createQuantifier(min, undefined, res.range[0], res.range[1]);
- }
- else if (res = matchReg(/^\{([0-9]+),([0-9]+)\}/)) {
- min = parseInt(res[1], 10);
- max = parseInt(res[2], 10);
- if (min > max) {
- throw SyntaxError('numbers out of order in {} quantifier');
- }
- quantifier = createQuantifier(min, max, res.range[0], res.range[1]);
- }
- if (quantifier) {
- if (match('?')) {
- quantifier.greedy = false;
- quantifier.range[1] += 1;
- }
- }
- return quantifier;
- }
- function parseAtom() {
- // Atom ::
- // PatternCharacter
- // .
- // \ AtomEscape
- // CharacterClass
- // ( Disjunction )
- // ( ? : Disjunction )
- var res;
- // jviereck: allow ']', '}' here as well to be compatible with browser's
- // implementations: ']'.match(/]/);
- // if (res = matchReg(/^[^^$\\.*+?()[\]{}|]/)) {
- if (res = matchReg(/^[^^$\\.*+?(){[|]/)) {
- // PatternCharacter
- return createCharacter(res);
- }
- else if (match('.')) {
- // .
- return createDot();
- }
- else if (match('\\')) {
- // \ AtomEscape
- res = parseAtomEscape();
- if (!res) {
- throw SyntaxError('atomEscape');
- }
- return res;
- }
- else if (res = parseCharacterClass()) {
- return res;
- }
- else {
- // ( Disjunction )
- // ( ? : Disjunction )
- return parseGroup('(?:', 'ignore', '(', 'normal');
- }
- }
- function parseUnicodeSurrogatePairEscape(firstEscape) {
- if (hasUnicodeFlag) {
- var first, second;
- if (firstEscape.kind == 'unicodeEscape' &&
- (first = firstEscape.codePoint) >= 0xD800 && first <= 0xDBFF &&
- current('\\') && next('u') ) {
- var prevPos = pos;
- pos++;
- var secondEscape = parseClassEscape();
- if (secondEscape.kind == 'unicodeEscape' &&
- (second = secondEscape.codePoint) >= 0xDC00 && second <= 0xDFFF) {
- // Unicode surrogate pair
- firstEscape.range[1] = secondEscape.range[1];
- firstEscape.codePoint = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
- firstEscape.type = 'value';
- firstEscape.kind = 'unicodeCodePointEscape';
- addRaw(firstEscape);
- }
- else {
- pos = prevPos;
- }
- }
- }
- return firstEscape;
- }
- function parseClassEscape() {
- return parseAtomEscape(true);
- }
- function parseAtomEscape(insideCharacterClass) {
- // AtomEscape ::
- // DecimalEscape
- // CharacterEscape
- // CharacterClassEscape
- var res;
- res = parseDecimalEscape();
- if (res) {
- return res;
- }
- // For ClassEscape
- if (insideCharacterClass) {
- if (match('b')) {
- // 15.10.2.19
- // The production ClassEscape :: b evaluates by returning the
- // CharSet containing the one character <BS> (Unicode value 0008).
- return createEscaped('singleEscape', 0x0008, '\\b');
- } else if (match('B')) {
- throw SyntaxError('\\B not possible inside of CharacterClass');
- }
- }
- res = parseCharacterEscape();
- return res;
- }
- function parseDecimalEscape() {
- // DecimalEscape ::
- // DecimalIntegerLiteral [lookahead ∉ DecimalDigit]
- // CharacterClassEscape :: one of d D s S w W
- var res, match;
- if (res = matchReg(/^(?!0)\d+/)) {
- match = res[0];
- var refIdx = parseInt(res[0], 10);
- if (refIdx <= closedCaptureCounter) {
- // If the number is smaller than the normal-groups found so
- // far, then it is a reference...
- return createReference(res[0]);
- } else {
- // ... otherwise it needs to be interpreted as a octal (if the
- // number is in an octal format). If it is NOT octal format,
- // then the slash is ignored and the number is matched later
- // as normal characters.
- // Recall the negative decision to decide if the input must be parsed
- // a second time with the total normal-groups.
- backrefDenied.push(refIdx);
- // Reset the position again, as maybe only parts of the previous
- // matched numbers are actual octal numbers. E.g. in '019' only
- // the '01' should be matched.
- incr(-res[0].length);
- if (res = matchReg(/^[0-7]{1,3}/)) {
- return createEscaped('octal', parseInt(res[0], 8), res[0], 1);
- } else {
- // If we end up here, we have a case like /\91/. Then the
- // first slash is to be ignored and the 9 & 1 to be treated
- // like ordinary characters. Create a character for the
- // first number only here - other number-characters
- // (if available) will be matched later.
- res = createCharacter(matchReg(/^[89]/));
- return updateRawStart(res, res.range[0] - 1);
- }
- }
- }
- // Only allow octal numbers in the following. All matched numbers start
- // with a zero (if the do not, the previous if-branch is executed).
- // If the number is not octal format and starts with zero (e.g. `091`)
- // then only the zeros `0` is treated here and the `91` are ordinary
- // characters.
- // Example:
- // /\091/.exec('\091')[0].length === 3
- else if (res = matchReg(/^[0-7]{1,3}/)) {
- match = res[0];
- if (/^0{1,3}$/.test(match)) {
- // If they are all zeros, then only take the first one.
- return createEscaped('null', 0x0000, '0', match.length + 1);
- } else {
- return createEscaped('octal', parseInt(match, 8), match, 1);
- }
- } else if (res = matchReg(/^[dDsSwW]/)) {
- return createCharacterClassEscape(res[0]);
- }
- return false;
- }
- function parseCharacterEscape() {
- // CharacterEscape ::
- // ControlEscape
- // c ControlLetter
- // HexEscapeSequence
- // UnicodeEscapeSequence
- // IdentityEscape
- var res;
- if (res = matchReg(/^[fnrtv]/)) {
- // ControlEscape
- var codePoint = 0;
- switch (res[0]) {
- case 't': codePoint = 0x009; break;
- case 'n': codePoint = 0x00A; break;
- case 'v': codePoint = 0x00B; break;
- case 'f': codePoint = 0x00C; break;
- case 'r': codePoint = 0x00D; break;
- }
- return createEscaped('singleEscape', codePoint, '\\' + res[0]);
- } else if (res = matchReg(/^c([a-zA-Z])/)) {
- // c ControlLetter
- return createEscaped('controlLetter', res[1].charCodeAt(0) % 32, res[1], 2);
- } else if (res = matchReg(/^x([0-9a-fA-F]{2})/)) {
- // HexEscapeSequence
- return createEscaped('hexadecimalEscape', parseInt(res[1], 16), res[1], 2);
- } else if (res = matchReg(/^u([0-9a-fA-F]{4})/)) {
- // UnicodeEscapeSequence
- return parseUnicodeSurrogatePairEscape(
- createEscaped('unicodeEscape', parseInt(res[1], 16), res[1], 2)
- );
- } else if (hasUnicodeFlag && (res = matchReg(/^u\{([0-9a-fA-F]+)\}/))) {
- // RegExpUnicodeEscapeSequence (ES6 Unicode code point escape)
- return createEscaped('unicodeCodePointEscape', parseInt(res[1], 16), res[1], 4);
- } else {
- // IdentityEscape
- return parseIdentityEscape();
- }
- }
- // Taken from the Esprima parser.
- function isIdentifierPart(ch) {
- // Generated by `tools/generate-identifier-regex.js`.
- var NonAsciiIdentifierPart = new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]');
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
- (ch >= 65 && ch <= 90) || // A..Z
- (ch >= 97 && ch <= 122) || // a..z
- (ch >= 48 && ch <= 57) || // 0..9
- (ch === 92) || // \ (backslash)
- ((ch >= 0x80) && NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
- }
- function parseIdentityEscape() {
- // IdentityEscape ::
- // SourceCharacter but not IdentifierPart
- // <ZWJ>
- // <ZWNJ>
- var ZWJ = '\u200C';
- var ZWNJ = '\u200D';
- var res;
- var tmp;
- if (!isIdentifierPart(lookahead())) {
- tmp = incr();
- return createEscaped('identifier', tmp.charCodeAt(0), tmp, 1);
- }
- if (match(ZWJ)) {
- // <ZWJ>
- return createEscaped('identifier', 0x200C, ZWJ);
- } else if (match(ZWNJ)) {
- // <ZWNJ>
- return createEscaped('identifier', 0x200D, ZWNJ);
- }
- return null;
- }
- function parseCharacterClass() {
- // CharacterClass ::
- // [ [lookahead ∉ {^}] ClassRanges ]
- // [ ^ ClassRanges ]
- var res, from = pos;
- if (res = matchReg(/^\[\^/)) {
- res = parseClassRanges();
- skip(']');
- return createCharacterClass(res, true, from, pos);
- } else if (match('[')) {
- res = parseClassRanges();
- skip(']');
- return createCharacterClass(res, false, from, pos);
- }
- return null;
- }
- function parseClassRanges() {
- // ClassRanges ::
- // [empty]
- // NonemptyClassRanges
- var res;
- if (current(']')) {
- // Empty array means nothing insinde of the ClassRange.
- return [];
- } else {
- res = parseNonemptyClassRanges();
- if (!res) {
- throw SyntaxError('nonEmptyClassRanges');
- }
- return res;
- }
- }
- function parseHelperClassRanges(atom) {
- var from, to, res;
- if (current('-') && !next(']')) {
- // ClassAtom - ClassAtom ClassRanges
- skip('-');
- res = parseClassAtom();
- if (!res) {
- throw SyntaxError('classAtom');
- }
- to = pos;
- var classRanges = parseClassRanges();
- if (!classRanges) {
- throw SyntaxError('classRanges');
- }
- from = atom.range[0];
- if (classRanges.type === 'empty') {
- return [createClassRange(atom, res, from, to)];
- }
- return [createClassRange(atom, res, from, to)].concat(classRanges);
- }
- res = parseNonemptyClassRangesNoDash();
- if (!res) {
- throw SyntaxError('nonEmptyClassRangesNoDash');
- }
- return [atom].concat(res);
- }
- function parseNonemptyClassRanges() {
- // NonemptyClassRanges ::
- // ClassAtom
- // ClassAtom NonemptyClassRangesNoDash
- // ClassAtom - ClassAtom ClassRanges
- var atom = parseClassAtom();
- if (!atom) {
- throw SyntaxError('classAtom');
- }
- if (current(']')) {
- // ClassAtom
- return [atom];
- }
- // ClassAtom NonemptyClassRangesNoDash
- // ClassAtom - ClassAtom ClassRanges
- return parseHelperClassRanges(atom);
- }
- function parseNonemptyClassRangesNoDash() {
- // NonemptyClassRangesNoDash ::
- // ClassAtom
- // ClassAtomNoDash NonemptyClassRangesNoDash
- // ClassAtomNoDash - ClassAtom ClassRanges
- var res = parseClassAtom();
- if (!res) {
- throw SyntaxError('classAtom');
- }
- if (current(']')) {
- // ClassAtom
- return res;
- }
- // ClassAtomNoDash NonemptyClassRangesNoDash
- // ClassAtomNoDash - ClassAtom ClassRanges
- return parseHelperClassRanges(res);
- }
- function parseClassAtom() {
- // ClassAtom ::
- // -
- // ClassAtomNoDash
- if (match('-')) {
- return createCharacter('-');
- } else {
- return parseClassAtomNoDash();
- }
- }
- function parseClassAtomNoDash() {
- // ClassAtomNoDash ::
- // SourceCharacter but not one of \ or ] or -
- // \ ClassEscape
- var res;
- if (res = matchReg(/^[^\\\]-]/)) {
- return createCharacter(res[0]);
- } else if (match('\\')) {
- res = parseClassEscape();
- if (!res) {
- throw SyntaxError('classEscape');
- }
- return parseUnicodeSurrogatePairEscape(res);
- }
- }
- var backrefDenied = [];
- var closedCaptureCounter = 0;
- var firstIteration = true;
- var hasUnicodeFlag = (flags || "").indexOf("u") !== -1;
- var pos = 0;
- // Convert the input to a string and treat the empty string special.
- str = String(str);
- if (str === '') {
- str = '(?:)';
- }
- var result = parseDisjunction();
- if (result.range[1] !== str.length) {
- throw SyntaxError('Could not parse entire input - got stuck: ' + str);
- }
- // The spec requires to interpret the `\2` in `/\2()()/` as backreference.
- // As the parser collects the number of capture groups as the string is
- // parsed it is impossible to make these decisions at the point the `\2` is
- // handled. In case the local decision turns out to be wrongq after the
- // parsing has finished, the input string is parsed a second time with the
- // total count of capture groups set.
- //
- // SEE: https://github.com/jviereck/regjsparser/issues/70
- for (var i = 0; i < backrefDenied.length; i++) {
- if (backrefDenied[i] <= closedCaptureCounter) {
- // Parse the input a second time.
- pos = 0;
- firstIteration = false;
- return parseDisjunction();
- }
- }
- return result;
- };
- var regjsparser = {
- parse: parse
- };
- if (typeof module !== 'undefined' && module.exports) {
- module.exports = regjsparser;
- } else {
- window.regjsparser = regjsparser;
- }
- }());
- },{}],478:[function(require,module,exports){
- var generate = require('regjsgen').generate;
- var parse = require('regjsparser').parse;
- var regenerate = require('regenerate');
- var iuMappings = require('./data/iu-mappings.json');
- var ESCAPE_SETS = require('./data/character-class-escape-sets.js');
- function getCharacterClassEscapeSet(character) {
- if (unicode) {
- if (ignoreCase) {
- return ESCAPE_SETS.UNICODE_IGNORE_CASE[character];
- }
- return ESCAPE_SETS.UNICODE[character];
- }
- return ESCAPE_SETS.REGULAR[character];
- }
- var object = {};
- var hasOwnProperty = object.hasOwnProperty;
- function has(object, property) {
- return hasOwnProperty.call(object, property);
- }
- // Prepare a Regenerate set containing all code points, used for negative
- // character classes (if any).
- var UNICODE_SET = regenerate().addRange(0x0, 0x10FFFF);
- // Without the `u` flag, the range stops at 0xFFFF.
- // https://mths.be/es6#sec-pattern-semantics
- var BMP_SET = regenerate().addRange(0x0, 0xFFFF);
- // Prepare a Regenerate set containing all code points that are supposed to be
- // matched by `/./u`. https://mths.be/es6#sec-atom
- var DOT_SET_UNICODE = UNICODE_SET.clone() // all Unicode code points
- .remove(
- // minus `LineTerminator`s (https://mths.be/es6#sec-line-terminators):
- 0x000A, // Line Feed <LF>
- 0x000D, // Carriage Return <CR>
- 0x2028, // Line Separator <LS>
- 0x2029 // Paragraph Separator <PS>
- );
- // Prepare a Regenerate set containing all code points that are supposed to be
- // matched by `/./` (only BMP code points).
- var DOT_SET = DOT_SET_UNICODE.clone()
- .intersection(BMP_SET);
- // Add a range of code points + any case-folded code points in that range to a
- // set.
- regenerate.prototype.iuAddRange = function(min, max) {
- var $this = this;
- do {
- var folded = caseFold(min);
- if (folded) {
- $this.add(folded);
- }
- } while (++min <= max);
- return $this;
- };
- function assign(target, source) {
- for (var key in source) {
- // Note: `hasOwnProperty` is not needed here.
- target[key] = source[key];
- }
- }
- function update(item, pattern) {
- // TODO: Test if memoizing `pattern` here is worth the effort.
- if (!pattern) {
- return;
- }
- var tree = parse(pattern, '');
- switch (tree.type) {
- case 'characterClass':
- case 'group':
- case 'value':
- // No wrapping needed.
- break;
- default:
- // Wrap the pattern in a non-capturing group.
- tree = wrap(tree, pattern);
- }
- assign(item, tree);
- }
- function wrap(tree, pattern) {
- // Wrap the pattern in a non-capturing group.
- return {
- 'type': 'group',
- 'behavior': 'ignore',
- 'body': [tree],
- 'raw': '(?:' + pattern + ')'
- };
- }
- function caseFold(codePoint) {
- return has(iuMappings, codePoint) ? iuMappings[codePoint] : false;
- }
- var ignoreCase = false;
- var unicode = false;
- function processCharacterClass(characterClassItem) {
- var set = regenerate();
- var body = characterClassItem.body.forEach(function(item) {
- switch (item.type) {
- case 'value':
- set.add(item.codePoint);
- if (ignoreCase && unicode) {
- var folded = caseFold(item.codePoint);
- if (folded) {
- set.add(folded);
- }
- }
- break;
- case 'characterClassRange':
- var min = item.min.codePoint;
- var max = item.max.codePoint;
- set.addRange(min, max);
- if (ignoreCase && unicode) {
- set.iuAddRange(min, max);
- }
- break;
- case 'characterClassEscape':
- set.add(getCharacterClassEscapeSet(item.value));
- break;
- // The `default` clause is only here as a safeguard; it should never be
- // reached. Code coverage tools should ignore it.
- /* istanbul ignore next */
- default:
- throw Error('Unknown term type: ' + item.type);
- }
- });
- if (characterClassItem.negative) {
- set = (unicode ? UNICODE_SET : BMP_SET).clone().remove(set);
- }
- update(characterClassItem, set.toString());
- return characterClassItem;
- }
- function processTerm(item) {
- switch (item.type) {
- case 'dot':
- update(
- item,
- (unicode ? DOT_SET_UNICODE : DOT_SET).toString()
- );
- break;
- case 'characterClass':
- item = processCharacterClass(item);
- break;
- case 'characterClassEscape':
- update(
- item,
- getCharacterClassEscapeSet(item.value).toString()
- );
- break;
- case 'alternative':
- case 'disjunction':
- case 'group':
- case 'quantifier':
- item.body = item.body.map(processTerm);
- break;
- case 'value':
- var codePoint = item.codePoint;
- var set = regenerate(codePoint);
- if (ignoreCase && unicode) {
- var folded = caseFold(codePoint);
- if (folded) {
- set.add(folded);
- }
- }
- update(item, set.toString());
- break;
- case 'anchor':
- case 'empty':
- case 'group':
- case 'reference':
- // Nothing to do here.
- break;
- // The `default` clause is only here as a safeguard; it should never be
- // reached. Code coverage tools should ignore it.
- /* istanbul ignore next */
- default:
- throw Error('Unknown term type: ' + item.type);
- }
- return item;
- };
- module.exports = function(pattern, flags) {
- var tree = parse(pattern, flags);
- ignoreCase = flags ? flags.indexOf('i') > -1 : false;
- unicode = flags ? flags.indexOf('u') > -1 : false;
- assign(tree, processTerm(tree));
- return generate(tree);
- };
- },{"./data/character-class-escape-sets.js":473,"./data/iu-mappings.json":474,"regenerate":475,"regjsgen":476,"regjsparser":477}],479:[function(require,module,exports){
- 'use strict';
- var isFinite = require('is-finite');
- module.exports = function (str, n) {
- if (typeof str !== 'string') {
- throw new TypeError('Expected a string as the first argument');
- }
- if (n < 0 || !isFinite(n)) {
- throw new TypeError('Expected a finite positive number');
- }
- var ret = '';
- do {
- if (n & 1) {
- ret += str;
- }
- str += str;
- } while (n = n >> 1);
- return ret;
- };
- },{"is-finite":480}],480:[function(require,module,exports){
- arguments[4][318][0].apply(exports,arguments)
- },{"dup":318}],481:[function(require,module,exports){
- 'use strict';
- module.exports = /^#!.*/;
- },{}],482:[function(require,module,exports){
- 'use strict';
- module.exports = function (str) {
- var isExtendedLengthPath = /^\\\\\?\\/.test(str);
- var hasNonAscii = /[^\x00-\x80]+/.test(str);
- if (isExtendedLengthPath || hasNonAscii) {
- return str;
- }
- return str.replace(/\\/g, '/');
- };
- },{}],483:[function(require,module,exports){
- /*
- * Copyright 2009-2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE.txt or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
- exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
- exports.SourceNode = require('./source-map/source-node').SourceNode;
- },{"./source-map/source-map-consumer":489,"./source-map/source-map-generator":490,"./source-map/source-node":491}],484:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- var util = require('./util');
- /**
- * A data structure which is a combination of an array and a set. Adding a new
- * member is O(1), testing for membership is O(1), and finding the index of an
- * element is O(1). Removing elements from the set is not supported. Only
- * strings are supported for membership.
- */
- function ArraySet() {
- this._array = [];
- this._set = {};
- }
- /**
- * Static method for creating ArraySet instances from an existing array.
- */
- ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
- var set = new ArraySet();
- for (var i = 0, len = aArray.length; i < len; i++) {
- set.add(aArray[i], aAllowDuplicates);
- }
- return set;
- };
- /**
- * Add the given string to this set.
- *
- * @param String aStr
- */
- ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
- var isDuplicate = this.has(aStr);
- var idx = this._array.length;
- if (!isDuplicate || aAllowDuplicates) {
- this._array.push(aStr);
- }
- if (!isDuplicate) {
- this._set[util.toSetString(aStr)] = idx;
- }
- };
- /**
- * Is the given string a member of this set?
- *
- * @param String aStr
- */
- ArraySet.prototype.has = function ArraySet_has(aStr) {
- return Object.prototype.hasOwnProperty.call(this._set,
- util.toSetString(aStr));
- };
- /**
- * What is the index of the given string in the array?
- *
- * @param String aStr
- */
- ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
- if (this.has(aStr)) {
- return this._set[util.toSetString(aStr)];
- }
- throw new Error('"' + aStr + '" is not in the set.');
- };
- /**
- * What is the element at the given index?
- *
- * @param Number aIdx
- */
- ArraySet.prototype.at = function ArraySet_at(aIdx) {
- if (aIdx >= 0 && aIdx < this._array.length) {
- return this._array[aIdx];
- }
- throw new Error('No element indexed by ' + aIdx);
- };
- /**
- * Returns the array representation of this set (which has the proper indices
- * indicated by indexOf). Note that this is a copy of the internal array used
- * for storing the members so that no one can mess with internal state.
- */
- ArraySet.prototype.toArray = function ArraySet_toArray() {
- return this._array.slice();
- };
- exports.ArraySet = ArraySet;
- });
- },{"./util":492,"amdefine":493}],485:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- *
- * Based on the Base 64 VLQ implementation in Closure Compiler:
- * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
- *
- * Copyright 2011 The Closure Compiler Authors. All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- var base64 = require('./base64');
- // A single base 64 digit can contain 6 bits of data. For the base 64 variable
- // length quantities we use in the source map spec, the first bit is the sign,
- // the next four bits are the actual value, and the 6th bit is the
- // continuation bit. The continuation bit tells us whether there are more
- // digits in this value following this digit.
- //
- // Continuation
- // | Sign
- // | |
- // V V
- // 101011
- var VLQ_BASE_SHIFT = 5;
- // binary: 100000
- var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
- // binary: 011111
- var VLQ_BASE_MASK = VLQ_BASE - 1;
- // binary: 100000
- var VLQ_CONTINUATION_BIT = VLQ_BASE;
- /**
- * Converts from a two-complement value to a value where the sign bit is
- * placed in the least significant bit. For example, as decimals:
- * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
- * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
- */
- function toVLQSigned(aValue) {
- return aValue < 0
- ? ((-aValue) << 1) + 1
- : (aValue << 1) + 0;
- }
- /**
- * Converts to a two-complement value from a value where the sign bit is
- * placed in the least significant bit. For example, as decimals:
- * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
- * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
- */
- function fromVLQSigned(aValue) {
- var isNegative = (aValue & 1) === 1;
- var shifted = aValue >> 1;
- return isNegative
- ? -shifted
- : shifted;
- }
- /**
- * Returns the base 64 VLQ encoded value.
- */
- exports.encode = function base64VLQ_encode(aValue) {
- var encoded = "";
- var digit;
- var vlq = toVLQSigned(aValue);
- do {
- digit = vlq & VLQ_BASE_MASK;
- vlq >>>= VLQ_BASE_SHIFT;
- if (vlq > 0) {
- // There are still more digits in this value, so we must make sure the
- // continuation bit is marked.
- digit |= VLQ_CONTINUATION_BIT;
- }
- encoded += base64.encode(digit);
- } while (vlq > 0);
- return encoded;
- };
- /**
- * Decodes the next base 64 VLQ value from the given string and returns the
- * value and the rest of the string via the out parameter.
- */
- exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
- var strLen = aStr.length;
- var result = 0;
- var shift = 0;
- var continuation, digit;
- do {
- if (aIndex >= strLen) {
- throw new Error("Expected more digits in base 64 VLQ value.");
- }
- digit = base64.decode(aStr.charAt(aIndex++));
- continuation = !!(digit & VLQ_CONTINUATION_BIT);
- digit &= VLQ_BASE_MASK;
- result = result + (digit << shift);
- shift += VLQ_BASE_SHIFT;
- } while (continuation);
- aOutParam.value = fromVLQSigned(result);
- aOutParam.rest = aIndex;
- };
- });
- },{"./base64":486,"amdefine":493}],486:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- var charToIntMap = {};
- var intToCharMap = {};
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- .split('')
- .forEach(function (ch, index) {
- charToIntMap[ch] = index;
- intToCharMap[index] = ch;
- });
- /**
- * Encode an integer in the range of 0 to 63 to a single base 64 digit.
- */
- exports.encode = function base64_encode(aNumber) {
- if (aNumber in intToCharMap) {
- return intToCharMap[aNumber];
- }
- throw new TypeError("Must be between 0 and 63: " + aNumber);
- };
- /**
- * Decode a single base 64 digit to an integer.
- */
- exports.decode = function base64_decode(aChar) {
- if (aChar in charToIntMap) {
- return charToIntMap[aChar];
- }
- throw new TypeError("Not a valid base 64 digit: " + aChar);
- };
- });
- },{"amdefine":493}],487:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- exports.GREATEST_LOWER_BOUND = 1;
- exports.LEAST_UPPER_BOUND = 2;
- /**
- * Recursive implementation of binary search.
- *
- * @param aLow Indices here and lower do not contain the needle.
- * @param aHigh Indices here and higher do not contain the needle.
- * @param aNeedle The element being searched for.
- * @param aHaystack The non-empty array being searched.
- * @param aCompare Function which takes two elements and returns -1, 0, or 1.
- * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
- * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- */
- function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
- // This function terminates when one of the following is true:
- //
- // 1. We find the exact element we are looking for.
- //
- // 2. We did not find the exact element, but we can return the index of
- // the next-closest element.
- //
- // 3. We did not find the exact element, and there is no next-closest
- // element than the one we are searching for, so we return -1.
- var mid = Math.floor((aHigh - aLow) / 2) + aLow;
- var cmp = aCompare(aNeedle, aHaystack[mid], true);
- if (cmp === 0) {
- // Found the element we are looking for.
- return mid;
- }
- else if (cmp > 0) {
- // Our needle is greater than aHaystack[mid].
- if (aHigh - mid > 1) {
- // The element is in the upper half.
- return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
- }
- // The exact needle element was not found in this haystack. Determine if
- // we are in termination case (3) or (2) and return the appropriate thing.
- if (aBias == exports.LEAST_UPPER_BOUND) {
- return aHigh < aHaystack.length ? aHigh : -1;
- } else {
- return mid;
- }
- }
- else {
- // Our needle is less than aHaystack[mid].
- if (mid - aLow > 1) {
- // The element is in the lower half.
- return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
- }
- // we are in termination case (3) or (2) and return the appropriate thing.
- if (aBias == exports.LEAST_UPPER_BOUND) {
- return mid;
- } else {
- return aLow < 0 ? -1 : aLow;
- }
- }
- }
- /**
- * This is an implementation of binary search which will always try and return
- * the index of the closest element if there is no exact hit. This is because
- * mappings between original and generated line/col pairs are single points,
- * and there is an implicit region between each of them, so a miss just means
- * that you aren't on the very start of a region.
- *
- * @param aNeedle The element you are looking for.
- * @param aHaystack The array that is being searched.
- * @param aCompare A function which takes the needle and an element in the
- * array and returns -1, 0, or 1 depending on whether the needle is less
- * than, equal to, or greater than the element, respectively.
- * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
- * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
- */
- exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
- if (aHaystack.length === 0) {
- return -1;
- }
- var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
- aCompare, aBias || exports.GREATEST_LOWER_BOUND);
- if (index < 0) {
- return -1;
- }
- // We have found either the exact element, or the next-closest element than
- // the one we are searching for. However, there may be more than one such
- // element. Make sure we always return the smallest of these.
- while (index - 1 >= 0) {
- if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
- break;
- }
- --index;
- }
- return index;
- };
- });
- },{"amdefine":493}],488:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2014 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- var util = require('./util');
- /**
- * Determine whether mappingB is after mappingA with respect to generated
- * position.
- */
- function generatedPositionAfter(mappingA, mappingB) {
- // Optimized for most common case
- var lineA = mappingA.generatedLine;
- var lineB = mappingB.generatedLine;
- var columnA = mappingA.generatedColumn;
- var columnB = mappingB.generatedColumn;
- return lineB > lineA || lineB == lineA && columnB >= columnA ||
- util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
- }
- /**
- * A data structure to provide a sorted view of accumulated mappings in a
- * performance conscious manner. It trades a neglibable overhead in general
- * case for a large speedup in case of mappings being added in order.
- */
- function MappingList() {
- this._array = [];
- this._sorted = true;
- // Serves as infimum
- this._last = {generatedLine: -1, generatedColumn: 0};
- }
- /**
- * Iterate through internal items. This method takes the same arguments that
- * `Array.prototype.forEach` takes.
- *
- * NOTE: The order of the mappings is NOT guaranteed.
- */
- MappingList.prototype.unsortedForEach =
- function MappingList_forEach(aCallback, aThisArg) {
- this._array.forEach(aCallback, aThisArg);
- };
- /**
- * Add the given source mapping.
- *
- * @param Object aMapping
- */
- MappingList.prototype.add = function MappingList_add(aMapping) {
- var mapping;
- if (generatedPositionAfter(this._last, aMapping)) {
- this._last = aMapping;
- this._array.push(aMapping);
- } else {
- this._sorted = false;
- this._array.push(aMapping);
- }
- };
- /**
- * Returns the flat, sorted array of mappings. The mappings are sorted by
- * generated position.
- *
- * WARNING: This method returns internal data without copying, for
- * performance. The return value must NOT be mutated, and should be treated as
- * an immutable borrow. If you want to take ownership, you must make your own
- * copy.
- */
- MappingList.prototype.toArray = function MappingList_toArray() {
- if (!this._sorted) {
- this._array.sort(util.compareByGeneratedPositions);
- this._sorted = true;
- }
- return this._array;
- };
- exports.MappingList = MappingList;
- });
- },{"./util":492,"amdefine":493}],489:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- var util = require('./util');
- var binarySearch = require('./binary-search');
- var ArraySet = require('./array-set').ArraySet;
- var base64VLQ = require('./base64-vlq');
- function SourceMapConsumer(aSourceMap) {
- var sourceMap = aSourceMap;
- if (typeof aSourceMap === 'string') {
- sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
- }
- return sourceMap.sections != null
- ? new IndexedSourceMapConsumer(sourceMap)
- : new BasicSourceMapConsumer(sourceMap);
- }
- SourceMapConsumer.fromSourceMap = function(aSourceMap) {
- return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
- }
- /**
- * The version of the source mapping spec that we are consuming.
- */
- SourceMapConsumer.prototype._version = 3;
- // `__generatedMappings` and `__originalMappings` are arrays that hold the
- // parsed mapping coordinates from the source map's "mappings" attribute. They
- // are lazily instantiated, accessed via the `_generatedMappings` and
- // `_originalMappings` getters respectively, and we only parse the mappings
- // and create these arrays once queried for a source location. We jump through
- // these hoops because there can be many thousands of mappings, and parsing
- // them is expensive, so we only want to do it if we must.
- //
- // Each object in the arrays is of the form:
- //
- // {
- // generatedLine: The line number in the generated code,
- // generatedColumn: The column number in the generated code,
- // source: The path to the original source file that generated this
- // chunk of code,
- // originalLine: The line number in the original source that
- // corresponds to this chunk of generated code,
- // originalColumn: The column number in the original source that
- // corresponds to this chunk of generated code,
- // name: The name of the original symbol which generated this chunk of
- // code.
- // }
- //
- // All properties except for `generatedLine` and `generatedColumn` can be
- // `null`.
- //
- // `_generatedMappings` is ordered by the generated positions.
- //
- // `_originalMappings` is ordered by the original positions.
- SourceMapConsumer.prototype.__generatedMappings = null;
- Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
- get: function () {
- if (!this.__generatedMappings) {
- this.__generatedMappings = [];
- this.__originalMappings = [];
- this._parseMappings(this._mappings, this.sourceRoot);
- }
- return this.__generatedMappings;
- }
- });
- SourceMapConsumer.prototype.__originalMappings = null;
- Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
- get: function () {
- if (!this.__originalMappings) {
- this.__generatedMappings = [];
- this.__originalMappings = [];
- this._parseMappings(this._mappings, this.sourceRoot);
- }
- return this.__originalMappings;
- }
- });
- SourceMapConsumer.prototype._nextCharIsMappingSeparator =
- function SourceMapConsumer_nextCharIsMappingSeparator(aStr, index) {
- var c = aStr.charAt(index);
- return c === ";" || c === ",";
- };
- /**
- * Parse the mappings in a string in to a data structure which we can easily
- * query (the ordered arrays in the `this.__generatedMappings` and
- * `this.__originalMappings` properties).
- */
- SourceMapConsumer.prototype._parseMappings =
- function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
- throw new Error("Subclasses must implement _parseMappings");
- };
- SourceMapConsumer.GENERATED_ORDER = 1;
- SourceMapConsumer.ORIGINAL_ORDER = 2;
- SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
- SourceMapConsumer.LEAST_UPPER_BOUND = 2;
- /**
- * Iterate over each mapping between an original source/line/column and a
- * generated line/column in this source map.
- *
- * @param Function aCallback
- * The function that is called with each mapping.
- * @param Object aContext
- * Optional. If specified, this object will be the value of `this` every
- * time that `aCallback` is called.
- * @param aOrder
- * Either `SourceMapConsumer.GENERATED_ORDER` or
- * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
- * iterate over the mappings sorted by the generated file's line/column
- * order or the original's source/line/column order, respectively. Defaults to
- * `SourceMapConsumer.GENERATED_ORDER`.
- */
- SourceMapConsumer.prototype.eachMapping =
- function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
- var context = aContext || null;
- var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
- var mappings;
- switch (order) {
- case SourceMapConsumer.GENERATED_ORDER:
- mappings = this._generatedMappings;
- break;
- case SourceMapConsumer.ORIGINAL_ORDER:
- mappings = this._originalMappings;
- break;
- default:
- throw new Error("Unknown order of iteration.");
- }
- var sourceRoot = this.sourceRoot;
- mappings.map(function (mapping) {
- var source = mapping.source;
- if (source != null && sourceRoot != null) {
- source = util.join(sourceRoot, source);
- }
- return {
- source: source,
- generatedLine: mapping.generatedLine,
- generatedColumn: mapping.generatedColumn,
- originalLine: mapping.originalLine,
- originalColumn: mapping.originalColumn,
- name: mapping.name
- };
- }).forEach(aCallback, context);
- };
- /**
- * Returns all generated line and column information for the original source,
- * line, and column provided. If no column is provided, returns all mappings
- * corresponding to a single line. Otherwise, returns all mappings
- * corresponding to a single line and column.
- *
- * The only argument is an object with the following properties:
- *
- * - source: The filename of the original source.
- * - line: The line number in the original source.
- * - column: Optional. the column number in the original source.
- *
- * and an array of objects is returned, each with the following properties:
- *
- * - line: The line number in the generated source, or null.
- * - column: The column number in the generated source, or null.
- */
- SourceMapConsumer.prototype.allGeneratedPositionsFor =
- function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
- // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
- // returns the index of the closest mapping less than the needle. By
- // setting needle.originalColumn to 0, we thus find the last mapping for
- // the given line, provided such a mapping exists.
- var needle = {
- source: util.getArg(aArgs, 'source'),
- originalLine: util.getArg(aArgs, 'line'),
- originalColumn: util.getArg(aArgs, 'column', 0)
- };
- if (this.sourceRoot != null) {
- needle.source = util.relative(this.sourceRoot, needle.source);
- }
- var mappings = [];
- var index = this._findMapping(needle,
- this._originalMappings,
- "originalLine",
- "originalColumn",
- util.compareByOriginalPositions,
- binarySearch.LEAST_UPPER_BOUND);
- if (index >= 0) {
- var mapping = this._originalMappings[index];
- var originalLine = mapping.originalLine;
- var originalColumn = mapping.originalColumn;
- // Iterate until either we run out of mappings, or we run into
- // a mapping for a different line. Since mappings are sorted, this is
- // guaranteed to find all mappings for the line we are searching for.
- while (mapping && mapping.originalLine === originalLine &&
- (aArgs.column === undefined ||
- mapping.originalColumn === originalColumn)) {
- mappings.push({
- line: util.getArg(mapping, 'generatedLine', null),
- column: util.getArg(mapping, 'generatedColumn', null),
- lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
- });
- mapping = this._originalMappings[++index];
- }
- }
- return mappings;
- };
- exports.SourceMapConsumer = SourceMapConsumer;
- /**
- * A BasicSourceMapConsumer instance represents a parsed source map which we can
- * query for information about the original file positions by giving it a file
- * position in the generated source.
- *
- * The only parameter is the raw source map (either as a JSON string, or
- * already parsed to an object). According to the spec, source maps have the
- * following attributes:
- *
- * - version: Which version of the source map spec this map is following.
- * - sources: An array of URLs to the original source files.
- * - names: An array of identifiers which can be referrenced by individual mappings.
- * - sourceRoot: Optional. The URL root from which all sources are relative.
- * - sourcesContent: Optional. An array of contents of the original source files.
- * - mappings: A string of base64 VLQs which contain the actual mappings.
- * - file: Optional. The generated file this source map is associated with.
- *
- * Here is an example source map, taken from the source map spec[0]:
- *
- * {
- * version : 3,
- * file: "out.js",
- * sourceRoot : "",
- * sources: ["foo.js", "bar.js"],
- * names: ["src", "maps", "are", "fun"],
- * mappings: "AA,AB;;ABCDE;"
- * }
- *
- * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
- */
- function BasicSourceMapConsumer(aSourceMap) {
- var sourceMap = aSourceMap;
- if (typeof aSourceMap === 'string') {
- sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
- }
- var version = util.getArg(sourceMap, 'version');
- var sources = util.getArg(sourceMap, 'sources');
- // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
- // requires the array) to play nice here.
- var names = util.getArg(sourceMap, 'names', []);
- var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
- var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
- var mappings = util.getArg(sourceMap, 'mappings');
- var file = util.getArg(sourceMap, 'file', null);
- // Once again, Sass deviates from the spec and supplies the version as a
- // string rather than a number, so we use loose equality checking here.
- if (version != this._version) {
- throw new Error('Unsupported version: ' + version);
- }
- // Some source maps produce relative source paths like "./foo.js" instead of
- // "foo.js". Normalize these first so that future comparisons will succeed.
- // See bugzil.la/1090768.
- sources = sources.map(util.normalize);
- // Pass `true` below to allow duplicate names and sources. While source maps
- // are intended to be compressed and deduplicated, the TypeScript compiler
- // sometimes generates source maps with duplicates in them. See Github issue
- // #72 and bugzil.la/889492.
- this._names = ArraySet.fromArray(names, true);
- this._sources = ArraySet.fromArray(sources, true);
- this.sourceRoot = sourceRoot;
- this.sourcesContent = sourcesContent;
- this._mappings = mappings;
- this.file = file;
- }
- BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
- BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
- /**
- * Create a BasicSourceMapConsumer from a SourceMapGenerator.
- *
- * @param SourceMapGenerator aSourceMap
- * The source map that will be consumed.
- * @returns BasicSourceMapConsumer
- */
- BasicSourceMapConsumer.fromSourceMap =
- function SourceMapConsumer_fromSourceMap(aSourceMap) {
- var smc = Object.create(BasicSourceMapConsumer.prototype);
- smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
- smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
- smc.sourceRoot = aSourceMap._sourceRoot;
- smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
- smc.sourceRoot);
- smc.file = aSourceMap._file;
- smc.__generatedMappings = aSourceMap._mappings.toArray().slice();
- smc.__originalMappings = aSourceMap._mappings.toArray().slice()
- .sort(util.compareByOriginalPositions);
- return smc;
- };
- /**
- * The version of the source mapping spec that we are consuming.
- */
- BasicSourceMapConsumer.prototype._version = 3;
- /**
- * The list of original sources.
- */
- Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
- get: function () {
- return this._sources.toArray().map(function (s) {
- return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
- }, this);
- }
- });
- /**
- * Parse the mappings in a string in to a data structure which we can easily
- * query (the ordered arrays in the `this.__generatedMappings` and
- * `this.__originalMappings` properties).
- */
- BasicSourceMapConsumer.prototype._parseMappings =
- function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
- var generatedLine = 1;
- var previousGeneratedColumn = 0;
- var previousOriginalLine = 0;
- var previousOriginalColumn = 0;
- var previousSource = 0;
- var previousName = 0;
- var length = aStr.length;
- var index = 0;
- var cachedValues = {};
- var temp = {};
- var mapping, str, values, end, value;
- while (index < length) {
- if (aStr.charAt(index) === ';') {
- generatedLine++;
- ++index;
- previousGeneratedColumn = 0;
- }
- else if (aStr.charAt(index) === ',') {
- ++index;
- }
- else {
- mapping = {};
- mapping.generatedLine = generatedLine;
- // Because each offset is encoded relative to the previous one,
- // many segments often have the same encoding. We can exploit this
- // fact by caching the parsed variable length fields of each segment,
- // allowing us to avoid a second parse if we encounter the same
- // segment again.
- for (end = index; end < length; ++end) {
- if (this._nextCharIsMappingSeparator(aStr, end)) {
- break;
- }
- }
- str = aStr.slice(index, end);
- values = cachedValues[str];
- if (values) {
- index += str.length;
- } else {
- values = [];
- while (index < end) {
- base64VLQ.decode(aStr, index, temp);
- value = temp.value;
- index = temp.rest;
- values.push(value);
- }
- cachedValues[str] = values;
- }
- // Generated column.
- mapping.generatedColumn = previousGeneratedColumn + values[0];
- previousGeneratedColumn = mapping.generatedColumn;
- if (values.length > 1) {
- // Original source.
- mapping.source = this._sources.at(previousSource + values[1]);
- previousSource += values[1];
- if (values.length === 2) {
- throw new Error('Found a source, but no line and column');
- }
- // Original line.
- mapping.originalLine = previousOriginalLine + values[2];
- previousOriginalLine = mapping.originalLine;
- // Lines are stored 0-based
- mapping.originalLine += 1;
- if (values.length === 3) {
- throw new Error('Found a source and line, but no column');
- }
- // Original column.
- mapping.originalColumn = previousOriginalColumn + values[3];
- previousOriginalColumn = mapping.originalColumn;
- if (values.length > 4) {
- // Original name.
- mapping.name = this._names.at(previousName + values[4]);
- previousName += values[4];
- }
- }
- this.__generatedMappings.push(mapping);
- if (typeof mapping.originalLine === 'number') {
- this.__originalMappings.push(mapping);
- }
- }
- }
- this.__generatedMappings.sort(util.compareByGeneratedPositions);
- this.__originalMappings.sort(util.compareByOriginalPositions);
- };
- /**
- * Find the mapping that best matches the hypothetical "needle" mapping that
- * we are searching for in the given "haystack" of mappings.
- */
- BasicSourceMapConsumer.prototype._findMapping =
- function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
- aColumnName, aComparator, aBias) {
- // To return the position we are searching for, we must first find the
- // mapping for the given position and then return the opposite position it
- // points to. Because the mappings are sorted, we can use binary search to
- // find the best mapping.
- if (aNeedle[aLineName] <= 0) {
- throw new TypeError('Line must be greater than or equal to 1, got '
- + aNeedle[aLineName]);
- }
- if (aNeedle[aColumnName] < 0) {
- throw new TypeError('Column must be greater than or equal to 0, got '
- + aNeedle[aColumnName]);
- }
- return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
- };
- /**
- * Compute the last column for each generated mapping. The last column is
- * inclusive.
- */
- BasicSourceMapConsumer.prototype.computeColumnSpans =
- function SourceMapConsumer_computeColumnSpans() {
- for (var index = 0; index < this._generatedMappings.length; ++index) {
- var mapping = this._generatedMappings[index];
- // Mappings do not contain a field for the last generated columnt. We
- // can come up with an optimistic estimate, however, by assuming that
- // mappings are contiguous (i.e. given two consecutive mappings, the
- // first mapping ends where the second one starts).
- if (index + 1 < this._generatedMappings.length) {
- var nextMapping = this._generatedMappings[index + 1];
- if (mapping.generatedLine === nextMapping.generatedLine) {
- mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
- continue;
- }
- }
- // The last mapping for each line spans the entire line.
- mapping.lastGeneratedColumn = Infinity;
- }
- };
- /**
- * Returns the original source, line, and column information for the generated
- * source's line and column positions provided. The only argument is an object
- * with the following properties:
- *
- * - line: The line number in the generated source.
- * - column: The column number in the generated source.
- * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
- * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
- *
- * and an object is returned with the following properties:
- *
- * - source: The original source file, or null.
- * - line: The line number in the original source, or null.
- * - column: The column number in the original source, or null.
- * - name: The original identifier, or null.
- */
- BasicSourceMapConsumer.prototype.originalPositionFor =
- function SourceMapConsumer_originalPositionFor(aArgs) {
- var needle = {
- generatedLine: util.getArg(aArgs, 'line'),
- generatedColumn: util.getArg(aArgs, 'column')
- };
- var index = this._findMapping(
- needle,
- this._generatedMappings,
- "generatedLine",
- "generatedColumn",
- util.compareByGeneratedPositions,
- util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
- );
- if (index >= 0) {
- var mapping = this._generatedMappings[index];
- if (mapping.generatedLine === needle.generatedLine) {
- var source = util.getArg(mapping, 'source', null);
- if (source != null && this.sourceRoot != null) {
- source = util.join(this.sourceRoot, source);
- }
- return {
- source: source,
- line: util.getArg(mapping, 'originalLine', null),
- column: util.getArg(mapping, 'originalColumn', null),
- name: util.getArg(mapping, 'name', null)
- };
- }
- }
- return {
- source: null,
- line: null,
- column: null,
- name: null
- };
- };
- /**
- * Returns the original source content. The only argument is the url of the
- * original source file. Returns null if no original source content is
- * availible.
- */
- BasicSourceMapConsumer.prototype.sourceContentFor =
- function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
- if (!this.sourcesContent) {
- return null;
- }
- if (this.sourceRoot != null) {
- aSource = util.relative(this.sourceRoot, aSource);
- }
- if (this._sources.has(aSource)) {
- return this.sourcesContent[this._sources.indexOf(aSource)];
- }
- var url;
- if (this.sourceRoot != null
- && (url = util.urlParse(this.sourceRoot))) {
- // XXX: file:// URIs and absolute paths lead to unexpected behavior for
- // many users. We can help them out when they expect file:// URIs to
- // behave like it would if they were running a local HTTP server. See
- // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
- var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
- if (url.scheme == "file"
- && this._sources.has(fileUriAbsPath)) {
- return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
- }
- if ((!url.path || url.path == "/")
- && this._sources.has("/" + aSource)) {
- return this.sourcesContent[this._sources.indexOf("/" + aSource)];
- }
- }
- // This function is used recursively from
- // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
- // don't want to throw if we can't find the source - we just want to
- // return null, so we provide a flag to exit gracefully.
- if (nullOnMissing) {
- return null;
- }
- else {
- throw new Error('"' + aSource + '" is not in the SourceMap.');
- }
- };
- /**
- * Returns the generated line and column information for the original source,
- * line, and column positions provided. The only argument is an object with
- * the following properties:
- *
- * - source: The filename of the original source.
- * - line: The line number in the original source.
- * - column: The column number in the original source.
- * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
- * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
- * closest element that is smaller than or greater than the one we are
- * searching for, respectively, if the exact element cannot be found.
- * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
- *
- * and an object is returned with the following properties:
- *
- * - line: The line number in the generated source, or null.
- * - column: The column number in the generated source, or null.
- */
- BasicSourceMapConsumer.prototype.generatedPositionFor =
- function SourceMapConsumer_generatedPositionFor(aArgs) {
- var needle = {
- source: util.getArg(aArgs, 'source'),
- originalLine: util.getArg(aArgs, 'line'),
- originalColumn: util.getArg(aArgs, 'column')
- };
- if (this.sourceRoot != null) {
- needle.source = util.relative(this.sourceRoot, needle.source);
- }
- var index = this._findMapping(
- needle,
- this._originalMappings,
- "originalLine",
- "originalColumn",
- util.compareByOriginalPositions,
- util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
- );
- if (index >= 0) {
- var mapping = this._originalMappings[index];
- if (mapping.source === needle.source) {
- return {
- line: util.getArg(mapping, 'generatedLine', null),
- column: util.getArg(mapping, 'generatedColumn', null),
- lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
- };
- }
- }
- return {
- line: null,
- column: null,
- lastColumn: null
- };
- };
- exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
- /**
- * An IndexedSourceMapConsumer instance represents a parsed source map which
- * we can query for information. It differs from BasicSourceMapConsumer in
- * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
- * input.
- *
- * The only parameter is a raw source map (either as a JSON string, or already
- * parsed to an object). According to the spec for indexed source maps, they
- * have the following attributes:
- *
- * - version: Which version of the source map spec this map is following.
- * - file: Optional. The generated file this source map is associated with.
- * - sections: A list of section definitions.
- *
- * Each value under the "sections" field has two fields:
- * - offset: The offset into the original specified at which this section
- * begins to apply, defined as an object with a "line" and "column"
- * field.
- * - map: A source map definition. This source map could also be indexed,
- * but doesn't have to be.
- *
- * Instead of the "map" field, it's also possible to have a "url" field
- * specifying a URL to retrieve a source map from, but that's currently
- * unsupported.
- *
- * Here's an example source map, taken from the source map spec[0], but
- * modified to omit a section which uses the "url" field.
- *
- * {
- * version : 3,
- * file: "app.js",
- * sections: [{
- * offset: {line:100, column:10},
- * map: {
- * version : 3,
- * file: "section.js",
- * sources: ["foo.js", "bar.js"],
- * names: ["src", "maps", "are", "fun"],
- * mappings: "AAAA,E;;ABCDE;"
- * }
- * }],
- * }
- *
- * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
- */
- function IndexedSourceMapConsumer(aSourceMap) {
- var sourceMap = aSourceMap;
- if (typeof aSourceMap === 'string') {
- sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
- }
- var version = util.getArg(sourceMap, 'version');
- var sections = util.getArg(sourceMap, 'sections');
- if (version != this._version) {
- throw new Error('Unsupported version: ' + version);
- }
- var lastOffset = {
- line: -1,
- column: 0
- };
- this._sections = sections.map(function (s) {
- if (s.url) {
- // The url field will require support for asynchronicity.
- // See https://github.com/mozilla/source-map/issues/16
- throw new Error('Support for url field in sections not implemented.');
- }
- var offset = util.getArg(s, 'offset');
- var offsetLine = util.getArg(offset, 'line');
- var offsetColumn = util.getArg(offset, 'column');
- if (offsetLine < lastOffset.line ||
- (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
- throw new Error('Section offsets must be ordered and non-overlapping.');
- }
- lastOffset = offset;
- return {
- generatedOffset: {
- // The offset fields are 0-based, but we use 1-based indices when
- // encoding/decoding from VLQ.
- generatedLine: offsetLine + 1,
- generatedColumn: offsetColumn + 1
- },
- consumer: new SourceMapConsumer(util.getArg(s, 'map'))
- }
- });
- }
- IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
- IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
- /**
- * The version of the source mapping spec that we are consuming.
- */
- IndexedSourceMapConsumer.prototype._version = 3;
- /**
- * The list of original sources.
- */
- Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
- get: function () {
- var sources = [];
- for (var i = 0; i < this._sections.length; i++) {
- for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
- sources.push(this._sections[i].consumer.sources[j]);
- }
- };
- return sources;
- }
- });
- /**
- * Returns the original source, line, and column information for the generated
- * source's line and column positions provided. The only argument is an object
- * with the following properties:
- *
- * - line: The line number in the generated source.
- * - column: The column number in the generated source.
- *
- * and an object is returned with the following properties:
- *
- * - source: The original source file, or null.
- * - line: The line number in the original source, or null.
- * - column: The column number in the original source, or null.
- * - name: The original identifier, or null.
- */
- IndexedSourceMapConsumer.prototype.originalPositionFor =
- function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
- var needle = {
- generatedLine: util.getArg(aArgs, 'line'),
- generatedColumn: util.getArg(aArgs, 'column')
- };
- // Find the section containing the generated position we're trying to map
- // to an original position.
- var sectionIndex = binarySearch.search(needle, this._sections,
- function(needle, section) {
- var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
- if (cmp) {
- return cmp;
- }
- return (needle.generatedColumn -
- section.generatedOffset.generatedColumn);
- });
- var section = this._sections[sectionIndex];
- if (!section) {
- return {
- source: null,
- line: null,
- column: null,
- name: null
- };
- }
- return section.consumer.originalPositionFor({
- line: needle.generatedLine -
- (section.generatedOffset.generatedLine - 1),
- column: needle.generatedColumn -
- (section.generatedOffset.generatedLine === needle.generatedLine
- ? section.generatedOffset.generatedColumn - 1
- : 0),
- bias: aArgs.bias
- });
- };
- /**
- * Returns the original source content. The only argument is the url of the
- * original source file. Returns null if no original source content is
- * available.
- */
- IndexedSourceMapConsumer.prototype.sourceContentFor =
- function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
- var content = section.consumer.sourceContentFor(aSource, true);
- if (content) {
- return content;
- }
- }
- if (nullOnMissing) {
- return null;
- }
- else {
- throw new Error('"' + aSource + '" is not in the SourceMap.');
- }
- };
- /**
- * Returns the generated line and column information for the original source,
- * line, and column positions provided. The only argument is an object with
- * the following properties:
- *
- * - source: The filename of the original source.
- * - line: The line number in the original source.
- * - column: The column number in the original source.
- *
- * and an object is returned with the following properties:
- *
- * - line: The line number in the generated source, or null.
- * - column: The column number in the generated source, or null.
- */
- IndexedSourceMapConsumer.prototype.generatedPositionFor =
- function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
- // Only consider this section if the requested source is in the list of
- // sources of the consumer.
- if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
- continue;
- }
- var generatedPosition = section.consumer.generatedPositionFor(aArgs);
- if (generatedPosition) {
- var ret = {
- line: generatedPosition.line +
- (section.generatedOffset.generatedLine - 1),
- column: generatedPosition.column +
- (section.generatedOffset.generatedLine === generatedPosition.line
- ? section.generatedOffset.generatedColumn - 1
- : 0)
- };
- return ret;
- }
- }
- return {
- line: null,
- column: null
- };
- };
- /**
- * Parse the mappings in a string in to a data structure which we can easily
- * query (the ordered arrays in the `this.__generatedMappings` and
- * `this.__originalMappings` properties).
- */
- IndexedSourceMapConsumer.prototype._parseMappings =
- function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
- this.__generatedMappings = [];
- this.__originalMappings = [];
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
- var sectionMappings = section.consumer._generatedMappings;
- for (var j = 0; j < sectionMappings.length; j++) {
- var mapping = sectionMappings[i];
- var source = mapping.source;
- var sourceRoot = section.consumer.sourceRoot;
- if (source != null && sourceRoot != null) {
- source = util.join(sourceRoot, source);
- }
- // The mappings coming from the consumer for the section have
- // generated positions relative to the start of the section, so we
- // need to offset them to be relative to the start of the concatenated
- // generated file.
- var adjustedMapping = {
- source: source,
- generatedLine: mapping.generatedLine +
- (section.generatedOffset.generatedLine - 1),
- generatedColumn: mapping.column +
- (section.generatedOffset.generatedLine === mapping.generatedLine)
- ? section.generatedOffset.generatedColumn - 1
- : 0,
- originalLine: mapping.originalLine,
- originalColumn: mapping.originalColumn,
- name: mapping.name
- };
- this.__generatedMappings.push(adjustedMapping);
- if (typeof adjustedMapping.originalLine === 'number') {
- this.__originalMappings.push(adjustedMapping);
- }
- };
- };
- this.__generatedMappings.sort(util.compareByGeneratedPositions);
- this.__originalMappings.sort(util.compareByOriginalPositions);
- };
- exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
- });
- },{"./array-set":484,"./base64-vlq":485,"./binary-search":487,"./util":492,"amdefine":493}],490:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- var base64VLQ = require('./base64-vlq');
- var util = require('./util');
- var ArraySet = require('./array-set').ArraySet;
- var MappingList = require('./mapping-list').MappingList;
- /**
- * An instance of the SourceMapGenerator represents a source map which is
- * being built incrementally. You may pass an object with the following
- * properties:
- *
- * - file: The filename of the generated source.
- * - sourceRoot: A root for all relative URLs in this source map.
- */
- function SourceMapGenerator(aArgs) {
- if (!aArgs) {
- aArgs = {};
- }
- this._file = util.getArg(aArgs, 'file', null);
- this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
- this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
- this._sources = new ArraySet();
- this._names = new ArraySet();
- this._mappings = new MappingList();
- this._sourcesContents = null;
- }
- SourceMapGenerator.prototype._version = 3;
- /**
- * Creates a new SourceMapGenerator based on a SourceMapConsumer
- *
- * @param aSourceMapConsumer The SourceMap.
- */
- SourceMapGenerator.fromSourceMap =
- function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
- var sourceRoot = aSourceMapConsumer.sourceRoot;
- var generator = new SourceMapGenerator({
- file: aSourceMapConsumer.file,
- sourceRoot: sourceRoot
- });
- aSourceMapConsumer.eachMapping(function (mapping) {
- var newMapping = {
- generated: {
- line: mapping.generatedLine,
- column: mapping.generatedColumn
- }
- };
- if (mapping.source != null) {
- newMapping.source = mapping.source;
- if (sourceRoot != null) {
- newMapping.source = util.relative(sourceRoot, newMapping.source);
- }
- newMapping.original = {
- line: mapping.originalLine,
- column: mapping.originalColumn
- };
- if (mapping.name != null) {
- newMapping.name = mapping.name;
- }
- }
- generator.addMapping(newMapping);
- });
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
- generator.setSourceContent(sourceFile, content);
- }
- });
- return generator;
- };
- /**
- * Add a single mapping from original source line and column to the generated
- * source's line and column for this source map being created. The mapping
- * object should have the following properties:
- *
- * - generated: An object with the generated line and column positions.
- * - original: An object with the original line and column positions.
- * - source: The original source file (relative to the sourceRoot).
- * - name: An optional original token name for this mapping.
- */
- SourceMapGenerator.prototype.addMapping =
- function SourceMapGenerator_addMapping(aArgs) {
- var generated = util.getArg(aArgs, 'generated');
- var original = util.getArg(aArgs, 'original', null);
- var source = util.getArg(aArgs, 'source', null);
- var name = util.getArg(aArgs, 'name', null);
- if (!this._skipValidation) {
- this._validateMapping(generated, original, source, name);
- }
- if (source != null && !this._sources.has(source)) {
- this._sources.add(source);
- }
- if (name != null && !this._names.has(name)) {
- this._names.add(name);
- }
- this._mappings.add({
- generatedLine: generated.line,
- generatedColumn: generated.column,
- originalLine: original != null && original.line,
- originalColumn: original != null && original.column,
- source: source,
- name: name
- });
- };
- /**
- * Set the source content for a source file.
- */
- SourceMapGenerator.prototype.setSourceContent =
- function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
- var source = aSourceFile;
- if (this._sourceRoot != null) {
- source = util.relative(this._sourceRoot, source);
- }
- if (aSourceContent != null) {
- // Add the source content to the _sourcesContents map.
- // Create a new _sourcesContents map if the property is null.
- if (!this._sourcesContents) {
- this._sourcesContents = {};
- }
- this._sourcesContents[util.toSetString(source)] = aSourceContent;
- } else if (this._sourcesContents) {
- // Remove the source file from the _sourcesContents map.
- // If the _sourcesContents map is empty, set the property to null.
- delete this._sourcesContents[util.toSetString(source)];
- if (Object.keys(this._sourcesContents).length === 0) {
- this._sourcesContents = null;
- }
- }
- };
- /**
- * Applies the mappings of a sub-source-map for a specific source file to the
- * source map being generated. Each mapping to the supplied source file is
- * rewritten using the supplied source map. Note: The resolution for the
- * resulting mappings is the minimium of this map and the supplied map.
- *
- * @param aSourceMapConsumer The source map to be applied.
- * @param aSourceFile Optional. The filename of the source file.
- * If omitted, SourceMapConsumer's file property will be used.
- * @param aSourceMapPath Optional. The dirname of the path to the source map
- * to be applied. If relative, it is relative to the SourceMapConsumer.
- * This parameter is needed when the two source maps aren't in the same
- * directory, and the source map to be applied contains relative source
- * paths. If so, those relative source paths need to be rewritten
- * relative to the SourceMapGenerator.
- */
- SourceMapGenerator.prototype.applySourceMap =
- function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
- var sourceFile = aSourceFile;
- // If aSourceFile is omitted, we will use the file property of the SourceMap
- if (aSourceFile == null) {
- if (aSourceMapConsumer.file == null) {
- throw new Error(
- 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
- 'or the source map\'s "file" property. Both were omitted.'
- );
- }
- sourceFile = aSourceMapConsumer.file;
- }
- var sourceRoot = this._sourceRoot;
- // Make "sourceFile" relative if an absolute Url is passed.
- if (sourceRoot != null) {
- sourceFile = util.relative(sourceRoot, sourceFile);
- }
- // Applying the SourceMap can add and remove items from the sources and
- // the names array.
- var newSources = new ArraySet();
- var newNames = new ArraySet();
- // Find mappings for the "sourceFile"
- this._mappings.unsortedForEach(function (mapping) {
- if (mapping.source === sourceFile && mapping.originalLine != null) {
- // Check if it can be mapped by the source map, then update the mapping.
- var original = aSourceMapConsumer.originalPositionFor({
- line: mapping.originalLine,
- column: mapping.originalColumn
- });
- if (original.source != null) {
- // Copy mapping
- mapping.source = original.source;
- if (aSourceMapPath != null) {
- mapping.source = util.join(aSourceMapPath, mapping.source)
- }
- if (sourceRoot != null) {
- mapping.source = util.relative(sourceRoot, mapping.source);
- }
- mapping.originalLine = original.line;
- mapping.originalColumn = original.column;
- if (original.name != null) {
- mapping.name = original.name;
- }
- }
- }
- var source = mapping.source;
- if (source != null && !newSources.has(source)) {
- newSources.add(source);
- }
- var name = mapping.name;
- if (name != null && !newNames.has(name)) {
- newNames.add(name);
- }
- }, this);
- this._sources = newSources;
- this._names = newNames;
- // Copy sourcesContents of applied map.
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
- if (aSourceMapPath != null) {
- sourceFile = util.join(aSourceMapPath, sourceFile);
- }
- if (sourceRoot != null) {
- sourceFile = util.relative(sourceRoot, sourceFile);
- }
- this.setSourceContent(sourceFile, content);
- }
- }, this);
- };
- /**
- * A mapping can have one of the three levels of data:
- *
- * 1. Just the generated position.
- * 2. The Generated position, original position, and original source.
- * 3. Generated and original position, original source, as well as a name
- * token.
- *
- * To maintain consistency, we validate that any new mapping being added falls
- * in to one of these categories.
- */
- SourceMapGenerator.prototype._validateMapping =
- function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
- aName) {
- if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
- && aGenerated.line > 0 && aGenerated.column >= 0
- && !aOriginal && !aSource && !aName) {
- // Case 1.
- return;
- }
- else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
- && aOriginal && 'line' in aOriginal && 'column' in aOriginal
- && aGenerated.line > 0 && aGenerated.column >= 0
- && aOriginal.line > 0 && aOriginal.column >= 0
- && aSource) {
- // Cases 2 and 3.
- return;
- }
- else {
- throw new Error('Invalid mapping: ' + JSON.stringify({
- generated: aGenerated,
- source: aSource,
- original: aOriginal,
- name: aName
- }));
- }
- };
- /**
- * Serialize the accumulated mappings in to the stream of base 64 VLQs
- * specified by the source map format.
- */
- SourceMapGenerator.prototype._serializeMappings =
- function SourceMapGenerator_serializeMappings() {
- var previousGeneratedColumn = 0;
- var previousGeneratedLine = 1;
- var previousOriginalColumn = 0;
- var previousOriginalLine = 0;
- var previousName = 0;
- var previousSource = 0;
- var result = '';
- var mapping;
- var mappings = this._mappings.toArray();
- for (var i = 0, len = mappings.length; i < len; i++) {
- mapping = mappings[i];
- if (mapping.generatedLine !== previousGeneratedLine) {
- previousGeneratedColumn = 0;
- while (mapping.generatedLine !== previousGeneratedLine) {
- result += ';';
- previousGeneratedLine++;
- }
- }
- else {
- if (i > 0) {
- if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {
- continue;
- }
- result += ',';
- }
- }
- result += base64VLQ.encode(mapping.generatedColumn
- - previousGeneratedColumn);
- previousGeneratedColumn = mapping.generatedColumn;
- if (mapping.source != null) {
- result += base64VLQ.encode(this._sources.indexOf(mapping.source)
- - previousSource);
- previousSource = this._sources.indexOf(mapping.source);
- // lines are stored 0-based in SourceMap spec version 3
- result += base64VLQ.encode(mapping.originalLine - 1
- - previousOriginalLine);
- previousOriginalLine = mapping.originalLine - 1;
- result += base64VLQ.encode(mapping.originalColumn
- - previousOriginalColumn);
- previousOriginalColumn = mapping.originalColumn;
- if (mapping.name != null) {
- result += base64VLQ.encode(this._names.indexOf(mapping.name)
- - previousName);
- previousName = this._names.indexOf(mapping.name);
- }
- }
- }
- return result;
- };
- SourceMapGenerator.prototype._generateSourcesContent =
- function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
- return aSources.map(function (source) {
- if (!this._sourcesContents) {
- return null;
- }
- if (aSourceRoot != null) {
- source = util.relative(aSourceRoot, source);
- }
- var key = util.toSetString(source);
- return Object.prototype.hasOwnProperty.call(this._sourcesContents,
- key)
- ? this._sourcesContents[key]
- : null;
- }, this);
- };
- /**
- * Externalize the source map.
- */
- SourceMapGenerator.prototype.toJSON =
- function SourceMapGenerator_toJSON() {
- var map = {
- version: this._version,
- sources: this._sources.toArray(),
- names: this._names.toArray(),
- mappings: this._serializeMappings()
- };
- if (this._file != null) {
- map.file = this._file;
- }
- if (this._sourceRoot != null) {
- map.sourceRoot = this._sourceRoot;
- }
- if (this._sourcesContents) {
- map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
- }
- return map;
- };
- /**
- * Render the source map being generated to a string.
- */
- SourceMapGenerator.prototype.toString =
- function SourceMapGenerator_toString() {
- return JSON.stringify(this.toJSON());
- };
- exports.SourceMapGenerator = SourceMapGenerator;
- });
- },{"./array-set":484,"./base64-vlq":485,"./mapping-list":488,"./util":492,"amdefine":493}],491:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
- var util = require('./util');
- // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
- // operating systems these days (capturing the result).
- var REGEX_NEWLINE = /(\r?\n)/;
- // Newline character code for charCodeAt() comparisons
- var NEWLINE_CODE = 10;
- // Private symbol for identifying `SourceNode`s when multiple versions of
- // the source-map library are loaded. This MUST NOT CHANGE across
- // versions!
- var isSourceNode = "$$$isSourceNode$$$";
- /**
- * SourceNodes provide a way to abstract over interpolating/concatenating
- * snippets of generated JavaScript source code while maintaining the line and
- * column information associated with the original source code.
- *
- * @param aLine The original line number.
- * @param aColumn The original column number.
- * @param aSource The original source's filename.
- * @param aChunks Optional. An array of strings which are snippets of
- * generated JS, or other SourceNodes.
- * @param aName The original identifier.
- */
- function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
- this.children = [];
- this.sourceContents = {};
- this.line = aLine == null ? null : aLine;
- this.column = aColumn == null ? null : aColumn;
- this.source = aSource == null ? null : aSource;
- this.name = aName == null ? null : aName;
- this[isSourceNode] = true;
- if (aChunks != null) this.add(aChunks);
- }
- /**
- * Creates a SourceNode from generated code and a SourceMapConsumer.
- *
- * @param aGeneratedCode The generated code
- * @param aSourceMapConsumer The SourceMap for the generated code
- * @param aRelativePath Optional. The path that relative sources in the
- * SourceMapConsumer should be relative to.
- */
- SourceNode.fromStringWithSourceMap =
- function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
- // The SourceNode we want to fill with the generated code
- // and the SourceMap
- var node = new SourceNode();
- // All even indices of this array are one line of the generated code,
- // while all odd indices are the newlines between two adjacent lines
- // (since `REGEX_NEWLINE` captures its match).
- // Processed fragments are removed from this array, by calling `shiftNextLine`.
- var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
- var shiftNextLine = function() {
- var lineContents = remainingLines.shift();
- // The last line of a file might not have a newline.
- var newLine = remainingLines.shift() || "";
- return lineContents + newLine;
- };
- // We need to remember the position of "remainingLines"
- var lastGeneratedLine = 1, lastGeneratedColumn = 0;
- // The generate SourceNodes we need a code range.
- // To extract it current and last mapping is used.
- // Here we store the last mapping.
- var lastMapping = null;
- aSourceMapConsumer.eachMapping(function (mapping) {
- if (lastMapping !== null) {
- // We add the code from "lastMapping" to "mapping":
- // First check if there is a new line in between.
- if (lastGeneratedLine < mapping.generatedLine) {
- var code = "";
- // Associate first line with "lastMapping"
- addMappingWithCode(lastMapping, shiftNextLine());
- lastGeneratedLine++;
- lastGeneratedColumn = 0;
- // The remaining code is added without mapping
- } else {
- // There is no new line in between.
- // Associate the code between "lastGeneratedColumn" and
- // "mapping.generatedColumn" with "lastMapping"
- var nextLine = remainingLines[0];
- var code = nextLine.substr(0, mapping.generatedColumn -
- lastGeneratedColumn);
- remainingLines[0] = nextLine.substr(mapping.generatedColumn -
- lastGeneratedColumn);
- lastGeneratedColumn = mapping.generatedColumn;
- addMappingWithCode(lastMapping, code);
- // No more remaining code, continue
- lastMapping = mapping;
- return;
- }
- }
- // We add the generated code until the first mapping
- // to the SourceNode without any mapping.
- // Each line is added as separate string.
- while (lastGeneratedLine < mapping.generatedLine) {
- node.add(shiftNextLine());
- lastGeneratedLine++;
- }
- if (lastGeneratedColumn < mapping.generatedColumn) {
- var nextLine = remainingLines[0];
- node.add(nextLine.substr(0, mapping.generatedColumn));
- remainingLines[0] = nextLine.substr(mapping.generatedColumn);
- lastGeneratedColumn = mapping.generatedColumn;
- }
- lastMapping = mapping;
- }, this);
- // We have processed all mappings.
- if (remainingLines.length > 0) {
- if (lastMapping) {
- // Associate the remaining code in the current line with "lastMapping"
- addMappingWithCode(lastMapping, shiftNextLine());
- }
- // and add the remaining lines without any mapping
- node.add(remainingLines.join(""));
- }
- // Copy sourcesContent into SourceNode
- aSourceMapConsumer.sources.forEach(function (sourceFile) {
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
- if (aRelativePath != null) {
- sourceFile = util.join(aRelativePath, sourceFile);
- }
- node.setSourceContent(sourceFile, content);
- }
- });
- return node;
- function addMappingWithCode(mapping, code) {
- if (mapping === null || mapping.source === undefined) {
- node.add(code);
- } else {
- var source = aRelativePath
- ? util.join(aRelativePath, mapping.source)
- : mapping.source;
- node.add(new SourceNode(mapping.originalLine,
- mapping.originalColumn,
- source,
- code,
- mapping.name));
- }
- }
- };
- /**
- * Add a chunk of generated JS to this source node.
- *
- * @param aChunk A string snippet of generated JS code, another instance of
- * SourceNode, or an array where each member is one of those things.
- */
- SourceNode.prototype.add = function SourceNode_add(aChunk) {
- if (Array.isArray(aChunk)) {
- aChunk.forEach(function (chunk) {
- this.add(chunk);
- }, this);
- }
- else if (aChunk[isSourceNode] || typeof aChunk === "string") {
- if (aChunk) {
- this.children.push(aChunk);
- }
- }
- else {
- throw new TypeError(
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
- );
- }
- return this;
- };
- /**
- * Add a chunk of generated JS to the beginning of this source node.
- *
- * @param aChunk A string snippet of generated JS code, another instance of
- * SourceNode, or an array where each member is one of those things.
- */
- SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
- if (Array.isArray(aChunk)) {
- for (var i = aChunk.length-1; i >= 0; i--) {
- this.prepend(aChunk[i]);
- }
- }
- else if (aChunk[isSourceNode] || typeof aChunk === "string") {
- this.children.unshift(aChunk);
- }
- else {
- throw new TypeError(
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
- );
- }
- return this;
- };
- /**
- * Walk over the tree of JS snippets in this node and its children. The
- * walking function is called once for each snippet of JS and is passed that
- * snippet and the its original associated source's line/column location.
- *
- * @param aFn The traversal function.
- */
- SourceNode.prototype.walk = function SourceNode_walk(aFn) {
- var chunk;
- for (var i = 0, len = this.children.length; i < len; i++) {
- chunk = this.children[i];
- if (chunk[isSourceNode]) {
- chunk.walk(aFn);
- }
- else {
- if (chunk !== '') {
- aFn(chunk, { source: this.source,
- line: this.line,
- column: this.column,
- name: this.name });
- }
- }
- }
- };
- /**
- * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
- * each of `this.children`.
- *
- * @param aSep The separator.
- */
- SourceNode.prototype.join = function SourceNode_join(aSep) {
- var newChildren;
- var i;
- var len = this.children.length;
- if (len > 0) {
- newChildren = [];
- for (i = 0; i < len-1; i++) {
- newChildren.push(this.children[i]);
- newChildren.push(aSep);
- }
- newChildren.push(this.children[i]);
- this.children = newChildren;
- }
- return this;
- };
- /**
- * Call String.prototype.replace on the very right-most source snippet. Useful
- * for trimming whitespace from the end of a source node, etc.
- *
- * @param aPattern The pattern to replace.
- * @param aReplacement The thing to replace the pattern with.
- */
- SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
- var lastChild = this.children[this.children.length - 1];
- if (lastChild[isSourceNode]) {
- lastChild.replaceRight(aPattern, aReplacement);
- }
- else if (typeof lastChild === 'string') {
- this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
- }
- else {
- this.children.push(''.replace(aPattern, aReplacement));
- }
- return this;
- };
- /**
- * Set the source content for a source file. This will be added to the SourceMapGenerator
- * in the sourcesContent field.
- *
- * @param aSourceFile The filename of the source file
- * @param aSourceContent The content of the source file
- */
- SourceNode.prototype.setSourceContent =
- function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
- this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
- };
- /**
- * Walk over the tree of SourceNodes. The walking function is called for each
- * source file content and is passed the filename and source content.
- *
- * @param aFn The traversal function.
- */
- SourceNode.prototype.walkSourceContents =
- function SourceNode_walkSourceContents(aFn) {
- for (var i = 0, len = this.children.length; i < len; i++) {
- if (this.children[i][isSourceNode]) {
- this.children[i].walkSourceContents(aFn);
- }
- }
- var sources = Object.keys(this.sourceContents);
- for (var i = 0, len = sources.length; i < len; i++) {
- aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
- }
- };
- /**
- * Return the string representation of this source node. Walks over the tree
- * and concatenates all the various snippets together to one string.
- */
- SourceNode.prototype.toString = function SourceNode_toString() {
- var str = "";
- this.walk(function (chunk) {
- str += chunk;
- });
- return str;
- };
- /**
- * Returns the string representation of this source node along with a source
- * map.
- */
- SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
- var generated = {
- code: "",
- line: 1,
- column: 0
- };
- var map = new SourceMapGenerator(aArgs);
- var sourceMappingActive = false;
- var lastOriginalSource = null;
- var lastOriginalLine = null;
- var lastOriginalColumn = null;
- var lastOriginalName = null;
- this.walk(function (chunk, original) {
- generated.code += chunk;
- if (original.source !== null
- && original.line !== null
- && original.column !== null) {
- if(lastOriginalSource !== original.source
- || lastOriginalLine !== original.line
- || lastOriginalColumn !== original.column
- || lastOriginalName !== original.name) {
- map.addMapping({
- source: original.source,
- original: {
- line: original.line,
- column: original.column
- },
- generated: {
- line: generated.line,
- column: generated.column
- },
- name: original.name
- });
- }
- lastOriginalSource = original.source;
- lastOriginalLine = original.line;
- lastOriginalColumn = original.column;
- lastOriginalName = original.name;
- sourceMappingActive = true;
- } else if (sourceMappingActive) {
- map.addMapping({
- generated: {
- line: generated.line,
- column: generated.column
- }
- });
- lastOriginalSource = null;
- sourceMappingActive = false;
- }
- for (var idx = 0, length = chunk.length; idx < length; idx++) {
- if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
- generated.line++;
- generated.column = 0;
- // Mappings end at eol
- if (idx + 1 === length) {
- lastOriginalSource = null;
- sourceMappingActive = false;
- } else if (sourceMappingActive) {
- map.addMapping({
- source: original.source,
- original: {
- line: original.line,
- column: original.column
- },
- generated: {
- line: generated.line,
- column: generated.column
- },
- name: original.name
- });
- }
- } else {
- generated.column++;
- }
- }
- });
- this.walkSourceContents(function (sourceFile, sourceContent) {
- map.setSourceContent(sourceFile, sourceContent);
- });
- return { code: generated.code, map: map };
- };
- exports.SourceNode = SourceNode;
- });
- },{"./source-map-generator":490,"./util":492,"amdefine":493}],492:[function(require,module,exports){
- /* -*- Mode: js; js-indent-level: 2; -*- */
- /*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
- if (typeof define !== 'function') {
- var define = require('amdefine')(module, require);
- }
- define(function (require, exports, module) {
- /**
- * This is a helper function for getting values from parameter/options
- * objects.
- *
- * @param args The object we are extracting values from
- * @param name The name of the property we are getting.
- * @param defaultValue An optional value to return if the property is missing
- * from the object. If this is not specified and the property is missing, an
- * error will be thrown.
- */
- function getArg(aArgs, aName, aDefaultValue) {
- if (aName in aArgs) {
- return aArgs[aName];
- } else if (arguments.length === 3) {
- return aDefaultValue;
- } else {
- throw new Error('"' + aName + '" is a required argument.');
- }
- }
- exports.getArg = getArg;
- var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
- var dataUrlRegexp = /^data:.+\,.+$/;
- function urlParse(aUrl) {
- var match = aUrl.match(urlRegexp);
- if (!match) {
- return null;
- }
- return {
- scheme: match[1],
- auth: match[2],
- host: match[3],
- port: match[4],
- path: match[5]
- };
- }
- exports.urlParse = urlParse;
- function urlGenerate(aParsedUrl) {
- var url = '';
- if (aParsedUrl.scheme) {
- url += aParsedUrl.scheme + ':';
- }
- url += '//';
- if (aParsedUrl.auth) {
- url += aParsedUrl.auth + '@';
- }
- if (aParsedUrl.host) {
- url += aParsedUrl.host;
- }
- if (aParsedUrl.port) {
- url += ":" + aParsedUrl.port
- }
- if (aParsedUrl.path) {
- url += aParsedUrl.path;
- }
- return url;
- }
- exports.urlGenerate = urlGenerate;
- /**
- * Normalizes a path, or the path portion of a URL:
- *
- * - Replaces consequtive slashes with one slash.
- * - Removes unnecessary '.' parts.
- * - Removes unnecessary '<dir>/..' parts.
- *
- * Based on code in the Node.js 'path' core module.
- *
- * @param aPath The path or url to normalize.
- */
- function normalize(aPath) {
- var path = aPath;
- var url = urlParse(aPath);
- if (url) {
- if (!url.path) {
- return aPath;
- }
- path = url.path;
- }
- var isAbsolute = (path.charAt(0) === '/');
- var parts = path.split(/\/+/);
- for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
- part = parts[i];
- if (part === '.') {
- parts.splice(i, 1);
- } else if (part === '..') {
- up++;
- } else if (up > 0) {
- if (part === '') {
- // The first part is blank if the path is absolute. Trying to go
- // above the root is a no-op. Therefore we can remove all '..' parts
- // directly after the root.
- parts.splice(i + 1, up);
- up = 0;
- } else {
- parts.splice(i, 2);
- up--;
- }
- }
- }
- path = parts.join('/');
- if (path === '') {
- path = isAbsolute ? '/' : '.';
- }
- if (url) {
- url.path = path;
- return urlGenerate(url);
- }
- return path;
- }
- exports.normalize = normalize;
- /**
- * Joins two paths/URLs.
- *
- * @param aRoot The root path or URL.
- * @param aPath The path or URL to be joined with the root.
- *
- * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
- * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
- * first.
- * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
- * is updated with the result and aRoot is returned. Otherwise the result
- * is returned.
- * - If aPath is absolute, the result is aPath.
- * - Otherwise the two paths are joined with a slash.
- * - Joining for example 'http://' and 'www.example.com' is also supported.
- */
- function join(aRoot, aPath) {
- if (aRoot === "") {
- aRoot = ".";
- }
- if (aPath === "") {
- aPath = ".";
- }
- var aPathUrl = urlParse(aPath);
- var aRootUrl = urlParse(aRoot);
- if (aRootUrl) {
- aRoot = aRootUrl.path || '/';
- }
- // `join(foo, '//www.example.org')`
- if (aPathUrl && !aPathUrl.scheme) {
- if (aRootUrl) {
- aPathUrl.scheme = aRootUrl.scheme;
- }
- return urlGenerate(aPathUrl);
- }
- if (aPathUrl || aPath.match(dataUrlRegexp)) {
- return aPath;
- }
- // `join('http://', 'www.example.com')`
- if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
- aRootUrl.host = aPath;
- return urlGenerate(aRootUrl);
- }
- var joined = aPath.charAt(0) === '/'
- ? aPath
- : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
- if (aRootUrl) {
- aRootUrl.path = joined;
- return urlGenerate(aRootUrl);
- }
- return joined;
- }
- exports.join = join;
- /**
- * Make a path relative to a URL or another path.
- *
- * @param aRoot The root path or URL.
- * @param aPath The path or URL to be made relative to aRoot.
- */
- function relative(aRoot, aPath) {
- if (aRoot === "") {
- aRoot = ".";
- }
- aRoot = aRoot.replace(/\/$/, '');
- // XXX: It is possible to remove this block, and the tests still pass!
- var url = urlParse(aRoot);
- if (aPath.charAt(0) == "/" && url && url.path == "/") {
- return aPath.slice(1);
- }
- return aPath.indexOf(aRoot + '/') === 0
- ? aPath.substr(aRoot.length + 1)
- : aPath;
- }
- exports.relative = relative;
- /**
- * Because behavior goes wacky when you set `__proto__` on objects, we
- * have to prefix all the strings in our set with an arbitrary character.
- *
- * See https://github.com/mozilla/source-map/pull/31 and
- * https://github.com/mozilla/source-map/issues/30
- *
- * @param String aStr
- */
- function toSetString(aStr) {
- return '$' + aStr;
- }
- exports.toSetString = toSetString;
- function fromSetString(aStr) {
- return aStr.substr(1);
- }
- exports.fromSetString = fromSetString;
- function strcmp(aStr1, aStr2) {
- var s1 = aStr1 || "";
- var s2 = aStr2 || "";
- return (s1 > s2) - (s1 < s2);
- }
- /**
- * Comparator between two mappings where the original positions are compared.
- *
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
- * mappings with the same original source/line/column, but different generated
- * line and column the same. Useful when searching for a mapping with a
- * stubbed out mapping.
- */
- function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
- var cmp;
- cmp = strcmp(mappingA.source, mappingB.source);
- if (cmp) {
- return cmp;
- }
- cmp = mappingA.originalLine - mappingB.originalLine;
- if (cmp) {
- return cmp;
- }
- cmp = mappingA.originalColumn - mappingB.originalColumn;
- if (cmp || onlyCompareOriginal) {
- return cmp;
- }
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
- if (cmp) {
- return cmp;
- }
- cmp = mappingA.generatedLine - mappingB.generatedLine;
- if (cmp) {
- return cmp;
- }
- return strcmp(mappingA.name, mappingB.name);
- };
- exports.compareByOriginalPositions = compareByOriginalPositions;
- /**
- * Comparator between two mappings where the generated positions are
- * compared.
- *
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
- * mappings with the same generated line and column, but different
- * source/name/original line and column the same. Useful when searching for a
- * mapping with a stubbed out mapping.
- */
- function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
- var cmp;
- cmp = mappingA.generatedLine - mappingB.generatedLine;
- if (cmp) {
- return cmp;
- }
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
- if (cmp || onlyCompareGenerated) {
- return cmp;
- }
- cmp = strcmp(mappingA.source, mappingB.source);
- if (cmp) {
- return cmp;
- }
- cmp = mappingA.originalLine - mappingB.originalLine;
- if (cmp) {
- return cmp;
- }
- cmp = mappingA.originalColumn - mappingB.originalColumn;
- if (cmp) {
- return cmp;
- }
- return strcmp(mappingA.name, mappingB.name);
- };
- exports.compareByGeneratedPositions = compareByGeneratedPositions;
- });
- },{"amdefine":493}],493:[function(require,module,exports){
- (function (process,__filename){
- /** vim: et:ts=4:sw=4:sts=4
- * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
- * Available via the MIT or new BSD license.
- * see: http://github.com/jrburke/amdefine for details
- */
- /*jslint node: true */
- /*global module, process */
- 'use strict';
- /**
- * Creates a define for node.
- * @param {Object} module the "module" object that is defined by Node for the
- * current module.
- * @param {Function} [requireFn]. Node's require function for the current module.
- * It only needs to be passed in Node versions before 0.5, when module.require
- * did not exist.
- * @returns {Function} a define function that is usable for the current node
- * module.
- */
- function amdefine(module, requireFn) {
- 'use strict';
- var defineCache = {},
- loaderCache = {},
- alreadyCalled = false,
- path = require('path'),
- makeRequire, stringRequire;
- /**
- * Trims the . and .. from an array of path segments.
- * It will keep a leading path segment if a .. will become
- * the first path segment, to help with module name lookups,
- * which act like paths, but can be remapped. But the end result,
- * all paths that use this function should look normalized.
- * NOTE: this method MODIFIES the input array.
- * @param {Array} ary the array of path segments.
- */
- function trimDots(ary) {
- var i, part;
- for (i = 0; ary[i]; i+= 1) {
- part = ary[i];
- if (part === '.') {
- ary.splice(i, 1);
- i -= 1;
- } else if (part === '..') {
- if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
- //End of the line. Keep at least one non-dot
- //path segment at the front so it can be mapped
- //correctly to disk. Otherwise, there is likely
- //no path mapping for a path starting with '..'.
- //This can still fail, but catches the most reasonable
- //uses of ..
- break;
- } else if (i > 0) {
- ary.splice(i - 1, 2);
- i -= 2;
- }
- }
- }
- }
- function normalize(name, baseName) {
- var baseParts;
- //Adjust any relative paths.
- if (name && name.charAt(0) === '.') {
- //If have a base name, try to normalize against it,
- //otherwise, assume it is a top-level require that will
- //be relative to baseUrl in the end.
- if (baseName) {
- baseParts = baseName.split('/');
- baseParts = baseParts.slice(0, baseParts.length - 1);
- baseParts = baseParts.concat(name.split('/'));
- trimDots(baseParts);
- name = baseParts.join('/');
- }
- }
- return name;
- }
- /**
- * Create the normalize() function passed to a loader plugin's
- * normalize method.
- */
- function makeNormalize(relName) {
- return function (name) {
- return normalize(name, relName);
- };
- }
- function makeLoad(id) {
- function load(value) {
- loaderCache[id] = value;
- }
- load.fromText = function (id, text) {
- //This one is difficult because the text can/probably uses
- //define, and any relative paths and requires should be relative
- //to that id was it would be found on disk. But this would require
- //bootstrapping a module/require fairly deeply from node core.
- //Not sure how best to go about that yet.
- throw new Error('amdefine does not implement load.fromText');
- };
- return load;
- }
- makeRequire = function (systemRequire, exports, module, relId) {
- function amdRequire(deps, callback) {
- if (typeof deps === 'string') {
- //Synchronous, single module require('')
- return stringRequire(systemRequire, exports, module, deps, relId);
- } else {
- //Array of dependencies with a callback.
- //Convert the dependencies to modules.
- deps = deps.map(function (depName) {
- return stringRequire(systemRequire, exports, module, depName, relId);
- });
- //Wait for next tick to call back the require call.
- process.nextTick(function () {
- callback.apply(null, deps);
- });
- }
- }
- amdRequire.toUrl = function (filePath) {
- if (filePath.indexOf('.') === 0) {
- return normalize(filePath, path.dirname(module.filename));
- } else {
- return filePath;
- }
- };
- return amdRequire;
- };
- //Favor explicit value, passed in if the module wants to support Node 0.4.
- requireFn = requireFn || function req() {
- return module.require.apply(module, arguments);
- };
- function runFactory(id, deps, factory) {
- var r, e, m, result;
- if (id) {
- e = loaderCache[id] = {};
- m = {
- id: id,
- uri: __filename,
- exports: e
- };
- r = makeRequire(requireFn, e, m, id);
- } else {
- //Only support one define call per file
- if (alreadyCalled) {
- throw new Error('amdefine with no module ID cannot be called more than once per file.');
- }
- alreadyCalled = true;
- //Use the real variables from node
- //Use module.exports for exports, since
- //the exports in here is amdefine exports.
- e = module.exports;
- m = module;
- r = makeRequire(requireFn, e, m, module.id);
- }
- //If there are dependencies, they are strings, so need
- //to convert them to dependency values.
- if (deps) {
- deps = deps.map(function (depName) {
- return r(depName);
- });
- }
- //Call the factory with the right dependencies.
- if (typeof factory === 'function') {
- result = factory.apply(m.exports, deps);
- } else {
- result = factory;
- }
- if (result !== undefined) {
- m.exports = result;
- if (id) {
- loaderCache[id] = m.exports;
- }
- }
- }
- stringRequire = function (systemRequire, exports, module, id, relId) {
- //Split the ID by a ! so that
- var index = id.indexOf('!'),
- originalId = id,
- prefix, plugin;
- if (index === -1) {
- id = normalize(id, relId);
- //Straight module lookup. If it is one of the special dependencies,
- //deal with it, otherwise, delegate to node.
- if (id === 'require') {
- return makeRequire(systemRequire, exports, module, relId);
- } else if (id === 'exports') {
- return exports;
- } else if (id === 'module') {
- return module;
- } else if (loaderCache.hasOwnProperty(id)) {
- return loaderCache[id];
- } else if (defineCache[id]) {
- runFactory.apply(null, defineCache[id]);
- return loaderCache[id];
- } else {
- if(systemRequire) {
- return systemRequire(originalId);
- } else {
- throw new Error('No module with ID: ' + id);
- }
- }
- } else {
- //There is a plugin in play.
- prefix = id.substring(0, index);
- id = id.substring(index + 1, id.length);
- plugin = stringRequire(systemRequire, exports, module, prefix, relId);
- if (plugin.normalize) {
- id = plugin.normalize(id, makeNormalize(relId));
- } else {
- //Normalize the ID normally.
- id = normalize(id, relId);
- }
- if (loaderCache[id]) {
- return loaderCache[id];
- } else {
- plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
- return loaderCache[id];
- }
- }
- };
- //Create a define function specific to the module asking for amdefine.
- function define(id, deps, factory) {
- if (Array.isArray(id)) {
- factory = deps;
- deps = id;
- id = undefined;
- } else if (typeof id !== 'string') {
- factory = id;
- id = deps = undefined;
- }
- if (deps && !Array.isArray(deps)) {
- factory = deps;
- deps = undefined;
- }
- if (!deps) {
- deps = ['require', 'exports', 'module'];
- }
- //Set up properties for this module. If an ID, then use
- //internal cache. If no ID, then use the external variables
- //for this node module.
- if (id) {
- //Put the module in deep freeze until there is a
- //require call for it.
- defineCache[id] = [id, deps, factory];
- } else {
- runFactory(id, deps, factory);
- }
- }
- //define.require, which has access to all the values in the
- //cache. Useful for AMD modules that all have IDs in the file,
- //but need to finally export a value to node based on one of those
- //IDs.
- define.require = function (id) {
- if (loaderCache[id]) {
- return loaderCache[id];
- }
- if (defineCache[id]) {
- runFactory.apply(null, defineCache[id]);
- return loaderCache[id];
- }
- };
- define.amd = {};
- return define;
- }
- module.exports = amdefine;
- }).call(this,require('_process'),"/node_modules/source-map/node_modules/amdefine/amdefine.js")
- },{"_process":200,"path":199}],494:[function(require,module,exports){
- /*!
- strip-json-comments
- Strip comments from JSON. Lets you use comments in your JSON files!
- https://github.com/sindresorhus/strip-json-comments
- by Sindre Sorhus
- MIT License
- */
- (function () {
- 'use strict';
- function stripJsonComments(str) {
- var currentChar;
- var nextChar;
- var insideString = false;
- var insideComment = false;
- var ret = '';
- for (var i = 0; i < str.length; i++) {
- currentChar = str[i];
- nextChar = str[i + 1];
- if (!insideComment && str[i - 1] !== '\\' && currentChar === '"') {
- insideString = !insideString;
- }
- if (insideString) {
- ret += currentChar;
- continue;
- }
- if (!insideComment && currentChar + nextChar === '//') {
- insideComment = 'single';
- i++;
- } else if (insideComment === 'single' && currentChar + nextChar === '\r\n') {
- insideComment = false;
- i++;
- ret += currentChar;
- ret += nextChar;
- continue;
- } else if (insideComment === 'single' && currentChar === '\n') {
- insideComment = false;
- } else if (!insideComment && currentChar + nextChar === '/*') {
- insideComment = 'multi';
- i++;
- continue;
- } else if (insideComment === 'multi' && currentChar + nextChar === '*/') {
- insideComment = false;
- i++;
- continue;
- }
- if (insideComment) {
- continue;
- }
- ret += currentChar;
- }
- return ret;
- }
- if (typeof module !== 'undefined' && module.exports) {
- module.exports = stripJsonComments;
- } else {
- window.stripJsonComments = stripJsonComments;
- }
- })();
- },{}],495:[function(require,module,exports){
- 'use strict';
- module.exports = function toFastProperties(obj) {
- /*jshint -W027*/
- function f() {}
- f.prototype = obj;
- new f();
- return;
- eval(obj);
- };
- },{}],496:[function(require,module,exports){
- 'use strict';
- module.exports = function (str) {
- return str.replace(/[\s\uFEFF\xA0]+$/g, '');
- };
- },{}],497:[function(require,module,exports){
- module.exports={
- "name": "babel-core",
- "description": "Turn ES6 code into readable vanilla ES5 with source maps",
- "version": "5.4.3",
- "author": "Sebastian McKenzie <sebmck@gmail.com>",
- "homepage": "https://babeljs.io/",
- "license": "MIT",
- "repository": "babel/babel",
- "main": "lib/babel/api/node.js",
- "browser": {
- "./lib/babel/api/register/node.js": "./lib/babel/api/register/browser.js"
- },
- "keywords": [
- "harmony",
- "classes",
- "modules",
- "let",
- "const",
- "var",
- "es6",
- "transpile",
- "transpiler",
- "6to5",
- "babel"
- ],
- "scripts": {
- "bench": "make bench",
- "test": "make test"
- },
- "dependencies": {
- "acorn-jsx": "^1.0.0",
- "ast-types": "~0.7.0",
- "bluebird": "^2.9.25",
- "chalk": "^1.0.0",
- "convert-source-map": "^1.1.0",
- "core-js": "^0.9.0",
- "debug": "^2.1.1",
- "detect-indent": "^3.0.0",
- "esquery": "^0.4.0",
- "estraverse": "^4.0.0",
- "esutils": "^2.0.0",
- "fs-readdir-recursive": "^0.1.0",
- "globals": "^6.4.0",
- "is-integer": "^1.0.4",
- "js-tokens": "1.0.0",
- "leven": "^1.0.1",
- "line-numbers": "0.2.0",
- "lodash": "^3.6.0",
- "minimatch": "^2.0.3",
- "output-file-sync": "^1.1.0",
- "path-is-absolute": "^1.0.0",
- "private": "^0.1.6",
- "regenerator": "^0.8.20",
- "regexpu": "^1.1.2",
- "repeating": "^1.1.2",
- "resolve": "^1.1.6",
- "shebang-regex": "^1.0.0",
- "slash": "^1.0.0",
- "source-map": "^0.4.0",
- "source-map-support": "^0.2.10",
- "strip-json-comments": "^1.0.2",
- "to-fast-properties": "^1.0.0",
- "trim-right": "^1.0.0",
- "user-home": "^1.1.1"
- },
- "devDependencies": {
- "babel": "5.3.1",
- "browserify": "^9.0.8",
- "chai": "^2.2.0",
- "eslint": "^0.18.0",
- "babel-eslint": "^2.0.0",
- "esvalid": "^1.1.0",
- "istanbul": "^0.3.5",
- "matcha": "^0.6.0",
- "mocha": "2.2.0",
- "rimraf": "^2.3.2",
- "uglify-js": "^2.4.16"
- }
- }
- },{}],498:[function(require,module,exports){
- module.exports={"abstract-expression-call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceGet","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"abstract-expression-delete":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceDelete","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"abstract-expression-get":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceGet","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"abstract-expression-set":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"PROPERTY","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"referenceSet","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"array-comprehension-container":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"elements":[],"type":"ArrayExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"array-from":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"from","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"array-push":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"push","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"STATEMENT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"CONTEXT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-decorator":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"CLASS_REF","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"DECORATOR","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"CLASS_REF","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"name":"CLASS_REF","type":"Identifier","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-super-constructor-call-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-super-constructor-call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"class-super-native-constructor-call":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"NATIVE_REF","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"SUPER_NAME","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null},"type":"SpreadElement","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"NATIVE_REF","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__proto__","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"CLASS_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"NATIVE_REF","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"default-parameter":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"VARIABLE_NAME","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"ARGUMENT_KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"DEFAULT_VALUE","type":"Identifier","end":null},"alternate":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"ARGUMENT_KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"let","type":"VariableDeclaration","end":null}],"type":"Program","end":null},"exports-assign":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-default-assign":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"module","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"VALUE","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-from-assign":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"INIT","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-module-declaration-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"exports-module-declaration":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"value":"__esModule","raw":null,"type":"Literal","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"for-of-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARR","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"name":"BODY","type":"Identifier","end":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"ForStatement","end":null,"_paths":null}],"type":"Program","end":null},"for-of-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"IS_ARRAY","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"IS_ARRAY","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"alternate":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":null,"update":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"IS_ARRAY","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"operator":">=","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"LOOP_OBJECT","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ID","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"INDEX","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"Program","end":null},"for-of":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_HAD_ERROR_KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_ERROR_KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"OBJECT","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"STEP_KEY","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"STEP_KEY","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":{"start":null,"loc":null,"range":null,"param":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"guard":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_HAD_ERROR_KEY","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"ITERATOR_ERROR_KEY","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"CatchClause","end":null,"_paths":null},"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"ITERATOR_COMPLETION","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ITERATOR_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":null,"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"ITERATOR_HAD_ERROR_KEY","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"ITERATOR_ERROR_KEY","type":"Identifier","end":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-async-to-generator":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"fn","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"gen","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"fn","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Promise","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"resolve","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"reject","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"callNext","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"step","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"bind","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},{"start":null,"loc":null,"range":null,"value":"next","raw":null,"type":"Literal","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"callThrow","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"step","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"bind","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},{"start":null,"loc":null,"range":null,"value":"throw","raw":null,"type":"Literal","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"step","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"arg","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"info","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"gen","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arg","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"info","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null}],"type":"BlockStatement","end":null},"handler":{"start":null,"loc":null,"range":null,"param":{"start":null,"loc":null,"range":null,"name":"error","type":"Identifier","end":null},"guard":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"reject","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"error","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":null,"type":"ReturnStatement","end":null}],"type":"BlockStatement","end":null},"type":"CatchClause","end":null,"_paths":null},"guardedHandlers":[],"finalizer":null,"type":"TryStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"info","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"resolve","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Promise","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"resolve","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"then","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"callNext","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"callThrow","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"callNext","type":"Identifier","end":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-bind":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Function","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"bind","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-class-call-check":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"instance","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"instance","type":"Identifier","end":null},"operator":"instanceof","right":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Cannot call a class as a function","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-create-class":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-create-decorated-class":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"initializers","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"leadingComments":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"||","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"The decorator for method ","raw":null,"type":"Literal","end":null},"operator":"+","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"value":" is of the invalid type ","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"initializers","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"label":null,"type":"ContinueStatement","end":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoInitializers","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticInitializers","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"protoProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"protoInitializers","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"staticInitializers","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"Constructor","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-create-decorated-object":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"leadingComments":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"operator":"delete","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"decorators","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"f","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"The decorator for method ","raw":null,"type":"Literal","end":null},"operator":"+","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"value":" is of the invalid type ","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"decorator","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-default-props":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"defaultProps","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"propName","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"props","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-defaults":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"defaults","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyNames","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"defaults","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyDescriptor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"defaults","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-define-decorated-property-descriptor":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptors","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"argument":null,"type":"ReturnStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null,"leadingComments":null},{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_key","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"_key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"_key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"ForInStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"initializer","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"leadingComments":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"descriptor","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-define-property":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-extends":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"assign","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"||","right":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":1,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"source","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-get":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyDescriptor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getPrototypeOf","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"getter","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"get","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"getter","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"getter","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-has-own":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-inherits":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"Super expression must either be null or a function, not ","raw":null,"type":"Literal","end":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"create","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"constructor","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"enumerable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"configurable","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"subClass","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__proto__","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"superClass","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-instanceof":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"left","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"hasInstance","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"hasInstance","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"left","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"left","type":"Identifier","end":null},"operator":"instanceof","right":{"start":null,"loc":null,"range":null,"name":"right","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-interop-require-default":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"alternate":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"value":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-interop-require-wildcard":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"!=","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"key","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"newObj","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-interop-require":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"alternate":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-object-destructuring-empty":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"==","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Cannot destructure undefined","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-object-without-properties":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"left":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"right":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"keys","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"indexOf","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"operator":">=","right":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"ContinueStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"hasOwnProperty","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"ContinueStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForInStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"target","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-self-global":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"self","type":"Identifier","end":null},"alternate":{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-set":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"set","type":"Identifier","end":null},"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getOwnPropertyDescriptor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"getPrototypeOf","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"object","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":null,"raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"set","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"parent","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"property","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"value":"value","raw":null,"type":"Literal","end":null},"operator":"in","right":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"writable","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"setter","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"desc","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"set","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"setter","type":"Identifier","end":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"setter","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"call","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"receiver","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-slice":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"slice","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-sliced-to-array-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"in","right":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"elements":[],"type":"ArrayExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_iterator","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_step","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_step","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_iterator","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"update":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"push","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_step","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Invalid attempt to destructure non-iterable instance","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-sliced-to-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"in","right":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"elements":[],"type":"ArrayExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null,"leadingComments":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_d","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":false,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_e","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"undefined","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"iterator","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"_s","type":"Identifier","end":null},"init":null,"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_s","type":"Identifier","end":null},"right":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"next","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"done","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"UnaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"push","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_s","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"label":null,"type":"BreakStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":{"start":null,"loc":null,"range":null,"param":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"guard":null,"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_d","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"start":null,"loc":null,"range":null,"name":"_e","type":"Identifier","end":null},"right":{"start":null,"loc":null,"range":null,"name":"err","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"CatchClause","end":null,"_paths":null},"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"block":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"!","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"_n","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"_i","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"return","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"handler":null,"guardedHandlers":[],"finalizer":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"_d","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"_e","type":"Identifier","end":null},"type":"ThrowStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"TryStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"_arr","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"TypeError","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"value":"Invalid attempt to destructure non-iterable instance","raw":null,"type":"Literal","end":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-tagged-template-literal-loose":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-tagged-template-literal":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"freeze","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"defineProperties","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"strings","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"value","type":"Identifier","end":null},"value":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Object","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"freeze","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"raw","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null}],"type":"CallExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-temporal-assert-defined":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"val","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"name","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"undef","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"val","type":"Identifier","end":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"undef","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"ReferenceError","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"name","type":"Identifier","end":null},"operator":"+","right":{"start":null,"loc":null,"range":null,"value":" is not defined - temporal dead zone","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null}],"type":"NewExpression","end":null,"_paths":null},"type":"ThrowStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-temporal-undefined":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null,"parenthesizedExpression":true},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-to-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"alternate":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"from","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-to-consumable-array":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"isArray","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":0,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"arr2","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"operator":"<","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr2","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"i","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"ForStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"arr2","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"from","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"arr","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"helper-typeof":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"constructor","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"name":"Symbol","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"value":"symbol","raw":null,"type":"Literal","end":null},"alternate":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"obj","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"type":"ConditionalExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"let-scoping-return":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"RETURN","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"object","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"RETURN","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"v","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null},"alternate":null,"type":"IfStatement","end":null,"_paths":null}],"type":"Program","end":null},"named-function":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"GET_OUTER_ID","type":"Identifier","end":null},"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"property-method-assignment-wrapper-generator":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"generator":true,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"delegate":true,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"YieldExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"FUNCTION","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"property-method-assignment-wrapper":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"apply","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"type":"ThisExpression","end":null},{"start":null,"loc":null,"range":null,"name":"arguments","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionDeclaration","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"FUNCTION_KEY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"toString","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[],"type":"CallExpression","end":null,"_paths":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"FUNCTION","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"prototype-identifier":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"CLASS_NAME","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"prototype","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"require-assign-key":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"VARIABLE_NAME","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"require","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"MODULE_NAME","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"property":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null}],"type":"Program","end":null},"require":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"require","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"MODULE_NAME","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"rest":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"init":{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"LEN","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"length","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"ARRAY","type":"Identifier","end":null},"init":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"Array","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"ARRAY_LEN","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"VariableDeclarator","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"name":"START","type":"Identifier","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"operator":"<","right":{"start":null,"loc":null,"range":null,"name":"LEN","type":"Identifier","end":null},"type":"BinaryExpression","end":null,"_paths":null},"update":{"loc":null,"start":null,"range":null,"operator":"++","prefix":false,"argument":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"type":"UpdateExpression","end":null,"_paths":null},"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARRAY","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"ARRAY_KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"ARGUMENTS","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"KEY","type":"Identifier","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"ForStatement","end":null,"_paths":null}],"type":"Program","end":null},"self-contained-helpers-head":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"value":"default","raw":null,"type":"Literal","end":null},"computed":true,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"name":"HELPER","type":"Identifier","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"__esModule","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"system":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"System","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"register","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"MODULE_NAME","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"MODULE_DEPENDENCIES","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"EXPORT_IDENTIFIER","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"argument":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"setters","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"SETTERS","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"execute","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"name":"EXECUTE","type":"Identifier","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"type":"ReturnStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"tail-call-body":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"AGAIN_ID","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"value":true,"raw":null,"type":"Literal","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"body":{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"AGAIN_ID","type":"Identifier","end":null},"body":{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"name":"BLOCK","type":"Identifier","end":null},"type":"ExpressionStatement","end":null,"_paths":null},"type":"WhileStatement","end":null,"_paths":null},"label":{"start":null,"loc":null,"range":null,"name":"FUNCTION_ID","type":"Identifier","end":null},"type":"LabeledStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null}],"type":"Program","end":null},"test-exports":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"test-module":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"module","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"!==","right":{"start":null,"loc":null,"range":null,"value":"undefined","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"umd-commonjs-strict":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"root","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"amd","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"AMD_ARGUMENTS","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"object","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"COMMON_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"BROWSER_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"UMD_ROOT","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"FACTORY_PARAMETERS","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"name":"FACTORY_BODY","type":"Identifier","end":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"_paths":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null},"umd-runner-body":{"loc":null,"start":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"start":null,"loc":null,"range":null,"id":null,"generator":false,"expression":false,"params":[{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"body":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"test":{"loc":null,"start":null,"range":null,"left":{"loc":null,"start":null,"range":null,"left":{"start":null,"loc":null,"range":null,"operator":"typeof","prefix":true,"argument":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"type":"UnaryExpression","end":null,"_paths":null},"operator":"===","right":{"start":null,"loc":null,"range":null,"value":"function","raw":null,"type":"Literal","end":null},"type":"BinaryExpression","end":null,"_paths":null},"operator":"&&","right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"amd","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"LogicalExpression","end":null,"_paths":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"define","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"AMD_ARGUMENTS","type":"Identifier","end":null},{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"test":{"start":null,"loc":null,"range":null,"name":"COMMON_TEST","type":"Identifier","end":null},"consequent":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"start":null,"loc":null,"range":null,"name":"COMMON_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"alternate":{"start":null,"loc":null,"range":null,"body":[{"start":null,"loc":null,"range":null,"declarations":[{"start":null,"loc":null,"range":null,"id":{"start":null,"loc":null,"range":null,"name":"mod","type":"Identifier","end":null},"init":{"start":null,"loc":null,"range":null,"properties":[{"start":null,"loc":null,"range":null,"method":false,"shorthand":false,"computed":false,"key":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"value":{"start":null,"loc":null,"range":null,"properties":[],"type":"ObjectExpression","end":null},"kind":"init","type":"Property","end":null,"_paths":null}],"type":"ObjectExpression","end":null},"type":"VariableDeclarator","end":null,"_paths":null}],"kind":"var","type":"VariableDeclaration","end":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"callee":{"start":null,"loc":null,"range":null,"name":"factory","type":"Identifier","end":null},"arguments":[{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"mod","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"name":"BROWSER_ARGUMENTS","type":"Identifier","end":null}],"type":"CallExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null},{"start":null,"loc":null,"range":null,"expression":{"loc":null,"start":null,"range":null,"operator":"=","left":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"global","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"GLOBAL_ARG","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"right":{"loc":null,"start":null,"range":null,"object":{"start":null,"loc":null,"range":null,"name":"mod","type":"Identifier","end":null},"property":{"start":null,"loc":null,"range":null,"name":"exports","type":"Identifier","end":null},"computed":false,"type":"MemberExpression","end":null,"_paths":null},"type":"AssignmentExpression","end":null,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"IfStatement","end":null,"_paths":null},"type":"IfStatement","end":null,"_paths":null}],"type":"BlockStatement","end":null},"type":"FunctionExpression","end":null,"parenthesizedExpression":true,"_paths":null},"type":"ExpressionStatement","end":null,"_paths":null}],"type":"Program","end":null}}
- },{}]},{},[19])(19)
- });
|