eslint.js 4.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883
  1. (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(_dereq_,module,exports){
  2. (function (global){
  3. "use strict";
  4. _dereq_(327);
  5. _dereq_(328);
  6. _dereq_(2);
  7. if (global._babelPolyfill) {
  8. throw new Error("only one instance of babel-polyfill is allowed");
  9. }
  10. global._babelPolyfill = true;
  11. var DEFINE_PROPERTY = "defineProperty";
  12. function define(O, key, value) {
  13. O[key] || Object[DEFINE_PROPERTY](O, key, {
  14. writable: true,
  15. configurable: true,
  16. value: value
  17. });
  18. }
  19. define(String.prototype, "padLeft", "".padStart);
  20. define(String.prototype, "padRight", "".padEnd);
  21. "pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function (key) {
  22. [][key] && define(Array, key, Function.call.bind([][key]));
  23. });
  24. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  25. },{"2":2,"327":327,"328":328}],2:[function(_dereq_,module,exports){
  26. _dereq_(130);
  27. module.exports = _dereq_(23).RegExp.escape;
  28. },{"130":130,"23":23}],3:[function(_dereq_,module,exports){
  29. module.exports = function (it) {
  30. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  31. return it;
  32. };
  33. },{}],4:[function(_dereq_,module,exports){
  34. var cof = _dereq_(18);
  35. module.exports = function (it, msg) {
  36. if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg);
  37. return +it;
  38. };
  39. },{"18":18}],5:[function(_dereq_,module,exports){
  40. // 22.1.3.31 Array.prototype[@@unscopables]
  41. var UNSCOPABLES = _dereq_(128)('unscopables');
  42. var ArrayProto = Array.prototype;
  43. if (ArrayProto[UNSCOPABLES] == undefined) _dereq_(42)(ArrayProto, UNSCOPABLES, {});
  44. module.exports = function (key) {
  45. ArrayProto[UNSCOPABLES][key] = true;
  46. };
  47. },{"128":128,"42":42}],6:[function(_dereq_,module,exports){
  48. module.exports = function (it, Constructor, name, forbiddenField) {
  49. if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
  50. throw TypeError(name + ': incorrect invocation!');
  51. } return it;
  52. };
  53. },{}],7:[function(_dereq_,module,exports){
  54. var isObject = _dereq_(51);
  55. module.exports = function (it) {
  56. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  57. return it;
  58. };
  59. },{"51":51}],8:[function(_dereq_,module,exports){
  60. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  61. 'use strict';
  62. var toObject = _dereq_(119);
  63. var toAbsoluteIndex = _dereq_(114);
  64. var toLength = _dereq_(118);
  65. module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
  66. var O = toObject(this);
  67. var len = toLength(O.length);
  68. var to = toAbsoluteIndex(target, len);
  69. var from = toAbsoluteIndex(start, len);
  70. var end = arguments.length > 2 ? arguments[2] : undefined;
  71. var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
  72. var inc = 1;
  73. if (from < to && to < from + count) {
  74. inc = -1;
  75. from += count - 1;
  76. to += count - 1;
  77. }
  78. while (count-- > 0) {
  79. if (from in O) O[to] = O[from];
  80. else delete O[to];
  81. to += inc;
  82. from += inc;
  83. } return O;
  84. };
  85. },{"114":114,"118":118,"119":119}],9:[function(_dereq_,module,exports){
  86. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  87. 'use strict';
  88. var toObject = _dereq_(119);
  89. var toAbsoluteIndex = _dereq_(114);
  90. var toLength = _dereq_(118);
  91. module.exports = function fill(value /* , start = 0, end = @length */) {
  92. var O = toObject(this);
  93. var length = toLength(O.length);
  94. var aLen = arguments.length;
  95. var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);
  96. var end = aLen > 2 ? arguments[2] : undefined;
  97. var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
  98. while (endPos > index) O[index++] = value;
  99. return O;
  100. };
  101. },{"114":114,"118":118,"119":119}],10:[function(_dereq_,module,exports){
  102. var forOf = _dereq_(39);
  103. module.exports = function (iter, ITERATOR) {
  104. var result = [];
  105. forOf(iter, false, result.push, result, ITERATOR);
  106. return result;
  107. };
  108. },{"39":39}],11:[function(_dereq_,module,exports){
  109. // false -> Array#indexOf
  110. // true -> Array#includes
  111. var toIObject = _dereq_(117);
  112. var toLength = _dereq_(118);
  113. var toAbsoluteIndex = _dereq_(114);
  114. module.exports = function (IS_INCLUDES) {
  115. return function ($this, el, fromIndex) {
  116. var O = toIObject($this);
  117. var length = toLength(O.length);
  118. var index = toAbsoluteIndex(fromIndex, length);
  119. var value;
  120. // Array#includes uses SameValueZero equality algorithm
  121. // eslint-disable-next-line no-self-compare
  122. if (IS_INCLUDES && el != el) while (length > index) {
  123. value = O[index++];
  124. // eslint-disable-next-line no-self-compare
  125. if (value != value) return true;
  126. // Array#indexOf ignores holes, Array#includes - not
  127. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  128. if (O[index] === el) return IS_INCLUDES || index || 0;
  129. } return !IS_INCLUDES && -1;
  130. };
  131. };
  132. },{"114":114,"117":117,"118":118}],12:[function(_dereq_,module,exports){
  133. // 0 -> Array#forEach
  134. // 1 -> Array#map
  135. // 2 -> Array#filter
  136. // 3 -> Array#some
  137. // 4 -> Array#every
  138. // 5 -> Array#find
  139. // 6 -> Array#findIndex
  140. var ctx = _dereq_(25);
  141. var IObject = _dereq_(47);
  142. var toObject = _dereq_(119);
  143. var toLength = _dereq_(118);
  144. var asc = _dereq_(15);
  145. module.exports = function (TYPE, $create) {
  146. var IS_MAP = TYPE == 1;
  147. var IS_FILTER = TYPE == 2;
  148. var IS_SOME = TYPE == 3;
  149. var IS_EVERY = TYPE == 4;
  150. var IS_FIND_INDEX = TYPE == 6;
  151. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  152. var create = $create || asc;
  153. return function ($this, callbackfn, that) {
  154. var O = toObject($this);
  155. var self = IObject(O);
  156. var f = ctx(callbackfn, that, 3);
  157. var length = toLength(self.length);
  158. var index = 0;
  159. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  160. var val, res;
  161. for (;length > index; index++) if (NO_HOLES || index in self) {
  162. val = self[index];
  163. res = f(val, index, O);
  164. if (TYPE) {
  165. if (IS_MAP) result[index] = res; // map
  166. else if (res) switch (TYPE) {
  167. case 3: return true; // some
  168. case 5: return val; // find
  169. case 6: return index; // findIndex
  170. case 2: result.push(val); // filter
  171. } else if (IS_EVERY) return false; // every
  172. }
  173. }
  174. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  175. };
  176. };
  177. },{"118":118,"119":119,"15":15,"25":25,"47":47}],13:[function(_dereq_,module,exports){
  178. var aFunction = _dereq_(3);
  179. var toObject = _dereq_(119);
  180. var IObject = _dereq_(47);
  181. var toLength = _dereq_(118);
  182. module.exports = function (that, callbackfn, aLen, memo, isRight) {
  183. aFunction(callbackfn);
  184. var O = toObject(that);
  185. var self = IObject(O);
  186. var length = toLength(O.length);
  187. var index = isRight ? length - 1 : 0;
  188. var i = isRight ? -1 : 1;
  189. if (aLen < 2) for (;;) {
  190. if (index in self) {
  191. memo = self[index];
  192. index += i;
  193. break;
  194. }
  195. index += i;
  196. if (isRight ? index < 0 : length <= index) {
  197. throw TypeError('Reduce of empty array with no initial value');
  198. }
  199. }
  200. for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {
  201. memo = callbackfn(memo, self[index], index, O);
  202. }
  203. return memo;
  204. };
  205. },{"118":118,"119":119,"3":3,"47":47}],14:[function(_dereq_,module,exports){
  206. var isObject = _dereq_(51);
  207. var isArray = _dereq_(49);
  208. var SPECIES = _dereq_(128)('species');
  209. module.exports = function (original) {
  210. var C;
  211. if (isArray(original)) {
  212. C = original.constructor;
  213. // cross-realm fallback
  214. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  215. if (isObject(C)) {
  216. C = C[SPECIES];
  217. if (C === null) C = undefined;
  218. }
  219. } return C === undefined ? Array : C;
  220. };
  221. },{"128":128,"49":49,"51":51}],15:[function(_dereq_,module,exports){
  222. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  223. var speciesConstructor = _dereq_(14);
  224. module.exports = function (original, length) {
  225. return new (speciesConstructor(original))(length);
  226. };
  227. },{"14":14}],16:[function(_dereq_,module,exports){
  228. 'use strict';
  229. var aFunction = _dereq_(3);
  230. var isObject = _dereq_(51);
  231. var invoke = _dereq_(46);
  232. var arraySlice = [].slice;
  233. var factories = {};
  234. var construct = function (F, len, args) {
  235. if (!(len in factories)) {
  236. for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']';
  237. // eslint-disable-next-line no-new-func
  238. factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');
  239. } return factories[len](F, args);
  240. };
  241. module.exports = Function.bind || function bind(that /* , ...args */) {
  242. var fn = aFunction(this);
  243. var partArgs = arraySlice.call(arguments, 1);
  244. var bound = function (/* args... */) {
  245. var args = partArgs.concat(arraySlice.call(arguments));
  246. return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);
  247. };
  248. if (isObject(fn.prototype)) bound.prototype = fn.prototype;
  249. return bound;
  250. };
  251. },{"3":3,"46":46,"51":51}],17:[function(_dereq_,module,exports){
  252. // getting tag from 19.1.3.6 Object.prototype.toString()
  253. var cof = _dereq_(18);
  254. var TAG = _dereq_(128)('toStringTag');
  255. // ES3 wrong here
  256. var ARG = cof(function () { return arguments; }()) == 'Arguments';
  257. // fallback for IE11 Script Access Denied error
  258. var tryGet = function (it, key) {
  259. try {
  260. return it[key];
  261. } catch (e) { /* empty */ }
  262. };
  263. module.exports = function (it) {
  264. var O, T, B;
  265. return it === undefined ? 'Undefined' : it === null ? 'Null'
  266. // @@toStringTag case
  267. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  268. // builtinTag case
  269. : ARG ? cof(O)
  270. // ES3 arguments fallback
  271. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  272. };
  273. },{"128":128,"18":18}],18:[function(_dereq_,module,exports){
  274. var toString = {}.toString;
  275. module.exports = function (it) {
  276. return toString.call(it).slice(8, -1);
  277. };
  278. },{}],19:[function(_dereq_,module,exports){
  279. 'use strict';
  280. var dP = _dereq_(72).f;
  281. var create = _dereq_(71);
  282. var redefineAll = _dereq_(93);
  283. var ctx = _dereq_(25);
  284. var anInstance = _dereq_(6);
  285. var forOf = _dereq_(39);
  286. var $iterDefine = _dereq_(55);
  287. var step = _dereq_(57);
  288. var setSpecies = _dereq_(100);
  289. var DESCRIPTORS = _dereq_(29);
  290. var fastKey = _dereq_(66).fastKey;
  291. var validate = _dereq_(125);
  292. var SIZE = DESCRIPTORS ? '_s' : 'size';
  293. var getEntry = function (that, key) {
  294. // fast case
  295. var index = fastKey(key);
  296. var entry;
  297. if (index !== 'F') return that._i[index];
  298. // frozen object case
  299. for (entry = that._f; entry; entry = entry.n) {
  300. if (entry.k == key) return entry;
  301. }
  302. };
  303. module.exports = {
  304. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  305. var C = wrapper(function (that, iterable) {
  306. anInstance(that, C, NAME, '_i');
  307. that._t = NAME; // collection type
  308. that._i = create(null); // index
  309. that._f = undefined; // first entry
  310. that._l = undefined; // last entry
  311. that[SIZE] = 0; // size
  312. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  313. });
  314. redefineAll(C.prototype, {
  315. // 23.1.3.1 Map.prototype.clear()
  316. // 23.2.3.2 Set.prototype.clear()
  317. clear: function clear() {
  318. for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
  319. entry.r = true;
  320. if (entry.p) entry.p = entry.p.n = undefined;
  321. delete data[entry.i];
  322. }
  323. that._f = that._l = undefined;
  324. that[SIZE] = 0;
  325. },
  326. // 23.1.3.3 Map.prototype.delete(key)
  327. // 23.2.3.4 Set.prototype.delete(value)
  328. 'delete': function (key) {
  329. var that = validate(this, NAME);
  330. var entry = getEntry(that, key);
  331. if (entry) {
  332. var next = entry.n;
  333. var prev = entry.p;
  334. delete that._i[entry.i];
  335. entry.r = true;
  336. if (prev) prev.n = next;
  337. if (next) next.p = prev;
  338. if (that._f == entry) that._f = next;
  339. if (that._l == entry) that._l = prev;
  340. that[SIZE]--;
  341. } return !!entry;
  342. },
  343. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  344. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  345. forEach: function forEach(callbackfn /* , that = undefined */) {
  346. validate(this, NAME);
  347. var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
  348. var entry;
  349. while (entry = entry ? entry.n : this._f) {
  350. f(entry.v, entry.k, this);
  351. // revert to the last existing entry
  352. while (entry && entry.r) entry = entry.p;
  353. }
  354. },
  355. // 23.1.3.7 Map.prototype.has(key)
  356. // 23.2.3.7 Set.prototype.has(value)
  357. has: function has(key) {
  358. return !!getEntry(validate(this, NAME), key);
  359. }
  360. });
  361. if (DESCRIPTORS) dP(C.prototype, 'size', {
  362. get: function () {
  363. return validate(this, NAME)[SIZE];
  364. }
  365. });
  366. return C;
  367. },
  368. def: function (that, key, value) {
  369. var entry = getEntry(that, key);
  370. var prev, index;
  371. // change existing entry
  372. if (entry) {
  373. entry.v = value;
  374. // create new entry
  375. } else {
  376. that._l = entry = {
  377. i: index = fastKey(key, true), // <- index
  378. k: key, // <- key
  379. v: value, // <- value
  380. p: prev = that._l, // <- previous entry
  381. n: undefined, // <- next entry
  382. r: false // <- removed
  383. };
  384. if (!that._f) that._f = entry;
  385. if (prev) prev.n = entry;
  386. that[SIZE]++;
  387. // add to index
  388. if (index !== 'F') that._i[index] = entry;
  389. } return that;
  390. },
  391. getEntry: getEntry,
  392. setStrong: function (C, NAME, IS_MAP) {
  393. // add .keys, .values, .entries, [@@iterator]
  394. // 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
  395. $iterDefine(C, NAME, function (iterated, kind) {
  396. this._t = validate(iterated, NAME); // target
  397. this._k = kind; // kind
  398. this._l = undefined; // previous
  399. }, function () {
  400. var that = this;
  401. var kind = that._k;
  402. var entry = that._l;
  403. // revert to the last existing entry
  404. while (entry && entry.r) entry = entry.p;
  405. // get next entry
  406. if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
  407. // or finish the iteration
  408. that._t = undefined;
  409. return step(1);
  410. }
  411. // return step by kind
  412. if (kind == 'keys') return step(0, entry.k);
  413. if (kind == 'values') return step(0, entry.v);
  414. return step(0, [entry.k, entry.v]);
  415. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  416. // add [@@species], 23.1.2.2, 23.2.2.2
  417. setSpecies(NAME);
  418. }
  419. };
  420. },{"100":100,"125":125,"25":25,"29":29,"39":39,"55":55,"57":57,"6":6,"66":66,"71":71,"72":72,"93":93}],20:[function(_dereq_,module,exports){
  421. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  422. var classof = _dereq_(17);
  423. var from = _dereq_(10);
  424. module.exports = function (NAME) {
  425. return function toJSON() {
  426. if (classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
  427. return from(this);
  428. };
  429. };
  430. },{"10":10,"17":17}],21:[function(_dereq_,module,exports){
  431. 'use strict';
  432. var redefineAll = _dereq_(93);
  433. var getWeak = _dereq_(66).getWeak;
  434. var anObject = _dereq_(7);
  435. var isObject = _dereq_(51);
  436. var anInstance = _dereq_(6);
  437. var forOf = _dereq_(39);
  438. var createArrayMethod = _dereq_(12);
  439. var $has = _dereq_(41);
  440. var validate = _dereq_(125);
  441. var arrayFind = createArrayMethod(5);
  442. var arrayFindIndex = createArrayMethod(6);
  443. var id = 0;
  444. // fallback for uncaught frozen keys
  445. var uncaughtFrozenStore = function (that) {
  446. return that._l || (that._l = new UncaughtFrozenStore());
  447. };
  448. var UncaughtFrozenStore = function () {
  449. this.a = [];
  450. };
  451. var findUncaughtFrozen = function (store, key) {
  452. return arrayFind(store.a, function (it) {
  453. return it[0] === key;
  454. });
  455. };
  456. UncaughtFrozenStore.prototype = {
  457. get: function (key) {
  458. var entry = findUncaughtFrozen(this, key);
  459. if (entry) return entry[1];
  460. },
  461. has: function (key) {
  462. return !!findUncaughtFrozen(this, key);
  463. },
  464. set: function (key, value) {
  465. var entry = findUncaughtFrozen(this, key);
  466. if (entry) entry[1] = value;
  467. else this.a.push([key, value]);
  468. },
  469. 'delete': function (key) {
  470. var index = arrayFindIndex(this.a, function (it) {
  471. return it[0] === key;
  472. });
  473. if (~index) this.a.splice(index, 1);
  474. return !!~index;
  475. }
  476. };
  477. module.exports = {
  478. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  479. var C = wrapper(function (that, iterable) {
  480. anInstance(that, C, NAME, '_i');
  481. that._t = NAME; // collection type
  482. that._i = id++; // collection id
  483. that._l = undefined; // leak store for uncaught frozen objects
  484. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  485. });
  486. redefineAll(C.prototype, {
  487. // 23.3.3.2 WeakMap.prototype.delete(key)
  488. // 23.4.3.3 WeakSet.prototype.delete(value)
  489. 'delete': function (key) {
  490. if (!isObject(key)) return false;
  491. var data = getWeak(key);
  492. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  493. return data && $has(data, this._i) && delete data[this._i];
  494. },
  495. // 23.3.3.4 WeakMap.prototype.has(key)
  496. // 23.4.3.4 WeakSet.prototype.has(value)
  497. has: function has(key) {
  498. if (!isObject(key)) return false;
  499. var data = getWeak(key);
  500. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  501. return data && $has(data, this._i);
  502. }
  503. });
  504. return C;
  505. },
  506. def: function (that, key, value) {
  507. var data = getWeak(anObject(key), true);
  508. if (data === true) uncaughtFrozenStore(that).set(key, value);
  509. else data[that._i] = value;
  510. return that;
  511. },
  512. ufstore: uncaughtFrozenStore
  513. };
  514. },{"12":12,"125":125,"39":39,"41":41,"51":51,"6":6,"66":66,"7":7,"93":93}],22:[function(_dereq_,module,exports){
  515. 'use strict';
  516. var global = _dereq_(40);
  517. var $export = _dereq_(33);
  518. var redefine = _dereq_(94);
  519. var redefineAll = _dereq_(93);
  520. var meta = _dereq_(66);
  521. var forOf = _dereq_(39);
  522. var anInstance = _dereq_(6);
  523. var isObject = _dereq_(51);
  524. var fails = _dereq_(35);
  525. var $iterDetect = _dereq_(56);
  526. var setToStringTag = _dereq_(101);
  527. var inheritIfRequired = _dereq_(45);
  528. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  529. var Base = global[NAME];
  530. var C = Base;
  531. var ADDER = IS_MAP ? 'set' : 'add';
  532. var proto = C && C.prototype;
  533. var O = {};
  534. var fixMethod = function (KEY) {
  535. var fn = proto[KEY];
  536. redefine(proto, KEY,
  537. KEY == 'delete' ? function (a) {
  538. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  539. } : KEY == 'has' ? function has(a) {
  540. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  541. } : KEY == 'get' ? function get(a) {
  542. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  543. } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }
  544. : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }
  545. );
  546. };
  547. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  548. new C().entries().next();
  549. }))) {
  550. // create collection constructor
  551. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  552. redefineAll(C.prototype, methods);
  553. meta.NEED = true;
  554. } else {
  555. var instance = new C();
  556. // early implementations not supports chaining
  557. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  558. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  559. var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
  560. // most early implementations doesn't supports iterables, most modern - not close it correctly
  561. var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new
  562. // for early implementations -0 and +0 not the same
  563. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  564. // V8 ~ Chromium 42- fails only with 5+ elements
  565. var $instance = new C();
  566. var index = 5;
  567. while (index--) $instance[ADDER](index, index);
  568. return !$instance.has(-0);
  569. });
  570. if (!ACCEPT_ITERABLES) {
  571. C = wrapper(function (target, iterable) {
  572. anInstance(target, C, NAME);
  573. var that = inheritIfRequired(new Base(), target, C);
  574. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  575. return that;
  576. });
  577. C.prototype = proto;
  578. proto.constructor = C;
  579. }
  580. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  581. fixMethod('delete');
  582. fixMethod('has');
  583. IS_MAP && fixMethod('get');
  584. }
  585. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  586. // weak collections should not contains .clear method
  587. if (IS_WEAK && proto.clear) delete proto.clear;
  588. }
  589. setToStringTag(C, NAME);
  590. O[NAME] = C;
  591. $export($export.G + $export.W + $export.F * (C != Base), O);
  592. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  593. return C;
  594. };
  595. },{"101":101,"33":33,"35":35,"39":39,"40":40,"45":45,"51":51,"56":56,"6":6,"66":66,"93":93,"94":94}],23:[function(_dereq_,module,exports){
  596. var core = module.exports = { version: '2.5.0' };
  597. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  598. },{}],24:[function(_dereq_,module,exports){
  599. 'use strict';
  600. var $defineProperty = _dereq_(72);
  601. var createDesc = _dereq_(92);
  602. module.exports = function (object, index, value) {
  603. if (index in object) $defineProperty.f(object, index, createDesc(0, value));
  604. else object[index] = value;
  605. };
  606. },{"72":72,"92":92}],25:[function(_dereq_,module,exports){
  607. // optional / simple context binding
  608. var aFunction = _dereq_(3);
  609. module.exports = function (fn, that, length) {
  610. aFunction(fn);
  611. if (that === undefined) return fn;
  612. switch (length) {
  613. case 1: return function (a) {
  614. return fn.call(that, a);
  615. };
  616. case 2: return function (a, b) {
  617. return fn.call(that, a, b);
  618. };
  619. case 3: return function (a, b, c) {
  620. return fn.call(that, a, b, c);
  621. };
  622. }
  623. return function (/* ...args */) {
  624. return fn.apply(that, arguments);
  625. };
  626. };
  627. },{"3":3}],26:[function(_dereq_,module,exports){
  628. 'use strict';
  629. // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
  630. var fails = _dereq_(35);
  631. var getTime = Date.prototype.getTime;
  632. var $toISOString = Date.prototype.toISOString;
  633. var lz = function (num) {
  634. return num > 9 ? num : '0' + num;
  635. };
  636. // PhantomJS / old WebKit has a broken implementations
  637. module.exports = (fails(function () {
  638. return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
  639. }) || !fails(function () {
  640. $toISOString.call(new Date(NaN));
  641. })) ? function toISOString() {
  642. if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');
  643. var d = this;
  644. var y = d.getUTCFullYear();
  645. var m = d.getUTCMilliseconds();
  646. var s = y < 0 ? '-' : y > 9999 ? '+' : '';
  647. return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
  648. '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
  649. 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
  650. ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
  651. } : $toISOString;
  652. },{"35":35}],27:[function(_dereq_,module,exports){
  653. 'use strict';
  654. var anObject = _dereq_(7);
  655. var toPrimitive = _dereq_(120);
  656. var NUMBER = 'number';
  657. module.exports = function (hint) {
  658. if (hint !== 'string' && hint !== NUMBER && hint !== 'default') throw TypeError('Incorrect hint');
  659. return toPrimitive(anObject(this), hint != NUMBER);
  660. };
  661. },{"120":120,"7":7}],28:[function(_dereq_,module,exports){
  662. // 7.2.1 RequireObjectCoercible(argument)
  663. module.exports = function (it) {
  664. if (it == undefined) throw TypeError("Can't call method on " + it);
  665. return it;
  666. };
  667. },{}],29:[function(_dereq_,module,exports){
  668. // Thank's IE8 for his funny defineProperty
  669. module.exports = !_dereq_(35)(function () {
  670. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  671. });
  672. },{"35":35}],30:[function(_dereq_,module,exports){
  673. var isObject = _dereq_(51);
  674. var document = _dereq_(40).document;
  675. // typeof document.createElement is 'object' in old IE
  676. var is = isObject(document) && isObject(document.createElement);
  677. module.exports = function (it) {
  678. return is ? document.createElement(it) : {};
  679. };
  680. },{"40":40,"51":51}],31:[function(_dereq_,module,exports){
  681. // IE 8- don't enum bug keys
  682. module.exports = (
  683. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  684. ).split(',');
  685. },{}],32:[function(_dereq_,module,exports){
  686. // all enumerable object keys, includes symbols
  687. var getKeys = _dereq_(81);
  688. var gOPS = _dereq_(78);
  689. var pIE = _dereq_(82);
  690. module.exports = function (it) {
  691. var result = getKeys(it);
  692. var getSymbols = gOPS.f;
  693. if (getSymbols) {
  694. var symbols = getSymbols(it);
  695. var isEnum = pIE.f;
  696. var i = 0;
  697. var key;
  698. while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
  699. } return result;
  700. };
  701. },{"78":78,"81":81,"82":82}],33:[function(_dereq_,module,exports){
  702. var global = _dereq_(40);
  703. var core = _dereq_(23);
  704. var hide = _dereq_(42);
  705. var redefine = _dereq_(94);
  706. var ctx = _dereq_(25);
  707. var PROTOTYPE = 'prototype';
  708. var $export = function (type, name, source) {
  709. var IS_FORCED = type & $export.F;
  710. var IS_GLOBAL = type & $export.G;
  711. var IS_STATIC = type & $export.S;
  712. var IS_PROTO = type & $export.P;
  713. var IS_BIND = type & $export.B;
  714. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  715. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  716. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  717. var key, own, out, exp;
  718. if (IS_GLOBAL) source = name;
  719. for (key in source) {
  720. // contains in native
  721. own = !IS_FORCED && target && target[key] !== undefined;
  722. // export native or passed
  723. out = (own ? target : source)[key];
  724. // bind timers to global for call from export context
  725. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  726. // extend global
  727. if (target) redefine(target, key, out, type & $export.U);
  728. // export
  729. if (exports[key] != out) hide(exports, key, exp);
  730. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  731. }
  732. };
  733. global.core = core;
  734. // type bitmap
  735. $export.F = 1; // forced
  736. $export.G = 2; // global
  737. $export.S = 4; // static
  738. $export.P = 8; // proto
  739. $export.B = 16; // bind
  740. $export.W = 32; // wrap
  741. $export.U = 64; // safe
  742. $export.R = 128; // real proto method for `library`
  743. module.exports = $export;
  744. },{"23":23,"25":25,"40":40,"42":42,"94":94}],34:[function(_dereq_,module,exports){
  745. var MATCH = _dereq_(128)('match');
  746. module.exports = function (KEY) {
  747. var re = /./;
  748. try {
  749. '/./'[KEY](re);
  750. } catch (e) {
  751. try {
  752. re[MATCH] = false;
  753. return !'/./'[KEY](re);
  754. } catch (f) { /* empty */ }
  755. } return true;
  756. };
  757. },{"128":128}],35:[function(_dereq_,module,exports){
  758. module.exports = function (exec) {
  759. try {
  760. return !!exec();
  761. } catch (e) {
  762. return true;
  763. }
  764. };
  765. },{}],36:[function(_dereq_,module,exports){
  766. 'use strict';
  767. var hide = _dereq_(42);
  768. var redefine = _dereq_(94);
  769. var fails = _dereq_(35);
  770. var defined = _dereq_(28);
  771. var wks = _dereq_(128);
  772. module.exports = function (KEY, length, exec) {
  773. var SYMBOL = wks(KEY);
  774. var fns = exec(defined, SYMBOL, ''[KEY]);
  775. var strfn = fns[0];
  776. var rxfn = fns[1];
  777. if (fails(function () {
  778. var O = {};
  779. O[SYMBOL] = function () { return 7; };
  780. return ''[KEY](O) != 7;
  781. })) {
  782. redefine(String.prototype, KEY, strfn);
  783. hide(RegExp.prototype, SYMBOL, length == 2
  784. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  785. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  786. ? function (string, arg) { return rxfn.call(string, this, arg); }
  787. // 21.2.5.6 RegExp.prototype[@@match](string)
  788. // 21.2.5.9 RegExp.prototype[@@search](string)
  789. : function (string) { return rxfn.call(string, this); }
  790. );
  791. }
  792. };
  793. },{"128":128,"28":28,"35":35,"42":42,"94":94}],37:[function(_dereq_,module,exports){
  794. 'use strict';
  795. // 21.2.5.3 get RegExp.prototype.flags
  796. var anObject = _dereq_(7);
  797. module.exports = function () {
  798. var that = anObject(this);
  799. var result = '';
  800. if (that.global) result += 'g';
  801. if (that.ignoreCase) result += 'i';
  802. if (that.multiline) result += 'm';
  803. if (that.unicode) result += 'u';
  804. if (that.sticky) result += 'y';
  805. return result;
  806. };
  807. },{"7":7}],38:[function(_dereq_,module,exports){
  808. 'use strict';
  809. // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
  810. var isArray = _dereq_(49);
  811. var isObject = _dereq_(51);
  812. var toLength = _dereq_(118);
  813. var ctx = _dereq_(25);
  814. var IS_CONCAT_SPREADABLE = _dereq_(128)('isConcatSpreadable');
  815. function flattenIntoArray(target, original, source, sourceLen, start, depth, mapper, thisArg) {
  816. var targetIndex = start;
  817. var sourceIndex = 0;
  818. var mapFn = mapper ? ctx(mapper, thisArg, 3) : false;
  819. var element, spreadable;
  820. while (sourceIndex < sourceLen) {
  821. if (sourceIndex in source) {
  822. element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
  823. spreadable = false;
  824. if (isObject(element)) {
  825. spreadable = element[IS_CONCAT_SPREADABLE];
  826. spreadable = spreadable !== undefined ? !!spreadable : isArray(element);
  827. }
  828. if (spreadable && depth > 0) {
  829. targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;
  830. } else {
  831. if (targetIndex >= 0x1fffffffffffff) throw TypeError();
  832. target[targetIndex] = element;
  833. }
  834. targetIndex++;
  835. }
  836. sourceIndex++;
  837. }
  838. return targetIndex;
  839. }
  840. module.exports = flattenIntoArray;
  841. },{"118":118,"128":128,"25":25,"49":49,"51":51}],39:[function(_dereq_,module,exports){
  842. var ctx = _dereq_(25);
  843. var call = _dereq_(53);
  844. var isArrayIter = _dereq_(48);
  845. var anObject = _dereq_(7);
  846. var toLength = _dereq_(118);
  847. var getIterFn = _dereq_(129);
  848. var BREAK = {};
  849. var RETURN = {};
  850. var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  851. var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
  852. var f = ctx(fn, that, entries ? 2 : 1);
  853. var index = 0;
  854. var length, step, iterator, result;
  855. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  856. // fast case for arrays with default iterator
  857. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  858. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  859. if (result === BREAK || result === RETURN) return result;
  860. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  861. result = call(iterator, f, step.value, entries);
  862. if (result === BREAK || result === RETURN) return result;
  863. }
  864. };
  865. exports.BREAK = BREAK;
  866. exports.RETURN = RETURN;
  867. },{"118":118,"129":129,"25":25,"48":48,"53":53,"7":7}],40:[function(_dereq_,module,exports){
  868. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  869. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  870. ? window : typeof self != 'undefined' && self.Math == Math ? self
  871. // eslint-disable-next-line no-new-func
  872. : Function('return this')();
  873. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  874. },{}],41:[function(_dereq_,module,exports){
  875. var hasOwnProperty = {}.hasOwnProperty;
  876. module.exports = function (it, key) {
  877. return hasOwnProperty.call(it, key);
  878. };
  879. },{}],42:[function(_dereq_,module,exports){
  880. var dP = _dereq_(72);
  881. var createDesc = _dereq_(92);
  882. module.exports = _dereq_(29) ? function (object, key, value) {
  883. return dP.f(object, key, createDesc(1, value));
  884. } : function (object, key, value) {
  885. object[key] = value;
  886. return object;
  887. };
  888. },{"29":29,"72":72,"92":92}],43:[function(_dereq_,module,exports){
  889. var document = _dereq_(40).document;
  890. module.exports = document && document.documentElement;
  891. },{"40":40}],44:[function(_dereq_,module,exports){
  892. module.exports = !_dereq_(29) && !_dereq_(35)(function () {
  893. return Object.defineProperty(_dereq_(30)('div'), 'a', { get: function () { return 7; } }).a != 7;
  894. });
  895. },{"29":29,"30":30,"35":35}],45:[function(_dereq_,module,exports){
  896. var isObject = _dereq_(51);
  897. var setPrototypeOf = _dereq_(99).set;
  898. module.exports = function (that, target, C) {
  899. var S = target.constructor;
  900. var P;
  901. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  902. setPrototypeOf(that, P);
  903. } return that;
  904. };
  905. },{"51":51,"99":99}],46:[function(_dereq_,module,exports){
  906. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  907. module.exports = function (fn, args, that) {
  908. var un = that === undefined;
  909. switch (args.length) {
  910. case 0: return un ? fn()
  911. : fn.call(that);
  912. case 1: return un ? fn(args[0])
  913. : fn.call(that, args[0]);
  914. case 2: return un ? fn(args[0], args[1])
  915. : fn.call(that, args[0], args[1]);
  916. case 3: return un ? fn(args[0], args[1], args[2])
  917. : fn.call(that, args[0], args[1], args[2]);
  918. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  919. : fn.call(that, args[0], args[1], args[2], args[3]);
  920. } return fn.apply(that, args);
  921. };
  922. },{}],47:[function(_dereq_,module,exports){
  923. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  924. var cof = _dereq_(18);
  925. // eslint-disable-next-line no-prototype-builtins
  926. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  927. return cof(it) == 'String' ? it.split('') : Object(it);
  928. };
  929. },{"18":18}],48:[function(_dereq_,module,exports){
  930. // check on default Array iterator
  931. var Iterators = _dereq_(58);
  932. var ITERATOR = _dereq_(128)('iterator');
  933. var ArrayProto = Array.prototype;
  934. module.exports = function (it) {
  935. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  936. };
  937. },{"128":128,"58":58}],49:[function(_dereq_,module,exports){
  938. // 7.2.2 IsArray(argument)
  939. var cof = _dereq_(18);
  940. module.exports = Array.isArray || function isArray(arg) {
  941. return cof(arg) == 'Array';
  942. };
  943. },{"18":18}],50:[function(_dereq_,module,exports){
  944. // 20.1.2.3 Number.isInteger(number)
  945. var isObject = _dereq_(51);
  946. var floor = Math.floor;
  947. module.exports = function isInteger(it) {
  948. return !isObject(it) && isFinite(it) && floor(it) === it;
  949. };
  950. },{"51":51}],51:[function(_dereq_,module,exports){
  951. module.exports = function (it) {
  952. return typeof it === 'object' ? it !== null : typeof it === 'function';
  953. };
  954. },{}],52:[function(_dereq_,module,exports){
  955. // 7.2.8 IsRegExp(argument)
  956. var isObject = _dereq_(51);
  957. var cof = _dereq_(18);
  958. var MATCH = _dereq_(128)('match');
  959. module.exports = function (it) {
  960. var isRegExp;
  961. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  962. };
  963. },{"128":128,"18":18,"51":51}],53:[function(_dereq_,module,exports){
  964. // call something on iterator step with safe closing on error
  965. var anObject = _dereq_(7);
  966. module.exports = function (iterator, fn, value, entries) {
  967. try {
  968. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  969. // 7.4.6 IteratorClose(iterator, completion)
  970. } catch (e) {
  971. var ret = iterator['return'];
  972. if (ret !== undefined) anObject(ret.call(iterator));
  973. throw e;
  974. }
  975. };
  976. },{"7":7}],54:[function(_dereq_,module,exports){
  977. 'use strict';
  978. var create = _dereq_(71);
  979. var descriptor = _dereq_(92);
  980. var setToStringTag = _dereq_(101);
  981. var IteratorPrototype = {};
  982. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  983. _dereq_(42)(IteratorPrototype, _dereq_(128)('iterator'), function () { return this; });
  984. module.exports = function (Constructor, NAME, next) {
  985. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  986. setToStringTag(Constructor, NAME + ' Iterator');
  987. };
  988. },{"101":101,"128":128,"42":42,"71":71,"92":92}],55:[function(_dereq_,module,exports){
  989. 'use strict';
  990. var LIBRARY = _dereq_(60);
  991. var $export = _dereq_(33);
  992. var redefine = _dereq_(94);
  993. var hide = _dereq_(42);
  994. var has = _dereq_(41);
  995. var Iterators = _dereq_(58);
  996. var $iterCreate = _dereq_(54);
  997. var setToStringTag = _dereq_(101);
  998. var getPrototypeOf = _dereq_(79);
  999. var ITERATOR = _dereq_(128)('iterator');
  1000. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  1001. var FF_ITERATOR = '@@iterator';
  1002. var KEYS = 'keys';
  1003. var VALUES = 'values';
  1004. var returnThis = function () { return this; };
  1005. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  1006. $iterCreate(Constructor, NAME, next);
  1007. var getMethod = function (kind) {
  1008. if (!BUGGY && kind in proto) return proto[kind];
  1009. switch (kind) {
  1010. case KEYS: return function keys() { return new Constructor(this, kind); };
  1011. case VALUES: return function values() { return new Constructor(this, kind); };
  1012. } return function entries() { return new Constructor(this, kind); };
  1013. };
  1014. var TAG = NAME + ' Iterator';
  1015. var DEF_VALUES = DEFAULT == VALUES;
  1016. var VALUES_BUG = false;
  1017. var proto = Base.prototype;
  1018. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  1019. var $default = $native || getMethod(DEFAULT);
  1020. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  1021. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  1022. var methods, key, IteratorPrototype;
  1023. // Fix native
  1024. if ($anyNative) {
  1025. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  1026. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  1027. // Set @@toStringTag to native iterators
  1028. setToStringTag(IteratorPrototype, TAG, true);
  1029. // fix for some old engines
  1030. if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
  1031. }
  1032. }
  1033. // fix Array#{values, @@iterator}.name in V8 / FF
  1034. if (DEF_VALUES && $native && $native.name !== VALUES) {
  1035. VALUES_BUG = true;
  1036. $default = function values() { return $native.call(this); };
  1037. }
  1038. // Define iterator
  1039. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  1040. hide(proto, ITERATOR, $default);
  1041. }
  1042. // Plug for library
  1043. Iterators[NAME] = $default;
  1044. Iterators[TAG] = returnThis;
  1045. if (DEFAULT) {
  1046. methods = {
  1047. values: DEF_VALUES ? $default : getMethod(VALUES),
  1048. keys: IS_SET ? $default : getMethod(KEYS),
  1049. entries: $entries
  1050. };
  1051. if (FORCED) for (key in methods) {
  1052. if (!(key in proto)) redefine(proto, key, methods[key]);
  1053. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  1054. }
  1055. return methods;
  1056. };
  1057. },{"101":101,"128":128,"33":33,"41":41,"42":42,"54":54,"58":58,"60":60,"79":79,"94":94}],56:[function(_dereq_,module,exports){
  1058. var ITERATOR = _dereq_(128)('iterator');
  1059. var SAFE_CLOSING = false;
  1060. try {
  1061. var riter = [7][ITERATOR]();
  1062. riter['return'] = function () { SAFE_CLOSING = true; };
  1063. // eslint-disable-next-line no-throw-literal
  1064. Array.from(riter, function () { throw 2; });
  1065. } catch (e) { /* empty */ }
  1066. module.exports = function (exec, skipClosing) {
  1067. if (!skipClosing && !SAFE_CLOSING) return false;
  1068. var safe = false;
  1069. try {
  1070. var arr = [7];
  1071. var iter = arr[ITERATOR]();
  1072. iter.next = function () { return { done: safe = true }; };
  1073. arr[ITERATOR] = function () { return iter; };
  1074. exec(arr);
  1075. } catch (e) { /* empty */ }
  1076. return safe;
  1077. };
  1078. },{"128":128}],57:[function(_dereq_,module,exports){
  1079. module.exports = function (done, value) {
  1080. return { value: value, done: !!done };
  1081. };
  1082. },{}],58:[function(_dereq_,module,exports){
  1083. module.exports = {};
  1084. },{}],59:[function(_dereq_,module,exports){
  1085. var getKeys = _dereq_(81);
  1086. var toIObject = _dereq_(117);
  1087. module.exports = function (object, el) {
  1088. var O = toIObject(object);
  1089. var keys = getKeys(O);
  1090. var length = keys.length;
  1091. var index = 0;
  1092. var key;
  1093. while (length > index) if (O[key = keys[index++]] === el) return key;
  1094. };
  1095. },{"117":117,"81":81}],60:[function(_dereq_,module,exports){
  1096. module.exports = false;
  1097. },{}],61:[function(_dereq_,module,exports){
  1098. // 20.2.2.14 Math.expm1(x)
  1099. var $expm1 = Math.expm1;
  1100. module.exports = (!$expm1
  1101. // Old FF bug
  1102. || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168
  1103. // Tor Browser bug
  1104. || $expm1(-2e-17) != -2e-17
  1105. ) ? function expm1(x) {
  1106. return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;
  1107. } : $expm1;
  1108. },{}],62:[function(_dereq_,module,exports){
  1109. // 20.2.2.16 Math.fround(x)
  1110. var sign = _dereq_(65);
  1111. var pow = Math.pow;
  1112. var EPSILON = pow(2, -52);
  1113. var EPSILON32 = pow(2, -23);
  1114. var MAX32 = pow(2, 127) * (2 - EPSILON32);
  1115. var MIN32 = pow(2, -126);
  1116. var roundTiesToEven = function (n) {
  1117. return n + 1 / EPSILON - 1 / EPSILON;
  1118. };
  1119. module.exports = Math.fround || function fround(x) {
  1120. var $abs = Math.abs(x);
  1121. var $sign = sign(x);
  1122. var a, result;
  1123. if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
  1124. a = (1 + EPSILON32 / EPSILON) * $abs;
  1125. result = a - (a - $abs);
  1126. // eslint-disable-next-line no-self-compare
  1127. if (result > MAX32 || result != result) return $sign * Infinity;
  1128. return $sign * result;
  1129. };
  1130. },{"65":65}],63:[function(_dereq_,module,exports){
  1131. // 20.2.2.20 Math.log1p(x)
  1132. module.exports = Math.log1p || function log1p(x) {
  1133. return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);
  1134. };
  1135. },{}],64:[function(_dereq_,module,exports){
  1136. // https://rwaldron.github.io/proposal-math-extensions/
  1137. module.exports = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) {
  1138. if (
  1139. arguments.length === 0
  1140. // eslint-disable-next-line no-self-compare
  1141. || x != x
  1142. // eslint-disable-next-line no-self-compare
  1143. || inLow != inLow
  1144. // eslint-disable-next-line no-self-compare
  1145. || inHigh != inHigh
  1146. // eslint-disable-next-line no-self-compare
  1147. || outLow != outLow
  1148. // eslint-disable-next-line no-self-compare
  1149. || outHigh != outHigh
  1150. ) return NaN;
  1151. if (x === Infinity || x === -Infinity) return x;
  1152. return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow;
  1153. };
  1154. },{}],65:[function(_dereq_,module,exports){
  1155. // 20.2.2.28 Math.sign(x)
  1156. module.exports = Math.sign || function sign(x) {
  1157. // eslint-disable-next-line no-self-compare
  1158. return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
  1159. };
  1160. },{}],66:[function(_dereq_,module,exports){
  1161. var META = _dereq_(124)('meta');
  1162. var isObject = _dereq_(51);
  1163. var has = _dereq_(41);
  1164. var setDesc = _dereq_(72).f;
  1165. var id = 0;
  1166. var isExtensible = Object.isExtensible || function () {
  1167. return true;
  1168. };
  1169. var FREEZE = !_dereq_(35)(function () {
  1170. return isExtensible(Object.preventExtensions({}));
  1171. });
  1172. var setMeta = function (it) {
  1173. setDesc(it, META, { value: {
  1174. i: 'O' + ++id, // object ID
  1175. w: {} // weak collections IDs
  1176. } });
  1177. };
  1178. var fastKey = function (it, create) {
  1179. // return primitive with prefix
  1180. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  1181. if (!has(it, META)) {
  1182. // can't set metadata to uncaught frozen object
  1183. if (!isExtensible(it)) return 'F';
  1184. // not necessary to add metadata
  1185. if (!create) return 'E';
  1186. // add missing metadata
  1187. setMeta(it);
  1188. // return object ID
  1189. } return it[META].i;
  1190. };
  1191. var getWeak = function (it, create) {
  1192. if (!has(it, META)) {
  1193. // can't set metadata to uncaught frozen object
  1194. if (!isExtensible(it)) return true;
  1195. // not necessary to add metadata
  1196. if (!create) return false;
  1197. // add missing metadata
  1198. setMeta(it);
  1199. // return hash weak collections IDs
  1200. } return it[META].w;
  1201. };
  1202. // add metadata on freeze-family methods calling
  1203. var onFreeze = function (it) {
  1204. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  1205. return it;
  1206. };
  1207. var meta = module.exports = {
  1208. KEY: META,
  1209. NEED: false,
  1210. fastKey: fastKey,
  1211. getWeak: getWeak,
  1212. onFreeze: onFreeze
  1213. };
  1214. },{"124":124,"35":35,"41":41,"51":51,"72":72}],67:[function(_dereq_,module,exports){
  1215. var Map = _dereq_(160);
  1216. var $export = _dereq_(33);
  1217. var shared = _dereq_(103)('metadata');
  1218. var store = shared.store || (shared.store = new (_dereq_(266))());
  1219. var getOrCreateMetadataMap = function (target, targetKey, create) {
  1220. var targetMetadata = store.get(target);
  1221. if (!targetMetadata) {
  1222. if (!create) return undefined;
  1223. store.set(target, targetMetadata = new Map());
  1224. }
  1225. var keyMetadata = targetMetadata.get(targetKey);
  1226. if (!keyMetadata) {
  1227. if (!create) return undefined;
  1228. targetMetadata.set(targetKey, keyMetadata = new Map());
  1229. } return keyMetadata;
  1230. };
  1231. var ordinaryHasOwnMetadata = function (MetadataKey, O, P) {
  1232. var metadataMap = getOrCreateMetadataMap(O, P, false);
  1233. return metadataMap === undefined ? false : metadataMap.has(MetadataKey);
  1234. };
  1235. var ordinaryGetOwnMetadata = function (MetadataKey, O, P) {
  1236. var metadataMap = getOrCreateMetadataMap(O, P, false);
  1237. return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
  1238. };
  1239. var ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) {
  1240. getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
  1241. };
  1242. var ordinaryOwnMetadataKeys = function (target, targetKey) {
  1243. var metadataMap = getOrCreateMetadataMap(target, targetKey, false);
  1244. var keys = [];
  1245. if (metadataMap) metadataMap.forEach(function (_, key) { keys.push(key); });
  1246. return keys;
  1247. };
  1248. var toMetaKey = function (it) {
  1249. return it === undefined || typeof it == 'symbol' ? it : String(it);
  1250. };
  1251. var exp = function (O) {
  1252. $export($export.S, 'Reflect', O);
  1253. };
  1254. module.exports = {
  1255. store: store,
  1256. map: getOrCreateMetadataMap,
  1257. has: ordinaryHasOwnMetadata,
  1258. get: ordinaryGetOwnMetadata,
  1259. set: ordinaryDefineOwnMetadata,
  1260. keys: ordinaryOwnMetadataKeys,
  1261. key: toMetaKey,
  1262. exp: exp
  1263. };
  1264. },{"103":103,"160":160,"266":266,"33":33}],68:[function(_dereq_,module,exports){
  1265. var global = _dereq_(40);
  1266. var macrotask = _dereq_(113).set;
  1267. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  1268. var process = global.process;
  1269. var Promise = global.Promise;
  1270. var isNode = _dereq_(18)(process) == 'process';
  1271. module.exports = function () {
  1272. var head, last, notify;
  1273. var flush = function () {
  1274. var parent, fn;
  1275. if (isNode && (parent = process.domain)) parent.exit();
  1276. while (head) {
  1277. fn = head.fn;
  1278. head = head.next;
  1279. try {
  1280. fn();
  1281. } catch (e) {
  1282. if (head) notify();
  1283. else last = undefined;
  1284. throw e;
  1285. }
  1286. } last = undefined;
  1287. if (parent) parent.enter();
  1288. };
  1289. // Node.js
  1290. if (isNode) {
  1291. notify = function () {
  1292. process.nextTick(flush);
  1293. };
  1294. // browsers with MutationObserver
  1295. } else if (Observer) {
  1296. var toggle = true;
  1297. var node = document.createTextNode('');
  1298. new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
  1299. notify = function () {
  1300. node.data = toggle = !toggle;
  1301. };
  1302. // environments with maybe non-completely correct, but existent Promise
  1303. } else if (Promise && Promise.resolve) {
  1304. var promise = Promise.resolve();
  1305. notify = function () {
  1306. promise.then(flush);
  1307. };
  1308. // for other environments - macrotask based on:
  1309. // - setImmediate
  1310. // - MessageChannel
  1311. // - window.postMessag
  1312. // - onreadystatechange
  1313. // - setTimeout
  1314. } else {
  1315. notify = function () {
  1316. // strange IE + webpack dev server bug - use .call(global)
  1317. macrotask.call(global, flush);
  1318. };
  1319. }
  1320. return function (fn) {
  1321. var task = { fn: fn, next: undefined };
  1322. if (last) last.next = task;
  1323. if (!head) {
  1324. head = task;
  1325. notify();
  1326. } last = task;
  1327. };
  1328. };
  1329. },{"113":113,"18":18,"40":40}],69:[function(_dereq_,module,exports){
  1330. 'use strict';
  1331. // 25.4.1.5 NewPromiseCapability(C)
  1332. var aFunction = _dereq_(3);
  1333. function PromiseCapability(C) {
  1334. var resolve, reject;
  1335. this.promise = new C(function ($$resolve, $$reject) {
  1336. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  1337. resolve = $$resolve;
  1338. reject = $$reject;
  1339. });
  1340. this.resolve = aFunction(resolve);
  1341. this.reject = aFunction(reject);
  1342. }
  1343. module.exports.f = function (C) {
  1344. return new PromiseCapability(C);
  1345. };
  1346. },{"3":3}],70:[function(_dereq_,module,exports){
  1347. 'use strict';
  1348. // 19.1.2.1 Object.assign(target, source, ...)
  1349. var getKeys = _dereq_(81);
  1350. var gOPS = _dereq_(78);
  1351. var pIE = _dereq_(82);
  1352. var toObject = _dereq_(119);
  1353. var IObject = _dereq_(47);
  1354. var $assign = Object.assign;
  1355. // should work with symbols and should have deterministic property order (V8 bug)
  1356. module.exports = !$assign || _dereq_(35)(function () {
  1357. var A = {};
  1358. var B = {};
  1359. // eslint-disable-next-line no-undef
  1360. var S = Symbol();
  1361. var K = 'abcdefghijklmnopqrst';
  1362. A[S] = 7;
  1363. K.split('').forEach(function (k) { B[k] = k; });
  1364. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  1365. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  1366. var T = toObject(target);
  1367. var aLen = arguments.length;
  1368. var index = 1;
  1369. var getSymbols = gOPS.f;
  1370. var isEnum = pIE.f;
  1371. while (aLen > index) {
  1372. var S = IObject(arguments[index++]);
  1373. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  1374. var length = keys.length;
  1375. var j = 0;
  1376. var key;
  1377. while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  1378. } return T;
  1379. } : $assign;
  1380. },{"119":119,"35":35,"47":47,"78":78,"81":81,"82":82}],71:[function(_dereq_,module,exports){
  1381. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  1382. var anObject = _dereq_(7);
  1383. var dPs = _dereq_(73);
  1384. var enumBugKeys = _dereq_(31);
  1385. var IE_PROTO = _dereq_(102)('IE_PROTO');
  1386. var Empty = function () { /* empty */ };
  1387. var PROTOTYPE = 'prototype';
  1388. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  1389. var createDict = function () {
  1390. // Thrash, waste and sodomy: IE GC bug
  1391. var iframe = _dereq_(30)('iframe');
  1392. var i = enumBugKeys.length;
  1393. var lt = '<';
  1394. var gt = '>';
  1395. var iframeDocument;
  1396. iframe.style.display = 'none';
  1397. _dereq_(43).appendChild(iframe);
  1398. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  1399. // createDict = iframe.contentWindow.Object;
  1400. // html.removeChild(iframe);
  1401. iframeDocument = iframe.contentWindow.document;
  1402. iframeDocument.open();
  1403. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  1404. iframeDocument.close();
  1405. createDict = iframeDocument.F;
  1406. while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
  1407. return createDict();
  1408. };
  1409. module.exports = Object.create || function create(O, Properties) {
  1410. var result;
  1411. if (O !== null) {
  1412. Empty[PROTOTYPE] = anObject(O);
  1413. result = new Empty();
  1414. Empty[PROTOTYPE] = null;
  1415. // add "__proto__" for Object.getPrototypeOf polyfill
  1416. result[IE_PROTO] = O;
  1417. } else result = createDict();
  1418. return Properties === undefined ? result : dPs(result, Properties);
  1419. };
  1420. },{"102":102,"30":30,"31":31,"43":43,"7":7,"73":73}],72:[function(_dereq_,module,exports){
  1421. var anObject = _dereq_(7);
  1422. var IE8_DOM_DEFINE = _dereq_(44);
  1423. var toPrimitive = _dereq_(120);
  1424. var dP = Object.defineProperty;
  1425. exports.f = _dereq_(29) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  1426. anObject(O);
  1427. P = toPrimitive(P, true);
  1428. anObject(Attributes);
  1429. if (IE8_DOM_DEFINE) try {
  1430. return dP(O, P, Attributes);
  1431. } catch (e) { /* empty */ }
  1432. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  1433. if ('value' in Attributes) O[P] = Attributes.value;
  1434. return O;
  1435. };
  1436. },{"120":120,"29":29,"44":44,"7":7}],73:[function(_dereq_,module,exports){
  1437. var dP = _dereq_(72);
  1438. var anObject = _dereq_(7);
  1439. var getKeys = _dereq_(81);
  1440. module.exports = _dereq_(29) ? Object.defineProperties : function defineProperties(O, Properties) {
  1441. anObject(O);
  1442. var keys = getKeys(Properties);
  1443. var length = keys.length;
  1444. var i = 0;
  1445. var P;
  1446. while (length > i) dP.f(O, P = keys[i++], Properties[P]);
  1447. return O;
  1448. };
  1449. },{"29":29,"7":7,"72":72,"81":81}],74:[function(_dereq_,module,exports){
  1450. 'use strict';
  1451. // Forced replacement prototype accessors methods
  1452. module.exports = _dereq_(60) || !_dereq_(35)(function () {
  1453. var K = Math.random();
  1454. // In FF throws only define methods
  1455. // eslint-disable-next-line no-undef, no-useless-call
  1456. __defineSetter__.call(null, K, function () { /* empty */ });
  1457. delete _dereq_(40)[K];
  1458. });
  1459. },{"35":35,"40":40,"60":60}],75:[function(_dereq_,module,exports){
  1460. var pIE = _dereq_(82);
  1461. var createDesc = _dereq_(92);
  1462. var toIObject = _dereq_(117);
  1463. var toPrimitive = _dereq_(120);
  1464. var has = _dereq_(41);
  1465. var IE8_DOM_DEFINE = _dereq_(44);
  1466. var gOPD = Object.getOwnPropertyDescriptor;
  1467. exports.f = _dereq_(29) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  1468. O = toIObject(O);
  1469. P = toPrimitive(P, true);
  1470. if (IE8_DOM_DEFINE) try {
  1471. return gOPD(O, P);
  1472. } catch (e) { /* empty */ }
  1473. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  1474. };
  1475. },{"117":117,"120":120,"29":29,"41":41,"44":44,"82":82,"92":92}],76:[function(_dereq_,module,exports){
  1476. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  1477. var toIObject = _dereq_(117);
  1478. var gOPN = _dereq_(77).f;
  1479. var toString = {}.toString;
  1480. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  1481. ? Object.getOwnPropertyNames(window) : [];
  1482. var getWindowNames = function (it) {
  1483. try {
  1484. return gOPN(it);
  1485. } catch (e) {
  1486. return windowNames.slice();
  1487. }
  1488. };
  1489. module.exports.f = function getOwnPropertyNames(it) {
  1490. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  1491. };
  1492. },{"117":117,"77":77}],77:[function(_dereq_,module,exports){
  1493. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  1494. var $keys = _dereq_(80);
  1495. var hiddenKeys = _dereq_(31).concat('length', 'prototype');
  1496. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1497. return $keys(O, hiddenKeys);
  1498. };
  1499. },{"31":31,"80":80}],78:[function(_dereq_,module,exports){
  1500. exports.f = Object.getOwnPropertySymbols;
  1501. },{}],79:[function(_dereq_,module,exports){
  1502. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  1503. var has = _dereq_(41);
  1504. var toObject = _dereq_(119);
  1505. var IE_PROTO = _dereq_(102)('IE_PROTO');
  1506. var ObjectProto = Object.prototype;
  1507. module.exports = Object.getPrototypeOf || function (O) {
  1508. O = toObject(O);
  1509. if (has(O, IE_PROTO)) return O[IE_PROTO];
  1510. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  1511. return O.constructor.prototype;
  1512. } return O instanceof Object ? ObjectProto : null;
  1513. };
  1514. },{"102":102,"119":119,"41":41}],80:[function(_dereq_,module,exports){
  1515. var has = _dereq_(41);
  1516. var toIObject = _dereq_(117);
  1517. var arrayIndexOf = _dereq_(11)(false);
  1518. var IE_PROTO = _dereq_(102)('IE_PROTO');
  1519. module.exports = function (object, names) {
  1520. var O = toIObject(object);
  1521. var i = 0;
  1522. var result = [];
  1523. var key;
  1524. for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
  1525. // Don't enum bug & hidden keys
  1526. while (names.length > i) if (has(O, key = names[i++])) {
  1527. ~arrayIndexOf(result, key) || result.push(key);
  1528. }
  1529. return result;
  1530. };
  1531. },{"102":102,"11":11,"117":117,"41":41}],81:[function(_dereq_,module,exports){
  1532. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  1533. var $keys = _dereq_(80);
  1534. var enumBugKeys = _dereq_(31);
  1535. module.exports = Object.keys || function keys(O) {
  1536. return $keys(O, enumBugKeys);
  1537. };
  1538. },{"31":31,"80":80}],82:[function(_dereq_,module,exports){
  1539. exports.f = {}.propertyIsEnumerable;
  1540. },{}],83:[function(_dereq_,module,exports){
  1541. // most Object methods by ES6 should accept primitives
  1542. var $export = _dereq_(33);
  1543. var core = _dereq_(23);
  1544. var fails = _dereq_(35);
  1545. module.exports = function (KEY, exec) {
  1546. var fn = (core.Object || {})[KEY] || Object[KEY];
  1547. var exp = {};
  1548. exp[KEY] = exec(fn);
  1549. $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
  1550. };
  1551. },{"23":23,"33":33,"35":35}],84:[function(_dereq_,module,exports){
  1552. var getKeys = _dereq_(81);
  1553. var toIObject = _dereq_(117);
  1554. var isEnum = _dereq_(82).f;
  1555. module.exports = function (isEntries) {
  1556. return function (it) {
  1557. var O = toIObject(it);
  1558. var keys = getKeys(O);
  1559. var length = keys.length;
  1560. var i = 0;
  1561. var result = [];
  1562. var key;
  1563. while (length > i) if (isEnum.call(O, key = keys[i++])) {
  1564. result.push(isEntries ? [key, O[key]] : O[key]);
  1565. } return result;
  1566. };
  1567. };
  1568. },{"117":117,"81":81,"82":82}],85:[function(_dereq_,module,exports){
  1569. // all object keys, includes non-enumerable and symbols
  1570. var gOPN = _dereq_(77);
  1571. var gOPS = _dereq_(78);
  1572. var anObject = _dereq_(7);
  1573. var Reflect = _dereq_(40).Reflect;
  1574. module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {
  1575. var keys = gOPN.f(anObject(it));
  1576. var getSymbols = gOPS.f;
  1577. return getSymbols ? keys.concat(getSymbols(it)) : keys;
  1578. };
  1579. },{"40":40,"7":7,"77":77,"78":78}],86:[function(_dereq_,module,exports){
  1580. var $parseFloat = _dereq_(40).parseFloat;
  1581. var $trim = _dereq_(111).trim;
  1582. module.exports = 1 / $parseFloat(_dereq_(112) + '-0') !== -Infinity ? function parseFloat(str) {
  1583. var string = $trim(String(str), 3);
  1584. var result = $parseFloat(string);
  1585. return result === 0 && string.charAt(0) == '-' ? -0 : result;
  1586. } : $parseFloat;
  1587. },{"111":111,"112":112,"40":40}],87:[function(_dereq_,module,exports){
  1588. var $parseInt = _dereq_(40).parseInt;
  1589. var $trim = _dereq_(111).trim;
  1590. var ws = _dereq_(112);
  1591. var hex = /^[-+]?0[xX]/;
  1592. module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix) {
  1593. var string = $trim(String(str), 3);
  1594. return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
  1595. } : $parseInt;
  1596. },{"111":111,"112":112,"40":40}],88:[function(_dereq_,module,exports){
  1597. 'use strict';
  1598. var path = _dereq_(89);
  1599. var invoke = _dereq_(46);
  1600. var aFunction = _dereq_(3);
  1601. module.exports = function (/* ...pargs */) {
  1602. var fn = aFunction(this);
  1603. var length = arguments.length;
  1604. var pargs = Array(length);
  1605. var i = 0;
  1606. var _ = path._;
  1607. var holder = false;
  1608. while (length > i) if ((pargs[i] = arguments[i++]) === _) holder = true;
  1609. return function (/* ...args */) {
  1610. var that = this;
  1611. var aLen = arguments.length;
  1612. var j = 0;
  1613. var k = 0;
  1614. var args;
  1615. if (!holder && !aLen) return invoke(fn, pargs, that);
  1616. args = pargs.slice();
  1617. if (holder) for (;length > j; j++) if (args[j] === _) args[j] = arguments[k++];
  1618. while (aLen > k) args.push(arguments[k++]);
  1619. return invoke(fn, args, that);
  1620. };
  1621. };
  1622. },{"3":3,"46":46,"89":89}],89:[function(_dereq_,module,exports){
  1623. module.exports = _dereq_(40);
  1624. },{"40":40}],90:[function(_dereq_,module,exports){
  1625. module.exports = function (exec) {
  1626. try {
  1627. return { e: false, v: exec() };
  1628. } catch (e) {
  1629. return { e: true, v: e };
  1630. }
  1631. };
  1632. },{}],91:[function(_dereq_,module,exports){
  1633. var newPromiseCapability = _dereq_(69);
  1634. module.exports = function (C, x) {
  1635. var promiseCapability = newPromiseCapability.f(C);
  1636. var resolve = promiseCapability.resolve;
  1637. resolve(x);
  1638. return promiseCapability.promise;
  1639. };
  1640. },{"69":69}],92:[function(_dereq_,module,exports){
  1641. module.exports = function (bitmap, value) {
  1642. return {
  1643. enumerable: !(bitmap & 1),
  1644. configurable: !(bitmap & 2),
  1645. writable: !(bitmap & 4),
  1646. value: value
  1647. };
  1648. };
  1649. },{}],93:[function(_dereq_,module,exports){
  1650. var redefine = _dereq_(94);
  1651. module.exports = function (target, src, safe) {
  1652. for (var key in src) redefine(target, key, src[key], safe);
  1653. return target;
  1654. };
  1655. },{"94":94}],94:[function(_dereq_,module,exports){
  1656. var global = _dereq_(40);
  1657. var hide = _dereq_(42);
  1658. var has = _dereq_(41);
  1659. var SRC = _dereq_(124)('src');
  1660. var TO_STRING = 'toString';
  1661. var $toString = Function[TO_STRING];
  1662. var TPL = ('' + $toString).split(TO_STRING);
  1663. _dereq_(23).inspectSource = function (it) {
  1664. return $toString.call(it);
  1665. };
  1666. (module.exports = function (O, key, val, safe) {
  1667. var isFunction = typeof val == 'function';
  1668. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  1669. if (O[key] === val) return;
  1670. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  1671. if (O === global) {
  1672. O[key] = val;
  1673. } else if (!safe) {
  1674. delete O[key];
  1675. hide(O, key, val);
  1676. } else if (O[key]) {
  1677. O[key] = val;
  1678. } else {
  1679. hide(O, key, val);
  1680. }
  1681. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  1682. })(Function.prototype, TO_STRING, function toString() {
  1683. return typeof this == 'function' && this[SRC] || $toString.call(this);
  1684. });
  1685. },{"124":124,"23":23,"40":40,"41":41,"42":42}],95:[function(_dereq_,module,exports){
  1686. module.exports = function (regExp, replace) {
  1687. var replacer = replace === Object(replace) ? function (part) {
  1688. return replace[part];
  1689. } : replace;
  1690. return function (it) {
  1691. return String(it).replace(regExp, replacer);
  1692. };
  1693. };
  1694. },{}],96:[function(_dereq_,module,exports){
  1695. // 7.2.9 SameValue(x, y)
  1696. module.exports = Object.is || function is(x, y) {
  1697. // eslint-disable-next-line no-self-compare
  1698. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  1699. };
  1700. },{}],97:[function(_dereq_,module,exports){
  1701. 'use strict';
  1702. // https://tc39.github.io/proposal-setmap-offrom/
  1703. var $export = _dereq_(33);
  1704. var aFunction = _dereq_(3);
  1705. var ctx = _dereq_(25);
  1706. var forOf = _dereq_(39);
  1707. module.exports = function (COLLECTION) {
  1708. $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
  1709. var mapFn = arguments[1];
  1710. var mapping, A, n, cb;
  1711. aFunction(this);
  1712. mapping = mapFn !== undefined;
  1713. if (mapping) aFunction(mapFn);
  1714. if (source == undefined) return new this();
  1715. A = [];
  1716. if (mapping) {
  1717. n = 0;
  1718. cb = ctx(mapFn, arguments[2], 2);
  1719. forOf(source, false, function (nextItem) {
  1720. A.push(cb(nextItem, n++));
  1721. });
  1722. } else {
  1723. forOf(source, false, A.push, A);
  1724. }
  1725. return new this(A);
  1726. } });
  1727. };
  1728. },{"25":25,"3":3,"33":33,"39":39}],98:[function(_dereq_,module,exports){
  1729. 'use strict';
  1730. // https://tc39.github.io/proposal-setmap-offrom/
  1731. var $export = _dereq_(33);
  1732. module.exports = function (COLLECTION) {
  1733. $export($export.S, COLLECTION, { of: function of() {
  1734. var length = arguments.length;
  1735. var A = Array(length);
  1736. while (length--) A[length] = arguments[length];
  1737. return new this(A);
  1738. } });
  1739. };
  1740. },{"33":33}],99:[function(_dereq_,module,exports){
  1741. // Works with __proto__ only. Old v8 can't work with null proto objects.
  1742. /* eslint-disable no-proto */
  1743. var isObject = _dereq_(51);
  1744. var anObject = _dereq_(7);
  1745. var check = function (O, proto) {
  1746. anObject(O);
  1747. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  1748. };
  1749. module.exports = {
  1750. set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
  1751. function (test, buggy, set) {
  1752. try {
  1753. set = _dereq_(25)(Function.call, _dereq_(75).f(Object.prototype, '__proto__').set, 2);
  1754. set(test, []);
  1755. buggy = !(test instanceof Array);
  1756. } catch (e) { buggy = true; }
  1757. return function setPrototypeOf(O, proto) {
  1758. check(O, proto);
  1759. if (buggy) O.__proto__ = proto;
  1760. else set(O, proto);
  1761. return O;
  1762. };
  1763. }({}, false) : undefined),
  1764. check: check
  1765. };
  1766. },{"25":25,"51":51,"7":7,"75":75}],100:[function(_dereq_,module,exports){
  1767. 'use strict';
  1768. var global = _dereq_(40);
  1769. var dP = _dereq_(72);
  1770. var DESCRIPTORS = _dereq_(29);
  1771. var SPECIES = _dereq_(128)('species');
  1772. module.exports = function (KEY) {
  1773. var C = global[KEY];
  1774. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  1775. configurable: true,
  1776. get: function () { return this; }
  1777. });
  1778. };
  1779. },{"128":128,"29":29,"40":40,"72":72}],101:[function(_dereq_,module,exports){
  1780. var def = _dereq_(72).f;
  1781. var has = _dereq_(41);
  1782. var TAG = _dereq_(128)('toStringTag');
  1783. module.exports = function (it, tag, stat) {
  1784. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  1785. };
  1786. },{"128":128,"41":41,"72":72}],102:[function(_dereq_,module,exports){
  1787. var shared = _dereq_(103)('keys');
  1788. var uid = _dereq_(124);
  1789. module.exports = function (key) {
  1790. return shared[key] || (shared[key] = uid(key));
  1791. };
  1792. },{"103":103,"124":124}],103:[function(_dereq_,module,exports){
  1793. var global = _dereq_(40);
  1794. var SHARED = '__core-js_shared__';
  1795. var store = global[SHARED] || (global[SHARED] = {});
  1796. module.exports = function (key) {
  1797. return store[key] || (store[key] = {});
  1798. };
  1799. },{"40":40}],104:[function(_dereq_,module,exports){
  1800. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  1801. var anObject = _dereq_(7);
  1802. var aFunction = _dereq_(3);
  1803. var SPECIES = _dereq_(128)('species');
  1804. module.exports = function (O, D) {
  1805. var C = anObject(O).constructor;
  1806. var S;
  1807. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  1808. };
  1809. },{"128":128,"3":3,"7":7}],105:[function(_dereq_,module,exports){
  1810. 'use strict';
  1811. var fails = _dereq_(35);
  1812. module.exports = function (method, arg) {
  1813. return !!method && fails(function () {
  1814. // eslint-disable-next-line no-useless-call
  1815. arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null);
  1816. });
  1817. };
  1818. },{"35":35}],106:[function(_dereq_,module,exports){
  1819. var toInteger = _dereq_(116);
  1820. var defined = _dereq_(28);
  1821. // true -> String#at
  1822. // false -> String#codePointAt
  1823. module.exports = function (TO_STRING) {
  1824. return function (that, pos) {
  1825. var s = String(defined(that));
  1826. var i = toInteger(pos);
  1827. var l = s.length;
  1828. var a, b;
  1829. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  1830. a = s.charCodeAt(i);
  1831. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  1832. ? TO_STRING ? s.charAt(i) : a
  1833. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  1834. };
  1835. };
  1836. },{"116":116,"28":28}],107:[function(_dereq_,module,exports){
  1837. // helper for String#{startsWith, endsWith, includes}
  1838. var isRegExp = _dereq_(52);
  1839. var defined = _dereq_(28);
  1840. module.exports = function (that, searchString, NAME) {
  1841. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  1842. return String(defined(that));
  1843. };
  1844. },{"28":28,"52":52}],108:[function(_dereq_,module,exports){
  1845. var $export = _dereq_(33);
  1846. var fails = _dereq_(35);
  1847. var defined = _dereq_(28);
  1848. var quot = /"/g;
  1849. // B.2.3.2.1 CreateHTML(string, tag, attribute, value)
  1850. var createHTML = function (string, tag, attribute, value) {
  1851. var S = String(defined(string));
  1852. var p1 = '<' + tag;
  1853. if (attribute !== '') p1 += ' ' + attribute + '="' + String(value).replace(quot, '&quot;') + '"';
  1854. return p1 + '>' + S + '</' + tag + '>';
  1855. };
  1856. module.exports = function (NAME, exec) {
  1857. var O = {};
  1858. O[NAME] = exec(createHTML);
  1859. $export($export.P + $export.F * fails(function () {
  1860. var test = ''[NAME]('"');
  1861. return test !== test.toLowerCase() || test.split('"').length > 3;
  1862. }), 'String', O);
  1863. };
  1864. },{"28":28,"33":33,"35":35}],109:[function(_dereq_,module,exports){
  1865. // https://github.com/tc39/proposal-string-pad-start-end
  1866. var toLength = _dereq_(118);
  1867. var repeat = _dereq_(110);
  1868. var defined = _dereq_(28);
  1869. module.exports = function (that, maxLength, fillString, left) {
  1870. var S = String(defined(that));
  1871. var stringLength = S.length;
  1872. var fillStr = fillString === undefined ? ' ' : String(fillString);
  1873. var intMaxLength = toLength(maxLength);
  1874. if (intMaxLength <= stringLength || fillStr == '') return S;
  1875. var fillLen = intMaxLength - stringLength;
  1876. var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  1877. if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
  1878. return left ? stringFiller + S : S + stringFiller;
  1879. };
  1880. },{"110":110,"118":118,"28":28}],110:[function(_dereq_,module,exports){
  1881. 'use strict';
  1882. var toInteger = _dereq_(116);
  1883. var defined = _dereq_(28);
  1884. module.exports = function repeat(count) {
  1885. var str = String(defined(this));
  1886. var res = '';
  1887. var n = toInteger(count);
  1888. if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
  1889. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;
  1890. return res;
  1891. };
  1892. },{"116":116,"28":28}],111:[function(_dereq_,module,exports){
  1893. var $export = _dereq_(33);
  1894. var defined = _dereq_(28);
  1895. var fails = _dereq_(35);
  1896. var spaces = _dereq_(112);
  1897. var space = '[' + spaces + ']';
  1898. var non = '\u200b\u0085';
  1899. var ltrim = RegExp('^' + space + space + '*');
  1900. var rtrim = RegExp(space + space + '*$');
  1901. var exporter = function (KEY, exec, ALIAS) {
  1902. var exp = {};
  1903. var FORCE = fails(function () {
  1904. return !!spaces[KEY]() || non[KEY]() != non;
  1905. });
  1906. var fn = exp[KEY] = FORCE ? exec(trim) : spaces[KEY];
  1907. if (ALIAS) exp[ALIAS] = fn;
  1908. $export($export.P + $export.F * FORCE, 'String', exp);
  1909. };
  1910. // 1 -> String#trimLeft
  1911. // 2 -> String#trimRight
  1912. // 3 -> String#trim
  1913. var trim = exporter.trim = function (string, TYPE) {
  1914. string = String(defined(string));
  1915. if (TYPE & 1) string = string.replace(ltrim, '');
  1916. if (TYPE & 2) string = string.replace(rtrim, '');
  1917. return string;
  1918. };
  1919. module.exports = exporter;
  1920. },{"112":112,"28":28,"33":33,"35":35}],112:[function(_dereq_,module,exports){
  1921. module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
  1922. '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  1923. },{}],113:[function(_dereq_,module,exports){
  1924. var ctx = _dereq_(25);
  1925. var invoke = _dereq_(46);
  1926. var html = _dereq_(43);
  1927. var cel = _dereq_(30);
  1928. var global = _dereq_(40);
  1929. var process = global.process;
  1930. var setTask = global.setImmediate;
  1931. var clearTask = global.clearImmediate;
  1932. var MessageChannel = global.MessageChannel;
  1933. var Dispatch = global.Dispatch;
  1934. var counter = 0;
  1935. var queue = {};
  1936. var ONREADYSTATECHANGE = 'onreadystatechange';
  1937. var defer, channel, port;
  1938. var run = function () {
  1939. var id = +this;
  1940. // eslint-disable-next-line no-prototype-builtins
  1941. if (queue.hasOwnProperty(id)) {
  1942. var fn = queue[id];
  1943. delete queue[id];
  1944. fn();
  1945. }
  1946. };
  1947. var listener = function (event) {
  1948. run.call(event.data);
  1949. };
  1950. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  1951. if (!setTask || !clearTask) {
  1952. setTask = function setImmediate(fn) {
  1953. var args = [];
  1954. var i = 1;
  1955. while (arguments.length > i) args.push(arguments[i++]);
  1956. queue[++counter] = function () {
  1957. // eslint-disable-next-line no-new-func
  1958. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  1959. };
  1960. defer(counter);
  1961. return counter;
  1962. };
  1963. clearTask = function clearImmediate(id) {
  1964. delete queue[id];
  1965. };
  1966. // Node.js 0.8-
  1967. if (_dereq_(18)(process) == 'process') {
  1968. defer = function (id) {
  1969. process.nextTick(ctx(run, id, 1));
  1970. };
  1971. // Sphere (JS game engine) Dispatch API
  1972. } else if (Dispatch && Dispatch.now) {
  1973. defer = function (id) {
  1974. Dispatch.now(ctx(run, id, 1));
  1975. };
  1976. // Browsers with MessageChannel, includes WebWorkers
  1977. } else if (MessageChannel) {
  1978. channel = new MessageChannel();
  1979. port = channel.port2;
  1980. channel.port1.onmessage = listener;
  1981. defer = ctx(port.postMessage, port, 1);
  1982. // Browsers with postMessage, skip WebWorkers
  1983. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  1984. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  1985. defer = function (id) {
  1986. global.postMessage(id + '', '*');
  1987. };
  1988. global.addEventListener('message', listener, false);
  1989. // IE8-
  1990. } else if (ONREADYSTATECHANGE in cel('script')) {
  1991. defer = function (id) {
  1992. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  1993. html.removeChild(this);
  1994. run.call(id);
  1995. };
  1996. };
  1997. // Rest old browsers
  1998. } else {
  1999. defer = function (id) {
  2000. setTimeout(ctx(run, id, 1), 0);
  2001. };
  2002. }
  2003. }
  2004. module.exports = {
  2005. set: setTask,
  2006. clear: clearTask
  2007. };
  2008. },{"18":18,"25":25,"30":30,"40":40,"43":43,"46":46}],114:[function(_dereq_,module,exports){
  2009. var toInteger = _dereq_(116);
  2010. var max = Math.max;
  2011. var min = Math.min;
  2012. module.exports = function (index, length) {
  2013. index = toInteger(index);
  2014. return index < 0 ? max(index + length, 0) : min(index, length);
  2015. };
  2016. },{"116":116}],115:[function(_dereq_,module,exports){
  2017. // https://tc39.github.io/ecma262/#sec-toindex
  2018. var toInteger = _dereq_(116);
  2019. var toLength = _dereq_(118);
  2020. module.exports = function (it) {
  2021. if (it === undefined) return 0;
  2022. var number = toInteger(it);
  2023. var length = toLength(number);
  2024. if (number !== length) throw RangeError('Wrong length!');
  2025. return length;
  2026. };
  2027. },{"116":116,"118":118}],116:[function(_dereq_,module,exports){
  2028. // 7.1.4 ToInteger
  2029. var ceil = Math.ceil;
  2030. var floor = Math.floor;
  2031. module.exports = function (it) {
  2032. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  2033. };
  2034. },{}],117:[function(_dereq_,module,exports){
  2035. // to indexed object, toObject with fallback for non-array-like ES3 strings
  2036. var IObject = _dereq_(47);
  2037. var defined = _dereq_(28);
  2038. module.exports = function (it) {
  2039. return IObject(defined(it));
  2040. };
  2041. },{"28":28,"47":47}],118:[function(_dereq_,module,exports){
  2042. // 7.1.15 ToLength
  2043. var toInteger = _dereq_(116);
  2044. var min = Math.min;
  2045. module.exports = function (it) {
  2046. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  2047. };
  2048. },{"116":116}],119:[function(_dereq_,module,exports){
  2049. // 7.1.13 ToObject(argument)
  2050. var defined = _dereq_(28);
  2051. module.exports = function (it) {
  2052. return Object(defined(it));
  2053. };
  2054. },{"28":28}],120:[function(_dereq_,module,exports){
  2055. // 7.1.1 ToPrimitive(input [, PreferredType])
  2056. var isObject = _dereq_(51);
  2057. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  2058. // and the second argument - flag - preferred type is a string
  2059. module.exports = function (it, S) {
  2060. if (!isObject(it)) return it;
  2061. var fn, val;
  2062. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  2063. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  2064. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  2065. throw TypeError("Can't convert object to primitive value");
  2066. };
  2067. },{"51":51}],121:[function(_dereq_,module,exports){
  2068. 'use strict';
  2069. if (_dereq_(29)) {
  2070. var LIBRARY = _dereq_(60);
  2071. var global = _dereq_(40);
  2072. var fails = _dereq_(35);
  2073. var $export = _dereq_(33);
  2074. var $typed = _dereq_(123);
  2075. var $buffer = _dereq_(122);
  2076. var ctx = _dereq_(25);
  2077. var anInstance = _dereq_(6);
  2078. var propertyDesc = _dereq_(92);
  2079. var hide = _dereq_(42);
  2080. var redefineAll = _dereq_(93);
  2081. var toInteger = _dereq_(116);
  2082. var toLength = _dereq_(118);
  2083. var toIndex = _dereq_(115);
  2084. var toAbsoluteIndex = _dereq_(114);
  2085. var toPrimitive = _dereq_(120);
  2086. var has = _dereq_(41);
  2087. var classof = _dereq_(17);
  2088. var isObject = _dereq_(51);
  2089. var toObject = _dereq_(119);
  2090. var isArrayIter = _dereq_(48);
  2091. var create = _dereq_(71);
  2092. var getPrototypeOf = _dereq_(79);
  2093. var gOPN = _dereq_(77).f;
  2094. var getIterFn = _dereq_(129);
  2095. var uid = _dereq_(124);
  2096. var wks = _dereq_(128);
  2097. var createArrayMethod = _dereq_(12);
  2098. var createArrayIncludes = _dereq_(11);
  2099. var speciesConstructor = _dereq_(104);
  2100. var ArrayIterators = _dereq_(141);
  2101. var Iterators = _dereq_(58);
  2102. var $iterDetect = _dereq_(56);
  2103. var setSpecies = _dereq_(100);
  2104. var arrayFill = _dereq_(9);
  2105. var arrayCopyWithin = _dereq_(8);
  2106. var $DP = _dereq_(72);
  2107. var $GOPD = _dereq_(75);
  2108. var dP = $DP.f;
  2109. var gOPD = $GOPD.f;
  2110. var RangeError = global.RangeError;
  2111. var TypeError = global.TypeError;
  2112. var Uint8Array = global.Uint8Array;
  2113. var ARRAY_BUFFER = 'ArrayBuffer';
  2114. var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER;
  2115. var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
  2116. var PROTOTYPE = 'prototype';
  2117. var ArrayProto = Array[PROTOTYPE];
  2118. var $ArrayBuffer = $buffer.ArrayBuffer;
  2119. var $DataView = $buffer.DataView;
  2120. var arrayForEach = createArrayMethod(0);
  2121. var arrayFilter = createArrayMethod(2);
  2122. var arraySome = createArrayMethod(3);
  2123. var arrayEvery = createArrayMethod(4);
  2124. var arrayFind = createArrayMethod(5);
  2125. var arrayFindIndex = createArrayMethod(6);
  2126. var arrayIncludes = createArrayIncludes(true);
  2127. var arrayIndexOf = createArrayIncludes(false);
  2128. var arrayValues = ArrayIterators.values;
  2129. var arrayKeys = ArrayIterators.keys;
  2130. var arrayEntries = ArrayIterators.entries;
  2131. var arrayLastIndexOf = ArrayProto.lastIndexOf;
  2132. var arrayReduce = ArrayProto.reduce;
  2133. var arrayReduceRight = ArrayProto.reduceRight;
  2134. var arrayJoin = ArrayProto.join;
  2135. var arraySort = ArrayProto.sort;
  2136. var arraySlice = ArrayProto.slice;
  2137. var arrayToString = ArrayProto.toString;
  2138. var arrayToLocaleString = ArrayProto.toLocaleString;
  2139. var ITERATOR = wks('iterator');
  2140. var TAG = wks('toStringTag');
  2141. var TYPED_CONSTRUCTOR = uid('typed_constructor');
  2142. var DEF_CONSTRUCTOR = uid('def_constructor');
  2143. var ALL_CONSTRUCTORS = $typed.CONSTR;
  2144. var TYPED_ARRAY = $typed.TYPED;
  2145. var VIEW = $typed.VIEW;
  2146. var WRONG_LENGTH = 'Wrong length!';
  2147. var $map = createArrayMethod(1, function (O, length) {
  2148. return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);
  2149. });
  2150. var LITTLE_ENDIAN = fails(function () {
  2151. // eslint-disable-next-line no-undef
  2152. return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
  2153. });
  2154. var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () {
  2155. new Uint8Array(1).set({});
  2156. });
  2157. var toOffset = function (it, BYTES) {
  2158. var offset = toInteger(it);
  2159. if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!');
  2160. return offset;
  2161. };
  2162. var validate = function (it) {
  2163. if (isObject(it) && TYPED_ARRAY in it) return it;
  2164. throw TypeError(it + ' is not a typed array!');
  2165. };
  2166. var allocate = function (C, length) {
  2167. if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) {
  2168. throw TypeError('It is not a typed array constructor!');
  2169. } return new C(length);
  2170. };
  2171. var speciesFromList = function (O, list) {
  2172. return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);
  2173. };
  2174. var fromList = function (C, list) {
  2175. var index = 0;
  2176. var length = list.length;
  2177. var result = allocate(C, length);
  2178. while (length > index) result[index] = list[index++];
  2179. return result;
  2180. };
  2181. var addGetter = function (it, key, internal) {
  2182. dP(it, key, { get: function () { return this._d[internal]; } });
  2183. };
  2184. var $from = function from(source /* , mapfn, thisArg */) {
  2185. var O = toObject(source);
  2186. var aLen = arguments.length;
  2187. var mapfn = aLen > 1 ? arguments[1] : undefined;
  2188. var mapping = mapfn !== undefined;
  2189. var iterFn = getIterFn(O);
  2190. var i, length, values, result, step, iterator;
  2191. if (iterFn != undefined && !isArrayIter(iterFn)) {
  2192. for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) {
  2193. values.push(step.value);
  2194. } O = values;
  2195. }
  2196. if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2);
  2197. for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) {
  2198. result[i] = mapping ? mapfn(O[i], i) : O[i];
  2199. }
  2200. return result;
  2201. };
  2202. var $of = function of(/* ...items */) {
  2203. var index = 0;
  2204. var length = arguments.length;
  2205. var result = allocate(this, length);
  2206. while (length > index) result[index] = arguments[index++];
  2207. return result;
  2208. };
  2209. // iOS Safari 6.x fails here
  2210. var TO_LOCALE_BUG = !!Uint8Array && fails(function () { arrayToLocaleString.call(new Uint8Array(1)); });
  2211. var $toLocaleString = function toLocaleString() {
  2212. return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);
  2213. };
  2214. var proto = {
  2215. copyWithin: function copyWithin(target, start /* , end */) {
  2216. return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
  2217. },
  2218. every: function every(callbackfn /* , thisArg */) {
  2219. return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  2220. },
  2221. fill: function fill(value /* , start, end */) { // eslint-disable-line no-unused-vars
  2222. return arrayFill.apply(validate(this), arguments);
  2223. },
  2224. filter: function filter(callbackfn /* , thisArg */) {
  2225. return speciesFromList(this, arrayFilter(validate(this), callbackfn,
  2226. arguments.length > 1 ? arguments[1] : undefined));
  2227. },
  2228. find: function find(predicate /* , thisArg */) {
  2229. return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  2230. },
  2231. findIndex: function findIndex(predicate /* , thisArg */) {
  2232. return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  2233. },
  2234. forEach: function forEach(callbackfn /* , thisArg */) {
  2235. arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  2236. },
  2237. indexOf: function indexOf(searchElement /* , fromIndex */) {
  2238. return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  2239. },
  2240. includes: function includes(searchElement /* , fromIndex */) {
  2241. return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  2242. },
  2243. join: function join(separator) { // eslint-disable-line no-unused-vars
  2244. return arrayJoin.apply(validate(this), arguments);
  2245. },
  2246. lastIndexOf: function lastIndexOf(searchElement /* , fromIndex */) { // eslint-disable-line no-unused-vars
  2247. return arrayLastIndexOf.apply(validate(this), arguments);
  2248. },
  2249. map: function map(mapfn /* , thisArg */) {
  2250. return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);
  2251. },
  2252. reduce: function reduce(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars
  2253. return arrayReduce.apply(validate(this), arguments);
  2254. },
  2255. reduceRight: function reduceRight(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars
  2256. return arrayReduceRight.apply(validate(this), arguments);
  2257. },
  2258. reverse: function reverse() {
  2259. var that = this;
  2260. var length = validate(that).length;
  2261. var middle = Math.floor(length / 2);
  2262. var index = 0;
  2263. var value;
  2264. while (index < middle) {
  2265. value = that[index];
  2266. that[index++] = that[--length];
  2267. that[length] = value;
  2268. } return that;
  2269. },
  2270. some: function some(callbackfn /* , thisArg */) {
  2271. return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  2272. },
  2273. sort: function sort(comparefn) {
  2274. return arraySort.call(validate(this), comparefn);
  2275. },
  2276. subarray: function subarray(begin, end) {
  2277. var O = validate(this);
  2278. var length = O.length;
  2279. var $begin = toAbsoluteIndex(begin, length);
  2280. return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(
  2281. O.buffer,
  2282. O.byteOffset + $begin * O.BYTES_PER_ELEMENT,
  2283. toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin)
  2284. );
  2285. }
  2286. };
  2287. var $slice = function slice(start, end) {
  2288. return speciesFromList(this, arraySlice.call(validate(this), start, end));
  2289. };
  2290. var $set = function set(arrayLike /* , offset */) {
  2291. validate(this);
  2292. var offset = toOffset(arguments[1], 1);
  2293. var length = this.length;
  2294. var src = toObject(arrayLike);
  2295. var len = toLength(src.length);
  2296. var index = 0;
  2297. if (len + offset > length) throw RangeError(WRONG_LENGTH);
  2298. while (index < len) this[offset + index] = src[index++];
  2299. };
  2300. var $iterators = {
  2301. entries: function entries() {
  2302. return arrayEntries.call(validate(this));
  2303. },
  2304. keys: function keys() {
  2305. return arrayKeys.call(validate(this));
  2306. },
  2307. values: function values() {
  2308. return arrayValues.call(validate(this));
  2309. }
  2310. };
  2311. var isTAIndex = function (target, key) {
  2312. return isObject(target)
  2313. && target[TYPED_ARRAY]
  2314. && typeof key != 'symbol'
  2315. && key in target
  2316. && String(+key) == String(key);
  2317. };
  2318. var $getDesc = function getOwnPropertyDescriptor(target, key) {
  2319. return isTAIndex(target, key = toPrimitive(key, true))
  2320. ? propertyDesc(2, target[key])
  2321. : gOPD(target, key);
  2322. };
  2323. var $setDesc = function defineProperty(target, key, desc) {
  2324. if (isTAIndex(target, key = toPrimitive(key, true))
  2325. && isObject(desc)
  2326. && has(desc, 'value')
  2327. && !has(desc, 'get')
  2328. && !has(desc, 'set')
  2329. // TODO: add validation descriptor w/o calling accessors
  2330. && !desc.configurable
  2331. && (!has(desc, 'writable') || desc.writable)
  2332. && (!has(desc, 'enumerable') || desc.enumerable)
  2333. ) {
  2334. target[key] = desc.value;
  2335. return target;
  2336. } return dP(target, key, desc);
  2337. };
  2338. if (!ALL_CONSTRUCTORS) {
  2339. $GOPD.f = $getDesc;
  2340. $DP.f = $setDesc;
  2341. }
  2342. $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {
  2343. getOwnPropertyDescriptor: $getDesc,
  2344. defineProperty: $setDesc
  2345. });
  2346. if (fails(function () { arrayToString.call({}); })) {
  2347. arrayToString = arrayToLocaleString = function toString() {
  2348. return arrayJoin.call(this);
  2349. };
  2350. }
  2351. var $TypedArrayPrototype$ = redefineAll({}, proto);
  2352. redefineAll($TypedArrayPrototype$, $iterators);
  2353. hide($TypedArrayPrototype$, ITERATOR, $iterators.values);
  2354. redefineAll($TypedArrayPrototype$, {
  2355. slice: $slice,
  2356. set: $set,
  2357. constructor: function () { /* noop */ },
  2358. toString: arrayToString,
  2359. toLocaleString: $toLocaleString
  2360. });
  2361. addGetter($TypedArrayPrototype$, 'buffer', 'b');
  2362. addGetter($TypedArrayPrototype$, 'byteOffset', 'o');
  2363. addGetter($TypedArrayPrototype$, 'byteLength', 'l');
  2364. addGetter($TypedArrayPrototype$, 'length', 'e');
  2365. dP($TypedArrayPrototype$, TAG, {
  2366. get: function () { return this[TYPED_ARRAY]; }
  2367. });
  2368. // eslint-disable-next-line max-statements
  2369. module.exports = function (KEY, BYTES, wrapper, CLAMPED) {
  2370. CLAMPED = !!CLAMPED;
  2371. var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array';
  2372. var GETTER = 'get' + KEY;
  2373. var SETTER = 'set' + KEY;
  2374. var TypedArray = global[NAME];
  2375. var Base = TypedArray || {};
  2376. var TAC = TypedArray && getPrototypeOf(TypedArray);
  2377. var FORCED = !TypedArray || !$typed.ABV;
  2378. var O = {};
  2379. var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];
  2380. var getter = function (that, index) {
  2381. var data = that._d;
  2382. return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);
  2383. };
  2384. var setter = function (that, index, value) {
  2385. var data = that._d;
  2386. if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;
  2387. data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);
  2388. };
  2389. var addElement = function (that, index) {
  2390. dP(that, index, {
  2391. get: function () {
  2392. return getter(this, index);
  2393. },
  2394. set: function (value) {
  2395. return setter(this, index, value);
  2396. },
  2397. enumerable: true
  2398. });
  2399. };
  2400. if (FORCED) {
  2401. TypedArray = wrapper(function (that, data, $offset, $length) {
  2402. anInstance(that, TypedArray, NAME, '_d');
  2403. var index = 0;
  2404. var offset = 0;
  2405. var buffer, byteLength, length, klass;
  2406. if (!isObject(data)) {
  2407. length = toIndex(data);
  2408. byteLength = length * BYTES;
  2409. buffer = new $ArrayBuffer(byteLength);
  2410. } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
  2411. buffer = data;
  2412. offset = toOffset($offset, BYTES);
  2413. var $len = data.byteLength;
  2414. if ($length === undefined) {
  2415. if ($len % BYTES) throw RangeError(WRONG_LENGTH);
  2416. byteLength = $len - offset;
  2417. if (byteLength < 0) throw RangeError(WRONG_LENGTH);
  2418. } else {
  2419. byteLength = toLength($length) * BYTES;
  2420. if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH);
  2421. }
  2422. length = byteLength / BYTES;
  2423. } else if (TYPED_ARRAY in data) {
  2424. return fromList(TypedArray, data);
  2425. } else {
  2426. return $from.call(TypedArray, data);
  2427. }
  2428. hide(that, '_d', {
  2429. b: buffer,
  2430. o: offset,
  2431. l: byteLength,
  2432. e: length,
  2433. v: new $DataView(buffer)
  2434. });
  2435. while (index < length) addElement(that, index++);
  2436. });
  2437. TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);
  2438. hide(TypedArrayPrototype, 'constructor', TypedArray);
  2439. } else if (!fails(function () {
  2440. TypedArray(1);
  2441. }) || !fails(function () {
  2442. new TypedArray(-1); // eslint-disable-line no-new
  2443. }) || !$iterDetect(function (iter) {
  2444. new TypedArray(); // eslint-disable-line no-new
  2445. new TypedArray(null); // eslint-disable-line no-new
  2446. new TypedArray(1.5); // eslint-disable-line no-new
  2447. new TypedArray(iter); // eslint-disable-line no-new
  2448. }, true)) {
  2449. TypedArray = wrapper(function (that, data, $offset, $length) {
  2450. anInstance(that, TypedArray, NAME);
  2451. var klass;
  2452. // `ws` module bug, temporarily remove validation length for Uint8Array
  2453. // https://github.com/websockets/ws/pull/645
  2454. if (!isObject(data)) return new Base(toIndex(data));
  2455. if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
  2456. return $length !== undefined
  2457. ? new Base(data, toOffset($offset, BYTES), $length)
  2458. : $offset !== undefined
  2459. ? new Base(data, toOffset($offset, BYTES))
  2460. : new Base(data);
  2461. }
  2462. if (TYPED_ARRAY in data) return fromList(TypedArray, data);
  2463. return $from.call(TypedArray, data);
  2464. });
  2465. arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) {
  2466. if (!(key in TypedArray)) hide(TypedArray, key, Base[key]);
  2467. });
  2468. TypedArray[PROTOTYPE] = TypedArrayPrototype;
  2469. if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray;
  2470. }
  2471. var $nativeIterator = TypedArrayPrototype[ITERATOR];
  2472. var CORRECT_ITER_NAME = !!$nativeIterator
  2473. && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined);
  2474. var $iterator = $iterators.values;
  2475. hide(TypedArray, TYPED_CONSTRUCTOR, true);
  2476. hide(TypedArrayPrototype, TYPED_ARRAY, NAME);
  2477. hide(TypedArrayPrototype, VIEW, true);
  2478. hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);
  2479. if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) {
  2480. dP(TypedArrayPrototype, TAG, {
  2481. get: function () { return NAME; }
  2482. });
  2483. }
  2484. O[NAME] = TypedArray;
  2485. $export($export.G + $export.W + $export.F * (TypedArray != Base), O);
  2486. $export($export.S, NAME, {
  2487. BYTES_PER_ELEMENT: BYTES
  2488. });
  2489. $export($export.S + $export.F * fails(function () { Base.of.call(TypedArray, 1); }), NAME, {
  2490. from: $from,
  2491. of: $of
  2492. });
  2493. if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);
  2494. $export($export.P, NAME, proto);
  2495. setSpecies(NAME);
  2496. $export($export.P + $export.F * FORCED_SET, NAME, { set: $set });
  2497. $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);
  2498. if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString;
  2499. $export($export.P + $export.F * fails(function () {
  2500. new TypedArray(1).slice();
  2501. }), NAME, { slice: $slice });
  2502. $export($export.P + $export.F * (fails(function () {
  2503. return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString();
  2504. }) || !fails(function () {
  2505. TypedArrayPrototype.toLocaleString.call([1, 2]);
  2506. })), NAME, { toLocaleString: $toLocaleString });
  2507. Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;
  2508. if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator);
  2509. };
  2510. } else module.exports = function () { /* empty */ };
  2511. },{"100":100,"104":104,"11":11,"114":114,"115":115,"116":116,"118":118,"119":119,"12":12,"120":120,"122":122,"123":123,"124":124,"128":128,"129":129,"141":141,"17":17,"25":25,"29":29,"33":33,"35":35,"40":40,"41":41,"42":42,"48":48,"51":51,"56":56,"58":58,"6":6,"60":60,"71":71,"72":72,"75":75,"77":77,"79":79,"8":8,"9":9,"92":92,"93":93}],122:[function(_dereq_,module,exports){
  2512. 'use strict';
  2513. var global = _dereq_(40);
  2514. var DESCRIPTORS = _dereq_(29);
  2515. var LIBRARY = _dereq_(60);
  2516. var $typed = _dereq_(123);
  2517. var hide = _dereq_(42);
  2518. var redefineAll = _dereq_(93);
  2519. var fails = _dereq_(35);
  2520. var anInstance = _dereq_(6);
  2521. var toInteger = _dereq_(116);
  2522. var toLength = _dereq_(118);
  2523. var toIndex = _dereq_(115);
  2524. var gOPN = _dereq_(77).f;
  2525. var dP = _dereq_(72).f;
  2526. var arrayFill = _dereq_(9);
  2527. var setToStringTag = _dereq_(101);
  2528. var ARRAY_BUFFER = 'ArrayBuffer';
  2529. var DATA_VIEW = 'DataView';
  2530. var PROTOTYPE = 'prototype';
  2531. var WRONG_LENGTH = 'Wrong length!';
  2532. var WRONG_INDEX = 'Wrong index!';
  2533. var $ArrayBuffer = global[ARRAY_BUFFER];
  2534. var $DataView = global[DATA_VIEW];
  2535. var Math = global.Math;
  2536. var RangeError = global.RangeError;
  2537. // eslint-disable-next-line no-shadow-restricted-names
  2538. var Infinity = global.Infinity;
  2539. var BaseBuffer = $ArrayBuffer;
  2540. var abs = Math.abs;
  2541. var pow = Math.pow;
  2542. var floor = Math.floor;
  2543. var log = Math.log;
  2544. var LN2 = Math.LN2;
  2545. var BUFFER = 'buffer';
  2546. var BYTE_LENGTH = 'byteLength';
  2547. var BYTE_OFFSET = 'byteOffset';
  2548. var $BUFFER = DESCRIPTORS ? '_b' : BUFFER;
  2549. var $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH;
  2550. var $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;
  2551. // IEEE754 conversions based on https://github.com/feross/ieee754
  2552. function packIEEE754(value, mLen, nBytes) {
  2553. var buffer = Array(nBytes);
  2554. var eLen = nBytes * 8 - mLen - 1;
  2555. var eMax = (1 << eLen) - 1;
  2556. var eBias = eMax >> 1;
  2557. var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0;
  2558. var i = 0;
  2559. var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
  2560. var e, m, c;
  2561. value = abs(value);
  2562. // eslint-disable-next-line no-self-compare
  2563. if (value != value || value === Infinity) {
  2564. // eslint-disable-next-line no-self-compare
  2565. m = value != value ? 1 : 0;
  2566. e = eMax;
  2567. } else {
  2568. e = floor(log(value) / LN2);
  2569. if (value * (c = pow(2, -e)) < 1) {
  2570. e--;
  2571. c *= 2;
  2572. }
  2573. if (e + eBias >= 1) {
  2574. value += rt / c;
  2575. } else {
  2576. value += rt * pow(2, 1 - eBias);
  2577. }
  2578. if (value * c >= 2) {
  2579. e++;
  2580. c /= 2;
  2581. }
  2582. if (e + eBias >= eMax) {
  2583. m = 0;
  2584. e = eMax;
  2585. } else if (e + eBias >= 1) {
  2586. m = (value * c - 1) * pow(2, mLen);
  2587. e = e + eBias;
  2588. } else {
  2589. m = value * pow(2, eBias - 1) * pow(2, mLen);
  2590. e = 0;
  2591. }
  2592. }
  2593. for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8);
  2594. e = e << mLen | m;
  2595. eLen += mLen;
  2596. for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8);
  2597. buffer[--i] |= s * 128;
  2598. return buffer;
  2599. }
  2600. function unpackIEEE754(buffer, mLen, nBytes) {
  2601. var eLen = nBytes * 8 - mLen - 1;
  2602. var eMax = (1 << eLen) - 1;
  2603. var eBias = eMax >> 1;
  2604. var nBits = eLen - 7;
  2605. var i = nBytes - 1;
  2606. var s = buffer[i--];
  2607. var e = s & 127;
  2608. var m;
  2609. s >>= 7;
  2610. for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8);
  2611. m = e & (1 << -nBits) - 1;
  2612. e >>= -nBits;
  2613. nBits += mLen;
  2614. for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8);
  2615. if (e === 0) {
  2616. e = 1 - eBias;
  2617. } else if (e === eMax) {
  2618. return m ? NaN : s ? -Infinity : Infinity;
  2619. } else {
  2620. m = m + pow(2, mLen);
  2621. e = e - eBias;
  2622. } return (s ? -1 : 1) * m * pow(2, e - mLen);
  2623. }
  2624. function unpackI32(bytes) {
  2625. return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
  2626. }
  2627. function packI8(it) {
  2628. return [it & 0xff];
  2629. }
  2630. function packI16(it) {
  2631. return [it & 0xff, it >> 8 & 0xff];
  2632. }
  2633. function packI32(it) {
  2634. return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];
  2635. }
  2636. function packF64(it) {
  2637. return packIEEE754(it, 52, 8);
  2638. }
  2639. function packF32(it) {
  2640. return packIEEE754(it, 23, 4);
  2641. }
  2642. function addGetter(C, key, internal) {
  2643. dP(C[PROTOTYPE], key, { get: function () { return this[internal]; } });
  2644. }
  2645. function get(view, bytes, index, isLittleEndian) {
  2646. var numIndex = +index;
  2647. var intIndex = toIndex(numIndex);
  2648. if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
  2649. var store = view[$BUFFER]._b;
  2650. var start = intIndex + view[$OFFSET];
  2651. var pack = store.slice(start, start + bytes);
  2652. return isLittleEndian ? pack : pack.reverse();
  2653. }
  2654. function set(view, bytes, index, conversion, value, isLittleEndian) {
  2655. var numIndex = +index;
  2656. var intIndex = toIndex(numIndex);
  2657. if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
  2658. var store = view[$BUFFER]._b;
  2659. var start = intIndex + view[$OFFSET];
  2660. var pack = conversion(+value);
  2661. for (var i = 0; i < bytes; i++) store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];
  2662. }
  2663. if (!$typed.ABV) {
  2664. $ArrayBuffer = function ArrayBuffer(length) {
  2665. anInstance(this, $ArrayBuffer, ARRAY_BUFFER);
  2666. var byteLength = toIndex(length);
  2667. this._b = arrayFill.call(Array(byteLength), 0);
  2668. this[$LENGTH] = byteLength;
  2669. };
  2670. $DataView = function DataView(buffer, byteOffset, byteLength) {
  2671. anInstance(this, $DataView, DATA_VIEW);
  2672. anInstance(buffer, $ArrayBuffer, DATA_VIEW);
  2673. var bufferLength = buffer[$LENGTH];
  2674. var offset = toInteger(byteOffset);
  2675. if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!');
  2676. byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
  2677. if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
  2678. this[$BUFFER] = buffer;
  2679. this[$OFFSET] = offset;
  2680. this[$LENGTH] = byteLength;
  2681. };
  2682. if (DESCRIPTORS) {
  2683. addGetter($ArrayBuffer, BYTE_LENGTH, '_l');
  2684. addGetter($DataView, BUFFER, '_b');
  2685. addGetter($DataView, BYTE_LENGTH, '_l');
  2686. addGetter($DataView, BYTE_OFFSET, '_o');
  2687. }
  2688. redefineAll($DataView[PROTOTYPE], {
  2689. getInt8: function getInt8(byteOffset) {
  2690. return get(this, 1, byteOffset)[0] << 24 >> 24;
  2691. },
  2692. getUint8: function getUint8(byteOffset) {
  2693. return get(this, 1, byteOffset)[0];
  2694. },
  2695. getInt16: function getInt16(byteOffset /* , littleEndian */) {
  2696. var bytes = get(this, 2, byteOffset, arguments[1]);
  2697. return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
  2698. },
  2699. getUint16: function getUint16(byteOffset /* , littleEndian */) {
  2700. var bytes = get(this, 2, byteOffset, arguments[1]);
  2701. return bytes[1] << 8 | bytes[0];
  2702. },
  2703. getInt32: function getInt32(byteOffset /* , littleEndian */) {
  2704. return unpackI32(get(this, 4, byteOffset, arguments[1]));
  2705. },
  2706. getUint32: function getUint32(byteOffset /* , littleEndian */) {
  2707. return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;
  2708. },
  2709. getFloat32: function getFloat32(byteOffset /* , littleEndian */) {
  2710. return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);
  2711. },
  2712. getFloat64: function getFloat64(byteOffset /* , littleEndian */) {
  2713. return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);
  2714. },
  2715. setInt8: function setInt8(byteOffset, value) {
  2716. set(this, 1, byteOffset, packI8, value);
  2717. },
  2718. setUint8: function setUint8(byteOffset, value) {
  2719. set(this, 1, byteOffset, packI8, value);
  2720. },
  2721. setInt16: function setInt16(byteOffset, value /* , littleEndian */) {
  2722. set(this, 2, byteOffset, packI16, value, arguments[2]);
  2723. },
  2724. setUint16: function setUint16(byteOffset, value /* , littleEndian */) {
  2725. set(this, 2, byteOffset, packI16, value, arguments[2]);
  2726. },
  2727. setInt32: function setInt32(byteOffset, value /* , littleEndian */) {
  2728. set(this, 4, byteOffset, packI32, value, arguments[2]);
  2729. },
  2730. setUint32: function setUint32(byteOffset, value /* , littleEndian */) {
  2731. set(this, 4, byteOffset, packI32, value, arguments[2]);
  2732. },
  2733. setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {
  2734. set(this, 4, byteOffset, packF32, value, arguments[2]);
  2735. },
  2736. setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {
  2737. set(this, 8, byteOffset, packF64, value, arguments[2]);
  2738. }
  2739. });
  2740. } else {
  2741. if (!fails(function () {
  2742. $ArrayBuffer(1);
  2743. }) || !fails(function () {
  2744. new $ArrayBuffer(-1); // eslint-disable-line no-new
  2745. }) || fails(function () {
  2746. new $ArrayBuffer(); // eslint-disable-line no-new
  2747. new $ArrayBuffer(1.5); // eslint-disable-line no-new
  2748. new $ArrayBuffer(NaN); // eslint-disable-line no-new
  2749. return $ArrayBuffer.name != ARRAY_BUFFER;
  2750. })) {
  2751. $ArrayBuffer = function ArrayBuffer(length) {
  2752. anInstance(this, $ArrayBuffer);
  2753. return new BaseBuffer(toIndex(length));
  2754. };
  2755. var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];
  2756. for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) {
  2757. if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]);
  2758. }
  2759. if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer;
  2760. }
  2761. // iOS Safari 7.x bug
  2762. var view = new $DataView(new $ArrayBuffer(2));
  2763. var $setInt8 = $DataView[PROTOTYPE].setInt8;
  2764. view.setInt8(0, 2147483648);
  2765. view.setInt8(1, 2147483649);
  2766. if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], {
  2767. setInt8: function setInt8(byteOffset, value) {
  2768. $setInt8.call(this, byteOffset, value << 24 >> 24);
  2769. },
  2770. setUint8: function setUint8(byteOffset, value) {
  2771. $setInt8.call(this, byteOffset, value << 24 >> 24);
  2772. }
  2773. }, true);
  2774. }
  2775. setToStringTag($ArrayBuffer, ARRAY_BUFFER);
  2776. setToStringTag($DataView, DATA_VIEW);
  2777. hide($DataView[PROTOTYPE], $typed.VIEW, true);
  2778. exports[ARRAY_BUFFER] = $ArrayBuffer;
  2779. exports[DATA_VIEW] = $DataView;
  2780. },{"101":101,"115":115,"116":116,"118":118,"123":123,"29":29,"35":35,"40":40,"42":42,"6":6,"60":60,"72":72,"77":77,"9":9,"93":93}],123:[function(_dereq_,module,exports){
  2781. var global = _dereq_(40);
  2782. var hide = _dereq_(42);
  2783. var uid = _dereq_(124);
  2784. var TYPED = uid('typed_array');
  2785. var VIEW = uid('view');
  2786. var ABV = !!(global.ArrayBuffer && global.DataView);
  2787. var CONSTR = ABV;
  2788. var i = 0;
  2789. var l = 9;
  2790. var Typed;
  2791. var TypedArrayConstructors = (
  2792. 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'
  2793. ).split(',');
  2794. while (i < l) {
  2795. if (Typed = global[TypedArrayConstructors[i++]]) {
  2796. hide(Typed.prototype, TYPED, true);
  2797. hide(Typed.prototype, VIEW, true);
  2798. } else CONSTR = false;
  2799. }
  2800. module.exports = {
  2801. ABV: ABV,
  2802. CONSTR: CONSTR,
  2803. TYPED: TYPED,
  2804. VIEW: VIEW
  2805. };
  2806. },{"124":124,"40":40,"42":42}],124:[function(_dereq_,module,exports){
  2807. var id = 0;
  2808. var px = Math.random();
  2809. module.exports = function (key) {
  2810. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  2811. };
  2812. },{}],125:[function(_dereq_,module,exports){
  2813. var isObject = _dereq_(51);
  2814. module.exports = function (it, TYPE) {
  2815. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  2816. return it;
  2817. };
  2818. },{"51":51}],126:[function(_dereq_,module,exports){
  2819. var global = _dereq_(40);
  2820. var core = _dereq_(23);
  2821. var LIBRARY = _dereq_(60);
  2822. var wksExt = _dereq_(127);
  2823. var defineProperty = _dereq_(72).f;
  2824. module.exports = function (name) {
  2825. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  2826. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
  2827. };
  2828. },{"127":127,"23":23,"40":40,"60":60,"72":72}],127:[function(_dereq_,module,exports){
  2829. exports.f = _dereq_(128);
  2830. },{"128":128}],128:[function(_dereq_,module,exports){
  2831. var store = _dereq_(103)('wks');
  2832. var uid = _dereq_(124);
  2833. var Symbol = _dereq_(40).Symbol;
  2834. var USE_SYMBOL = typeof Symbol == 'function';
  2835. var $exports = module.exports = function (name) {
  2836. return store[name] || (store[name] =
  2837. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  2838. };
  2839. $exports.store = store;
  2840. },{"103":103,"124":124,"40":40}],129:[function(_dereq_,module,exports){
  2841. var classof = _dereq_(17);
  2842. var ITERATOR = _dereq_(128)('iterator');
  2843. var Iterators = _dereq_(58);
  2844. module.exports = _dereq_(23).getIteratorMethod = function (it) {
  2845. if (it != undefined) return it[ITERATOR]
  2846. || it['@@iterator']
  2847. || Iterators[classof(it)];
  2848. };
  2849. },{"128":128,"17":17,"23":23,"58":58}],130:[function(_dereq_,module,exports){
  2850. // https://github.com/benjamingr/RexExp.escape
  2851. var $export = _dereq_(33);
  2852. var $re = _dereq_(95)(/[\\^$*+?.()|[\]{}]/g, '\\$&');
  2853. $export($export.S, 'RegExp', { escape: function escape(it) { return $re(it); } });
  2854. },{"33":33,"95":95}],131:[function(_dereq_,module,exports){
  2855. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  2856. var $export = _dereq_(33);
  2857. $export($export.P, 'Array', { copyWithin: _dereq_(8) });
  2858. _dereq_(5)('copyWithin');
  2859. },{"33":33,"5":5,"8":8}],132:[function(_dereq_,module,exports){
  2860. 'use strict';
  2861. var $export = _dereq_(33);
  2862. var $every = _dereq_(12)(4);
  2863. $export($export.P + $export.F * !_dereq_(105)([].every, true), 'Array', {
  2864. // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
  2865. every: function every(callbackfn /* , thisArg */) {
  2866. return $every(this, callbackfn, arguments[1]);
  2867. }
  2868. });
  2869. },{"105":105,"12":12,"33":33}],133:[function(_dereq_,module,exports){
  2870. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  2871. var $export = _dereq_(33);
  2872. $export($export.P, 'Array', { fill: _dereq_(9) });
  2873. _dereq_(5)('fill');
  2874. },{"33":33,"5":5,"9":9}],134:[function(_dereq_,module,exports){
  2875. 'use strict';
  2876. var $export = _dereq_(33);
  2877. var $filter = _dereq_(12)(2);
  2878. $export($export.P + $export.F * !_dereq_(105)([].filter, true), 'Array', {
  2879. // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
  2880. filter: function filter(callbackfn /* , thisArg */) {
  2881. return $filter(this, callbackfn, arguments[1]);
  2882. }
  2883. });
  2884. },{"105":105,"12":12,"33":33}],135:[function(_dereq_,module,exports){
  2885. 'use strict';
  2886. // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
  2887. var $export = _dereq_(33);
  2888. var $find = _dereq_(12)(6);
  2889. var KEY = 'findIndex';
  2890. var forced = true;
  2891. // Shouldn't skip holes
  2892. if (KEY in []) Array(1)[KEY](function () { forced = false; });
  2893. $export($export.P + $export.F * forced, 'Array', {
  2894. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  2895. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  2896. }
  2897. });
  2898. _dereq_(5)(KEY);
  2899. },{"12":12,"33":33,"5":5}],136:[function(_dereq_,module,exports){
  2900. 'use strict';
  2901. // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
  2902. var $export = _dereq_(33);
  2903. var $find = _dereq_(12)(5);
  2904. var KEY = 'find';
  2905. var forced = true;
  2906. // Shouldn't skip holes
  2907. if (KEY in []) Array(1)[KEY](function () { forced = false; });
  2908. $export($export.P + $export.F * forced, 'Array', {
  2909. find: function find(callbackfn /* , that = undefined */) {
  2910. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  2911. }
  2912. });
  2913. _dereq_(5)(KEY);
  2914. },{"12":12,"33":33,"5":5}],137:[function(_dereq_,module,exports){
  2915. 'use strict';
  2916. var $export = _dereq_(33);
  2917. var $forEach = _dereq_(12)(0);
  2918. var STRICT = _dereq_(105)([].forEach, true);
  2919. $export($export.P + $export.F * !STRICT, 'Array', {
  2920. // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
  2921. forEach: function forEach(callbackfn /* , thisArg */) {
  2922. return $forEach(this, callbackfn, arguments[1]);
  2923. }
  2924. });
  2925. },{"105":105,"12":12,"33":33}],138:[function(_dereq_,module,exports){
  2926. 'use strict';
  2927. var ctx = _dereq_(25);
  2928. var $export = _dereq_(33);
  2929. var toObject = _dereq_(119);
  2930. var call = _dereq_(53);
  2931. var isArrayIter = _dereq_(48);
  2932. var toLength = _dereq_(118);
  2933. var createProperty = _dereq_(24);
  2934. var getIterFn = _dereq_(129);
  2935. $export($export.S + $export.F * !_dereq_(56)(function (iter) { Array.from(iter); }), 'Array', {
  2936. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  2937. from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  2938. var O = toObject(arrayLike);
  2939. var C = typeof this == 'function' ? this : Array;
  2940. var aLen = arguments.length;
  2941. var mapfn = aLen > 1 ? arguments[1] : undefined;
  2942. var mapping = mapfn !== undefined;
  2943. var index = 0;
  2944. var iterFn = getIterFn(O);
  2945. var length, result, step, iterator;
  2946. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  2947. // if object isn't iterable or it's array with default iterator - use simple case
  2948. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  2949. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  2950. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  2951. }
  2952. } else {
  2953. length = toLength(O.length);
  2954. for (result = new C(length); length > index; index++) {
  2955. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  2956. }
  2957. }
  2958. result.length = index;
  2959. return result;
  2960. }
  2961. });
  2962. },{"118":118,"119":119,"129":129,"24":24,"25":25,"33":33,"48":48,"53":53,"56":56}],139:[function(_dereq_,module,exports){
  2963. 'use strict';
  2964. var $export = _dereq_(33);
  2965. var $indexOf = _dereq_(11)(false);
  2966. var $native = [].indexOf;
  2967. var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;
  2968. $export($export.P + $export.F * (NEGATIVE_ZERO || !_dereq_(105)($native)), 'Array', {
  2969. // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
  2970. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  2971. return NEGATIVE_ZERO
  2972. // convert -0 to +0
  2973. ? $native.apply(this, arguments) || 0
  2974. : $indexOf(this, searchElement, arguments[1]);
  2975. }
  2976. });
  2977. },{"105":105,"11":11,"33":33}],140:[function(_dereq_,module,exports){
  2978. // 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
  2979. var $export = _dereq_(33);
  2980. $export($export.S, 'Array', { isArray: _dereq_(49) });
  2981. },{"33":33,"49":49}],141:[function(_dereq_,module,exports){
  2982. 'use strict';
  2983. var addToUnscopables = _dereq_(5);
  2984. var step = _dereq_(57);
  2985. var Iterators = _dereq_(58);
  2986. var toIObject = _dereq_(117);
  2987. // 22.1.3.4 Array.prototype.entries()
  2988. // 22.1.3.13 Array.prototype.keys()
  2989. // 22.1.3.29 Array.prototype.values()
  2990. // 22.1.3.30 Array.prototype[@@iterator]()
  2991. module.exports = _dereq_(55)(Array, 'Array', function (iterated, kind) {
  2992. this._t = toIObject(iterated); // target
  2993. this._i = 0; // next index
  2994. this._k = kind; // kind
  2995. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  2996. }, function () {
  2997. var O = this._t;
  2998. var kind = this._k;
  2999. var index = this._i++;
  3000. if (!O || index >= O.length) {
  3001. this._t = undefined;
  3002. return step(1);
  3003. }
  3004. if (kind == 'keys') return step(0, index);
  3005. if (kind == 'values') return step(0, O[index]);
  3006. return step(0, [index, O[index]]);
  3007. }, 'values');
  3008. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  3009. Iterators.Arguments = Iterators.Array;
  3010. addToUnscopables('keys');
  3011. addToUnscopables('values');
  3012. addToUnscopables('entries');
  3013. },{"117":117,"5":5,"55":55,"57":57,"58":58}],142:[function(_dereq_,module,exports){
  3014. 'use strict';
  3015. // 22.1.3.13 Array.prototype.join(separator)
  3016. var $export = _dereq_(33);
  3017. var toIObject = _dereq_(117);
  3018. var arrayJoin = [].join;
  3019. // fallback for not array-like strings
  3020. $export($export.P + $export.F * (_dereq_(47) != Object || !_dereq_(105)(arrayJoin)), 'Array', {
  3021. join: function join(separator) {
  3022. return arrayJoin.call(toIObject(this), separator === undefined ? ',' : separator);
  3023. }
  3024. });
  3025. },{"105":105,"117":117,"33":33,"47":47}],143:[function(_dereq_,module,exports){
  3026. 'use strict';
  3027. var $export = _dereq_(33);
  3028. var toIObject = _dereq_(117);
  3029. var toInteger = _dereq_(116);
  3030. var toLength = _dereq_(118);
  3031. var $native = [].lastIndexOf;
  3032. var NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;
  3033. $export($export.P + $export.F * (NEGATIVE_ZERO || !_dereq_(105)($native)), 'Array', {
  3034. // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
  3035. lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
  3036. // convert -0 to +0
  3037. if (NEGATIVE_ZERO) return $native.apply(this, arguments) || 0;
  3038. var O = toIObject(this);
  3039. var length = toLength(O.length);
  3040. var index = length - 1;
  3041. if (arguments.length > 1) index = Math.min(index, toInteger(arguments[1]));
  3042. if (index < 0) index = length + index;
  3043. for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0;
  3044. return -1;
  3045. }
  3046. });
  3047. },{"105":105,"116":116,"117":117,"118":118,"33":33}],144:[function(_dereq_,module,exports){
  3048. 'use strict';
  3049. var $export = _dereq_(33);
  3050. var $map = _dereq_(12)(1);
  3051. $export($export.P + $export.F * !_dereq_(105)([].map, true), 'Array', {
  3052. // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
  3053. map: function map(callbackfn /* , thisArg */) {
  3054. return $map(this, callbackfn, arguments[1]);
  3055. }
  3056. });
  3057. },{"105":105,"12":12,"33":33}],145:[function(_dereq_,module,exports){
  3058. 'use strict';
  3059. var $export = _dereq_(33);
  3060. var createProperty = _dereq_(24);
  3061. // WebKit Array.of isn't generic
  3062. $export($export.S + $export.F * _dereq_(35)(function () {
  3063. function F() { /* empty */ }
  3064. return !(Array.of.call(F) instanceof F);
  3065. }), 'Array', {
  3066. // 22.1.2.3 Array.of( ...items)
  3067. of: function of(/* ...args */) {
  3068. var index = 0;
  3069. var aLen = arguments.length;
  3070. var result = new (typeof this == 'function' ? this : Array)(aLen);
  3071. while (aLen > index) createProperty(result, index, arguments[index++]);
  3072. result.length = aLen;
  3073. return result;
  3074. }
  3075. });
  3076. },{"24":24,"33":33,"35":35}],146:[function(_dereq_,module,exports){
  3077. 'use strict';
  3078. var $export = _dereq_(33);
  3079. var $reduce = _dereq_(13);
  3080. $export($export.P + $export.F * !_dereq_(105)([].reduceRight, true), 'Array', {
  3081. // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
  3082. reduceRight: function reduceRight(callbackfn /* , initialValue */) {
  3083. return $reduce(this, callbackfn, arguments.length, arguments[1], true);
  3084. }
  3085. });
  3086. },{"105":105,"13":13,"33":33}],147:[function(_dereq_,module,exports){
  3087. 'use strict';
  3088. var $export = _dereq_(33);
  3089. var $reduce = _dereq_(13);
  3090. $export($export.P + $export.F * !_dereq_(105)([].reduce, true), 'Array', {
  3091. // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
  3092. reduce: function reduce(callbackfn /* , initialValue */) {
  3093. return $reduce(this, callbackfn, arguments.length, arguments[1], false);
  3094. }
  3095. });
  3096. },{"105":105,"13":13,"33":33}],148:[function(_dereq_,module,exports){
  3097. 'use strict';
  3098. var $export = _dereq_(33);
  3099. var html = _dereq_(43);
  3100. var cof = _dereq_(18);
  3101. var toAbsoluteIndex = _dereq_(114);
  3102. var toLength = _dereq_(118);
  3103. var arraySlice = [].slice;
  3104. // fallback for not array-like ES3 strings and DOM objects
  3105. $export($export.P + $export.F * _dereq_(35)(function () {
  3106. if (html) arraySlice.call(html);
  3107. }), 'Array', {
  3108. slice: function slice(begin, end) {
  3109. var len = toLength(this.length);
  3110. var klass = cof(this);
  3111. end = end === undefined ? len : end;
  3112. if (klass == 'Array') return arraySlice.call(this, begin, end);
  3113. var start = toAbsoluteIndex(begin, len);
  3114. var upTo = toAbsoluteIndex(end, len);
  3115. var size = toLength(upTo - start);
  3116. var cloned = Array(size);
  3117. var i = 0;
  3118. for (; i < size; i++) cloned[i] = klass == 'String'
  3119. ? this.charAt(start + i)
  3120. : this[start + i];
  3121. return cloned;
  3122. }
  3123. });
  3124. },{"114":114,"118":118,"18":18,"33":33,"35":35,"43":43}],149:[function(_dereq_,module,exports){
  3125. 'use strict';
  3126. var $export = _dereq_(33);
  3127. var $some = _dereq_(12)(3);
  3128. $export($export.P + $export.F * !_dereq_(105)([].some, true), 'Array', {
  3129. // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
  3130. some: function some(callbackfn /* , thisArg */) {
  3131. return $some(this, callbackfn, arguments[1]);
  3132. }
  3133. });
  3134. },{"105":105,"12":12,"33":33}],150:[function(_dereq_,module,exports){
  3135. 'use strict';
  3136. var $export = _dereq_(33);
  3137. var aFunction = _dereq_(3);
  3138. var toObject = _dereq_(119);
  3139. var fails = _dereq_(35);
  3140. var $sort = [].sort;
  3141. var test = [1, 2, 3];
  3142. $export($export.P + $export.F * (fails(function () {
  3143. // IE8-
  3144. test.sort(undefined);
  3145. }) || !fails(function () {
  3146. // V8 bug
  3147. test.sort(null);
  3148. // Old WebKit
  3149. }) || !_dereq_(105)($sort)), 'Array', {
  3150. // 22.1.3.25 Array.prototype.sort(comparefn)
  3151. sort: function sort(comparefn) {
  3152. return comparefn === undefined
  3153. ? $sort.call(toObject(this))
  3154. : $sort.call(toObject(this), aFunction(comparefn));
  3155. }
  3156. });
  3157. },{"105":105,"119":119,"3":3,"33":33,"35":35}],151:[function(_dereq_,module,exports){
  3158. _dereq_(100)('Array');
  3159. },{"100":100}],152:[function(_dereq_,module,exports){
  3160. // 20.3.3.1 / 15.9.4.4 Date.now()
  3161. var $export = _dereq_(33);
  3162. $export($export.S, 'Date', { now: function () { return new Date().getTime(); } });
  3163. },{"33":33}],153:[function(_dereq_,module,exports){
  3164. // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
  3165. var $export = _dereq_(33);
  3166. var toISOString = _dereq_(26);
  3167. // PhantomJS / old WebKit has a broken implementations
  3168. $export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'Date', {
  3169. toISOString: toISOString
  3170. });
  3171. },{"26":26,"33":33}],154:[function(_dereq_,module,exports){
  3172. 'use strict';
  3173. var $export = _dereq_(33);
  3174. var toObject = _dereq_(119);
  3175. var toPrimitive = _dereq_(120);
  3176. $export($export.P + $export.F * _dereq_(35)(function () {
  3177. return new Date(NaN).toJSON() !== null
  3178. || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1;
  3179. }), 'Date', {
  3180. // eslint-disable-next-line no-unused-vars
  3181. toJSON: function toJSON(key) {
  3182. var O = toObject(this);
  3183. var pv = toPrimitive(O);
  3184. return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
  3185. }
  3186. });
  3187. },{"119":119,"120":120,"33":33,"35":35}],155:[function(_dereq_,module,exports){
  3188. var TO_PRIMITIVE = _dereq_(128)('toPrimitive');
  3189. var proto = Date.prototype;
  3190. if (!(TO_PRIMITIVE in proto)) _dereq_(42)(proto, TO_PRIMITIVE, _dereq_(27));
  3191. },{"128":128,"27":27,"42":42}],156:[function(_dereq_,module,exports){
  3192. var DateProto = Date.prototype;
  3193. var INVALID_DATE = 'Invalid Date';
  3194. var TO_STRING = 'toString';
  3195. var $toString = DateProto[TO_STRING];
  3196. var getTime = DateProto.getTime;
  3197. if (new Date(NaN) + '' != INVALID_DATE) {
  3198. _dereq_(94)(DateProto, TO_STRING, function toString() {
  3199. var value = getTime.call(this);
  3200. // eslint-disable-next-line no-self-compare
  3201. return value === value ? $toString.call(this) : INVALID_DATE;
  3202. });
  3203. }
  3204. },{"94":94}],157:[function(_dereq_,module,exports){
  3205. // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
  3206. var $export = _dereq_(33);
  3207. $export($export.P, 'Function', { bind: _dereq_(16) });
  3208. },{"16":16,"33":33}],158:[function(_dereq_,module,exports){
  3209. 'use strict';
  3210. var isObject = _dereq_(51);
  3211. var getPrototypeOf = _dereq_(79);
  3212. var HAS_INSTANCE = _dereq_(128)('hasInstance');
  3213. var FunctionProto = Function.prototype;
  3214. // 19.2.3.6 Function.prototype[@@hasInstance](V)
  3215. if (!(HAS_INSTANCE in FunctionProto)) _dereq_(72).f(FunctionProto, HAS_INSTANCE, { value: function (O) {
  3216. if (typeof this != 'function' || !isObject(O)) return false;
  3217. if (!isObject(this.prototype)) return O instanceof this;
  3218. // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
  3219. while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
  3220. return false;
  3221. } });
  3222. },{"128":128,"51":51,"72":72,"79":79}],159:[function(_dereq_,module,exports){
  3223. var dP = _dereq_(72).f;
  3224. var FProto = Function.prototype;
  3225. var nameRE = /^\s*function ([^ (]*)/;
  3226. var NAME = 'name';
  3227. // 19.2.4.2 name
  3228. NAME in FProto || _dereq_(29) && dP(FProto, NAME, {
  3229. configurable: true,
  3230. get: function () {
  3231. try {
  3232. return ('' + this).match(nameRE)[1];
  3233. } catch (e) {
  3234. return '';
  3235. }
  3236. }
  3237. });
  3238. },{"29":29,"72":72}],160:[function(_dereq_,module,exports){
  3239. 'use strict';
  3240. var strong = _dereq_(19);
  3241. var validate = _dereq_(125);
  3242. var MAP = 'Map';
  3243. // 23.1 Map Objects
  3244. module.exports = _dereq_(22)(MAP, function (get) {
  3245. return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  3246. }, {
  3247. // 23.1.3.6 Map.prototype.get(key)
  3248. get: function get(key) {
  3249. var entry = strong.getEntry(validate(this, MAP), key);
  3250. return entry && entry.v;
  3251. },
  3252. // 23.1.3.9 Map.prototype.set(key, value)
  3253. set: function set(key, value) {
  3254. return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
  3255. }
  3256. }, strong, true);
  3257. },{"125":125,"19":19,"22":22}],161:[function(_dereq_,module,exports){
  3258. // 20.2.2.3 Math.acosh(x)
  3259. var $export = _dereq_(33);
  3260. var log1p = _dereq_(63);
  3261. var sqrt = Math.sqrt;
  3262. var $acosh = Math.acosh;
  3263. $export($export.S + $export.F * !($acosh
  3264. // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
  3265. && Math.floor($acosh(Number.MAX_VALUE)) == 710
  3266. // Tor Browser bug: Math.acosh(Infinity) -> NaN
  3267. && $acosh(Infinity) == Infinity
  3268. ), 'Math', {
  3269. acosh: function acosh(x) {
  3270. return (x = +x) < 1 ? NaN : x > 94906265.62425156
  3271. ? Math.log(x) + Math.LN2
  3272. : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
  3273. }
  3274. });
  3275. },{"33":33,"63":63}],162:[function(_dereq_,module,exports){
  3276. // 20.2.2.5 Math.asinh(x)
  3277. var $export = _dereq_(33);
  3278. var $asinh = Math.asinh;
  3279. function asinh(x) {
  3280. return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));
  3281. }
  3282. // Tor Browser bug: Math.asinh(0) -> -0
  3283. $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh });
  3284. },{"33":33}],163:[function(_dereq_,module,exports){
  3285. // 20.2.2.7 Math.atanh(x)
  3286. var $export = _dereq_(33);
  3287. var $atanh = Math.atanh;
  3288. // Tor Browser bug: Math.atanh(-0) -> 0
  3289. $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', {
  3290. atanh: function atanh(x) {
  3291. return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;
  3292. }
  3293. });
  3294. },{"33":33}],164:[function(_dereq_,module,exports){
  3295. // 20.2.2.9 Math.cbrt(x)
  3296. var $export = _dereq_(33);
  3297. var sign = _dereq_(65);
  3298. $export($export.S, 'Math', {
  3299. cbrt: function cbrt(x) {
  3300. return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);
  3301. }
  3302. });
  3303. },{"33":33,"65":65}],165:[function(_dereq_,module,exports){
  3304. // 20.2.2.11 Math.clz32(x)
  3305. var $export = _dereq_(33);
  3306. $export($export.S, 'Math', {
  3307. clz32: function clz32(x) {
  3308. return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;
  3309. }
  3310. });
  3311. },{"33":33}],166:[function(_dereq_,module,exports){
  3312. // 20.2.2.12 Math.cosh(x)
  3313. var $export = _dereq_(33);
  3314. var exp = Math.exp;
  3315. $export($export.S, 'Math', {
  3316. cosh: function cosh(x) {
  3317. return (exp(x = +x) + exp(-x)) / 2;
  3318. }
  3319. });
  3320. },{"33":33}],167:[function(_dereq_,module,exports){
  3321. // 20.2.2.14 Math.expm1(x)
  3322. var $export = _dereq_(33);
  3323. var $expm1 = _dereq_(61);
  3324. $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 });
  3325. },{"33":33,"61":61}],168:[function(_dereq_,module,exports){
  3326. // 20.2.2.16 Math.fround(x)
  3327. var $export = _dereq_(33);
  3328. $export($export.S, 'Math', { fround: _dereq_(62) });
  3329. },{"33":33,"62":62}],169:[function(_dereq_,module,exports){
  3330. // 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
  3331. var $export = _dereq_(33);
  3332. var abs = Math.abs;
  3333. $export($export.S, 'Math', {
  3334. hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars
  3335. var sum = 0;
  3336. var i = 0;
  3337. var aLen = arguments.length;
  3338. var larg = 0;
  3339. var arg, div;
  3340. while (i < aLen) {
  3341. arg = abs(arguments[i++]);
  3342. if (larg < arg) {
  3343. div = larg / arg;
  3344. sum = sum * div * div + 1;
  3345. larg = arg;
  3346. } else if (arg > 0) {
  3347. div = arg / larg;
  3348. sum += div * div;
  3349. } else sum += arg;
  3350. }
  3351. return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
  3352. }
  3353. });
  3354. },{"33":33}],170:[function(_dereq_,module,exports){
  3355. // 20.2.2.18 Math.imul(x, y)
  3356. var $export = _dereq_(33);
  3357. var $imul = Math.imul;
  3358. // some WebKit versions fails with big numbers, some has wrong arity
  3359. $export($export.S + $export.F * _dereq_(35)(function () {
  3360. return $imul(0xffffffff, 5) != -5 || $imul.length != 2;
  3361. }), 'Math', {
  3362. imul: function imul(x, y) {
  3363. var UINT16 = 0xffff;
  3364. var xn = +x;
  3365. var yn = +y;
  3366. var xl = UINT16 & xn;
  3367. var yl = UINT16 & yn;
  3368. return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
  3369. }
  3370. });
  3371. },{"33":33,"35":35}],171:[function(_dereq_,module,exports){
  3372. // 20.2.2.21 Math.log10(x)
  3373. var $export = _dereq_(33);
  3374. $export($export.S, 'Math', {
  3375. log10: function log10(x) {
  3376. return Math.log(x) * Math.LOG10E;
  3377. }
  3378. });
  3379. },{"33":33}],172:[function(_dereq_,module,exports){
  3380. // 20.2.2.20 Math.log1p(x)
  3381. var $export = _dereq_(33);
  3382. $export($export.S, 'Math', { log1p: _dereq_(63) });
  3383. },{"33":33,"63":63}],173:[function(_dereq_,module,exports){
  3384. // 20.2.2.22 Math.log2(x)
  3385. var $export = _dereq_(33);
  3386. $export($export.S, 'Math', {
  3387. log2: function log2(x) {
  3388. return Math.log(x) / Math.LN2;
  3389. }
  3390. });
  3391. },{"33":33}],174:[function(_dereq_,module,exports){
  3392. // 20.2.2.28 Math.sign(x)
  3393. var $export = _dereq_(33);
  3394. $export($export.S, 'Math', { sign: _dereq_(65) });
  3395. },{"33":33,"65":65}],175:[function(_dereq_,module,exports){
  3396. // 20.2.2.30 Math.sinh(x)
  3397. var $export = _dereq_(33);
  3398. var expm1 = _dereq_(61);
  3399. var exp = Math.exp;
  3400. // V8 near Chromium 38 has a problem with very small numbers
  3401. $export($export.S + $export.F * _dereq_(35)(function () {
  3402. return !Math.sinh(-2e-17) != -2e-17;
  3403. }), 'Math', {
  3404. sinh: function sinh(x) {
  3405. return Math.abs(x = +x) < 1
  3406. ? (expm1(x) - expm1(-x)) / 2
  3407. : (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);
  3408. }
  3409. });
  3410. },{"33":33,"35":35,"61":61}],176:[function(_dereq_,module,exports){
  3411. // 20.2.2.33 Math.tanh(x)
  3412. var $export = _dereq_(33);
  3413. var expm1 = _dereq_(61);
  3414. var exp = Math.exp;
  3415. $export($export.S, 'Math', {
  3416. tanh: function tanh(x) {
  3417. var a = expm1(x = +x);
  3418. var b = expm1(-x);
  3419. return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
  3420. }
  3421. });
  3422. },{"33":33,"61":61}],177:[function(_dereq_,module,exports){
  3423. // 20.2.2.34 Math.trunc(x)
  3424. var $export = _dereq_(33);
  3425. $export($export.S, 'Math', {
  3426. trunc: function trunc(it) {
  3427. return (it > 0 ? Math.floor : Math.ceil)(it);
  3428. }
  3429. });
  3430. },{"33":33}],178:[function(_dereq_,module,exports){
  3431. 'use strict';
  3432. var global = _dereq_(40);
  3433. var has = _dereq_(41);
  3434. var cof = _dereq_(18);
  3435. var inheritIfRequired = _dereq_(45);
  3436. var toPrimitive = _dereq_(120);
  3437. var fails = _dereq_(35);
  3438. var gOPN = _dereq_(77).f;
  3439. var gOPD = _dereq_(75).f;
  3440. var dP = _dereq_(72).f;
  3441. var $trim = _dereq_(111).trim;
  3442. var NUMBER = 'Number';
  3443. var $Number = global[NUMBER];
  3444. var Base = $Number;
  3445. var proto = $Number.prototype;
  3446. // Opera ~12 has broken Object#toString
  3447. var BROKEN_COF = cof(_dereq_(71)(proto)) == NUMBER;
  3448. var TRIM = 'trim' in String.prototype;
  3449. // 7.1.3 ToNumber(argument)
  3450. var toNumber = function (argument) {
  3451. var it = toPrimitive(argument, false);
  3452. if (typeof it == 'string' && it.length > 2) {
  3453. it = TRIM ? it.trim() : $trim(it, 3);
  3454. var first = it.charCodeAt(0);
  3455. var third, radix, maxCode;
  3456. if (first === 43 || first === 45) {
  3457. third = it.charCodeAt(2);
  3458. if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
  3459. } else if (first === 48) {
  3460. switch (it.charCodeAt(1)) {
  3461. case 66: case 98: radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i
  3462. case 79: case 111: radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i
  3463. default: return +it;
  3464. }
  3465. for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) {
  3466. code = digits.charCodeAt(i);
  3467. // parseInt parses a string to a first unavailable symbol
  3468. // but ToNumber should return NaN if a string contains unavailable symbols
  3469. if (code < 48 || code > maxCode) return NaN;
  3470. } return parseInt(digits, radix);
  3471. }
  3472. } return +it;
  3473. };
  3474. if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) {
  3475. $Number = function Number(value) {
  3476. var it = arguments.length < 1 ? 0 : value;
  3477. var that = this;
  3478. return that instanceof $Number
  3479. // check on 1..constructor(foo) case
  3480. && (BROKEN_COF ? fails(function () { proto.valueOf.call(that); }) : cof(that) != NUMBER)
  3481. ? inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it);
  3482. };
  3483. for (var keys = _dereq_(29) ? gOPN(Base) : (
  3484. // ES3:
  3485. 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
  3486. // ES6 (in case, if modules with ES6 Number statics required before):
  3487. 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
  3488. 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
  3489. ).split(','), j = 0, key; keys.length > j; j++) {
  3490. if (has(Base, key = keys[j]) && !has($Number, key)) {
  3491. dP($Number, key, gOPD(Base, key));
  3492. }
  3493. }
  3494. $Number.prototype = proto;
  3495. proto.constructor = $Number;
  3496. _dereq_(94)(global, NUMBER, $Number);
  3497. }
  3498. },{"111":111,"120":120,"18":18,"29":29,"35":35,"40":40,"41":41,"45":45,"71":71,"72":72,"75":75,"77":77,"94":94}],179:[function(_dereq_,module,exports){
  3499. // 20.1.2.1 Number.EPSILON
  3500. var $export = _dereq_(33);
  3501. $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) });
  3502. },{"33":33}],180:[function(_dereq_,module,exports){
  3503. // 20.1.2.2 Number.isFinite(number)
  3504. var $export = _dereq_(33);
  3505. var _isFinite = _dereq_(40).isFinite;
  3506. $export($export.S, 'Number', {
  3507. isFinite: function isFinite(it) {
  3508. return typeof it == 'number' && _isFinite(it);
  3509. }
  3510. });
  3511. },{"33":33,"40":40}],181:[function(_dereq_,module,exports){
  3512. // 20.1.2.3 Number.isInteger(number)
  3513. var $export = _dereq_(33);
  3514. $export($export.S, 'Number', { isInteger: _dereq_(50) });
  3515. },{"33":33,"50":50}],182:[function(_dereq_,module,exports){
  3516. // 20.1.2.4 Number.isNaN(number)
  3517. var $export = _dereq_(33);
  3518. $export($export.S, 'Number', {
  3519. isNaN: function isNaN(number) {
  3520. // eslint-disable-next-line no-self-compare
  3521. return number != number;
  3522. }
  3523. });
  3524. },{"33":33}],183:[function(_dereq_,module,exports){
  3525. // 20.1.2.5 Number.isSafeInteger(number)
  3526. var $export = _dereq_(33);
  3527. var isInteger = _dereq_(50);
  3528. var abs = Math.abs;
  3529. $export($export.S, 'Number', {
  3530. isSafeInteger: function isSafeInteger(number) {
  3531. return isInteger(number) && abs(number) <= 0x1fffffffffffff;
  3532. }
  3533. });
  3534. },{"33":33,"50":50}],184:[function(_dereq_,module,exports){
  3535. // 20.1.2.6 Number.MAX_SAFE_INTEGER
  3536. var $export = _dereq_(33);
  3537. $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });
  3538. },{"33":33}],185:[function(_dereq_,module,exports){
  3539. // 20.1.2.10 Number.MIN_SAFE_INTEGER
  3540. var $export = _dereq_(33);
  3541. $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff });
  3542. },{"33":33}],186:[function(_dereq_,module,exports){
  3543. var $export = _dereq_(33);
  3544. var $parseFloat = _dereq_(86);
  3545. // 20.1.2.12 Number.parseFloat(string)
  3546. $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat });
  3547. },{"33":33,"86":86}],187:[function(_dereq_,module,exports){
  3548. var $export = _dereq_(33);
  3549. var $parseInt = _dereq_(87);
  3550. // 20.1.2.13 Number.parseInt(string, radix)
  3551. $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt });
  3552. },{"33":33,"87":87}],188:[function(_dereq_,module,exports){
  3553. 'use strict';
  3554. var $export = _dereq_(33);
  3555. var toInteger = _dereq_(116);
  3556. var aNumberValue = _dereq_(4);
  3557. var repeat = _dereq_(110);
  3558. var $toFixed = 1.0.toFixed;
  3559. var floor = Math.floor;
  3560. var data = [0, 0, 0, 0, 0, 0];
  3561. var ERROR = 'Number.toFixed: incorrect invocation!';
  3562. var ZERO = '0';
  3563. var multiply = function (n, c) {
  3564. var i = -1;
  3565. var c2 = c;
  3566. while (++i < 6) {
  3567. c2 += n * data[i];
  3568. data[i] = c2 % 1e7;
  3569. c2 = floor(c2 / 1e7);
  3570. }
  3571. };
  3572. var divide = function (n) {
  3573. var i = 6;
  3574. var c = 0;
  3575. while (--i >= 0) {
  3576. c += data[i];
  3577. data[i] = floor(c / n);
  3578. c = (c % n) * 1e7;
  3579. }
  3580. };
  3581. var numToString = function () {
  3582. var i = 6;
  3583. var s = '';
  3584. while (--i >= 0) {
  3585. if (s !== '' || i === 0 || data[i] !== 0) {
  3586. var t = String(data[i]);
  3587. s = s === '' ? t : s + repeat.call(ZERO, 7 - t.length) + t;
  3588. }
  3589. } return s;
  3590. };
  3591. var pow = function (x, n, acc) {
  3592. return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
  3593. };
  3594. var log = function (x) {
  3595. var n = 0;
  3596. var x2 = x;
  3597. while (x2 >= 4096) {
  3598. n += 12;
  3599. x2 /= 4096;
  3600. }
  3601. while (x2 >= 2) {
  3602. n += 1;
  3603. x2 /= 2;
  3604. } return n;
  3605. };
  3606. $export($export.P + $export.F * (!!$toFixed && (
  3607. 0.00008.toFixed(3) !== '0.000' ||
  3608. 0.9.toFixed(0) !== '1' ||
  3609. 1.255.toFixed(2) !== '1.25' ||
  3610. 1000000000000000128.0.toFixed(0) !== '1000000000000000128'
  3611. ) || !_dereq_(35)(function () {
  3612. // V8 ~ Android 4.3-
  3613. $toFixed.call({});
  3614. })), 'Number', {
  3615. toFixed: function toFixed(fractionDigits) {
  3616. var x = aNumberValue(this, ERROR);
  3617. var f = toInteger(fractionDigits);
  3618. var s = '';
  3619. var m = ZERO;
  3620. var e, z, j, k;
  3621. if (f < 0 || f > 20) throw RangeError(ERROR);
  3622. // eslint-disable-next-line no-self-compare
  3623. if (x != x) return 'NaN';
  3624. if (x <= -1e21 || x >= 1e21) return String(x);
  3625. if (x < 0) {
  3626. s = '-';
  3627. x = -x;
  3628. }
  3629. if (x > 1e-21) {
  3630. e = log(x * pow(2, 69, 1)) - 69;
  3631. z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1);
  3632. z *= 0x10000000000000;
  3633. e = 52 - e;
  3634. if (e > 0) {
  3635. multiply(0, z);
  3636. j = f;
  3637. while (j >= 7) {
  3638. multiply(1e7, 0);
  3639. j -= 7;
  3640. }
  3641. multiply(pow(10, j, 1), 0);
  3642. j = e - 1;
  3643. while (j >= 23) {
  3644. divide(1 << 23);
  3645. j -= 23;
  3646. }
  3647. divide(1 << j);
  3648. multiply(1, 1);
  3649. divide(2);
  3650. m = numToString();
  3651. } else {
  3652. multiply(0, z);
  3653. multiply(1 << -e, 0);
  3654. m = numToString() + repeat.call(ZERO, f);
  3655. }
  3656. }
  3657. if (f > 0) {
  3658. k = m.length;
  3659. m = s + (k <= f ? '0.' + repeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f));
  3660. } else {
  3661. m = s + m;
  3662. } return m;
  3663. }
  3664. });
  3665. },{"110":110,"116":116,"33":33,"35":35,"4":4}],189:[function(_dereq_,module,exports){
  3666. 'use strict';
  3667. var $export = _dereq_(33);
  3668. var $fails = _dereq_(35);
  3669. var aNumberValue = _dereq_(4);
  3670. var $toPrecision = 1.0.toPrecision;
  3671. $export($export.P + $export.F * ($fails(function () {
  3672. // IE7-
  3673. return $toPrecision.call(1, undefined) !== '1';
  3674. }) || !$fails(function () {
  3675. // V8 ~ Android 4.3-
  3676. $toPrecision.call({});
  3677. })), 'Number', {
  3678. toPrecision: function toPrecision(precision) {
  3679. var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!');
  3680. return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision);
  3681. }
  3682. });
  3683. },{"33":33,"35":35,"4":4}],190:[function(_dereq_,module,exports){
  3684. // 19.1.3.1 Object.assign(target, source)
  3685. var $export = _dereq_(33);
  3686. $export($export.S + $export.F, 'Object', { assign: _dereq_(70) });
  3687. },{"33":33,"70":70}],191:[function(_dereq_,module,exports){
  3688. var $export = _dereq_(33);
  3689. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  3690. $export($export.S, 'Object', { create: _dereq_(71) });
  3691. },{"33":33,"71":71}],192:[function(_dereq_,module,exports){
  3692. var $export = _dereq_(33);
  3693. // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
  3694. $export($export.S + $export.F * !_dereq_(29), 'Object', { defineProperties: _dereq_(73) });
  3695. },{"29":29,"33":33,"73":73}],193:[function(_dereq_,module,exports){
  3696. var $export = _dereq_(33);
  3697. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  3698. $export($export.S + $export.F * !_dereq_(29), 'Object', { defineProperty: _dereq_(72).f });
  3699. },{"29":29,"33":33,"72":72}],194:[function(_dereq_,module,exports){
  3700. // 19.1.2.5 Object.freeze(O)
  3701. var isObject = _dereq_(51);
  3702. var meta = _dereq_(66).onFreeze;
  3703. _dereq_(83)('freeze', function ($freeze) {
  3704. return function freeze(it) {
  3705. return $freeze && isObject(it) ? $freeze(meta(it)) : it;
  3706. };
  3707. });
  3708. },{"51":51,"66":66,"83":83}],195:[function(_dereq_,module,exports){
  3709. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  3710. var toIObject = _dereq_(117);
  3711. var $getOwnPropertyDescriptor = _dereq_(75).f;
  3712. _dereq_(83)('getOwnPropertyDescriptor', function () {
  3713. return function getOwnPropertyDescriptor(it, key) {
  3714. return $getOwnPropertyDescriptor(toIObject(it), key);
  3715. };
  3716. });
  3717. },{"117":117,"75":75,"83":83}],196:[function(_dereq_,module,exports){
  3718. // 19.1.2.7 Object.getOwnPropertyNames(O)
  3719. _dereq_(83)('getOwnPropertyNames', function () {
  3720. return _dereq_(76).f;
  3721. });
  3722. },{"76":76,"83":83}],197:[function(_dereq_,module,exports){
  3723. // 19.1.2.9 Object.getPrototypeOf(O)
  3724. var toObject = _dereq_(119);
  3725. var $getPrototypeOf = _dereq_(79);
  3726. _dereq_(83)('getPrototypeOf', function () {
  3727. return function getPrototypeOf(it) {
  3728. return $getPrototypeOf(toObject(it));
  3729. };
  3730. });
  3731. },{"119":119,"79":79,"83":83}],198:[function(_dereq_,module,exports){
  3732. // 19.1.2.11 Object.isExtensible(O)
  3733. var isObject = _dereq_(51);
  3734. _dereq_(83)('isExtensible', function ($isExtensible) {
  3735. return function isExtensible(it) {
  3736. return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
  3737. };
  3738. });
  3739. },{"51":51,"83":83}],199:[function(_dereq_,module,exports){
  3740. // 19.1.2.12 Object.isFrozen(O)
  3741. var isObject = _dereq_(51);
  3742. _dereq_(83)('isFrozen', function ($isFrozen) {
  3743. return function isFrozen(it) {
  3744. return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
  3745. };
  3746. });
  3747. },{"51":51,"83":83}],200:[function(_dereq_,module,exports){
  3748. // 19.1.2.13 Object.isSealed(O)
  3749. var isObject = _dereq_(51);
  3750. _dereq_(83)('isSealed', function ($isSealed) {
  3751. return function isSealed(it) {
  3752. return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
  3753. };
  3754. });
  3755. },{"51":51,"83":83}],201:[function(_dereq_,module,exports){
  3756. // 19.1.3.10 Object.is(value1, value2)
  3757. var $export = _dereq_(33);
  3758. $export($export.S, 'Object', { is: _dereq_(96) });
  3759. },{"33":33,"96":96}],202:[function(_dereq_,module,exports){
  3760. // 19.1.2.14 Object.keys(O)
  3761. var toObject = _dereq_(119);
  3762. var $keys = _dereq_(81);
  3763. _dereq_(83)('keys', function () {
  3764. return function keys(it) {
  3765. return $keys(toObject(it));
  3766. };
  3767. });
  3768. },{"119":119,"81":81,"83":83}],203:[function(_dereq_,module,exports){
  3769. // 19.1.2.15 Object.preventExtensions(O)
  3770. var isObject = _dereq_(51);
  3771. var meta = _dereq_(66).onFreeze;
  3772. _dereq_(83)('preventExtensions', function ($preventExtensions) {
  3773. return function preventExtensions(it) {
  3774. return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;
  3775. };
  3776. });
  3777. },{"51":51,"66":66,"83":83}],204:[function(_dereq_,module,exports){
  3778. // 19.1.2.17 Object.seal(O)
  3779. var isObject = _dereq_(51);
  3780. var meta = _dereq_(66).onFreeze;
  3781. _dereq_(83)('seal', function ($seal) {
  3782. return function seal(it) {
  3783. return $seal && isObject(it) ? $seal(meta(it)) : it;
  3784. };
  3785. });
  3786. },{"51":51,"66":66,"83":83}],205:[function(_dereq_,module,exports){
  3787. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  3788. var $export = _dereq_(33);
  3789. $export($export.S, 'Object', { setPrototypeOf: _dereq_(99).set });
  3790. },{"33":33,"99":99}],206:[function(_dereq_,module,exports){
  3791. 'use strict';
  3792. // 19.1.3.6 Object.prototype.toString()
  3793. var classof = _dereq_(17);
  3794. var test = {};
  3795. test[_dereq_(128)('toStringTag')] = 'z';
  3796. if (test + '' != '[object z]') {
  3797. _dereq_(94)(Object.prototype, 'toString', function toString() {
  3798. return '[object ' + classof(this) + ']';
  3799. }, true);
  3800. }
  3801. },{"128":128,"17":17,"94":94}],207:[function(_dereq_,module,exports){
  3802. var $export = _dereq_(33);
  3803. var $parseFloat = _dereq_(86);
  3804. // 18.2.4 parseFloat(string)
  3805. $export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat });
  3806. },{"33":33,"86":86}],208:[function(_dereq_,module,exports){
  3807. var $export = _dereq_(33);
  3808. var $parseInt = _dereq_(87);
  3809. // 18.2.5 parseInt(string, radix)
  3810. $export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt });
  3811. },{"33":33,"87":87}],209:[function(_dereq_,module,exports){
  3812. 'use strict';
  3813. var LIBRARY = _dereq_(60);
  3814. var global = _dereq_(40);
  3815. var ctx = _dereq_(25);
  3816. var classof = _dereq_(17);
  3817. var $export = _dereq_(33);
  3818. var isObject = _dereq_(51);
  3819. var aFunction = _dereq_(3);
  3820. var anInstance = _dereq_(6);
  3821. var forOf = _dereq_(39);
  3822. var speciesConstructor = _dereq_(104);
  3823. var task = _dereq_(113).set;
  3824. var microtask = _dereq_(68)();
  3825. var newPromiseCapabilityModule = _dereq_(69);
  3826. var perform = _dereq_(90);
  3827. var promiseResolve = _dereq_(91);
  3828. var PROMISE = 'Promise';
  3829. var TypeError = global.TypeError;
  3830. var process = global.process;
  3831. var $Promise = global[PROMISE];
  3832. var isNode = classof(process) == 'process';
  3833. var empty = function () { /* empty */ };
  3834. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  3835. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  3836. var USE_NATIVE = !!function () {
  3837. try {
  3838. // correct subclassing with @@species support
  3839. var promise = $Promise.resolve(1);
  3840. var FakePromise = (promise.constructor = {})[_dereq_(128)('species')] = function (exec) {
  3841. exec(empty, empty);
  3842. };
  3843. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  3844. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  3845. } catch (e) { /* empty */ }
  3846. }();
  3847. // helpers
  3848. var sameConstructor = LIBRARY ? function (a, b) {
  3849. // with library wrapper special case
  3850. return a === b || a === $Promise && b === Wrapper;
  3851. } : function (a, b) {
  3852. return a === b;
  3853. };
  3854. var isThenable = function (it) {
  3855. var then;
  3856. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  3857. };
  3858. var notify = function (promise, isReject) {
  3859. if (promise._n) return;
  3860. promise._n = true;
  3861. var chain = promise._c;
  3862. microtask(function () {
  3863. var value = promise._v;
  3864. var ok = promise._s == 1;
  3865. var i = 0;
  3866. var run = function (reaction) {
  3867. var handler = ok ? reaction.ok : reaction.fail;
  3868. var resolve = reaction.resolve;
  3869. var reject = reaction.reject;
  3870. var domain = reaction.domain;
  3871. var result, then;
  3872. try {
  3873. if (handler) {
  3874. if (!ok) {
  3875. if (promise._h == 2) onHandleUnhandled(promise);
  3876. promise._h = 1;
  3877. }
  3878. if (handler === true) result = value;
  3879. else {
  3880. if (domain) domain.enter();
  3881. result = handler(value);
  3882. if (domain) domain.exit();
  3883. }
  3884. if (result === reaction.promise) {
  3885. reject(TypeError('Promise-chain cycle'));
  3886. } else if (then = isThenable(result)) {
  3887. then.call(result, resolve, reject);
  3888. } else resolve(result);
  3889. } else reject(value);
  3890. } catch (e) {
  3891. reject(e);
  3892. }
  3893. };
  3894. while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
  3895. promise._c = [];
  3896. promise._n = false;
  3897. if (isReject && !promise._h) onUnhandled(promise);
  3898. });
  3899. };
  3900. var onUnhandled = function (promise) {
  3901. task.call(global, function () {
  3902. var value = promise._v;
  3903. var unhandled = isUnhandled(promise);
  3904. var result, handler, console;
  3905. if (unhandled) {
  3906. result = perform(function () {
  3907. if (isNode) {
  3908. process.emit('unhandledRejection', value, promise);
  3909. } else if (handler = global.onunhandledrejection) {
  3910. handler({ promise: promise, reason: value });
  3911. } else if ((console = global.console) && console.error) {
  3912. console.error('Unhandled promise rejection', value);
  3913. }
  3914. });
  3915. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  3916. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  3917. } promise._a = undefined;
  3918. if (unhandled && result.e) throw result.v;
  3919. });
  3920. };
  3921. var isUnhandled = function (promise) {
  3922. if (promise._h == 1) return false;
  3923. var chain = promise._a || promise._c;
  3924. var i = 0;
  3925. var reaction;
  3926. while (chain.length > i) {
  3927. reaction = chain[i++];
  3928. if (reaction.fail || !isUnhandled(reaction.promise)) return false;
  3929. } return true;
  3930. };
  3931. var onHandleUnhandled = function (promise) {
  3932. task.call(global, function () {
  3933. var handler;
  3934. if (isNode) {
  3935. process.emit('rejectionHandled', promise);
  3936. } else if (handler = global.onrejectionhandled) {
  3937. handler({ promise: promise, reason: promise._v });
  3938. }
  3939. });
  3940. };
  3941. var $reject = function (value) {
  3942. var promise = this;
  3943. if (promise._d) return;
  3944. promise._d = true;
  3945. promise = promise._w || promise; // unwrap
  3946. promise._v = value;
  3947. promise._s = 2;
  3948. if (!promise._a) promise._a = promise._c.slice();
  3949. notify(promise, true);
  3950. };
  3951. var $resolve = function (value) {
  3952. var promise = this;
  3953. var then;
  3954. if (promise._d) return;
  3955. promise._d = true;
  3956. promise = promise._w || promise; // unwrap
  3957. try {
  3958. if (promise === value) throw TypeError("Promise can't be resolved itself");
  3959. if (then = isThenable(value)) {
  3960. microtask(function () {
  3961. var wrapper = { _w: promise, _d: false }; // wrap
  3962. try {
  3963. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  3964. } catch (e) {
  3965. $reject.call(wrapper, e);
  3966. }
  3967. });
  3968. } else {
  3969. promise._v = value;
  3970. promise._s = 1;
  3971. notify(promise, false);
  3972. }
  3973. } catch (e) {
  3974. $reject.call({ _w: promise, _d: false }, e); // wrap
  3975. }
  3976. };
  3977. // constructor polyfill
  3978. if (!USE_NATIVE) {
  3979. // 25.4.3.1 Promise(executor)
  3980. $Promise = function Promise(executor) {
  3981. anInstance(this, $Promise, PROMISE, '_h');
  3982. aFunction(executor);
  3983. Internal.call(this);
  3984. try {
  3985. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  3986. } catch (err) {
  3987. $reject.call(this, err);
  3988. }
  3989. };
  3990. // eslint-disable-next-line no-unused-vars
  3991. Internal = function Promise(executor) {
  3992. this._c = []; // <- awaiting reactions
  3993. this._a = undefined; // <- checked in isUnhandled reactions
  3994. this._s = 0; // <- state
  3995. this._d = false; // <- done
  3996. this._v = undefined; // <- value
  3997. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  3998. this._n = false; // <- notify
  3999. };
  4000. Internal.prototype = _dereq_(93)($Promise.prototype, {
  4001. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  4002. then: function then(onFulfilled, onRejected) {
  4003. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  4004. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  4005. reaction.fail = typeof onRejected == 'function' && onRejected;
  4006. reaction.domain = isNode ? process.domain : undefined;
  4007. this._c.push(reaction);
  4008. if (this._a) this._a.push(reaction);
  4009. if (this._s) notify(this, false);
  4010. return reaction.promise;
  4011. },
  4012. // 25.4.5.1 Promise.prototype.catch(onRejected)
  4013. 'catch': function (onRejected) {
  4014. return this.then(undefined, onRejected);
  4015. }
  4016. });
  4017. OwnPromiseCapability = function () {
  4018. var promise = new Internal();
  4019. this.promise = promise;
  4020. this.resolve = ctx($resolve, promise, 1);
  4021. this.reject = ctx($reject, promise, 1);
  4022. };
  4023. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  4024. return sameConstructor($Promise, C)
  4025. ? new OwnPromiseCapability(C)
  4026. : newGenericPromiseCapability(C);
  4027. };
  4028. }
  4029. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
  4030. _dereq_(101)($Promise, PROMISE);
  4031. _dereq_(100)(PROMISE);
  4032. Wrapper = _dereq_(23)[PROMISE];
  4033. // statics
  4034. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  4035. // 25.4.4.5 Promise.reject(r)
  4036. reject: function reject(r) {
  4037. var capability = newPromiseCapability(this);
  4038. var $$reject = capability.reject;
  4039. $$reject(r);
  4040. return capability.promise;
  4041. }
  4042. });
  4043. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  4044. // 25.4.4.6 Promise.resolve(x)
  4045. resolve: function resolve(x) {
  4046. // instanceof instead of internal slot check because we should fix it without replacement native Promise core
  4047. if (x instanceof $Promise && sameConstructor(x.constructor, this)) return x;
  4048. return promiseResolve(this, x);
  4049. }
  4050. });
  4051. $export($export.S + $export.F * !(USE_NATIVE && _dereq_(56)(function (iter) {
  4052. $Promise.all(iter)['catch'](empty);
  4053. })), PROMISE, {
  4054. // 25.4.4.1 Promise.all(iterable)
  4055. all: function all(iterable) {
  4056. var C = this;
  4057. var capability = newPromiseCapability(C);
  4058. var resolve = capability.resolve;
  4059. var reject = capability.reject;
  4060. var result = perform(function () {
  4061. var values = [];
  4062. var index = 0;
  4063. var remaining = 1;
  4064. forOf(iterable, false, function (promise) {
  4065. var $index = index++;
  4066. var alreadyCalled = false;
  4067. values.push(undefined);
  4068. remaining++;
  4069. C.resolve(promise).then(function (value) {
  4070. if (alreadyCalled) return;
  4071. alreadyCalled = true;
  4072. values[$index] = value;
  4073. --remaining || resolve(values);
  4074. }, reject);
  4075. });
  4076. --remaining || resolve(values);
  4077. });
  4078. if (result.e) reject(result.v);
  4079. return capability.promise;
  4080. },
  4081. // 25.4.4.4 Promise.race(iterable)
  4082. race: function race(iterable) {
  4083. var C = this;
  4084. var capability = newPromiseCapability(C);
  4085. var reject = capability.reject;
  4086. var result = perform(function () {
  4087. forOf(iterable, false, function (promise) {
  4088. C.resolve(promise).then(capability.resolve, reject);
  4089. });
  4090. });
  4091. if (result.e) reject(result.v);
  4092. return capability.promise;
  4093. }
  4094. });
  4095. },{"100":100,"101":101,"104":104,"113":113,"128":128,"17":17,"23":23,"25":25,"3":3,"33":33,"39":39,"40":40,"51":51,"56":56,"6":6,"60":60,"68":68,"69":69,"90":90,"91":91,"93":93}],210:[function(_dereq_,module,exports){
  4096. // 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
  4097. var $export = _dereq_(33);
  4098. var aFunction = _dereq_(3);
  4099. var anObject = _dereq_(7);
  4100. var rApply = (_dereq_(40).Reflect || {}).apply;
  4101. var fApply = Function.apply;
  4102. // MS Edge argumentsList argument is optional
  4103. $export($export.S + $export.F * !_dereq_(35)(function () {
  4104. rApply(function () { /* empty */ });
  4105. }), 'Reflect', {
  4106. apply: function apply(target, thisArgument, argumentsList) {
  4107. var T = aFunction(target);
  4108. var L = anObject(argumentsList);
  4109. return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L);
  4110. }
  4111. });
  4112. },{"3":3,"33":33,"35":35,"40":40,"7":7}],211:[function(_dereq_,module,exports){
  4113. // 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
  4114. var $export = _dereq_(33);
  4115. var create = _dereq_(71);
  4116. var aFunction = _dereq_(3);
  4117. var anObject = _dereq_(7);
  4118. var isObject = _dereq_(51);
  4119. var fails = _dereq_(35);
  4120. var bind = _dereq_(16);
  4121. var rConstruct = (_dereq_(40).Reflect || {}).construct;
  4122. // MS Edge supports only 2 arguments and argumentsList argument is optional
  4123. // FF Nightly sets third argument as `new.target`, but does not create `this` from it
  4124. var NEW_TARGET_BUG = fails(function () {
  4125. function F() { /* empty */ }
  4126. return !(rConstruct(function () { /* empty */ }, [], F) instanceof F);
  4127. });
  4128. var ARGS_BUG = !fails(function () {
  4129. rConstruct(function () { /* empty */ });
  4130. });
  4131. $export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', {
  4132. construct: function construct(Target, args /* , newTarget */) {
  4133. aFunction(Target);
  4134. anObject(args);
  4135. var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);
  4136. if (ARGS_BUG && !NEW_TARGET_BUG) return rConstruct(Target, args, newTarget);
  4137. if (Target == newTarget) {
  4138. // w/o altered newTarget, optimization for 0-4 arguments
  4139. switch (args.length) {
  4140. case 0: return new Target();
  4141. case 1: return new Target(args[0]);
  4142. case 2: return new Target(args[0], args[1]);
  4143. case 3: return new Target(args[0], args[1], args[2]);
  4144. case 4: return new Target(args[0], args[1], args[2], args[3]);
  4145. }
  4146. // w/o altered newTarget, lot of arguments case
  4147. var $args = [null];
  4148. $args.push.apply($args, args);
  4149. return new (bind.apply(Target, $args))();
  4150. }
  4151. // with altered newTarget, not support built-in constructors
  4152. var proto = newTarget.prototype;
  4153. var instance = create(isObject(proto) ? proto : Object.prototype);
  4154. var result = Function.apply.call(Target, instance, args);
  4155. return isObject(result) ? result : instance;
  4156. }
  4157. });
  4158. },{"16":16,"3":3,"33":33,"35":35,"40":40,"51":51,"7":7,"71":71}],212:[function(_dereq_,module,exports){
  4159. // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
  4160. var dP = _dereq_(72);
  4161. var $export = _dereq_(33);
  4162. var anObject = _dereq_(7);
  4163. var toPrimitive = _dereq_(120);
  4164. // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
  4165. $export($export.S + $export.F * _dereq_(35)(function () {
  4166. // eslint-disable-next-line no-undef
  4167. Reflect.defineProperty(dP.f({}, 1, { value: 1 }), 1, { value: 2 });
  4168. }), 'Reflect', {
  4169. defineProperty: function defineProperty(target, propertyKey, attributes) {
  4170. anObject(target);
  4171. propertyKey = toPrimitive(propertyKey, true);
  4172. anObject(attributes);
  4173. try {
  4174. dP.f(target, propertyKey, attributes);
  4175. return true;
  4176. } catch (e) {
  4177. return false;
  4178. }
  4179. }
  4180. });
  4181. },{"120":120,"33":33,"35":35,"7":7,"72":72}],213:[function(_dereq_,module,exports){
  4182. // 26.1.4 Reflect.deleteProperty(target, propertyKey)
  4183. var $export = _dereq_(33);
  4184. var gOPD = _dereq_(75).f;
  4185. var anObject = _dereq_(7);
  4186. $export($export.S, 'Reflect', {
  4187. deleteProperty: function deleteProperty(target, propertyKey) {
  4188. var desc = gOPD(anObject(target), propertyKey);
  4189. return desc && !desc.configurable ? false : delete target[propertyKey];
  4190. }
  4191. });
  4192. },{"33":33,"7":7,"75":75}],214:[function(_dereq_,module,exports){
  4193. 'use strict';
  4194. // 26.1.5 Reflect.enumerate(target)
  4195. var $export = _dereq_(33);
  4196. var anObject = _dereq_(7);
  4197. var Enumerate = function (iterated) {
  4198. this._t = anObject(iterated); // target
  4199. this._i = 0; // next index
  4200. var keys = this._k = []; // keys
  4201. var key;
  4202. for (key in iterated) keys.push(key);
  4203. };
  4204. _dereq_(54)(Enumerate, 'Object', function () {
  4205. var that = this;
  4206. var keys = that._k;
  4207. var key;
  4208. do {
  4209. if (that._i >= keys.length) return { value: undefined, done: true };
  4210. } while (!((key = keys[that._i++]) in that._t));
  4211. return { value: key, done: false };
  4212. });
  4213. $export($export.S, 'Reflect', {
  4214. enumerate: function enumerate(target) {
  4215. return new Enumerate(target);
  4216. }
  4217. });
  4218. },{"33":33,"54":54,"7":7}],215:[function(_dereq_,module,exports){
  4219. // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
  4220. var gOPD = _dereq_(75);
  4221. var $export = _dereq_(33);
  4222. var anObject = _dereq_(7);
  4223. $export($export.S, 'Reflect', {
  4224. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {
  4225. return gOPD.f(anObject(target), propertyKey);
  4226. }
  4227. });
  4228. },{"33":33,"7":7,"75":75}],216:[function(_dereq_,module,exports){
  4229. // 26.1.8 Reflect.getPrototypeOf(target)
  4230. var $export = _dereq_(33);
  4231. var getProto = _dereq_(79);
  4232. var anObject = _dereq_(7);
  4233. $export($export.S, 'Reflect', {
  4234. getPrototypeOf: function getPrototypeOf(target) {
  4235. return getProto(anObject(target));
  4236. }
  4237. });
  4238. },{"33":33,"7":7,"79":79}],217:[function(_dereq_,module,exports){
  4239. // 26.1.6 Reflect.get(target, propertyKey [, receiver])
  4240. var gOPD = _dereq_(75);
  4241. var getPrototypeOf = _dereq_(79);
  4242. var has = _dereq_(41);
  4243. var $export = _dereq_(33);
  4244. var isObject = _dereq_(51);
  4245. var anObject = _dereq_(7);
  4246. function get(target, propertyKey /* , receiver */) {
  4247. var receiver = arguments.length < 3 ? target : arguments[2];
  4248. var desc, proto;
  4249. if (anObject(target) === receiver) return target[propertyKey];
  4250. if (desc = gOPD.f(target, propertyKey)) return has(desc, 'value')
  4251. ? desc.value
  4252. : desc.get !== undefined
  4253. ? desc.get.call(receiver)
  4254. : undefined;
  4255. if (isObject(proto = getPrototypeOf(target))) return get(proto, propertyKey, receiver);
  4256. }
  4257. $export($export.S, 'Reflect', { get: get });
  4258. },{"33":33,"41":41,"51":51,"7":7,"75":75,"79":79}],218:[function(_dereq_,module,exports){
  4259. // 26.1.9 Reflect.has(target, propertyKey)
  4260. var $export = _dereq_(33);
  4261. $export($export.S, 'Reflect', {
  4262. has: function has(target, propertyKey) {
  4263. return propertyKey in target;
  4264. }
  4265. });
  4266. },{"33":33}],219:[function(_dereq_,module,exports){
  4267. // 26.1.10 Reflect.isExtensible(target)
  4268. var $export = _dereq_(33);
  4269. var anObject = _dereq_(7);
  4270. var $isExtensible = Object.isExtensible;
  4271. $export($export.S, 'Reflect', {
  4272. isExtensible: function isExtensible(target) {
  4273. anObject(target);
  4274. return $isExtensible ? $isExtensible(target) : true;
  4275. }
  4276. });
  4277. },{"33":33,"7":7}],220:[function(_dereq_,module,exports){
  4278. // 26.1.11 Reflect.ownKeys(target)
  4279. var $export = _dereq_(33);
  4280. $export($export.S, 'Reflect', { ownKeys: _dereq_(85) });
  4281. },{"33":33,"85":85}],221:[function(_dereq_,module,exports){
  4282. // 26.1.12 Reflect.preventExtensions(target)
  4283. var $export = _dereq_(33);
  4284. var anObject = _dereq_(7);
  4285. var $preventExtensions = Object.preventExtensions;
  4286. $export($export.S, 'Reflect', {
  4287. preventExtensions: function preventExtensions(target) {
  4288. anObject(target);
  4289. try {
  4290. if ($preventExtensions) $preventExtensions(target);
  4291. return true;
  4292. } catch (e) {
  4293. return false;
  4294. }
  4295. }
  4296. });
  4297. },{"33":33,"7":7}],222:[function(_dereq_,module,exports){
  4298. // 26.1.14 Reflect.setPrototypeOf(target, proto)
  4299. var $export = _dereq_(33);
  4300. var setProto = _dereq_(99);
  4301. if (setProto) $export($export.S, 'Reflect', {
  4302. setPrototypeOf: function setPrototypeOf(target, proto) {
  4303. setProto.check(target, proto);
  4304. try {
  4305. setProto.set(target, proto);
  4306. return true;
  4307. } catch (e) {
  4308. return false;
  4309. }
  4310. }
  4311. });
  4312. },{"33":33,"99":99}],223:[function(_dereq_,module,exports){
  4313. // 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
  4314. var dP = _dereq_(72);
  4315. var gOPD = _dereq_(75);
  4316. var getPrototypeOf = _dereq_(79);
  4317. var has = _dereq_(41);
  4318. var $export = _dereq_(33);
  4319. var createDesc = _dereq_(92);
  4320. var anObject = _dereq_(7);
  4321. var isObject = _dereq_(51);
  4322. function set(target, propertyKey, V /* , receiver */) {
  4323. var receiver = arguments.length < 4 ? target : arguments[3];
  4324. var ownDesc = gOPD.f(anObject(target), propertyKey);
  4325. var existingDescriptor, proto;
  4326. if (!ownDesc) {
  4327. if (isObject(proto = getPrototypeOf(target))) {
  4328. return set(proto, propertyKey, V, receiver);
  4329. }
  4330. ownDesc = createDesc(0);
  4331. }
  4332. if (has(ownDesc, 'value')) {
  4333. if (ownDesc.writable === false || !isObject(receiver)) return false;
  4334. existingDescriptor = gOPD.f(receiver, propertyKey) || createDesc(0);
  4335. existingDescriptor.value = V;
  4336. dP.f(receiver, propertyKey, existingDescriptor);
  4337. return true;
  4338. }
  4339. return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
  4340. }
  4341. $export($export.S, 'Reflect', { set: set });
  4342. },{"33":33,"41":41,"51":51,"7":7,"72":72,"75":75,"79":79,"92":92}],224:[function(_dereq_,module,exports){
  4343. var global = _dereq_(40);
  4344. var inheritIfRequired = _dereq_(45);
  4345. var dP = _dereq_(72).f;
  4346. var gOPN = _dereq_(77).f;
  4347. var isRegExp = _dereq_(52);
  4348. var $flags = _dereq_(37);
  4349. var $RegExp = global.RegExp;
  4350. var Base = $RegExp;
  4351. var proto = $RegExp.prototype;
  4352. var re1 = /a/g;
  4353. var re2 = /a/g;
  4354. // "new" creates a new object, old webkit buggy here
  4355. var CORRECT_NEW = new $RegExp(re1) !== re1;
  4356. if (_dereq_(29) && (!CORRECT_NEW || _dereq_(35)(function () {
  4357. re2[_dereq_(128)('match')] = false;
  4358. // RegExp constructor can alter flags and IsRegExp works correct with @@match
  4359. return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i';
  4360. }))) {
  4361. $RegExp = function RegExp(p, f) {
  4362. var tiRE = this instanceof $RegExp;
  4363. var piRE = isRegExp(p);
  4364. var fiU = f === undefined;
  4365. return !tiRE && piRE && p.constructor === $RegExp && fiU ? p
  4366. : inheritIfRequired(CORRECT_NEW
  4367. ? new Base(piRE && !fiU ? p.source : p, f)
  4368. : Base((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? $flags.call(p) : f)
  4369. , tiRE ? this : proto, $RegExp);
  4370. };
  4371. var proxy = function (key) {
  4372. key in $RegExp || dP($RegExp, key, {
  4373. configurable: true,
  4374. get: function () { return Base[key]; },
  4375. set: function (it) { Base[key] = it; }
  4376. });
  4377. };
  4378. for (var keys = gOPN(Base), i = 0; keys.length > i;) proxy(keys[i++]);
  4379. proto.constructor = $RegExp;
  4380. $RegExp.prototype = proto;
  4381. _dereq_(94)(global, 'RegExp', $RegExp);
  4382. }
  4383. _dereq_(100)('RegExp');
  4384. },{"100":100,"128":128,"29":29,"35":35,"37":37,"40":40,"45":45,"52":52,"72":72,"77":77,"94":94}],225:[function(_dereq_,module,exports){
  4385. // 21.2.5.3 get RegExp.prototype.flags()
  4386. if (_dereq_(29) && /./g.flags != 'g') _dereq_(72).f(RegExp.prototype, 'flags', {
  4387. configurable: true,
  4388. get: _dereq_(37)
  4389. });
  4390. },{"29":29,"37":37,"72":72}],226:[function(_dereq_,module,exports){
  4391. // @@match logic
  4392. _dereq_(36)('match', 1, function (defined, MATCH, $match) {
  4393. // 21.1.3.11 String.prototype.match(regexp)
  4394. return [function match(regexp) {
  4395. 'use strict';
  4396. var O = defined(this);
  4397. var fn = regexp == undefined ? undefined : regexp[MATCH];
  4398. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  4399. }, $match];
  4400. });
  4401. },{"36":36}],227:[function(_dereq_,module,exports){
  4402. // @@replace logic
  4403. _dereq_(36)('replace', 2, function (defined, REPLACE, $replace) {
  4404. // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
  4405. return [function replace(searchValue, replaceValue) {
  4406. 'use strict';
  4407. var O = defined(this);
  4408. var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
  4409. return fn !== undefined
  4410. ? fn.call(searchValue, O, replaceValue)
  4411. : $replace.call(String(O), searchValue, replaceValue);
  4412. }, $replace];
  4413. });
  4414. },{"36":36}],228:[function(_dereq_,module,exports){
  4415. // @@search logic
  4416. _dereq_(36)('search', 1, function (defined, SEARCH, $search) {
  4417. // 21.1.3.15 String.prototype.search(regexp)
  4418. return [function search(regexp) {
  4419. 'use strict';
  4420. var O = defined(this);
  4421. var fn = regexp == undefined ? undefined : regexp[SEARCH];
  4422. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  4423. }, $search];
  4424. });
  4425. },{"36":36}],229:[function(_dereq_,module,exports){
  4426. // @@split logic
  4427. _dereq_(36)('split', 2, function (defined, SPLIT, $split) {
  4428. 'use strict';
  4429. var isRegExp = _dereq_(52);
  4430. var _split = $split;
  4431. var $push = [].push;
  4432. var $SPLIT = 'split';
  4433. var LENGTH = 'length';
  4434. var LAST_INDEX = 'lastIndex';
  4435. if (
  4436. 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
  4437. 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
  4438. 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
  4439. '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
  4440. '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
  4441. ''[$SPLIT](/.?/)[LENGTH]
  4442. ) {
  4443. var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
  4444. // based on es5-shim implementation, need to rework it
  4445. $split = function (separator, limit) {
  4446. var string = String(this);
  4447. if (separator === undefined && limit === 0) return [];
  4448. // If `separator` is not a regex, use native split
  4449. if (!isRegExp(separator)) return _split.call(string, separator, limit);
  4450. var output = [];
  4451. var flags = (separator.ignoreCase ? 'i' : '') +
  4452. (separator.multiline ? 'm' : '') +
  4453. (separator.unicode ? 'u' : '') +
  4454. (separator.sticky ? 'y' : '');
  4455. var lastLastIndex = 0;
  4456. var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
  4457. // Make `global` and avoid `lastIndex` issues by working with a copy
  4458. var separatorCopy = new RegExp(separator.source, flags + 'g');
  4459. var separator2, match, lastIndex, lastLength, i;
  4460. // Doesn't need flags gy, but they don't hurt
  4461. if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
  4462. while (match = separatorCopy.exec(string)) {
  4463. // `separatorCopy.lastIndex` is not reliable cross-browser
  4464. lastIndex = match.index + match[0][LENGTH];
  4465. if (lastIndex > lastLastIndex) {
  4466. output.push(string.slice(lastLastIndex, match.index));
  4467. // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
  4468. // eslint-disable-next-line no-loop-func
  4469. if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () {
  4470. for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined;
  4471. });
  4472. if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));
  4473. lastLength = match[0][LENGTH];
  4474. lastLastIndex = lastIndex;
  4475. if (output[LENGTH] >= splitLimit) break;
  4476. }
  4477. if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
  4478. }
  4479. if (lastLastIndex === string[LENGTH]) {
  4480. if (lastLength || !separatorCopy.test('')) output.push('');
  4481. } else output.push(string.slice(lastLastIndex));
  4482. return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
  4483. };
  4484. // Chakra, V8
  4485. } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {
  4486. $split = function (separator, limit) {
  4487. return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
  4488. };
  4489. }
  4490. // 21.1.3.17 String.prototype.split(separator, limit)
  4491. return [function split(separator, limit) {
  4492. var O = defined(this);
  4493. var fn = separator == undefined ? undefined : separator[SPLIT];
  4494. return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
  4495. }, $split];
  4496. });
  4497. },{"36":36,"52":52}],230:[function(_dereq_,module,exports){
  4498. 'use strict';
  4499. _dereq_(225);
  4500. var anObject = _dereq_(7);
  4501. var $flags = _dereq_(37);
  4502. var DESCRIPTORS = _dereq_(29);
  4503. var TO_STRING = 'toString';
  4504. var $toString = /./[TO_STRING];
  4505. var define = function (fn) {
  4506. _dereq_(94)(RegExp.prototype, TO_STRING, fn, true);
  4507. };
  4508. // 21.2.5.14 RegExp.prototype.toString()
  4509. if (_dereq_(35)(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) {
  4510. define(function toString() {
  4511. var R = anObject(this);
  4512. return '/'.concat(R.source, '/',
  4513. 'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined);
  4514. });
  4515. // FF44- RegExp#toString has a wrong name
  4516. } else if ($toString.name != TO_STRING) {
  4517. define(function toString() {
  4518. return $toString.call(this);
  4519. });
  4520. }
  4521. },{"225":225,"29":29,"35":35,"37":37,"7":7,"94":94}],231:[function(_dereq_,module,exports){
  4522. 'use strict';
  4523. var strong = _dereq_(19);
  4524. var validate = _dereq_(125);
  4525. var SET = 'Set';
  4526. // 23.2 Set Objects
  4527. module.exports = _dereq_(22)(SET, function (get) {
  4528. return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  4529. }, {
  4530. // 23.2.3.1 Set.prototype.add(value)
  4531. add: function add(value) {
  4532. return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);
  4533. }
  4534. }, strong);
  4535. },{"125":125,"19":19,"22":22}],232:[function(_dereq_,module,exports){
  4536. 'use strict';
  4537. // B.2.3.2 String.prototype.anchor(name)
  4538. _dereq_(108)('anchor', function (createHTML) {
  4539. return function anchor(name) {
  4540. return createHTML(this, 'a', 'name', name);
  4541. };
  4542. });
  4543. },{"108":108}],233:[function(_dereq_,module,exports){
  4544. 'use strict';
  4545. // B.2.3.3 String.prototype.big()
  4546. _dereq_(108)('big', function (createHTML) {
  4547. return function big() {
  4548. return createHTML(this, 'big', '', '');
  4549. };
  4550. });
  4551. },{"108":108}],234:[function(_dereq_,module,exports){
  4552. 'use strict';
  4553. // B.2.3.4 String.prototype.blink()
  4554. _dereq_(108)('blink', function (createHTML) {
  4555. return function blink() {
  4556. return createHTML(this, 'blink', '', '');
  4557. };
  4558. });
  4559. },{"108":108}],235:[function(_dereq_,module,exports){
  4560. 'use strict';
  4561. // B.2.3.5 String.prototype.bold()
  4562. _dereq_(108)('bold', function (createHTML) {
  4563. return function bold() {
  4564. return createHTML(this, 'b', '', '');
  4565. };
  4566. });
  4567. },{"108":108}],236:[function(_dereq_,module,exports){
  4568. 'use strict';
  4569. var $export = _dereq_(33);
  4570. var $at = _dereq_(106)(false);
  4571. $export($export.P, 'String', {
  4572. // 21.1.3.3 String.prototype.codePointAt(pos)
  4573. codePointAt: function codePointAt(pos) {
  4574. return $at(this, pos);
  4575. }
  4576. });
  4577. },{"106":106,"33":33}],237:[function(_dereq_,module,exports){
  4578. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  4579. 'use strict';
  4580. var $export = _dereq_(33);
  4581. var toLength = _dereq_(118);
  4582. var context = _dereq_(107);
  4583. var ENDS_WITH = 'endsWith';
  4584. var $endsWith = ''[ENDS_WITH];
  4585. $export($export.P + $export.F * _dereq_(34)(ENDS_WITH), 'String', {
  4586. endsWith: function endsWith(searchString /* , endPosition = @length */) {
  4587. var that = context(this, searchString, ENDS_WITH);
  4588. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  4589. var len = toLength(that.length);
  4590. var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  4591. var search = String(searchString);
  4592. return $endsWith
  4593. ? $endsWith.call(that, search, end)
  4594. : that.slice(end - search.length, end) === search;
  4595. }
  4596. });
  4597. },{"107":107,"118":118,"33":33,"34":34}],238:[function(_dereq_,module,exports){
  4598. 'use strict';
  4599. // B.2.3.6 String.prototype.fixed()
  4600. _dereq_(108)('fixed', function (createHTML) {
  4601. return function fixed() {
  4602. return createHTML(this, 'tt', '', '');
  4603. };
  4604. });
  4605. },{"108":108}],239:[function(_dereq_,module,exports){
  4606. 'use strict';
  4607. // B.2.3.7 String.prototype.fontcolor(color)
  4608. _dereq_(108)('fontcolor', function (createHTML) {
  4609. return function fontcolor(color) {
  4610. return createHTML(this, 'font', 'color', color);
  4611. };
  4612. });
  4613. },{"108":108}],240:[function(_dereq_,module,exports){
  4614. 'use strict';
  4615. // B.2.3.8 String.prototype.fontsize(size)
  4616. _dereq_(108)('fontsize', function (createHTML) {
  4617. return function fontsize(size) {
  4618. return createHTML(this, 'font', 'size', size);
  4619. };
  4620. });
  4621. },{"108":108}],241:[function(_dereq_,module,exports){
  4622. var $export = _dereq_(33);
  4623. var toAbsoluteIndex = _dereq_(114);
  4624. var fromCharCode = String.fromCharCode;
  4625. var $fromCodePoint = String.fromCodePoint;
  4626. // length should be 1, old FF problem
  4627. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  4628. // 21.1.2.2 String.fromCodePoint(...codePoints)
  4629. fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
  4630. var res = [];
  4631. var aLen = arguments.length;
  4632. var i = 0;
  4633. var code;
  4634. while (aLen > i) {
  4635. code = +arguments[i++];
  4636. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  4637. res.push(code < 0x10000
  4638. ? fromCharCode(code)
  4639. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  4640. );
  4641. } return res.join('');
  4642. }
  4643. });
  4644. },{"114":114,"33":33}],242:[function(_dereq_,module,exports){
  4645. // 21.1.3.7 String.prototype.includes(searchString, position = 0)
  4646. 'use strict';
  4647. var $export = _dereq_(33);
  4648. var context = _dereq_(107);
  4649. var INCLUDES = 'includes';
  4650. $export($export.P + $export.F * _dereq_(34)(INCLUDES), 'String', {
  4651. includes: function includes(searchString /* , position = 0 */) {
  4652. return !!~context(this, searchString, INCLUDES)
  4653. .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  4654. }
  4655. });
  4656. },{"107":107,"33":33,"34":34}],243:[function(_dereq_,module,exports){
  4657. 'use strict';
  4658. // B.2.3.9 String.prototype.italics()
  4659. _dereq_(108)('italics', function (createHTML) {
  4660. return function italics() {
  4661. return createHTML(this, 'i', '', '');
  4662. };
  4663. });
  4664. },{"108":108}],244:[function(_dereq_,module,exports){
  4665. 'use strict';
  4666. var $at = _dereq_(106)(true);
  4667. // 21.1.3.27 String.prototype[@@iterator]()
  4668. _dereq_(55)(String, 'String', function (iterated) {
  4669. this._t = String(iterated); // target
  4670. this._i = 0; // next index
  4671. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  4672. }, function () {
  4673. var O = this._t;
  4674. var index = this._i;
  4675. var point;
  4676. if (index >= O.length) return { value: undefined, done: true };
  4677. point = $at(O, index);
  4678. this._i += point.length;
  4679. return { value: point, done: false };
  4680. });
  4681. },{"106":106,"55":55}],245:[function(_dereq_,module,exports){
  4682. 'use strict';
  4683. // B.2.3.10 String.prototype.link(url)
  4684. _dereq_(108)('link', function (createHTML) {
  4685. return function link(url) {
  4686. return createHTML(this, 'a', 'href', url);
  4687. };
  4688. });
  4689. },{"108":108}],246:[function(_dereq_,module,exports){
  4690. var $export = _dereq_(33);
  4691. var toIObject = _dereq_(117);
  4692. var toLength = _dereq_(118);
  4693. $export($export.S, 'String', {
  4694. // 21.1.2.4 String.raw(callSite, ...substitutions)
  4695. raw: function raw(callSite) {
  4696. var tpl = toIObject(callSite.raw);
  4697. var len = toLength(tpl.length);
  4698. var aLen = arguments.length;
  4699. var res = [];
  4700. var i = 0;
  4701. while (len > i) {
  4702. res.push(String(tpl[i++]));
  4703. if (i < aLen) res.push(String(arguments[i]));
  4704. } return res.join('');
  4705. }
  4706. });
  4707. },{"117":117,"118":118,"33":33}],247:[function(_dereq_,module,exports){
  4708. var $export = _dereq_(33);
  4709. $export($export.P, 'String', {
  4710. // 21.1.3.13 String.prototype.repeat(count)
  4711. repeat: _dereq_(110)
  4712. });
  4713. },{"110":110,"33":33}],248:[function(_dereq_,module,exports){
  4714. 'use strict';
  4715. // B.2.3.11 String.prototype.small()
  4716. _dereq_(108)('small', function (createHTML) {
  4717. return function small() {
  4718. return createHTML(this, 'small', '', '');
  4719. };
  4720. });
  4721. },{"108":108}],249:[function(_dereq_,module,exports){
  4722. // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
  4723. 'use strict';
  4724. var $export = _dereq_(33);
  4725. var toLength = _dereq_(118);
  4726. var context = _dereq_(107);
  4727. var STARTS_WITH = 'startsWith';
  4728. var $startsWith = ''[STARTS_WITH];
  4729. $export($export.P + $export.F * _dereq_(34)(STARTS_WITH), 'String', {
  4730. startsWith: function startsWith(searchString /* , position = 0 */) {
  4731. var that = context(this, searchString, STARTS_WITH);
  4732. var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  4733. var search = String(searchString);
  4734. return $startsWith
  4735. ? $startsWith.call(that, search, index)
  4736. : that.slice(index, index + search.length) === search;
  4737. }
  4738. });
  4739. },{"107":107,"118":118,"33":33,"34":34}],250:[function(_dereq_,module,exports){
  4740. 'use strict';
  4741. // B.2.3.12 String.prototype.strike()
  4742. _dereq_(108)('strike', function (createHTML) {
  4743. return function strike() {
  4744. return createHTML(this, 'strike', '', '');
  4745. };
  4746. });
  4747. },{"108":108}],251:[function(_dereq_,module,exports){
  4748. 'use strict';
  4749. // B.2.3.13 String.prototype.sub()
  4750. _dereq_(108)('sub', function (createHTML) {
  4751. return function sub() {
  4752. return createHTML(this, 'sub', '', '');
  4753. };
  4754. });
  4755. },{"108":108}],252:[function(_dereq_,module,exports){
  4756. 'use strict';
  4757. // B.2.3.14 String.prototype.sup()
  4758. _dereq_(108)('sup', function (createHTML) {
  4759. return function sup() {
  4760. return createHTML(this, 'sup', '', '');
  4761. };
  4762. });
  4763. },{"108":108}],253:[function(_dereq_,module,exports){
  4764. 'use strict';
  4765. // 21.1.3.25 String.prototype.trim()
  4766. _dereq_(111)('trim', function ($trim) {
  4767. return function trim() {
  4768. return $trim(this, 3);
  4769. };
  4770. });
  4771. },{"111":111}],254:[function(_dereq_,module,exports){
  4772. 'use strict';
  4773. // ECMAScript 6 symbols shim
  4774. var global = _dereq_(40);
  4775. var has = _dereq_(41);
  4776. var DESCRIPTORS = _dereq_(29);
  4777. var $export = _dereq_(33);
  4778. var redefine = _dereq_(94);
  4779. var META = _dereq_(66).KEY;
  4780. var $fails = _dereq_(35);
  4781. var shared = _dereq_(103);
  4782. var setToStringTag = _dereq_(101);
  4783. var uid = _dereq_(124);
  4784. var wks = _dereq_(128);
  4785. var wksExt = _dereq_(127);
  4786. var wksDefine = _dereq_(126);
  4787. var keyOf = _dereq_(59);
  4788. var enumKeys = _dereq_(32);
  4789. var isArray = _dereq_(49);
  4790. var anObject = _dereq_(7);
  4791. var toIObject = _dereq_(117);
  4792. var toPrimitive = _dereq_(120);
  4793. var createDesc = _dereq_(92);
  4794. var _create = _dereq_(71);
  4795. var gOPNExt = _dereq_(76);
  4796. var $GOPD = _dereq_(75);
  4797. var $DP = _dereq_(72);
  4798. var $keys = _dereq_(81);
  4799. var gOPD = $GOPD.f;
  4800. var dP = $DP.f;
  4801. var gOPN = gOPNExt.f;
  4802. var $Symbol = global.Symbol;
  4803. var $JSON = global.JSON;
  4804. var _stringify = $JSON && $JSON.stringify;
  4805. var PROTOTYPE = 'prototype';
  4806. var HIDDEN = wks('_hidden');
  4807. var TO_PRIMITIVE = wks('toPrimitive');
  4808. var isEnum = {}.propertyIsEnumerable;
  4809. var SymbolRegistry = shared('symbol-registry');
  4810. var AllSymbols = shared('symbols');
  4811. var OPSymbols = shared('op-symbols');
  4812. var ObjectProto = Object[PROTOTYPE];
  4813. var USE_NATIVE = typeof $Symbol == 'function';
  4814. var QObject = global.QObject;
  4815. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  4816. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  4817. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  4818. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  4819. return _create(dP({}, 'a', {
  4820. get: function () { return dP(this, 'a', { value: 7 }).a; }
  4821. })).a != 7;
  4822. }) ? function (it, key, D) {
  4823. var protoDesc = gOPD(ObjectProto, key);
  4824. if (protoDesc) delete ObjectProto[key];
  4825. dP(it, key, D);
  4826. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  4827. } : dP;
  4828. var wrap = function (tag) {
  4829. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  4830. sym._k = tag;
  4831. return sym;
  4832. };
  4833. var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
  4834. return typeof it == 'symbol';
  4835. } : function (it) {
  4836. return it instanceof $Symbol;
  4837. };
  4838. var $defineProperty = function defineProperty(it, key, D) {
  4839. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  4840. anObject(it);
  4841. key = toPrimitive(key, true);
  4842. anObject(D);
  4843. if (has(AllSymbols, key)) {
  4844. if (!D.enumerable) {
  4845. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  4846. it[HIDDEN][key] = true;
  4847. } else {
  4848. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  4849. D = _create(D, { enumerable: createDesc(0, false) });
  4850. } return setSymbolDesc(it, key, D);
  4851. } return dP(it, key, D);
  4852. };
  4853. var $defineProperties = function defineProperties(it, P) {
  4854. anObject(it);
  4855. var keys = enumKeys(P = toIObject(P));
  4856. var i = 0;
  4857. var l = keys.length;
  4858. var key;
  4859. while (l > i) $defineProperty(it, key = keys[i++], P[key]);
  4860. return it;
  4861. };
  4862. var $create = function create(it, P) {
  4863. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  4864. };
  4865. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  4866. var E = isEnum.call(this, key = toPrimitive(key, true));
  4867. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  4868. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  4869. };
  4870. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  4871. it = toIObject(it);
  4872. key = toPrimitive(key, true);
  4873. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  4874. var D = gOPD(it, key);
  4875. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  4876. return D;
  4877. };
  4878. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  4879. var names = gOPN(toIObject(it));
  4880. var result = [];
  4881. var i = 0;
  4882. var key;
  4883. while (names.length > i) {
  4884. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  4885. } return result;
  4886. };
  4887. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  4888. var IS_OP = it === ObjectProto;
  4889. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  4890. var result = [];
  4891. var i = 0;
  4892. var key;
  4893. while (names.length > i) {
  4894. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  4895. } return result;
  4896. };
  4897. // 19.4.1.1 Symbol([description])
  4898. if (!USE_NATIVE) {
  4899. $Symbol = function Symbol() {
  4900. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  4901. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  4902. var $set = function (value) {
  4903. if (this === ObjectProto) $set.call(OPSymbols, value);
  4904. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  4905. setSymbolDesc(this, tag, createDesc(1, value));
  4906. };
  4907. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
  4908. return wrap(tag);
  4909. };
  4910. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  4911. return this._k;
  4912. });
  4913. $GOPD.f = $getOwnPropertyDescriptor;
  4914. $DP.f = $defineProperty;
  4915. _dereq_(77).f = gOPNExt.f = $getOwnPropertyNames;
  4916. _dereq_(82).f = $propertyIsEnumerable;
  4917. _dereq_(78).f = $getOwnPropertySymbols;
  4918. if (DESCRIPTORS && !_dereq_(60)) {
  4919. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  4920. }
  4921. wksExt.f = function (name) {
  4922. return wrap(wks(name));
  4923. };
  4924. }
  4925. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
  4926. for (var es6Symbols = (
  4927. // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
  4928. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  4929. ).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
  4930. for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
  4931. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  4932. // 19.4.2.1 Symbol.for(key)
  4933. 'for': function (key) {
  4934. return has(SymbolRegistry, key += '')
  4935. ? SymbolRegistry[key]
  4936. : SymbolRegistry[key] = $Symbol(key);
  4937. },
  4938. // 19.4.2.5 Symbol.keyFor(sym)
  4939. keyFor: function keyFor(key) {
  4940. if (isSymbol(key)) return keyOf(SymbolRegistry, key);
  4941. throw TypeError(key + ' is not a symbol!');
  4942. },
  4943. useSetter: function () { setter = true; },
  4944. useSimple: function () { setter = false; }
  4945. });
  4946. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  4947. // 19.1.2.2 Object.create(O [, Properties])
  4948. create: $create,
  4949. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  4950. defineProperty: $defineProperty,
  4951. // 19.1.2.3 Object.defineProperties(O, Properties)
  4952. defineProperties: $defineProperties,
  4953. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  4954. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  4955. // 19.1.2.7 Object.getOwnPropertyNames(O)
  4956. getOwnPropertyNames: $getOwnPropertyNames,
  4957. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  4958. getOwnPropertySymbols: $getOwnPropertySymbols
  4959. });
  4960. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  4961. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  4962. var S = $Symbol();
  4963. // MS Edge converts symbol values to JSON as {}
  4964. // WebKit converts symbol values to JSON as null
  4965. // V8 throws on boxed symbols
  4966. return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
  4967. })), 'JSON', {
  4968. stringify: function stringify(it) {
  4969. if (it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  4970. var args = [it];
  4971. var i = 1;
  4972. var replacer, $replacer;
  4973. while (arguments.length > i) args.push(arguments[i++]);
  4974. replacer = args[1];
  4975. if (typeof replacer == 'function') $replacer = replacer;
  4976. if ($replacer || !isArray(replacer)) replacer = function (key, value) {
  4977. if ($replacer) value = $replacer.call(this, key, value);
  4978. if (!isSymbol(value)) return value;
  4979. };
  4980. args[1] = replacer;
  4981. return _stringify.apply($JSON, args);
  4982. }
  4983. });
  4984. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  4985. $Symbol[PROTOTYPE][TO_PRIMITIVE] || _dereq_(42)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  4986. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  4987. setToStringTag($Symbol, 'Symbol');
  4988. // 20.2.1.9 Math[@@toStringTag]
  4989. setToStringTag(Math, 'Math', true);
  4990. // 24.3.3 JSON[@@toStringTag]
  4991. setToStringTag(global.JSON, 'JSON', true);
  4992. },{"101":101,"103":103,"117":117,"120":120,"124":124,"126":126,"127":127,"128":128,"29":29,"32":32,"33":33,"35":35,"40":40,"41":41,"42":42,"49":49,"59":59,"60":60,"66":66,"7":7,"71":71,"72":72,"75":75,"76":76,"77":77,"78":78,"81":81,"82":82,"92":92,"94":94}],255:[function(_dereq_,module,exports){
  4993. 'use strict';
  4994. var $export = _dereq_(33);
  4995. var $typed = _dereq_(123);
  4996. var buffer = _dereq_(122);
  4997. var anObject = _dereq_(7);
  4998. var toAbsoluteIndex = _dereq_(114);
  4999. var toLength = _dereq_(118);
  5000. var isObject = _dereq_(51);
  5001. var ArrayBuffer = _dereq_(40).ArrayBuffer;
  5002. var speciesConstructor = _dereq_(104);
  5003. var $ArrayBuffer = buffer.ArrayBuffer;
  5004. var $DataView = buffer.DataView;
  5005. var $isView = $typed.ABV && ArrayBuffer.isView;
  5006. var $slice = $ArrayBuffer.prototype.slice;
  5007. var VIEW = $typed.VIEW;
  5008. var ARRAY_BUFFER = 'ArrayBuffer';
  5009. $export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), { ArrayBuffer: $ArrayBuffer });
  5010. $export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, {
  5011. // 24.1.3.1 ArrayBuffer.isView(arg)
  5012. isView: function isView(it) {
  5013. return $isView && $isView(it) || isObject(it) && VIEW in it;
  5014. }
  5015. });
  5016. $export($export.P + $export.U + $export.F * _dereq_(35)(function () {
  5017. return !new $ArrayBuffer(2).slice(1, undefined).byteLength;
  5018. }), ARRAY_BUFFER, {
  5019. // 24.1.4.3 ArrayBuffer.prototype.slice(start, end)
  5020. slice: function slice(start, end) {
  5021. if ($slice !== undefined && end === undefined) return $slice.call(anObject(this), start); // FF fix
  5022. var len = anObject(this).byteLength;
  5023. var first = toAbsoluteIndex(start, len);
  5024. var final = toAbsoluteIndex(end === undefined ? len : end, len);
  5025. var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(final - first));
  5026. var viewS = new $DataView(this);
  5027. var viewT = new $DataView(result);
  5028. var index = 0;
  5029. while (first < final) {
  5030. viewT.setUint8(index++, viewS.getUint8(first++));
  5031. } return result;
  5032. }
  5033. });
  5034. _dereq_(100)(ARRAY_BUFFER);
  5035. },{"100":100,"104":104,"114":114,"118":118,"122":122,"123":123,"33":33,"35":35,"40":40,"51":51,"7":7}],256:[function(_dereq_,module,exports){
  5036. var $export = _dereq_(33);
  5037. $export($export.G + $export.W + $export.F * !_dereq_(123).ABV, {
  5038. DataView: _dereq_(122).DataView
  5039. });
  5040. },{"122":122,"123":123,"33":33}],257:[function(_dereq_,module,exports){
  5041. _dereq_(121)('Float32', 4, function (init) {
  5042. return function Float32Array(data, byteOffset, length) {
  5043. return init(this, data, byteOffset, length);
  5044. };
  5045. });
  5046. },{"121":121}],258:[function(_dereq_,module,exports){
  5047. _dereq_(121)('Float64', 8, function (init) {
  5048. return function Float64Array(data, byteOffset, length) {
  5049. return init(this, data, byteOffset, length);
  5050. };
  5051. });
  5052. },{"121":121}],259:[function(_dereq_,module,exports){
  5053. _dereq_(121)('Int16', 2, function (init) {
  5054. return function Int16Array(data, byteOffset, length) {
  5055. return init(this, data, byteOffset, length);
  5056. };
  5057. });
  5058. },{"121":121}],260:[function(_dereq_,module,exports){
  5059. _dereq_(121)('Int32', 4, function (init) {
  5060. return function Int32Array(data, byteOffset, length) {
  5061. return init(this, data, byteOffset, length);
  5062. };
  5063. });
  5064. },{"121":121}],261:[function(_dereq_,module,exports){
  5065. _dereq_(121)('Int8', 1, function (init) {
  5066. return function Int8Array(data, byteOffset, length) {
  5067. return init(this, data, byteOffset, length);
  5068. };
  5069. });
  5070. },{"121":121}],262:[function(_dereq_,module,exports){
  5071. _dereq_(121)('Uint16', 2, function (init) {
  5072. return function Uint16Array(data, byteOffset, length) {
  5073. return init(this, data, byteOffset, length);
  5074. };
  5075. });
  5076. },{"121":121}],263:[function(_dereq_,module,exports){
  5077. _dereq_(121)('Uint32', 4, function (init) {
  5078. return function Uint32Array(data, byteOffset, length) {
  5079. return init(this, data, byteOffset, length);
  5080. };
  5081. });
  5082. },{"121":121}],264:[function(_dereq_,module,exports){
  5083. _dereq_(121)('Uint8', 1, function (init) {
  5084. return function Uint8Array(data, byteOffset, length) {
  5085. return init(this, data, byteOffset, length);
  5086. };
  5087. });
  5088. },{"121":121}],265:[function(_dereq_,module,exports){
  5089. _dereq_(121)('Uint8', 1, function (init) {
  5090. return function Uint8ClampedArray(data, byteOffset, length) {
  5091. return init(this, data, byteOffset, length);
  5092. };
  5093. }, true);
  5094. },{"121":121}],266:[function(_dereq_,module,exports){
  5095. 'use strict';
  5096. var each = _dereq_(12)(0);
  5097. var redefine = _dereq_(94);
  5098. var meta = _dereq_(66);
  5099. var assign = _dereq_(70);
  5100. var weak = _dereq_(21);
  5101. var isObject = _dereq_(51);
  5102. var fails = _dereq_(35);
  5103. var validate = _dereq_(125);
  5104. var WEAK_MAP = 'WeakMap';
  5105. var getWeak = meta.getWeak;
  5106. var isExtensible = Object.isExtensible;
  5107. var uncaughtFrozenStore = weak.ufstore;
  5108. var tmp = {};
  5109. var InternalMap;
  5110. var wrapper = function (get) {
  5111. return function WeakMap() {
  5112. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  5113. };
  5114. };
  5115. var methods = {
  5116. // 23.3.3.3 WeakMap.prototype.get(key)
  5117. get: function get(key) {
  5118. if (isObject(key)) {
  5119. var data = getWeak(key);
  5120. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  5121. return data ? data[this._i] : undefined;
  5122. }
  5123. },
  5124. // 23.3.3.5 WeakMap.prototype.set(key, value)
  5125. set: function set(key, value) {
  5126. return weak.def(validate(this, WEAK_MAP), key, value);
  5127. }
  5128. };
  5129. // 23.3 WeakMap Objects
  5130. var $WeakMap = module.exports = _dereq_(22)(WEAK_MAP, wrapper, methods, weak, true, true);
  5131. // IE11 WeakMap frozen keys fix
  5132. if (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
  5133. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  5134. assign(InternalMap.prototype, methods);
  5135. meta.NEED = true;
  5136. each(['delete', 'has', 'get', 'set'], function (key) {
  5137. var proto = $WeakMap.prototype;
  5138. var method = proto[key];
  5139. redefine(proto, key, function (a, b) {
  5140. // store frozen objects on internal weakmap shim
  5141. if (isObject(a) && !isExtensible(a)) {
  5142. if (!this._f) this._f = new InternalMap();
  5143. var result = this._f[key](a, b);
  5144. return key == 'set' ? this : result;
  5145. // store all the rest on native weakmap
  5146. } return method.call(this, a, b);
  5147. });
  5148. });
  5149. }
  5150. },{"12":12,"125":125,"21":21,"22":22,"35":35,"51":51,"66":66,"70":70,"94":94}],267:[function(_dereq_,module,exports){
  5151. 'use strict';
  5152. var weak = _dereq_(21);
  5153. var validate = _dereq_(125);
  5154. var WEAK_SET = 'WeakSet';
  5155. // 23.4 WeakSet Objects
  5156. _dereq_(22)(WEAK_SET, function (get) {
  5157. return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  5158. }, {
  5159. // 23.4.3.1 WeakSet.prototype.add(value)
  5160. add: function add(value) {
  5161. return weak.def(validate(this, WEAK_SET), value, true);
  5162. }
  5163. }, weak, false, true);
  5164. },{"125":125,"21":21,"22":22}],268:[function(_dereq_,module,exports){
  5165. 'use strict';
  5166. // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap
  5167. var $export = _dereq_(33);
  5168. var flattenIntoArray = _dereq_(38);
  5169. var toObject = _dereq_(119);
  5170. var toLength = _dereq_(118);
  5171. var aFunction = _dereq_(3);
  5172. var arraySpeciesCreate = _dereq_(15);
  5173. $export($export.P, 'Array', {
  5174. flatMap: function flatMap(callbackfn /* , thisArg */) {
  5175. var O = toObject(this);
  5176. var sourceLen, A;
  5177. aFunction(callbackfn);
  5178. sourceLen = toLength(O.length);
  5179. A = arraySpeciesCreate(O, 0);
  5180. flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments[1]);
  5181. return A;
  5182. }
  5183. });
  5184. _dereq_(5)('flatMap');
  5185. },{"118":118,"119":119,"15":15,"3":3,"33":33,"38":38,"5":5}],269:[function(_dereq_,module,exports){
  5186. 'use strict';
  5187. // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatten
  5188. var $export = _dereq_(33);
  5189. var flattenIntoArray = _dereq_(38);
  5190. var toObject = _dereq_(119);
  5191. var toLength = _dereq_(118);
  5192. var toInteger = _dereq_(116);
  5193. var arraySpeciesCreate = _dereq_(15);
  5194. $export($export.P, 'Array', {
  5195. flatten: function flatten(/* depthArg = 1 */) {
  5196. var depthArg = arguments[0];
  5197. var O = toObject(this);
  5198. var sourceLen = toLength(O.length);
  5199. var A = arraySpeciesCreate(O, 0);
  5200. flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
  5201. return A;
  5202. }
  5203. });
  5204. _dereq_(5)('flatten');
  5205. },{"116":116,"118":118,"119":119,"15":15,"33":33,"38":38,"5":5}],270:[function(_dereq_,module,exports){
  5206. 'use strict';
  5207. // https://github.com/tc39/Array.prototype.includes
  5208. var $export = _dereq_(33);
  5209. var $includes = _dereq_(11)(true);
  5210. $export($export.P, 'Array', {
  5211. includes: function includes(el /* , fromIndex = 0 */) {
  5212. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  5213. }
  5214. });
  5215. _dereq_(5)('includes');
  5216. },{"11":11,"33":33,"5":5}],271:[function(_dereq_,module,exports){
  5217. // https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask
  5218. var $export = _dereq_(33);
  5219. var microtask = _dereq_(68)();
  5220. var process = _dereq_(40).process;
  5221. var isNode = _dereq_(18)(process) == 'process';
  5222. $export($export.G, {
  5223. asap: function asap(fn) {
  5224. var domain = isNode && process.domain;
  5225. microtask(domain ? domain.bind(fn) : fn);
  5226. }
  5227. });
  5228. },{"18":18,"33":33,"40":40,"68":68}],272:[function(_dereq_,module,exports){
  5229. // https://github.com/ljharb/proposal-is-error
  5230. var $export = _dereq_(33);
  5231. var cof = _dereq_(18);
  5232. $export($export.S, 'Error', {
  5233. isError: function isError(it) {
  5234. return cof(it) === 'Error';
  5235. }
  5236. });
  5237. },{"18":18,"33":33}],273:[function(_dereq_,module,exports){
  5238. // https://github.com/tc39/proposal-global
  5239. var $export = _dereq_(33);
  5240. $export($export.G, { global: _dereq_(40) });
  5241. },{"33":33,"40":40}],274:[function(_dereq_,module,exports){
  5242. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  5243. _dereq_(97)('Map');
  5244. },{"97":97}],275:[function(_dereq_,module,exports){
  5245. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  5246. _dereq_(98)('Map');
  5247. },{"98":98}],276:[function(_dereq_,module,exports){
  5248. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  5249. var $export = _dereq_(33);
  5250. $export($export.P + $export.R, 'Map', { toJSON: _dereq_(20)('Map') });
  5251. },{"20":20,"33":33}],277:[function(_dereq_,module,exports){
  5252. // https://rwaldron.github.io/proposal-math-extensions/
  5253. var $export = _dereq_(33);
  5254. $export($export.S, 'Math', {
  5255. clamp: function clamp(x, lower, upper) {
  5256. return Math.min(upper, Math.max(lower, x));
  5257. }
  5258. });
  5259. },{"33":33}],278:[function(_dereq_,module,exports){
  5260. // https://rwaldron.github.io/proposal-math-extensions/
  5261. var $export = _dereq_(33);
  5262. $export($export.S, 'Math', { DEG_PER_RAD: Math.PI / 180 });
  5263. },{"33":33}],279:[function(_dereq_,module,exports){
  5264. // https://rwaldron.github.io/proposal-math-extensions/
  5265. var $export = _dereq_(33);
  5266. var RAD_PER_DEG = 180 / Math.PI;
  5267. $export($export.S, 'Math', {
  5268. degrees: function degrees(radians) {
  5269. return radians * RAD_PER_DEG;
  5270. }
  5271. });
  5272. },{"33":33}],280:[function(_dereq_,module,exports){
  5273. // https://rwaldron.github.io/proposal-math-extensions/
  5274. var $export = _dereq_(33);
  5275. var scale = _dereq_(64);
  5276. var fround = _dereq_(62);
  5277. $export($export.S, 'Math', {
  5278. fscale: function fscale(x, inLow, inHigh, outLow, outHigh) {
  5279. return fround(scale(x, inLow, inHigh, outLow, outHigh));
  5280. }
  5281. });
  5282. },{"33":33,"62":62,"64":64}],281:[function(_dereq_,module,exports){
  5283. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  5284. var $export = _dereq_(33);
  5285. $export($export.S, 'Math', {
  5286. iaddh: function iaddh(x0, x1, y0, y1) {
  5287. var $x0 = x0 >>> 0;
  5288. var $x1 = x1 >>> 0;
  5289. var $y0 = y0 >>> 0;
  5290. return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0;
  5291. }
  5292. });
  5293. },{"33":33}],282:[function(_dereq_,module,exports){
  5294. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  5295. var $export = _dereq_(33);
  5296. $export($export.S, 'Math', {
  5297. imulh: function imulh(u, v) {
  5298. var UINT16 = 0xffff;
  5299. var $u = +u;
  5300. var $v = +v;
  5301. var u0 = $u & UINT16;
  5302. var v0 = $v & UINT16;
  5303. var u1 = $u >> 16;
  5304. var v1 = $v >> 16;
  5305. var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
  5306. return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16);
  5307. }
  5308. });
  5309. },{"33":33}],283:[function(_dereq_,module,exports){
  5310. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  5311. var $export = _dereq_(33);
  5312. $export($export.S, 'Math', {
  5313. isubh: function isubh(x0, x1, y0, y1) {
  5314. var $x0 = x0 >>> 0;
  5315. var $x1 = x1 >>> 0;
  5316. var $y0 = y0 >>> 0;
  5317. return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0;
  5318. }
  5319. });
  5320. },{"33":33}],284:[function(_dereq_,module,exports){
  5321. // https://rwaldron.github.io/proposal-math-extensions/
  5322. var $export = _dereq_(33);
  5323. $export($export.S, 'Math', { RAD_PER_DEG: 180 / Math.PI });
  5324. },{"33":33}],285:[function(_dereq_,module,exports){
  5325. // https://rwaldron.github.io/proposal-math-extensions/
  5326. var $export = _dereq_(33);
  5327. var DEG_PER_RAD = Math.PI / 180;
  5328. $export($export.S, 'Math', {
  5329. radians: function radians(degrees) {
  5330. return degrees * DEG_PER_RAD;
  5331. }
  5332. });
  5333. },{"33":33}],286:[function(_dereq_,module,exports){
  5334. // https://rwaldron.github.io/proposal-math-extensions/
  5335. var $export = _dereq_(33);
  5336. $export($export.S, 'Math', { scale: _dereq_(64) });
  5337. },{"33":33,"64":64}],287:[function(_dereq_,module,exports){
  5338. // http://jfbastien.github.io/papers/Math.signbit.html
  5339. var $export = _dereq_(33);
  5340. $export($export.S, 'Math', { signbit: function signbit(x) {
  5341. // eslint-disable-next-line no-self-compare
  5342. return (x = +x) != x ? x : x == 0 ? 1 / x == Infinity : x > 0;
  5343. } });
  5344. },{"33":33}],288:[function(_dereq_,module,exports){
  5345. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  5346. var $export = _dereq_(33);
  5347. $export($export.S, 'Math', {
  5348. umulh: function umulh(u, v) {
  5349. var UINT16 = 0xffff;
  5350. var $u = +u;
  5351. var $v = +v;
  5352. var u0 = $u & UINT16;
  5353. var v0 = $v & UINT16;
  5354. var u1 = $u >>> 16;
  5355. var v1 = $v >>> 16;
  5356. var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
  5357. return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16);
  5358. }
  5359. });
  5360. },{"33":33}],289:[function(_dereq_,module,exports){
  5361. 'use strict';
  5362. var $export = _dereq_(33);
  5363. var toObject = _dereq_(119);
  5364. var aFunction = _dereq_(3);
  5365. var $defineProperty = _dereq_(72);
  5366. // B.2.2.2 Object.prototype.__defineGetter__(P, getter)
  5367. _dereq_(29) && $export($export.P + _dereq_(74), 'Object', {
  5368. __defineGetter__: function __defineGetter__(P, getter) {
  5369. $defineProperty.f(toObject(this), P, { get: aFunction(getter), enumerable: true, configurable: true });
  5370. }
  5371. });
  5372. },{"119":119,"29":29,"3":3,"33":33,"72":72,"74":74}],290:[function(_dereq_,module,exports){
  5373. 'use strict';
  5374. var $export = _dereq_(33);
  5375. var toObject = _dereq_(119);
  5376. var aFunction = _dereq_(3);
  5377. var $defineProperty = _dereq_(72);
  5378. // B.2.2.3 Object.prototype.__defineSetter__(P, setter)
  5379. _dereq_(29) && $export($export.P + _dereq_(74), 'Object', {
  5380. __defineSetter__: function __defineSetter__(P, setter) {
  5381. $defineProperty.f(toObject(this), P, { set: aFunction(setter), enumerable: true, configurable: true });
  5382. }
  5383. });
  5384. },{"119":119,"29":29,"3":3,"33":33,"72":72,"74":74}],291:[function(_dereq_,module,exports){
  5385. // https://github.com/tc39/proposal-object-values-entries
  5386. var $export = _dereq_(33);
  5387. var $entries = _dereq_(84)(true);
  5388. $export($export.S, 'Object', {
  5389. entries: function entries(it) {
  5390. return $entries(it);
  5391. }
  5392. });
  5393. },{"33":33,"84":84}],292:[function(_dereq_,module,exports){
  5394. // https://github.com/tc39/proposal-object-getownpropertydescriptors
  5395. var $export = _dereq_(33);
  5396. var ownKeys = _dereq_(85);
  5397. var toIObject = _dereq_(117);
  5398. var gOPD = _dereq_(75);
  5399. var createProperty = _dereq_(24);
  5400. $export($export.S, 'Object', {
  5401. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  5402. var O = toIObject(object);
  5403. var getDesc = gOPD.f;
  5404. var keys = ownKeys(O);
  5405. var result = {};
  5406. var i = 0;
  5407. var key, desc;
  5408. while (keys.length > i) {
  5409. desc = getDesc(O, key = keys[i++]);
  5410. if (desc !== undefined) createProperty(result, key, desc);
  5411. }
  5412. return result;
  5413. }
  5414. });
  5415. },{"117":117,"24":24,"33":33,"75":75,"85":85}],293:[function(_dereq_,module,exports){
  5416. 'use strict';
  5417. var $export = _dereq_(33);
  5418. var toObject = _dereq_(119);
  5419. var toPrimitive = _dereq_(120);
  5420. var getPrototypeOf = _dereq_(79);
  5421. var getOwnPropertyDescriptor = _dereq_(75).f;
  5422. // B.2.2.4 Object.prototype.__lookupGetter__(P)
  5423. _dereq_(29) && $export($export.P + _dereq_(74), 'Object', {
  5424. __lookupGetter__: function __lookupGetter__(P) {
  5425. var O = toObject(this);
  5426. var K = toPrimitive(P, true);
  5427. var D;
  5428. do {
  5429. if (D = getOwnPropertyDescriptor(O, K)) return D.get;
  5430. } while (O = getPrototypeOf(O));
  5431. }
  5432. });
  5433. },{"119":119,"120":120,"29":29,"33":33,"74":74,"75":75,"79":79}],294:[function(_dereq_,module,exports){
  5434. 'use strict';
  5435. var $export = _dereq_(33);
  5436. var toObject = _dereq_(119);
  5437. var toPrimitive = _dereq_(120);
  5438. var getPrototypeOf = _dereq_(79);
  5439. var getOwnPropertyDescriptor = _dereq_(75).f;
  5440. // B.2.2.5 Object.prototype.__lookupSetter__(P)
  5441. _dereq_(29) && $export($export.P + _dereq_(74), 'Object', {
  5442. __lookupSetter__: function __lookupSetter__(P) {
  5443. var O = toObject(this);
  5444. var K = toPrimitive(P, true);
  5445. var D;
  5446. do {
  5447. if (D = getOwnPropertyDescriptor(O, K)) return D.set;
  5448. } while (O = getPrototypeOf(O));
  5449. }
  5450. });
  5451. },{"119":119,"120":120,"29":29,"33":33,"74":74,"75":75,"79":79}],295:[function(_dereq_,module,exports){
  5452. // https://github.com/tc39/proposal-object-values-entries
  5453. var $export = _dereq_(33);
  5454. var $values = _dereq_(84)(false);
  5455. $export($export.S, 'Object', {
  5456. values: function values(it) {
  5457. return $values(it);
  5458. }
  5459. });
  5460. },{"33":33,"84":84}],296:[function(_dereq_,module,exports){
  5461. 'use strict';
  5462. // https://github.com/zenparsing/es-observable
  5463. var $export = _dereq_(33);
  5464. var global = _dereq_(40);
  5465. var core = _dereq_(23);
  5466. var microtask = _dereq_(68)();
  5467. var OBSERVABLE = _dereq_(128)('observable');
  5468. var aFunction = _dereq_(3);
  5469. var anObject = _dereq_(7);
  5470. var anInstance = _dereq_(6);
  5471. var redefineAll = _dereq_(93);
  5472. var hide = _dereq_(42);
  5473. var forOf = _dereq_(39);
  5474. var RETURN = forOf.RETURN;
  5475. var getMethod = function (fn) {
  5476. return fn == null ? undefined : aFunction(fn);
  5477. };
  5478. var cleanupSubscription = function (subscription) {
  5479. var cleanup = subscription._c;
  5480. if (cleanup) {
  5481. subscription._c = undefined;
  5482. cleanup();
  5483. }
  5484. };
  5485. var subscriptionClosed = function (subscription) {
  5486. return subscription._o === undefined;
  5487. };
  5488. var closeSubscription = function (subscription) {
  5489. if (!subscriptionClosed(subscription)) {
  5490. subscription._o = undefined;
  5491. cleanupSubscription(subscription);
  5492. }
  5493. };
  5494. var Subscription = function (observer, subscriber) {
  5495. anObject(observer);
  5496. this._c = undefined;
  5497. this._o = observer;
  5498. observer = new SubscriptionObserver(this);
  5499. try {
  5500. var cleanup = subscriber(observer);
  5501. var subscription = cleanup;
  5502. if (cleanup != null) {
  5503. if (typeof cleanup.unsubscribe === 'function') cleanup = function () { subscription.unsubscribe(); };
  5504. else aFunction(cleanup);
  5505. this._c = cleanup;
  5506. }
  5507. } catch (e) {
  5508. observer.error(e);
  5509. return;
  5510. } if (subscriptionClosed(this)) cleanupSubscription(this);
  5511. };
  5512. Subscription.prototype = redefineAll({}, {
  5513. unsubscribe: function unsubscribe() { closeSubscription(this); }
  5514. });
  5515. var SubscriptionObserver = function (subscription) {
  5516. this._s = subscription;
  5517. };
  5518. SubscriptionObserver.prototype = redefineAll({}, {
  5519. next: function next(value) {
  5520. var subscription = this._s;
  5521. if (!subscriptionClosed(subscription)) {
  5522. var observer = subscription._o;
  5523. try {
  5524. var m = getMethod(observer.next);
  5525. if (m) return m.call(observer, value);
  5526. } catch (e) {
  5527. try {
  5528. closeSubscription(subscription);
  5529. } finally {
  5530. throw e;
  5531. }
  5532. }
  5533. }
  5534. },
  5535. error: function error(value) {
  5536. var subscription = this._s;
  5537. if (subscriptionClosed(subscription)) throw value;
  5538. var observer = subscription._o;
  5539. subscription._o = undefined;
  5540. try {
  5541. var m = getMethod(observer.error);
  5542. if (!m) throw value;
  5543. value = m.call(observer, value);
  5544. } catch (e) {
  5545. try {
  5546. cleanupSubscription(subscription);
  5547. } finally {
  5548. throw e;
  5549. }
  5550. } cleanupSubscription(subscription);
  5551. return value;
  5552. },
  5553. complete: function complete(value) {
  5554. var subscription = this._s;
  5555. if (!subscriptionClosed(subscription)) {
  5556. var observer = subscription._o;
  5557. subscription._o = undefined;
  5558. try {
  5559. var m = getMethod(observer.complete);
  5560. value = m ? m.call(observer, value) : undefined;
  5561. } catch (e) {
  5562. try {
  5563. cleanupSubscription(subscription);
  5564. } finally {
  5565. throw e;
  5566. }
  5567. } cleanupSubscription(subscription);
  5568. return value;
  5569. }
  5570. }
  5571. });
  5572. var $Observable = function Observable(subscriber) {
  5573. anInstance(this, $Observable, 'Observable', '_f')._f = aFunction(subscriber);
  5574. };
  5575. redefineAll($Observable.prototype, {
  5576. subscribe: function subscribe(observer) {
  5577. return new Subscription(observer, this._f);
  5578. },
  5579. forEach: function forEach(fn) {
  5580. var that = this;
  5581. return new (core.Promise || global.Promise)(function (resolve, reject) {
  5582. aFunction(fn);
  5583. var subscription = that.subscribe({
  5584. next: function (value) {
  5585. try {
  5586. return fn(value);
  5587. } catch (e) {
  5588. reject(e);
  5589. subscription.unsubscribe();
  5590. }
  5591. },
  5592. error: reject,
  5593. complete: resolve
  5594. });
  5595. });
  5596. }
  5597. });
  5598. redefineAll($Observable, {
  5599. from: function from(x) {
  5600. var C = typeof this === 'function' ? this : $Observable;
  5601. var method = getMethod(anObject(x)[OBSERVABLE]);
  5602. if (method) {
  5603. var observable = anObject(method.call(x));
  5604. return observable.constructor === C ? observable : new C(function (observer) {
  5605. return observable.subscribe(observer);
  5606. });
  5607. }
  5608. return new C(function (observer) {
  5609. var done = false;
  5610. microtask(function () {
  5611. if (!done) {
  5612. try {
  5613. if (forOf(x, false, function (it) {
  5614. observer.next(it);
  5615. if (done) return RETURN;
  5616. }) === RETURN) return;
  5617. } catch (e) {
  5618. if (done) throw e;
  5619. observer.error(e);
  5620. return;
  5621. } observer.complete();
  5622. }
  5623. });
  5624. return function () { done = true; };
  5625. });
  5626. },
  5627. of: function of() {
  5628. for (var i = 0, l = arguments.length, items = Array(l); i < l;) items[i] = arguments[i++];
  5629. return new (typeof this === 'function' ? this : $Observable)(function (observer) {
  5630. var done = false;
  5631. microtask(function () {
  5632. if (!done) {
  5633. for (var j = 0; j < items.length; ++j) {
  5634. observer.next(items[j]);
  5635. if (done) return;
  5636. } observer.complete();
  5637. }
  5638. });
  5639. return function () { done = true; };
  5640. });
  5641. }
  5642. });
  5643. hide($Observable.prototype, OBSERVABLE, function () { return this; });
  5644. $export($export.G, { Observable: $Observable });
  5645. _dereq_(100)('Observable');
  5646. },{"100":100,"128":128,"23":23,"3":3,"33":33,"39":39,"40":40,"42":42,"6":6,"68":68,"7":7,"93":93}],297:[function(_dereq_,module,exports){
  5647. // https://github.com/tc39/proposal-promise-finally
  5648. 'use strict';
  5649. var $export = _dereq_(33);
  5650. var core = _dereq_(23);
  5651. var global = _dereq_(40);
  5652. var speciesConstructor = _dereq_(104);
  5653. var promiseResolve = _dereq_(91);
  5654. $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
  5655. var C = speciesConstructor(this, core.Promise || global.Promise);
  5656. var isFunction = typeof onFinally == 'function';
  5657. return this.then(
  5658. isFunction ? function (x) {
  5659. return promiseResolve(C, onFinally()).then(function () { return x; });
  5660. } : onFinally,
  5661. isFunction ? function (e) {
  5662. return promiseResolve(C, onFinally()).then(function () { throw e; });
  5663. } : onFinally
  5664. );
  5665. } });
  5666. },{"104":104,"23":23,"33":33,"40":40,"91":91}],298:[function(_dereq_,module,exports){
  5667. 'use strict';
  5668. // https://github.com/tc39/proposal-promise-try
  5669. var $export = _dereq_(33);
  5670. var newPromiseCapability = _dereq_(69);
  5671. var perform = _dereq_(90);
  5672. $export($export.S, 'Promise', { 'try': function (callbackfn) {
  5673. var promiseCapability = newPromiseCapability.f(this);
  5674. var result = perform(callbackfn);
  5675. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  5676. return promiseCapability.promise;
  5677. } });
  5678. },{"33":33,"69":69,"90":90}],299:[function(_dereq_,module,exports){
  5679. var metadata = _dereq_(67);
  5680. var anObject = _dereq_(7);
  5681. var toMetaKey = metadata.key;
  5682. var ordinaryDefineOwnMetadata = metadata.set;
  5683. metadata.exp({ defineMetadata: function defineMetadata(metadataKey, metadataValue, target, targetKey) {
  5684. ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetaKey(targetKey));
  5685. } });
  5686. },{"67":67,"7":7}],300:[function(_dereq_,module,exports){
  5687. var metadata = _dereq_(67);
  5688. var anObject = _dereq_(7);
  5689. var toMetaKey = metadata.key;
  5690. var getOrCreateMetadataMap = metadata.map;
  5691. var store = metadata.store;
  5692. metadata.exp({ deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) {
  5693. var targetKey = arguments.length < 3 ? undefined : toMetaKey(arguments[2]);
  5694. var metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false);
  5695. if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false;
  5696. if (metadataMap.size) return true;
  5697. var targetMetadata = store.get(target);
  5698. targetMetadata['delete'](targetKey);
  5699. return !!targetMetadata.size || store['delete'](target);
  5700. } });
  5701. },{"67":67,"7":7}],301:[function(_dereq_,module,exports){
  5702. var Set = _dereq_(231);
  5703. var from = _dereq_(10);
  5704. var metadata = _dereq_(67);
  5705. var anObject = _dereq_(7);
  5706. var getPrototypeOf = _dereq_(79);
  5707. var ordinaryOwnMetadataKeys = metadata.keys;
  5708. var toMetaKey = metadata.key;
  5709. var ordinaryMetadataKeys = function (O, P) {
  5710. var oKeys = ordinaryOwnMetadataKeys(O, P);
  5711. var parent = getPrototypeOf(O);
  5712. if (parent === null) return oKeys;
  5713. var pKeys = ordinaryMetadataKeys(parent, P);
  5714. return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;
  5715. };
  5716. metadata.exp({ getMetadataKeys: function getMetadataKeys(target /* , targetKey */) {
  5717. return ordinaryMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
  5718. } });
  5719. },{"10":10,"231":231,"67":67,"7":7,"79":79}],302:[function(_dereq_,module,exports){
  5720. var metadata = _dereq_(67);
  5721. var anObject = _dereq_(7);
  5722. var getPrototypeOf = _dereq_(79);
  5723. var ordinaryHasOwnMetadata = metadata.has;
  5724. var ordinaryGetOwnMetadata = metadata.get;
  5725. var toMetaKey = metadata.key;
  5726. var ordinaryGetMetadata = function (MetadataKey, O, P) {
  5727. var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
  5728. if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P);
  5729. var parent = getPrototypeOf(O);
  5730. return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
  5731. };
  5732. metadata.exp({ getMetadata: function getMetadata(metadataKey, target /* , targetKey */) {
  5733. return ordinaryGetMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  5734. } });
  5735. },{"67":67,"7":7,"79":79}],303:[function(_dereq_,module,exports){
  5736. var metadata = _dereq_(67);
  5737. var anObject = _dereq_(7);
  5738. var ordinaryOwnMetadataKeys = metadata.keys;
  5739. var toMetaKey = metadata.key;
  5740. metadata.exp({ getOwnMetadataKeys: function getOwnMetadataKeys(target /* , targetKey */) {
  5741. return ordinaryOwnMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
  5742. } });
  5743. },{"67":67,"7":7}],304:[function(_dereq_,module,exports){
  5744. var metadata = _dereq_(67);
  5745. var anObject = _dereq_(7);
  5746. var ordinaryGetOwnMetadata = metadata.get;
  5747. var toMetaKey = metadata.key;
  5748. metadata.exp({ getOwnMetadata: function getOwnMetadata(metadataKey, target /* , targetKey */) {
  5749. return ordinaryGetOwnMetadata(metadataKey, anObject(target)
  5750. , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  5751. } });
  5752. },{"67":67,"7":7}],305:[function(_dereq_,module,exports){
  5753. var metadata = _dereq_(67);
  5754. var anObject = _dereq_(7);
  5755. var getPrototypeOf = _dereq_(79);
  5756. var ordinaryHasOwnMetadata = metadata.has;
  5757. var toMetaKey = metadata.key;
  5758. var ordinaryHasMetadata = function (MetadataKey, O, P) {
  5759. var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
  5760. if (hasOwn) return true;
  5761. var parent = getPrototypeOf(O);
  5762. return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false;
  5763. };
  5764. metadata.exp({ hasMetadata: function hasMetadata(metadataKey, target /* , targetKey */) {
  5765. return ordinaryHasMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  5766. } });
  5767. },{"67":67,"7":7,"79":79}],306:[function(_dereq_,module,exports){
  5768. var metadata = _dereq_(67);
  5769. var anObject = _dereq_(7);
  5770. var ordinaryHasOwnMetadata = metadata.has;
  5771. var toMetaKey = metadata.key;
  5772. metadata.exp({ hasOwnMetadata: function hasOwnMetadata(metadataKey, target /* , targetKey */) {
  5773. return ordinaryHasOwnMetadata(metadataKey, anObject(target)
  5774. , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  5775. } });
  5776. },{"67":67,"7":7}],307:[function(_dereq_,module,exports){
  5777. var $metadata = _dereq_(67);
  5778. var anObject = _dereq_(7);
  5779. var aFunction = _dereq_(3);
  5780. var toMetaKey = $metadata.key;
  5781. var ordinaryDefineOwnMetadata = $metadata.set;
  5782. $metadata.exp({ metadata: function metadata(metadataKey, metadataValue) {
  5783. return function decorator(target, targetKey) {
  5784. ordinaryDefineOwnMetadata(
  5785. metadataKey, metadataValue,
  5786. (targetKey !== undefined ? anObject : aFunction)(target),
  5787. toMetaKey(targetKey)
  5788. );
  5789. };
  5790. } });
  5791. },{"3":3,"67":67,"7":7}],308:[function(_dereq_,module,exports){
  5792. // https://tc39.github.io/proposal-setmap-offrom/#sec-set.from
  5793. _dereq_(97)('Set');
  5794. },{"97":97}],309:[function(_dereq_,module,exports){
  5795. // https://tc39.github.io/proposal-setmap-offrom/#sec-set.of
  5796. _dereq_(98)('Set');
  5797. },{"98":98}],310:[function(_dereq_,module,exports){
  5798. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  5799. var $export = _dereq_(33);
  5800. $export($export.P + $export.R, 'Set', { toJSON: _dereq_(20)('Set') });
  5801. },{"20":20,"33":33}],311:[function(_dereq_,module,exports){
  5802. 'use strict';
  5803. // https://github.com/mathiasbynens/String.prototype.at
  5804. var $export = _dereq_(33);
  5805. var $at = _dereq_(106)(true);
  5806. $export($export.P, 'String', {
  5807. at: function at(pos) {
  5808. return $at(this, pos);
  5809. }
  5810. });
  5811. },{"106":106,"33":33}],312:[function(_dereq_,module,exports){
  5812. 'use strict';
  5813. // https://tc39.github.io/String.prototype.matchAll/
  5814. var $export = _dereq_(33);
  5815. var defined = _dereq_(28);
  5816. var toLength = _dereq_(118);
  5817. var isRegExp = _dereq_(52);
  5818. var getFlags = _dereq_(37);
  5819. var RegExpProto = RegExp.prototype;
  5820. var $RegExpStringIterator = function (regexp, string) {
  5821. this._r = regexp;
  5822. this._s = string;
  5823. };
  5824. _dereq_(54)($RegExpStringIterator, 'RegExp String', function next() {
  5825. var match = this._r.exec(this._s);
  5826. return { value: match, done: match === null };
  5827. });
  5828. $export($export.P, 'String', {
  5829. matchAll: function matchAll(regexp) {
  5830. defined(this);
  5831. if (!isRegExp(regexp)) throw TypeError(regexp + ' is not a regexp!');
  5832. var S = String(this);
  5833. var flags = 'flags' in RegExpProto ? String(regexp.flags) : getFlags.call(regexp);
  5834. var rx = new RegExp(regexp.source, ~flags.indexOf('g') ? flags : 'g' + flags);
  5835. rx.lastIndex = toLength(regexp.lastIndex);
  5836. return new $RegExpStringIterator(rx, S);
  5837. }
  5838. });
  5839. },{"118":118,"28":28,"33":33,"37":37,"52":52,"54":54}],313:[function(_dereq_,module,exports){
  5840. 'use strict';
  5841. // https://github.com/tc39/proposal-string-pad-start-end
  5842. var $export = _dereq_(33);
  5843. var $pad = _dereq_(109);
  5844. $export($export.P, 'String', {
  5845. padEnd: function padEnd(maxLength /* , fillString = ' ' */) {
  5846. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  5847. }
  5848. });
  5849. },{"109":109,"33":33}],314:[function(_dereq_,module,exports){
  5850. 'use strict';
  5851. // https://github.com/tc39/proposal-string-pad-start-end
  5852. var $export = _dereq_(33);
  5853. var $pad = _dereq_(109);
  5854. $export($export.P, 'String', {
  5855. padStart: function padStart(maxLength /* , fillString = ' ' */) {
  5856. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  5857. }
  5858. });
  5859. },{"109":109,"33":33}],315:[function(_dereq_,module,exports){
  5860. 'use strict';
  5861. // https://github.com/sebmarkbage/ecmascript-string-left-right-trim
  5862. _dereq_(111)('trimLeft', function ($trim) {
  5863. return function trimLeft() {
  5864. return $trim(this, 1);
  5865. };
  5866. }, 'trimStart');
  5867. },{"111":111}],316:[function(_dereq_,module,exports){
  5868. 'use strict';
  5869. // https://github.com/sebmarkbage/ecmascript-string-left-right-trim
  5870. _dereq_(111)('trimRight', function ($trim) {
  5871. return function trimRight() {
  5872. return $trim(this, 2);
  5873. };
  5874. }, 'trimEnd');
  5875. },{"111":111}],317:[function(_dereq_,module,exports){
  5876. _dereq_(126)('asyncIterator');
  5877. },{"126":126}],318:[function(_dereq_,module,exports){
  5878. _dereq_(126)('observable');
  5879. },{"126":126}],319:[function(_dereq_,module,exports){
  5880. // https://github.com/tc39/proposal-global
  5881. var $export = _dereq_(33);
  5882. $export($export.S, 'System', { global: _dereq_(40) });
  5883. },{"33":33,"40":40}],320:[function(_dereq_,module,exports){
  5884. // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from
  5885. _dereq_(97)('WeakMap');
  5886. },{"97":97}],321:[function(_dereq_,module,exports){
  5887. // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of
  5888. _dereq_(98)('WeakMap');
  5889. },{"98":98}],322:[function(_dereq_,module,exports){
  5890. // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from
  5891. _dereq_(97)('WeakSet');
  5892. },{"97":97}],323:[function(_dereq_,module,exports){
  5893. // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of
  5894. _dereq_(98)('WeakSet');
  5895. },{"98":98}],324:[function(_dereq_,module,exports){
  5896. var $iterators = _dereq_(141);
  5897. var getKeys = _dereq_(81);
  5898. var redefine = _dereq_(94);
  5899. var global = _dereq_(40);
  5900. var hide = _dereq_(42);
  5901. var Iterators = _dereq_(58);
  5902. var wks = _dereq_(128);
  5903. var ITERATOR = wks('iterator');
  5904. var TO_STRING_TAG = wks('toStringTag');
  5905. var ArrayValues = Iterators.Array;
  5906. var DOMIterables = {
  5907. CSSRuleList: true, // TODO: Not spec compliant, should be false.
  5908. CSSStyleDeclaration: false,
  5909. CSSValueList: false,
  5910. ClientRectList: false,
  5911. DOMRectList: false,
  5912. DOMStringList: false,
  5913. DOMTokenList: true,
  5914. DataTransferItemList: false,
  5915. FileList: false,
  5916. HTMLAllCollection: false,
  5917. HTMLCollection: false,
  5918. HTMLFormElement: false,
  5919. HTMLSelectElement: false,
  5920. MediaList: true, // TODO: Not spec compliant, should be false.
  5921. MimeTypeArray: false,
  5922. NamedNodeMap: false,
  5923. NodeList: true,
  5924. PaintRequestList: false,
  5925. Plugin: false,
  5926. PluginArray: false,
  5927. SVGLengthList: false,
  5928. SVGNumberList: false,
  5929. SVGPathSegList: false,
  5930. SVGPointList: false,
  5931. SVGStringList: false,
  5932. SVGTransformList: false,
  5933. SourceBufferList: false,
  5934. StyleSheetList: true, // TODO: Not spec compliant, should be false.
  5935. TextTrackCueList: false,
  5936. TextTrackList: false,
  5937. TouchList: false
  5938. };
  5939. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  5940. var NAME = collections[i];
  5941. var explicit = DOMIterables[NAME];
  5942. var Collection = global[NAME];
  5943. var proto = Collection && Collection.prototype;
  5944. var key;
  5945. if (proto) {
  5946. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  5947. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  5948. Iterators[NAME] = ArrayValues;
  5949. if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);
  5950. }
  5951. }
  5952. },{"128":128,"141":141,"40":40,"42":42,"58":58,"81":81,"94":94}],325:[function(_dereq_,module,exports){
  5953. var $export = _dereq_(33);
  5954. var $task = _dereq_(113);
  5955. $export($export.G + $export.B, {
  5956. setImmediate: $task.set,
  5957. clearImmediate: $task.clear
  5958. });
  5959. },{"113":113,"33":33}],326:[function(_dereq_,module,exports){
  5960. // ie9- setTimeout & setInterval additional parameters fix
  5961. var global = _dereq_(40);
  5962. var $export = _dereq_(33);
  5963. var invoke = _dereq_(46);
  5964. var partial = _dereq_(88);
  5965. var navigator = global.navigator;
  5966. var MSIE = !!navigator && /MSIE .\./.test(navigator.userAgent); // <- dirty ie9- check
  5967. var wrap = function (set) {
  5968. return MSIE ? function (fn, time /* , ...args */) {
  5969. return set(invoke(
  5970. partial,
  5971. [].slice.call(arguments, 2),
  5972. // eslint-disable-next-line no-new-func
  5973. typeof fn == 'function' ? fn : Function(fn)
  5974. ), time);
  5975. } : set;
  5976. };
  5977. $export($export.G + $export.B + $export.F * MSIE, {
  5978. setTimeout: wrap(global.setTimeout),
  5979. setInterval: wrap(global.setInterval)
  5980. });
  5981. },{"33":33,"40":40,"46":46,"88":88}],327:[function(_dereq_,module,exports){
  5982. _dereq_(254);
  5983. _dereq_(191);
  5984. _dereq_(193);
  5985. _dereq_(192);
  5986. _dereq_(195);
  5987. _dereq_(197);
  5988. _dereq_(202);
  5989. _dereq_(196);
  5990. _dereq_(194);
  5991. _dereq_(204);
  5992. _dereq_(203);
  5993. _dereq_(199);
  5994. _dereq_(200);
  5995. _dereq_(198);
  5996. _dereq_(190);
  5997. _dereq_(201);
  5998. _dereq_(205);
  5999. _dereq_(206);
  6000. _dereq_(157);
  6001. _dereq_(159);
  6002. _dereq_(158);
  6003. _dereq_(208);
  6004. _dereq_(207);
  6005. _dereq_(178);
  6006. _dereq_(188);
  6007. _dereq_(189);
  6008. _dereq_(179);
  6009. _dereq_(180);
  6010. _dereq_(181);
  6011. _dereq_(182);
  6012. _dereq_(183);
  6013. _dereq_(184);
  6014. _dereq_(185);
  6015. _dereq_(186);
  6016. _dereq_(187);
  6017. _dereq_(161);
  6018. _dereq_(162);
  6019. _dereq_(163);
  6020. _dereq_(164);
  6021. _dereq_(165);
  6022. _dereq_(166);
  6023. _dereq_(167);
  6024. _dereq_(168);
  6025. _dereq_(169);
  6026. _dereq_(170);
  6027. _dereq_(171);
  6028. _dereq_(172);
  6029. _dereq_(173);
  6030. _dereq_(174);
  6031. _dereq_(175);
  6032. _dereq_(176);
  6033. _dereq_(177);
  6034. _dereq_(241);
  6035. _dereq_(246);
  6036. _dereq_(253);
  6037. _dereq_(244);
  6038. _dereq_(236);
  6039. _dereq_(237);
  6040. _dereq_(242);
  6041. _dereq_(247);
  6042. _dereq_(249);
  6043. _dereq_(232);
  6044. _dereq_(233);
  6045. _dereq_(234);
  6046. _dereq_(235);
  6047. _dereq_(238);
  6048. _dereq_(239);
  6049. _dereq_(240);
  6050. _dereq_(243);
  6051. _dereq_(245);
  6052. _dereq_(248);
  6053. _dereq_(250);
  6054. _dereq_(251);
  6055. _dereq_(252);
  6056. _dereq_(152);
  6057. _dereq_(154);
  6058. _dereq_(153);
  6059. _dereq_(156);
  6060. _dereq_(155);
  6061. _dereq_(140);
  6062. _dereq_(138);
  6063. _dereq_(145);
  6064. _dereq_(142);
  6065. _dereq_(148);
  6066. _dereq_(150);
  6067. _dereq_(137);
  6068. _dereq_(144);
  6069. _dereq_(134);
  6070. _dereq_(149);
  6071. _dereq_(132);
  6072. _dereq_(147);
  6073. _dereq_(146);
  6074. _dereq_(139);
  6075. _dereq_(143);
  6076. _dereq_(131);
  6077. _dereq_(133);
  6078. _dereq_(136);
  6079. _dereq_(135);
  6080. _dereq_(151);
  6081. _dereq_(141);
  6082. _dereq_(224);
  6083. _dereq_(230);
  6084. _dereq_(225);
  6085. _dereq_(226);
  6086. _dereq_(227);
  6087. _dereq_(228);
  6088. _dereq_(229);
  6089. _dereq_(209);
  6090. _dereq_(160);
  6091. _dereq_(231);
  6092. _dereq_(266);
  6093. _dereq_(267);
  6094. _dereq_(255);
  6095. _dereq_(256);
  6096. _dereq_(261);
  6097. _dereq_(264);
  6098. _dereq_(265);
  6099. _dereq_(259);
  6100. _dereq_(262);
  6101. _dereq_(260);
  6102. _dereq_(263);
  6103. _dereq_(257);
  6104. _dereq_(258);
  6105. _dereq_(210);
  6106. _dereq_(211);
  6107. _dereq_(212);
  6108. _dereq_(213);
  6109. _dereq_(214);
  6110. _dereq_(217);
  6111. _dereq_(215);
  6112. _dereq_(216);
  6113. _dereq_(218);
  6114. _dereq_(219);
  6115. _dereq_(220);
  6116. _dereq_(221);
  6117. _dereq_(223);
  6118. _dereq_(222);
  6119. _dereq_(270);
  6120. _dereq_(268);
  6121. _dereq_(269);
  6122. _dereq_(311);
  6123. _dereq_(314);
  6124. _dereq_(313);
  6125. _dereq_(315);
  6126. _dereq_(316);
  6127. _dereq_(312);
  6128. _dereq_(317);
  6129. _dereq_(318);
  6130. _dereq_(292);
  6131. _dereq_(295);
  6132. _dereq_(291);
  6133. _dereq_(289);
  6134. _dereq_(290);
  6135. _dereq_(293);
  6136. _dereq_(294);
  6137. _dereq_(276);
  6138. _dereq_(310);
  6139. _dereq_(275);
  6140. _dereq_(309);
  6141. _dereq_(321);
  6142. _dereq_(323);
  6143. _dereq_(274);
  6144. _dereq_(308);
  6145. _dereq_(320);
  6146. _dereq_(322);
  6147. _dereq_(273);
  6148. _dereq_(319);
  6149. _dereq_(272);
  6150. _dereq_(277);
  6151. _dereq_(278);
  6152. _dereq_(279);
  6153. _dereq_(280);
  6154. _dereq_(281);
  6155. _dereq_(283);
  6156. _dereq_(282);
  6157. _dereq_(284);
  6158. _dereq_(285);
  6159. _dereq_(286);
  6160. _dereq_(288);
  6161. _dereq_(287);
  6162. _dereq_(297);
  6163. _dereq_(298);
  6164. _dereq_(299);
  6165. _dereq_(300);
  6166. _dereq_(302);
  6167. _dereq_(301);
  6168. _dereq_(304);
  6169. _dereq_(303);
  6170. _dereq_(305);
  6171. _dereq_(306);
  6172. _dereq_(307);
  6173. _dereq_(271);
  6174. _dereq_(296);
  6175. _dereq_(326);
  6176. _dereq_(325);
  6177. _dereq_(324);
  6178. module.exports = _dereq_(23);
  6179. },{"131":131,"132":132,"133":133,"134":134,"135":135,"136":136,"137":137,"138":138,"139":139,"140":140,"141":141,"142":142,"143":143,"144":144,"145":145,"146":146,"147":147,"148":148,"149":149,"150":150,"151":151,"152":152,"153":153,"154":154,"155":155,"156":156,"157":157,"158":158,"159":159,"160":160,"161":161,"162":162,"163":163,"164":164,"165":165,"166":166,"167":167,"168":168,"169":169,"170":170,"171":171,"172":172,"173":173,"174":174,"175":175,"176":176,"177":177,"178":178,"179":179,"180":180,"181":181,"182":182,"183":183,"184":184,"185":185,"186":186,"187":187,"188":188,"189":189,"190":190,"191":191,"192":192,"193":193,"194":194,"195":195,"196":196,"197":197,"198":198,"199":199,"200":200,"201":201,"202":202,"203":203,"204":204,"205":205,"206":206,"207":207,"208":208,"209":209,"210":210,"211":211,"212":212,"213":213,"214":214,"215":215,"216":216,"217":217,"218":218,"219":219,"220":220,"221":221,"222":222,"223":223,"224":224,"225":225,"226":226,"227":227,"228":228,"229":229,"23":23,"230":230,"231":231,"232":232,"233":233,"234":234,"235":235,"236":236,"237":237,"238":238,"239":239,"240":240,"241":241,"242":242,"243":243,"244":244,"245":245,"246":246,"247":247,"248":248,"249":249,"250":250,"251":251,"252":252,"253":253,"254":254,"255":255,"256":256,"257":257,"258":258,"259":259,"260":260,"261":261,"262":262,"263":263,"264":264,"265":265,"266":266,"267":267,"268":268,"269":269,"270":270,"271":271,"272":272,"273":273,"274":274,"275":275,"276":276,"277":277,"278":278,"279":279,"280":280,"281":281,"282":282,"283":283,"284":284,"285":285,"286":286,"287":287,"288":288,"289":289,"290":290,"291":291,"292":292,"293":293,"294":294,"295":295,"296":296,"297":297,"298":298,"299":299,"300":300,"301":301,"302":302,"303":303,"304":304,"305":305,"306":306,"307":307,"308":308,"309":309,"310":310,"311":311,"312":312,"313":313,"314":314,"315":315,"316":316,"317":317,"318":318,"319":319,"320":320,"321":321,"322":322,"323":323,"324":324,"325":325,"326":326}],328:[function(_dereq_,module,exports){
  6180. (function (global){
  6181. /**
  6182. * Copyright (c) 2014, Facebook, Inc.
  6183. * All rights reserved.
  6184. *
  6185. * This source code is licensed under the BSD-style license found in the
  6186. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  6187. * additional grant of patent rights can be found in the PATENTS file in
  6188. * the same directory.
  6189. */
  6190. !(function(global) {
  6191. "use strict";
  6192. var Op = Object.prototype;
  6193. var hasOwn = Op.hasOwnProperty;
  6194. var undefined; // More compressible than void 0.
  6195. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  6196. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  6197. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  6198. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  6199. var inModule = typeof module === "object";
  6200. var runtime = global.regeneratorRuntime;
  6201. if (runtime) {
  6202. if (inModule) {
  6203. // If regeneratorRuntime is defined globally and we're in a module,
  6204. // make the exports object identical to regeneratorRuntime.
  6205. module.exports = runtime;
  6206. }
  6207. // Don't bother evaluating the rest of this file if the runtime was
  6208. // already defined globally.
  6209. return;
  6210. }
  6211. // Define the runtime globally (as expected by generated code) as either
  6212. // module.exports (if we're in a module) or a new, empty object.
  6213. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  6214. function wrap(innerFn, outerFn, self, tryLocsList) {
  6215. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  6216. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  6217. var generator = Object.create(protoGenerator.prototype);
  6218. var context = new Context(tryLocsList || []);
  6219. // The ._invoke method unifies the implementations of the .next,
  6220. // .throw, and .return methods.
  6221. generator._invoke = makeInvokeMethod(innerFn, self, context);
  6222. return generator;
  6223. }
  6224. runtime.wrap = wrap;
  6225. // Try/catch helper to minimize deoptimizations. Returns a completion
  6226. // record like context.tryEntries[i].completion. This interface could
  6227. // have been (and was previously) designed to take a closure to be
  6228. // invoked without arguments, but in all the cases we care about we
  6229. // already have an existing method we want to call, so there's no need
  6230. // to create a new function object. We can even get away with assuming
  6231. // the method takes exactly one argument, since that happens to be true
  6232. // in every case, so we don't have to touch the arguments object. The
  6233. // only additional allocation required is the completion record, which
  6234. // has a stable shape and so hopefully should be cheap to allocate.
  6235. function tryCatch(fn, obj, arg) {
  6236. try {
  6237. return { type: "normal", arg: fn.call(obj, arg) };
  6238. } catch (err) {
  6239. return { type: "throw", arg: err };
  6240. }
  6241. }
  6242. var GenStateSuspendedStart = "suspendedStart";
  6243. var GenStateSuspendedYield = "suspendedYield";
  6244. var GenStateExecuting = "executing";
  6245. var GenStateCompleted = "completed";
  6246. // Returning this object from the innerFn has the same effect as
  6247. // breaking out of the dispatch switch statement.
  6248. var ContinueSentinel = {};
  6249. // Dummy constructor functions that we use as the .constructor and
  6250. // .constructor.prototype properties for functions that return Generator
  6251. // objects. For full spec compliance, you may wish to configure your
  6252. // minifier not to mangle the names of these two functions.
  6253. function Generator() {}
  6254. function GeneratorFunction() {}
  6255. function GeneratorFunctionPrototype() {}
  6256. // This is a polyfill for %IteratorPrototype% for environments that
  6257. // don't natively support it.
  6258. var IteratorPrototype = {};
  6259. IteratorPrototype[iteratorSymbol] = function () {
  6260. return this;
  6261. };
  6262. var getProto = Object.getPrototypeOf;
  6263. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  6264. if (NativeIteratorPrototype &&
  6265. NativeIteratorPrototype !== Op &&
  6266. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  6267. // This environment has a native %IteratorPrototype%; use it instead
  6268. // of the polyfill.
  6269. IteratorPrototype = NativeIteratorPrototype;
  6270. }
  6271. var Gp = GeneratorFunctionPrototype.prototype =
  6272. Generator.prototype = Object.create(IteratorPrototype);
  6273. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  6274. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  6275. GeneratorFunctionPrototype[toStringTagSymbol] =
  6276. GeneratorFunction.displayName = "GeneratorFunction";
  6277. // Helper for defining the .next, .throw, and .return methods of the
  6278. // Iterator interface in terms of a single ._invoke method.
  6279. function defineIteratorMethods(prototype) {
  6280. ["next", "throw", "return"].forEach(function(method) {
  6281. prototype[method] = function(arg) {
  6282. return this._invoke(method, arg);
  6283. };
  6284. });
  6285. }
  6286. runtime.isGeneratorFunction = function(genFun) {
  6287. var ctor = typeof genFun === "function" && genFun.constructor;
  6288. return ctor
  6289. ? ctor === GeneratorFunction ||
  6290. // For the native GeneratorFunction constructor, the best we can
  6291. // do is to check its .name property.
  6292. (ctor.displayName || ctor.name) === "GeneratorFunction"
  6293. : false;
  6294. };
  6295. runtime.mark = function(genFun) {
  6296. if (Object.setPrototypeOf) {
  6297. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  6298. } else {
  6299. genFun.__proto__ = GeneratorFunctionPrototype;
  6300. if (!(toStringTagSymbol in genFun)) {
  6301. genFun[toStringTagSymbol] = "GeneratorFunction";
  6302. }
  6303. }
  6304. genFun.prototype = Object.create(Gp);
  6305. return genFun;
  6306. };
  6307. // Within the body of any async function, `await x` is transformed to
  6308. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  6309. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  6310. // meant to be awaited.
  6311. runtime.awrap = function(arg) {
  6312. return { __await: arg };
  6313. };
  6314. function AsyncIterator(generator) {
  6315. function invoke(method, arg, resolve, reject) {
  6316. var record = tryCatch(generator[method], generator, arg);
  6317. if (record.type === "throw") {
  6318. reject(record.arg);
  6319. } else {
  6320. var result = record.arg;
  6321. var value = result.value;
  6322. if (value &&
  6323. typeof value === "object" &&
  6324. hasOwn.call(value, "__await")) {
  6325. return Promise.resolve(value.__await).then(function(value) {
  6326. invoke("next", value, resolve, reject);
  6327. }, function(err) {
  6328. invoke("throw", err, resolve, reject);
  6329. });
  6330. }
  6331. return Promise.resolve(value).then(function(unwrapped) {
  6332. // When a yielded Promise is resolved, its final value becomes
  6333. // the .value of the Promise<{value,done}> result for the
  6334. // current iteration. If the Promise is rejected, however, the
  6335. // result for this iteration will be rejected with the same
  6336. // reason. Note that rejections of yielded Promises are not
  6337. // thrown back into the generator function, as is the case
  6338. // when an awaited Promise is rejected. This difference in
  6339. // behavior between yield and await is important, because it
  6340. // allows the consumer to decide what to do with the yielded
  6341. // rejection (swallow it and continue, manually .throw it back
  6342. // into the generator, abandon iteration, whatever). With
  6343. // await, by contrast, there is no opportunity to examine the
  6344. // rejection reason outside the generator function, so the
  6345. // only option is to throw it from the await expression, and
  6346. // let the generator function handle the exception.
  6347. result.value = unwrapped;
  6348. resolve(result);
  6349. }, reject);
  6350. }
  6351. }
  6352. if (typeof global.process === "object" && global.process.domain) {
  6353. invoke = global.process.domain.bind(invoke);
  6354. }
  6355. var previousPromise;
  6356. function enqueue(method, arg) {
  6357. function callInvokeWithMethodAndArg() {
  6358. return new Promise(function(resolve, reject) {
  6359. invoke(method, arg, resolve, reject);
  6360. });
  6361. }
  6362. return previousPromise =
  6363. // If enqueue has been called before, then we want to wait until
  6364. // all previous Promises have been resolved before calling invoke,
  6365. // so that results are always delivered in the correct order. If
  6366. // enqueue has not been called before, then it is important to
  6367. // call invoke immediately, without waiting on a callback to fire,
  6368. // so that the async generator function has the opportunity to do
  6369. // any necessary setup in a predictable way. This predictability
  6370. // is why the Promise constructor synchronously invokes its
  6371. // executor callback, and why async functions synchronously
  6372. // execute code before the first await. Since we implement simple
  6373. // async functions in terms of async generators, it is especially
  6374. // important to get this right, even though it requires care.
  6375. previousPromise ? previousPromise.then(
  6376. callInvokeWithMethodAndArg,
  6377. // Avoid propagating failures to Promises returned by later
  6378. // invocations of the iterator.
  6379. callInvokeWithMethodAndArg
  6380. ) : callInvokeWithMethodAndArg();
  6381. }
  6382. // Define the unified helper method that is used to implement .next,
  6383. // .throw, and .return (see defineIteratorMethods).
  6384. this._invoke = enqueue;
  6385. }
  6386. defineIteratorMethods(AsyncIterator.prototype);
  6387. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  6388. return this;
  6389. };
  6390. runtime.AsyncIterator = AsyncIterator;
  6391. // Note that simple async functions are implemented on top of
  6392. // AsyncIterator objects; they just return a Promise for the value of
  6393. // the final result produced by the iterator.
  6394. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  6395. var iter = new AsyncIterator(
  6396. wrap(innerFn, outerFn, self, tryLocsList)
  6397. );
  6398. return runtime.isGeneratorFunction(outerFn)
  6399. ? iter // If outerFn is a generator, return the full iterator.
  6400. : iter.next().then(function(result) {
  6401. return result.done ? result.value : iter.next();
  6402. });
  6403. };
  6404. function makeInvokeMethod(innerFn, self, context) {
  6405. var state = GenStateSuspendedStart;
  6406. return function invoke(method, arg) {
  6407. if (state === GenStateExecuting) {
  6408. throw new Error("Generator is already running");
  6409. }
  6410. if (state === GenStateCompleted) {
  6411. if (method === "throw") {
  6412. throw arg;
  6413. }
  6414. // Be forgiving, per 25.3.3.3.3 of the spec:
  6415. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  6416. return doneResult();
  6417. }
  6418. context.method = method;
  6419. context.arg = arg;
  6420. while (true) {
  6421. var delegate = context.delegate;
  6422. if (delegate) {
  6423. var delegateResult = maybeInvokeDelegate(delegate, context);
  6424. if (delegateResult) {
  6425. if (delegateResult === ContinueSentinel) continue;
  6426. return delegateResult;
  6427. }
  6428. }
  6429. if (context.method === "next") {
  6430. // Setting context._sent for legacy support of Babel's
  6431. // function.sent implementation.
  6432. context.sent = context._sent = context.arg;
  6433. } else if (context.method === "throw") {
  6434. if (state === GenStateSuspendedStart) {
  6435. state = GenStateCompleted;
  6436. throw context.arg;
  6437. }
  6438. context.dispatchException(context.arg);
  6439. } else if (context.method === "return") {
  6440. context.abrupt("return", context.arg);
  6441. }
  6442. state = GenStateExecuting;
  6443. var record = tryCatch(innerFn, self, context);
  6444. if (record.type === "normal") {
  6445. // If an exception is thrown from innerFn, we leave state ===
  6446. // GenStateExecuting and loop back for another invocation.
  6447. state = context.done
  6448. ? GenStateCompleted
  6449. : GenStateSuspendedYield;
  6450. if (record.arg === ContinueSentinel) {
  6451. continue;
  6452. }
  6453. return {
  6454. value: record.arg,
  6455. done: context.done
  6456. };
  6457. } else if (record.type === "throw") {
  6458. state = GenStateCompleted;
  6459. // Dispatch the exception by looping back around to the
  6460. // context.dispatchException(context.arg) call above.
  6461. context.method = "throw";
  6462. context.arg = record.arg;
  6463. }
  6464. }
  6465. };
  6466. }
  6467. // Call delegate.iterator[context.method](context.arg) and handle the
  6468. // result, either by returning a { value, done } result from the
  6469. // delegate iterator, or by modifying context.method and context.arg,
  6470. // setting context.delegate to null, and returning the ContinueSentinel.
  6471. function maybeInvokeDelegate(delegate, context) {
  6472. var method = delegate.iterator[context.method];
  6473. if (method === undefined) {
  6474. // A .throw or .return when the delegate iterator has no .throw
  6475. // method always terminates the yield* loop.
  6476. context.delegate = null;
  6477. if (context.method === "throw") {
  6478. if (delegate.iterator.return) {
  6479. // If the delegate iterator has a return method, give it a
  6480. // chance to clean up.
  6481. context.method = "return";
  6482. context.arg = undefined;
  6483. maybeInvokeDelegate(delegate, context);
  6484. if (context.method === "throw") {
  6485. // If maybeInvokeDelegate(context) changed context.method from
  6486. // "return" to "throw", let that override the TypeError below.
  6487. return ContinueSentinel;
  6488. }
  6489. }
  6490. context.method = "throw";
  6491. context.arg = new TypeError(
  6492. "The iterator does not provide a 'throw' method");
  6493. }
  6494. return ContinueSentinel;
  6495. }
  6496. var record = tryCatch(method, delegate.iterator, context.arg);
  6497. if (record.type === "throw") {
  6498. context.method = "throw";
  6499. context.arg = record.arg;
  6500. context.delegate = null;
  6501. return ContinueSentinel;
  6502. }
  6503. var info = record.arg;
  6504. if (! info) {
  6505. context.method = "throw";
  6506. context.arg = new TypeError("iterator result is not an object");
  6507. context.delegate = null;
  6508. return ContinueSentinel;
  6509. }
  6510. if (info.done) {
  6511. // Assign the result of the finished delegate to the temporary
  6512. // variable specified by delegate.resultName (see delegateYield).
  6513. context[delegate.resultName] = info.value;
  6514. // Resume execution at the desired location (see delegateYield).
  6515. context.next = delegate.nextLoc;
  6516. // If context.method was "throw" but the delegate handled the
  6517. // exception, let the outer generator proceed normally. If
  6518. // context.method was "next", forget context.arg since it has been
  6519. // "consumed" by the delegate iterator. If context.method was
  6520. // "return", allow the original .return call to continue in the
  6521. // outer generator.
  6522. if (context.method !== "return") {
  6523. context.method = "next";
  6524. context.arg = undefined;
  6525. }
  6526. } else {
  6527. // Re-yield the result returned by the delegate method.
  6528. return info;
  6529. }
  6530. // The delegate iterator is finished, so forget it and continue with
  6531. // the outer generator.
  6532. context.delegate = null;
  6533. return ContinueSentinel;
  6534. }
  6535. // Define Generator.prototype.{next,throw,return} in terms of the
  6536. // unified ._invoke helper method.
  6537. defineIteratorMethods(Gp);
  6538. Gp[toStringTagSymbol] = "Generator";
  6539. // A Generator should always return itself as the iterator object when the
  6540. // @@iterator function is called on it. Some browsers' implementations of the
  6541. // iterator prototype chain incorrectly implement this, causing the Generator
  6542. // object to not be returned from this call. This ensures that doesn't happen.
  6543. // See https://github.com/facebook/regenerator/issues/274 for more details.
  6544. Gp[iteratorSymbol] = function() {
  6545. return this;
  6546. };
  6547. Gp.toString = function() {
  6548. return "[object Generator]";
  6549. };
  6550. function pushTryEntry(locs) {
  6551. var entry = { tryLoc: locs[0] };
  6552. if (1 in locs) {
  6553. entry.catchLoc = locs[1];
  6554. }
  6555. if (2 in locs) {
  6556. entry.finallyLoc = locs[2];
  6557. entry.afterLoc = locs[3];
  6558. }
  6559. this.tryEntries.push(entry);
  6560. }
  6561. function resetTryEntry(entry) {
  6562. var record = entry.completion || {};
  6563. record.type = "normal";
  6564. delete record.arg;
  6565. entry.completion = record;
  6566. }
  6567. function Context(tryLocsList) {
  6568. // The root entry object (effectively a try statement without a catch
  6569. // or a finally block) gives us a place to store values thrown from
  6570. // locations where there is no enclosing try statement.
  6571. this.tryEntries = [{ tryLoc: "root" }];
  6572. tryLocsList.forEach(pushTryEntry, this);
  6573. this.reset(true);
  6574. }
  6575. runtime.keys = function(object) {
  6576. var keys = [];
  6577. for (var key in object) {
  6578. keys.push(key);
  6579. }
  6580. keys.reverse();
  6581. // Rather than returning an object with a next method, we keep
  6582. // things simple and return the next function itself.
  6583. return function next() {
  6584. while (keys.length) {
  6585. var key = keys.pop();
  6586. if (key in object) {
  6587. next.value = key;
  6588. next.done = false;
  6589. return next;
  6590. }
  6591. }
  6592. // To avoid creating an additional object, we just hang the .value
  6593. // and .done properties off the next function object itself. This
  6594. // also ensures that the minifier will not anonymize the function.
  6595. next.done = true;
  6596. return next;
  6597. };
  6598. };
  6599. function values(iterable) {
  6600. if (iterable) {
  6601. var iteratorMethod = iterable[iteratorSymbol];
  6602. if (iteratorMethod) {
  6603. return iteratorMethod.call(iterable);
  6604. }
  6605. if (typeof iterable.next === "function") {
  6606. return iterable;
  6607. }
  6608. if (!isNaN(iterable.length)) {
  6609. var i = -1, next = function next() {
  6610. while (++i < iterable.length) {
  6611. if (hasOwn.call(iterable, i)) {
  6612. next.value = iterable[i];
  6613. next.done = false;
  6614. return next;
  6615. }
  6616. }
  6617. next.value = undefined;
  6618. next.done = true;
  6619. return next;
  6620. };
  6621. return next.next = next;
  6622. }
  6623. }
  6624. // Return an iterator with no values.
  6625. return { next: doneResult };
  6626. }
  6627. runtime.values = values;
  6628. function doneResult() {
  6629. return { value: undefined, done: true };
  6630. }
  6631. Context.prototype = {
  6632. constructor: Context,
  6633. reset: function(skipTempReset) {
  6634. this.prev = 0;
  6635. this.next = 0;
  6636. // Resetting context._sent for legacy support of Babel's
  6637. // function.sent implementation.
  6638. this.sent = this._sent = undefined;
  6639. this.done = false;
  6640. this.delegate = null;
  6641. this.method = "next";
  6642. this.arg = undefined;
  6643. this.tryEntries.forEach(resetTryEntry);
  6644. if (!skipTempReset) {
  6645. for (var name in this) {
  6646. // Not sure about the optimal order of these conditions:
  6647. if (name.charAt(0) === "t" &&
  6648. hasOwn.call(this, name) &&
  6649. !isNaN(+name.slice(1))) {
  6650. this[name] = undefined;
  6651. }
  6652. }
  6653. }
  6654. },
  6655. stop: function() {
  6656. this.done = true;
  6657. var rootEntry = this.tryEntries[0];
  6658. var rootRecord = rootEntry.completion;
  6659. if (rootRecord.type === "throw") {
  6660. throw rootRecord.arg;
  6661. }
  6662. return this.rval;
  6663. },
  6664. dispatchException: function(exception) {
  6665. if (this.done) {
  6666. throw exception;
  6667. }
  6668. var context = this;
  6669. function handle(loc, caught) {
  6670. record.type = "throw";
  6671. record.arg = exception;
  6672. context.next = loc;
  6673. if (caught) {
  6674. // If the dispatched exception was caught by a catch block,
  6675. // then let that catch block handle the exception normally.
  6676. context.method = "next";
  6677. context.arg = undefined;
  6678. }
  6679. return !! caught;
  6680. }
  6681. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6682. var entry = this.tryEntries[i];
  6683. var record = entry.completion;
  6684. if (entry.tryLoc === "root") {
  6685. // Exception thrown outside of any try block that could handle
  6686. // it, so set the completion value of the entire function to
  6687. // throw the exception.
  6688. return handle("end");
  6689. }
  6690. if (entry.tryLoc <= this.prev) {
  6691. var hasCatch = hasOwn.call(entry, "catchLoc");
  6692. var hasFinally = hasOwn.call(entry, "finallyLoc");
  6693. if (hasCatch && hasFinally) {
  6694. if (this.prev < entry.catchLoc) {
  6695. return handle(entry.catchLoc, true);
  6696. } else if (this.prev < entry.finallyLoc) {
  6697. return handle(entry.finallyLoc);
  6698. }
  6699. } else if (hasCatch) {
  6700. if (this.prev < entry.catchLoc) {
  6701. return handle(entry.catchLoc, true);
  6702. }
  6703. } else if (hasFinally) {
  6704. if (this.prev < entry.finallyLoc) {
  6705. return handle(entry.finallyLoc);
  6706. }
  6707. } else {
  6708. throw new Error("try statement without catch or finally");
  6709. }
  6710. }
  6711. }
  6712. },
  6713. abrupt: function(type, arg) {
  6714. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6715. var entry = this.tryEntries[i];
  6716. if (entry.tryLoc <= this.prev &&
  6717. hasOwn.call(entry, "finallyLoc") &&
  6718. this.prev < entry.finallyLoc) {
  6719. var finallyEntry = entry;
  6720. break;
  6721. }
  6722. }
  6723. if (finallyEntry &&
  6724. (type === "break" ||
  6725. type === "continue") &&
  6726. finallyEntry.tryLoc <= arg &&
  6727. arg <= finallyEntry.finallyLoc) {
  6728. // Ignore the finally entry if control is not jumping to a
  6729. // location outside the try/catch block.
  6730. finallyEntry = null;
  6731. }
  6732. var record = finallyEntry ? finallyEntry.completion : {};
  6733. record.type = type;
  6734. record.arg = arg;
  6735. if (finallyEntry) {
  6736. this.method = "next";
  6737. this.next = finallyEntry.finallyLoc;
  6738. return ContinueSentinel;
  6739. }
  6740. return this.complete(record);
  6741. },
  6742. complete: function(record, afterLoc) {
  6743. if (record.type === "throw") {
  6744. throw record.arg;
  6745. }
  6746. if (record.type === "break" ||
  6747. record.type === "continue") {
  6748. this.next = record.arg;
  6749. } else if (record.type === "return") {
  6750. this.rval = this.arg = record.arg;
  6751. this.method = "return";
  6752. this.next = "end";
  6753. } else if (record.type === "normal" && afterLoc) {
  6754. this.next = afterLoc;
  6755. }
  6756. return ContinueSentinel;
  6757. },
  6758. finish: function(finallyLoc) {
  6759. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6760. var entry = this.tryEntries[i];
  6761. if (entry.finallyLoc === finallyLoc) {
  6762. this.complete(entry.completion, entry.afterLoc);
  6763. resetTryEntry(entry);
  6764. return ContinueSentinel;
  6765. }
  6766. }
  6767. },
  6768. "catch": function(tryLoc) {
  6769. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6770. var entry = this.tryEntries[i];
  6771. if (entry.tryLoc === tryLoc) {
  6772. var record = entry.completion;
  6773. if (record.type === "throw") {
  6774. var thrown = record.arg;
  6775. resetTryEntry(entry);
  6776. }
  6777. return thrown;
  6778. }
  6779. }
  6780. // The context.catch method must only be called with a location
  6781. // argument that corresponds to a known catch block.
  6782. throw new Error("illegal catch attempt");
  6783. },
  6784. delegateYield: function(iterable, resultName, nextLoc) {
  6785. this.delegate = {
  6786. iterator: values(iterable),
  6787. resultName: resultName,
  6788. nextLoc: nextLoc
  6789. };
  6790. if (this.method === "next") {
  6791. // Deliberately forget the last sent value so that we don't
  6792. // accidentally pass it on to the delegate.
  6793. this.arg = undefined;
  6794. }
  6795. return ContinueSentinel;
  6796. }
  6797. };
  6798. })(
  6799. // Among the various tricks for obtaining a reference to the global
  6800. // object, this seems to be the most reliable technique that does not
  6801. // use indirect eval (which violates Content Security Policy).
  6802. typeof global === "object" ? global :
  6803. typeof window === "object" ? window :
  6804. typeof self === "object" ? self : this
  6805. );
  6806. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6807. },{}]},{},[1]);
  6808. require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  6809. 'use strict';
  6810. 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; }; }();
  6811. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  6812. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6813. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  6814. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6815. var XHTMLEntities = require('./xhtml');
  6816. var hexNumber = /^[\da-fA-F]+$/;
  6817. var decimalNumber = /^\d+$/;
  6818. var acorn = require("acorn");
  6819. var tt = acorn.tokTypes;
  6820. var TokContext = acorn.TokContext;
  6821. var tokContexts = acorn.tokContexts;
  6822. var TokenType = acorn.TokenType;
  6823. var isNewLine = acorn.isNewLine;
  6824. var isIdentifierStart = acorn.isIdentifierStart;
  6825. var isIdentifierChar = acorn.isIdentifierChar;
  6826. var tc_oTag = new TokContext('<tag', false);
  6827. var tc_cTag = new TokContext('</tag', false);
  6828. var tc_expr = new TokContext('<tag>...</tag>', true, true);
  6829. var tok = {
  6830. jsxName: new TokenType('jsxName'),
  6831. jsxText: new TokenType('jsxText', { beforeExpr: true }),
  6832. jsxTagStart: new TokenType('jsxTagStart'),
  6833. jsxTagEnd: new TokenType('jsxTagEnd')
  6834. };
  6835. tok.jsxTagStart.updateContext = function () {
  6836. this.context.push(tc_expr); // treat as beginning of JSX expression
  6837. this.context.push(tc_oTag); // start opening tag context
  6838. this.exprAllowed = false;
  6839. };
  6840. tok.jsxTagEnd.updateContext = function (prevType) {
  6841. var out = this.context.pop();
  6842. if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
  6843. this.context.pop();
  6844. this.exprAllowed = this.curContext() === tc_expr;
  6845. } else {
  6846. this.exprAllowed = true;
  6847. }
  6848. };
  6849. // Transforms JSX element name to string.
  6850. function getQualifiedJSXName(object) {
  6851. if (!object) return object;
  6852. if (object.type === 'JSXIdentifier') return object.name;
  6853. if (object.type === 'JSXNamespacedName') return object.namespace.name + ':' + object.name.name;
  6854. if (object.type === 'JSXMemberExpression') return getQualifiedJSXName(object.object) + '.' + getQualifiedJSXName(object.property);
  6855. }
  6856. module.exports = function (options) {
  6857. options = options || {};
  6858. return function (Parser) {
  6859. return plugin({
  6860. allowNamespaces: options.allowNamespaces !== false,
  6861. allowNamespacedObjects: !!options.allowNamespacedObjects
  6862. }, Parser);
  6863. };
  6864. };
  6865. module.exports.tokTypes = tok;
  6866. function plugin(options, Parser) {
  6867. return function (_Parser) {
  6868. _inherits(_class, _Parser);
  6869. function _class() {
  6870. _classCallCheck(this, _class);
  6871. return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments));
  6872. }
  6873. _createClass(_class, [{
  6874. key: 'jsx_readToken',
  6875. // Reads inline JSX contents token.
  6876. value: function jsx_readToken() {
  6877. var out = '',
  6878. chunkStart = this.pos;
  6879. for (;;) {
  6880. if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated JSX contents');
  6881. var ch = this.input.charCodeAt(this.pos);
  6882. switch (ch) {
  6883. case 60: // '<'
  6884. case 123:
  6885. // '{'
  6886. if (this.pos === this.start) {
  6887. if (ch === 60 && this.exprAllowed) {
  6888. ++this.pos;
  6889. return this.finishToken(tok.jsxTagStart);
  6890. }
  6891. return this.getTokenFromCode(ch);
  6892. }
  6893. out += this.input.slice(chunkStart, this.pos);
  6894. return this.finishToken(tok.jsxText, out);
  6895. case 38:
  6896. // '&'
  6897. out += this.input.slice(chunkStart, this.pos);
  6898. out += this.jsx_readEntity();
  6899. chunkStart = this.pos;
  6900. break;
  6901. default:
  6902. if (isNewLine(ch)) {
  6903. out += this.input.slice(chunkStart, this.pos);
  6904. out += this.jsx_readNewLine(true);
  6905. chunkStart = this.pos;
  6906. } else {
  6907. ++this.pos;
  6908. }
  6909. }
  6910. }
  6911. }
  6912. }, {
  6913. key: 'jsx_readNewLine',
  6914. value: function jsx_readNewLine(normalizeCRLF) {
  6915. var ch = this.input.charCodeAt(this.pos);
  6916. var out = void 0;
  6917. ++this.pos;
  6918. if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
  6919. ++this.pos;
  6920. out = normalizeCRLF ? '\n' : '\r\n';
  6921. } else {
  6922. out = String.fromCharCode(ch);
  6923. }
  6924. if (this.options.locations) {
  6925. ++this.curLine;
  6926. this.lineStart = this.pos;
  6927. }
  6928. return out;
  6929. }
  6930. }, {
  6931. key: 'jsx_readString',
  6932. value: function jsx_readString(quote) {
  6933. var out = '',
  6934. chunkStart = ++this.pos;
  6935. for (;;) {
  6936. if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated string constant');
  6937. var ch = this.input.charCodeAt(this.pos);
  6938. if (ch === quote) break;
  6939. if (ch === 38) {
  6940. // '&'
  6941. out += this.input.slice(chunkStart, this.pos);
  6942. out += this.jsx_readEntity();
  6943. chunkStart = this.pos;
  6944. } else if (isNewLine(ch)) {
  6945. out += this.input.slice(chunkStart, this.pos);
  6946. out += this.jsx_readNewLine(false);
  6947. chunkStart = this.pos;
  6948. } else {
  6949. ++this.pos;
  6950. }
  6951. }
  6952. out += this.input.slice(chunkStart, this.pos++);
  6953. return this.finishToken(tt.string, out);
  6954. }
  6955. }, {
  6956. key: 'jsx_readEntity',
  6957. value: function jsx_readEntity() {
  6958. var str = '',
  6959. count = 0,
  6960. entity = void 0;
  6961. var ch = this.input[this.pos];
  6962. if (ch !== '&') this.raise(this.pos, 'Entity must start with an ampersand');
  6963. var startPos = ++this.pos;
  6964. while (this.pos < this.input.length && count++ < 10) {
  6965. ch = this.input[this.pos++];
  6966. if (ch === ';') {
  6967. if (str[0] === '#') {
  6968. if (str[1] === 'x') {
  6969. str = str.substr(2);
  6970. if (hexNumber.test(str)) entity = String.fromCharCode(parseInt(str, 16));
  6971. } else {
  6972. str = str.substr(1);
  6973. if (decimalNumber.test(str)) entity = String.fromCharCode(parseInt(str, 10));
  6974. }
  6975. } else {
  6976. entity = XHTMLEntities[str];
  6977. }
  6978. break;
  6979. }
  6980. str += ch;
  6981. }
  6982. if (!entity) {
  6983. this.pos = startPos;
  6984. return '&';
  6985. }
  6986. return entity;
  6987. }
  6988. // Read a JSX identifier (valid tag or attribute name).
  6989. //
  6990. // Optimized version since JSX identifiers can't contain
  6991. // escape characters and so can be read as single slice.
  6992. // Also assumes that first character was already checked
  6993. // by isIdentifierStart in readToken.
  6994. }, {
  6995. key: 'jsx_readWord',
  6996. value: function jsx_readWord() {
  6997. var ch = void 0,
  6998. start = this.pos;
  6999. do {
  7000. ch = this.input.charCodeAt(++this.pos);
  7001. } while (isIdentifierChar(ch) || ch === 45); // '-'
  7002. return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
  7003. }
  7004. // Parse next token as JSX identifier
  7005. }, {
  7006. key: 'jsx_parseIdentifier',
  7007. value: function jsx_parseIdentifier() {
  7008. var node = this.startNode();
  7009. if (this.type === tok.jsxName) node.name = this.value;else if (this.type.keyword) node.name = this.type.keyword;else this.unexpected();
  7010. this.next();
  7011. return this.finishNode(node, 'JSXIdentifier');
  7012. }
  7013. // Parse namespaced identifier.
  7014. }, {
  7015. key: 'jsx_parseNamespacedName',
  7016. value: function jsx_parseNamespacedName() {
  7017. var startPos = this.start,
  7018. startLoc = this.startLoc;
  7019. var name = this.jsx_parseIdentifier();
  7020. if (!options.allowNamespaces || !this.eat(tt.colon)) return name;
  7021. var node = this.startNodeAt(startPos, startLoc);
  7022. node.namespace = name;
  7023. node.name = this.jsx_parseIdentifier();
  7024. return this.finishNode(node, 'JSXNamespacedName');
  7025. }
  7026. // Parses element name in any form - namespaced, member
  7027. // or single identifier.
  7028. }, {
  7029. key: 'jsx_parseElementName',
  7030. value: function jsx_parseElementName() {
  7031. if (this.type === tok.jsxTagEnd) return '';
  7032. var startPos = this.start,
  7033. startLoc = this.startLoc;
  7034. var node = this.jsx_parseNamespacedName();
  7035. if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) {
  7036. this.unexpected();
  7037. }
  7038. while (this.eat(tt.dot)) {
  7039. var newNode = this.startNodeAt(startPos, startLoc);
  7040. newNode.object = node;
  7041. newNode.property = this.jsx_parseIdentifier();
  7042. node = this.finishNode(newNode, 'JSXMemberExpression');
  7043. }
  7044. return node;
  7045. }
  7046. // Parses any type of JSX attribute value.
  7047. }, {
  7048. key: 'jsx_parseAttributeValue',
  7049. value: function jsx_parseAttributeValue() {
  7050. switch (this.type) {
  7051. case tt.braceL:
  7052. var node = this.jsx_parseExpressionContainer();
  7053. if (node.expression.type === 'JSXEmptyExpression') this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
  7054. return node;
  7055. case tok.jsxTagStart:
  7056. case tt.string:
  7057. return this.parseExprAtom();
  7058. default:
  7059. this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
  7060. }
  7061. }
  7062. // JSXEmptyExpression is unique type since it doesn't actually parse anything,
  7063. // and so it should start at the end of last read token (left brace) and finish
  7064. // at the beginning of the next one (right brace).
  7065. }, {
  7066. key: 'jsx_parseEmptyExpression',
  7067. value: function jsx_parseEmptyExpression() {
  7068. var node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
  7069. return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc);
  7070. }
  7071. // Parses JSX expression enclosed into curly brackets.
  7072. }, {
  7073. key: 'jsx_parseExpressionContainer',
  7074. value: function jsx_parseExpressionContainer() {
  7075. var node = this.startNode();
  7076. this.next();
  7077. node.expression = this.type === tt.braceR ? this.jsx_parseEmptyExpression() : this.parseExpression();
  7078. this.expect(tt.braceR);
  7079. return this.finishNode(node, 'JSXExpressionContainer');
  7080. }
  7081. // Parses following JSX attribute name-value pair.
  7082. }, {
  7083. key: 'jsx_parseAttribute',
  7084. value: function jsx_parseAttribute() {
  7085. var node = this.startNode();
  7086. if (this.eat(tt.braceL)) {
  7087. this.expect(tt.ellipsis);
  7088. node.argument = this.parseMaybeAssign();
  7089. this.expect(tt.braceR);
  7090. return this.finishNode(node, 'JSXSpreadAttribute');
  7091. }
  7092. node.name = this.jsx_parseNamespacedName();
  7093. node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
  7094. return this.finishNode(node, 'JSXAttribute');
  7095. }
  7096. // Parses JSX opening tag starting after '<'.
  7097. }, {
  7098. key: 'jsx_parseOpeningElementAt',
  7099. value: function jsx_parseOpeningElementAt(startPos, startLoc) {
  7100. var node = this.startNodeAt(startPos, startLoc);
  7101. node.attributes = [];
  7102. var nodeName = this.jsx_parseElementName();
  7103. if (nodeName) node.name = nodeName;
  7104. while (this.type !== tt.slash && this.type !== tok.jsxTagEnd) {
  7105. node.attributes.push(this.jsx_parseAttribute());
  7106. }node.selfClosing = this.eat(tt.slash);
  7107. this.expect(tok.jsxTagEnd);
  7108. return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
  7109. }
  7110. // Parses JSX closing tag starting after '</'.
  7111. }, {
  7112. key: 'jsx_parseClosingElementAt',
  7113. value: function jsx_parseClosingElementAt(startPos, startLoc) {
  7114. var node = this.startNodeAt(startPos, startLoc);
  7115. var nodeName = this.jsx_parseElementName();
  7116. if (nodeName) node.name = nodeName;
  7117. this.expect(tok.jsxTagEnd);
  7118. return this.finishNode(node, nodeName ? 'JSXClosingElement' : 'JSXClosingFragment');
  7119. }
  7120. // Parses entire JSX element, including it's opening tag
  7121. // (starting after '<'), attributes, contents and closing tag.
  7122. }, {
  7123. key: 'jsx_parseElementAt',
  7124. value: function jsx_parseElementAt(startPos, startLoc) {
  7125. var node = this.startNodeAt(startPos, startLoc);
  7126. var children = [];
  7127. var openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
  7128. var closingElement = null;
  7129. if (!openingElement.selfClosing) {
  7130. contents: for (;;) {
  7131. switch (this.type) {
  7132. case tok.jsxTagStart:
  7133. startPos = this.start;startLoc = this.startLoc;
  7134. this.next();
  7135. if (this.eat(tt.slash)) {
  7136. closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
  7137. break contents;
  7138. }
  7139. children.push(this.jsx_parseElementAt(startPos, startLoc));
  7140. break;
  7141. case tok.jsxText:
  7142. children.push(this.parseExprAtom());
  7143. break;
  7144. case tt.braceL:
  7145. children.push(this.jsx_parseExpressionContainer());
  7146. break;
  7147. default:
  7148. this.unexpected();
  7149. }
  7150. }
  7151. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  7152. this.raise(closingElement.start, 'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
  7153. }
  7154. }
  7155. var fragmentOrElement = openingElement.name ? 'Element' : 'Fragment';
  7156. node['opening' + fragmentOrElement] = openingElement;
  7157. node['closing' + fragmentOrElement] = closingElement;
  7158. node.children = children;
  7159. if (this.type === tt.relational && this.value === "<") {
  7160. this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
  7161. }
  7162. return this.finishNode(node, 'JSX' + fragmentOrElement);
  7163. }
  7164. // Parse JSX text
  7165. }, {
  7166. key: 'jsx_parseText',
  7167. value: function jsx_parseText(value) {
  7168. var node = this.parseLiteral(value);
  7169. node.type = "JSXText";
  7170. return node;
  7171. }
  7172. // Parses entire JSX element from current position.
  7173. }, {
  7174. key: 'jsx_parseElement',
  7175. value: function jsx_parseElement() {
  7176. var startPos = this.start,
  7177. startLoc = this.startLoc;
  7178. this.next();
  7179. return this.jsx_parseElementAt(startPos, startLoc);
  7180. }
  7181. }, {
  7182. key: 'parseExprAtom',
  7183. value: function parseExprAtom(refShortHandDefaultPos) {
  7184. if (this.type === tok.jsxText) return this.jsx_parseText(this.value);else if (this.type === tok.jsxTagStart) return this.jsx_parseElement();else return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'parseExprAtom', this).call(this, refShortHandDefaultPos);
  7185. }
  7186. }, {
  7187. key: 'readToken',
  7188. value: function readToken(code) {
  7189. var context = this.curContext();
  7190. if (context === tc_expr) return this.jsx_readToken();
  7191. if (context === tc_oTag || context === tc_cTag) {
  7192. if (isIdentifierStart(code)) return this.jsx_readWord();
  7193. if (code == 62) {
  7194. ++this.pos;
  7195. return this.finishToken(tok.jsxTagEnd);
  7196. }
  7197. if ((code === 34 || code === 39) && context == tc_oTag) return this.jsx_readString(code);
  7198. }
  7199. if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
  7200. ++this.pos;
  7201. return this.finishToken(tok.jsxTagStart);
  7202. }
  7203. return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'readToken', this).call(this, code);
  7204. }
  7205. }, {
  7206. key: 'updateContext',
  7207. value: function updateContext(prevType) {
  7208. if (this.type == tt.braceL) {
  7209. var curContext = this.curContext();
  7210. if (curContext == tc_oTag) this.context.push(tokContexts.b_expr);else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl);else _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'updateContext', this).call(this, prevType);
  7211. this.exprAllowed = true;
  7212. } else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
  7213. this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
  7214. this.context.push(tc_cTag); // reconsider as closing tag context
  7215. this.exprAllowed = false;
  7216. } else {
  7217. return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'updateContext', this).call(this, prevType);
  7218. }
  7219. }
  7220. }]);
  7221. return _class;
  7222. }(Parser);
  7223. }
  7224. },{"./xhtml":2,"acorn":3}],2:[function(require,module,exports){
  7225. 'use strict';
  7226. module.exports = {
  7227. quot: '"',
  7228. amp: '&',
  7229. apos: '\'',
  7230. lt: '<',
  7231. gt: '>',
  7232. nbsp: '\xA0',
  7233. iexcl: '\xA1',
  7234. cent: '\xA2',
  7235. pound: '\xA3',
  7236. curren: '\xA4',
  7237. yen: '\xA5',
  7238. brvbar: '\xA6',
  7239. sect: '\xA7',
  7240. uml: '\xA8',
  7241. copy: '\xA9',
  7242. ordf: '\xAA',
  7243. laquo: '\xAB',
  7244. not: '\xAC',
  7245. shy: '\xAD',
  7246. reg: '\xAE',
  7247. macr: '\xAF',
  7248. deg: '\xB0',
  7249. plusmn: '\xB1',
  7250. sup2: '\xB2',
  7251. sup3: '\xB3',
  7252. acute: '\xB4',
  7253. micro: '\xB5',
  7254. para: '\xB6',
  7255. middot: '\xB7',
  7256. cedil: '\xB8',
  7257. sup1: '\xB9',
  7258. ordm: '\xBA',
  7259. raquo: '\xBB',
  7260. frac14: '\xBC',
  7261. frac12: '\xBD',
  7262. frac34: '\xBE',
  7263. iquest: '\xBF',
  7264. Agrave: '\xC0',
  7265. Aacute: '\xC1',
  7266. Acirc: '\xC2',
  7267. Atilde: '\xC3',
  7268. Auml: '\xC4',
  7269. Aring: '\xC5',
  7270. AElig: '\xC6',
  7271. Ccedil: '\xC7',
  7272. Egrave: '\xC8',
  7273. Eacute: '\xC9',
  7274. Ecirc: '\xCA',
  7275. Euml: '\xCB',
  7276. Igrave: '\xCC',
  7277. Iacute: '\xCD',
  7278. Icirc: '\xCE',
  7279. Iuml: '\xCF',
  7280. ETH: '\xD0',
  7281. Ntilde: '\xD1',
  7282. Ograve: '\xD2',
  7283. Oacute: '\xD3',
  7284. Ocirc: '\xD4',
  7285. Otilde: '\xD5',
  7286. Ouml: '\xD6',
  7287. times: '\xD7',
  7288. Oslash: '\xD8',
  7289. Ugrave: '\xD9',
  7290. Uacute: '\xDA',
  7291. Ucirc: '\xDB',
  7292. Uuml: '\xDC',
  7293. Yacute: '\xDD',
  7294. THORN: '\xDE',
  7295. szlig: '\xDF',
  7296. agrave: '\xE0',
  7297. aacute: '\xE1',
  7298. acirc: '\xE2',
  7299. atilde: '\xE3',
  7300. auml: '\xE4',
  7301. aring: '\xE5',
  7302. aelig: '\xE6',
  7303. ccedil: '\xE7',
  7304. egrave: '\xE8',
  7305. eacute: '\xE9',
  7306. ecirc: '\xEA',
  7307. euml: '\xEB',
  7308. igrave: '\xEC',
  7309. iacute: '\xED',
  7310. icirc: '\xEE',
  7311. iuml: '\xEF',
  7312. eth: '\xF0',
  7313. ntilde: '\xF1',
  7314. ograve: '\xF2',
  7315. oacute: '\xF3',
  7316. ocirc: '\xF4',
  7317. otilde: '\xF5',
  7318. ouml: '\xF6',
  7319. divide: '\xF7',
  7320. oslash: '\xF8',
  7321. ugrave: '\xF9',
  7322. uacute: '\xFA',
  7323. ucirc: '\xFB',
  7324. uuml: '\xFC',
  7325. yacute: '\xFD',
  7326. thorn: '\xFE',
  7327. yuml: '\xFF',
  7328. OElig: '\u0152',
  7329. oelig: '\u0153',
  7330. Scaron: '\u0160',
  7331. scaron: '\u0161',
  7332. Yuml: '\u0178',
  7333. fnof: '\u0192',
  7334. circ: '\u02C6',
  7335. tilde: '\u02DC',
  7336. Alpha: '\u0391',
  7337. Beta: '\u0392',
  7338. Gamma: '\u0393',
  7339. Delta: '\u0394',
  7340. Epsilon: '\u0395',
  7341. Zeta: '\u0396',
  7342. Eta: '\u0397',
  7343. Theta: '\u0398',
  7344. Iota: '\u0399',
  7345. Kappa: '\u039A',
  7346. Lambda: '\u039B',
  7347. Mu: '\u039C',
  7348. Nu: '\u039D',
  7349. Xi: '\u039E',
  7350. Omicron: '\u039F',
  7351. Pi: '\u03A0',
  7352. Rho: '\u03A1',
  7353. Sigma: '\u03A3',
  7354. Tau: '\u03A4',
  7355. Upsilon: '\u03A5',
  7356. Phi: '\u03A6',
  7357. Chi: '\u03A7',
  7358. Psi: '\u03A8',
  7359. Omega: '\u03A9',
  7360. alpha: '\u03B1',
  7361. beta: '\u03B2',
  7362. gamma: '\u03B3',
  7363. delta: '\u03B4',
  7364. epsilon: '\u03B5',
  7365. zeta: '\u03B6',
  7366. eta: '\u03B7',
  7367. theta: '\u03B8',
  7368. iota: '\u03B9',
  7369. kappa: '\u03BA',
  7370. lambda: '\u03BB',
  7371. mu: '\u03BC',
  7372. nu: '\u03BD',
  7373. xi: '\u03BE',
  7374. omicron: '\u03BF',
  7375. pi: '\u03C0',
  7376. rho: '\u03C1',
  7377. sigmaf: '\u03C2',
  7378. sigma: '\u03C3',
  7379. tau: '\u03C4',
  7380. upsilon: '\u03C5',
  7381. phi: '\u03C6',
  7382. chi: '\u03C7',
  7383. psi: '\u03C8',
  7384. omega: '\u03C9',
  7385. thetasym: '\u03D1',
  7386. upsih: '\u03D2',
  7387. piv: '\u03D6',
  7388. ensp: '\u2002',
  7389. emsp: '\u2003',
  7390. thinsp: '\u2009',
  7391. zwnj: '\u200C',
  7392. zwj: '\u200D',
  7393. lrm: '\u200E',
  7394. rlm: '\u200F',
  7395. ndash: '\u2013',
  7396. mdash: '\u2014',
  7397. lsquo: '\u2018',
  7398. rsquo: '\u2019',
  7399. sbquo: '\u201A',
  7400. ldquo: '\u201C',
  7401. rdquo: '\u201D',
  7402. bdquo: '\u201E',
  7403. dagger: '\u2020',
  7404. Dagger: '\u2021',
  7405. bull: '\u2022',
  7406. hellip: '\u2026',
  7407. permil: '\u2030',
  7408. prime: '\u2032',
  7409. Prime: '\u2033',
  7410. lsaquo: '\u2039',
  7411. rsaquo: '\u203A',
  7412. oline: '\u203E',
  7413. frasl: '\u2044',
  7414. euro: '\u20AC',
  7415. image: '\u2111',
  7416. weierp: '\u2118',
  7417. real: '\u211C',
  7418. trade: '\u2122',
  7419. alefsym: '\u2135',
  7420. larr: '\u2190',
  7421. uarr: '\u2191',
  7422. rarr: '\u2192',
  7423. darr: '\u2193',
  7424. harr: '\u2194',
  7425. crarr: '\u21B5',
  7426. lArr: '\u21D0',
  7427. uArr: '\u21D1',
  7428. rArr: '\u21D2',
  7429. dArr: '\u21D3',
  7430. hArr: '\u21D4',
  7431. forall: '\u2200',
  7432. part: '\u2202',
  7433. exist: '\u2203',
  7434. empty: '\u2205',
  7435. nabla: '\u2207',
  7436. isin: '\u2208',
  7437. notin: '\u2209',
  7438. ni: '\u220B',
  7439. prod: '\u220F',
  7440. sum: '\u2211',
  7441. minus: '\u2212',
  7442. lowast: '\u2217',
  7443. radic: '\u221A',
  7444. prop: '\u221D',
  7445. infin: '\u221E',
  7446. ang: '\u2220',
  7447. and: '\u2227',
  7448. or: '\u2228',
  7449. cap: '\u2229',
  7450. cup: '\u222A',
  7451. 'int': '\u222B',
  7452. there4: '\u2234',
  7453. sim: '\u223C',
  7454. cong: '\u2245',
  7455. asymp: '\u2248',
  7456. ne: '\u2260',
  7457. equiv: '\u2261',
  7458. le: '\u2264',
  7459. ge: '\u2265',
  7460. sub: '\u2282',
  7461. sup: '\u2283',
  7462. nsub: '\u2284',
  7463. sube: '\u2286',
  7464. supe: '\u2287',
  7465. oplus: '\u2295',
  7466. otimes: '\u2297',
  7467. perp: '\u22A5',
  7468. sdot: '\u22C5',
  7469. lceil: '\u2308',
  7470. rceil: '\u2309',
  7471. lfloor: '\u230A',
  7472. rfloor: '\u230B',
  7473. lang: '\u2329',
  7474. rang: '\u232A',
  7475. loz: '\u25CA',
  7476. spades: '\u2660',
  7477. clubs: '\u2663',
  7478. hearts: '\u2665',
  7479. diams: '\u2666'
  7480. };
  7481. },{}],3:[function(require,module,exports){
  7482. 'use strict';
  7483. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7484. (function (global, factory) {
  7485. (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory(global.acorn = {});
  7486. })(undefined, function (exports) {
  7487. 'use strict';
  7488. // Reserved word lists for various dialects of the language
  7489. var reservedWords = {
  7490. 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
  7491. 5: "class enum extends super const export import",
  7492. 6: "enum",
  7493. strict: "implements interface let package private protected public static yield",
  7494. strictBind: "eval arguments"
  7495. };
  7496. // And the keywords
  7497. 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";
  7498. var keywords = {
  7499. 5: ecma5AndLessKeywords,
  7500. 6: ecma5AndLessKeywords + " const class extends export import super"
  7501. };
  7502. var keywordRelationalOperator = /^in(stanceof)?$/;
  7503. // ## Character categories
  7504. // Big ugly regular expressions that match characters in the
  7505. // whitespace, identifier, and identifier-start categories. These
  7506. // are only applied when a character is found to actually have a
  7507. // code point above 128.
  7508. // Generated by `bin/generate-identifier-regex.js`.
  7509. var nonASCIIidentifierStartChars = '\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEF\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7B9\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC';
  7510. var nonASCIIidentifierChars = '\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F';
  7511. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  7512. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  7513. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  7514. // These are a run-length and offset encoded representation of the
  7515. // >0xffff code points that are a valid part of identifiers. The
  7516. // offset starts at 0x10000, and each pair of numbers represents an
  7517. // offset to the next range, and then a size of the range. They were
  7518. // generated by bin/generate-identifier-regex.js
  7519. // eslint-disable-next-line comma-spacing
  7520. var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 477, 28, 11, 0, 9, 21, 190, 52, 76, 44, 33, 24, 27, 35, 30, 0, 12, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 54, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 86, 26, 230, 43, 117, 63, 32, 0, 257, 0, 11, 39, 8, 0, 22, 0, 12, 39, 3, 3, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 270, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 68, 12, 0, 67, 12, 65, 1, 31, 6129, 15, 754, 9486, 286, 82, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 4149, 196, 60, 67, 1213, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541];
  7521. // eslint-disable-next-line comma-spacing
  7522. var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 525, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 4, 9, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 280, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1016, 45, 17, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 2214, 6, 110, 6, 6, 9, 792487, 239];
  7523. // This has a complexity linear to the value of the code. The
  7524. // assumption is that looking up astral identifier characters is
  7525. // rare.
  7526. function isInAstralSet(code, set) {
  7527. var pos = 0x10000;
  7528. for (var i = 0; i < set.length; i += 2) {
  7529. pos += set[i];
  7530. if (pos > code) {
  7531. return false;
  7532. }
  7533. pos += set[i + 1];
  7534. if (pos >= code) {
  7535. return true;
  7536. }
  7537. }
  7538. }
  7539. // Test whether a given character code starts an identifier.
  7540. function isIdentifierStart(code, astral) {
  7541. if (code < 65) {
  7542. return code === 36;
  7543. }
  7544. if (code < 91) {
  7545. return true;
  7546. }
  7547. if (code < 97) {
  7548. return code === 95;
  7549. }
  7550. if (code < 123) {
  7551. return true;
  7552. }
  7553. if (code <= 0xffff) {
  7554. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  7555. }
  7556. if (astral === false) {
  7557. return false;
  7558. }
  7559. return isInAstralSet(code, astralIdentifierStartCodes);
  7560. }
  7561. // Test whether a given character is part of an identifier.
  7562. function isIdentifierChar(code, astral) {
  7563. if (code < 48) {
  7564. return code === 36;
  7565. }
  7566. if (code < 58) {
  7567. return true;
  7568. }
  7569. if (code < 65) {
  7570. return false;
  7571. }
  7572. if (code < 91) {
  7573. return true;
  7574. }
  7575. if (code < 97) {
  7576. return code === 95;
  7577. }
  7578. if (code < 123) {
  7579. return true;
  7580. }
  7581. if (code <= 0xffff) {
  7582. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  7583. }
  7584. if (astral === false) {
  7585. return false;
  7586. }
  7587. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  7588. }
  7589. // ## Token types
  7590. // The assignment of fine-grained, information-carrying type objects
  7591. // allows the tokenizer to store the information it has about a
  7592. // token in a way that is very cheap for the parser to look up.
  7593. // All token type variables start with an underscore, to make them
  7594. // easy to recognize.
  7595. // The `beforeExpr` property is used to disambiguate between regular
  7596. // expressions and divisions. It is set on all token types that can
  7597. // be followed by an expression (thus, a slash after them would be a
  7598. // regular expression).
  7599. //
  7600. // The `startsExpr` property is used to check if the token ends a
  7601. // `yield` expression. It is set on all token types that either can
  7602. // directly start an expression (like a quotation mark) or can
  7603. // continue an expression (like the body of a string).
  7604. //
  7605. // `isLoop` marks a keyword as starting a loop, which is important
  7606. // to know when parsing a label, in order to allow or disallow
  7607. // continue jumps to that label.
  7608. var TokenType = function TokenType(label, conf) {
  7609. if (conf === void 0) conf = {};
  7610. this.label = label;
  7611. this.keyword = conf.keyword;
  7612. this.beforeExpr = !!conf.beforeExpr;
  7613. this.startsExpr = !!conf.startsExpr;
  7614. this.isLoop = !!conf.isLoop;
  7615. this.isAssign = !!conf.isAssign;
  7616. this.prefix = !!conf.prefix;
  7617. this.postfix = !!conf.postfix;
  7618. this.binop = conf.binop || null;
  7619. this.updateContext = null;
  7620. };
  7621. function binop(name, prec) {
  7622. return new TokenType(name, { beforeExpr: true, binop: prec });
  7623. }
  7624. var beforeExpr = { beforeExpr: true };
  7625. var startsExpr = { startsExpr: true };
  7626. // Map keyword names to token types.
  7627. var keywords$1 = {};
  7628. // Succinct definitions of keyword token types
  7629. function kw(name, options) {
  7630. if (options === void 0) options = {};
  7631. options.keyword = name;
  7632. return keywords$1[name] = new TokenType(name, options);
  7633. }
  7634. var types = {
  7635. num: new TokenType("num", startsExpr),
  7636. regexp: new TokenType("regexp", startsExpr),
  7637. string: new TokenType("string", startsExpr),
  7638. name: new TokenType("name", startsExpr),
  7639. eof: new TokenType("eof"),
  7640. // Punctuation token types.
  7641. bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),
  7642. bracketR: new TokenType("]"),
  7643. braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),
  7644. braceR: new TokenType("}"),
  7645. parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),
  7646. parenR: new TokenType(")"),
  7647. comma: new TokenType(",", beforeExpr),
  7648. semi: new TokenType(";", beforeExpr),
  7649. colon: new TokenType(":", beforeExpr),
  7650. dot: new TokenType("."),
  7651. question: new TokenType("?", beforeExpr),
  7652. arrow: new TokenType("=>", beforeExpr),
  7653. template: new TokenType("template"),
  7654. invalidTemplate: new TokenType("invalidTemplate"),
  7655. ellipsis: new TokenType("...", beforeExpr),
  7656. backQuote: new TokenType("`", startsExpr),
  7657. dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),
  7658. // Operators. These carry several kinds of properties to help the
  7659. // parser use them properly (the presence of these properties is
  7660. // what categorizes them as operators).
  7661. //
  7662. // `binop`, when present, specifies that this operator is a binary
  7663. // operator, and will refer to its precedence.
  7664. //
  7665. // `prefix` and `postfix` mark the operator as a prefix or postfix
  7666. // unary operator.
  7667. //
  7668. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  7669. // binary operators with a very low precedence, that should result
  7670. // in AssignmentExpression nodes.
  7671. eq: new TokenType("=", { beforeExpr: true, isAssign: true }),
  7672. assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),
  7673. incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),
  7674. prefix: new TokenType("!/~", { beforeExpr: true, prefix: true, startsExpr: true }),
  7675. logicalOR: binop("||", 1),
  7676. logicalAND: binop("&&", 2),
  7677. bitwiseOR: binop("|", 3),
  7678. bitwiseXOR: binop("^", 4),
  7679. bitwiseAND: binop("&", 5),
  7680. equality: binop("==/!=/===/!==", 6),
  7681. relational: binop("</>/<=/>=", 7),
  7682. bitShift: binop("<</>>/>>>", 8),
  7683. plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),
  7684. modulo: binop("%", 10),
  7685. star: binop("*", 10),
  7686. slash: binop("/", 10),
  7687. starstar: new TokenType("**", { beforeExpr: true }),
  7688. // Keyword token types.
  7689. _break: kw("break"),
  7690. _case: kw("case", beforeExpr),
  7691. _catch: kw("catch"),
  7692. _continue: kw("continue"),
  7693. _debugger: kw("debugger"),
  7694. _default: kw("default", beforeExpr),
  7695. _do: kw("do", { isLoop: true, beforeExpr: true }),
  7696. _else: kw("else", beforeExpr),
  7697. _finally: kw("finally"),
  7698. _for: kw("for", { isLoop: true }),
  7699. _function: kw("function", startsExpr),
  7700. _if: kw("if"),
  7701. _return: kw("return", beforeExpr),
  7702. _switch: kw("switch"),
  7703. _throw: kw("throw", beforeExpr),
  7704. _try: kw("try"),
  7705. _var: kw("var"),
  7706. _const: kw("const"),
  7707. _while: kw("while", { isLoop: true }),
  7708. _with: kw("with"),
  7709. _new: kw("new", { beforeExpr: true, startsExpr: true }),
  7710. _this: kw("this", startsExpr),
  7711. _super: kw("super", startsExpr),
  7712. _class: kw("class", startsExpr),
  7713. _extends: kw("extends", beforeExpr),
  7714. _export: kw("export"),
  7715. _import: kw("import"),
  7716. _null: kw("null", startsExpr),
  7717. _true: kw("true", startsExpr),
  7718. _false: kw("false", startsExpr),
  7719. _in: kw("in", { beforeExpr: true, binop: 7 }),
  7720. _instanceof: kw("instanceof", { beforeExpr: true, binop: 7 }),
  7721. _typeof: kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true }),
  7722. _void: kw("void", { beforeExpr: true, prefix: true, startsExpr: true }),
  7723. _delete: kw("delete", { beforeExpr: true, prefix: true, startsExpr: true })
  7724. };
  7725. // Matches a whole line break (where CRLF is considered a single
  7726. // line break). Used to count lines.
  7727. var lineBreak = /\r\n?|\n|\u2028|\u2029/;
  7728. var lineBreakG = new RegExp(lineBreak.source, "g");
  7729. function isNewLine(code, ecma2019String) {
  7730. return code === 10 || code === 13 || !ecma2019String && (code === 0x2028 || code === 0x2029);
  7731. }
  7732. var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  7733. var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  7734. var ref = Object.prototype;
  7735. var hasOwnProperty = ref.hasOwnProperty;
  7736. var toString = ref.toString;
  7737. // Checks if an object has a property.
  7738. function has(obj, propName) {
  7739. return hasOwnProperty.call(obj, propName);
  7740. }
  7741. var isArray = Array.isArray || function (obj) {
  7742. return toString.call(obj) === "[object Array]";
  7743. };
  7744. // These are used when `options.locations` is on, for the
  7745. // `startLoc` and `endLoc` properties.
  7746. var Position = function Position(line, col) {
  7747. this.line = line;
  7748. this.column = col;
  7749. };
  7750. Position.prototype.offset = function offset(n) {
  7751. return new Position(this.line, this.column + n);
  7752. };
  7753. var SourceLocation = function SourceLocation(p, start, end) {
  7754. this.start = start;
  7755. this.end = end;
  7756. if (p.sourceFile !== null) {
  7757. this.source = p.sourceFile;
  7758. }
  7759. };
  7760. // The `getLineInfo` function is mostly useful when the
  7761. // `locations` option is off (for performance reasons) and you
  7762. // want to find the line/column position for a given character
  7763. // offset. `input` should be the code string that the offset refers
  7764. // into.
  7765. function getLineInfo(input, offset) {
  7766. for (var line = 1, cur = 0;;) {
  7767. lineBreakG.lastIndex = cur;
  7768. var match = lineBreakG.exec(input);
  7769. if (match && match.index < offset) {
  7770. ++line;
  7771. cur = match.index + match[0].length;
  7772. } else {
  7773. return new Position(line, offset - cur);
  7774. }
  7775. }
  7776. }
  7777. // A second optional argument can be given to further configure
  7778. // the parser process. These options are recognized:
  7779. var defaultOptions = {
  7780. // `ecmaVersion` indicates the ECMAScript version to parse. Must be
  7781. // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10
  7782. // (2019). This influences support for strict mode, the set of
  7783. // reserved words, and support for new syntax features. The default
  7784. // is 9.
  7785. ecmaVersion: 9,
  7786. // `sourceType` indicates the mode the code should be parsed in.
  7787. // Can be either `"script"` or `"module"`. This influences global
  7788. // strict mode and parsing of `import` and `export` declarations.
  7789. sourceType: "script",
  7790. // `onInsertedSemicolon` can be a callback that will be called
  7791. // when a semicolon is automatically inserted. It will be passed
  7792. // th position of the comma as an offset, and if `locations` is
  7793. // enabled, it is given the location as a `{line, column}` object
  7794. // as second argument.
  7795. onInsertedSemicolon: null,
  7796. // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  7797. // trailing commas.
  7798. onTrailingComma: null,
  7799. // By default, reserved words are only enforced if ecmaVersion >= 5.
  7800. // Set `allowReserved` to a boolean value to explicitly turn this on
  7801. // an off. When this option has the value "never", reserved words
  7802. // and keywords can also not be used as property names.
  7803. allowReserved: null,
  7804. // When enabled, a return at the top level is not considered an
  7805. // error.
  7806. allowReturnOutsideFunction: false,
  7807. // When enabled, import/export statements are not constrained to
  7808. // appearing at the top of the program.
  7809. allowImportExportEverywhere: false,
  7810. // When enabled, await identifiers are allowed to appear at the top-level scope,
  7811. // but they are still not allowed in non-async functions.
  7812. allowAwaitOutsideFunction: false,
  7813. // When enabled, hashbang directive in the beginning of file
  7814. // is allowed and treated as a line comment.
  7815. allowHashBang: false,
  7816. // When `locations` is on, `loc` properties holding objects with
  7817. // `start` and `end` properties in `{line, column}` form (with
  7818. // line being 1-based and column 0-based) will be attached to the
  7819. // nodes.
  7820. locations: false,
  7821. // A function can be passed as `onToken` option, which will
  7822. // cause Acorn to call that function with object in the same
  7823. // format as tokens returned from `tokenizer().getToken()`. Note
  7824. // that you are not allowed to call the parser from the
  7825. // callback—that will corrupt its internal state.
  7826. onToken: null,
  7827. // A function can be passed as `onComment` option, which will
  7828. // cause Acorn to call that function with `(block, text, start,
  7829. // end)` parameters whenever a comment is skipped. `block` is a
  7830. // boolean indicating whether this is a block (`/* */`) comment,
  7831. // `text` is the content of the comment, and `start` and `end` are
  7832. // character offsets that denote the start and end of the comment.
  7833. // When the `locations` option is on, two more parameters are
  7834. // passed, the full `{line, column}` locations of the start and
  7835. // end of the comments. Note that you are not allowed to call the
  7836. // parser from the callback—that will corrupt its internal state.
  7837. onComment: null,
  7838. // Nodes have their start and end characters offsets recorded in
  7839. // `start` and `end` properties (directly on the node, rather than
  7840. // the `loc` object, which holds line/column data. To also add a
  7841. // [semi-standardized][range] `range` property holding a `[start,
  7842. // end]` array with the same numbers, set the `ranges` option to
  7843. // `true`.
  7844. //
  7845. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  7846. ranges: false,
  7847. // It is possible to parse multiple files into a single AST by
  7848. // passing the tree produced by parsing the first file as
  7849. // `program` option in subsequent parses. This will add the
  7850. // toplevel forms of the parsed file to the `Program` (top) node
  7851. // of an existing parse tree.
  7852. program: null,
  7853. // When `locations` is on, you can pass this to record the source
  7854. // file in every node's `loc` object.
  7855. sourceFile: null,
  7856. // This value, if given, is stored in every node, whether
  7857. // `locations` is on or off.
  7858. directSourceFile: null,
  7859. // When enabled, parenthesized expressions are represented by
  7860. // (non-standard) ParenthesizedExpression nodes
  7861. preserveParens: false
  7862. };
  7863. // Interpret and default an options object
  7864. function getOptions(opts) {
  7865. var options = {};
  7866. for (var opt in defaultOptions) {
  7867. options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
  7868. }
  7869. if (options.ecmaVersion >= 2015) {
  7870. options.ecmaVersion -= 2009;
  7871. }
  7872. if (options.allowReserved == null) {
  7873. options.allowReserved = options.ecmaVersion < 5;
  7874. }
  7875. if (isArray(options.onToken)) {
  7876. var tokens = options.onToken;
  7877. options.onToken = function (token) {
  7878. return tokens.push(token);
  7879. };
  7880. }
  7881. if (isArray(options.onComment)) {
  7882. options.onComment = pushComment(options, options.onComment);
  7883. }
  7884. return options;
  7885. }
  7886. function pushComment(options, array) {
  7887. return function (block, text, start, end, startLoc, endLoc) {
  7888. var comment = {
  7889. type: block ? "Block" : "Line",
  7890. value: text,
  7891. start: start,
  7892. end: end
  7893. };
  7894. if (options.locations) {
  7895. comment.loc = new SourceLocation(this, startLoc, endLoc);
  7896. }
  7897. if (options.ranges) {
  7898. comment.range = [start, end];
  7899. }
  7900. array.push(comment);
  7901. };
  7902. }
  7903. // Each scope gets a bitset that may contain these flags
  7904. var SCOPE_TOP = 1;
  7905. var SCOPE_FUNCTION = 2;
  7906. var SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION;
  7907. var SCOPE_ASYNC = 4;
  7908. var SCOPE_GENERATOR = 8;
  7909. var SCOPE_ARROW = 16;
  7910. var SCOPE_SIMPLE_CATCH = 32;
  7911. var SCOPE_SUPER = 64;
  7912. var SCOPE_DIRECT_SUPER = 128;
  7913. function functionFlags(async, generator) {
  7914. return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0);
  7915. }
  7916. // Used in checkLVal and declareName to determine the type of a binding
  7917. var BIND_NONE = 0;
  7918. var BIND_VAR = 1;
  7919. var BIND_LEXICAL = 2;
  7920. var BIND_FUNCTION = 3;
  7921. var BIND_SIMPLE_CATCH = 4;
  7922. var BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
  7923. function keywordRegexp(words) {
  7924. return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$");
  7925. }
  7926. var Parser = function Parser(options, input, startPos) {
  7927. this.options = options = getOptions(options);
  7928. this.sourceFile = options.sourceFile;
  7929. this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]);
  7930. var reserved = "";
  7931. if (!options.allowReserved) {
  7932. for (var v = options.ecmaVersion;; v--) {
  7933. if (reserved = reservedWords[v]) {
  7934. break;
  7935. }
  7936. }
  7937. if (options.sourceType === "module") {
  7938. reserved += " await";
  7939. }
  7940. }
  7941. this.reservedWords = keywordRegexp(reserved);
  7942. var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
  7943. this.reservedWordsStrict = keywordRegexp(reservedStrict);
  7944. this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind);
  7945. this.input = String(input);
  7946. // Used to signal to callers of `readWord1` whether the word
  7947. // contained any escape sequences. This is needed because words with
  7948. // escape sequences must not be interpreted as keywords.
  7949. this.containsEsc = false;
  7950. // Set up token state
  7951. // The current position of the tokenizer in the input.
  7952. if (startPos) {
  7953. this.pos = startPos;
  7954. this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
  7955. this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
  7956. } else {
  7957. this.pos = this.lineStart = 0;
  7958. this.curLine = 1;
  7959. }
  7960. // Properties of the current token:
  7961. // Its type
  7962. this.type = types.eof;
  7963. // For tokens that include more information than their type, the value
  7964. this.value = null;
  7965. // Its start and end offset
  7966. this.start = this.end = this.pos;
  7967. // And, if locations are used, the {line, column} object
  7968. // corresponding to those offsets
  7969. this.startLoc = this.endLoc = this.curPosition();
  7970. // Position information for the previous token
  7971. this.lastTokEndLoc = this.lastTokStartLoc = null;
  7972. this.lastTokStart = this.lastTokEnd = this.pos;
  7973. // The context stack is used to superficially track syntactic
  7974. // context to predict whether a regular expression is allowed in a
  7975. // given position.
  7976. this.context = this.initialContext();
  7977. this.exprAllowed = true;
  7978. // Figure out if it's a module code.
  7979. this.inModule = options.sourceType === "module";
  7980. this.strict = this.inModule || this.strictDirective(this.pos);
  7981. // Used to signify the start of a potential arrow function
  7982. this.potentialArrowAt = -1;
  7983. // Positions to delayed-check that yield/await does not exist in default parameters.
  7984. this.yieldPos = this.awaitPos = 0;
  7985. // Labels in scope.
  7986. this.labels = [];
  7987. // If enabled, skip leading hashbang line.
  7988. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") {
  7989. this.skipLineComment(2);
  7990. }
  7991. // Scope tracking for duplicate variable names (see scope.js)
  7992. this.scopeStack = [];
  7993. this.enterScope(SCOPE_TOP);
  7994. // For RegExp validation
  7995. this.regexpState = null;
  7996. };
  7997. var prototypeAccessors = { inFunction: { configurable: true }, inGenerator: { configurable: true }, inAsync: { configurable: true }, allowSuper: { configurable: true }, allowDirectSuper: { configurable: true } };
  7998. Parser.prototype.parse = function parse() {
  7999. var node = this.options.program || this.startNode();
  8000. this.nextToken();
  8001. return this.parseTopLevel(node);
  8002. };
  8003. prototypeAccessors.inFunction.get = function () {
  8004. return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
  8005. };
  8006. prototypeAccessors.inGenerator.get = function () {
  8007. return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0;
  8008. };
  8009. prototypeAccessors.inAsync.get = function () {
  8010. return (this.currentVarScope().flags & SCOPE_ASYNC) > 0;
  8011. };
  8012. prototypeAccessors.allowSuper.get = function () {
  8013. return (this.currentThisScope().flags & SCOPE_SUPER) > 0;
  8014. };
  8015. prototypeAccessors.allowDirectSuper.get = function () {
  8016. return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
  8017. };
  8018. // Switch to a getter for 7.0.0.
  8019. Parser.prototype.inNonArrowFunction = function inNonArrowFunction() {
  8020. return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0;
  8021. };
  8022. Parser.extend = function extend() {
  8023. var plugins = [],
  8024. len = arguments.length;
  8025. while (len--) {
  8026. plugins[len] = arguments[len];
  8027. }var cls = this;
  8028. for (var i = 0; i < plugins.length; i++) {
  8029. cls = plugins[i](cls);
  8030. }
  8031. return cls;
  8032. };
  8033. Parser.parse = function parse(input, options) {
  8034. return new this(options, input).parse();
  8035. };
  8036. Parser.parseExpressionAt = function parseExpressionAt(input, pos, options) {
  8037. var parser = new this(options, input, pos);
  8038. parser.nextToken();
  8039. return parser.parseExpression();
  8040. };
  8041. Parser.tokenizer = function tokenizer(input, options) {
  8042. return new this(options, input);
  8043. };
  8044. Object.defineProperties(Parser.prototype, prototypeAccessors);
  8045. var pp = Parser.prototype;
  8046. // ## Parser utilities
  8047. var literal = /^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;
  8048. pp.strictDirective = function (start) {
  8049. var this$1 = this;
  8050. for (;;) {
  8051. skipWhiteSpace.lastIndex = start;
  8052. start += skipWhiteSpace.exec(this$1.input)[0].length;
  8053. var match = literal.exec(this$1.input.slice(start));
  8054. if (!match) {
  8055. return false;
  8056. }
  8057. if ((match[1] || match[2]) === "use strict") {
  8058. return true;
  8059. }
  8060. start += match[0].length;
  8061. }
  8062. };
  8063. // Predicate that tests whether the next token is of the given
  8064. // type, and if yes, consumes it as a side effect.
  8065. pp.eat = function (type) {
  8066. if (this.type === type) {
  8067. this.next();
  8068. return true;
  8069. } else {
  8070. return false;
  8071. }
  8072. };
  8073. // Tests whether parsed token is a contextual keyword.
  8074. pp.isContextual = function (name) {
  8075. return this.type === types.name && this.value === name && !this.containsEsc;
  8076. };
  8077. // Consumes contextual keyword if possible.
  8078. pp.eatContextual = function (name) {
  8079. if (!this.isContextual(name)) {
  8080. return false;
  8081. }
  8082. this.next();
  8083. return true;
  8084. };
  8085. // Asserts that following token is given contextual keyword.
  8086. pp.expectContextual = function (name) {
  8087. if (!this.eatContextual(name)) {
  8088. this.unexpected();
  8089. }
  8090. };
  8091. // Test whether a semicolon can be inserted at the current position.
  8092. pp.canInsertSemicolon = function () {
  8093. return this.type === types.eof || this.type === types.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
  8094. };
  8095. pp.insertSemicolon = function () {
  8096. if (this.canInsertSemicolon()) {
  8097. if (this.options.onInsertedSemicolon) {
  8098. this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
  8099. }
  8100. return true;
  8101. }
  8102. };
  8103. // Consume a semicolon, or, failing that, see if we are allowed to
  8104. // pretend that there is a semicolon at this position.
  8105. pp.semicolon = function () {
  8106. if (!this.eat(types.semi) && !this.insertSemicolon()) {
  8107. this.unexpected();
  8108. }
  8109. };
  8110. pp.afterTrailingComma = function (tokType, notNext) {
  8111. if (this.type === tokType) {
  8112. if (this.options.onTrailingComma) {
  8113. this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
  8114. }
  8115. if (!notNext) {
  8116. this.next();
  8117. }
  8118. return true;
  8119. }
  8120. };
  8121. // Expect a token of a given type. If found, consume it, otherwise,
  8122. // raise an unexpected token error.
  8123. pp.expect = function (type) {
  8124. this.eat(type) || this.unexpected();
  8125. };
  8126. // Raise an unexpected token error.
  8127. pp.unexpected = function (pos) {
  8128. this.raise(pos != null ? pos : this.start, "Unexpected token");
  8129. };
  8130. function DestructuringErrors() {
  8131. this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1;
  8132. }
  8133. pp.checkPatternErrors = function (refDestructuringErrors, isAssign) {
  8134. if (!refDestructuringErrors) {
  8135. return;
  8136. }
  8137. if (refDestructuringErrors.trailingComma > -1) {
  8138. this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element");
  8139. }
  8140. var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
  8141. if (parens > -1) {
  8142. this.raiseRecoverable(parens, "Parenthesized pattern");
  8143. }
  8144. };
  8145. pp.checkExpressionErrors = function (refDestructuringErrors, andThrow) {
  8146. if (!refDestructuringErrors) {
  8147. return false;
  8148. }
  8149. var shorthandAssign = refDestructuringErrors.shorthandAssign;
  8150. var doubleProto = refDestructuringErrors.doubleProto;
  8151. if (!andThrow) {
  8152. return shorthandAssign >= 0 || doubleProto >= 0;
  8153. }
  8154. if (shorthandAssign >= 0) {
  8155. this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns");
  8156. }
  8157. if (doubleProto >= 0) {
  8158. this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property");
  8159. }
  8160. };
  8161. pp.checkYieldAwaitInDefaultParams = function () {
  8162. if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) {
  8163. this.raise(this.yieldPos, "Yield expression cannot be a default value");
  8164. }
  8165. if (this.awaitPos) {
  8166. this.raise(this.awaitPos, "Await expression cannot be a default value");
  8167. }
  8168. };
  8169. pp.isSimpleAssignTarget = function (expr) {
  8170. if (expr.type === "ParenthesizedExpression") {
  8171. return this.isSimpleAssignTarget(expr.expression);
  8172. }
  8173. return expr.type === "Identifier" || expr.type === "MemberExpression";
  8174. };
  8175. var pp$1 = Parser.prototype;
  8176. // ### Statement parsing
  8177. // Parse a program. Initializes the parser, reads any number of
  8178. // statements, and wraps them in a Program node. Optionally takes a
  8179. // `program` argument. If present, the statements will be appended
  8180. // to its body instead of creating a new node.
  8181. pp$1.parseTopLevel = function (node) {
  8182. var this$1 = this;
  8183. var exports = {};
  8184. if (!node.body) {
  8185. node.body = [];
  8186. }
  8187. while (this.type !== types.eof) {
  8188. var stmt = this$1.parseStatement(null, true, exports);
  8189. node.body.push(stmt);
  8190. }
  8191. this.adaptDirectivePrologue(node.body);
  8192. this.next();
  8193. if (this.options.ecmaVersion >= 6) {
  8194. node.sourceType = this.options.sourceType;
  8195. }
  8196. return this.finishNode(node, "Program");
  8197. };
  8198. var loopLabel = { kind: "loop" };
  8199. var switchLabel = { kind: "switch" };
  8200. pp$1.isLet = function () {
  8201. if (this.options.ecmaVersion < 6 || !this.isContextual("let")) {
  8202. return false;
  8203. }
  8204. skipWhiteSpace.lastIndex = this.pos;
  8205. var skip = skipWhiteSpace.exec(this.input);
  8206. var next = this.pos + skip[0].length,
  8207. nextCh = this.input.charCodeAt(next);
  8208. if (nextCh === 91 || nextCh === 123) {
  8209. return true;
  8210. } // '{' and '['
  8211. if (isIdentifierStart(nextCh, true)) {
  8212. var pos = next + 1;
  8213. while (isIdentifierChar(this.input.charCodeAt(pos), true)) {
  8214. ++pos;
  8215. }
  8216. var ident = this.input.slice(next, pos);
  8217. if (!keywordRelationalOperator.test(ident)) {
  8218. return true;
  8219. }
  8220. }
  8221. return false;
  8222. };
  8223. // check 'async [no LineTerminator here] function'
  8224. // - 'async /*foo*/ function' is OK.
  8225. // - 'async /*\n*/ function' is invalid.
  8226. pp$1.isAsyncFunction = function () {
  8227. if (this.options.ecmaVersion < 8 || !this.isContextual("async")) {
  8228. return false;
  8229. }
  8230. skipWhiteSpace.lastIndex = this.pos;
  8231. var skip = skipWhiteSpace.exec(this.input);
  8232. var next = this.pos + skip[0].length;
  8233. return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)));
  8234. };
  8235. // Parse a single statement.
  8236. //
  8237. // If expecting a statement and finding a slash operator, parse a
  8238. // regular expression literal. This is to handle cases like
  8239. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  8240. // does not help.
  8241. pp$1.parseStatement = function (context, topLevel, exports) {
  8242. var starttype = this.type,
  8243. node = this.startNode(),
  8244. kind;
  8245. if (this.isLet()) {
  8246. starttype = types._var;
  8247. kind = "let";
  8248. }
  8249. // Most types of statements are recognized by the keyword they
  8250. // start with. Many are trivial to parse, some require a bit of
  8251. // complexity.
  8252. switch (starttype) {
  8253. case types._break:case types._continue:
  8254. return this.parseBreakContinueStatement(node, starttype.keyword);
  8255. case types._debugger:
  8256. return this.parseDebuggerStatement(node);
  8257. case types._do:
  8258. return this.parseDoStatement(node);
  8259. case types._for:
  8260. return this.parseForStatement(node);
  8261. case types._function:
  8262. if (context && (this.strict || context !== "if") && this.options.ecmaVersion >= 6) {
  8263. this.unexpected();
  8264. }
  8265. return this.parseFunctionStatement(node, false, !context);
  8266. case types._class:
  8267. if (context) {
  8268. this.unexpected();
  8269. }
  8270. return this.parseClass(node, true);
  8271. case types._if:
  8272. return this.parseIfStatement(node);
  8273. case types._return:
  8274. return this.parseReturnStatement(node);
  8275. case types._switch:
  8276. return this.parseSwitchStatement(node);
  8277. case types._throw:
  8278. return this.parseThrowStatement(node);
  8279. case types._try:
  8280. return this.parseTryStatement(node);
  8281. case types._const:case types._var:
  8282. kind = kind || this.value;
  8283. if (context && kind !== "var") {
  8284. this.unexpected();
  8285. }
  8286. return this.parseVarStatement(node, kind);
  8287. case types._while:
  8288. return this.parseWhileStatement(node);
  8289. case types._with:
  8290. return this.parseWithStatement(node);
  8291. case types.braceL:
  8292. return this.parseBlock(true, node);
  8293. case types.semi:
  8294. return this.parseEmptyStatement(node);
  8295. case types._export:
  8296. case types._import:
  8297. if (!this.options.allowImportExportEverywhere) {
  8298. if (!topLevel) {
  8299. this.raise(this.start, "'import' and 'export' may only appear at the top level");
  8300. }
  8301. if (!this.inModule) {
  8302. this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
  8303. }
  8304. }
  8305. return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports);
  8306. // If the statement does not start with a statement keyword or a
  8307. // brace, it's an ExpressionStatement or LabeledStatement. We
  8308. // simply start parsing an expression, and afterwards, if the
  8309. // next token is a colon and the expression was a simple
  8310. // Identifier node, we switch to interpreting it as a label.
  8311. default:
  8312. if (this.isAsyncFunction()) {
  8313. if (context) {
  8314. this.unexpected();
  8315. }
  8316. this.next();
  8317. return this.parseFunctionStatement(node, true, !context);
  8318. }
  8319. var maybeName = this.value,
  8320. expr = this.parseExpression();
  8321. if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) {
  8322. return this.parseLabeledStatement(node, maybeName, expr, context);
  8323. } else {
  8324. return this.parseExpressionStatement(node, expr);
  8325. }
  8326. }
  8327. };
  8328. pp$1.parseBreakContinueStatement = function (node, keyword) {
  8329. var this$1 = this;
  8330. var isBreak = keyword === "break";
  8331. this.next();
  8332. if (this.eat(types.semi) || this.insertSemicolon()) {
  8333. node.label = null;
  8334. } else if (this.type !== types.name) {
  8335. this.unexpected();
  8336. } else {
  8337. node.label = this.parseIdent();
  8338. this.semicolon();
  8339. }
  8340. // Verify that there is an actual destination to break or
  8341. // continue to.
  8342. var i = 0;
  8343. for (; i < this.labels.length; ++i) {
  8344. var lab = this$1.labels[i];
  8345. if (node.label == null || lab.name === node.label.name) {
  8346. if (lab.kind != null && (isBreak || lab.kind === "loop")) {
  8347. break;
  8348. }
  8349. if (node.label && isBreak) {
  8350. break;
  8351. }
  8352. }
  8353. }
  8354. if (i === this.labels.length) {
  8355. this.raise(node.start, "Unsyntactic " + keyword);
  8356. }
  8357. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  8358. };
  8359. pp$1.parseDebuggerStatement = function (node) {
  8360. this.next();
  8361. this.semicolon();
  8362. return this.finishNode(node, "DebuggerStatement");
  8363. };
  8364. pp$1.parseDoStatement = function (node) {
  8365. this.next();
  8366. this.labels.push(loopLabel);
  8367. node.body = this.parseStatement("do");
  8368. this.labels.pop();
  8369. this.expect(types._while);
  8370. node.test = this.parseParenExpression();
  8371. if (this.options.ecmaVersion >= 6) {
  8372. this.eat(types.semi);
  8373. } else {
  8374. this.semicolon();
  8375. }
  8376. return this.finishNode(node, "DoWhileStatement");
  8377. };
  8378. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  8379. // loop is non-trivial. Basically, we have to parse the init `var`
  8380. // statement or expression, disallowing the `in` operator (see
  8381. // the second parameter to `parseExpression`), and then check
  8382. // whether the next token is `in` or `of`. When there is no init
  8383. // part (semicolon immediately after the opening parenthesis), it
  8384. // is a regular `for` loop.
  8385. pp$1.parseForStatement = function (node) {
  8386. this.next();
  8387. var awaitAt = this.options.ecmaVersion >= 9 && (this.inAsync || !this.inFunction && this.options.allowAwaitOutsideFunction) && this.eatContextual("await") ? this.lastTokStart : -1;
  8388. this.labels.push(loopLabel);
  8389. this.enterScope(0);
  8390. this.expect(types.parenL);
  8391. if (this.type === types.semi) {
  8392. if (awaitAt > -1) {
  8393. this.unexpected(awaitAt);
  8394. }
  8395. return this.parseFor(node, null);
  8396. }
  8397. var isLet = this.isLet();
  8398. if (this.type === types._var || this.type === types._const || isLet) {
  8399. var init$1 = this.startNode(),
  8400. kind = isLet ? "let" : this.value;
  8401. this.next();
  8402. this.parseVar(init$1, true, kind);
  8403. this.finishNode(init$1, "VariableDeclaration");
  8404. if ((this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init$1.declarations.length === 1 && !(kind !== "var" && init$1.declarations[0].init)) {
  8405. if (this.options.ecmaVersion >= 9) {
  8406. if (this.type === types._in) {
  8407. if (awaitAt > -1) {
  8408. this.unexpected(awaitAt);
  8409. }
  8410. } else {
  8411. node.await = awaitAt > -1;
  8412. }
  8413. }
  8414. return this.parseForIn(node, init$1);
  8415. }
  8416. if (awaitAt > -1) {
  8417. this.unexpected(awaitAt);
  8418. }
  8419. return this.parseFor(node, init$1);
  8420. }
  8421. var refDestructuringErrors = new DestructuringErrors();
  8422. var init = this.parseExpression(true, refDestructuringErrors);
  8423. if (this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {
  8424. if (this.options.ecmaVersion >= 9) {
  8425. if (this.type === types._in) {
  8426. if (awaitAt > -1) {
  8427. this.unexpected(awaitAt);
  8428. }
  8429. } else {
  8430. node.await = awaitAt > -1;
  8431. }
  8432. }
  8433. this.toAssignable(init, false, refDestructuringErrors);
  8434. this.checkLVal(init);
  8435. return this.parseForIn(node, init);
  8436. } else {
  8437. this.checkExpressionErrors(refDestructuringErrors, true);
  8438. }
  8439. if (awaitAt > -1) {
  8440. this.unexpected(awaitAt);
  8441. }
  8442. return this.parseFor(node, init);
  8443. };
  8444. pp$1.parseFunctionStatement = function (node, isAsync, declarationPosition) {
  8445. this.next();
  8446. return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync);
  8447. };
  8448. pp$1.parseIfStatement = function (node) {
  8449. this.next();
  8450. node.test = this.parseParenExpression();
  8451. // allow function declarations in branches, but only in non-strict mode
  8452. node.consequent = this.parseStatement("if");
  8453. node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
  8454. return this.finishNode(node, "IfStatement");
  8455. };
  8456. pp$1.parseReturnStatement = function (node) {
  8457. if (!this.inFunction && !this.options.allowReturnOutsideFunction) {
  8458. this.raise(this.start, "'return' outside of function");
  8459. }
  8460. this.next();
  8461. // In `return` (and `break`/`continue`), the keywords with
  8462. // optional arguments, we eagerly look for a semicolon or the
  8463. // possibility to insert one.
  8464. if (this.eat(types.semi) || this.insertSemicolon()) {
  8465. node.argument = null;
  8466. } else {
  8467. node.argument = this.parseExpression();this.semicolon();
  8468. }
  8469. return this.finishNode(node, "ReturnStatement");
  8470. };
  8471. pp$1.parseSwitchStatement = function (node) {
  8472. var this$1 = this;
  8473. this.next();
  8474. node.discriminant = this.parseParenExpression();
  8475. node.cases = [];
  8476. this.expect(types.braceL);
  8477. this.labels.push(switchLabel);
  8478. this.enterScope(0);
  8479. // Statements under must be grouped (by label) in SwitchCase
  8480. // nodes. `cur` is used to keep the node that we are currently
  8481. // adding statements to.
  8482. var cur;
  8483. for (var sawDefault = false; this.type !== types.braceR;) {
  8484. if (this$1.type === types._case || this$1.type === types._default) {
  8485. var isCase = this$1.type === types._case;
  8486. if (cur) {
  8487. this$1.finishNode(cur, "SwitchCase");
  8488. }
  8489. node.cases.push(cur = this$1.startNode());
  8490. cur.consequent = [];
  8491. this$1.next();
  8492. if (isCase) {
  8493. cur.test = this$1.parseExpression();
  8494. } else {
  8495. if (sawDefault) {
  8496. this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses");
  8497. }
  8498. sawDefault = true;
  8499. cur.test = null;
  8500. }
  8501. this$1.expect(types.colon);
  8502. } else {
  8503. if (!cur) {
  8504. this$1.unexpected();
  8505. }
  8506. cur.consequent.push(this$1.parseStatement(null));
  8507. }
  8508. }
  8509. this.exitScope();
  8510. if (cur) {
  8511. this.finishNode(cur, "SwitchCase");
  8512. }
  8513. this.next(); // Closing brace
  8514. this.labels.pop();
  8515. return this.finishNode(node, "SwitchStatement");
  8516. };
  8517. pp$1.parseThrowStatement = function (node) {
  8518. this.next();
  8519. if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) {
  8520. this.raise(this.lastTokEnd, "Illegal newline after throw");
  8521. }
  8522. node.argument = this.parseExpression();
  8523. this.semicolon();
  8524. return this.finishNode(node, "ThrowStatement");
  8525. };
  8526. // Reused empty array added for node fields that are always empty.
  8527. var empty = [];
  8528. pp$1.parseTryStatement = function (node) {
  8529. this.next();
  8530. node.block = this.parseBlock();
  8531. node.handler = null;
  8532. if (this.type === types._catch) {
  8533. var clause = this.startNode();
  8534. this.next();
  8535. if (this.eat(types.parenL)) {
  8536. clause.param = this.parseBindingAtom();
  8537. var simple = clause.param.type === "Identifier";
  8538. this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
  8539. this.checkLVal(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
  8540. this.expect(types.parenR);
  8541. } else {
  8542. if (this.options.ecmaVersion < 10) {
  8543. this.unexpected();
  8544. }
  8545. clause.param = null;
  8546. this.enterScope(0);
  8547. }
  8548. clause.body = this.parseBlock(false);
  8549. this.exitScope();
  8550. node.handler = this.finishNode(clause, "CatchClause");
  8551. }
  8552. node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
  8553. if (!node.handler && !node.finalizer) {
  8554. this.raise(node.start, "Missing catch or finally clause");
  8555. }
  8556. return this.finishNode(node, "TryStatement");
  8557. };
  8558. pp$1.parseVarStatement = function (node, kind) {
  8559. this.next();
  8560. this.parseVar(node, false, kind);
  8561. this.semicolon();
  8562. return this.finishNode(node, "VariableDeclaration");
  8563. };
  8564. pp$1.parseWhileStatement = function (node) {
  8565. this.next();
  8566. node.test = this.parseParenExpression();
  8567. this.labels.push(loopLabel);
  8568. node.body = this.parseStatement("while");
  8569. this.labels.pop();
  8570. return this.finishNode(node, "WhileStatement");
  8571. };
  8572. pp$1.parseWithStatement = function (node) {
  8573. if (this.strict) {
  8574. this.raise(this.start, "'with' in strict mode");
  8575. }
  8576. this.next();
  8577. node.object = this.parseParenExpression();
  8578. node.body = this.parseStatement("with");
  8579. return this.finishNode(node, "WithStatement");
  8580. };
  8581. pp$1.parseEmptyStatement = function (node) {
  8582. this.next();
  8583. return this.finishNode(node, "EmptyStatement");
  8584. };
  8585. pp$1.parseLabeledStatement = function (node, maybeName, expr, context) {
  8586. var this$1 = this;
  8587. for (var i$1 = 0, list = this$1.labels; i$1 < list.length; i$1 += 1) {
  8588. var label = list[i$1];
  8589. if (label.name === maybeName) {
  8590. this$1.raise(expr.start, "Label '" + maybeName + "' is already declared");
  8591. }
  8592. }
  8593. var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
  8594. for (var i = this.labels.length - 1; i >= 0; i--) {
  8595. var label$1 = this$1.labels[i];
  8596. if (label$1.statementStart === node.start) {
  8597. // Update information about previous labels on this node
  8598. label$1.statementStart = this$1.start;
  8599. label$1.kind = kind;
  8600. } else {
  8601. break;
  8602. }
  8603. }
  8604. this.labels.push({ name: maybeName, kind: kind, statementStart: this.start });
  8605. node.body = this.parseStatement(context);
  8606. if (node.body.type === "ClassDeclaration" || node.body.type === "VariableDeclaration" && node.body.kind !== "var" || node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator || node.body.async)) {
  8607. this.raiseRecoverable(node.body.start, "Invalid labeled declaration");
  8608. }
  8609. this.labels.pop();
  8610. node.label = expr;
  8611. return this.finishNode(node, "LabeledStatement");
  8612. };
  8613. pp$1.parseExpressionStatement = function (node, expr) {
  8614. node.expression = expr;
  8615. this.semicolon();
  8616. return this.finishNode(node, "ExpressionStatement");
  8617. };
  8618. // Parse a semicolon-enclosed block of statements, handling `"use
  8619. // strict"` declarations when `allowStrict` is true (used for
  8620. // function bodies).
  8621. pp$1.parseBlock = function (createNewLexicalScope, node) {
  8622. var this$1 = this;
  8623. if (createNewLexicalScope === void 0) createNewLexicalScope = true;
  8624. if (node === void 0) node = this.startNode();
  8625. node.body = [];
  8626. this.expect(types.braceL);
  8627. if (createNewLexicalScope) {
  8628. this.enterScope(0);
  8629. }
  8630. while (!this.eat(types.braceR)) {
  8631. var stmt = this$1.parseStatement(null);
  8632. node.body.push(stmt);
  8633. }
  8634. if (createNewLexicalScope) {
  8635. this.exitScope();
  8636. }
  8637. return this.finishNode(node, "BlockStatement");
  8638. };
  8639. // Parse a regular `for` loop. The disambiguation code in
  8640. // `parseStatement` will already have parsed the init statement or
  8641. // expression.
  8642. pp$1.parseFor = function (node, init) {
  8643. node.init = init;
  8644. this.expect(types.semi);
  8645. node.test = this.type === types.semi ? null : this.parseExpression();
  8646. this.expect(types.semi);
  8647. node.update = this.type === types.parenR ? null : this.parseExpression();
  8648. this.expect(types.parenR);
  8649. this.exitScope();
  8650. node.body = this.parseStatement("for");
  8651. this.labels.pop();
  8652. return this.finishNode(node, "ForStatement");
  8653. };
  8654. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  8655. // same from parser's perspective.
  8656. pp$1.parseForIn = function (node, init) {
  8657. var type = this.type === types._in ? "ForInStatement" : "ForOfStatement";
  8658. this.next();
  8659. if (type === "ForInStatement") {
  8660. if (init.type === "AssignmentPattern" || init.type === "VariableDeclaration" && init.declarations[0].init != null && (this.strict || init.declarations[0].id.type !== "Identifier")) {
  8661. this.raise(init.start, "Invalid assignment in for-in loop head");
  8662. }
  8663. }
  8664. node.left = init;
  8665. node.right = type === "ForInStatement" ? this.parseExpression() : this.parseMaybeAssign();
  8666. this.expect(types.parenR);
  8667. this.exitScope();
  8668. node.body = this.parseStatement("for");
  8669. this.labels.pop();
  8670. return this.finishNode(node, type);
  8671. };
  8672. // Parse a list of variable declarations.
  8673. pp$1.parseVar = function (node, isFor, kind) {
  8674. var this$1 = this;
  8675. node.declarations = [];
  8676. node.kind = kind;
  8677. for (;;) {
  8678. var decl = this$1.startNode();
  8679. this$1.parseVarId(decl, kind);
  8680. if (this$1.eat(types.eq)) {
  8681. decl.init = this$1.parseMaybeAssign(isFor);
  8682. } else if (kind === "const" && !(this$1.type === types._in || this$1.options.ecmaVersion >= 6 && this$1.isContextual("of"))) {
  8683. this$1.unexpected();
  8684. } else if (decl.id.type !== "Identifier" && !(isFor && (this$1.type === types._in || this$1.isContextual("of")))) {
  8685. this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value");
  8686. } else {
  8687. decl.init = null;
  8688. }
  8689. node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"));
  8690. if (!this$1.eat(types.comma)) {
  8691. break;
  8692. }
  8693. }
  8694. return node;
  8695. };
  8696. pp$1.parseVarId = function (decl, kind) {
  8697. decl.id = this.parseBindingAtom(kind);
  8698. this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
  8699. };
  8700. var FUNC_STATEMENT = 1;
  8701. var FUNC_HANGING_STATEMENT = 2;
  8702. var FUNC_NULLABLE_ID = 4;
  8703. // Parse a function declaration or literal (depending on the
  8704. // `isStatement` parameter).
  8705. pp$1.parseFunction = function (node, statement, allowExpressionBody, isAsync) {
  8706. this.initFunction(node);
  8707. if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
  8708. node.generator = this.eat(types.star);
  8709. }
  8710. if (this.options.ecmaVersion >= 8) {
  8711. node.async = !!isAsync;
  8712. }
  8713. if (statement & FUNC_STATEMENT) {
  8714. node.id = statement & FUNC_NULLABLE_ID && this.type !== types.name ? null : this.parseIdent();
  8715. if (node.id && !(statement & FUNC_HANGING_STATEMENT)) {
  8716. this.checkLVal(node.id, this.inModule && !this.inFunction ? BIND_LEXICAL : BIND_FUNCTION);
  8717. }
  8718. }
  8719. var oldYieldPos = this.yieldPos,
  8720. oldAwaitPos = this.awaitPos;
  8721. this.yieldPos = 0;
  8722. this.awaitPos = 0;
  8723. this.enterScope(functionFlags(node.async, node.generator));
  8724. if (!(statement & FUNC_STATEMENT)) {
  8725. node.id = this.type === types.name ? this.parseIdent() : null;
  8726. }
  8727. this.parseFunctionParams(node);
  8728. this.parseFunctionBody(node, allowExpressionBody);
  8729. this.yieldPos = oldYieldPos;
  8730. this.awaitPos = oldAwaitPos;
  8731. return this.finishNode(node, statement & FUNC_STATEMENT ? "FunctionDeclaration" : "FunctionExpression");
  8732. };
  8733. pp$1.parseFunctionParams = function (node) {
  8734. this.expect(types.parenL);
  8735. node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
  8736. this.checkYieldAwaitInDefaultParams();
  8737. };
  8738. // Parse a class declaration or literal (depending on the
  8739. // `isStatement` parameter).
  8740. pp$1.parseClass = function (node, isStatement) {
  8741. var this$1 = this;
  8742. this.next();
  8743. this.parseClassId(node, isStatement);
  8744. this.parseClassSuper(node);
  8745. var classBody = this.startNode();
  8746. var hadConstructor = false;
  8747. classBody.body = [];
  8748. this.expect(types.braceL);
  8749. while (!this.eat(types.braceR)) {
  8750. var element = this$1.parseClassElement(node.superClass !== null);
  8751. if (element) {
  8752. classBody.body.push(element);
  8753. if (element.type === "MethodDefinition" && element.kind === "constructor") {
  8754. if (hadConstructor) {
  8755. this$1.raise(element.start, "Duplicate constructor in the same class");
  8756. }
  8757. hadConstructor = true;
  8758. }
  8759. }
  8760. }
  8761. node.body = this.finishNode(classBody, "ClassBody");
  8762. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  8763. };
  8764. pp$1.parseClassElement = function (constructorAllowsSuper) {
  8765. var this$1 = this;
  8766. if (this.eat(types.semi)) {
  8767. return null;
  8768. }
  8769. var method = this.startNode();
  8770. var tryContextual = function tryContextual(k, noLineBreak) {
  8771. if (noLineBreak === void 0) noLineBreak = false;
  8772. var start = this$1.start,
  8773. startLoc = this$1.startLoc;
  8774. if (!this$1.eatContextual(k)) {
  8775. return false;
  8776. }
  8777. if (this$1.type !== types.parenL && (!noLineBreak || !this$1.canInsertSemicolon())) {
  8778. return true;
  8779. }
  8780. if (method.key) {
  8781. this$1.unexpected();
  8782. }
  8783. method.computed = false;
  8784. method.key = this$1.startNodeAt(start, startLoc);
  8785. method.key.name = k;
  8786. this$1.finishNode(method.key, "Identifier");
  8787. return false;
  8788. };
  8789. method.kind = "method";
  8790. method.static = tryContextual("static");
  8791. var isGenerator = this.eat(types.star);
  8792. var isAsync = false;
  8793. if (!isGenerator) {
  8794. if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) {
  8795. isAsync = true;
  8796. isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
  8797. } else if (tryContextual("get")) {
  8798. method.kind = "get";
  8799. } else if (tryContextual("set")) {
  8800. method.kind = "set";
  8801. }
  8802. }
  8803. if (!method.key) {
  8804. this.parsePropertyName(method);
  8805. }
  8806. var key = method.key;
  8807. var allowsDirectSuper = false;
  8808. if (!method.computed && !method.static && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {
  8809. if (method.kind !== "method") {
  8810. this.raise(key.start, "Constructor can't have get/set modifier");
  8811. }
  8812. if (isGenerator) {
  8813. this.raise(key.start, "Constructor can't be a generator");
  8814. }
  8815. if (isAsync) {
  8816. this.raise(key.start, "Constructor can't be an async method");
  8817. }
  8818. method.kind = "constructor";
  8819. allowsDirectSuper = constructorAllowsSuper;
  8820. } else if (method.static && key.type === "Identifier" && key.name === "prototype") {
  8821. this.raise(key.start, "Classes may not have a static property named prototype");
  8822. }
  8823. this.parseClassMethod(method, isGenerator, isAsync, allowsDirectSuper);
  8824. if (method.kind === "get" && method.value.params.length !== 0) {
  8825. this.raiseRecoverable(method.value.start, "getter should have no params");
  8826. }
  8827. if (method.kind === "set" && method.value.params.length !== 1) {
  8828. this.raiseRecoverable(method.value.start, "setter should have exactly one param");
  8829. }
  8830. if (method.kind === "set" && method.value.params[0].type === "RestElement") {
  8831. this.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params");
  8832. }
  8833. return method;
  8834. };
  8835. pp$1.parseClassMethod = function (method, isGenerator, isAsync, allowsDirectSuper) {
  8836. method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
  8837. return this.finishNode(method, "MethodDefinition");
  8838. };
  8839. pp$1.parseClassId = function (node, isStatement) {
  8840. node.id = this.type === types.name ? this.parseIdent() : isStatement === true ? this.unexpected() : null;
  8841. };
  8842. pp$1.parseClassSuper = function (node) {
  8843. node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
  8844. };
  8845. // Parses module export declaration.
  8846. pp$1.parseExport = function (node, exports) {
  8847. var this$1 = this;
  8848. this.next();
  8849. // export * from '...'
  8850. if (this.eat(types.star)) {
  8851. this.expectContextual("from");
  8852. if (this.type !== types.string) {
  8853. this.unexpected();
  8854. }
  8855. node.source = this.parseExprAtom();
  8856. this.semicolon();
  8857. return this.finishNode(node, "ExportAllDeclaration");
  8858. }
  8859. if (this.eat(types._default)) {
  8860. // export default ...
  8861. this.checkExport(exports, "default", this.lastTokStart);
  8862. var isAsync;
  8863. if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
  8864. var fNode = this.startNode();
  8865. this.next();
  8866. if (isAsync) {
  8867. this.next();
  8868. }
  8869. node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync, true);
  8870. } else if (this.type === types._class) {
  8871. var cNode = this.startNode();
  8872. node.declaration = this.parseClass(cNode, "nullableID");
  8873. } else {
  8874. node.declaration = this.parseMaybeAssign();
  8875. this.semicolon();
  8876. }
  8877. return this.finishNode(node, "ExportDefaultDeclaration");
  8878. }
  8879. // export var|const|let|function|class ...
  8880. if (this.shouldParseExportStatement()) {
  8881. node.declaration = this.parseStatement(null);
  8882. if (node.declaration.type === "VariableDeclaration") {
  8883. this.checkVariableExport(exports, node.declaration.declarations);
  8884. } else {
  8885. this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
  8886. }
  8887. node.specifiers = [];
  8888. node.source = null;
  8889. } else {
  8890. // export { x, y as z } [from '...']
  8891. node.declaration = null;
  8892. node.specifiers = this.parseExportSpecifiers(exports);
  8893. if (this.eatContextual("from")) {
  8894. if (this.type !== types.string) {
  8895. this.unexpected();
  8896. }
  8897. node.source = this.parseExprAtom();
  8898. } else {
  8899. // check for keywords used as local names
  8900. for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
  8901. var spec = list[i];
  8902. this$1.checkUnreserved(spec.local);
  8903. }
  8904. node.source = null;
  8905. }
  8906. this.semicolon();
  8907. }
  8908. return this.finishNode(node, "ExportNamedDeclaration");
  8909. };
  8910. pp$1.checkExport = function (exports, name, pos) {
  8911. if (!exports) {
  8912. return;
  8913. }
  8914. if (has(exports, name)) {
  8915. this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
  8916. }
  8917. exports[name] = true;
  8918. };
  8919. pp$1.checkPatternExport = function (exports, pat) {
  8920. var this$1 = this;
  8921. var type = pat.type;
  8922. if (type === "Identifier") {
  8923. this.checkExport(exports, pat.name, pat.start);
  8924. } else if (type === "ObjectPattern") {
  8925. for (var i = 0, list = pat.properties; i < list.length; i += 1) {
  8926. var prop = list[i];
  8927. this$1.checkPatternExport(exports, prop);
  8928. }
  8929. } else if (type === "ArrayPattern") {
  8930. for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
  8931. var elt = list$1[i$1];
  8932. if (elt) {
  8933. this$1.checkPatternExport(exports, elt);
  8934. }
  8935. }
  8936. } else if (type === "Property") {
  8937. this.checkPatternExport(exports, pat.value);
  8938. } else if (type === "AssignmentPattern") {
  8939. this.checkPatternExport(exports, pat.left);
  8940. } else if (type === "RestElement") {
  8941. this.checkPatternExport(exports, pat.argument);
  8942. } else if (type === "ParenthesizedExpression") {
  8943. this.checkPatternExport(exports, pat.expression);
  8944. }
  8945. };
  8946. pp$1.checkVariableExport = function (exports, decls) {
  8947. var this$1 = this;
  8948. if (!exports) {
  8949. return;
  8950. }
  8951. for (var i = 0, list = decls; i < list.length; i += 1) {
  8952. var decl = list[i];
  8953. this$1.checkPatternExport(exports, decl.id);
  8954. }
  8955. };
  8956. pp$1.shouldParseExportStatement = function () {
  8957. return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
  8958. };
  8959. // Parses a comma-separated list of module exports.
  8960. pp$1.parseExportSpecifiers = function (exports) {
  8961. var this$1 = this;
  8962. var nodes = [],
  8963. first = true;
  8964. // export { x, y as z } [from '...']
  8965. this.expect(types.braceL);
  8966. while (!this.eat(types.braceR)) {
  8967. if (!first) {
  8968. this$1.expect(types.comma);
  8969. if (this$1.afterTrailingComma(types.braceR)) {
  8970. break;
  8971. }
  8972. } else {
  8973. first = false;
  8974. }
  8975. var node = this$1.startNode();
  8976. node.local = this$1.parseIdent(true);
  8977. node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local;
  8978. this$1.checkExport(exports, node.exported.name, node.exported.start);
  8979. nodes.push(this$1.finishNode(node, "ExportSpecifier"));
  8980. }
  8981. return nodes;
  8982. };
  8983. // Parses import declaration.
  8984. pp$1.parseImport = function (node) {
  8985. this.next();
  8986. // import '...'
  8987. if (this.type === types.string) {
  8988. node.specifiers = empty;
  8989. node.source = this.parseExprAtom();
  8990. } else {
  8991. node.specifiers = this.parseImportSpecifiers();
  8992. this.expectContextual("from");
  8993. node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
  8994. }
  8995. this.semicolon();
  8996. return this.finishNode(node, "ImportDeclaration");
  8997. };
  8998. // Parses a comma-separated list of module imports.
  8999. pp$1.parseImportSpecifiers = function () {
  9000. var this$1 = this;
  9001. var nodes = [],
  9002. first = true;
  9003. if (this.type === types.name) {
  9004. // import defaultObj, { x, y as z } from '...'
  9005. var node = this.startNode();
  9006. node.local = this.parseIdent();
  9007. this.checkLVal(node.local, BIND_LEXICAL);
  9008. nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
  9009. if (!this.eat(types.comma)) {
  9010. return nodes;
  9011. }
  9012. }
  9013. if (this.type === types.star) {
  9014. var node$1 = this.startNode();
  9015. this.next();
  9016. this.expectContextual("as");
  9017. node$1.local = this.parseIdent();
  9018. this.checkLVal(node$1.local, BIND_LEXICAL);
  9019. nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
  9020. return nodes;
  9021. }
  9022. this.expect(types.braceL);
  9023. while (!this.eat(types.braceR)) {
  9024. if (!first) {
  9025. this$1.expect(types.comma);
  9026. if (this$1.afterTrailingComma(types.braceR)) {
  9027. break;
  9028. }
  9029. } else {
  9030. first = false;
  9031. }
  9032. var node$2 = this$1.startNode();
  9033. node$2.imported = this$1.parseIdent(true);
  9034. if (this$1.eatContextual("as")) {
  9035. node$2.local = this$1.parseIdent();
  9036. } else {
  9037. this$1.checkUnreserved(node$2.imported);
  9038. node$2.local = node$2.imported;
  9039. }
  9040. this$1.checkLVal(node$2.local, BIND_LEXICAL);
  9041. nodes.push(this$1.finishNode(node$2, "ImportSpecifier"));
  9042. }
  9043. return nodes;
  9044. };
  9045. // Set `ExpressionStatement#directive` property for directive prologues.
  9046. pp$1.adaptDirectivePrologue = function (statements) {
  9047. for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
  9048. statements[i].directive = statements[i].expression.raw.slice(1, -1);
  9049. }
  9050. };
  9051. pp$1.isDirectiveCandidate = function (statement) {
  9052. return statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && typeof statement.expression.value === "string" && (
  9053. // Reject parenthesized strings.
  9054. this.input[statement.start] === "\"" || this.input[statement.start] === "'");
  9055. };
  9056. var pp$2 = Parser.prototype;
  9057. // Convert existing expression atom to assignable pattern
  9058. // if possible.
  9059. pp$2.toAssignable = function (node, isBinding, refDestructuringErrors) {
  9060. var this$1 = this;
  9061. if (this.options.ecmaVersion >= 6 && node) {
  9062. switch (node.type) {
  9063. case "Identifier":
  9064. if (this.inAsync && node.name === "await") {
  9065. this.raise(node.start, "Can not use 'await' as identifier inside an async function");
  9066. }
  9067. break;
  9068. case "ObjectPattern":
  9069. case "ArrayPattern":
  9070. case "RestElement":
  9071. break;
  9072. case "ObjectExpression":
  9073. node.type = "ObjectPattern";
  9074. if (refDestructuringErrors) {
  9075. this.checkPatternErrors(refDestructuringErrors, true);
  9076. }
  9077. for (var i = 0, list = node.properties; i < list.length; i += 1) {
  9078. var prop = list[i];
  9079. this$1.toAssignable(prop, isBinding);
  9080. // Early error:
  9081. // AssignmentRestProperty[Yield, Await] :
  9082. // `...` DestructuringAssignmentTarget[Yield, Await]
  9083. //
  9084. // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
  9085. if (prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")) {
  9086. this$1.raise(prop.argument.start, "Unexpected token");
  9087. }
  9088. }
  9089. break;
  9090. case "Property":
  9091. // AssignmentProperty has type === "Property"
  9092. if (node.kind !== "init") {
  9093. this.raise(node.key.start, "Object pattern can't contain getter or setter");
  9094. }
  9095. this.toAssignable(node.value, isBinding);
  9096. break;
  9097. case "ArrayExpression":
  9098. node.type = "ArrayPattern";
  9099. if (refDestructuringErrors) {
  9100. this.checkPatternErrors(refDestructuringErrors, true);
  9101. }
  9102. this.toAssignableList(node.elements, isBinding);
  9103. break;
  9104. case "SpreadElement":
  9105. node.type = "RestElement";
  9106. this.toAssignable(node.argument, isBinding);
  9107. if (node.argument.type === "AssignmentPattern") {
  9108. this.raise(node.argument.start, "Rest elements cannot have a default value");
  9109. }
  9110. break;
  9111. case "AssignmentExpression":
  9112. if (node.operator !== "=") {
  9113. this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
  9114. }
  9115. node.type = "AssignmentPattern";
  9116. delete node.operator;
  9117. this.toAssignable(node.left, isBinding);
  9118. // falls through to AssignmentPattern
  9119. case "AssignmentPattern":
  9120. break;
  9121. case "ParenthesizedExpression":
  9122. this.toAssignable(node.expression, isBinding);
  9123. break;
  9124. case "MemberExpression":
  9125. if (!isBinding) {
  9126. break;
  9127. }
  9128. default:
  9129. this.raise(node.start, "Assigning to rvalue");
  9130. }
  9131. } else if (refDestructuringErrors) {
  9132. this.checkPatternErrors(refDestructuringErrors, true);
  9133. }
  9134. return node;
  9135. };
  9136. // Convert list of expression atoms to binding list.
  9137. pp$2.toAssignableList = function (exprList, isBinding) {
  9138. var this$1 = this;
  9139. var end = exprList.length;
  9140. for (var i = 0; i < end; i++) {
  9141. var elt = exprList[i];
  9142. if (elt) {
  9143. this$1.toAssignable(elt, isBinding);
  9144. }
  9145. }
  9146. if (end) {
  9147. var last = exprList[end - 1];
  9148. if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") {
  9149. this.unexpected(last.argument.start);
  9150. }
  9151. }
  9152. return exprList;
  9153. };
  9154. // Parses spread element.
  9155. pp$2.parseSpread = function (refDestructuringErrors) {
  9156. var node = this.startNode();
  9157. this.next();
  9158. node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  9159. return this.finishNode(node, "SpreadElement");
  9160. };
  9161. pp$2.parseRestBinding = function () {
  9162. var node = this.startNode();
  9163. this.next();
  9164. // RestElement inside of a function parameter must be an identifier
  9165. if (this.options.ecmaVersion === 6 && this.type !== types.name) {
  9166. this.unexpected();
  9167. }
  9168. node.argument = this.parseBindingAtom();
  9169. return this.finishNode(node, "RestElement");
  9170. };
  9171. // Parses lvalue (assignable) atom.
  9172. pp$2.parseBindingAtom = function () {
  9173. if (this.options.ecmaVersion >= 6) {
  9174. switch (this.type) {
  9175. case types.bracketL:
  9176. var node = this.startNode();
  9177. this.next();
  9178. node.elements = this.parseBindingList(types.bracketR, true, true);
  9179. return this.finishNode(node, "ArrayPattern");
  9180. case types.braceL:
  9181. return this.parseObj(true);
  9182. }
  9183. }
  9184. return this.parseIdent();
  9185. };
  9186. pp$2.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
  9187. var this$1 = this;
  9188. var elts = [],
  9189. first = true;
  9190. while (!this.eat(close)) {
  9191. if (first) {
  9192. first = false;
  9193. } else {
  9194. this$1.expect(types.comma);
  9195. }
  9196. if (allowEmpty && this$1.type === types.comma) {
  9197. elts.push(null);
  9198. } else if (allowTrailingComma && this$1.afterTrailingComma(close)) {
  9199. break;
  9200. } else if (this$1.type === types.ellipsis) {
  9201. var rest = this$1.parseRestBinding();
  9202. this$1.parseBindingListItem(rest);
  9203. elts.push(rest);
  9204. if (this$1.type === types.comma) {
  9205. this$1.raise(this$1.start, "Comma is not permitted after the rest element");
  9206. }
  9207. this$1.expect(close);
  9208. break;
  9209. } else {
  9210. var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc);
  9211. this$1.parseBindingListItem(elem);
  9212. elts.push(elem);
  9213. }
  9214. }
  9215. return elts;
  9216. };
  9217. pp$2.parseBindingListItem = function (param) {
  9218. return param;
  9219. };
  9220. // Parses assignment pattern around given atom if possible.
  9221. pp$2.parseMaybeDefault = function (startPos, startLoc, left) {
  9222. left = left || this.parseBindingAtom();
  9223. if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) {
  9224. return left;
  9225. }
  9226. var node = this.startNodeAt(startPos, startLoc);
  9227. node.left = left;
  9228. node.right = this.parseMaybeAssign();
  9229. return this.finishNode(node, "AssignmentPattern");
  9230. };
  9231. // Verify that a node is an lval — something that can be assigned
  9232. // to.
  9233. // bindingType can be either:
  9234. // 'var' indicating that the lval creates a 'var' binding
  9235. // 'let' indicating that the lval creates a lexical ('let' or 'const') binding
  9236. // 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references
  9237. pp$2.checkLVal = function (expr, bindingType, checkClashes) {
  9238. var this$1 = this;
  9239. if (bindingType === void 0) bindingType = BIND_NONE;
  9240. switch (expr.type) {
  9241. case "Identifier":
  9242. if (this.strict && this.reservedWordsStrictBind.test(expr.name)) {
  9243. this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
  9244. }
  9245. if (checkClashes) {
  9246. if (has(checkClashes, expr.name)) {
  9247. this.raiseRecoverable(expr.start, "Argument name clash");
  9248. }
  9249. checkClashes[expr.name] = true;
  9250. }
  9251. if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) {
  9252. this.declareName(expr.name, bindingType, expr.start);
  9253. }
  9254. break;
  9255. case "MemberExpression":
  9256. if (bindingType) {
  9257. this.raiseRecoverable(expr.start, "Binding member expression");
  9258. }
  9259. break;
  9260. case "ObjectPattern":
  9261. for (var i = 0, list = expr.properties; i < list.length; i += 1) {
  9262. var prop = list[i];
  9263. this$1.checkLVal(prop, bindingType, checkClashes);
  9264. }
  9265. break;
  9266. case "Property":
  9267. // AssignmentProperty has type === "Property"
  9268. this.checkLVal(expr.value, bindingType, checkClashes);
  9269. break;
  9270. case "ArrayPattern":
  9271. for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
  9272. var elem = list$1[i$1];
  9273. if (elem) {
  9274. this$1.checkLVal(elem, bindingType, checkClashes);
  9275. }
  9276. }
  9277. break;
  9278. case "AssignmentPattern":
  9279. this.checkLVal(expr.left, bindingType, checkClashes);
  9280. break;
  9281. case "RestElement":
  9282. this.checkLVal(expr.argument, bindingType, checkClashes);
  9283. break;
  9284. case "ParenthesizedExpression":
  9285. this.checkLVal(expr.expression, bindingType, checkClashes);
  9286. break;
  9287. default:
  9288. this.raise(expr.start, (bindingType ? "Binding" : "Assigning to") + " rvalue");
  9289. }
  9290. };
  9291. // A recursive descent parser operates by defining functions for all
  9292. // syntactic elements, and recursively calling those, each function
  9293. // advancing the input stream and returning an AST node. Precedence
  9294. // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
  9295. // instead of `(!x)[1]` is handled by the fact that the parser
  9296. // function that parses unary prefix operators is called first, and
  9297. // in turn calls the function that parses `[]` subscripts — that
  9298. // way, it'll receive the node for `x[1]` already parsed, and wraps
  9299. // *that* in the unary operator node.
  9300. //
  9301. // Acorn uses an [operator precedence parser][opp] to handle binary
  9302. // operator precedence, because it is much more compact than using
  9303. // the technique outlined above, which uses different, nesting
  9304. // functions to specify precedence, for all of the ten binary
  9305. // precedence levels that JavaScript defines.
  9306. //
  9307. // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
  9308. var pp$3 = Parser.prototype;
  9309. // Check if property name clashes with already added.
  9310. // Object/class getters and setters are not allowed to clash —
  9311. // either with each other or with an init property — and in
  9312. // strict mode, init properties are also not allowed to be repeated.
  9313. pp$3.checkPropClash = function (prop, propHash, refDestructuringErrors) {
  9314. if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") {
  9315. return;
  9316. }
  9317. if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) {
  9318. return;
  9319. }
  9320. var key = prop.key;
  9321. var name;
  9322. switch (key.type) {
  9323. case "Identifier":
  9324. name = key.name;break;
  9325. case "Literal":
  9326. name = String(key.value);break;
  9327. default:
  9328. return;
  9329. }
  9330. var kind = prop.kind;
  9331. if (this.options.ecmaVersion >= 6) {
  9332. if (name === "__proto__" && kind === "init") {
  9333. if (propHash.proto) {
  9334. if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) {
  9335. refDestructuringErrors.doubleProto = key.start;
  9336. }
  9337. // Backwards-compat kludge. Can be removed in version 6.0
  9338. else {
  9339. this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
  9340. }
  9341. }
  9342. propHash.proto = true;
  9343. }
  9344. return;
  9345. }
  9346. name = "$" + name;
  9347. var other = propHash[name];
  9348. if (other) {
  9349. var redefinition;
  9350. if (kind === "init") {
  9351. redefinition = this.strict && other.init || other.get || other.set;
  9352. } else {
  9353. redefinition = other.init || other[kind];
  9354. }
  9355. if (redefinition) {
  9356. this.raiseRecoverable(key.start, "Redefinition of property");
  9357. }
  9358. } else {
  9359. other = propHash[name] = {
  9360. init: false,
  9361. get: false,
  9362. set: false
  9363. };
  9364. }
  9365. other[kind] = true;
  9366. };
  9367. // ### Expression parsing
  9368. // These nest, from the most general expression type at the top to
  9369. // 'atomic', nondivisible expression types at the bottom. Most of
  9370. // the functions will simply let the function(s) below them parse,
  9371. // and, *if* the syntactic construct they handle is present, wrap
  9372. // the AST node that the inner parser gave them in another node.
  9373. // Parse a full expression. The optional arguments are used to
  9374. // forbid the `in` operator (in for loops initalization expressions)
  9375. // and provide reference for storing '=' operator inside shorthand
  9376. // property assignment in contexts where both object expression
  9377. // and object pattern might appear (so it's possible to raise
  9378. // delayed syntax error at correct position).
  9379. pp$3.parseExpression = function (noIn, refDestructuringErrors) {
  9380. var this$1 = this;
  9381. var startPos = this.start,
  9382. startLoc = this.startLoc;
  9383. var expr = this.parseMaybeAssign(noIn, refDestructuringErrors);
  9384. if (this.type === types.comma) {
  9385. var node = this.startNodeAt(startPos, startLoc);
  9386. node.expressions = [expr];
  9387. while (this.eat(types.comma)) {
  9388. node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors));
  9389. }
  9390. return this.finishNode(node, "SequenceExpression");
  9391. }
  9392. return expr;
  9393. };
  9394. // Parse an assignment expression. This includes applications of
  9395. // operators like `+=`.
  9396. pp$3.parseMaybeAssign = function (noIn, refDestructuringErrors, afterLeftParse) {
  9397. if (this.isContextual("yield")) {
  9398. if (this.inGenerator) {
  9399. return this.parseYield();
  9400. }
  9401. // The tokenizer will assume an expression is allowed after
  9402. // `yield`, but this isn't that kind of yield
  9403. else {
  9404. this.exprAllowed = false;
  9405. }
  9406. }
  9407. var ownDestructuringErrors = false,
  9408. oldParenAssign = -1,
  9409. oldTrailingComma = -1,
  9410. oldShorthandAssign = -1;
  9411. if (refDestructuringErrors) {
  9412. oldParenAssign = refDestructuringErrors.parenthesizedAssign;
  9413. oldTrailingComma = refDestructuringErrors.trailingComma;
  9414. oldShorthandAssign = refDestructuringErrors.shorthandAssign;
  9415. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = -1;
  9416. } else {
  9417. refDestructuringErrors = new DestructuringErrors();
  9418. ownDestructuringErrors = true;
  9419. }
  9420. var startPos = this.start,
  9421. startLoc = this.startLoc;
  9422. if (this.type === types.parenL || this.type === types.name) {
  9423. this.potentialArrowAt = this.start;
  9424. }
  9425. var left = this.parseMaybeConditional(noIn, refDestructuringErrors);
  9426. if (afterLeftParse) {
  9427. left = afterLeftParse.call(this, left, startPos, startLoc);
  9428. }
  9429. if (this.type.isAssign) {
  9430. var node = this.startNodeAt(startPos, startLoc);
  9431. node.operator = this.value;
  9432. node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left;
  9433. if (!ownDestructuringErrors) {
  9434. DestructuringErrors.call(refDestructuringErrors);
  9435. }
  9436. refDestructuringErrors.shorthandAssign = -1; // reset because shorthand default was used correctly
  9437. this.checkLVal(left);
  9438. this.next();
  9439. node.right = this.parseMaybeAssign(noIn);
  9440. return this.finishNode(node, "AssignmentExpression");
  9441. } else {
  9442. if (ownDestructuringErrors) {
  9443. this.checkExpressionErrors(refDestructuringErrors, true);
  9444. }
  9445. }
  9446. if (oldParenAssign > -1) {
  9447. refDestructuringErrors.parenthesizedAssign = oldParenAssign;
  9448. }
  9449. if (oldTrailingComma > -1) {
  9450. refDestructuringErrors.trailingComma = oldTrailingComma;
  9451. }
  9452. if (oldShorthandAssign > -1) {
  9453. refDestructuringErrors.shorthandAssign = oldShorthandAssign;
  9454. }
  9455. return left;
  9456. };
  9457. // Parse a ternary conditional (`?:`) operator.
  9458. pp$3.parseMaybeConditional = function (noIn, refDestructuringErrors) {
  9459. var startPos = this.start,
  9460. startLoc = this.startLoc;
  9461. var expr = this.parseExprOps(noIn, refDestructuringErrors);
  9462. if (this.checkExpressionErrors(refDestructuringErrors)) {
  9463. return expr;
  9464. }
  9465. if (this.eat(types.question)) {
  9466. var node = this.startNodeAt(startPos, startLoc);
  9467. node.test = expr;
  9468. node.consequent = this.parseMaybeAssign();
  9469. this.expect(types.colon);
  9470. node.alternate = this.parseMaybeAssign(noIn);
  9471. return this.finishNode(node, "ConditionalExpression");
  9472. }
  9473. return expr;
  9474. };
  9475. // Start the precedence parser.
  9476. pp$3.parseExprOps = function (noIn, refDestructuringErrors) {
  9477. var startPos = this.start,
  9478. startLoc = this.startLoc;
  9479. var expr = this.parseMaybeUnary(refDestructuringErrors, false);
  9480. if (this.checkExpressionErrors(refDestructuringErrors)) {
  9481. return expr;
  9482. }
  9483. return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn);
  9484. };
  9485. // Parse binary operators with the operator precedence parsing
  9486. // algorithm. `left` is the left-hand side of the operator.
  9487. // `minPrec` provides context that allows the function to stop and
  9488. // defer further parser to one of its callers when it encounters an
  9489. // operator that has a lower precedence than the set it is parsing.
  9490. pp$3.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) {
  9491. var prec = this.type.binop;
  9492. if (prec != null && (!noIn || this.type !== types._in)) {
  9493. if (prec > minPrec) {
  9494. var logical = this.type === types.logicalOR || this.type === types.logicalAND;
  9495. var op = this.value;
  9496. this.next();
  9497. var startPos = this.start,
  9498. startLoc = this.startLoc;
  9499. var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
  9500. var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical);
  9501. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);
  9502. }
  9503. }
  9504. return left;
  9505. };
  9506. pp$3.buildBinary = function (startPos, startLoc, left, right, op, logical) {
  9507. var node = this.startNodeAt(startPos, startLoc);
  9508. node.left = left;
  9509. node.operator = op;
  9510. node.right = right;
  9511. return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression");
  9512. };
  9513. // Parse unary operators, both prefix and postfix.
  9514. pp$3.parseMaybeUnary = function (refDestructuringErrors, sawUnary) {
  9515. var this$1 = this;
  9516. var startPos = this.start,
  9517. startLoc = this.startLoc,
  9518. expr;
  9519. if (this.isContextual("await") && (this.inAsync || !this.inFunction && this.options.allowAwaitOutsideFunction)) {
  9520. expr = this.parseAwait();
  9521. sawUnary = true;
  9522. } else if (this.type.prefix) {
  9523. var node = this.startNode(),
  9524. update = this.type === types.incDec;
  9525. node.operator = this.value;
  9526. node.prefix = true;
  9527. this.next();
  9528. node.argument = this.parseMaybeUnary(null, true);
  9529. this.checkExpressionErrors(refDestructuringErrors, true);
  9530. if (update) {
  9531. this.checkLVal(node.argument);
  9532. } else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") {
  9533. this.raiseRecoverable(node.start, "Deleting local variable in strict mode");
  9534. } else {
  9535. sawUnary = true;
  9536. }
  9537. expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
  9538. } else {
  9539. expr = this.parseExprSubscripts(refDestructuringErrors);
  9540. if (this.checkExpressionErrors(refDestructuringErrors)) {
  9541. return expr;
  9542. }
  9543. while (this.type.postfix && !this.canInsertSemicolon()) {
  9544. var node$1 = this$1.startNodeAt(startPos, startLoc);
  9545. node$1.operator = this$1.value;
  9546. node$1.prefix = false;
  9547. node$1.argument = expr;
  9548. this$1.checkLVal(expr);
  9549. this$1.next();
  9550. expr = this$1.finishNode(node$1, "UpdateExpression");
  9551. }
  9552. }
  9553. if (!sawUnary && this.eat(types.starstar)) {
  9554. return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false);
  9555. } else {
  9556. return expr;
  9557. }
  9558. };
  9559. // Parse call, dot, and `[]`-subscript expressions.
  9560. pp$3.parseExprSubscripts = function (refDestructuringErrors) {
  9561. var startPos = this.start,
  9562. startLoc = this.startLoc;
  9563. var expr = this.parseExprAtom(refDestructuringErrors);
  9564. var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")";
  9565. if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) {
  9566. return expr;
  9567. }
  9568. var result = this.parseSubscripts(expr, startPos, startLoc);
  9569. if (refDestructuringErrors && result.type === "MemberExpression") {
  9570. if (refDestructuringErrors.parenthesizedAssign >= result.start) {
  9571. refDestructuringErrors.parenthesizedAssign = -1;
  9572. }
  9573. if (refDestructuringErrors.parenthesizedBind >= result.start) {
  9574. refDestructuringErrors.parenthesizedBind = -1;
  9575. }
  9576. }
  9577. return result;
  9578. };
  9579. pp$3.parseSubscripts = function (base, startPos, startLoc, noCalls) {
  9580. var this$1 = this;
  9581. var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async";
  9582. for (var computed = void 0;;) {
  9583. if ((computed = this$1.eat(types.bracketL)) || this$1.eat(types.dot)) {
  9584. var node = this$1.startNodeAt(startPos, startLoc);
  9585. node.object = base;
  9586. node.property = computed ? this$1.parseExpression() : this$1.parseIdent(true);
  9587. node.computed = !!computed;
  9588. if (computed) {
  9589. this$1.expect(types.bracketR);
  9590. }
  9591. base = this$1.finishNode(node, "MemberExpression");
  9592. } else if (!noCalls && this$1.eat(types.parenL)) {
  9593. var refDestructuringErrors = new DestructuringErrors(),
  9594. oldYieldPos = this$1.yieldPos,
  9595. oldAwaitPos = this$1.awaitPos;
  9596. this$1.yieldPos = 0;
  9597. this$1.awaitPos = 0;
  9598. var exprList = this$1.parseExprList(types.parenR, this$1.options.ecmaVersion >= 8, false, refDestructuringErrors);
  9599. if (maybeAsyncArrow && !this$1.canInsertSemicolon() && this$1.eat(types.arrow)) {
  9600. this$1.checkPatternErrors(refDestructuringErrors, false);
  9601. this$1.checkYieldAwaitInDefaultParams();
  9602. this$1.yieldPos = oldYieldPos;
  9603. this$1.awaitPos = oldAwaitPos;
  9604. return this$1.parseArrowExpression(this$1.startNodeAt(startPos, startLoc), exprList, true);
  9605. }
  9606. this$1.checkExpressionErrors(refDestructuringErrors, true);
  9607. this$1.yieldPos = oldYieldPos || this$1.yieldPos;
  9608. this$1.awaitPos = oldAwaitPos || this$1.awaitPos;
  9609. var node$1 = this$1.startNodeAt(startPos, startLoc);
  9610. node$1.callee = base;
  9611. node$1.arguments = exprList;
  9612. base = this$1.finishNode(node$1, "CallExpression");
  9613. } else if (this$1.type === types.backQuote) {
  9614. var node$2 = this$1.startNodeAt(startPos, startLoc);
  9615. node$2.tag = base;
  9616. node$2.quasi = this$1.parseTemplate({ isTagged: true });
  9617. base = this$1.finishNode(node$2, "TaggedTemplateExpression");
  9618. } else {
  9619. return base;
  9620. }
  9621. }
  9622. };
  9623. // Parse an atomic expression — either a single token that is an
  9624. // expression, an expression started by a keyword like `function` or
  9625. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  9626. // or `{}`.
  9627. pp$3.parseExprAtom = function (refDestructuringErrors) {
  9628. // If a division operator appears in an expression position, the
  9629. // tokenizer got confused, and we force it to read a regexp instead.
  9630. if (this.type === types.slash) {
  9631. this.readRegexp();
  9632. }
  9633. var node,
  9634. canBeArrow = this.potentialArrowAt === this.start;
  9635. switch (this.type) {
  9636. case types._super:
  9637. if (!this.allowSuper) {
  9638. this.raise(this.start, "'super' keyword outside a method");
  9639. }
  9640. node = this.startNode();
  9641. this.next();
  9642. if (this.type === types.parenL && !this.allowDirectSuper) {
  9643. this.raise(node.start, "super() call outside constructor of a subclass");
  9644. }
  9645. // The `super` keyword can appear at below:
  9646. // SuperProperty:
  9647. // super [ Expression ]
  9648. // super . IdentifierName
  9649. // SuperCall:
  9650. // super Arguments
  9651. if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL) {
  9652. this.unexpected();
  9653. }
  9654. return this.finishNode(node, "Super");
  9655. case types._this:
  9656. node = this.startNode();
  9657. this.next();
  9658. return this.finishNode(node, "ThisExpression");
  9659. case types.name:
  9660. var startPos = this.start,
  9661. startLoc = this.startLoc,
  9662. containsEsc = this.containsEsc;
  9663. var id = this.parseIdent(this.type !== types.name);
  9664. if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function)) {
  9665. return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true);
  9666. }
  9667. if (canBeArrow && !this.canInsertSemicolon()) {
  9668. if (this.eat(types.arrow)) {
  9669. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false);
  9670. }
  9671. if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc) {
  9672. id = this.parseIdent();
  9673. if (this.canInsertSemicolon() || !this.eat(types.arrow)) {
  9674. this.unexpected();
  9675. }
  9676. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true);
  9677. }
  9678. }
  9679. return id;
  9680. case types.regexp:
  9681. var value = this.value;
  9682. node = this.parseLiteral(value.value);
  9683. node.regex = { pattern: value.pattern, flags: value.flags };
  9684. return node;
  9685. case types.num:case types.string:
  9686. return this.parseLiteral(this.value);
  9687. case types._null:case types._true:case types._false:
  9688. node = this.startNode();
  9689. node.value = this.type === types._null ? null : this.type === types._true;
  9690. node.raw = this.type.keyword;
  9691. this.next();
  9692. return this.finishNode(node, "Literal");
  9693. case types.parenL:
  9694. var start = this.start,
  9695. expr = this.parseParenAndDistinguishExpression(canBeArrow);
  9696. if (refDestructuringErrors) {
  9697. if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) {
  9698. refDestructuringErrors.parenthesizedAssign = start;
  9699. }
  9700. if (refDestructuringErrors.parenthesizedBind < 0) {
  9701. refDestructuringErrors.parenthesizedBind = start;
  9702. }
  9703. }
  9704. return expr;
  9705. case types.bracketL:
  9706. node = this.startNode();
  9707. this.next();
  9708. node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
  9709. return this.finishNode(node, "ArrayExpression");
  9710. case types.braceL:
  9711. return this.parseObj(false, refDestructuringErrors);
  9712. case types._function:
  9713. node = this.startNode();
  9714. this.next();
  9715. return this.parseFunction(node, 0);
  9716. case types._class:
  9717. return this.parseClass(this.startNode(), false);
  9718. case types._new:
  9719. return this.parseNew();
  9720. case types.backQuote:
  9721. return this.parseTemplate();
  9722. default:
  9723. this.unexpected();
  9724. }
  9725. };
  9726. pp$3.parseLiteral = function (value) {
  9727. var node = this.startNode();
  9728. node.value = value;
  9729. node.raw = this.input.slice(this.start, this.end);
  9730. this.next();
  9731. return this.finishNode(node, "Literal");
  9732. };
  9733. pp$3.parseParenExpression = function () {
  9734. this.expect(types.parenL);
  9735. var val = this.parseExpression();
  9736. this.expect(types.parenR);
  9737. return val;
  9738. };
  9739. pp$3.parseParenAndDistinguishExpression = function (canBeArrow) {
  9740. var this$1 = this;
  9741. var startPos = this.start,
  9742. startLoc = this.startLoc,
  9743. val,
  9744. allowTrailingComma = this.options.ecmaVersion >= 8;
  9745. if (this.options.ecmaVersion >= 6) {
  9746. this.next();
  9747. var innerStartPos = this.start,
  9748. innerStartLoc = this.startLoc;
  9749. var exprList = [],
  9750. first = true,
  9751. lastIsComma = false;
  9752. var refDestructuringErrors = new DestructuringErrors(),
  9753. oldYieldPos = this.yieldPos,
  9754. oldAwaitPos = this.awaitPos,
  9755. spreadStart;
  9756. this.yieldPos = 0;
  9757. this.awaitPos = 0;
  9758. while (this.type !== types.parenR) {
  9759. first ? first = false : this$1.expect(types.comma);
  9760. if (allowTrailingComma && this$1.afterTrailingComma(types.parenR, true)) {
  9761. lastIsComma = true;
  9762. break;
  9763. } else if (this$1.type === types.ellipsis) {
  9764. spreadStart = this$1.start;
  9765. exprList.push(this$1.parseParenItem(this$1.parseRestBinding()));
  9766. if (this$1.type === types.comma) {
  9767. this$1.raise(this$1.start, "Comma is not permitted after the rest element");
  9768. }
  9769. break;
  9770. } else {
  9771. exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem));
  9772. }
  9773. }
  9774. var innerEndPos = this.start,
  9775. innerEndLoc = this.startLoc;
  9776. this.expect(types.parenR);
  9777. if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
  9778. this.checkPatternErrors(refDestructuringErrors, false);
  9779. this.checkYieldAwaitInDefaultParams();
  9780. this.yieldPos = oldYieldPos;
  9781. this.awaitPos = oldAwaitPos;
  9782. return this.parseParenArrowList(startPos, startLoc, exprList);
  9783. }
  9784. if (!exprList.length || lastIsComma) {
  9785. this.unexpected(this.lastTokStart);
  9786. }
  9787. if (spreadStart) {
  9788. this.unexpected(spreadStart);
  9789. }
  9790. this.checkExpressionErrors(refDestructuringErrors, true);
  9791. this.yieldPos = oldYieldPos || this.yieldPos;
  9792. this.awaitPos = oldAwaitPos || this.awaitPos;
  9793. if (exprList.length > 1) {
  9794. val = this.startNodeAt(innerStartPos, innerStartLoc);
  9795. val.expressions = exprList;
  9796. this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
  9797. } else {
  9798. val = exprList[0];
  9799. }
  9800. } else {
  9801. val = this.parseParenExpression();
  9802. }
  9803. if (this.options.preserveParens) {
  9804. var par = this.startNodeAt(startPos, startLoc);
  9805. par.expression = val;
  9806. return this.finishNode(par, "ParenthesizedExpression");
  9807. } else {
  9808. return val;
  9809. }
  9810. };
  9811. pp$3.parseParenItem = function (item) {
  9812. return item;
  9813. };
  9814. pp$3.parseParenArrowList = function (startPos, startLoc, exprList) {
  9815. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList);
  9816. };
  9817. // New's precedence is slightly tricky. It must allow its argument to
  9818. // be a `[]` or dot subscript expression, but not a call — at least,
  9819. // not without wrapping it in parentheses. Thus, it uses the noCalls
  9820. // argument to parseSubscripts to prevent it from consuming the
  9821. // argument list.
  9822. var empty$1 = [];
  9823. pp$3.parseNew = function () {
  9824. var node = this.startNode();
  9825. var meta = this.parseIdent(true);
  9826. if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
  9827. node.meta = meta;
  9828. var containsEsc = this.containsEsc;
  9829. node.property = this.parseIdent(true);
  9830. if (node.property.name !== "target" || containsEsc) {
  9831. this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target");
  9832. }
  9833. if (!this.inNonArrowFunction()) {
  9834. this.raiseRecoverable(node.start, "new.target can only be used in functions");
  9835. }
  9836. return this.finishNode(node, "MetaProperty");
  9837. }
  9838. var startPos = this.start,
  9839. startLoc = this.startLoc;
  9840. node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
  9841. if (this.eat(types.parenL)) {
  9842. node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false);
  9843. } else {
  9844. node.arguments = empty$1;
  9845. }
  9846. return this.finishNode(node, "NewExpression");
  9847. };
  9848. // Parse template expression.
  9849. pp$3.parseTemplateElement = function (ref) {
  9850. var isTagged = ref.isTagged;
  9851. var elem = this.startNode();
  9852. if (this.type === types.invalidTemplate) {
  9853. if (!isTagged) {
  9854. this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
  9855. }
  9856. elem.value = {
  9857. raw: this.value,
  9858. cooked: null
  9859. };
  9860. } else {
  9861. elem.value = {
  9862. raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
  9863. cooked: this.value
  9864. };
  9865. }
  9866. this.next();
  9867. elem.tail = this.type === types.backQuote;
  9868. return this.finishNode(elem, "TemplateElement");
  9869. };
  9870. pp$3.parseTemplate = function (ref) {
  9871. var this$1 = this;
  9872. if (ref === void 0) ref = {};
  9873. var isTagged = ref.isTagged;if (isTagged === void 0) isTagged = false;
  9874. var node = this.startNode();
  9875. this.next();
  9876. node.expressions = [];
  9877. var curElt = this.parseTemplateElement({ isTagged: isTagged });
  9878. node.quasis = [curElt];
  9879. while (!curElt.tail) {
  9880. if (this$1.type === types.eof) {
  9881. this$1.raise(this$1.pos, "Unterminated template literal");
  9882. }
  9883. this$1.expect(types.dollarBraceL);
  9884. node.expressions.push(this$1.parseExpression());
  9885. this$1.expect(types.braceR);
  9886. node.quasis.push(curElt = this$1.parseTemplateElement({ isTagged: isTagged }));
  9887. }
  9888. this.next();
  9889. return this.finishNode(node, "TemplateLiteral");
  9890. };
  9891. pp$3.isAsyncProp = function (prop) {
  9892. return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === types.star) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
  9893. };
  9894. // Parse an object literal or binding pattern.
  9895. pp$3.parseObj = function (isPattern, refDestructuringErrors) {
  9896. var this$1 = this;
  9897. var node = this.startNode(),
  9898. first = true,
  9899. propHash = {};
  9900. node.properties = [];
  9901. this.next();
  9902. while (!this.eat(types.braceR)) {
  9903. if (!first) {
  9904. this$1.expect(types.comma);
  9905. if (this$1.afterTrailingComma(types.braceR)) {
  9906. break;
  9907. }
  9908. } else {
  9909. first = false;
  9910. }
  9911. var prop = this$1.parseProperty(isPattern, refDestructuringErrors);
  9912. if (!isPattern) {
  9913. this$1.checkPropClash(prop, propHash, refDestructuringErrors);
  9914. }
  9915. node.properties.push(prop);
  9916. }
  9917. return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
  9918. };
  9919. pp$3.parseProperty = function (isPattern, refDestructuringErrors) {
  9920. var prop = this.startNode(),
  9921. isGenerator,
  9922. isAsync,
  9923. startPos,
  9924. startLoc;
  9925. if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
  9926. if (isPattern) {
  9927. prop.argument = this.parseIdent(false);
  9928. if (this.type === types.comma) {
  9929. this.raise(this.start, "Comma is not permitted after the rest element");
  9930. }
  9931. return this.finishNode(prop, "RestElement");
  9932. }
  9933. // To disallow parenthesized identifier via `this.toAssignable()`.
  9934. if (this.type === types.parenL && refDestructuringErrors) {
  9935. if (refDestructuringErrors.parenthesizedAssign < 0) {
  9936. refDestructuringErrors.parenthesizedAssign = this.start;
  9937. }
  9938. if (refDestructuringErrors.parenthesizedBind < 0) {
  9939. refDestructuringErrors.parenthesizedBind = this.start;
  9940. }
  9941. }
  9942. // Parse argument.
  9943. prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  9944. // To disallow trailing comma via `this.toAssignable()`.
  9945. if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
  9946. refDestructuringErrors.trailingComma = this.start;
  9947. }
  9948. // Finish
  9949. return this.finishNode(prop, "SpreadElement");
  9950. }
  9951. if (this.options.ecmaVersion >= 6) {
  9952. prop.method = false;
  9953. prop.shorthand = false;
  9954. if (isPattern || refDestructuringErrors) {
  9955. startPos = this.start;
  9956. startLoc = this.startLoc;
  9957. }
  9958. if (!isPattern) {
  9959. isGenerator = this.eat(types.star);
  9960. }
  9961. }
  9962. var containsEsc = this.containsEsc;
  9963. this.parsePropertyName(prop);
  9964. if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
  9965. isAsync = true;
  9966. isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
  9967. this.parsePropertyName(prop, refDestructuringErrors);
  9968. } else {
  9969. isAsync = false;
  9970. }
  9971. this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
  9972. return this.finishNode(prop, "Property");
  9973. };
  9974. pp$3.parsePropertyValue = function (prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
  9975. if ((isGenerator || isAsync) && this.type === types.colon) {
  9976. this.unexpected();
  9977. }
  9978. if (this.eat(types.colon)) {
  9979. prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
  9980. prop.kind = "init";
  9981. } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
  9982. if (isPattern) {
  9983. this.unexpected();
  9984. }
  9985. prop.kind = "init";
  9986. prop.method = true;
  9987. prop.value = this.parseMethod(isGenerator, isAsync);
  9988. } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && this.type !== types.comma && this.type !== types.braceR) {
  9989. if (isGenerator || isAsync) {
  9990. this.unexpected();
  9991. }
  9992. prop.kind = prop.key.name;
  9993. this.parsePropertyName(prop);
  9994. prop.value = this.parseMethod(false);
  9995. var paramCount = prop.kind === "get" ? 0 : 1;
  9996. if (prop.value.params.length !== paramCount) {
  9997. var start = prop.value.start;
  9998. if (prop.kind === "get") {
  9999. this.raiseRecoverable(start, "getter should have no params");
  10000. } else {
  10001. this.raiseRecoverable(start, "setter should have exactly one param");
  10002. }
  10003. } else {
  10004. if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
  10005. this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
  10006. }
  10007. }
  10008. } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  10009. this.checkUnreserved(prop.key);
  10010. prop.kind = "init";
  10011. if (isPattern) {
  10012. prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
  10013. } else if (this.type === types.eq && refDestructuringErrors) {
  10014. if (refDestructuringErrors.shorthandAssign < 0) {
  10015. refDestructuringErrors.shorthandAssign = this.start;
  10016. }
  10017. prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
  10018. } else {
  10019. prop.value = prop.key;
  10020. }
  10021. prop.shorthand = true;
  10022. } else {
  10023. this.unexpected();
  10024. }
  10025. };
  10026. pp$3.parsePropertyName = function (prop) {
  10027. if (this.options.ecmaVersion >= 6) {
  10028. if (this.eat(types.bracketL)) {
  10029. prop.computed = true;
  10030. prop.key = this.parseMaybeAssign();
  10031. this.expect(types.bracketR);
  10032. return prop.key;
  10033. } else {
  10034. prop.computed = false;
  10035. }
  10036. }
  10037. return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(true);
  10038. };
  10039. // Initialize empty function node.
  10040. pp$3.initFunction = function (node) {
  10041. node.id = null;
  10042. if (this.options.ecmaVersion >= 6) {
  10043. node.generator = node.expression = false;
  10044. }
  10045. if (this.options.ecmaVersion >= 8) {
  10046. node.async = false;
  10047. }
  10048. };
  10049. // Parse object or class method.
  10050. pp$3.parseMethod = function (isGenerator, isAsync, allowDirectSuper) {
  10051. var node = this.startNode(),
  10052. oldYieldPos = this.yieldPos,
  10053. oldAwaitPos = this.awaitPos;
  10054. this.initFunction(node);
  10055. if (this.options.ecmaVersion >= 6) {
  10056. node.generator = isGenerator;
  10057. }
  10058. if (this.options.ecmaVersion >= 8) {
  10059. node.async = !!isAsync;
  10060. }
  10061. this.yieldPos = 0;
  10062. this.awaitPos = 0;
  10063. this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
  10064. this.expect(types.parenL);
  10065. node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
  10066. this.checkYieldAwaitInDefaultParams();
  10067. this.parseFunctionBody(node, false);
  10068. this.yieldPos = oldYieldPos;
  10069. this.awaitPos = oldAwaitPos;
  10070. return this.finishNode(node, "FunctionExpression");
  10071. };
  10072. // Parse arrow function expression with given parameters.
  10073. pp$3.parseArrowExpression = function (node, params, isAsync) {
  10074. var oldYieldPos = this.yieldPos,
  10075. oldAwaitPos = this.awaitPos;
  10076. this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
  10077. this.initFunction(node);
  10078. if (this.options.ecmaVersion >= 8) {
  10079. node.async = !!isAsync;
  10080. }
  10081. this.yieldPos = 0;
  10082. this.awaitPos = 0;
  10083. node.params = this.toAssignableList(params, true);
  10084. this.parseFunctionBody(node, true);
  10085. this.yieldPos = oldYieldPos;
  10086. this.awaitPos = oldAwaitPos;
  10087. return this.finishNode(node, "ArrowFunctionExpression");
  10088. };
  10089. // Parse function body and check parameters.
  10090. pp$3.parseFunctionBody = function (node, isArrowFunction) {
  10091. var isExpression = isArrowFunction && this.type !== types.braceL;
  10092. var oldStrict = this.strict,
  10093. useStrict = false;
  10094. if (isExpression) {
  10095. node.body = this.parseMaybeAssign();
  10096. node.expression = true;
  10097. this.checkParams(node, false);
  10098. } else {
  10099. var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
  10100. if (!oldStrict || nonSimple) {
  10101. useStrict = this.strictDirective(this.end);
  10102. // If this is a strict mode function, verify that argument names
  10103. // are not repeated, and it does not try to bind the words `eval`
  10104. // or `arguments`.
  10105. if (useStrict && nonSimple) {
  10106. this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list");
  10107. }
  10108. }
  10109. // Start a new scope with regard to labels and the `inFunction`
  10110. // flag (restore them to their old value afterwards).
  10111. var oldLabels = this.labels;
  10112. this.labels = [];
  10113. if (useStrict) {
  10114. this.strict = true;
  10115. }
  10116. // Add the params to varDeclaredNames to ensure that an error is thrown
  10117. // if a let/const declaration in the function clashes with one of the params.
  10118. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params));
  10119. node.body = this.parseBlock(false);
  10120. node.expression = false;
  10121. this.adaptDirectivePrologue(node.body.body);
  10122. this.labels = oldLabels;
  10123. }
  10124. this.exitScope();
  10125. // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
  10126. if (this.strict && node.id) {
  10127. this.checkLVal(node.id, BIND_OUTSIDE);
  10128. }
  10129. this.strict = oldStrict;
  10130. };
  10131. pp$3.isSimpleParamList = function (params) {
  10132. for (var i = 0, list = params; i < list.length; i += 1) {
  10133. var param = list[i];
  10134. if (param.type !== "Identifier") {
  10135. return false;
  10136. }
  10137. }
  10138. return true;
  10139. };
  10140. // Checks function params for various disallowed patterns such as using "eval"
  10141. // or "arguments" and duplicate parameters.
  10142. pp$3.checkParams = function (node, allowDuplicates) {
  10143. var this$1 = this;
  10144. var nameHash = {};
  10145. for (var i = 0, list = node.params; i < list.length; i += 1) {
  10146. var param = list[i];
  10147. this$1.checkLVal(param, BIND_VAR, allowDuplicates ? null : nameHash);
  10148. }
  10149. };
  10150. // Parses a comma-separated list of expressions, and returns them as
  10151. // an array. `close` is the token type that ends the list, and
  10152. // `allowEmpty` can be turned on to allow subsequent commas with
  10153. // nothing in between them to be parsed as `null` (which is needed
  10154. // for array literals).
  10155. pp$3.parseExprList = function (close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
  10156. var this$1 = this;
  10157. var elts = [],
  10158. first = true;
  10159. while (!this.eat(close)) {
  10160. if (!first) {
  10161. this$1.expect(types.comma);
  10162. if (allowTrailingComma && this$1.afterTrailingComma(close)) {
  10163. break;
  10164. }
  10165. } else {
  10166. first = false;
  10167. }
  10168. var elt = void 0;
  10169. if (allowEmpty && this$1.type === types.comma) {
  10170. elt = null;
  10171. } else if (this$1.type === types.ellipsis) {
  10172. elt = this$1.parseSpread(refDestructuringErrors);
  10173. if (refDestructuringErrors && this$1.type === types.comma && refDestructuringErrors.trailingComma < 0) {
  10174. refDestructuringErrors.trailingComma = this$1.start;
  10175. }
  10176. } else {
  10177. elt = this$1.parseMaybeAssign(false, refDestructuringErrors);
  10178. }
  10179. elts.push(elt);
  10180. }
  10181. return elts;
  10182. };
  10183. pp$3.checkUnreserved = function (ref) {
  10184. var start = ref.start;
  10185. var end = ref.end;
  10186. var name = ref.name;
  10187. if (this.inGenerator && name === "yield") {
  10188. this.raiseRecoverable(start, "Can not use 'yield' as identifier inside a generator");
  10189. }
  10190. if (this.inAsync && name === "await") {
  10191. this.raiseRecoverable(start, "Can not use 'await' as identifier inside an async function");
  10192. }
  10193. if (this.keywords.test(name)) {
  10194. this.raise(start, "Unexpected keyword '" + name + "'");
  10195. }
  10196. if (this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1) {
  10197. return;
  10198. }
  10199. var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
  10200. if (re.test(name)) {
  10201. if (!this.inAsync && name === "await") {
  10202. this.raiseRecoverable(start, "Can not use keyword 'await' outside an async function");
  10203. }
  10204. this.raiseRecoverable(start, "The keyword '" + name + "' is reserved");
  10205. }
  10206. };
  10207. // Parse the next token as an identifier. If `liberal` is true (used
  10208. // when parsing properties), it will also convert keywords into
  10209. // identifiers.
  10210. pp$3.parseIdent = function (liberal, isBinding) {
  10211. var node = this.startNode();
  10212. if (liberal && this.options.allowReserved === "never") {
  10213. liberal = false;
  10214. }
  10215. if (this.type === types.name) {
  10216. node.name = this.value;
  10217. } else if (this.type.keyword) {
  10218. node.name = this.type.keyword;
  10219. // To fix https://github.com/acornjs/acorn/issues/575
  10220. // `class` and `function` keywords push new context into this.context.
  10221. // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
  10222. // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
  10223. if ((node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
  10224. this.context.pop();
  10225. }
  10226. } else {
  10227. this.unexpected();
  10228. }
  10229. this.next();
  10230. this.finishNode(node, "Identifier");
  10231. if (!liberal) {
  10232. this.checkUnreserved(node);
  10233. }
  10234. return node;
  10235. };
  10236. // Parses yield expression inside generator.
  10237. pp$3.parseYield = function () {
  10238. if (!this.yieldPos) {
  10239. this.yieldPos = this.start;
  10240. }
  10241. var node = this.startNode();
  10242. this.next();
  10243. if (this.type === types.semi || this.canInsertSemicolon() || this.type !== types.star && !this.type.startsExpr) {
  10244. node.delegate = false;
  10245. node.argument = null;
  10246. } else {
  10247. node.delegate = this.eat(types.star);
  10248. node.argument = this.parseMaybeAssign();
  10249. }
  10250. return this.finishNode(node, "YieldExpression");
  10251. };
  10252. pp$3.parseAwait = function () {
  10253. if (!this.awaitPos) {
  10254. this.awaitPos = this.start;
  10255. }
  10256. var node = this.startNode();
  10257. this.next();
  10258. node.argument = this.parseMaybeUnary(null, true);
  10259. return this.finishNode(node, "AwaitExpression");
  10260. };
  10261. var pp$4 = Parser.prototype;
  10262. // This function is used to raise exceptions on parse errors. It
  10263. // takes an offset integer (into the current `input`) to indicate
  10264. // the location of the error, attaches the position to the end
  10265. // of the error message, and then raises a `SyntaxError` with that
  10266. // message.
  10267. pp$4.raise = function (pos, message) {
  10268. var loc = getLineInfo(this.input, pos);
  10269. message += " (" + loc.line + ":" + loc.column + ")";
  10270. var err = new SyntaxError(message);
  10271. err.pos = pos;err.loc = loc;err.raisedAt = this.pos;
  10272. throw err;
  10273. };
  10274. pp$4.raiseRecoverable = pp$4.raise;
  10275. pp$4.curPosition = function () {
  10276. if (this.options.locations) {
  10277. return new Position(this.curLine, this.pos - this.lineStart);
  10278. }
  10279. };
  10280. var pp$5 = Parser.prototype;
  10281. var Scope = function Scope(flags) {
  10282. this.flags = flags;
  10283. // A list of var-declared names in the current lexical scope
  10284. this.var = [];
  10285. // A list of lexically-declared names in the current lexical scope
  10286. this.lexical = [];
  10287. };
  10288. // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
  10289. pp$5.enterScope = function (flags) {
  10290. this.scopeStack.push(new Scope(flags));
  10291. };
  10292. pp$5.exitScope = function () {
  10293. this.scopeStack.pop();
  10294. };
  10295. pp$5.declareName = function (name, bindingType, pos) {
  10296. var this$1 = this;
  10297. var redeclared = false;
  10298. if (bindingType === BIND_LEXICAL) {
  10299. var scope = this.currentScope();
  10300. redeclared = scope.lexical.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
  10301. scope.lexical.push(name);
  10302. } else if (bindingType === BIND_SIMPLE_CATCH) {
  10303. var scope$1 = this.currentScope();
  10304. scope$1.lexical.push(name);
  10305. } else if (bindingType === BIND_FUNCTION) {
  10306. var scope$2 = this.currentScope();
  10307. redeclared = scope$2.lexical.indexOf(name) > -1;
  10308. scope$2.var.push(name);
  10309. } else {
  10310. for (var i = this.scopeStack.length - 1; i >= 0; --i) {
  10311. var scope$3 = this$1.scopeStack[i];
  10312. if (scope$3.lexical.indexOf(name) > -1 && !(scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) {
  10313. redeclared = true;
  10314. }
  10315. scope$3.var.push(name);
  10316. if (scope$3.flags & SCOPE_VAR) {
  10317. break;
  10318. }
  10319. }
  10320. }
  10321. if (redeclared) {
  10322. this.raiseRecoverable(pos, "Identifier '" + name + "' has already been declared");
  10323. }
  10324. };
  10325. pp$5.currentScope = function () {
  10326. return this.scopeStack[this.scopeStack.length - 1];
  10327. };
  10328. pp$5.currentVarScope = function () {
  10329. var this$1 = this;
  10330. for (var i = this.scopeStack.length - 1;; i--) {
  10331. var scope = this$1.scopeStack[i];
  10332. if (scope.flags & SCOPE_VAR) {
  10333. return scope;
  10334. }
  10335. }
  10336. };
  10337. // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
  10338. pp$5.currentThisScope = function () {
  10339. var this$1 = this;
  10340. for (var i = this.scopeStack.length - 1;; i--) {
  10341. var scope = this$1.scopeStack[i];
  10342. if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) {
  10343. return scope;
  10344. }
  10345. }
  10346. };
  10347. var Node = function Node(parser, pos, loc) {
  10348. this.type = "";
  10349. this.start = pos;
  10350. this.end = 0;
  10351. if (parser.options.locations) {
  10352. this.loc = new SourceLocation(parser, loc);
  10353. }
  10354. if (parser.options.directSourceFile) {
  10355. this.sourceFile = parser.options.directSourceFile;
  10356. }
  10357. if (parser.options.ranges) {
  10358. this.range = [pos, 0];
  10359. }
  10360. };
  10361. // Start an AST node, attaching a start offset.
  10362. var pp$6 = Parser.prototype;
  10363. pp$6.startNode = function () {
  10364. return new Node(this, this.start, this.startLoc);
  10365. };
  10366. pp$6.startNodeAt = function (pos, loc) {
  10367. return new Node(this, pos, loc);
  10368. };
  10369. // Finish an AST node, adding `type` and `end` properties.
  10370. function finishNodeAt(node, type, pos, loc) {
  10371. node.type = type;
  10372. node.end = pos;
  10373. if (this.options.locations) {
  10374. node.loc.end = loc;
  10375. }
  10376. if (this.options.ranges) {
  10377. node.range[1] = pos;
  10378. }
  10379. return node;
  10380. }
  10381. pp$6.finishNode = function (node, type) {
  10382. return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc);
  10383. };
  10384. // Finish node at given position
  10385. pp$6.finishNodeAt = function (node, type, pos, loc) {
  10386. return finishNodeAt.call(this, node, type, pos, loc);
  10387. };
  10388. // The algorithm used to determine whether a regexp can appear at a
  10389. // given point in the program is loosely based on sweet.js' approach.
  10390. // See https://github.com/mozilla/sweet.js/wiki/design
  10391. var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
  10392. this.token = token;
  10393. this.isExpr = !!isExpr;
  10394. this.preserveSpace = !!preserveSpace;
  10395. this.override = override;
  10396. this.generator = !!generator;
  10397. };
  10398. var types$1 = {
  10399. b_stat: new TokContext("{", false),
  10400. b_expr: new TokContext("{", true),
  10401. b_tmpl: new TokContext("${", false),
  10402. p_stat: new TokContext("(", false),
  10403. p_expr: new TokContext("(", true),
  10404. q_tmpl: new TokContext("`", true, true, function (p) {
  10405. return p.tryReadTemplateToken();
  10406. }),
  10407. f_stat: new TokContext("function", false),
  10408. f_expr: new TokContext("function", true),
  10409. f_expr_gen: new TokContext("function", true, false, null, true),
  10410. f_gen: new TokContext("function", false, false, null, true)
  10411. };
  10412. var pp$7 = Parser.prototype;
  10413. pp$7.initialContext = function () {
  10414. return [types$1.b_stat];
  10415. };
  10416. pp$7.braceIsBlock = function (prevType) {
  10417. var parent = this.curContext();
  10418. if (parent === types$1.f_expr || parent === types$1.f_stat) {
  10419. return true;
  10420. }
  10421. if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr)) {
  10422. return !parent.isExpr;
  10423. }
  10424. // The check for `tt.name && exprAllowed` detects whether we are
  10425. // after a `yield` or `of` construct. See the `updateContext` for
  10426. // `tt.name`.
  10427. if (prevType === types._return || prevType === types.name && this.exprAllowed) {
  10428. return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
  10429. }
  10430. if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow) {
  10431. return true;
  10432. }
  10433. if (prevType === types.braceL) {
  10434. return parent === types$1.b_stat;
  10435. }
  10436. if (prevType === types._var || prevType === types._const || prevType === types.name) {
  10437. return false;
  10438. }
  10439. return !this.exprAllowed;
  10440. };
  10441. pp$7.inGeneratorContext = function () {
  10442. var this$1 = this;
  10443. for (var i = this.context.length - 1; i >= 1; i--) {
  10444. var context = this$1.context[i];
  10445. if (context.token === "function") {
  10446. return context.generator;
  10447. }
  10448. }
  10449. return false;
  10450. };
  10451. pp$7.updateContext = function (prevType) {
  10452. var update,
  10453. type = this.type;
  10454. if (type.keyword && prevType === types.dot) {
  10455. this.exprAllowed = false;
  10456. } else if (update = type.updateContext) {
  10457. update.call(this, prevType);
  10458. } else {
  10459. this.exprAllowed = type.beforeExpr;
  10460. }
  10461. };
  10462. // Token-specific context update code
  10463. types.parenR.updateContext = types.braceR.updateContext = function () {
  10464. if (this.context.length === 1) {
  10465. this.exprAllowed = true;
  10466. return;
  10467. }
  10468. var out = this.context.pop();
  10469. if (out === types$1.b_stat && this.curContext().token === "function") {
  10470. out = this.context.pop();
  10471. }
  10472. this.exprAllowed = !out.isExpr;
  10473. };
  10474. types.braceL.updateContext = function (prevType) {
  10475. this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
  10476. this.exprAllowed = true;
  10477. };
  10478. types.dollarBraceL.updateContext = function () {
  10479. this.context.push(types$1.b_tmpl);
  10480. this.exprAllowed = true;
  10481. };
  10482. types.parenL.updateContext = function (prevType) {
  10483. var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
  10484. this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
  10485. this.exprAllowed = true;
  10486. };
  10487. types.incDec.updateContext = function () {
  10488. // tokExprAllowed stays unchanged
  10489. };
  10490. types._function.updateContext = types._class.updateContext = function (prevType) {
  10491. if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && !(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) {
  10492. this.context.push(types$1.f_expr);
  10493. } else {
  10494. this.context.push(types$1.f_stat);
  10495. }
  10496. this.exprAllowed = false;
  10497. };
  10498. types.backQuote.updateContext = function () {
  10499. if (this.curContext() === types$1.q_tmpl) {
  10500. this.context.pop();
  10501. } else {
  10502. this.context.push(types$1.q_tmpl);
  10503. }
  10504. this.exprAllowed = false;
  10505. };
  10506. types.star.updateContext = function (prevType) {
  10507. if (prevType === types._function) {
  10508. var index = this.context.length - 1;
  10509. if (this.context[index] === types$1.f_expr) {
  10510. this.context[index] = types$1.f_expr_gen;
  10511. } else {
  10512. this.context[index] = types$1.f_gen;
  10513. }
  10514. }
  10515. this.exprAllowed = true;
  10516. };
  10517. types.name.updateContext = function (prevType) {
  10518. var allowed = false;
  10519. if (this.options.ecmaVersion >= 6 && prevType !== types.dot) {
  10520. if (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) {
  10521. allowed = true;
  10522. }
  10523. }
  10524. this.exprAllowed = allowed;
  10525. };
  10526. var data = {
  10527. "$LONE": ["ASCII", "ASCII_Hex_Digit", "AHex", "Alphabetic", "Alpha", "Any", "Assigned", "Bidi_Control", "Bidi_C", "Bidi_Mirrored", "Bidi_M", "Case_Ignorable", "CI", "Cased", "Changes_When_Casefolded", "CWCF", "Changes_When_Casemapped", "CWCM", "Changes_When_Lowercased", "CWL", "Changes_When_NFKC_Casefolded", "CWKCF", "Changes_When_Titlecased", "CWT", "Changes_When_Uppercased", "CWU", "Dash", "Default_Ignorable_Code_Point", "DI", "Deprecated", "Dep", "Diacritic", "Dia", "Emoji", "Emoji_Component", "Emoji_Modifier", "Emoji_Modifier_Base", "Emoji_Presentation", "Extender", "Ext", "Grapheme_Base", "Gr_Base", "Grapheme_Extend", "Gr_Ext", "Hex_Digit", "Hex", "IDS_Binary_Operator", "IDSB", "IDS_Trinary_Operator", "IDST", "ID_Continue", "IDC", "ID_Start", "IDS", "Ideographic", "Ideo", "Join_Control", "Join_C", "Logical_Order_Exception", "LOE", "Lowercase", "Lower", "Math", "Noncharacter_Code_Point", "NChar", "Pattern_Syntax", "Pat_Syn", "Pattern_White_Space", "Pat_WS", "Quotation_Mark", "QMark", "Radical", "Regional_Indicator", "RI", "Sentence_Terminal", "STerm", "Soft_Dotted", "SD", "Terminal_Punctuation", "Term", "Unified_Ideograph", "UIdeo", "Uppercase", "Upper", "Variation_Selector", "VS", "White_Space", "space", "XID_Continue", "XIDC", "XID_Start", "XIDS"],
  10528. "General_Category": ["Cased_Letter", "LC", "Close_Punctuation", "Pe", "Connector_Punctuation", "Pc", "Control", "Cc", "cntrl", "Currency_Symbol", "Sc", "Dash_Punctuation", "Pd", "Decimal_Number", "Nd", "digit", "Enclosing_Mark", "Me", "Final_Punctuation", "Pf", "Format", "Cf", "Initial_Punctuation", "Pi", "Letter", "L", "Letter_Number", "Nl", "Line_Separator", "Zl", "Lowercase_Letter", "Ll", "Mark", "M", "Combining_Mark", "Math_Symbol", "Sm", "Modifier_Letter", "Lm", "Modifier_Symbol", "Sk", "Nonspacing_Mark", "Mn", "Number", "N", "Open_Punctuation", "Ps", "Other", "C", "Other_Letter", "Lo", "Other_Number", "No", "Other_Punctuation", "Po", "Other_Symbol", "So", "Paragraph_Separator", "Zp", "Private_Use", "Co", "Punctuation", "P", "punct", "Separator", "Z", "Space_Separator", "Zs", "Spacing_Mark", "Mc", "Surrogate", "Cs", "Symbol", "S", "Titlecase_Letter", "Lt", "Unassigned", "Cn", "Uppercase_Letter", "Lu"],
  10529. "Script": ["Adlam", "Adlm", "Ahom", "Anatolian_Hieroglyphs", "Hluw", "Arabic", "Arab", "Armenian", "Armn", "Avestan", "Avst", "Balinese", "Bali", "Bamum", "Bamu", "Bassa_Vah", "Bass", "Batak", "Batk", "Bengali", "Beng", "Bhaiksuki", "Bhks", "Bopomofo", "Bopo", "Brahmi", "Brah", "Braille", "Brai", "Buginese", "Bugi", "Buhid", "Buhd", "Canadian_Aboriginal", "Cans", "Carian", "Cari", "Caucasian_Albanian", "Aghb", "Chakma", "Cakm", "Cham", "Cherokee", "Cher", "Common", "Zyyy", "Coptic", "Copt", "Qaac", "Cuneiform", "Xsux", "Cypriot", "Cprt", "Cyrillic", "Cyrl", "Deseret", "Dsrt", "Devanagari", "Deva", "Duployan", "Dupl", "Egyptian_Hieroglyphs", "Egyp", "Elbasan", "Elba", "Ethiopic", "Ethi", "Georgian", "Geor", "Glagolitic", "Glag", "Gothic", "Goth", "Grantha", "Gran", "Greek", "Grek", "Gujarati", "Gujr", "Gurmukhi", "Guru", "Han", "Hani", "Hangul", "Hang", "Hanunoo", "Hano", "Hatran", "Hatr", "Hebrew", "Hebr", "Hiragana", "Hira", "Imperial_Aramaic", "Armi", "Inherited", "Zinh", "Qaai", "Inscriptional_Pahlavi", "Phli", "Inscriptional_Parthian", "Prti", "Javanese", "Java", "Kaithi", "Kthi", "Kannada", "Knda", "Katakana", "Kana", "Kayah_Li", "Kali", "Kharoshthi", "Khar", "Khmer", "Khmr", "Khojki", "Khoj", "Khudawadi", "Sind", "Lao", "Laoo", "Latin", "Latn", "Lepcha", "Lepc", "Limbu", "Limb", "Linear_A", "Lina", "Linear_B", "Linb", "Lisu", "Lycian", "Lyci", "Lydian", "Lydi", "Mahajani", "Mahj", "Malayalam", "Mlym", "Mandaic", "Mand", "Manichaean", "Mani", "Marchen", "Marc", "Masaram_Gondi", "Gonm", "Meetei_Mayek", "Mtei", "Mende_Kikakui", "Mend", "Meroitic_Cursive", "Merc", "Meroitic_Hieroglyphs", "Mero", "Miao", "Plrd", "Modi", "Mongolian", "Mong", "Mro", "Mroo", "Multani", "Mult", "Myanmar", "Mymr", "Nabataean", "Nbat", "New_Tai_Lue", "Talu", "Newa", "Nko", "Nkoo", "Nushu", "Nshu", "Ogham", "Ogam", "Ol_Chiki", "Olck", "Old_Hungarian", "Hung", "Old_Italic", "Ital", "Old_North_Arabian", "Narb", "Old_Permic", "Perm", "Old_Persian", "Xpeo", "Old_South_Arabian", "Sarb", "Old_Turkic", "Orkh", "Oriya", "Orya", "Osage", "Osge", "Osmanya", "Osma", "Pahawh_Hmong", "Hmng", "Palmyrene", "Palm", "Pau_Cin_Hau", "Pauc", "Phags_Pa", "Phag", "Phoenician", "Phnx", "Psalter_Pahlavi", "Phlp", "Rejang", "Rjng", "Runic", "Runr", "Samaritan", "Samr", "Saurashtra", "Saur", "Sharada", "Shrd", "Shavian", "Shaw", "Siddham", "Sidd", "SignWriting", "Sgnw", "Sinhala", "Sinh", "Sora_Sompeng", "Sora", "Soyombo", "Soyo", "Sundanese", "Sund", "Syloti_Nagri", "Sylo", "Syriac", "Syrc", "Tagalog", "Tglg", "Tagbanwa", "Tagb", "Tai_Le", "Tale", "Tai_Tham", "Lana", "Tai_Viet", "Tavt", "Takri", "Takr", "Tamil", "Taml", "Tangut", "Tang", "Telugu", "Telu", "Thaana", "Thaa", "Thai", "Tibetan", "Tibt", "Tifinagh", "Tfng", "Tirhuta", "Tirh", "Ugaritic", "Ugar", "Vai", "Vaii", "Warang_Citi", "Wara", "Yi", "Yiii", "Zanabazar_Square", "Zanb"]
  10530. };
  10531. Array.prototype.push.apply(data.$LONE, data.General_Category);
  10532. data.gc = data.General_Category;
  10533. data.sc = data.Script_Extensions = data.scx = data.Script;
  10534. var pp$9 = Parser.prototype;
  10535. var RegExpValidationState = function RegExpValidationState(parser) {
  10536. this.parser = parser;
  10537. this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "");
  10538. this.source = "";
  10539. this.flags = "";
  10540. this.start = 0;
  10541. this.switchU = false;
  10542. this.switchN = false;
  10543. this.pos = 0;
  10544. this.lastIntValue = 0;
  10545. this.lastStringValue = "";
  10546. this.lastAssertionIsQuantifiable = false;
  10547. this.numCapturingParens = 0;
  10548. this.maxBackReference = 0;
  10549. this.groupNames = [];
  10550. this.backReferenceNames = [];
  10551. };
  10552. RegExpValidationState.prototype.reset = function reset(start, pattern, flags) {
  10553. var unicode = flags.indexOf("u") !== -1;
  10554. this.start = start | 0;
  10555. this.source = pattern + "";
  10556. this.flags = flags;
  10557. this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
  10558. this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
  10559. };
  10560. RegExpValidationState.prototype.raise = function raise(message) {
  10561. this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + message);
  10562. };
  10563. // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
  10564. // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
  10565. RegExpValidationState.prototype.at = function at(i) {
  10566. var s = this.source;
  10567. var l = s.length;
  10568. if (i >= l) {
  10569. return -1;
  10570. }
  10571. var c = s.charCodeAt(i);
  10572. if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
  10573. return c;
  10574. }
  10575. return (c << 10) + s.charCodeAt(i + 1) - 0x35FDC00;
  10576. };
  10577. RegExpValidationState.prototype.nextIndex = function nextIndex(i) {
  10578. var s = this.source;
  10579. var l = s.length;
  10580. if (i >= l) {
  10581. return l;
  10582. }
  10583. var c = s.charCodeAt(i);
  10584. if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
  10585. return i + 1;
  10586. }
  10587. return i + 2;
  10588. };
  10589. RegExpValidationState.prototype.current = function current() {
  10590. return this.at(this.pos);
  10591. };
  10592. RegExpValidationState.prototype.lookahead = function lookahead() {
  10593. return this.at(this.nextIndex(this.pos));
  10594. };
  10595. RegExpValidationState.prototype.advance = function advance() {
  10596. this.pos = this.nextIndex(this.pos);
  10597. };
  10598. RegExpValidationState.prototype.eat = function eat(ch) {
  10599. if (this.current() === ch) {
  10600. this.advance();
  10601. return true;
  10602. }
  10603. return false;
  10604. };
  10605. function codePointToString$1(ch) {
  10606. if (ch <= 0xFFFF) {
  10607. return String.fromCharCode(ch);
  10608. }
  10609. ch -= 0x10000;
  10610. return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00);
  10611. }
  10612. /**
  10613. * Validate the flags part of a given RegExpLiteral.
  10614. *
  10615. * @param {RegExpValidationState} state The state to validate RegExp.
  10616. * @returns {void}
  10617. */
  10618. pp$9.validateRegExpFlags = function (state) {
  10619. var this$1 = this;
  10620. var validFlags = state.validFlags;
  10621. var flags = state.flags;
  10622. for (var i = 0; i < flags.length; i++) {
  10623. var flag = flags.charAt(i);
  10624. if (validFlags.indexOf(flag) === -1) {
  10625. this$1.raise(state.start, "Invalid regular expression flag");
  10626. }
  10627. if (flags.indexOf(flag, i + 1) > -1) {
  10628. this$1.raise(state.start, "Duplicate regular expression flag");
  10629. }
  10630. }
  10631. };
  10632. /**
  10633. * Validate the pattern part of a given RegExpLiteral.
  10634. *
  10635. * @param {RegExpValidationState} state The state to validate RegExp.
  10636. * @returns {void}
  10637. */
  10638. pp$9.validateRegExpPattern = function (state) {
  10639. this.regexp_pattern(state);
  10640. // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
  10641. // parsing contains a |GroupName|, reparse with the goal symbol
  10642. // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
  10643. // exception if _P_ did not conform to the grammar, if any elements of _P_
  10644. // were not matched by the parse, or if any Early Error conditions exist.
  10645. if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
  10646. state.switchN = true;
  10647. this.regexp_pattern(state);
  10648. }
  10649. };
  10650. // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
  10651. pp$9.regexp_pattern = function (state) {
  10652. state.pos = 0;
  10653. state.lastIntValue = 0;
  10654. state.lastStringValue = "";
  10655. state.lastAssertionIsQuantifiable = false;
  10656. state.numCapturingParens = 0;
  10657. state.maxBackReference = 0;
  10658. state.groupNames.length = 0;
  10659. state.backReferenceNames.length = 0;
  10660. this.regexp_disjunction(state);
  10661. if (state.pos !== state.source.length) {
  10662. // Make the same messages as V8.
  10663. if (state.eat(0x29 /* ) */)) {
  10664. state.raise("Unmatched ')'");
  10665. }
  10666. if (state.eat(0x5D /* [ */) || state.eat(0x7D /* } */)) {
  10667. state.raise("Lone quantifier brackets");
  10668. }
  10669. }
  10670. if (state.maxBackReference > state.numCapturingParens) {
  10671. state.raise("Invalid escape");
  10672. }
  10673. for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
  10674. var name = list[i];
  10675. if (state.groupNames.indexOf(name) === -1) {
  10676. state.raise("Invalid named capture referenced");
  10677. }
  10678. }
  10679. };
  10680. // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
  10681. pp$9.regexp_disjunction = function (state) {
  10682. var this$1 = this;
  10683. this.regexp_alternative(state);
  10684. while (state.eat(0x7C /* | */)) {
  10685. this$1.regexp_alternative(state);
  10686. }
  10687. // Make the same message as V8.
  10688. if (this.regexp_eatQuantifier(state, true)) {
  10689. state.raise("Nothing to repeat");
  10690. }
  10691. if (state.eat(0x7B /* { */)) {
  10692. state.raise("Lone quantifier brackets");
  10693. }
  10694. };
  10695. // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
  10696. pp$9.regexp_alternative = function (state) {
  10697. while (state.pos < state.source.length && this.regexp_eatTerm(state)) {}
  10698. };
  10699. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
  10700. pp$9.regexp_eatTerm = function (state) {
  10701. if (this.regexp_eatAssertion(state)) {
  10702. // Handle `QuantifiableAssertion Quantifier` alternative.
  10703. // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
  10704. // is a QuantifiableAssertion.
  10705. if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
  10706. // Make the same message as V8.
  10707. if (state.switchU) {
  10708. state.raise("Invalid quantifier");
  10709. }
  10710. }
  10711. return true;
  10712. }
  10713. if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
  10714. this.regexp_eatQuantifier(state);
  10715. return true;
  10716. }
  10717. return false;
  10718. };
  10719. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
  10720. pp$9.regexp_eatAssertion = function (state) {
  10721. var start = state.pos;
  10722. state.lastAssertionIsQuantifiable = false;
  10723. // ^, $
  10724. if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
  10725. return true;
  10726. }
  10727. // \b \B
  10728. if (state.eat(0x5C /* \ */)) {
  10729. if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
  10730. return true;
  10731. }
  10732. state.pos = start;
  10733. }
  10734. // Lookahead / Lookbehind
  10735. if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
  10736. var lookbehind = false;
  10737. if (this.options.ecmaVersion >= 9) {
  10738. lookbehind = state.eat(0x3C /* < */);
  10739. }
  10740. if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
  10741. this.regexp_disjunction(state);
  10742. if (!state.eat(0x29 /* ) */)) {
  10743. state.raise("Unterminated group");
  10744. }
  10745. state.lastAssertionIsQuantifiable = !lookbehind;
  10746. return true;
  10747. }
  10748. }
  10749. state.pos = start;
  10750. return false;
  10751. };
  10752. // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
  10753. pp$9.regexp_eatQuantifier = function (state, noError) {
  10754. if (noError === void 0) noError = false;
  10755. if (this.regexp_eatQuantifierPrefix(state, noError)) {
  10756. state.eat(0x3F /* ? */);
  10757. return true;
  10758. }
  10759. return false;
  10760. };
  10761. // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
  10762. pp$9.regexp_eatQuantifierPrefix = function (state, noError) {
  10763. return state.eat(0x2A /* * */) || state.eat(0x2B /* + */) || state.eat(0x3F /* ? */) || this.regexp_eatBracedQuantifier(state, noError);
  10764. };
  10765. pp$9.regexp_eatBracedQuantifier = function (state, noError) {
  10766. var start = state.pos;
  10767. if (state.eat(0x7B /* { */)) {
  10768. var min = 0,
  10769. max = -1;
  10770. if (this.regexp_eatDecimalDigits(state)) {
  10771. min = state.lastIntValue;
  10772. if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
  10773. max = state.lastIntValue;
  10774. }
  10775. if (state.eat(0x7D /* } */)) {
  10776. // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
  10777. if (max !== -1 && max < min && !noError) {
  10778. state.raise("numbers out of order in {} quantifier");
  10779. }
  10780. return true;
  10781. }
  10782. }
  10783. if (state.switchU && !noError) {
  10784. state.raise("Incomplete quantifier");
  10785. }
  10786. state.pos = start;
  10787. }
  10788. return false;
  10789. };
  10790. // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
  10791. pp$9.regexp_eatAtom = function (state) {
  10792. return this.regexp_eatPatternCharacters(state) || state.eat(0x2E /* . */) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state);
  10793. };
  10794. pp$9.regexp_eatReverseSolidusAtomEscape = function (state) {
  10795. var start = state.pos;
  10796. if (state.eat(0x5C /* \ */)) {
  10797. if (this.regexp_eatAtomEscape(state)) {
  10798. return true;
  10799. }
  10800. state.pos = start;
  10801. }
  10802. return false;
  10803. };
  10804. pp$9.regexp_eatUncapturingGroup = function (state) {
  10805. var start = state.pos;
  10806. if (state.eat(0x28 /* ( */)) {
  10807. if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
  10808. this.regexp_disjunction(state);
  10809. if (state.eat(0x29 /* ) */)) {
  10810. return true;
  10811. }
  10812. state.raise("Unterminated group");
  10813. }
  10814. state.pos = start;
  10815. }
  10816. return false;
  10817. };
  10818. pp$9.regexp_eatCapturingGroup = function (state) {
  10819. if (state.eat(0x28 /* ( */)) {
  10820. if (this.options.ecmaVersion >= 9) {
  10821. this.regexp_groupSpecifier(state);
  10822. } else if (state.current() === 0x3F /* ? */) {
  10823. state.raise("Invalid group");
  10824. }
  10825. this.regexp_disjunction(state);
  10826. if (state.eat(0x29 /* ) */)) {
  10827. state.numCapturingParens += 1;
  10828. return true;
  10829. }
  10830. state.raise("Unterminated group");
  10831. }
  10832. return false;
  10833. };
  10834. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
  10835. pp$9.regexp_eatExtendedAtom = function (state) {
  10836. return state.eat(0x2E /* . */) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) || this.regexp_eatInvalidBracedQuantifier(state) || this.regexp_eatExtendedPatternCharacter(state);
  10837. };
  10838. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
  10839. pp$9.regexp_eatInvalidBracedQuantifier = function (state) {
  10840. if (this.regexp_eatBracedQuantifier(state, true)) {
  10841. state.raise("Nothing to repeat");
  10842. }
  10843. return false;
  10844. };
  10845. // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
  10846. pp$9.regexp_eatSyntaxCharacter = function (state) {
  10847. var ch = state.current();
  10848. if (isSyntaxCharacter(ch)) {
  10849. state.lastIntValue = ch;
  10850. state.advance();
  10851. return true;
  10852. }
  10853. return false;
  10854. };
  10855. function isSyntaxCharacter(ch) {
  10856. return ch === 0x24 /* $ */ || ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ || ch === 0x2E /* . */ || ch === 0x3F /* ? */ || ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ || ch >= 0x7B /* { */ && ch <= 0x7D /* } */
  10857. ;
  10858. }
  10859. // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
  10860. // But eat eager.
  10861. pp$9.regexp_eatPatternCharacters = function (state) {
  10862. var start = state.pos;
  10863. var ch = 0;
  10864. while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
  10865. state.advance();
  10866. }
  10867. return state.pos !== start;
  10868. };
  10869. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
  10870. pp$9.regexp_eatExtendedPatternCharacter = function (state) {
  10871. var ch = state.current();
  10872. if (ch !== -1 && ch !== 0x24 /* $ */ && !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) && ch !== 0x2E /* . */ && ch !== 0x3F /* ? */ && ch !== 0x5B /* [ */ && ch !== 0x5E /* ^ */ && ch !== 0x7C /* | */
  10873. ) {
  10874. state.advance();
  10875. return true;
  10876. }
  10877. return false;
  10878. };
  10879. // GroupSpecifier[U] ::
  10880. // [empty]
  10881. // `?` GroupName[?U]
  10882. pp$9.regexp_groupSpecifier = function (state) {
  10883. if (state.eat(0x3F /* ? */)) {
  10884. if (this.regexp_eatGroupName(state)) {
  10885. if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
  10886. state.raise("Duplicate capture group name");
  10887. }
  10888. state.groupNames.push(state.lastStringValue);
  10889. return;
  10890. }
  10891. state.raise("Invalid group");
  10892. }
  10893. };
  10894. // GroupName[U] ::
  10895. // `<` RegExpIdentifierName[?U] `>`
  10896. // Note: this updates `state.lastStringValue` property with the eaten name.
  10897. pp$9.regexp_eatGroupName = function (state) {
  10898. state.lastStringValue = "";
  10899. if (state.eat(0x3C /* < */)) {
  10900. if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
  10901. return true;
  10902. }
  10903. state.raise("Invalid capture group name");
  10904. }
  10905. return false;
  10906. };
  10907. // RegExpIdentifierName[U] ::
  10908. // RegExpIdentifierStart[?U]
  10909. // RegExpIdentifierName[?U] RegExpIdentifierPart[?U]
  10910. // Note: this updates `state.lastStringValue` property with the eaten name.
  10911. pp$9.regexp_eatRegExpIdentifierName = function (state) {
  10912. state.lastStringValue = "";
  10913. if (this.regexp_eatRegExpIdentifierStart(state)) {
  10914. state.lastStringValue += codePointToString$1(state.lastIntValue);
  10915. while (this.regexp_eatRegExpIdentifierPart(state)) {
  10916. state.lastStringValue += codePointToString$1(state.lastIntValue);
  10917. }
  10918. return true;
  10919. }
  10920. return false;
  10921. };
  10922. // RegExpIdentifierStart[U] ::
  10923. // UnicodeIDStart
  10924. // `$`
  10925. // `_`
  10926. // `\` RegExpUnicodeEscapeSequence[?U]
  10927. pp$9.regexp_eatRegExpIdentifierStart = function (state) {
  10928. var start = state.pos;
  10929. var ch = state.current();
  10930. state.advance();
  10931. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {
  10932. ch = state.lastIntValue;
  10933. }
  10934. if (isRegExpIdentifierStart(ch)) {
  10935. state.lastIntValue = ch;
  10936. return true;
  10937. }
  10938. state.pos = start;
  10939. return false;
  10940. };
  10941. function isRegExpIdentifierStart(ch) {
  10942. return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F; /* _ */
  10943. }
  10944. // RegExpIdentifierPart[U] ::
  10945. // UnicodeIDContinue
  10946. // `$`
  10947. // `_`
  10948. // `\` RegExpUnicodeEscapeSequence[?U]
  10949. // <ZWNJ>
  10950. // <ZWJ>
  10951. pp$9.regexp_eatRegExpIdentifierPart = function (state) {
  10952. var start = state.pos;
  10953. var ch = state.current();
  10954. state.advance();
  10955. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {
  10956. ch = state.lastIntValue;
  10957. }
  10958. if (isRegExpIdentifierPart(ch)) {
  10959. state.lastIntValue = ch;
  10960. return true;
  10961. }
  10962. state.pos = start;
  10963. return false;
  10964. };
  10965. function isRegExpIdentifierPart(ch) {
  10966. return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D; /* <ZWJ> */
  10967. }
  10968. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
  10969. pp$9.regexp_eatAtomEscape = function (state) {
  10970. if (this.regexp_eatBackReference(state) || this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) || state.switchN && this.regexp_eatKGroupName(state)) {
  10971. return true;
  10972. }
  10973. if (state.switchU) {
  10974. // Make the same message as V8.
  10975. if (state.current() === 0x63 /* c */) {
  10976. state.raise("Invalid unicode escape");
  10977. }
  10978. state.raise("Invalid escape");
  10979. }
  10980. return false;
  10981. };
  10982. pp$9.regexp_eatBackReference = function (state) {
  10983. var start = state.pos;
  10984. if (this.regexp_eatDecimalEscape(state)) {
  10985. var n = state.lastIntValue;
  10986. if (state.switchU) {
  10987. // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
  10988. if (n > state.maxBackReference) {
  10989. state.maxBackReference = n;
  10990. }
  10991. return true;
  10992. }
  10993. if (n <= state.numCapturingParens) {
  10994. return true;
  10995. }
  10996. state.pos = start;
  10997. }
  10998. return false;
  10999. };
  11000. pp$9.regexp_eatKGroupName = function (state) {
  11001. if (state.eat(0x6B /* k */)) {
  11002. if (this.regexp_eatGroupName(state)) {
  11003. state.backReferenceNames.push(state.lastStringValue);
  11004. return true;
  11005. }
  11006. state.raise("Invalid named reference");
  11007. }
  11008. return false;
  11009. };
  11010. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
  11011. pp$9.regexp_eatCharacterEscape = function (state) {
  11012. return this.regexp_eatControlEscape(state) || this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state) || !state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state) || this.regexp_eatIdentityEscape(state);
  11013. };
  11014. pp$9.regexp_eatCControlLetter = function (state) {
  11015. var start = state.pos;
  11016. if (state.eat(0x63 /* c */)) {
  11017. if (this.regexp_eatControlLetter(state)) {
  11018. return true;
  11019. }
  11020. state.pos = start;
  11021. }
  11022. return false;
  11023. };
  11024. pp$9.regexp_eatZero = function (state) {
  11025. if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
  11026. state.lastIntValue = 0;
  11027. state.advance();
  11028. return true;
  11029. }
  11030. return false;
  11031. };
  11032. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
  11033. pp$9.regexp_eatControlEscape = function (state) {
  11034. var ch = state.current();
  11035. if (ch === 0x74 /* t */) {
  11036. state.lastIntValue = 0x09; /* \t */
  11037. state.advance();
  11038. return true;
  11039. }
  11040. if (ch === 0x6E /* n */) {
  11041. state.lastIntValue = 0x0A; /* \n */
  11042. state.advance();
  11043. return true;
  11044. }
  11045. if (ch === 0x76 /* v */) {
  11046. state.lastIntValue = 0x0B; /* \v */
  11047. state.advance();
  11048. return true;
  11049. }
  11050. if (ch === 0x66 /* f */) {
  11051. state.lastIntValue = 0x0C; /* \f */
  11052. state.advance();
  11053. return true;
  11054. }
  11055. if (ch === 0x72 /* r */) {
  11056. state.lastIntValue = 0x0D; /* \r */
  11057. state.advance();
  11058. return true;
  11059. }
  11060. return false;
  11061. };
  11062. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
  11063. pp$9.regexp_eatControlLetter = function (state) {
  11064. var ch = state.current();
  11065. if (isControlLetter(ch)) {
  11066. state.lastIntValue = ch % 0x20;
  11067. state.advance();
  11068. return true;
  11069. }
  11070. return false;
  11071. };
  11072. function isControlLetter(ch) {
  11073. return ch >= 0x41 /* A */ && ch <= 0x5A /* Z */ || ch >= 0x61 /* a */ && ch <= 0x7A /* z */;
  11074. }
  11075. // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
  11076. pp$9.regexp_eatRegExpUnicodeEscapeSequence = function (state) {
  11077. var start = state.pos;
  11078. if (state.eat(0x75 /* u */)) {
  11079. if (this.regexp_eatFixedHexDigits(state, 4)) {
  11080. var lead = state.lastIntValue;
  11081. if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) {
  11082. var leadSurrogateEnd = state.pos;
  11083. if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
  11084. var trail = state.lastIntValue;
  11085. if (trail >= 0xDC00 && trail <= 0xDFFF) {
  11086. state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  11087. return true;
  11088. }
  11089. }
  11090. state.pos = leadSurrogateEnd;
  11091. state.lastIntValue = lead;
  11092. }
  11093. return true;
  11094. }
  11095. if (state.switchU && state.eat(0x7B /* { */) && this.regexp_eatHexDigits(state) && state.eat(0x7D /* } */) && isValidUnicode(state.lastIntValue)) {
  11096. return true;
  11097. }
  11098. if (state.switchU) {
  11099. state.raise("Invalid unicode escape");
  11100. }
  11101. state.pos = start;
  11102. }
  11103. return false;
  11104. };
  11105. function isValidUnicode(ch) {
  11106. return ch >= 0 && ch <= 0x10FFFF;
  11107. }
  11108. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
  11109. pp$9.regexp_eatIdentityEscape = function (state) {
  11110. if (state.switchU) {
  11111. if (this.regexp_eatSyntaxCharacter(state)) {
  11112. return true;
  11113. }
  11114. if (state.eat(0x2F /* / */)) {
  11115. state.lastIntValue = 0x2F; /* / */
  11116. return true;
  11117. }
  11118. return false;
  11119. }
  11120. var ch = state.current();
  11121. if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
  11122. state.lastIntValue = ch;
  11123. state.advance();
  11124. return true;
  11125. }
  11126. return false;
  11127. };
  11128. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
  11129. pp$9.regexp_eatDecimalEscape = function (state) {
  11130. state.lastIntValue = 0;
  11131. var ch = state.current();
  11132. if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
  11133. do {
  11134. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  11135. state.advance();
  11136. } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */);
  11137. return true;
  11138. }
  11139. return false;
  11140. };
  11141. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
  11142. pp$9.regexp_eatCharacterClassEscape = function (state) {
  11143. var ch = state.current();
  11144. if (isCharacterClassEscape(ch)) {
  11145. state.lastIntValue = -1;
  11146. state.advance();
  11147. return true;
  11148. }
  11149. if (state.switchU && this.options.ecmaVersion >= 9 && (ch === 0x50 /* P */ || ch === 0x70 /* p */)) {
  11150. state.lastIntValue = -1;
  11151. state.advance();
  11152. if (state.eat(0x7B /* { */) && this.regexp_eatUnicodePropertyValueExpression(state) && state.eat(0x7D /* } */)) {
  11153. return true;
  11154. }
  11155. state.raise("Invalid property name");
  11156. }
  11157. return false;
  11158. };
  11159. function isCharacterClassEscape(ch) {
  11160. return ch === 0x64 /* d */ || ch === 0x44 /* D */ || ch === 0x73 /* s */ || ch === 0x53 /* S */ || ch === 0x77 /* w */ || ch === 0x57 /* W */
  11161. ;
  11162. }
  11163. // UnicodePropertyValueExpression ::
  11164. // UnicodePropertyName `=` UnicodePropertyValue
  11165. // LoneUnicodePropertyNameOrValue
  11166. pp$9.regexp_eatUnicodePropertyValueExpression = function (state) {
  11167. var start = state.pos;
  11168. // UnicodePropertyName `=` UnicodePropertyValue
  11169. if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
  11170. var name = state.lastStringValue;
  11171. if (this.regexp_eatUnicodePropertyValue(state)) {
  11172. var value = state.lastStringValue;
  11173. this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
  11174. return true;
  11175. }
  11176. }
  11177. state.pos = start;
  11178. // LoneUnicodePropertyNameOrValue
  11179. if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
  11180. var nameOrValue = state.lastStringValue;
  11181. this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
  11182. return true;
  11183. }
  11184. return false;
  11185. };
  11186. pp$9.regexp_validateUnicodePropertyNameAndValue = function (state, name, value) {
  11187. if (!data.hasOwnProperty(name) || data[name].indexOf(value) === -1) {
  11188. state.raise("Invalid property name");
  11189. }
  11190. };
  11191. pp$9.regexp_validateUnicodePropertyNameOrValue = function (state, nameOrValue) {
  11192. if (data.$LONE.indexOf(nameOrValue) === -1) {
  11193. state.raise("Invalid property name");
  11194. }
  11195. };
  11196. // UnicodePropertyName ::
  11197. // UnicodePropertyNameCharacters
  11198. pp$9.regexp_eatUnicodePropertyName = function (state) {
  11199. var ch = 0;
  11200. state.lastStringValue = "";
  11201. while (isUnicodePropertyNameCharacter(ch = state.current())) {
  11202. state.lastStringValue += codePointToString$1(ch);
  11203. state.advance();
  11204. }
  11205. return state.lastStringValue !== "";
  11206. };
  11207. function isUnicodePropertyNameCharacter(ch) {
  11208. return isControlLetter(ch) || ch === 0x5F; /* _ */
  11209. }
  11210. // UnicodePropertyValue ::
  11211. // UnicodePropertyValueCharacters
  11212. pp$9.regexp_eatUnicodePropertyValue = function (state) {
  11213. var ch = 0;
  11214. state.lastStringValue = "";
  11215. while (isUnicodePropertyValueCharacter(ch = state.current())) {
  11216. state.lastStringValue += codePointToString$1(ch);
  11217. state.advance();
  11218. }
  11219. return state.lastStringValue !== "";
  11220. };
  11221. function isUnicodePropertyValueCharacter(ch) {
  11222. return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch);
  11223. }
  11224. // LoneUnicodePropertyNameOrValue ::
  11225. // UnicodePropertyValueCharacters
  11226. pp$9.regexp_eatLoneUnicodePropertyNameOrValue = function (state) {
  11227. return this.regexp_eatUnicodePropertyValue(state);
  11228. };
  11229. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
  11230. pp$9.regexp_eatCharacterClass = function (state) {
  11231. if (state.eat(0x5B /* [ */)) {
  11232. state.eat(0x5E /* ^ */);
  11233. this.regexp_classRanges(state);
  11234. if (state.eat(0x5D /* [ */)) {
  11235. return true;
  11236. }
  11237. // Unreachable since it threw "unterminated regular expression" error before.
  11238. state.raise("Unterminated character class");
  11239. }
  11240. return false;
  11241. };
  11242. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
  11243. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
  11244. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
  11245. pp$9.regexp_classRanges = function (state) {
  11246. var this$1 = this;
  11247. while (this.regexp_eatClassAtom(state)) {
  11248. var left = state.lastIntValue;
  11249. if (state.eat(0x2D /* - */) && this$1.regexp_eatClassAtom(state)) {
  11250. var right = state.lastIntValue;
  11251. if (state.switchU && (left === -1 || right === -1)) {
  11252. state.raise("Invalid character class");
  11253. }
  11254. if (left !== -1 && right !== -1 && left > right) {
  11255. state.raise("Range out of order in character class");
  11256. }
  11257. }
  11258. }
  11259. };
  11260. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
  11261. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
  11262. pp$9.regexp_eatClassAtom = function (state) {
  11263. var start = state.pos;
  11264. if (state.eat(0x5C /* \ */)) {
  11265. if (this.regexp_eatClassEscape(state)) {
  11266. return true;
  11267. }
  11268. if (state.switchU) {
  11269. // Make the same message as V8.
  11270. var ch$1 = state.current();
  11271. if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
  11272. state.raise("Invalid class escape");
  11273. }
  11274. state.raise("Invalid escape");
  11275. }
  11276. state.pos = start;
  11277. }
  11278. var ch = state.current();
  11279. if (ch !== 0x5D /* [ */) {
  11280. state.lastIntValue = ch;
  11281. state.advance();
  11282. return true;
  11283. }
  11284. return false;
  11285. };
  11286. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
  11287. pp$9.regexp_eatClassEscape = function (state) {
  11288. var start = state.pos;
  11289. if (state.eat(0x62 /* b */)) {
  11290. state.lastIntValue = 0x08; /* <BS> */
  11291. return true;
  11292. }
  11293. if (state.switchU && state.eat(0x2D /* - */)) {
  11294. state.lastIntValue = 0x2D; /* - */
  11295. return true;
  11296. }
  11297. if (!state.switchU && state.eat(0x63 /* c */)) {
  11298. if (this.regexp_eatClassControlLetter(state)) {
  11299. return true;
  11300. }
  11301. state.pos = start;
  11302. }
  11303. return this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state);
  11304. };
  11305. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
  11306. pp$9.regexp_eatClassControlLetter = function (state) {
  11307. var ch = state.current();
  11308. if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
  11309. state.lastIntValue = ch % 0x20;
  11310. state.advance();
  11311. return true;
  11312. }
  11313. return false;
  11314. };
  11315. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  11316. pp$9.regexp_eatHexEscapeSequence = function (state) {
  11317. var start = state.pos;
  11318. if (state.eat(0x78 /* x */)) {
  11319. if (this.regexp_eatFixedHexDigits(state, 2)) {
  11320. return true;
  11321. }
  11322. if (state.switchU) {
  11323. state.raise("Invalid escape");
  11324. }
  11325. state.pos = start;
  11326. }
  11327. return false;
  11328. };
  11329. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
  11330. pp$9.regexp_eatDecimalDigits = function (state) {
  11331. var start = state.pos;
  11332. var ch = 0;
  11333. state.lastIntValue = 0;
  11334. while (isDecimalDigit(ch = state.current())) {
  11335. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  11336. state.advance();
  11337. }
  11338. return state.pos !== start;
  11339. };
  11340. function isDecimalDigit(ch) {
  11341. return ch >= 0x30 /* 0 */ && ch <= 0x39; /* 9 */
  11342. }
  11343. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
  11344. pp$9.regexp_eatHexDigits = function (state) {
  11345. var start = state.pos;
  11346. var ch = 0;
  11347. state.lastIntValue = 0;
  11348. while (isHexDigit(ch = state.current())) {
  11349. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  11350. state.advance();
  11351. }
  11352. return state.pos !== start;
  11353. };
  11354. function isHexDigit(ch) {
  11355. return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */ || ch >= 0x41 /* A */ && ch <= 0x46 /* F */ || ch >= 0x61 /* a */ && ch <= 0x66 /* f */;
  11356. }
  11357. function hexToInt(ch) {
  11358. if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
  11359. return 10 + (ch - 0x41 /* A */);
  11360. }
  11361. if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
  11362. return 10 + (ch - 0x61 /* a */);
  11363. }
  11364. return ch - 0x30; /* 0 */
  11365. }
  11366. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
  11367. // Allows only 0-377(octal) i.e. 0-255(decimal).
  11368. pp$9.regexp_eatLegacyOctalEscapeSequence = function (state) {
  11369. if (this.regexp_eatOctalDigit(state)) {
  11370. var n1 = state.lastIntValue;
  11371. if (this.regexp_eatOctalDigit(state)) {
  11372. var n2 = state.lastIntValue;
  11373. if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
  11374. state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
  11375. } else {
  11376. state.lastIntValue = n1 * 8 + n2;
  11377. }
  11378. } else {
  11379. state.lastIntValue = n1;
  11380. }
  11381. return true;
  11382. }
  11383. return false;
  11384. };
  11385. // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
  11386. pp$9.regexp_eatOctalDigit = function (state) {
  11387. var ch = state.current();
  11388. if (isOctalDigit(ch)) {
  11389. state.lastIntValue = ch - 0x30; /* 0 */
  11390. state.advance();
  11391. return true;
  11392. }
  11393. state.lastIntValue = 0;
  11394. return false;
  11395. };
  11396. function isOctalDigit(ch) {
  11397. return ch >= 0x30 /* 0 */ && ch <= 0x37; /* 7 */
  11398. }
  11399. // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
  11400. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
  11401. // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  11402. pp$9.regexp_eatFixedHexDigits = function (state, length) {
  11403. var start = state.pos;
  11404. state.lastIntValue = 0;
  11405. for (var i = 0; i < length; ++i) {
  11406. var ch = state.current();
  11407. if (!isHexDigit(ch)) {
  11408. state.pos = start;
  11409. return false;
  11410. }
  11411. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  11412. state.advance();
  11413. }
  11414. return true;
  11415. };
  11416. // Object type used to represent tokens. Note that normally, tokens
  11417. // simply exist as properties on the parser object. This is only
  11418. // used for the onToken callback and the external tokenizer.
  11419. var Token = function Token(p) {
  11420. this.type = p.type;
  11421. this.value = p.value;
  11422. this.start = p.start;
  11423. this.end = p.end;
  11424. if (p.options.locations) {
  11425. this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
  11426. }
  11427. if (p.options.ranges) {
  11428. this.range = [p.start, p.end];
  11429. }
  11430. };
  11431. // ## Tokenizer
  11432. var pp$8 = Parser.prototype;
  11433. // Move to the next token
  11434. pp$8.next = function () {
  11435. if (this.options.onToken) {
  11436. this.options.onToken(new Token(this));
  11437. }
  11438. this.lastTokEnd = this.end;
  11439. this.lastTokStart = this.start;
  11440. this.lastTokEndLoc = this.endLoc;
  11441. this.lastTokStartLoc = this.startLoc;
  11442. this.nextToken();
  11443. };
  11444. pp$8.getToken = function () {
  11445. this.next();
  11446. return new Token(this);
  11447. };
  11448. // If we're in an ES6 environment, make parsers iterable
  11449. if (typeof Symbol !== "undefined") {
  11450. pp$8[Symbol.iterator] = function () {
  11451. var this$1 = this;
  11452. return {
  11453. next: function next() {
  11454. var token = this$1.getToken();
  11455. return {
  11456. done: token.type === types.eof,
  11457. value: token
  11458. };
  11459. }
  11460. };
  11461. };
  11462. }
  11463. // Toggle strict mode. Re-reads the next number or string to please
  11464. // pedantic tests (`"use strict"; 010;` should fail).
  11465. pp$8.curContext = function () {
  11466. return this.context[this.context.length - 1];
  11467. };
  11468. // Read a single token, updating the parser object's token-related
  11469. // properties.
  11470. pp$8.nextToken = function () {
  11471. var curContext = this.curContext();
  11472. if (!curContext || !curContext.preserveSpace) {
  11473. this.skipSpace();
  11474. }
  11475. this.start = this.pos;
  11476. if (this.options.locations) {
  11477. this.startLoc = this.curPosition();
  11478. }
  11479. if (this.pos >= this.input.length) {
  11480. return this.finishToken(types.eof);
  11481. }
  11482. if (curContext.override) {
  11483. return curContext.override(this);
  11484. } else {
  11485. this.readToken(this.fullCharCodeAtPos());
  11486. }
  11487. };
  11488. pp$8.readToken = function (code) {
  11489. // Identifier or keyword. '\uXXXX' sequences are allowed in
  11490. // identifiers, so '\' also dispatches to that.
  11491. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) {
  11492. return this.readWord();
  11493. }
  11494. return this.getTokenFromCode(code);
  11495. };
  11496. pp$8.fullCharCodeAtPos = function () {
  11497. var code = this.input.charCodeAt(this.pos);
  11498. if (code <= 0xd7ff || code >= 0xe000) {
  11499. return code;
  11500. }
  11501. var next = this.input.charCodeAt(this.pos + 1);
  11502. return (code << 10) + next - 0x35fdc00;
  11503. };
  11504. pp$8.skipBlockComment = function () {
  11505. var this$1 = this;
  11506. var startLoc = this.options.onComment && this.curPosition();
  11507. var start = this.pos,
  11508. end = this.input.indexOf("*/", this.pos += 2);
  11509. if (end === -1) {
  11510. this.raise(this.pos - 2, "Unterminated comment");
  11511. }
  11512. this.pos = end + 2;
  11513. if (this.options.locations) {
  11514. lineBreakG.lastIndex = start;
  11515. var match;
  11516. while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
  11517. ++this$1.curLine;
  11518. this$1.lineStart = match.index + match[0].length;
  11519. }
  11520. }
  11521. if (this.options.onComment) {
  11522. this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.curPosition());
  11523. }
  11524. };
  11525. pp$8.skipLineComment = function (startSkip) {
  11526. var this$1 = this;
  11527. var start = this.pos;
  11528. var startLoc = this.options.onComment && this.curPosition();
  11529. var ch = this.input.charCodeAt(this.pos += startSkip);
  11530. while (this.pos < this.input.length && !isNewLine(ch)) {
  11531. ch = this$1.input.charCodeAt(++this$1.pos);
  11532. }
  11533. if (this.options.onComment) {
  11534. this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.curPosition());
  11535. }
  11536. };
  11537. // Called at the start of the parse and after every token. Skips
  11538. // whitespace and comments, and.
  11539. pp$8.skipSpace = function () {
  11540. var this$1 = this;
  11541. loop: while (this.pos < this.input.length) {
  11542. var ch = this$1.input.charCodeAt(this$1.pos);
  11543. switch (ch) {
  11544. case 32:case 160:
  11545. // ' '
  11546. ++this$1.pos;
  11547. break;
  11548. case 13:
  11549. if (this$1.input.charCodeAt(this$1.pos + 1) === 10) {
  11550. ++this$1.pos;
  11551. }
  11552. case 10:case 8232:case 8233:
  11553. ++this$1.pos;
  11554. if (this$1.options.locations) {
  11555. ++this$1.curLine;
  11556. this$1.lineStart = this$1.pos;
  11557. }
  11558. break;
  11559. case 47:
  11560. // '/'
  11561. switch (this$1.input.charCodeAt(this$1.pos + 1)) {
  11562. case 42:
  11563. // '*'
  11564. this$1.skipBlockComment();
  11565. break;
  11566. case 47:
  11567. this$1.skipLineComment(2);
  11568. break;
  11569. default:
  11570. break loop;
  11571. }
  11572. break;
  11573. default:
  11574. if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  11575. ++this$1.pos;
  11576. } else {
  11577. break loop;
  11578. }
  11579. }
  11580. }
  11581. };
  11582. // Called at the end of every token. Sets `end`, `val`, and
  11583. // maintains `context` and `exprAllowed`, and skips the space after
  11584. // the token, so that the next one's `start` will point at the
  11585. // right position.
  11586. pp$8.finishToken = function (type, val) {
  11587. this.end = this.pos;
  11588. if (this.options.locations) {
  11589. this.endLoc = this.curPosition();
  11590. }
  11591. var prevType = this.type;
  11592. this.type = type;
  11593. this.value = val;
  11594. this.updateContext(prevType);
  11595. };
  11596. // ### Token reading
  11597. // This is the function that is called to fetch the next token. It
  11598. // is somewhat obscure, because it works in character codes rather
  11599. // than characters, and because operator parsing has been inlined
  11600. // into it.
  11601. //
  11602. // All in the name of speed.
  11603. //
  11604. pp$8.readToken_dot = function () {
  11605. var next = this.input.charCodeAt(this.pos + 1);
  11606. if (next >= 48 && next <= 57) {
  11607. return this.readNumber(true);
  11608. }
  11609. var next2 = this.input.charCodeAt(this.pos + 2);
  11610. if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
  11611. // 46 = dot '.'
  11612. this.pos += 3;
  11613. return this.finishToken(types.ellipsis);
  11614. } else {
  11615. ++this.pos;
  11616. return this.finishToken(types.dot);
  11617. }
  11618. };
  11619. pp$8.readToken_slash = function () {
  11620. // '/'
  11621. var next = this.input.charCodeAt(this.pos + 1);
  11622. if (this.exprAllowed) {
  11623. ++this.pos;return this.readRegexp();
  11624. }
  11625. if (next === 61) {
  11626. return this.finishOp(types.assign, 2);
  11627. }
  11628. return this.finishOp(types.slash, 1);
  11629. };
  11630. pp$8.readToken_mult_modulo_exp = function (code) {
  11631. // '%*'
  11632. var next = this.input.charCodeAt(this.pos + 1);
  11633. var size = 1;
  11634. var tokentype = code === 42 ? types.star : types.modulo;
  11635. // exponentiation operator ** and **=
  11636. if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
  11637. ++size;
  11638. tokentype = types.starstar;
  11639. next = this.input.charCodeAt(this.pos + 2);
  11640. }
  11641. if (next === 61) {
  11642. return this.finishOp(types.assign, size + 1);
  11643. }
  11644. return this.finishOp(tokentype, size);
  11645. };
  11646. pp$8.readToken_pipe_amp = function (code) {
  11647. // '|&'
  11648. var next = this.input.charCodeAt(this.pos + 1);
  11649. if (next === code) {
  11650. return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2);
  11651. }
  11652. if (next === 61) {
  11653. return this.finishOp(types.assign, 2);
  11654. }
  11655. return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1);
  11656. };
  11657. pp$8.readToken_caret = function () {
  11658. // '^'
  11659. var next = this.input.charCodeAt(this.pos + 1);
  11660. if (next === 61) {
  11661. return this.finishOp(types.assign, 2);
  11662. }
  11663. return this.finishOp(types.bitwiseXOR, 1);
  11664. };
  11665. pp$8.readToken_plus_min = function (code) {
  11666. // '+-'
  11667. var next = this.input.charCodeAt(this.pos + 1);
  11668. if (next === code) {
  11669. if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
  11670. // A `-->` line comment
  11671. this.skipLineComment(3);
  11672. this.skipSpace();
  11673. return this.nextToken();
  11674. }
  11675. return this.finishOp(types.incDec, 2);
  11676. }
  11677. if (next === 61) {
  11678. return this.finishOp(types.assign, 2);
  11679. }
  11680. return this.finishOp(types.plusMin, 1);
  11681. };
  11682. pp$8.readToken_lt_gt = function (code) {
  11683. // '<>'
  11684. var next = this.input.charCodeAt(this.pos + 1);
  11685. var size = 1;
  11686. if (next === code) {
  11687. size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
  11688. if (this.input.charCodeAt(this.pos + size) === 61) {
  11689. return this.finishOp(types.assign, size + 1);
  11690. }
  11691. return this.finishOp(types.bitShift, size);
  11692. }
  11693. if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45) {
  11694. // `<!--`, an XML-style comment that should be interpreted as a line comment
  11695. this.skipLineComment(4);
  11696. this.skipSpace();
  11697. return this.nextToken();
  11698. }
  11699. if (next === 61) {
  11700. size = 2;
  11701. }
  11702. return this.finishOp(types.relational, size);
  11703. };
  11704. pp$8.readToken_eq_excl = function (code) {
  11705. // '=!'
  11706. var next = this.input.charCodeAt(this.pos + 1);
  11707. if (next === 61) {
  11708. return this.finishOp(types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
  11709. }
  11710. if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
  11711. // '=>'
  11712. this.pos += 2;
  11713. return this.finishToken(types.arrow);
  11714. }
  11715. return this.finishOp(code === 61 ? types.eq : types.prefix, 1);
  11716. };
  11717. pp$8.getTokenFromCode = function (code) {
  11718. switch (code) {
  11719. // The interpretation of a dot depends on whether it is followed
  11720. // by a digit or another two dots.
  11721. case 46:
  11722. // '.'
  11723. return this.readToken_dot();
  11724. // Punctuation tokens.
  11725. case 40:
  11726. ++this.pos;return this.finishToken(types.parenL);
  11727. case 41:
  11728. ++this.pos;return this.finishToken(types.parenR);
  11729. case 59:
  11730. ++this.pos;return this.finishToken(types.semi);
  11731. case 44:
  11732. ++this.pos;return this.finishToken(types.comma);
  11733. case 91:
  11734. ++this.pos;return this.finishToken(types.bracketL);
  11735. case 93:
  11736. ++this.pos;return this.finishToken(types.bracketR);
  11737. case 123:
  11738. ++this.pos;return this.finishToken(types.braceL);
  11739. case 125:
  11740. ++this.pos;return this.finishToken(types.braceR);
  11741. case 58:
  11742. ++this.pos;return this.finishToken(types.colon);
  11743. case 63:
  11744. ++this.pos;return this.finishToken(types.question);
  11745. case 96:
  11746. // '`'
  11747. if (this.options.ecmaVersion < 6) {
  11748. break;
  11749. }
  11750. ++this.pos;
  11751. return this.finishToken(types.backQuote);
  11752. case 48:
  11753. // '0'
  11754. var next = this.input.charCodeAt(this.pos + 1);
  11755. if (next === 120 || next === 88) {
  11756. return this.readRadixNumber(16);
  11757. } // '0x', '0X' - hex number
  11758. if (this.options.ecmaVersion >= 6) {
  11759. if (next === 111 || next === 79) {
  11760. return this.readRadixNumber(8);
  11761. } // '0o', '0O' - octal number
  11762. if (next === 98 || next === 66) {
  11763. return this.readRadixNumber(2);
  11764. } // '0b', '0B' - binary number
  11765. }
  11766. // Anything else beginning with a digit is an integer, octal
  11767. // number, or float.
  11768. case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:
  11769. // 1-9
  11770. return this.readNumber(false);
  11771. // Quotes produce strings.
  11772. case 34:case 39:
  11773. // '"', "'"
  11774. return this.readString(code);
  11775. // Operators are parsed inline in tiny state machines. '=' (61) is
  11776. // often referred to. `finishOp` simply skips the amount of
  11777. // characters it is given as second argument, and returns a token
  11778. // of the type given by its first argument.
  11779. case 47:
  11780. // '/'
  11781. return this.readToken_slash();
  11782. case 37:case 42:
  11783. // '%*'
  11784. return this.readToken_mult_modulo_exp(code);
  11785. case 124:case 38:
  11786. // '|&'
  11787. return this.readToken_pipe_amp(code);
  11788. case 94:
  11789. // '^'
  11790. return this.readToken_caret();
  11791. case 43:case 45:
  11792. // '+-'
  11793. return this.readToken_plus_min(code);
  11794. case 60:case 62:
  11795. // '<>'
  11796. return this.readToken_lt_gt(code);
  11797. case 61:case 33:
  11798. // '=!'
  11799. return this.readToken_eq_excl(code);
  11800. case 126:
  11801. // '~'
  11802. return this.finishOp(types.prefix, 1);
  11803. }
  11804. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  11805. };
  11806. pp$8.finishOp = function (type, size) {
  11807. var str = this.input.slice(this.pos, this.pos + size);
  11808. this.pos += size;
  11809. return this.finishToken(type, str);
  11810. };
  11811. pp$8.readRegexp = function () {
  11812. var this$1 = this;
  11813. var escaped,
  11814. inClass,
  11815. start = this.pos;
  11816. for (;;) {
  11817. if (this$1.pos >= this$1.input.length) {
  11818. this$1.raise(start, "Unterminated regular expression");
  11819. }
  11820. var ch = this$1.input.charAt(this$1.pos);
  11821. if (lineBreak.test(ch)) {
  11822. this$1.raise(start, "Unterminated regular expression");
  11823. }
  11824. if (!escaped) {
  11825. if (ch === "[") {
  11826. inClass = true;
  11827. } else if (ch === "]" && inClass) {
  11828. inClass = false;
  11829. } else if (ch === "/" && !inClass) {
  11830. break;
  11831. }
  11832. escaped = ch === "\\";
  11833. } else {
  11834. escaped = false;
  11835. }
  11836. ++this$1.pos;
  11837. }
  11838. var pattern = this.input.slice(start, this.pos);
  11839. ++this.pos;
  11840. var flagsStart = this.pos;
  11841. var flags = this.readWord1();
  11842. if (this.containsEsc) {
  11843. this.unexpected(flagsStart);
  11844. }
  11845. // Validate pattern
  11846. var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
  11847. state.reset(start, pattern, flags);
  11848. this.validateRegExpFlags(state);
  11849. this.validateRegExpPattern(state);
  11850. // Create Literal#value property value.
  11851. var value = null;
  11852. try {
  11853. value = new RegExp(pattern, flags);
  11854. } catch (e) {
  11855. // ESTree requires null if it failed to instantiate RegExp object.
  11856. // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
  11857. }
  11858. return this.finishToken(types.regexp, { pattern: pattern, flags: flags, value: value });
  11859. };
  11860. // Read an integer in the given radix. Return null if zero digits
  11861. // were read, the integer value otherwise. When `len` is given, this
  11862. // will return `null` unless the integer has exactly `len` digits.
  11863. pp$8.readInt = function (radix, len) {
  11864. var this$1 = this;
  11865. var start = this.pos,
  11866. total = 0;
  11867. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  11868. var code = this$1.input.charCodeAt(this$1.pos),
  11869. val = void 0;
  11870. if (code >= 97) {
  11871. val = code - 97 + 10;
  11872. } // a
  11873. else if (code >= 65) {
  11874. val = code - 65 + 10;
  11875. } // A
  11876. else if (code >= 48 && code <= 57) {
  11877. val = code - 48;
  11878. } // 0-9
  11879. else {
  11880. val = Infinity;
  11881. }
  11882. if (val >= radix) {
  11883. break;
  11884. }
  11885. ++this$1.pos;
  11886. total = total * radix + val;
  11887. }
  11888. if (this.pos === start || len != null && this.pos - start !== len) {
  11889. return null;
  11890. }
  11891. return total;
  11892. };
  11893. pp$8.readRadixNumber = function (radix) {
  11894. this.pos += 2; // 0x
  11895. var val = this.readInt(radix);
  11896. if (val == null) {
  11897. this.raise(this.start + 2, "Expected number in radix " + radix);
  11898. }
  11899. if (isIdentifierStart(this.fullCharCodeAtPos())) {
  11900. this.raise(this.pos, "Identifier directly after number");
  11901. }
  11902. return this.finishToken(types.num, val);
  11903. };
  11904. // Read an integer, octal integer, or floating-point number.
  11905. pp$8.readNumber = function (startsWithDot) {
  11906. var start = this.pos;
  11907. if (!startsWithDot && this.readInt(10) === null) {
  11908. this.raise(start, "Invalid number");
  11909. }
  11910. var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  11911. if (octal && this.strict) {
  11912. this.raise(start, "Invalid number");
  11913. }
  11914. if (octal && /[89]/.test(this.input.slice(start, this.pos))) {
  11915. octal = false;
  11916. }
  11917. var next = this.input.charCodeAt(this.pos);
  11918. if (next === 46 && !octal) {
  11919. // '.'
  11920. ++this.pos;
  11921. this.readInt(10);
  11922. next = this.input.charCodeAt(this.pos);
  11923. }
  11924. if ((next === 69 || next === 101) && !octal) {
  11925. // 'eE'
  11926. next = this.input.charCodeAt(++this.pos);
  11927. if (next === 43 || next === 45) {
  11928. ++this.pos;
  11929. } // '+-'
  11930. if (this.readInt(10) === null) {
  11931. this.raise(start, "Invalid number");
  11932. }
  11933. }
  11934. if (isIdentifierStart(this.fullCharCodeAtPos())) {
  11935. this.raise(this.pos, "Identifier directly after number");
  11936. }
  11937. var str = this.input.slice(start, this.pos);
  11938. var val = octal ? parseInt(str, 8) : parseFloat(str);
  11939. return this.finishToken(types.num, val);
  11940. };
  11941. // Read a string value, interpreting backslash-escapes.
  11942. pp$8.readCodePoint = function () {
  11943. var ch = this.input.charCodeAt(this.pos),
  11944. code;
  11945. if (ch === 123) {
  11946. // '{'
  11947. if (this.options.ecmaVersion < 6) {
  11948. this.unexpected();
  11949. }
  11950. var codePos = ++this.pos;
  11951. code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
  11952. ++this.pos;
  11953. if (code > 0x10FFFF) {
  11954. this.invalidStringToken(codePos, "Code point out of bounds");
  11955. }
  11956. } else {
  11957. code = this.readHexChar(4);
  11958. }
  11959. return code;
  11960. };
  11961. function codePointToString(code) {
  11962. // UTF-16 Decoding
  11963. if (code <= 0xFFFF) {
  11964. return String.fromCharCode(code);
  11965. }
  11966. code -= 0x10000;
  11967. return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00);
  11968. }
  11969. pp$8.readString = function (quote) {
  11970. var this$1 = this;
  11971. var out = "",
  11972. chunkStart = ++this.pos;
  11973. for (;;) {
  11974. if (this$1.pos >= this$1.input.length) {
  11975. this$1.raise(this$1.start, "Unterminated string constant");
  11976. }
  11977. var ch = this$1.input.charCodeAt(this$1.pos);
  11978. if (ch === quote) {
  11979. break;
  11980. }
  11981. if (ch === 92) {
  11982. // '\'
  11983. out += this$1.input.slice(chunkStart, this$1.pos);
  11984. out += this$1.readEscapedChar(false);
  11985. chunkStart = this$1.pos;
  11986. } else {
  11987. if (isNewLine(ch, this$1.options.ecmaVersion >= 10)) {
  11988. this$1.raise(this$1.start, "Unterminated string constant");
  11989. }
  11990. ++this$1.pos;
  11991. }
  11992. }
  11993. out += this.input.slice(chunkStart, this.pos++);
  11994. return this.finishToken(types.string, out);
  11995. };
  11996. // Reads template string tokens.
  11997. var INVALID_TEMPLATE_ESCAPE_ERROR = {};
  11998. pp$8.tryReadTemplateToken = function () {
  11999. this.inTemplateElement = true;
  12000. try {
  12001. this.readTmplToken();
  12002. } catch (err) {
  12003. if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
  12004. this.readInvalidTemplateToken();
  12005. } else {
  12006. throw err;
  12007. }
  12008. }
  12009. this.inTemplateElement = false;
  12010. };
  12011. pp$8.invalidStringToken = function (position, message) {
  12012. if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
  12013. throw INVALID_TEMPLATE_ESCAPE_ERROR;
  12014. } else {
  12015. this.raise(position, message);
  12016. }
  12017. };
  12018. pp$8.readTmplToken = function () {
  12019. var this$1 = this;
  12020. var out = "",
  12021. chunkStart = this.pos;
  12022. for (;;) {
  12023. if (this$1.pos >= this$1.input.length) {
  12024. this$1.raise(this$1.start, "Unterminated template");
  12025. }
  12026. var ch = this$1.input.charCodeAt(this$1.pos);
  12027. if (ch === 96 || ch === 36 && this$1.input.charCodeAt(this$1.pos + 1) === 123) {
  12028. // '`', '${'
  12029. if (this$1.pos === this$1.start && (this$1.type === types.template || this$1.type === types.invalidTemplate)) {
  12030. if (ch === 36) {
  12031. this$1.pos += 2;
  12032. return this$1.finishToken(types.dollarBraceL);
  12033. } else {
  12034. ++this$1.pos;
  12035. return this$1.finishToken(types.backQuote);
  12036. }
  12037. }
  12038. out += this$1.input.slice(chunkStart, this$1.pos);
  12039. return this$1.finishToken(types.template, out);
  12040. }
  12041. if (ch === 92) {
  12042. // '\'
  12043. out += this$1.input.slice(chunkStart, this$1.pos);
  12044. out += this$1.readEscapedChar(true);
  12045. chunkStart = this$1.pos;
  12046. } else if (isNewLine(ch)) {
  12047. out += this$1.input.slice(chunkStart, this$1.pos);
  12048. ++this$1.pos;
  12049. switch (ch) {
  12050. case 13:
  12051. if (this$1.input.charCodeAt(this$1.pos) === 10) {
  12052. ++this$1.pos;
  12053. }
  12054. case 10:
  12055. out += "\n";
  12056. break;
  12057. default:
  12058. out += String.fromCharCode(ch);
  12059. break;
  12060. }
  12061. if (this$1.options.locations) {
  12062. ++this$1.curLine;
  12063. this$1.lineStart = this$1.pos;
  12064. }
  12065. chunkStart = this$1.pos;
  12066. } else {
  12067. ++this$1.pos;
  12068. }
  12069. }
  12070. };
  12071. // Reads a template token to search for the end, without validating any escape sequences
  12072. pp$8.readInvalidTemplateToken = function () {
  12073. var this$1 = this;
  12074. for (; this.pos < this.input.length; this.pos++) {
  12075. switch (this$1.input[this$1.pos]) {
  12076. case "\\":
  12077. ++this$1.pos;
  12078. break;
  12079. case "$":
  12080. if (this$1.input[this$1.pos + 1] !== "{") {
  12081. break;
  12082. }
  12083. // falls through
  12084. case "`":
  12085. return this$1.finishToken(types.invalidTemplate, this$1.input.slice(this$1.start, this$1.pos));
  12086. // no default
  12087. }
  12088. }
  12089. this.raise(this.start, "Unterminated template");
  12090. };
  12091. // Used to read escaped characters
  12092. pp$8.readEscapedChar = function (inTemplate) {
  12093. var ch = this.input.charCodeAt(++this.pos);
  12094. ++this.pos;
  12095. switch (ch) {
  12096. case 110:
  12097. return "\n"; // 'n' -> '\n'
  12098. case 114:
  12099. return "\r"; // 'r' -> '\r'
  12100. case 120:
  12101. return String.fromCharCode(this.readHexChar(2)); // 'x'
  12102. case 117:
  12103. return codePointToString(this.readCodePoint()); // 'u'
  12104. case 116:
  12105. return "\t"; // 't' -> '\t'
  12106. case 98:
  12107. return "\b"; // 'b' -> '\b'
  12108. case 118:
  12109. return '\x0B'; // 'v' -> '\u000b'
  12110. case 102:
  12111. return "\f"; // 'f' -> '\f'
  12112. case 13:
  12113. if (this.input.charCodeAt(this.pos) === 10) {
  12114. ++this.pos;
  12115. } // '\r\n'
  12116. case 10:
  12117. // ' \n'
  12118. if (this.options.locations) {
  12119. this.lineStart = this.pos;++this.curLine;
  12120. }
  12121. return "";
  12122. default:
  12123. if (ch >= 48 && ch <= 55) {
  12124. var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
  12125. var octal = parseInt(octalStr, 8);
  12126. if (octal > 255) {
  12127. octalStr = octalStr.slice(0, -1);
  12128. octal = parseInt(octalStr, 8);
  12129. }
  12130. this.pos += octalStr.length - 1;
  12131. ch = this.input.charCodeAt(this.pos);
  12132. if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
  12133. this.invalidStringToken(this.pos - 1 - octalStr.length, inTemplate ? "Octal literal in template string" : "Octal literal in strict mode");
  12134. }
  12135. return String.fromCharCode(octal);
  12136. }
  12137. return String.fromCharCode(ch);
  12138. }
  12139. };
  12140. // Used to read character escape sequences ('\x', '\u', '\U').
  12141. pp$8.readHexChar = function (len) {
  12142. var codePos = this.pos;
  12143. var n = this.readInt(16, len);
  12144. if (n === null) {
  12145. this.invalidStringToken(codePos, "Bad character escape sequence");
  12146. }
  12147. return n;
  12148. };
  12149. // Read an identifier, and return it as a string. Sets `this.containsEsc`
  12150. // to whether the word contained a '\u' escape.
  12151. //
  12152. // Incrementally adds only escaped chars, adding other chunks as-is
  12153. // as a micro-optimization.
  12154. pp$8.readWord1 = function () {
  12155. var this$1 = this;
  12156. this.containsEsc = false;
  12157. var word = "",
  12158. first = true,
  12159. chunkStart = this.pos;
  12160. var astral = this.options.ecmaVersion >= 6;
  12161. while (this.pos < this.input.length) {
  12162. var ch = this$1.fullCharCodeAtPos();
  12163. if (isIdentifierChar(ch, astral)) {
  12164. this$1.pos += ch <= 0xffff ? 1 : 2;
  12165. } else if (ch === 92) {
  12166. // "\"
  12167. this$1.containsEsc = true;
  12168. word += this$1.input.slice(chunkStart, this$1.pos);
  12169. var escStart = this$1.pos;
  12170. if (this$1.input.charCodeAt(++this$1.pos) !== 117) // "u"
  12171. {
  12172. this$1.invalidStringToken(this$1.pos, 'Expecting Unicode escape sequence \\uXXXX');
  12173. }
  12174. ++this$1.pos;
  12175. var esc = this$1.readCodePoint();
  12176. if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) {
  12177. this$1.invalidStringToken(escStart, "Invalid Unicode escape");
  12178. }
  12179. word += codePointToString(esc);
  12180. chunkStart = this$1.pos;
  12181. } else {
  12182. break;
  12183. }
  12184. first = false;
  12185. }
  12186. return word + this.input.slice(chunkStart, this.pos);
  12187. };
  12188. // Read an identifier or keyword token. Will check for reserved
  12189. // words when necessary.
  12190. pp$8.readWord = function () {
  12191. var word = this.readWord1();
  12192. var type = types.name;
  12193. if (this.keywords.test(word)) {
  12194. if (this.containsEsc) {
  12195. this.raiseRecoverable(this.start, "Escape sequence in keyword " + word);
  12196. }
  12197. type = keywords$1[word];
  12198. }
  12199. return this.finishToken(type, word);
  12200. };
  12201. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
  12202. //
  12203. // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
  12204. // various contributors and released under an MIT license.
  12205. //
  12206. // Git repositories for Acorn are available at
  12207. //
  12208. // http://marijnhaverbeke.nl/git/acorn
  12209. // https://github.com/acornjs/acorn.git
  12210. //
  12211. // Please use the [github bug tracker][ghbt] to report issues.
  12212. //
  12213. // [ghbt]: https://github.com/acornjs/acorn/issues
  12214. //
  12215. // [walk]: util/walk.js
  12216. var version = "6.0.4";
  12217. // The main exported interface (under `self.acorn` when in the
  12218. // browser) is a `parse` function that takes a code string and
  12219. // returns an abstract syntax tree as specified by [Mozilla parser
  12220. // API][api].
  12221. //
  12222. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  12223. function parse(input, options) {
  12224. return Parser.parse(input, options);
  12225. }
  12226. // This function tries to parse a single expression at a given
  12227. // offset in a string. Useful for parsing mixed-language formats
  12228. // that embed JavaScript expressions.
  12229. function parseExpressionAt(input, pos, options) {
  12230. return Parser.parseExpressionAt(input, pos, options);
  12231. }
  12232. // Acorn is organized as a tokenizer and a recursive-descent parser.
  12233. // The `tokenizer` export provides an interface to the tokenizer.
  12234. function tokenizer(input, options) {
  12235. return Parser.tokenizer(input, options);
  12236. }
  12237. exports.version = version;
  12238. exports.parse = parse;
  12239. exports.parseExpressionAt = parseExpressionAt;
  12240. exports.tokenizer = tokenizer;
  12241. exports.Parser = Parser;
  12242. exports.defaultOptions = defaultOptions;
  12243. exports.Position = Position;
  12244. exports.SourceLocation = SourceLocation;
  12245. exports.getLineInfo = getLineInfo;
  12246. exports.Node = Node;
  12247. exports.TokenType = TokenType;
  12248. exports.tokTypes = types;
  12249. exports.keywordTypes = keywords$1;
  12250. exports.TokContext = TokContext;
  12251. exports.tokContexts = types$1;
  12252. exports.isIdentifierChar = isIdentifierChar;
  12253. exports.isIdentifierStart = isIdentifierStart;
  12254. exports.Token = Token;
  12255. exports.isNewLine = isNewLine;
  12256. exports.lineBreak = lineBreak;
  12257. exports.lineBreakG = lineBreakG;
  12258. exports.nonASCIIwhitespace = nonASCIIwhitespace;
  12259. Object.defineProperty(exports, '__esModule', { value: true });
  12260. });
  12261. },{}],4:[function(require,module,exports){
  12262. /**
  12263. * @author Toru Nagashima <https://github.com/mysticatea>
  12264. * See LICENSE file in root directory for full license.
  12265. */
  12266. "use strict";
  12267. var KEYS = require("./visitor-keys.json");
  12268. // Types.
  12269. var NODE_TYPES = Object.freeze(Object.keys(KEYS));
  12270. // Freeze the keys.
  12271. var _iteratorNormalCompletion = true;
  12272. var _didIteratorError = false;
  12273. var _iteratorError = undefined;
  12274. try {
  12275. for (var _iterator = NODE_TYPES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  12276. var type = _step.value;
  12277. Object.freeze(KEYS[type]);
  12278. }
  12279. } catch (err) {
  12280. _didIteratorError = true;
  12281. _iteratorError = err;
  12282. } finally {
  12283. try {
  12284. if (!_iteratorNormalCompletion && _iterator.return) {
  12285. _iterator.return();
  12286. }
  12287. } finally {
  12288. if (_didIteratorError) {
  12289. throw _iteratorError;
  12290. }
  12291. }
  12292. }
  12293. Object.freeze(KEYS);
  12294. // List to ignore keys.
  12295. var KEY_BLACKLIST = new Set(["parent", "leadingComments", "trailingComments"]);
  12296. /**
  12297. * Check whether a given key should be used or not.
  12298. * @param {string} key The key to check.
  12299. * @returns {boolean} `true` if the key should be used.
  12300. */
  12301. function filterKey(key) {
  12302. return !KEY_BLACKLIST.has(key) && key[0] !== "_";
  12303. }
  12304. //------------------------------------------------------------------------------
  12305. // Public interfaces
  12306. //------------------------------------------------------------------------------
  12307. module.exports = Object.freeze({
  12308. /**
  12309. * Visitor keys.
  12310. * @type {{ [type: string]: string[] | undefined }}
  12311. */
  12312. KEYS: KEYS,
  12313. /**
  12314. * Get visitor keys of a given node.
  12315. * @param {Object} node The AST node to get keys.
  12316. * @returns {string[]} Visitor keys of the node.
  12317. */
  12318. getKeys: function getKeys(node) {
  12319. return Object.keys(node).filter(filterKey);
  12320. },
  12321. // Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
  12322. // eslint-disable-next-line valid-jsdoc
  12323. /**
  12324. * Make the union set with `KEYS` and given keys.
  12325. * @param {Object} additionalKeys The additional keys.
  12326. * @returns {{ [type: string]: string[] | undefined }} The union set.
  12327. */
  12328. unionWith: function unionWith(additionalKeys) {
  12329. var retv = Object.assign({}, KEYS);
  12330. var _iteratorNormalCompletion2 = true;
  12331. var _didIteratorError2 = false;
  12332. var _iteratorError2 = undefined;
  12333. try {
  12334. for (var _iterator2 = Object.keys(additionalKeys)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  12335. var type = _step2.value;
  12336. if (retv.hasOwnProperty(type)) {
  12337. var keys = new Set(additionalKeys[type]);
  12338. var _iteratorNormalCompletion3 = true;
  12339. var _didIteratorError3 = false;
  12340. var _iteratorError3 = undefined;
  12341. try {
  12342. for (var _iterator3 = retv[type][Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  12343. var key = _step3.value;
  12344. keys.add(key);
  12345. }
  12346. } catch (err) {
  12347. _didIteratorError3 = true;
  12348. _iteratorError3 = err;
  12349. } finally {
  12350. try {
  12351. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  12352. _iterator3.return();
  12353. }
  12354. } finally {
  12355. if (_didIteratorError3) {
  12356. throw _iteratorError3;
  12357. }
  12358. }
  12359. }
  12360. retv[type] = Object.freeze(Array.from(keys));
  12361. } else {
  12362. retv[type] = Object.freeze(Array.from(additionalKeys[type]));
  12363. }
  12364. }
  12365. } catch (err) {
  12366. _didIteratorError2 = true;
  12367. _iteratorError2 = err;
  12368. } finally {
  12369. try {
  12370. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  12371. _iterator2.return();
  12372. }
  12373. } finally {
  12374. if (_didIteratorError2) {
  12375. throw _iteratorError2;
  12376. }
  12377. }
  12378. }
  12379. return Object.freeze(retv);
  12380. }
  12381. });
  12382. },{"./visitor-keys.json":5}],5:[function(require,module,exports){
  12383. module.exports={
  12384. "AssignmentExpression": [
  12385. "left",
  12386. "right"
  12387. ],
  12388. "AssignmentPattern": [
  12389. "left",
  12390. "right"
  12391. ],
  12392. "ArrayExpression": [
  12393. "elements"
  12394. ],
  12395. "ArrayPattern": [
  12396. "elements"
  12397. ],
  12398. "ArrowFunctionExpression": [
  12399. "params",
  12400. "body"
  12401. ],
  12402. "AwaitExpression": [
  12403. "argument"
  12404. ],
  12405. "BlockStatement": [
  12406. "body"
  12407. ],
  12408. "BinaryExpression": [
  12409. "left",
  12410. "right"
  12411. ],
  12412. "BreakStatement": [
  12413. "label"
  12414. ],
  12415. "CallExpression": [
  12416. "callee",
  12417. "arguments"
  12418. ],
  12419. "CatchClause": [
  12420. "param",
  12421. "body"
  12422. ],
  12423. "ClassBody": [
  12424. "body"
  12425. ],
  12426. "ClassDeclaration": [
  12427. "id",
  12428. "superClass",
  12429. "body"
  12430. ],
  12431. "ClassExpression": [
  12432. "id",
  12433. "superClass",
  12434. "body"
  12435. ],
  12436. "ConditionalExpression": [
  12437. "test",
  12438. "consequent",
  12439. "alternate"
  12440. ],
  12441. "ContinueStatement": [
  12442. "label"
  12443. ],
  12444. "DebuggerStatement": [],
  12445. "DoWhileStatement": [
  12446. "body",
  12447. "test"
  12448. ],
  12449. "EmptyStatement": [],
  12450. "ExportAllDeclaration": [
  12451. "source"
  12452. ],
  12453. "ExportDefaultDeclaration": [
  12454. "declaration"
  12455. ],
  12456. "ExportNamedDeclaration": [
  12457. "declaration",
  12458. "specifiers",
  12459. "source"
  12460. ],
  12461. "ExportSpecifier": [
  12462. "exported",
  12463. "local"
  12464. ],
  12465. "ExpressionStatement": [
  12466. "expression"
  12467. ],
  12468. "ExperimentalRestProperty": [
  12469. "argument"
  12470. ],
  12471. "ExperimentalSpreadProperty": [
  12472. "argument"
  12473. ],
  12474. "ForStatement": [
  12475. "init",
  12476. "test",
  12477. "update",
  12478. "body"
  12479. ],
  12480. "ForInStatement": [
  12481. "left",
  12482. "right",
  12483. "body"
  12484. ],
  12485. "ForOfStatement": [
  12486. "left",
  12487. "right",
  12488. "body"
  12489. ],
  12490. "FunctionDeclaration": [
  12491. "id",
  12492. "params",
  12493. "body"
  12494. ],
  12495. "FunctionExpression": [
  12496. "id",
  12497. "params",
  12498. "body"
  12499. ],
  12500. "Identifier": [],
  12501. "IfStatement": [
  12502. "test",
  12503. "consequent",
  12504. "alternate"
  12505. ],
  12506. "ImportDeclaration": [
  12507. "specifiers",
  12508. "source"
  12509. ],
  12510. "ImportDefaultSpecifier": [
  12511. "local"
  12512. ],
  12513. "ImportNamespaceSpecifier": [
  12514. "local"
  12515. ],
  12516. "ImportSpecifier": [
  12517. "imported",
  12518. "local"
  12519. ],
  12520. "JSXAttribute": [
  12521. "name",
  12522. "value"
  12523. ],
  12524. "JSXClosingElement": [
  12525. "name"
  12526. ],
  12527. "JSXElement": [
  12528. "openingElement",
  12529. "children",
  12530. "closingElement"
  12531. ],
  12532. "JSXEmptyExpression": [],
  12533. "JSXExpressionContainer": [
  12534. "expression"
  12535. ],
  12536. "JSXIdentifier": [],
  12537. "JSXMemberExpression": [
  12538. "object",
  12539. "property"
  12540. ],
  12541. "JSXNamespacedName": [
  12542. "namespace",
  12543. "name"
  12544. ],
  12545. "JSXOpeningElement": [
  12546. "name",
  12547. "attributes"
  12548. ],
  12549. "JSXSpreadAttribute": [
  12550. "argument"
  12551. ],
  12552. "JSXText": [],
  12553. "JSXFragment": [
  12554. "openingFragment",
  12555. "children",
  12556. "closingFragment"
  12557. ],
  12558. "Literal": [],
  12559. "LabeledStatement": [
  12560. "label",
  12561. "body"
  12562. ],
  12563. "LogicalExpression": [
  12564. "left",
  12565. "right"
  12566. ],
  12567. "MemberExpression": [
  12568. "object",
  12569. "property"
  12570. ],
  12571. "MetaProperty": [
  12572. "meta",
  12573. "property"
  12574. ],
  12575. "MethodDefinition": [
  12576. "key",
  12577. "value"
  12578. ],
  12579. "NewExpression": [
  12580. "callee",
  12581. "arguments"
  12582. ],
  12583. "ObjectExpression": [
  12584. "properties"
  12585. ],
  12586. "ObjectPattern": [
  12587. "properties"
  12588. ],
  12589. "Program": [
  12590. "body"
  12591. ],
  12592. "Property": [
  12593. "key",
  12594. "value"
  12595. ],
  12596. "RestElement": [
  12597. "argument"
  12598. ],
  12599. "ReturnStatement": [
  12600. "argument"
  12601. ],
  12602. "SequenceExpression": [
  12603. "expressions"
  12604. ],
  12605. "SpreadElement": [
  12606. "argument"
  12607. ],
  12608. "Super": [],
  12609. "SwitchStatement": [
  12610. "discriminant",
  12611. "cases"
  12612. ],
  12613. "SwitchCase": [
  12614. "test",
  12615. "consequent"
  12616. ],
  12617. "TaggedTemplateExpression": [
  12618. "tag",
  12619. "quasi"
  12620. ],
  12621. "TemplateElement": [],
  12622. "TemplateLiteral": [
  12623. "quasis",
  12624. "expressions"
  12625. ],
  12626. "ThisExpression": [],
  12627. "ThrowStatement": [
  12628. "argument"
  12629. ],
  12630. "TryStatement": [
  12631. "block",
  12632. "handler",
  12633. "finalizer"
  12634. ],
  12635. "UnaryExpression": [
  12636. "argument"
  12637. ],
  12638. "UpdateExpression": [
  12639. "argument"
  12640. ],
  12641. "VariableDeclaration": [
  12642. "declarations"
  12643. ],
  12644. "VariableDeclarator": [
  12645. "id",
  12646. "init"
  12647. ],
  12648. "WhileStatement": [
  12649. "test",
  12650. "body"
  12651. ],
  12652. "WithStatement": [
  12653. "object",
  12654. "body"
  12655. ],
  12656. "YieldExpression": [
  12657. "argument"
  12658. ]
  12659. }
  12660. },{}],6:[function(require,module,exports){
  12661. /**
  12662. * @fileoverview The AST node types produced by the parser.
  12663. * @author Nicholas C. Zakas
  12664. */
  12665. "use strict";
  12666. //------------------------------------------------------------------------------
  12667. // Requirements
  12668. //------------------------------------------------------------------------------
  12669. // None!
  12670. //------------------------------------------------------------------------------
  12671. // Public
  12672. //------------------------------------------------------------------------------
  12673. module.exports = {
  12674. AssignmentExpression: "AssignmentExpression",
  12675. AssignmentPattern: "AssignmentPattern",
  12676. ArrayExpression: "ArrayExpression",
  12677. ArrayPattern: "ArrayPattern",
  12678. ArrowFunctionExpression: "ArrowFunctionExpression",
  12679. AwaitExpression: "AwaitExpression",
  12680. BlockStatement: "BlockStatement",
  12681. BinaryExpression: "BinaryExpression",
  12682. BreakStatement: "BreakStatement",
  12683. CallExpression: "CallExpression",
  12684. CatchClause: "CatchClause",
  12685. ClassBody: "ClassBody",
  12686. ClassDeclaration: "ClassDeclaration",
  12687. ClassExpression: "ClassExpression",
  12688. ConditionalExpression: "ConditionalExpression",
  12689. ContinueStatement: "ContinueStatement",
  12690. DoWhileStatement: "DoWhileStatement",
  12691. DebuggerStatement: "DebuggerStatement",
  12692. EmptyStatement: "EmptyStatement",
  12693. ExpressionStatement: "ExpressionStatement",
  12694. ForStatement: "ForStatement",
  12695. ForInStatement: "ForInStatement",
  12696. ForOfStatement: "ForOfStatement",
  12697. FunctionDeclaration: "FunctionDeclaration",
  12698. FunctionExpression: "FunctionExpression",
  12699. Identifier: "Identifier",
  12700. IfStatement: "IfStatement",
  12701. Literal: "Literal",
  12702. LabeledStatement: "LabeledStatement",
  12703. LogicalExpression: "LogicalExpression",
  12704. MemberExpression: "MemberExpression",
  12705. MetaProperty: "MetaProperty",
  12706. MethodDefinition: "MethodDefinition",
  12707. NewExpression: "NewExpression",
  12708. ObjectExpression: "ObjectExpression",
  12709. ObjectPattern: "ObjectPattern",
  12710. Program: "Program",
  12711. Property: "Property",
  12712. RestElement: "RestElement",
  12713. ReturnStatement: "ReturnStatement",
  12714. SequenceExpression: "SequenceExpression",
  12715. SpreadElement: "SpreadElement",
  12716. Super: "Super",
  12717. SwitchCase: "SwitchCase",
  12718. SwitchStatement: "SwitchStatement",
  12719. TaggedTemplateExpression: "TaggedTemplateExpression",
  12720. TemplateElement: "TemplateElement",
  12721. TemplateLiteral: "TemplateLiteral",
  12722. ThisExpression: "ThisExpression",
  12723. ThrowStatement: "ThrowStatement",
  12724. TryStatement: "TryStatement",
  12725. UnaryExpression: "UnaryExpression",
  12726. UpdateExpression: "UpdateExpression",
  12727. VariableDeclaration: "VariableDeclaration",
  12728. VariableDeclarator: "VariableDeclarator",
  12729. WhileStatement: "WhileStatement",
  12730. WithStatement: "WithStatement",
  12731. YieldExpression: "YieldExpression",
  12732. JSXIdentifier: "JSXIdentifier",
  12733. JSXNamespacedName: "JSXNamespacedName",
  12734. JSXMemberExpression: "JSXMemberExpression",
  12735. JSXEmptyExpression: "JSXEmptyExpression",
  12736. JSXExpressionContainer: "JSXExpressionContainer",
  12737. JSXElement: "JSXElement",
  12738. JSXClosingElement: "JSXClosingElement",
  12739. JSXOpeningElement: "JSXOpeningElement",
  12740. JSXAttribute: "JSXAttribute",
  12741. JSXSpreadAttribute: "JSXSpreadAttribute",
  12742. JSXText: "JSXText",
  12743. ExportDefaultDeclaration: "ExportDefaultDeclaration",
  12744. ExportNamedDeclaration: "ExportNamedDeclaration",
  12745. ExportAllDeclaration: "ExportAllDeclaration",
  12746. ExportSpecifier: "ExportSpecifier",
  12747. ImportDeclaration: "ImportDeclaration",
  12748. ImportSpecifier: "ImportSpecifier",
  12749. ImportDefaultSpecifier: "ImportDefaultSpecifier",
  12750. ImportNamespaceSpecifier: "ImportNamespaceSpecifier"
  12751. };
  12752. },{}],7:[function(require,module,exports){
  12753. "use strict";
  12754. /* eslint-disable no-param-reassign*/
  12755. 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; }; }();
  12756. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  12757. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  12758. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12759. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  12760. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  12761. var acorn = require("acorn");
  12762. var jsx = require("acorn-jsx");
  12763. var TokenTranslator = require("./token-translator");
  12764. var DEFAULT_ECMA_VERSION = 5;
  12765. var STATE = Symbol("espree's internal state");
  12766. var ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
  12767. var tokTypes = Object.assign({}, acorn.tokTypes, jsx.tokTypes);
  12768. /**
  12769. * Normalize ECMAScript version from the initial config
  12770. * @param {number} ecmaVersion ECMAScript version from the initial config
  12771. * @returns {number} normalized ECMAScript version
  12772. */
  12773. function normalizeEcmaVersion(ecmaVersion) {
  12774. if (typeof ecmaVersion === "number") {
  12775. var version = ecmaVersion;
  12776. // Calculate ECMAScript edition number from official year version starting with
  12777. // ES2015, which corresponds with ES6 (or a difference of 2009).
  12778. if (version >= 2015) {
  12779. version -= 2009;
  12780. }
  12781. switch (version) {
  12782. case 3:
  12783. case 5:
  12784. case 6:
  12785. case 7:
  12786. case 8:
  12787. case 9:
  12788. case 10:
  12789. return version;
  12790. default:
  12791. throw new Error("Invalid ecmaVersion.");
  12792. }
  12793. } else {
  12794. return DEFAULT_ECMA_VERSION;
  12795. }
  12796. }
  12797. /**
  12798. * Converts an Acorn comment to a Esprima comment.
  12799. * @param {boolean} block True if it's a block comment, false if not.
  12800. * @param {string} text The text of the comment.
  12801. * @param {int} start The index at which the comment starts.
  12802. * @param {int} end The index at which the comment ends.
  12803. * @param {Location} startLoc The location at which the comment starts.
  12804. * @param {Location} endLoc The location at which the comment ends.
  12805. * @returns {Object} The comment object.
  12806. * @private
  12807. */
  12808. function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) {
  12809. var comment = {
  12810. type: block ? "Block" : "Line",
  12811. value: text
  12812. };
  12813. if (typeof start === "number") {
  12814. comment.start = start;
  12815. comment.end = end;
  12816. comment.range = [start, end];
  12817. }
  12818. if ((typeof startLoc === "undefined" ? "undefined" : _typeof(startLoc)) === "object") {
  12819. comment.loc = {
  12820. start: startLoc,
  12821. end: endLoc
  12822. };
  12823. }
  12824. return comment;
  12825. }
  12826. module.exports = function () {
  12827. return function (Parser) {
  12828. return function (_Parser) {
  12829. _inherits(Espree, _Parser);
  12830. function Espree(options, code) {
  12831. _classCallCheck(this, Espree);
  12832. if ((typeof options === "undefined" ? "undefined" : _typeof(options)) !== "object" || options === null) {
  12833. options = {};
  12834. }
  12835. if (typeof code !== "string" && !(code instanceof String)) {
  12836. code = String(code);
  12837. }
  12838. var ecmaFeatures = options.ecmaFeatures || {};
  12839. var ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
  12840. var isModule = options.sourceType === "module";
  12841. var tokenTranslator = options.tokens === true ? new TokenTranslator(tokTypes, code) : null;
  12842. // Initialize acorn parser.
  12843. // Initialize internal state.
  12844. var _this = _possibleConstructorReturn(this, (Espree.__proto__ || Object.getPrototypeOf(Espree)).call(this, {
  12845. ecmaVersion: isModule ? Math.max(6, ecmaVersion) : ecmaVersion,
  12846. sourceType: isModule ? "module" : "script",
  12847. ranges: options.range === true,
  12848. locations: options.loc === true,
  12849. // Truthy value is true for backward compatibility.
  12850. allowReturnOutsideFunction: Boolean(ecmaFeatures.globalReturn),
  12851. // Collect tokens
  12852. onToken: function onToken(token) {
  12853. if (tokenTranslator) {
  12854. // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
  12855. tokenTranslator.onToken(token, _this[STATE]);
  12856. }
  12857. if (token.type !== tokTypes.eof) {
  12858. _this[STATE].lastToken = token;
  12859. }
  12860. },
  12861. // Collect comments
  12862. onComment: function onComment(block, text, start, end, startLoc, endLoc) {
  12863. if (_this[STATE].comments) {
  12864. var comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);
  12865. _this[STATE].comments.push(comment);
  12866. }
  12867. }
  12868. }, code));
  12869. _this[STATE] = {
  12870. tokens: tokenTranslator ? [] : null,
  12871. comments: options.comment === true ? [] : null,
  12872. impliedStrict: ecmaFeatures.impliedStrict === true && _this.options.ecmaVersion >= 5,
  12873. ecmaVersion: _this.options.ecmaVersion,
  12874. jsxAttrValueToken: false,
  12875. lastToken: null
  12876. };
  12877. return _this;
  12878. }
  12879. _createClass(Espree, [{
  12880. key: "tokenize",
  12881. value: function tokenize() {
  12882. do {
  12883. this.next();
  12884. } while (this.type !== tokTypes.eof);
  12885. var extra = this[STATE];
  12886. var tokens = extra.tokens;
  12887. if (extra.comments) {
  12888. tokens.comments = extra.comments;
  12889. }
  12890. return tokens;
  12891. }
  12892. }, {
  12893. key: "finishNode",
  12894. value: function finishNode() {
  12895. var _get2;
  12896. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  12897. args[_key] = arguments[_key];
  12898. }
  12899. var result = (_get2 = _get(Espree.prototype.__proto__ || Object.getPrototypeOf(Espree.prototype), "finishNode", this)).call.apply(_get2, [this].concat(args));
  12900. return this[ESPRIMA_FINISH_NODE](result);
  12901. }
  12902. }, {
  12903. key: "finishNodeAt",
  12904. value: function finishNodeAt() {
  12905. var _get3;
  12906. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  12907. args[_key2] = arguments[_key2];
  12908. }
  12909. var result = (_get3 = _get(Espree.prototype.__proto__ || Object.getPrototypeOf(Espree.prototype), "finishNodeAt", this)).call.apply(_get3, [this].concat(args));
  12910. return this[ESPRIMA_FINISH_NODE](result);
  12911. }
  12912. }, {
  12913. key: "parse",
  12914. value: function parse() {
  12915. var extra = this[STATE];
  12916. var program = _get(Espree.prototype.__proto__ || Object.getPrototypeOf(Espree.prototype), "parse", this).call(this);
  12917. program.sourceType = this.options.sourceType;
  12918. if (extra.comments) {
  12919. program.comments = extra.comments;
  12920. }
  12921. if (extra.tokens) {
  12922. program.tokens = extra.tokens;
  12923. }
  12924. /*
  12925. * Adjust opening and closing position of program to match Esprima.
  12926. * Acorn always starts programs at range 0 whereas Esprima starts at the
  12927. * first AST node's start (the only real difference is when there's leading
  12928. * whitespace or leading comments). Acorn also counts trailing whitespace
  12929. * as part of the program whereas Esprima only counts up to the last token.
  12930. */
  12931. if (program.range) {
  12932. program.range[0] = program.body.length ? program.body[0].range[0] : program.range[0];
  12933. program.range[1] = extra.lastToken ? extra.lastToken.range[1] : program.range[1];
  12934. }
  12935. if (program.loc) {
  12936. program.loc.start = program.body.length ? program.body[0].loc.start : program.loc.start;
  12937. program.loc.end = extra.lastToken ? extra.lastToken.loc.end : program.loc.end;
  12938. }
  12939. return program;
  12940. }
  12941. }, {
  12942. key: "parseTopLevel",
  12943. value: function parseTopLevel(node) {
  12944. if (this[STATE].impliedStrict) {
  12945. this.strict = true;
  12946. }
  12947. return _get(Espree.prototype.__proto__ || Object.getPrototypeOf(Espree.prototype), "parseTopLevel", this).call(this, node);
  12948. }
  12949. /**
  12950. * Overwrites the default raise method to throw Esprima-style errors.
  12951. * @param {int} pos The position of the error.
  12952. * @param {string} message The error message.
  12953. * @throws {SyntaxError} A syntax error.
  12954. * @returns {void}
  12955. */
  12956. }, {
  12957. key: "raise",
  12958. value: function raise(pos, message) {
  12959. var loc = acorn.getLineInfo(this.input, pos);
  12960. var err = new SyntaxError(message);
  12961. err.index = pos;
  12962. err.lineNumber = loc.line;
  12963. err.column = loc.column + 1; // acorn uses 0-based columns
  12964. throw err;
  12965. }
  12966. /**
  12967. * Overwrites the default raise method to throw Esprima-style errors.
  12968. * @param {int} pos The position of the error.
  12969. * @param {string} message The error message.
  12970. * @throws {SyntaxError} A syntax error.
  12971. * @returns {void}
  12972. */
  12973. }, {
  12974. key: "raiseRecoverable",
  12975. value: function raiseRecoverable(pos, message) {
  12976. this.raise(pos, message);
  12977. }
  12978. /**
  12979. * Overwrites the default unexpected method to throw Esprima-style errors.
  12980. * @param {int} pos The position of the error.
  12981. * @throws {SyntaxError} A syntax error.
  12982. * @returns {void}
  12983. */
  12984. }, {
  12985. key: "unexpected",
  12986. value: function unexpected(pos) {
  12987. var message = "Unexpected token";
  12988. if (pos !== null && pos !== void 0) {
  12989. this.pos = pos;
  12990. if (this.options.locations) {
  12991. while (this.pos < this.lineStart) {
  12992. this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
  12993. --this.curLine;
  12994. }
  12995. }
  12996. this.nextToken();
  12997. }
  12998. if (this.end > this.start) {
  12999. message += " " + this.input.slice(this.start, this.end);
  13000. }
  13001. this.raise(this.start, message);
  13002. }
  13003. /*
  13004. * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX
  13005. * uses regular tt.string without any distinction between this and regular JS
  13006. * strings. As such, we intercept an attempt to read a JSX string and set a flag
  13007. * on extra so that when tokens are converted, the next token will be switched
  13008. * to JSXText via onToken.
  13009. */
  13010. }, {
  13011. key: "jsx_readString",
  13012. value: function jsx_readString(quote) {
  13013. // eslint-disable-line camelcase
  13014. var result = _get(Espree.prototype.__proto__ || Object.getPrototypeOf(Espree.prototype), "jsx_readString", this).call(this, quote);
  13015. if (this.type === tokTypes.string) {
  13016. this[STATE].jsxAttrValueToken = true;
  13017. }
  13018. return result;
  13019. }
  13020. /**
  13021. * Performs last-minute Esprima-specific compatibility checks and fixes.
  13022. * @param {ASTNode} result The node to check.
  13023. * @returns {ASTNode} The finished node.
  13024. */
  13025. }, {
  13026. key: ESPRIMA_FINISH_NODE,
  13027. value: function value(result) {
  13028. // Acorn doesn't count the opening and closing backticks as part of templates
  13029. // so we have to adjust ranges/locations appropriately.
  13030. if (result.type === "TemplateElement") {
  13031. // additional adjustment needed if ${ is the last token
  13032. var terminalDollarBraceL = this.input.slice(result.end, result.end + 2) === "${";
  13033. if (result.range) {
  13034. result.range[0]--;
  13035. result.range[1] += terminalDollarBraceL ? 2 : 1;
  13036. }
  13037. if (result.loc) {
  13038. result.loc.start.column--;
  13039. result.loc.end.column += terminalDollarBraceL ? 2 : 1;
  13040. }
  13041. }
  13042. if (result.type.indexOf("Function") > -1 && !result.generator) {
  13043. result.generator = false;
  13044. }
  13045. return result;
  13046. }
  13047. }]);
  13048. return Espree;
  13049. }(Parser);
  13050. };
  13051. };
  13052. },{"./token-translator":8,"acorn":3,"acorn-jsx":1}],8:[function(require,module,exports){
  13053. /**
  13054. * @fileoverview Translates tokens between Acorn format and Esprima format.
  13055. * @author Nicholas C. Zakas
  13056. */
  13057. /* eslint no-underscore-dangle: 0 */
  13058. "use strict";
  13059. //------------------------------------------------------------------------------
  13060. // Requirements
  13061. //------------------------------------------------------------------------------
  13062. // none!
  13063. //------------------------------------------------------------------------------
  13064. // Private
  13065. //------------------------------------------------------------------------------
  13066. // Esprima Token Types
  13067. var Token = {
  13068. Boolean: "Boolean",
  13069. EOF: "<end>",
  13070. Identifier: "Identifier",
  13071. Keyword: "Keyword",
  13072. Null: "Null",
  13073. Numeric: "Numeric",
  13074. Punctuator: "Punctuator",
  13075. String: "String",
  13076. RegularExpression: "RegularExpression",
  13077. Template: "Template",
  13078. JSXIdentifier: "JSXIdentifier",
  13079. JSXText: "JSXText"
  13080. };
  13081. /**
  13082. * Converts part of a template into an Esprima token.
  13083. * @param {AcornToken[]} tokens The Acorn tokens representing the template.
  13084. * @param {string} code The source code.
  13085. * @returns {EsprimaToken} The Esprima equivalent of the template token.
  13086. * @private
  13087. */
  13088. function convertTemplatePart(tokens, code) {
  13089. var firstToken = tokens[0],
  13090. lastTemplateToken = tokens[tokens.length - 1];
  13091. var token = {
  13092. type: Token.Template,
  13093. value: code.slice(firstToken.start, lastTemplateToken.end)
  13094. };
  13095. if (firstToken.loc) {
  13096. token.loc = {
  13097. start: firstToken.loc.start,
  13098. end: lastTemplateToken.loc.end
  13099. };
  13100. }
  13101. if (firstToken.range) {
  13102. token.start = firstToken.range[0];
  13103. token.end = lastTemplateToken.range[1];
  13104. token.range = [token.start, token.end];
  13105. }
  13106. return token;
  13107. }
  13108. /**
  13109. * Contains logic to translate Acorn tokens into Esprima tokens.
  13110. * @param {Object} acornTokTypes The Acorn token types.
  13111. * @param {string} code The source code Acorn is parsing. This is necessary
  13112. * to correct the "value" property of some tokens.
  13113. * @constructor
  13114. */
  13115. function TokenTranslator(acornTokTypes, code) {
  13116. // token types
  13117. this._acornTokTypes = acornTokTypes;
  13118. // token buffer for templates
  13119. this._tokens = [];
  13120. // track the last curly brace
  13121. this._curlyBrace = null;
  13122. // the source code
  13123. this._code = code;
  13124. }
  13125. TokenTranslator.prototype = {
  13126. constructor: TokenTranslator,
  13127. /**
  13128. * Translates a single Esprima token to a single Acorn token. This may be
  13129. * inaccurate due to how templates are handled differently in Esprima and
  13130. * Acorn, but should be accurate for all other tokens.
  13131. * @param {AcornToken} token The Acorn token to translate.
  13132. * @param {Object} extra Espree extra object.
  13133. * @returns {EsprimaToken} The Esprima version of the token.
  13134. */
  13135. translate: function translate(token, extra) {
  13136. var type = token.type,
  13137. tt = this._acornTokTypes;
  13138. if (type === tt.name) {
  13139. token.type = Token.Identifier;
  13140. // TODO: See if this is an Acorn bug
  13141. if (token.value === "static") {
  13142. token.type = Token.Keyword;
  13143. }
  13144. if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) {
  13145. token.type = Token.Keyword;
  13146. }
  13147. } else if (type === tt.semi || type === tt.comma || type === tt.parenL || type === tt.parenR || type === tt.braceL || type === tt.braceR || type === tt.dot || type === tt.bracketL || type === tt.colon || type === tt.question || type === tt.bracketR || type === tt.ellipsis || type === tt.arrow || type === tt.jsxTagStart || type === tt.incDec || type === tt.starstar || type === tt.jsxTagEnd || type === tt.prefix || type.binop && !type.keyword || type.isAssign) {
  13148. token.type = Token.Punctuator;
  13149. token.value = this._code.slice(token.start, token.end);
  13150. } else if (type === tt.jsxName) {
  13151. token.type = Token.JSXIdentifier;
  13152. } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) {
  13153. token.type = Token.JSXText;
  13154. } else if (type.keyword) {
  13155. if (type.keyword === "true" || type.keyword === "false") {
  13156. token.type = Token.Boolean;
  13157. } else if (type.keyword === "null") {
  13158. token.type = Token.Null;
  13159. } else {
  13160. token.type = Token.Keyword;
  13161. }
  13162. } else if (type === tt.num) {
  13163. token.type = Token.Numeric;
  13164. token.value = this._code.slice(token.start, token.end);
  13165. } else if (type === tt.string) {
  13166. if (extra.jsxAttrValueToken) {
  13167. extra.jsxAttrValueToken = false;
  13168. token.type = Token.JSXText;
  13169. } else {
  13170. token.type = Token.String;
  13171. }
  13172. token.value = this._code.slice(token.start, token.end);
  13173. } else if (type === tt.regexp) {
  13174. token.type = Token.RegularExpression;
  13175. var value = token.value;
  13176. token.regex = {
  13177. flags: value.flags,
  13178. pattern: value.pattern
  13179. };
  13180. token.value = "/" + value.pattern + "/" + value.flags;
  13181. }
  13182. return token;
  13183. },
  13184. /**
  13185. * Function to call during Acorn's onToken handler.
  13186. * @param {AcornToken} token The Acorn token.
  13187. * @param {Object} extra The Espree extra object.
  13188. * @returns {void}
  13189. */
  13190. onToken: function onToken(token, extra) {
  13191. var that = this,
  13192. tt = this._acornTokTypes,
  13193. tokens = extra.tokens,
  13194. templateTokens = this._tokens;
  13195. /**
  13196. * Flushes the buffered template tokens and resets the template
  13197. * tracking.
  13198. * @returns {void}
  13199. * @private
  13200. */
  13201. function translateTemplateTokens() {
  13202. tokens.push(convertTemplatePart(that._tokens, that._code));
  13203. that._tokens = [];
  13204. }
  13205. if (token.type === tt.eof) {
  13206. // might be one last curlyBrace
  13207. if (this._curlyBrace) {
  13208. tokens.push(this.translate(this._curlyBrace, extra));
  13209. }
  13210. return;
  13211. }
  13212. if (token.type === tt.backQuote) {
  13213. // if there's already a curly, it's not part of the template
  13214. if (this._curlyBrace) {
  13215. tokens.push(this.translate(this._curlyBrace, extra));
  13216. this._curlyBrace = null;
  13217. }
  13218. templateTokens.push(token);
  13219. // it's the end
  13220. if (templateTokens.length > 1) {
  13221. translateTemplateTokens();
  13222. }
  13223. return;
  13224. }
  13225. if (token.type === tt.dollarBraceL) {
  13226. templateTokens.push(token);
  13227. translateTemplateTokens();
  13228. return;
  13229. }
  13230. if (token.type === tt.braceR) {
  13231. // if there's already a curly, it's not part of the template
  13232. if (this._curlyBrace) {
  13233. tokens.push(this.translate(this._curlyBrace, extra));
  13234. }
  13235. // store new curly for later
  13236. this._curlyBrace = token;
  13237. return;
  13238. }
  13239. if (token.type === tt.template || token.type === tt.invalidTemplate) {
  13240. if (this._curlyBrace) {
  13241. templateTokens.push(this._curlyBrace);
  13242. this._curlyBrace = null;
  13243. }
  13244. templateTokens.push(token);
  13245. return;
  13246. }
  13247. if (this._curlyBrace) {
  13248. tokens.push(this.translate(this._curlyBrace, extra));
  13249. this._curlyBrace = null;
  13250. }
  13251. tokens.push(this.translate(token, extra));
  13252. }
  13253. };
  13254. //------------------------------------------------------------------------------
  13255. // Public
  13256. //------------------------------------------------------------------------------
  13257. module.exports = TokenTranslator;
  13258. },{}],9:[function(require,module,exports){
  13259. module.exports={
  13260. "_from": "espree@^5.0.0",
  13261. "_id": "espree@5.0.0",
  13262. "_inBundle": false,
  13263. "_integrity": "sha512-1MpUfwsdS9MMoN7ZXqAr9e9UKdVHDcvrJpyx7mm1WuQlx/ygErEQBzgi5Nh5qBHIoYweprhtMkTCb9GhcAIcsA==",
  13264. "_location": "/espree",
  13265. "_phantomChildren": {},
  13266. "_requested": {
  13267. "type": "range",
  13268. "registry": true,
  13269. "raw": "espree@^5.0.0",
  13270. "name": "espree",
  13271. "escapedName": "espree",
  13272. "rawSpec": "^5.0.0",
  13273. "saveSpec": null,
  13274. "fetchSpec": "^5.0.0"
  13275. },
  13276. "_requiredBy": [
  13277. "/"
  13278. ],
  13279. "_resolved": "https://registry.npmjs.org/espree/-/espree-5.0.0.tgz",
  13280. "_shasum": "fc7f984b62b36a0f543b13fb9cd7b9f4a7f5b65c",
  13281. "_spec": "espree@^5.0.0",
  13282. "_where": "/var/lib/jenkins/workspace/Releases/eslint Release/eslint",
  13283. "author": {
  13284. "name": "Nicholas C. Zakas",
  13285. "email": "nicholas+npm@nczconsulting.com"
  13286. },
  13287. "bugs": {
  13288. "url": "http://github.com/eslint/espree.git"
  13289. },
  13290. "bundleDependencies": false,
  13291. "dependencies": {
  13292. "acorn": "^6.0.2",
  13293. "acorn-jsx": "^5.0.0",
  13294. "eslint-visitor-keys": "^1.0.0"
  13295. },
  13296. "deprecated": false,
  13297. "description": "An Esprima-compatible JavaScript parser built on Acorn",
  13298. "devDependencies": {
  13299. "browserify": "^7.0.0",
  13300. "chai": "^1.10.0",
  13301. "eslint": "^5.7.0",
  13302. "eslint-config-eslint": "^5.0.1",
  13303. "eslint-plugin-node": "^8.0.0",
  13304. "eslint-release": "^1.0.0",
  13305. "esprima": "latest",
  13306. "esprima-fb": "^8001.2001.0-dev-harmony-fb",
  13307. "json-diff": "~0.3.1",
  13308. "leche": "^1.0.1",
  13309. "mocha": "^2.0.1",
  13310. "nyc": "^13.0.1",
  13311. "regenerate": "~0.5.4",
  13312. "shelljs": "^0.3.0",
  13313. "shelljs-nodecli": "^0.1.1",
  13314. "unicode-6.3.0": "~0.1.0"
  13315. },
  13316. "engines": {
  13317. "node": ">=6.0.0"
  13318. },
  13319. "files": [
  13320. "lib",
  13321. "espree.js"
  13322. ],
  13323. "homepage": "https://github.com/eslint/espree",
  13324. "keywords": [
  13325. "ast",
  13326. "ecmascript",
  13327. "javascript",
  13328. "parser",
  13329. "syntax",
  13330. "acorn"
  13331. ],
  13332. "license": "BSD-2-Clause",
  13333. "main": "espree.js",
  13334. "name": "espree",
  13335. "repository": {
  13336. "type": "git",
  13337. "url": "git+https://github.com/eslint/espree.git"
  13338. },
  13339. "scripts": {
  13340. "browserify": "node Makefile.js browserify",
  13341. "generate-alpharelease": "eslint-generate-prerelease alpha",
  13342. "generate-betarelease": "eslint-generate-prerelease beta",
  13343. "generate-rcrelease": "eslint-generate-prerelease rc",
  13344. "generate-regex": "node tools/generate-identifier-regex.js",
  13345. "generate-release": "eslint-generate-release",
  13346. "lint": "node Makefile.js lint",
  13347. "publish-release": "eslint-publish-release",
  13348. "test": "npm run-script lint && node Makefile.js test"
  13349. },
  13350. "version": "5.0.0"
  13351. }
  13352. },{}],"espree":[function(require,module,exports){
  13353. /**
  13354. * @fileoverview Main Espree file that converts Acorn into Esprima output.
  13355. *
  13356. * This file contains code from the following MIT-licensed projects:
  13357. * 1. Acorn
  13358. * 2. Babylon
  13359. * 3. Babel-ESLint
  13360. *
  13361. * This file also contains code from Esprima, which is BSD licensed.
  13362. *
  13363. * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
  13364. * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
  13365. * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
  13366. *
  13367. * Redistribution and use in source and binary forms, with or without
  13368. * modification, are permitted provided that the following conditions are met:
  13369. *
  13370. * * Redistributions of source code must retain the above copyright
  13371. * notice, this list of conditions and the following disclaimer.
  13372. * * Redistributions in binary form must reproduce the above copyright
  13373. * notice, this list of conditions and the following disclaimer in the
  13374. * documentation and/or other materials provided with the distribution.
  13375. *
  13376. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  13377. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13378. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  13379. * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  13380. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13381. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13382. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13383. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13384. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  13385. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13386. *
  13387. * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
  13388. *
  13389. * Redistribution and use in source and binary forms, with or without
  13390. * modification, are permitted provided that the following conditions are met:
  13391. *
  13392. * * Redistributions of source code must retain the above copyright
  13393. * notice, this list of conditions and the following disclaimer.
  13394. * * Redistributions in binary form must reproduce the above copyright
  13395. * notice, this list of conditions and the following disclaimer in the
  13396. * documentation and/or other materials provided with the distribution.
  13397. *
  13398. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  13399. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13400. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  13401. * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  13402. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13403. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13404. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13405. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13406. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  13407. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13408. */
  13409. /* eslint no-undefined:0, no-use-before-define: 0 */
  13410. "use strict";
  13411. var acorn = require("acorn");
  13412. var jsx = require("acorn-jsx");
  13413. var astNodeTypes = require("./lib/ast-node-types");
  13414. var espree = require("./lib/espree");
  13415. // To initialize lazily.
  13416. var parsers = {
  13417. _regular: null,
  13418. _jsx: null,
  13419. get regular() {
  13420. if (this._regular === null) {
  13421. this._regular = acorn.Parser.extend(espree());
  13422. }
  13423. return this._regular;
  13424. },
  13425. get jsx() {
  13426. if (this._jsx === null) {
  13427. this._jsx = acorn.Parser.extend(jsx(), espree());
  13428. }
  13429. return this._jsx;
  13430. },
  13431. get: function get(options) {
  13432. var useJsx = Boolean(options && options.ecmaFeatures && options.ecmaFeatures.jsx);
  13433. return useJsx ? this.jsx : this.regular;
  13434. }
  13435. };
  13436. //------------------------------------------------------------------------------
  13437. // Tokenizer
  13438. //------------------------------------------------------------------------------
  13439. /**
  13440. * Tokenizes the given code.
  13441. * @param {string} code The code to tokenize.
  13442. * @param {Object} options Options defining how to tokenize.
  13443. * @returns {Token[]} An array of tokens.
  13444. * @throws {SyntaxError} If the input code is invalid.
  13445. * @private
  13446. */
  13447. function tokenize(code, options) {
  13448. var Parser = parsers.get(options);
  13449. // Ensure to collect tokens.
  13450. if (!options || options.tokens !== true) {
  13451. options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign
  13452. }
  13453. return new Parser(options, code).tokenize();
  13454. }
  13455. //------------------------------------------------------------------------------
  13456. // Parser
  13457. //------------------------------------------------------------------------------
  13458. /**
  13459. * Parses the given code.
  13460. * @param {string} code The code to tokenize.
  13461. * @param {Object} options Options defining how to tokenize.
  13462. * @returns {ASTNode} The "Program" AST node.
  13463. * @throws {SyntaxError} If the input code is invalid.
  13464. */
  13465. function parse(code, options) {
  13466. var Parser = parsers.get(options);
  13467. return new Parser(options, code).parse();
  13468. }
  13469. //------------------------------------------------------------------------------
  13470. // Public
  13471. //------------------------------------------------------------------------------
  13472. exports.version = require("./package.json").version;
  13473. exports.tokenize = tokenize;
  13474. exports.parse = parse;
  13475. // Deep copy.
  13476. /* istanbul ignore next */
  13477. exports.Syntax = function () {
  13478. var name = void 0,
  13479. types = {};
  13480. if (typeof Object.create === "function") {
  13481. types = Object.create(null);
  13482. }
  13483. for (name in astNodeTypes) {
  13484. if (astNodeTypes.hasOwnProperty(name)) {
  13485. types[name] = astNodeTypes[name];
  13486. }
  13487. }
  13488. if (typeof Object.freeze === "function") {
  13489. Object.freeze(types);
  13490. }
  13491. return types;
  13492. }();
  13493. /* istanbul ignore next */
  13494. exports.VisitorKeys = function () {
  13495. return require("eslint-visitor-keys").KEYS;
  13496. }();
  13497. },{"./lib/ast-node-types":6,"./lib/espree":7,"./package.json":9,"acorn":3,"acorn-jsx":1,"eslint-visitor-keys":4}]},{},[]);
  13498. (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.eslint = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  13499. /**
  13500. * @fileoverview Defines a schema for configs.
  13501. * @author Sylvan Mably
  13502. */
  13503. "use strict";
  13504. var baseConfigProperties = {
  13505. env: { type: "object" },
  13506. globals: { type: "object" },
  13507. parser: { type: ["string", "null"] },
  13508. parserOptions: { type: "object" },
  13509. plugins: { type: "array" },
  13510. rules: { type: "object" },
  13511. settings: { type: "object" },
  13512. ecmaFeatures: { type: "object" // deprecated; logs a warning when used
  13513. } };
  13514. var overrideProperties = Object.assign({}, baseConfigProperties, {
  13515. files: {
  13516. oneOf: [{ type: "string" }, {
  13517. type: "array",
  13518. items: { type: "string" },
  13519. minItems: 1
  13520. }]
  13521. },
  13522. excludedFiles: {
  13523. oneOf: [{ type: "string" }, {
  13524. type: "array",
  13525. items: { type: "string" }
  13526. }]
  13527. }
  13528. });
  13529. var topLevelConfigProperties = Object.assign({}, baseConfigProperties, {
  13530. extends: { type: ["string", "array"] },
  13531. root: { type: "boolean" },
  13532. overrides: {
  13533. type: "array",
  13534. items: {
  13535. type: "object",
  13536. properties: overrideProperties,
  13537. required: ["files"],
  13538. additionalProperties: false
  13539. }
  13540. }
  13541. });
  13542. var configSchema = {
  13543. type: "object",
  13544. properties: topLevelConfigProperties,
  13545. additionalProperties: false
  13546. };
  13547. module.exports = configSchema;
  13548. },{}],2:[function(require,module,exports){
  13549. /**
  13550. * @fileoverview Defines environment settings and globals.
  13551. * @author Elan Shanker
  13552. */
  13553. "use strict";
  13554. //------------------------------------------------------------------------------
  13555. // Requirements
  13556. //------------------------------------------------------------------------------
  13557. var globals = require("globals");
  13558. //------------------------------------------------------------------------------
  13559. // Public Interface
  13560. //------------------------------------------------------------------------------
  13561. module.exports = {
  13562. builtin: {
  13563. globals: globals.es5
  13564. },
  13565. browser: {
  13566. globals: globals.browser
  13567. },
  13568. node: {
  13569. globals: globals.node,
  13570. parserOptions: {
  13571. ecmaFeatures: {
  13572. globalReturn: true
  13573. }
  13574. }
  13575. },
  13576. commonjs: {
  13577. globals: globals.commonjs,
  13578. parserOptions: {
  13579. ecmaFeatures: {
  13580. globalReturn: true
  13581. }
  13582. }
  13583. },
  13584. "shared-node-browser": {
  13585. globals: globals["shared-node-browser"]
  13586. },
  13587. worker: {
  13588. globals: globals.worker
  13589. },
  13590. amd: {
  13591. globals: globals.amd
  13592. },
  13593. mocha: {
  13594. globals: globals.mocha
  13595. },
  13596. jasmine: {
  13597. globals: globals.jasmine
  13598. },
  13599. jest: {
  13600. globals: globals.jest
  13601. },
  13602. phantomjs: {
  13603. globals: globals.phantomjs
  13604. },
  13605. jquery: {
  13606. globals: globals.jquery
  13607. },
  13608. qunit: {
  13609. globals: globals.qunit
  13610. },
  13611. prototypejs: {
  13612. globals: globals.prototypejs
  13613. },
  13614. shelljs: {
  13615. globals: globals.shelljs
  13616. },
  13617. meteor: {
  13618. globals: globals.meteor
  13619. },
  13620. mongo: {
  13621. globals: globals.mongo
  13622. },
  13623. protractor: {
  13624. globals: globals.protractor
  13625. },
  13626. applescript: {
  13627. globals: globals.applescript
  13628. },
  13629. nashorn: {
  13630. globals: globals.nashorn
  13631. },
  13632. serviceworker: {
  13633. globals: globals.serviceworker
  13634. },
  13635. atomtest: {
  13636. globals: globals.atomtest
  13637. },
  13638. embertest: {
  13639. globals: globals.embertest
  13640. },
  13641. webextensions: {
  13642. globals: globals.webextensions
  13643. },
  13644. es6: {
  13645. globals: globals.es2015,
  13646. parserOptions: {
  13647. ecmaVersion: 6
  13648. }
  13649. },
  13650. greasemonkey: {
  13651. globals: globals.greasemonkey
  13652. }
  13653. };
  13654. },{"globals":85}],3:[function(require,module,exports){
  13655. module.exports={
  13656. "rules": {
  13657. "generator-star": ["generator-star-spacing"],
  13658. "global-strict": ["strict"],
  13659. "no-arrow-condition": ["no-confusing-arrow", "no-constant-condition"],
  13660. "no-comma-dangle": ["comma-dangle"],
  13661. "no-empty-class": ["no-empty-character-class"],
  13662. "no-empty-label": ["no-labels"],
  13663. "no-extra-strict": ["strict"],
  13664. "no-reserved-keys": ["quote-props"],
  13665. "no-space-before-semi": ["semi-spacing"],
  13666. "no-wrap-func": ["no-extra-parens"],
  13667. "space-after-function-name": ["space-before-function-paren"],
  13668. "space-after-keywords": ["keyword-spacing"],
  13669. "space-before-function-parentheses": ["space-before-function-paren"],
  13670. "space-before-keywords": ["keyword-spacing"],
  13671. "space-in-brackets": ["object-curly-spacing", "array-bracket-spacing", "computed-property-spacing"],
  13672. "space-return-throw-case": ["keyword-spacing"],
  13673. "space-unary-word-ops": ["space-unary-ops"],
  13674. "spaced-line-comment": ["spaced-comment"]
  13675. }
  13676. }
  13677. },{}],4:[function(require,module,exports){
  13678. 'use strict';
  13679. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  13680. var compileSchema = require('./compile'),
  13681. resolve = require('./compile/resolve'),
  13682. Cache = require('./cache'),
  13683. SchemaObject = require('./compile/schema_obj'),
  13684. stableStringify = require('fast-json-stable-stringify'),
  13685. formats = require('./compile/formats'),
  13686. rules = require('./compile/rules'),
  13687. $dataMetaSchema = require('./data'),
  13688. util = require('./compile/util');
  13689. module.exports = Ajv;
  13690. Ajv.prototype.validate = validate;
  13691. Ajv.prototype.compile = compile;
  13692. Ajv.prototype.addSchema = addSchema;
  13693. Ajv.prototype.addMetaSchema = addMetaSchema;
  13694. Ajv.prototype.validateSchema = validateSchema;
  13695. Ajv.prototype.getSchema = getSchema;
  13696. Ajv.prototype.removeSchema = removeSchema;
  13697. Ajv.prototype.addFormat = addFormat;
  13698. Ajv.prototype.errorsText = errorsText;
  13699. Ajv.prototype._addSchema = _addSchema;
  13700. Ajv.prototype._compile = _compile;
  13701. Ajv.prototype.compileAsync = require('./compile/async');
  13702. var customKeyword = require('./keyword');
  13703. Ajv.prototype.addKeyword = customKeyword.add;
  13704. Ajv.prototype.getKeyword = customKeyword.get;
  13705. Ajv.prototype.removeKeyword = customKeyword.remove;
  13706. var errorClasses = require('./compile/error_classes');
  13707. Ajv.ValidationError = errorClasses.Validation;
  13708. Ajv.MissingRefError = errorClasses.MissingRef;
  13709. Ajv.$dataMetaSchema = $dataMetaSchema;
  13710. var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
  13711. var META_IGNORE_OPTIONS = ['removeAdditional', 'useDefaults', 'coerceTypes'];
  13712. var META_SUPPORT_DATA = ['/properties'];
  13713. /**
  13714. * Creates validator instance.
  13715. * Usage: `Ajv(opts)`
  13716. * @param {Object} opts optional options
  13717. * @return {Object} ajv instance
  13718. */
  13719. function Ajv(opts) {
  13720. if (!(this instanceof Ajv)) return new Ajv(opts);
  13721. opts = this._opts = util.copy(opts) || {};
  13722. setLogger(this);
  13723. this._schemas = {};
  13724. this._refs = {};
  13725. this._fragments = {};
  13726. this._formats = formats(opts.format);
  13727. this._cache = opts.cache || new Cache();
  13728. this._loadingSchemas = {};
  13729. this._compilations = [];
  13730. this.RULES = rules();
  13731. this._getId = chooseGetId(opts);
  13732. opts.loopRequired = opts.loopRequired || Infinity;
  13733. if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
  13734. if (opts.serialize === undefined) opts.serialize = stableStringify;
  13735. this._metaOpts = getMetaSchemaOptions(this);
  13736. if (opts.formats) addInitialFormats(this);
  13737. addDefaultMetaSchema(this);
  13738. if (_typeof(opts.meta) == 'object') this.addMetaSchema(opts.meta);
  13739. if (opts.nullable) this.addKeyword('nullable', { metaSchema: { const: true } });
  13740. addInitialSchemas(this);
  13741. }
  13742. /**
  13743. * Validate data using schema
  13744. * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
  13745. * @this Ajv
  13746. * @param {String|Object} schemaKeyRef key, ref or schema object
  13747. * @param {Any} data to be validated
  13748. * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
  13749. */
  13750. function validate(schemaKeyRef, data) {
  13751. var v;
  13752. if (typeof schemaKeyRef == 'string') {
  13753. v = this.getSchema(schemaKeyRef);
  13754. if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
  13755. } else {
  13756. var schemaObj = this._addSchema(schemaKeyRef);
  13757. v = schemaObj.validate || this._compile(schemaObj);
  13758. }
  13759. var valid = v(data);
  13760. if (v.$async !== true) this.errors = v.errors;
  13761. return valid;
  13762. }
  13763. /**
  13764. * Create validating function for passed schema.
  13765. * @this Ajv
  13766. * @param {Object} schema schema object
  13767. * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
  13768. * @return {Function} validating function
  13769. */
  13770. function compile(schema, _meta) {
  13771. var schemaObj = this._addSchema(schema, undefined, _meta);
  13772. return schemaObj.validate || this._compile(schemaObj);
  13773. }
  13774. /**
  13775. * Adds schema to the instance.
  13776. * @this Ajv
  13777. * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
  13778. * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
  13779. * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
  13780. * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
  13781. * @return {Ajv} this for method chaining
  13782. */
  13783. function addSchema(schema, key, _skipValidation, _meta) {
  13784. if (Array.isArray(schema)) {
  13785. for (var i = 0; i < schema.length; i++) {
  13786. this.addSchema(schema[i], undefined, _skipValidation, _meta);
  13787. }return this;
  13788. }
  13789. var id = this._getId(schema);
  13790. if (id !== undefined && typeof id != 'string') throw new Error('schema id must be string');
  13791. key = resolve.normalizeId(key || id);
  13792. checkUnique(this, key);
  13793. this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
  13794. return this;
  13795. }
  13796. /**
  13797. * Add schema that will be used to validate other schemas
  13798. * options in META_IGNORE_OPTIONS are alway set to false
  13799. * @this Ajv
  13800. * @param {Object} schema schema object
  13801. * @param {String} key optional schema key
  13802. * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
  13803. * @return {Ajv} this for method chaining
  13804. */
  13805. function addMetaSchema(schema, key, skipValidation) {
  13806. this.addSchema(schema, key, skipValidation, true);
  13807. return this;
  13808. }
  13809. /**
  13810. * Validate schema
  13811. * @this Ajv
  13812. * @param {Object} schema schema to validate
  13813. * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
  13814. * @return {Boolean} true if schema is valid
  13815. */
  13816. function validateSchema(schema, throwOrLogError) {
  13817. var $schema = schema.$schema;
  13818. if ($schema !== undefined && typeof $schema != 'string') throw new Error('$schema must be a string');
  13819. $schema = $schema || this._opts.defaultMeta || defaultMeta(this);
  13820. if (!$schema) {
  13821. this.logger.warn('meta-schema not available');
  13822. this.errors = null;
  13823. return true;
  13824. }
  13825. var valid = this.validate($schema, schema);
  13826. if (!valid && throwOrLogError) {
  13827. var message = 'schema is invalid: ' + this.errorsText();
  13828. if (this._opts.validateSchema == 'log') this.logger.error(message);else throw new Error(message);
  13829. }
  13830. return valid;
  13831. }
  13832. function defaultMeta(self) {
  13833. var meta = self._opts.meta;
  13834. self._opts.defaultMeta = (typeof meta === 'undefined' ? 'undefined' : _typeof(meta)) == 'object' ? self._getId(meta) || meta : self.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined;
  13835. return self._opts.defaultMeta;
  13836. }
  13837. /**
  13838. * Get compiled schema from the instance by `key` or `ref`.
  13839. * @this Ajv
  13840. * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
  13841. * @return {Function} schema validating function (with property `schema`).
  13842. */
  13843. function getSchema(keyRef) {
  13844. var schemaObj = _getSchemaObj(this, keyRef);
  13845. switch (typeof schemaObj === 'undefined' ? 'undefined' : _typeof(schemaObj)) {
  13846. case 'object':
  13847. return schemaObj.validate || this._compile(schemaObj);
  13848. case 'string':
  13849. return this.getSchema(schemaObj);
  13850. case 'undefined':
  13851. return _getSchemaFragment(this, keyRef);
  13852. }
  13853. }
  13854. function _getSchemaFragment(self, ref) {
  13855. var res = resolve.schema.call(self, { schema: {} }, ref);
  13856. if (res) {
  13857. var schema = res.schema,
  13858. root = res.root,
  13859. baseId = res.baseId;
  13860. var v = compileSchema.call(self, schema, root, undefined, baseId);
  13861. self._fragments[ref] = new SchemaObject({
  13862. ref: ref,
  13863. fragment: true,
  13864. schema: schema,
  13865. root: root,
  13866. baseId: baseId,
  13867. validate: v
  13868. });
  13869. return v;
  13870. }
  13871. }
  13872. function _getSchemaObj(self, keyRef) {
  13873. keyRef = resolve.normalizeId(keyRef);
  13874. return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
  13875. }
  13876. /**
  13877. * Remove cached schema(s).
  13878. * If no parameter is passed all schemas but meta-schemas are removed.
  13879. * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
  13880. * Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
  13881. * @this Ajv
  13882. * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
  13883. * @return {Ajv} this for method chaining
  13884. */
  13885. function removeSchema(schemaKeyRef) {
  13886. if (schemaKeyRef instanceof RegExp) {
  13887. _removeAllSchemas(this, this._schemas, schemaKeyRef);
  13888. _removeAllSchemas(this, this._refs, schemaKeyRef);
  13889. return this;
  13890. }
  13891. switch (typeof schemaKeyRef === 'undefined' ? 'undefined' : _typeof(schemaKeyRef)) {
  13892. case 'undefined':
  13893. _removeAllSchemas(this, this._schemas);
  13894. _removeAllSchemas(this, this._refs);
  13895. this._cache.clear();
  13896. return this;
  13897. case 'string':
  13898. var schemaObj = _getSchemaObj(this, schemaKeyRef);
  13899. if (schemaObj) this._cache.del(schemaObj.cacheKey);
  13900. delete this._schemas[schemaKeyRef];
  13901. delete this._refs[schemaKeyRef];
  13902. return this;
  13903. case 'object':
  13904. var serialize = this._opts.serialize;
  13905. var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
  13906. this._cache.del(cacheKey);
  13907. var id = this._getId(schemaKeyRef);
  13908. if (id) {
  13909. id = resolve.normalizeId(id);
  13910. delete this._schemas[id];
  13911. delete this._refs[id];
  13912. }
  13913. }
  13914. return this;
  13915. }
  13916. function _removeAllSchemas(self, schemas, regex) {
  13917. for (var keyRef in schemas) {
  13918. var schemaObj = schemas[keyRef];
  13919. if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
  13920. self._cache.del(schemaObj.cacheKey);
  13921. delete schemas[keyRef];
  13922. }
  13923. }
  13924. }
  13925. /* @this Ajv */
  13926. function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
  13927. if ((typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) != 'object' && typeof schema != 'boolean') throw new Error('schema should be object or boolean');
  13928. var serialize = this._opts.serialize;
  13929. var cacheKey = serialize ? serialize(schema) : schema;
  13930. var cached = this._cache.get(cacheKey);
  13931. if (cached) return cached;
  13932. shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
  13933. var id = resolve.normalizeId(this._getId(schema));
  13934. if (id && shouldAddSchema) checkUnique(this, id);
  13935. var willValidate = this._opts.validateSchema !== false && !skipValidation;
  13936. var recursiveMeta;
  13937. if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema))) this.validateSchema(schema, true);
  13938. var localRefs = resolve.ids.call(this, schema);
  13939. var schemaObj = new SchemaObject({
  13940. id: id,
  13941. schema: schema,
  13942. localRefs: localRefs,
  13943. cacheKey: cacheKey,
  13944. meta: meta
  13945. });
  13946. if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
  13947. this._cache.put(cacheKey, schemaObj);
  13948. if (willValidate && recursiveMeta) this.validateSchema(schema, true);
  13949. return schemaObj;
  13950. }
  13951. /* @this Ajv */
  13952. function _compile(schemaObj, root) {
  13953. if (schemaObj.compiling) {
  13954. schemaObj.validate = callValidate;
  13955. callValidate.schema = schemaObj.schema;
  13956. callValidate.errors = null;
  13957. callValidate.root = root ? root : callValidate;
  13958. if (schemaObj.schema.$async === true) callValidate.$async = true;
  13959. return callValidate;
  13960. }
  13961. schemaObj.compiling = true;
  13962. var currentOpts;
  13963. if (schemaObj.meta) {
  13964. currentOpts = this._opts;
  13965. this._opts = this._metaOpts;
  13966. }
  13967. var v;
  13968. try {
  13969. v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs);
  13970. } catch (e) {
  13971. delete schemaObj.validate;
  13972. throw e;
  13973. } finally {
  13974. schemaObj.compiling = false;
  13975. if (schemaObj.meta) this._opts = currentOpts;
  13976. }
  13977. schemaObj.validate = v;
  13978. schemaObj.refs = v.refs;
  13979. schemaObj.refVal = v.refVal;
  13980. schemaObj.root = v.root;
  13981. return v;
  13982. /* @this {*} - custom context, see passContext option */
  13983. function callValidate() {
  13984. /* jshint validthis: true */
  13985. var _validate = schemaObj.validate;
  13986. var result = _validate.apply(this, arguments);
  13987. callValidate.errors = _validate.errors;
  13988. return result;
  13989. }
  13990. }
  13991. function chooseGetId(opts) {
  13992. switch (opts.schemaId) {
  13993. case 'auto':
  13994. return _get$IdOrId;
  13995. case 'id':
  13996. return _getId;
  13997. default:
  13998. return _get$Id;
  13999. }
  14000. }
  14001. /* @this Ajv */
  14002. function _getId(schema) {
  14003. if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
  14004. return schema.id;
  14005. }
  14006. /* @this Ajv */
  14007. function _get$Id(schema) {
  14008. if (schema.id) this.logger.warn('schema id ignored', schema.id);
  14009. return schema.$id;
  14010. }
  14011. function _get$IdOrId(schema) {
  14012. if (schema.$id && schema.id && schema.$id != schema.id) throw new Error('schema $id is different from id');
  14013. return schema.$id || schema.id;
  14014. }
  14015. /**
  14016. * Convert array of error message objects to string
  14017. * @this Ajv
  14018. * @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
  14019. * @param {Object} options optional options with properties `separator` and `dataVar`.
  14020. * @return {String} human readable string with all errors descriptions
  14021. */
  14022. function errorsText(errors, options) {
  14023. errors = errors || this.errors;
  14024. if (!errors) return 'No errors';
  14025. options = options || {};
  14026. var separator = options.separator === undefined ? ', ' : options.separator;
  14027. var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
  14028. var text = '';
  14029. for (var i = 0; i < errors.length; i++) {
  14030. var e = errors[i];
  14031. if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
  14032. }
  14033. return text.slice(0, -separator.length);
  14034. }
  14035. /**
  14036. * Add custom format
  14037. * @this Ajv
  14038. * @param {String} name format name
  14039. * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
  14040. * @return {Ajv} this for method chaining
  14041. */
  14042. function addFormat(name, format) {
  14043. if (typeof format == 'string') format = new RegExp(format);
  14044. this._formats[name] = format;
  14045. return this;
  14046. }
  14047. function addDefaultMetaSchema(self) {
  14048. var $dataSchema;
  14049. if (self._opts.$data) {
  14050. $dataSchema = require('./refs/data.json');
  14051. self.addMetaSchema($dataSchema, $dataSchema.$id, true);
  14052. }
  14053. if (self._opts.meta === false) return;
  14054. var metaSchema = require('./refs/json-schema-draft-07.json');
  14055. if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
  14056. self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
  14057. self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
  14058. }
  14059. function addInitialSchemas(self) {
  14060. var optsSchemas = self._opts.schemas;
  14061. if (!optsSchemas) return;
  14062. if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);else for (var key in optsSchemas) {
  14063. self.addSchema(optsSchemas[key], key);
  14064. }
  14065. }
  14066. function addInitialFormats(self) {
  14067. for (var name in self._opts.formats) {
  14068. var format = self._opts.formats[name];
  14069. self.addFormat(name, format);
  14070. }
  14071. }
  14072. function checkUnique(self, id) {
  14073. if (self._schemas[id] || self._refs[id]) throw new Error('schema with key or id "' + id + '" already exists');
  14074. }
  14075. function getMetaSchemaOptions(self) {
  14076. var metaOpts = util.copy(self._opts);
  14077. for (var i = 0; i < META_IGNORE_OPTIONS.length; i++) {
  14078. delete metaOpts[META_IGNORE_OPTIONS[i]];
  14079. }return metaOpts;
  14080. }
  14081. function setLogger(self) {
  14082. var logger = self._opts.logger;
  14083. if (logger === false) {
  14084. self.logger = { log: noop, warn: noop, error: noop };
  14085. } else {
  14086. if (logger === undefined) logger = console;
  14087. if (!((typeof logger === 'undefined' ? 'undefined' : _typeof(logger)) == 'object' && logger.log && logger.warn && logger.error)) throw new Error('logger must implement log, warn and error methods');
  14088. self.logger = logger;
  14089. }
  14090. }
  14091. function noop() {}
  14092. },{"./cache":5,"./compile":9,"./compile/async":6,"./compile/error_classes":7,"./compile/formats":8,"./compile/resolve":10,"./compile/rules":11,"./compile/schema_obj":12,"./compile/util":14,"./data":15,"./keyword":42,"./refs/data.json":43,"./refs/json-schema-draft-07.json":45,"fast-json-stable-stringify":82}],5:[function(require,module,exports){
  14093. 'use strict';
  14094. var Cache = module.exports = function Cache() {
  14095. this._cache = {};
  14096. };
  14097. Cache.prototype.put = function Cache_put(key, value) {
  14098. this._cache[key] = value;
  14099. };
  14100. Cache.prototype.get = function Cache_get(key) {
  14101. return this._cache[key];
  14102. };
  14103. Cache.prototype.del = function Cache_del(key) {
  14104. delete this._cache[key];
  14105. };
  14106. Cache.prototype.clear = function Cache_clear() {
  14107. this._cache = {};
  14108. };
  14109. },{}],6:[function(require,module,exports){
  14110. 'use strict';
  14111. var MissingRefError = require('./error_classes').MissingRef;
  14112. module.exports = compileAsync;
  14113. /**
  14114. * Creates validating function for passed schema with asynchronous loading of missing schemas.
  14115. * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
  14116. * @this Ajv
  14117. * @param {Object} schema schema object
  14118. * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
  14119. * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
  14120. * @return {Promise} promise that resolves with a validating function.
  14121. */
  14122. function compileAsync(schema, meta, callback) {
  14123. /* eslint no-shadow: 0 */
  14124. /* global Promise */
  14125. /* jshint validthis: true */
  14126. var self = this;
  14127. if (typeof this._opts.loadSchema != 'function') throw new Error('options.loadSchema should be a function');
  14128. if (typeof meta == 'function') {
  14129. callback = meta;
  14130. meta = undefined;
  14131. }
  14132. var p = loadMetaSchemaOf(schema).then(function () {
  14133. var schemaObj = self._addSchema(schema, undefined, meta);
  14134. return schemaObj.validate || _compileAsync(schemaObj);
  14135. });
  14136. if (callback) {
  14137. p.then(function (v) {
  14138. callback(null, v);
  14139. }, callback);
  14140. }
  14141. return p;
  14142. function loadMetaSchemaOf(sch) {
  14143. var $schema = sch.$schema;
  14144. return $schema && !self.getSchema($schema) ? compileAsync.call(self, { $ref: $schema }, true) : Promise.resolve();
  14145. }
  14146. function _compileAsync(schemaObj) {
  14147. try {
  14148. return self._compile(schemaObj);
  14149. } catch (e) {
  14150. if (e instanceof MissingRefError) return loadMissingSchema(e);
  14151. throw e;
  14152. }
  14153. function loadMissingSchema(e) {
  14154. var ref = e.missingSchema;
  14155. if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
  14156. var schemaPromise = self._loadingSchemas[ref];
  14157. if (!schemaPromise) {
  14158. schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
  14159. schemaPromise.then(removePromise, removePromise);
  14160. }
  14161. return schemaPromise.then(function (sch) {
  14162. if (!added(ref)) {
  14163. return loadMetaSchemaOf(sch).then(function () {
  14164. if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
  14165. });
  14166. }
  14167. }).then(function () {
  14168. return _compileAsync(schemaObj);
  14169. });
  14170. function removePromise() {
  14171. delete self._loadingSchemas[ref];
  14172. }
  14173. function added(ref) {
  14174. return self._refs[ref] || self._schemas[ref];
  14175. }
  14176. }
  14177. }
  14178. }
  14179. },{"./error_classes":7}],7:[function(require,module,exports){
  14180. 'use strict';
  14181. var resolve = require('./resolve');
  14182. module.exports = {
  14183. Validation: errorSubclass(ValidationError),
  14184. MissingRef: errorSubclass(MissingRefError)
  14185. };
  14186. function ValidationError(errors) {
  14187. this.message = 'validation failed';
  14188. this.errors = errors;
  14189. this.ajv = this.validation = true;
  14190. }
  14191. MissingRefError.message = function (baseId, ref) {
  14192. return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
  14193. };
  14194. function MissingRefError(baseId, ref, message) {
  14195. this.message = message || MissingRefError.message(baseId, ref);
  14196. this.missingRef = resolve.url(baseId, ref);
  14197. this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
  14198. }
  14199. function errorSubclass(Subclass) {
  14200. Subclass.prototype = Object.create(Error.prototype);
  14201. Subclass.prototype.constructor = Subclass;
  14202. return Subclass;
  14203. }
  14204. },{"./resolve":10}],8:[function(require,module,exports){
  14205. 'use strict';
  14206. var util = require('./util');
  14207. var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
  14208. var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  14209. var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
  14210. var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i;
  14211. var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
  14212. var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
  14213. // uri-template: https://tools.ietf.org/html/rfc6570
  14214. var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
  14215. // For the source: https://gist.github.com/dperini/729294
  14216. // For test cases: https://mathiasbynens.be/demo/url-regex
  14217. // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
  14218. // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
  14219. var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
  14220. var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
  14221. var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
  14222. var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
  14223. var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
  14224. module.exports = formats;
  14225. function formats(mode) {
  14226. mode = mode == 'full' ? 'full' : 'fast';
  14227. return util.copy(formats[mode]);
  14228. }
  14229. formats.fast = {
  14230. // date: http://tools.ietf.org/html/rfc3339#section-5.6
  14231. date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
  14232. // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
  14233. time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
  14234. 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,
  14235. // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
  14236. uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,
  14237. 'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
  14238. 'uri-template': URITEMPLATE,
  14239. url: URL,
  14240. // email (sources from jsen validator):
  14241. // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
  14242. // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
  14243. email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
  14244. hostname: HOSTNAME,
  14245. // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
  14246. ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  14247. // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
  14248. ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
  14249. regex: regex,
  14250. // uuid: http://tools.ietf.org/html/rfc4122
  14251. uuid: UUID,
  14252. // JSON-pointer: https://tools.ietf.org/html/rfc6901
  14253. // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
  14254. 'json-pointer': JSON_POINTER,
  14255. 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
  14256. // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
  14257. 'relative-json-pointer': RELATIVE_JSON_POINTER
  14258. };
  14259. formats.full = {
  14260. date: date,
  14261. time: time,
  14262. 'date-time': date_time,
  14263. uri: uri,
  14264. 'uri-reference': URIREF,
  14265. 'uri-template': URITEMPLATE,
  14266. url: URL,
  14267. email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
  14268. hostname: hostname,
  14269. ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  14270. ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
  14271. regex: regex,
  14272. uuid: UUID,
  14273. 'json-pointer': JSON_POINTER,
  14274. 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
  14275. 'relative-json-pointer': RELATIVE_JSON_POINTER
  14276. };
  14277. function isLeapYear(year) {
  14278. // https://tools.ietf.org/html/rfc3339#appendix-C
  14279. return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
  14280. }
  14281. function date(str) {
  14282. // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
  14283. var matches = str.match(DATE);
  14284. if (!matches) return false;
  14285. var year = +matches[1];
  14286. var month = +matches[2];
  14287. var day = +matches[3];
  14288. return month >= 1 && month <= 12 && day >= 1 && day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
  14289. }
  14290. function time(str, full) {
  14291. var matches = str.match(TIME);
  14292. if (!matches) return false;
  14293. var hour = matches[1];
  14294. var minute = matches[2];
  14295. var second = matches[3];
  14296. var timeZone = matches[5];
  14297. return (hour <= 23 && minute <= 59 && second <= 59 || hour == 23 && minute == 59 && second == 60) && (!full || timeZone);
  14298. }
  14299. var DATE_TIME_SEPARATOR = /t|\s/i;
  14300. function date_time(str) {
  14301. // http://tools.ietf.org/html/rfc3339#section-5.6
  14302. var dateTime = str.split(DATE_TIME_SEPARATOR);
  14303. return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
  14304. }
  14305. function hostname(str) {
  14306. // https://tools.ietf.org/html/rfc1034#section-3.5
  14307. // https://tools.ietf.org/html/rfc1123#section-2
  14308. return str.length <= 255 && HOSTNAME.test(str);
  14309. }
  14310. var NOT_URI_FRAGMENT = /\/|:/;
  14311. function uri(str) {
  14312. // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
  14313. return NOT_URI_FRAGMENT.test(str) && URI.test(str);
  14314. }
  14315. var Z_ANCHOR = /[^\\]\\Z/;
  14316. function regex(str) {
  14317. if (Z_ANCHOR.test(str)) return false;
  14318. try {
  14319. new RegExp(str);
  14320. return true;
  14321. } catch (e) {
  14322. return false;
  14323. }
  14324. }
  14325. },{"./util":14}],9:[function(require,module,exports){
  14326. 'use strict';
  14327. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  14328. var resolve = require('./resolve'),
  14329. util = require('./util'),
  14330. errorClasses = require('./error_classes'),
  14331. stableStringify = require('fast-json-stable-stringify');
  14332. var validateGenerator = require('../dotjs/validate');
  14333. /**
  14334. * Functions below are used inside compiled validations function
  14335. */
  14336. var ucs2length = util.ucs2length;
  14337. var equal = require('fast-deep-equal');
  14338. // this error is thrown by async schemas to return validation errors via exception
  14339. var ValidationError = errorClasses.Validation;
  14340. module.exports = compile;
  14341. /**
  14342. * Compiles schema to validation function
  14343. * @this Ajv
  14344. * @param {Object} schema schema object
  14345. * @param {Object} root object with information about the root schema for this schema
  14346. * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
  14347. * @param {String} baseId base ID for IDs in the schema
  14348. * @return {Function} validation function
  14349. */
  14350. function compile(schema, root, localRefs, baseId) {
  14351. /* jshint validthis: true, evil: true */
  14352. /* eslint no-shadow: 0 */
  14353. var self = this,
  14354. opts = this._opts,
  14355. refVal = [undefined],
  14356. refs = {},
  14357. patterns = [],
  14358. patternsHash = {},
  14359. defaults = [],
  14360. defaultsHash = {},
  14361. customRules = [];
  14362. root = root || { schema: schema, refVal: refVal, refs: refs };
  14363. var c = checkCompiling.call(this, schema, root, baseId);
  14364. var compilation = this._compilations[c.index];
  14365. if (c.compiling) return compilation.callValidate = callValidate;
  14366. var formats = this._formats;
  14367. var RULES = this.RULES;
  14368. try {
  14369. var v = localCompile(schema, root, localRefs, baseId);
  14370. compilation.validate = v;
  14371. var cv = compilation.callValidate;
  14372. if (cv) {
  14373. cv.schema = v.schema;
  14374. cv.errors = null;
  14375. cv.refs = v.refs;
  14376. cv.refVal = v.refVal;
  14377. cv.root = v.root;
  14378. cv.$async = v.$async;
  14379. if (opts.sourceCode) cv.source = v.source;
  14380. }
  14381. return v;
  14382. } finally {
  14383. endCompiling.call(this, schema, root, baseId);
  14384. }
  14385. /* @this {*} - custom context, see passContext option */
  14386. function callValidate() {
  14387. /* jshint validthis: true */
  14388. var validate = compilation.validate;
  14389. var result = validate.apply(this, arguments);
  14390. callValidate.errors = validate.errors;
  14391. return result;
  14392. }
  14393. function localCompile(_schema, _root, localRefs, baseId) {
  14394. var isRoot = !_root || _root && _root.schema == _schema;
  14395. if (_root.schema != root.schema) return compile.call(self, _schema, _root, localRefs, baseId);
  14396. var $async = _schema.$async === true;
  14397. var sourceCode = validateGenerator({
  14398. isTop: true,
  14399. schema: _schema,
  14400. isRoot: isRoot,
  14401. baseId: baseId,
  14402. root: _root,
  14403. schemaPath: '',
  14404. errSchemaPath: '#',
  14405. errorPath: '""',
  14406. MissingRefError: errorClasses.MissingRef,
  14407. RULES: RULES,
  14408. validate: validateGenerator,
  14409. util: util,
  14410. resolve: resolve,
  14411. resolveRef: resolveRef,
  14412. usePattern: usePattern,
  14413. useDefault: useDefault,
  14414. useCustomRule: useCustomRule,
  14415. opts: opts,
  14416. formats: formats,
  14417. logger: self.logger,
  14418. self: self
  14419. });
  14420. sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode) + vars(defaults, defaultCode) + vars(customRules, customRuleCode) + sourceCode;
  14421. if (opts.processCode) sourceCode = opts.processCode(sourceCode);
  14422. // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
  14423. var validate;
  14424. try {
  14425. var makeValidate = new Function('self', 'RULES', 'formats', 'root', 'refVal', 'defaults', 'customRules', 'equal', 'ucs2length', 'ValidationError', sourceCode);
  14426. validate = makeValidate(self, RULES, formats, root, refVal, defaults, customRules, equal, ucs2length, ValidationError);
  14427. refVal[0] = validate;
  14428. } catch (e) {
  14429. self.logger.error('Error compiling schema, function code:', sourceCode);
  14430. throw e;
  14431. }
  14432. validate.schema = _schema;
  14433. validate.errors = null;
  14434. validate.refs = refs;
  14435. validate.refVal = refVal;
  14436. validate.root = isRoot ? validate : _root;
  14437. if ($async) validate.$async = true;
  14438. if (opts.sourceCode === true) {
  14439. validate.source = {
  14440. code: sourceCode,
  14441. patterns: patterns,
  14442. defaults: defaults
  14443. };
  14444. }
  14445. return validate;
  14446. }
  14447. function resolveRef(baseId, ref, isRoot) {
  14448. ref = resolve.url(baseId, ref);
  14449. var refIndex = refs[ref];
  14450. var _refVal, refCode;
  14451. if (refIndex !== undefined) {
  14452. _refVal = refVal[refIndex];
  14453. refCode = 'refVal[' + refIndex + ']';
  14454. return resolvedRef(_refVal, refCode);
  14455. }
  14456. if (!isRoot && root.refs) {
  14457. var rootRefId = root.refs[ref];
  14458. if (rootRefId !== undefined) {
  14459. _refVal = root.refVal[rootRefId];
  14460. refCode = addLocalRef(ref, _refVal);
  14461. return resolvedRef(_refVal, refCode);
  14462. }
  14463. }
  14464. refCode = addLocalRef(ref);
  14465. var v = resolve.call(self, localCompile, root, ref);
  14466. if (v === undefined) {
  14467. var localSchema = localRefs && localRefs[ref];
  14468. if (localSchema) {
  14469. v = resolve.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId);
  14470. }
  14471. }
  14472. if (v === undefined) {
  14473. removeLocalRef(ref);
  14474. } else {
  14475. replaceLocalRef(ref, v);
  14476. return resolvedRef(v, refCode);
  14477. }
  14478. }
  14479. function addLocalRef(ref, v) {
  14480. var refId = refVal.length;
  14481. refVal[refId] = v;
  14482. refs[ref] = refId;
  14483. return 'refVal' + refId;
  14484. }
  14485. function removeLocalRef(ref) {
  14486. delete refs[ref];
  14487. }
  14488. function replaceLocalRef(ref, v) {
  14489. var refId = refs[ref];
  14490. refVal[refId] = v;
  14491. }
  14492. function resolvedRef(refVal, code) {
  14493. return (typeof refVal === 'undefined' ? 'undefined' : _typeof(refVal)) == 'object' || typeof refVal == 'boolean' ? { code: code, schema: refVal, inline: true } : { code: code, $async: refVal && !!refVal.$async };
  14494. }
  14495. function usePattern(regexStr) {
  14496. var index = patternsHash[regexStr];
  14497. if (index === undefined) {
  14498. index = patternsHash[regexStr] = patterns.length;
  14499. patterns[index] = regexStr;
  14500. }
  14501. return 'pattern' + index;
  14502. }
  14503. function useDefault(value) {
  14504. switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
  14505. case 'boolean':
  14506. case 'number':
  14507. return '' + value;
  14508. case 'string':
  14509. return util.toQuotedString(value);
  14510. case 'object':
  14511. if (value === null) return 'null';
  14512. var valueStr = stableStringify(value);
  14513. var index = defaultsHash[valueStr];
  14514. if (index === undefined) {
  14515. index = defaultsHash[valueStr] = defaults.length;
  14516. defaults[index] = value;
  14517. }
  14518. return 'default' + index;
  14519. }
  14520. }
  14521. function useCustomRule(rule, schema, parentSchema, it) {
  14522. var validateSchema = rule.definition.validateSchema;
  14523. if (validateSchema && self._opts.validateSchema !== false) {
  14524. var valid = validateSchema(schema);
  14525. if (!valid) {
  14526. var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
  14527. if (self._opts.validateSchema == 'log') self.logger.error(message);else throw new Error(message);
  14528. }
  14529. }
  14530. var compile = rule.definition.compile,
  14531. inline = rule.definition.inline,
  14532. macro = rule.definition.macro;
  14533. var validate;
  14534. if (compile) {
  14535. validate = compile.call(self, schema, parentSchema, it);
  14536. } else if (macro) {
  14537. validate = macro.call(self, schema, parentSchema, it);
  14538. if (opts.validateSchema !== false) self.validateSchema(validate, true);
  14539. } else if (inline) {
  14540. validate = inline.call(self, it, rule.keyword, schema, parentSchema);
  14541. } else {
  14542. validate = rule.definition.validate;
  14543. if (!validate) return;
  14544. }
  14545. if (validate === undefined) throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
  14546. var index = customRules.length;
  14547. customRules[index] = validate;
  14548. return {
  14549. code: 'customRule' + index,
  14550. validate: validate
  14551. };
  14552. }
  14553. }
  14554. /**
  14555. * Checks if the schema is currently compiled
  14556. * @this Ajv
  14557. * @param {Object} schema schema to compile
  14558. * @param {Object} root root object
  14559. * @param {String} baseId base schema ID
  14560. * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
  14561. */
  14562. function checkCompiling(schema, root, baseId) {
  14563. /* jshint validthis: true */
  14564. var index = compIndex.call(this, schema, root, baseId);
  14565. if (index >= 0) return { index: index, compiling: true };
  14566. index = this._compilations.length;
  14567. this._compilations[index] = {
  14568. schema: schema,
  14569. root: root,
  14570. baseId: baseId
  14571. };
  14572. return { index: index, compiling: false };
  14573. }
  14574. /**
  14575. * Removes the schema from the currently compiled list
  14576. * @this Ajv
  14577. * @param {Object} schema schema to compile
  14578. * @param {Object} root root object
  14579. * @param {String} baseId base schema ID
  14580. */
  14581. function endCompiling(schema, root, baseId) {
  14582. /* jshint validthis: true */
  14583. var i = compIndex.call(this, schema, root, baseId);
  14584. if (i >= 0) this._compilations.splice(i, 1);
  14585. }
  14586. /**
  14587. * Index of schema compilation in the currently compiled list
  14588. * @this Ajv
  14589. * @param {Object} schema schema to compile
  14590. * @param {Object} root root object
  14591. * @param {String} baseId base schema ID
  14592. * @return {Integer} compilation index
  14593. */
  14594. function compIndex(schema, root, baseId) {
  14595. /* jshint validthis: true */
  14596. for (var i = 0; i < this._compilations.length; i++) {
  14597. var c = this._compilations[i];
  14598. if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
  14599. }
  14600. return -1;
  14601. }
  14602. function patternCode(i, patterns) {
  14603. return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
  14604. }
  14605. function defaultCode(i) {
  14606. return 'var default' + i + ' = defaults[' + i + '];';
  14607. }
  14608. function refValCode(i, refVal) {
  14609. return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
  14610. }
  14611. function customRuleCode(i) {
  14612. return 'var customRule' + i + ' = customRules[' + i + '];';
  14613. }
  14614. function vars(arr, statement) {
  14615. if (!arr.length) return '';
  14616. var code = '';
  14617. for (var i = 0; i < arr.length; i++) {
  14618. code += statement(i, arr);
  14619. }return code;
  14620. }
  14621. },{"../dotjs/validate":41,"./error_classes":7,"./resolve":10,"./util":14,"fast-deep-equal":81,"fast-json-stable-stringify":82}],10:[function(require,module,exports){
  14622. 'use strict';
  14623. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  14624. var URI = require('uri-js'),
  14625. equal = require('fast-deep-equal'),
  14626. util = require('./util'),
  14627. SchemaObject = require('./schema_obj'),
  14628. traverse = require('json-schema-traverse');
  14629. module.exports = resolve;
  14630. resolve.normalizeId = normalizeId;
  14631. resolve.fullPath = getFullPath;
  14632. resolve.url = resolveUrl;
  14633. resolve.ids = resolveIds;
  14634. resolve.inlineRef = inlineRef;
  14635. resolve.schema = resolveSchema;
  14636. /**
  14637. * [resolve and compile the references ($ref)]
  14638. * @this Ajv
  14639. * @param {Function} compile reference to schema compilation funciton (localCompile)
  14640. * @param {Object} root object with information about the root schema for the current schema
  14641. * @param {String} ref reference to resolve
  14642. * @return {Object|Function} schema object (if the schema can be inlined) or validation function
  14643. */
  14644. function resolve(compile, root, ref) {
  14645. /* jshint validthis: true */
  14646. var refVal = this._refs[ref];
  14647. if (typeof refVal == 'string') {
  14648. if (this._refs[refVal]) refVal = this._refs[refVal];else return resolve.call(this, compile, root, refVal);
  14649. }
  14650. refVal = refVal || this._schemas[ref];
  14651. if (refVal instanceof SchemaObject) {
  14652. return inlineRef(refVal.schema, this._opts.inlineRefs) ? refVal.schema : refVal.validate || this._compile(refVal);
  14653. }
  14654. var res = resolveSchema.call(this, root, ref);
  14655. var schema, v, baseId;
  14656. if (res) {
  14657. schema = res.schema;
  14658. root = res.root;
  14659. baseId = res.baseId;
  14660. }
  14661. if (schema instanceof SchemaObject) {
  14662. v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
  14663. } else if (schema !== undefined) {
  14664. v = inlineRef(schema, this._opts.inlineRefs) ? schema : compile.call(this, schema, root, undefined, baseId);
  14665. }
  14666. return v;
  14667. }
  14668. /**
  14669. * Resolve schema, its root and baseId
  14670. * @this Ajv
  14671. * @param {Object} root root object with properties schema, refVal, refs
  14672. * @param {String} ref reference to resolve
  14673. * @return {Object} object with properties schema, root, baseId
  14674. */
  14675. function resolveSchema(root, ref) {
  14676. /* jshint validthis: true */
  14677. var p = URI.parse(ref),
  14678. refPath = _getFullPath(p),
  14679. baseId = getFullPath(this._getId(root.schema));
  14680. if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
  14681. var id = normalizeId(refPath);
  14682. var refVal = this._refs[id];
  14683. if (typeof refVal == 'string') {
  14684. return resolveRecursive.call(this, root, refVal, p);
  14685. } else if (refVal instanceof SchemaObject) {
  14686. if (!refVal.validate) this._compile(refVal);
  14687. root = refVal;
  14688. } else {
  14689. refVal = this._schemas[id];
  14690. if (refVal instanceof SchemaObject) {
  14691. if (!refVal.validate) this._compile(refVal);
  14692. if (id == normalizeId(ref)) return { schema: refVal, root: root, baseId: baseId };
  14693. root = refVal;
  14694. } else {
  14695. return;
  14696. }
  14697. }
  14698. if (!root.schema) return;
  14699. baseId = getFullPath(this._getId(root.schema));
  14700. }
  14701. return getJsonPointer.call(this, p, baseId, root.schema, root);
  14702. }
  14703. /* @this Ajv */
  14704. function resolveRecursive(root, ref, parsedRef) {
  14705. /* jshint validthis: true */
  14706. var res = resolveSchema.call(this, root, ref);
  14707. if (res) {
  14708. var schema = res.schema;
  14709. var baseId = res.baseId;
  14710. root = res.root;
  14711. var id = this._getId(schema);
  14712. if (id) baseId = resolveUrl(baseId, id);
  14713. return getJsonPointer.call(this, parsedRef, baseId, schema, root);
  14714. }
  14715. }
  14716. var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
  14717. /* @this Ajv */
  14718. function getJsonPointer(parsedRef, baseId, schema, root) {
  14719. /* jshint validthis: true */
  14720. parsedRef.fragment = parsedRef.fragment || '';
  14721. if (parsedRef.fragment.slice(0, 1) != '/') return;
  14722. var parts = parsedRef.fragment.split('/');
  14723. for (var i = 1; i < parts.length; i++) {
  14724. var part = parts[i];
  14725. if (part) {
  14726. part = util.unescapeFragment(part);
  14727. schema = schema[part];
  14728. if (schema === undefined) break;
  14729. var id;
  14730. if (!PREVENT_SCOPE_CHANGE[part]) {
  14731. id = this._getId(schema);
  14732. if (id) baseId = resolveUrl(baseId, id);
  14733. if (schema.$ref) {
  14734. var $ref = resolveUrl(baseId, schema.$ref);
  14735. var res = resolveSchema.call(this, root, $ref);
  14736. if (res) {
  14737. schema = res.schema;
  14738. root = res.root;
  14739. baseId = res.baseId;
  14740. }
  14741. }
  14742. }
  14743. }
  14744. }
  14745. if (schema !== undefined && schema !== root.schema) return { schema: schema, root: root, baseId: baseId };
  14746. }
  14747. var SIMPLE_INLINED = util.toHash(['type', 'format', 'pattern', 'maxLength', 'minLength', 'maxProperties', 'minProperties', 'maxItems', 'minItems', 'maximum', 'minimum', 'uniqueItems', 'multipleOf', 'required', 'enum']);
  14748. function inlineRef(schema, limit) {
  14749. if (limit === false) return false;
  14750. if (limit === undefined || limit === true) return checkNoRef(schema);else if (limit) return countKeys(schema) <= limit;
  14751. }
  14752. function checkNoRef(schema) {
  14753. var item;
  14754. if (Array.isArray(schema)) {
  14755. for (var i = 0; i < schema.length; i++) {
  14756. item = schema[i];
  14757. if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) == 'object' && !checkNoRef(item)) return false;
  14758. }
  14759. } else {
  14760. for (var key in schema) {
  14761. if (key == '$ref') return false;
  14762. item = schema[key];
  14763. if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) == 'object' && !checkNoRef(item)) return false;
  14764. }
  14765. }
  14766. return true;
  14767. }
  14768. function countKeys(schema) {
  14769. var count = 0,
  14770. item;
  14771. if (Array.isArray(schema)) {
  14772. for (var i = 0; i < schema.length; i++) {
  14773. item = schema[i];
  14774. if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) == 'object') count += countKeys(item);
  14775. if (count == Infinity) return Infinity;
  14776. }
  14777. } else {
  14778. for (var key in schema) {
  14779. if (key == '$ref') return Infinity;
  14780. if (SIMPLE_INLINED[key]) {
  14781. count++;
  14782. } else {
  14783. item = schema[key];
  14784. if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) == 'object') count += countKeys(item) + 1;
  14785. if (count == Infinity) return Infinity;
  14786. }
  14787. }
  14788. }
  14789. return count;
  14790. }
  14791. function getFullPath(id, normalize) {
  14792. if (normalize !== false) id = normalizeId(id);
  14793. var p = URI.parse(id);
  14794. return _getFullPath(p);
  14795. }
  14796. function _getFullPath(p) {
  14797. return URI.serialize(p).split('#')[0] + '#';
  14798. }
  14799. var TRAILING_SLASH_HASH = /#\/?$/;
  14800. function normalizeId(id) {
  14801. return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
  14802. }
  14803. function resolveUrl(baseId, id) {
  14804. id = normalizeId(id);
  14805. return URI.resolve(baseId, id);
  14806. }
  14807. /* @this Ajv */
  14808. function resolveIds(schema) {
  14809. var schemaId = normalizeId(this._getId(schema));
  14810. var baseIds = { '': schemaId };
  14811. var fullPaths = { '': getFullPath(schemaId, false) };
  14812. var localRefs = {};
  14813. var self = this;
  14814. traverse(schema, { allKeys: true }, function (sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
  14815. if (jsonPtr === '') return;
  14816. var id = self._getId(sch);
  14817. var baseId = baseIds[parentJsonPtr];
  14818. var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
  14819. if (keyIndex !== undefined) fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
  14820. if (typeof id == 'string') {
  14821. id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
  14822. var refVal = self._refs[id];
  14823. if (typeof refVal == 'string') refVal = self._refs[refVal];
  14824. if (refVal && refVal.schema) {
  14825. if (!equal(sch, refVal.schema)) throw new Error('id "' + id + '" resolves to more than one schema');
  14826. } else if (id != normalizeId(fullPath)) {
  14827. if (id[0] == '#') {
  14828. if (localRefs[id] && !equal(sch, localRefs[id])) throw new Error('id "' + id + '" resolves to more than one schema');
  14829. localRefs[id] = sch;
  14830. } else {
  14831. self._refs[id] = fullPath;
  14832. }
  14833. }
  14834. }
  14835. baseIds[jsonPtr] = baseId;
  14836. fullPaths[jsonPtr] = fullPath;
  14837. });
  14838. return localRefs;
  14839. }
  14840. },{"./schema_obj":12,"./util":14,"fast-deep-equal":81,"json-schema-traverse":88,"uri-js":108}],11:[function(require,module,exports){
  14841. 'use strict';
  14842. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  14843. var ruleModules = require('../dotjs'),
  14844. toHash = require('./util').toHash;
  14845. module.exports = function rules() {
  14846. var RULES = [{ type: 'number',
  14847. rules: [{ 'maximum': ['exclusiveMaximum'] }, { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] }, { type: 'string',
  14848. rules: ['maxLength', 'minLength', 'pattern', 'format'] }, { type: 'array',
  14849. rules: ['maxItems', 'minItems', 'items', 'contains', 'uniqueItems'] }, { type: 'object',
  14850. rules: ['maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames', { 'properties': ['additionalProperties', 'patternProperties'] }] }, { rules: ['$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if'] }];
  14851. var ALL = ['type', '$comment'];
  14852. var KEYWORDS = ['$schema', '$id', 'id', '$data', 'title', 'description', 'default', 'definitions', 'examples', 'readOnly', 'writeOnly', 'contentMediaType', 'contentEncoding', 'additionalItems', 'then', 'else'];
  14853. var TYPES = ['number', 'integer', 'string', 'array', 'object', 'boolean', 'null'];
  14854. RULES.all = toHash(ALL);
  14855. RULES.types = toHash(TYPES);
  14856. RULES.forEach(function (group) {
  14857. group.rules = group.rules.map(function (keyword) {
  14858. var implKeywords;
  14859. if ((typeof keyword === 'undefined' ? 'undefined' : _typeof(keyword)) == 'object') {
  14860. var key = Object.keys(keyword)[0];
  14861. implKeywords = keyword[key];
  14862. keyword = key;
  14863. implKeywords.forEach(function (k) {
  14864. ALL.push(k);
  14865. RULES.all[k] = true;
  14866. });
  14867. }
  14868. ALL.push(keyword);
  14869. var rule = RULES.all[keyword] = {
  14870. keyword: keyword,
  14871. code: ruleModules[keyword],
  14872. implements: implKeywords
  14873. };
  14874. return rule;
  14875. });
  14876. RULES.all.$comment = {
  14877. keyword: '$comment',
  14878. code: ruleModules.$comment
  14879. };
  14880. if (group.type) RULES.types[group.type] = group;
  14881. });
  14882. RULES.keywords = toHash(ALL.concat(KEYWORDS));
  14883. RULES.custom = {};
  14884. return RULES;
  14885. };
  14886. },{"../dotjs":30,"./util":14}],12:[function(require,module,exports){
  14887. 'use strict';
  14888. var util = require('./util');
  14889. module.exports = SchemaObject;
  14890. function SchemaObject(obj) {
  14891. util.copy(obj, this);
  14892. }
  14893. },{"./util":14}],13:[function(require,module,exports){
  14894. 'use strict';
  14895. // https://mathiasbynens.be/notes/javascript-encoding
  14896. // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
  14897. module.exports = function ucs2length(str) {
  14898. var length = 0,
  14899. len = str.length,
  14900. pos = 0,
  14901. value;
  14902. while (pos < len) {
  14903. length++;
  14904. value = str.charCodeAt(pos++);
  14905. if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
  14906. // high surrogate, and there is a next character
  14907. value = str.charCodeAt(pos);
  14908. if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
  14909. }
  14910. }
  14911. return length;
  14912. };
  14913. },{}],14:[function(require,module,exports){
  14914. 'use strict';
  14915. module.exports = {
  14916. copy: copy,
  14917. checkDataType: checkDataType,
  14918. checkDataTypes: checkDataTypes,
  14919. coerceToTypes: coerceToTypes,
  14920. toHash: toHash,
  14921. getProperty: getProperty,
  14922. escapeQuotes: escapeQuotes,
  14923. equal: require('fast-deep-equal'),
  14924. ucs2length: require('./ucs2length'),
  14925. varOccurences: varOccurences,
  14926. varReplace: varReplace,
  14927. cleanUpCode: cleanUpCode,
  14928. finalCleanUpCode: finalCleanUpCode,
  14929. schemaHasRules: schemaHasRules,
  14930. schemaHasRulesExcept: schemaHasRulesExcept,
  14931. toQuotedString: toQuotedString,
  14932. getPathExpr: getPathExpr,
  14933. getPath: getPath,
  14934. getData: getData,
  14935. unescapeFragment: unescapeFragment,
  14936. unescapeJsonPointer: unescapeJsonPointer,
  14937. escapeFragment: escapeFragment,
  14938. escapeJsonPointer: escapeJsonPointer
  14939. };
  14940. function copy(o, to) {
  14941. to = to || {};
  14942. for (var key in o) {
  14943. to[key] = o[key];
  14944. }return to;
  14945. }
  14946. function checkDataType(dataType, data, negate) {
  14947. var EQUAL = negate ? ' !== ' : ' === ',
  14948. AND = negate ? ' || ' : ' && ',
  14949. OK = negate ? '!' : '',
  14950. NOT = negate ? '' : '!';
  14951. switch (dataType) {
  14952. case 'null':
  14953. return data + EQUAL + 'null';
  14954. case 'array':
  14955. return OK + 'Array.isArray(' + data + ')';
  14956. case 'object':
  14957. return '(' + OK + data + AND + 'typeof ' + data + EQUAL + '"object"' + AND + NOT + 'Array.isArray(' + data + '))';
  14958. case 'integer':
  14959. return '(typeof ' + data + EQUAL + '"number"' + AND + NOT + '(' + data + ' % 1)' + AND + data + EQUAL + data + ')';
  14960. default:
  14961. return 'typeof ' + data + EQUAL + '"' + dataType + '"';
  14962. }
  14963. }
  14964. function checkDataTypes(dataTypes, data) {
  14965. switch (dataTypes.length) {
  14966. case 1:
  14967. return checkDataType(dataTypes[0], data, true);
  14968. default:
  14969. var code = '';
  14970. var types = toHash(dataTypes);
  14971. if (types.array && types.object) {
  14972. code = types.null ? '(' : '(!' + data + ' || ';
  14973. code += 'typeof ' + data + ' !== "object")';
  14974. delete types.null;
  14975. delete types.array;
  14976. delete types.object;
  14977. }
  14978. if (types.number) delete types.integer;
  14979. for (var t in types) {
  14980. code += (code ? ' && ' : '') + checkDataType(t, data, true);
  14981. }return code;
  14982. }
  14983. }
  14984. var COERCE_TO_TYPES = toHash(['string', 'number', 'integer', 'boolean', 'null']);
  14985. function coerceToTypes(optionCoerceTypes, dataTypes) {
  14986. if (Array.isArray(dataTypes)) {
  14987. var types = [];
  14988. for (var i = 0; i < dataTypes.length; i++) {
  14989. var t = dataTypes[i];
  14990. if (COERCE_TO_TYPES[t]) types[types.length] = t;else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
  14991. }
  14992. if (types.length) return types;
  14993. } else if (COERCE_TO_TYPES[dataTypes]) {
  14994. return [dataTypes];
  14995. } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
  14996. return ['array'];
  14997. }
  14998. }
  14999. function toHash(arr) {
  15000. var hash = {};
  15001. for (var i = 0; i < arr.length; i++) {
  15002. hash[arr[i]] = true;
  15003. }return hash;
  15004. }
  15005. var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
  15006. var SINGLE_QUOTE = /'|\\/g;
  15007. function getProperty(key) {
  15008. return typeof key == 'number' ? '[' + key + ']' : IDENTIFIER.test(key) ? '.' + key : "['" + escapeQuotes(key) + "']";
  15009. }
  15010. function escapeQuotes(str) {
  15011. return str.replace(SINGLE_QUOTE, '\\$&').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\f/g, '\\f').replace(/\t/g, '\\t');
  15012. }
  15013. function varOccurences(str, dataVar) {
  15014. dataVar += '[^0-9]';
  15015. var matches = str.match(new RegExp(dataVar, 'g'));
  15016. return matches ? matches.length : 0;
  15017. }
  15018. function varReplace(str, dataVar, expr) {
  15019. dataVar += '([^0-9])';
  15020. expr = expr.replace(/\$/g, '$$$$');
  15021. return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
  15022. }
  15023. var EMPTY_ELSE = /else\s*{\s*}/g,
  15024. EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g,
  15025. EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
  15026. function cleanUpCode(out) {
  15027. return out.replace(EMPTY_ELSE, '').replace(EMPTY_IF_NO_ELSE, '').replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
  15028. }
  15029. var ERRORS_REGEXP = /[^v.]errors/g,
  15030. REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g,
  15031. REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g,
  15032. RETURN_VALID = 'return errors === 0;',
  15033. RETURN_TRUE = 'validate.errors = null; return true;',
  15034. RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/,
  15035. RETURN_DATA_ASYNC = 'return data;',
  15036. ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g,
  15037. REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
  15038. function finalCleanUpCode(out, async) {
  15039. var matches = out.match(ERRORS_REGEXP);
  15040. if (matches && matches.length == 2) {
  15041. out = async ? out.replace(REMOVE_ERRORS_ASYNC, '').replace(RETURN_ASYNC, RETURN_DATA_ASYNC) : out.replace(REMOVE_ERRORS, '').replace(RETURN_VALID, RETURN_TRUE);
  15042. }
  15043. matches = out.match(ROOTDATA_REGEXP);
  15044. if (!matches || matches.length !== 3) return out;
  15045. return out.replace(REMOVE_ROOTDATA, '');
  15046. }
  15047. function schemaHasRules(schema, rules) {
  15048. if (typeof schema == 'boolean') return !schema;
  15049. for (var key in schema) {
  15050. if (rules[key]) return true;
  15051. }
  15052. }
  15053. function schemaHasRulesExcept(schema, rules, exceptKeyword) {
  15054. if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
  15055. for (var key in schema) {
  15056. if (key != exceptKeyword && rules[key]) return true;
  15057. }
  15058. }
  15059. function toQuotedString(str) {
  15060. return '\'' + escapeQuotes(str) + '\'';
  15061. }
  15062. function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
  15063. var path = jsonPointers // false by default
  15064. ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')') : isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'';
  15065. return joinPaths(currentPath, path);
  15066. }
  15067. function getPath(currentPath, prop, jsonPointers) {
  15068. var path = jsonPointers // false by default
  15069. ? toQuotedString('/' + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
  15070. return joinPaths(currentPath, path);
  15071. }
  15072. var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
  15073. var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
  15074. function getData($data, lvl, paths) {
  15075. var up, jsonPointer, data, matches;
  15076. if ($data === '') return 'rootData';
  15077. if ($data[0] == '/') {
  15078. if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
  15079. jsonPointer = $data;
  15080. data = 'rootData';
  15081. } else {
  15082. matches = $data.match(RELATIVE_JSON_POINTER);
  15083. if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
  15084. up = +matches[1];
  15085. jsonPointer = matches[2];
  15086. if (jsonPointer == '#') {
  15087. if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
  15088. return paths[lvl - up];
  15089. }
  15090. if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
  15091. data = 'data' + (lvl - up || '');
  15092. if (!jsonPointer) return data;
  15093. }
  15094. var expr = data;
  15095. var segments = jsonPointer.split('/');
  15096. for (var i = 0; i < segments.length; i++) {
  15097. var segment = segments[i];
  15098. if (segment) {
  15099. data += getProperty(unescapeJsonPointer(segment));
  15100. expr += ' && ' + data;
  15101. }
  15102. }
  15103. return expr;
  15104. }
  15105. function joinPaths(a, b) {
  15106. if (a == '""') return b;
  15107. return (a + ' + ' + b).replace(/' \+ '/g, '');
  15108. }
  15109. function unescapeFragment(str) {
  15110. return unescapeJsonPointer(decodeURIComponent(str));
  15111. }
  15112. function escapeFragment(str) {
  15113. return encodeURIComponent(escapeJsonPointer(str));
  15114. }
  15115. function escapeJsonPointer(str) {
  15116. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  15117. }
  15118. function unescapeJsonPointer(str) {
  15119. return str.replace(/~1/g, '/').replace(/~0/g, '~');
  15120. }
  15121. },{"./ucs2length":13,"fast-deep-equal":81}],15:[function(require,module,exports){
  15122. 'use strict';
  15123. var KEYWORDS = ['multipleOf', 'maximum', 'exclusiveMaximum', 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern', 'additionalItems', 'maxItems', 'minItems', 'uniqueItems', 'maxProperties', 'minProperties', 'required', 'additionalProperties', 'enum', 'format', 'const'];
  15124. module.exports = function (metaSchema, keywordsJsonPointers) {
  15125. for (var i = 0; i < keywordsJsonPointers.length; i++) {
  15126. metaSchema = JSON.parse(JSON.stringify(metaSchema));
  15127. var segments = keywordsJsonPointers[i].split('/');
  15128. var keywords = metaSchema;
  15129. var j;
  15130. for (j = 1; j < segments.length; j++) {
  15131. keywords = keywords[segments[j]];
  15132. }for (j = 0; j < KEYWORDS.length; j++) {
  15133. var key = KEYWORDS[j];
  15134. var schema = keywords[key];
  15135. if (schema) {
  15136. keywords[key] = {
  15137. anyOf: [schema, { $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }]
  15138. };
  15139. }
  15140. }
  15141. }
  15142. return metaSchema;
  15143. };
  15144. },{}],16:[function(require,module,exports){
  15145. 'use strict';
  15146. module.exports = function generate__limit(it, $keyword, $ruleType) {
  15147. var out = ' ';
  15148. var $lvl = it.level;
  15149. var $dataLvl = it.dataLevel;
  15150. var $schema = it.schema[$keyword];
  15151. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15152. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15153. var $breakOnError = !it.opts.allErrors;
  15154. var $errorKeyword;
  15155. var $data = 'data' + ($dataLvl || '');
  15156. var $isData = it.opts.$data && $schema && $schema.$data,
  15157. $schemaValue;
  15158. if ($isData) {
  15159. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  15160. $schemaValue = 'schema' + $lvl;
  15161. } else {
  15162. $schemaValue = $schema;
  15163. }
  15164. var $isMax = $keyword == 'maximum',
  15165. $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
  15166. $schemaExcl = it.schema[$exclusiveKeyword],
  15167. $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
  15168. $op = $isMax ? '<' : '>',
  15169. $notOp = $isMax ? '>' : '<',
  15170. $errorKeyword = undefined;
  15171. if ($isDataExcl) {
  15172. var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
  15173. $exclusive = 'exclusive' + $lvl,
  15174. $exclType = 'exclType' + $lvl,
  15175. $exclIsNumber = 'exclIsNumber' + $lvl,
  15176. $opExpr = 'op' + $lvl,
  15177. $opStr = '\' + ' + $opExpr + ' + \'';
  15178. out += ' var schemaExcl' + $lvl + ' = ' + $schemaValueExcl + '; ';
  15179. $schemaValueExcl = 'schemaExcl' + $lvl;
  15180. out += ' var ' + $exclusive + '; var ' + $exclType + ' = typeof ' + $schemaValueExcl + '; if (' + $exclType + ' != \'boolean\' && ' + $exclType + ' != \'undefined\' && ' + $exclType + ' != \'number\') { ';
  15181. var $errorKeyword = $exclusiveKeyword;
  15182. var $$outStack = $$outStack || [];
  15183. $$outStack.push(out);
  15184. out = ''; /* istanbul ignore else */
  15185. if (it.createErrors !== false) {
  15186. out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
  15187. if (it.opts.messages !== false) {
  15188. out += ' , message: \'' + $exclusiveKeyword + ' should be boolean\' ';
  15189. }
  15190. if (it.opts.verbose) {
  15191. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15192. }
  15193. out += ' } ';
  15194. } else {
  15195. out += ' {} ';
  15196. }
  15197. var __err = out;
  15198. out = $$outStack.pop();
  15199. if (!it.compositeRule && $breakOnError) {
  15200. /* istanbul ignore if */
  15201. if (it.async) {
  15202. out += ' throw new ValidationError([' + __err + ']); ';
  15203. } else {
  15204. out += ' validate.errors = [' + __err + ']; return false; ';
  15205. }
  15206. } else {
  15207. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15208. }
  15209. out += ' } else if ( ';
  15210. if ($isData) {
  15211. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
  15212. }
  15213. out += ' ' + $exclType + ' == \'number\' ? ( (' + $exclusive + ' = ' + $schemaValue + ' === undefined || ' + $schemaValueExcl + ' ' + $op + '= ' + $schemaValue + ') ? ' + $data + ' ' + $notOp + '= ' + $schemaValueExcl + ' : ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' ) : ( (' + $exclusive + ' = ' + $schemaValueExcl + ' === true) ? ' + $data + ' ' + $notOp + '= ' + $schemaValue + ' : ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' ) || ' + $data + ' !== ' + $data + ') { var op' + $lvl + ' = ' + $exclusive + ' ? \'' + $op + '\' : \'' + $op + '=\'; ';
  15214. if ($schema === undefined) {
  15215. $errorKeyword = $exclusiveKeyword;
  15216. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  15217. $schemaValue = $schemaValueExcl;
  15218. $isData = $isDataExcl;
  15219. }
  15220. } else {
  15221. var $exclIsNumber = typeof $schemaExcl == 'number',
  15222. $opStr = $op;
  15223. if ($exclIsNumber && $isData) {
  15224. var $opExpr = '\'' + $opStr + '\'';
  15225. out += ' if ( ';
  15226. if ($isData) {
  15227. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
  15228. }
  15229. out += ' ( ' + $schemaValue + ' === undefined || ' + $schemaExcl + ' ' + $op + '= ' + $schemaValue + ' ? ' + $data + ' ' + $notOp + '= ' + $schemaExcl + ' : ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' ) || ' + $data + ' !== ' + $data + ') { ';
  15230. } else {
  15231. if ($exclIsNumber && $schema === undefined) {
  15232. $exclusive = true;
  15233. $errorKeyword = $exclusiveKeyword;
  15234. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  15235. $schemaValue = $schemaExcl;
  15236. $notOp += '=';
  15237. } else {
  15238. if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
  15239. if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
  15240. $exclusive = true;
  15241. $errorKeyword = $exclusiveKeyword;
  15242. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  15243. $notOp += '=';
  15244. } else {
  15245. $exclusive = false;
  15246. $opStr += '=';
  15247. }
  15248. }
  15249. var $opExpr = '\'' + $opStr + '\'';
  15250. out += ' if ( ';
  15251. if ($isData) {
  15252. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
  15253. }
  15254. out += ' ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' || ' + $data + ' !== ' + $data + ') { ';
  15255. }
  15256. }
  15257. $errorKeyword = $errorKeyword || $keyword;
  15258. var $$outStack = $$outStack || [];
  15259. $$outStack.push(out);
  15260. out = ''; /* istanbul ignore else */
  15261. if (it.createErrors !== false) {
  15262. out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { comparison: ' + $opExpr + ', limit: ' + $schemaValue + ', exclusive: ' + $exclusive + ' } ';
  15263. if (it.opts.messages !== false) {
  15264. out += ' , message: \'should be ' + $opStr + ' ';
  15265. if ($isData) {
  15266. out += '\' + ' + $schemaValue;
  15267. } else {
  15268. out += '' + $schemaValue + '\'';
  15269. }
  15270. }
  15271. if (it.opts.verbose) {
  15272. out += ' , schema: ';
  15273. if ($isData) {
  15274. out += 'validate.schema' + $schemaPath;
  15275. } else {
  15276. out += '' + $schema;
  15277. }
  15278. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15279. }
  15280. out += ' } ';
  15281. } else {
  15282. out += ' {} ';
  15283. }
  15284. var __err = out;
  15285. out = $$outStack.pop();
  15286. if (!it.compositeRule && $breakOnError) {
  15287. /* istanbul ignore if */
  15288. if (it.async) {
  15289. out += ' throw new ValidationError([' + __err + ']); ';
  15290. } else {
  15291. out += ' validate.errors = [' + __err + ']; return false; ';
  15292. }
  15293. } else {
  15294. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15295. }
  15296. out += ' } ';
  15297. if ($breakOnError) {
  15298. out += ' else { ';
  15299. }
  15300. return out;
  15301. };
  15302. },{}],17:[function(require,module,exports){
  15303. 'use strict';
  15304. module.exports = function generate__limitItems(it, $keyword, $ruleType) {
  15305. var out = ' ';
  15306. var $lvl = it.level;
  15307. var $dataLvl = it.dataLevel;
  15308. var $schema = it.schema[$keyword];
  15309. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15310. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15311. var $breakOnError = !it.opts.allErrors;
  15312. var $errorKeyword;
  15313. var $data = 'data' + ($dataLvl || '');
  15314. var $isData = it.opts.$data && $schema && $schema.$data,
  15315. $schemaValue;
  15316. if ($isData) {
  15317. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  15318. $schemaValue = 'schema' + $lvl;
  15319. } else {
  15320. $schemaValue = $schema;
  15321. }
  15322. var $op = $keyword == 'maxItems' ? '>' : '<';
  15323. out += 'if ( ';
  15324. if ($isData) {
  15325. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
  15326. }
  15327. out += ' ' + $data + '.length ' + $op + ' ' + $schemaValue + ') { ';
  15328. var $errorKeyword = $keyword;
  15329. var $$outStack = $$outStack || [];
  15330. $$outStack.push(out);
  15331. out = ''; /* istanbul ignore else */
  15332. if (it.createErrors !== false) {
  15333. out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
  15334. if (it.opts.messages !== false) {
  15335. out += ' , message: \'should NOT have ';
  15336. if ($keyword == 'maxItems') {
  15337. out += 'more';
  15338. } else {
  15339. out += 'fewer';
  15340. }
  15341. out += ' than ';
  15342. if ($isData) {
  15343. out += '\' + ' + $schemaValue + ' + \'';
  15344. } else {
  15345. out += '' + $schema;
  15346. }
  15347. out += ' items\' ';
  15348. }
  15349. if (it.opts.verbose) {
  15350. out += ' , schema: ';
  15351. if ($isData) {
  15352. out += 'validate.schema' + $schemaPath;
  15353. } else {
  15354. out += '' + $schema;
  15355. }
  15356. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15357. }
  15358. out += ' } ';
  15359. } else {
  15360. out += ' {} ';
  15361. }
  15362. var __err = out;
  15363. out = $$outStack.pop();
  15364. if (!it.compositeRule && $breakOnError) {
  15365. /* istanbul ignore if */
  15366. if (it.async) {
  15367. out += ' throw new ValidationError([' + __err + ']); ';
  15368. } else {
  15369. out += ' validate.errors = [' + __err + ']; return false; ';
  15370. }
  15371. } else {
  15372. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15373. }
  15374. out += '} ';
  15375. if ($breakOnError) {
  15376. out += ' else { ';
  15377. }
  15378. return out;
  15379. };
  15380. },{}],18:[function(require,module,exports){
  15381. 'use strict';
  15382. module.exports = function generate__limitLength(it, $keyword, $ruleType) {
  15383. var out = ' ';
  15384. var $lvl = it.level;
  15385. var $dataLvl = it.dataLevel;
  15386. var $schema = it.schema[$keyword];
  15387. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15388. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15389. var $breakOnError = !it.opts.allErrors;
  15390. var $errorKeyword;
  15391. var $data = 'data' + ($dataLvl || '');
  15392. var $isData = it.opts.$data && $schema && $schema.$data,
  15393. $schemaValue;
  15394. if ($isData) {
  15395. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  15396. $schemaValue = 'schema' + $lvl;
  15397. } else {
  15398. $schemaValue = $schema;
  15399. }
  15400. var $op = $keyword == 'maxLength' ? '>' : '<';
  15401. out += 'if ( ';
  15402. if ($isData) {
  15403. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
  15404. }
  15405. if (it.opts.unicode === false) {
  15406. out += ' ' + $data + '.length ';
  15407. } else {
  15408. out += ' ucs2length(' + $data + ') ';
  15409. }
  15410. out += ' ' + $op + ' ' + $schemaValue + ') { ';
  15411. var $errorKeyword = $keyword;
  15412. var $$outStack = $$outStack || [];
  15413. $$outStack.push(out);
  15414. out = ''; /* istanbul ignore else */
  15415. if (it.createErrors !== false) {
  15416. out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
  15417. if (it.opts.messages !== false) {
  15418. out += ' , message: \'should NOT be ';
  15419. if ($keyword == 'maxLength') {
  15420. out += 'longer';
  15421. } else {
  15422. out += 'shorter';
  15423. }
  15424. out += ' than ';
  15425. if ($isData) {
  15426. out += '\' + ' + $schemaValue + ' + \'';
  15427. } else {
  15428. out += '' + $schema;
  15429. }
  15430. out += ' characters\' ';
  15431. }
  15432. if (it.opts.verbose) {
  15433. out += ' , schema: ';
  15434. if ($isData) {
  15435. out += 'validate.schema' + $schemaPath;
  15436. } else {
  15437. out += '' + $schema;
  15438. }
  15439. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15440. }
  15441. out += ' } ';
  15442. } else {
  15443. out += ' {} ';
  15444. }
  15445. var __err = out;
  15446. out = $$outStack.pop();
  15447. if (!it.compositeRule && $breakOnError) {
  15448. /* istanbul ignore if */
  15449. if (it.async) {
  15450. out += ' throw new ValidationError([' + __err + ']); ';
  15451. } else {
  15452. out += ' validate.errors = [' + __err + ']; return false; ';
  15453. }
  15454. } else {
  15455. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15456. }
  15457. out += '} ';
  15458. if ($breakOnError) {
  15459. out += ' else { ';
  15460. }
  15461. return out;
  15462. };
  15463. },{}],19:[function(require,module,exports){
  15464. 'use strict';
  15465. module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
  15466. var out = ' ';
  15467. var $lvl = it.level;
  15468. var $dataLvl = it.dataLevel;
  15469. var $schema = it.schema[$keyword];
  15470. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15471. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15472. var $breakOnError = !it.opts.allErrors;
  15473. var $errorKeyword;
  15474. var $data = 'data' + ($dataLvl || '');
  15475. var $isData = it.opts.$data && $schema && $schema.$data,
  15476. $schemaValue;
  15477. if ($isData) {
  15478. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  15479. $schemaValue = 'schema' + $lvl;
  15480. } else {
  15481. $schemaValue = $schema;
  15482. }
  15483. var $op = $keyword == 'maxProperties' ? '>' : '<';
  15484. out += 'if ( ';
  15485. if ($isData) {
  15486. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
  15487. }
  15488. out += ' Object.keys(' + $data + ').length ' + $op + ' ' + $schemaValue + ') { ';
  15489. var $errorKeyword = $keyword;
  15490. var $$outStack = $$outStack || [];
  15491. $$outStack.push(out);
  15492. out = ''; /* istanbul ignore else */
  15493. if (it.createErrors !== false) {
  15494. out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
  15495. if (it.opts.messages !== false) {
  15496. out += ' , message: \'should NOT have ';
  15497. if ($keyword == 'maxProperties') {
  15498. out += 'more';
  15499. } else {
  15500. out += 'fewer';
  15501. }
  15502. out += ' than ';
  15503. if ($isData) {
  15504. out += '\' + ' + $schemaValue + ' + \'';
  15505. } else {
  15506. out += '' + $schema;
  15507. }
  15508. out += ' properties\' ';
  15509. }
  15510. if (it.opts.verbose) {
  15511. out += ' , schema: ';
  15512. if ($isData) {
  15513. out += 'validate.schema' + $schemaPath;
  15514. } else {
  15515. out += '' + $schema;
  15516. }
  15517. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15518. }
  15519. out += ' } ';
  15520. } else {
  15521. out += ' {} ';
  15522. }
  15523. var __err = out;
  15524. out = $$outStack.pop();
  15525. if (!it.compositeRule && $breakOnError) {
  15526. /* istanbul ignore if */
  15527. if (it.async) {
  15528. out += ' throw new ValidationError([' + __err + ']); ';
  15529. } else {
  15530. out += ' validate.errors = [' + __err + ']; return false; ';
  15531. }
  15532. } else {
  15533. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15534. }
  15535. out += '} ';
  15536. if ($breakOnError) {
  15537. out += ' else { ';
  15538. }
  15539. return out;
  15540. };
  15541. },{}],20:[function(require,module,exports){
  15542. 'use strict';
  15543. module.exports = function generate_allOf(it, $keyword, $ruleType) {
  15544. var out = ' ';
  15545. var $schema = it.schema[$keyword];
  15546. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15547. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15548. var $breakOnError = !it.opts.allErrors;
  15549. var $it = it.util.copy(it);
  15550. var $closingBraces = '';
  15551. $it.level++;
  15552. var $nextValid = 'valid' + $it.level;
  15553. var $currentBaseId = $it.baseId,
  15554. $allSchemasEmpty = true;
  15555. var arr1 = $schema;
  15556. if (arr1) {
  15557. var $sch,
  15558. $i = -1,
  15559. l1 = arr1.length - 1;
  15560. while ($i < l1) {
  15561. $sch = arr1[$i += 1];
  15562. if (it.util.schemaHasRules($sch, it.RULES.all)) {
  15563. $allSchemasEmpty = false;
  15564. $it.schema = $sch;
  15565. $it.schemaPath = $schemaPath + '[' + $i + ']';
  15566. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  15567. out += ' ' + it.validate($it) + ' ';
  15568. $it.baseId = $currentBaseId;
  15569. if ($breakOnError) {
  15570. out += ' if (' + $nextValid + ') { ';
  15571. $closingBraces += '}';
  15572. }
  15573. }
  15574. }
  15575. }
  15576. if ($breakOnError) {
  15577. if ($allSchemasEmpty) {
  15578. out += ' if (true) { ';
  15579. } else {
  15580. out += ' ' + $closingBraces.slice(0, -1) + ' ';
  15581. }
  15582. }
  15583. out = it.util.cleanUpCode(out);
  15584. return out;
  15585. };
  15586. },{}],21:[function(require,module,exports){
  15587. 'use strict';
  15588. module.exports = function generate_anyOf(it, $keyword, $ruleType) {
  15589. var out = ' ';
  15590. var $lvl = it.level;
  15591. var $dataLvl = it.dataLevel;
  15592. var $schema = it.schema[$keyword];
  15593. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15594. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15595. var $breakOnError = !it.opts.allErrors;
  15596. var $data = 'data' + ($dataLvl || '');
  15597. var $valid = 'valid' + $lvl;
  15598. var $errs = 'errs__' + $lvl;
  15599. var $it = it.util.copy(it);
  15600. var $closingBraces = '';
  15601. $it.level++;
  15602. var $nextValid = 'valid' + $it.level;
  15603. var $noEmptySchema = $schema.every(function ($sch) {
  15604. return it.util.schemaHasRules($sch, it.RULES.all);
  15605. });
  15606. if ($noEmptySchema) {
  15607. var $currentBaseId = $it.baseId;
  15608. out += ' var ' + $errs + ' = errors; var ' + $valid + ' = false; ';
  15609. var $wasComposite = it.compositeRule;
  15610. it.compositeRule = $it.compositeRule = true;
  15611. var arr1 = $schema;
  15612. if (arr1) {
  15613. var $sch,
  15614. $i = -1,
  15615. l1 = arr1.length - 1;
  15616. while ($i < l1) {
  15617. $sch = arr1[$i += 1];
  15618. $it.schema = $sch;
  15619. $it.schemaPath = $schemaPath + '[' + $i + ']';
  15620. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  15621. out += ' ' + it.validate($it) + ' ';
  15622. $it.baseId = $currentBaseId;
  15623. out += ' ' + $valid + ' = ' + $valid + ' || ' + $nextValid + '; if (!' + $valid + ') { ';
  15624. $closingBraces += '}';
  15625. }
  15626. }
  15627. it.compositeRule = $it.compositeRule = $wasComposite;
  15628. out += ' ' + $closingBraces + ' if (!' + $valid + ') { var err = '; /* istanbul ignore else */
  15629. if (it.createErrors !== false) {
  15630. out += ' { keyword: \'' + 'anyOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
  15631. if (it.opts.messages !== false) {
  15632. out += ' , message: \'should match some schema in anyOf\' ';
  15633. }
  15634. if (it.opts.verbose) {
  15635. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15636. }
  15637. out += ' } ';
  15638. } else {
  15639. out += ' {} ';
  15640. }
  15641. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15642. if (!it.compositeRule && $breakOnError) {
  15643. /* istanbul ignore if */
  15644. if (it.async) {
  15645. out += ' throw new ValidationError(vErrors); ';
  15646. } else {
  15647. out += ' validate.errors = vErrors; return false; ';
  15648. }
  15649. }
  15650. out += ' } else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
  15651. if (it.opts.allErrors) {
  15652. out += ' } ';
  15653. }
  15654. out = it.util.cleanUpCode(out);
  15655. } else {
  15656. if ($breakOnError) {
  15657. out += ' if (true) { ';
  15658. }
  15659. }
  15660. return out;
  15661. };
  15662. },{}],22:[function(require,module,exports){
  15663. 'use strict';
  15664. module.exports = function generate_comment(it, $keyword, $ruleType) {
  15665. var out = ' ';
  15666. var $schema = it.schema[$keyword];
  15667. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15668. var $breakOnError = !it.opts.allErrors;
  15669. var $comment = it.util.toQuotedString($schema);
  15670. if (it.opts.$comment === true) {
  15671. out += ' console.log(' + $comment + ');';
  15672. } else if (typeof it.opts.$comment == 'function') {
  15673. out += ' self._opts.$comment(' + $comment + ', ' + it.util.toQuotedString($errSchemaPath) + ', validate.root.schema);';
  15674. }
  15675. return out;
  15676. };
  15677. },{}],23:[function(require,module,exports){
  15678. 'use strict';
  15679. module.exports = function generate_const(it, $keyword, $ruleType) {
  15680. var out = ' ';
  15681. var $lvl = it.level;
  15682. var $dataLvl = it.dataLevel;
  15683. var $schema = it.schema[$keyword];
  15684. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15685. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15686. var $breakOnError = !it.opts.allErrors;
  15687. var $data = 'data' + ($dataLvl || '');
  15688. var $valid = 'valid' + $lvl;
  15689. var $isData = it.opts.$data && $schema && $schema.$data,
  15690. $schemaValue;
  15691. if ($isData) {
  15692. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  15693. $schemaValue = 'schema' + $lvl;
  15694. } else {
  15695. $schemaValue = $schema;
  15696. }
  15697. if (!$isData) {
  15698. out += ' var schema' + $lvl + ' = validate.schema' + $schemaPath + ';';
  15699. }
  15700. out += 'var ' + $valid + ' = equal(' + $data + ', schema' + $lvl + '); if (!' + $valid + ') { ';
  15701. var $$outStack = $$outStack || [];
  15702. $$outStack.push(out);
  15703. out = ''; /* istanbul ignore else */
  15704. if (it.createErrors !== false) {
  15705. out += ' { keyword: \'' + 'const' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { allowedValue: schema' + $lvl + ' } ';
  15706. if (it.opts.messages !== false) {
  15707. out += ' , message: \'should be equal to constant\' ';
  15708. }
  15709. if (it.opts.verbose) {
  15710. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15711. }
  15712. out += ' } ';
  15713. } else {
  15714. out += ' {} ';
  15715. }
  15716. var __err = out;
  15717. out = $$outStack.pop();
  15718. if (!it.compositeRule && $breakOnError) {
  15719. /* istanbul ignore if */
  15720. if (it.async) {
  15721. out += ' throw new ValidationError([' + __err + ']); ';
  15722. } else {
  15723. out += ' validate.errors = [' + __err + ']; return false; ';
  15724. }
  15725. } else {
  15726. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15727. }
  15728. out += ' }';
  15729. if ($breakOnError) {
  15730. out += ' else { ';
  15731. }
  15732. return out;
  15733. };
  15734. },{}],24:[function(require,module,exports){
  15735. 'use strict';
  15736. module.exports = function generate_contains(it, $keyword, $ruleType) {
  15737. var out = ' ';
  15738. var $lvl = it.level;
  15739. var $dataLvl = it.dataLevel;
  15740. var $schema = it.schema[$keyword];
  15741. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15742. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15743. var $breakOnError = !it.opts.allErrors;
  15744. var $data = 'data' + ($dataLvl || '');
  15745. var $valid = 'valid' + $lvl;
  15746. var $errs = 'errs__' + $lvl;
  15747. var $it = it.util.copy(it);
  15748. var $closingBraces = '';
  15749. $it.level++;
  15750. var $nextValid = 'valid' + $it.level;
  15751. var $idx = 'i' + $lvl,
  15752. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  15753. $nextData = 'data' + $dataNxt,
  15754. $currentBaseId = it.baseId,
  15755. $nonEmptySchema = it.util.schemaHasRules($schema, it.RULES.all);
  15756. out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
  15757. if ($nonEmptySchema) {
  15758. var $wasComposite = it.compositeRule;
  15759. it.compositeRule = $it.compositeRule = true;
  15760. $it.schema = $schema;
  15761. $it.schemaPath = $schemaPath;
  15762. $it.errSchemaPath = $errSchemaPath;
  15763. out += ' var ' + $nextValid + ' = false; for (var ' + $idx + ' = 0; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
  15764. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  15765. var $passData = $data + '[' + $idx + ']';
  15766. $it.dataPathArr[$dataNxt] = $idx;
  15767. var $code = it.validate($it);
  15768. $it.baseId = $currentBaseId;
  15769. if (it.util.varOccurences($code, $nextData) < 2) {
  15770. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  15771. } else {
  15772. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  15773. }
  15774. out += ' if (' + $nextValid + ') break; } ';
  15775. it.compositeRule = $it.compositeRule = $wasComposite;
  15776. out += ' ' + $closingBraces + ' if (!' + $nextValid + ') {';
  15777. } else {
  15778. out += ' if (' + $data + '.length == 0) {';
  15779. }
  15780. var $$outStack = $$outStack || [];
  15781. $$outStack.push(out);
  15782. out = ''; /* istanbul ignore else */
  15783. if (it.createErrors !== false) {
  15784. out += ' { keyword: \'' + 'contains' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
  15785. if (it.opts.messages !== false) {
  15786. out += ' , message: \'should contain a valid item\' ';
  15787. }
  15788. if (it.opts.verbose) {
  15789. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15790. }
  15791. out += ' } ';
  15792. } else {
  15793. out += ' {} ';
  15794. }
  15795. var __err = out;
  15796. out = $$outStack.pop();
  15797. if (!it.compositeRule && $breakOnError) {
  15798. /* istanbul ignore if */
  15799. if (it.async) {
  15800. out += ' throw new ValidationError([' + __err + ']); ';
  15801. } else {
  15802. out += ' validate.errors = [' + __err + ']; return false; ';
  15803. }
  15804. } else {
  15805. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15806. }
  15807. out += ' } else { ';
  15808. if ($nonEmptySchema) {
  15809. out += ' errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
  15810. }
  15811. if (it.opts.allErrors) {
  15812. out += ' } ';
  15813. }
  15814. out = it.util.cleanUpCode(out);
  15815. return out;
  15816. };
  15817. },{}],25:[function(require,module,exports){
  15818. 'use strict';
  15819. module.exports = function generate_custom(it, $keyword, $ruleType) {
  15820. var out = ' ';
  15821. var $lvl = it.level;
  15822. var $dataLvl = it.dataLevel;
  15823. var $schema = it.schema[$keyword];
  15824. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  15825. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  15826. var $breakOnError = !it.opts.allErrors;
  15827. var $errorKeyword;
  15828. var $data = 'data' + ($dataLvl || '');
  15829. var $valid = 'valid' + $lvl;
  15830. var $errs = 'errs__' + $lvl;
  15831. var $isData = it.opts.$data && $schema && $schema.$data,
  15832. $schemaValue;
  15833. if ($isData) {
  15834. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  15835. $schemaValue = 'schema' + $lvl;
  15836. } else {
  15837. $schemaValue = $schema;
  15838. }
  15839. var $rule = this,
  15840. $definition = 'definition' + $lvl,
  15841. $rDef = $rule.definition,
  15842. $closingBraces = '';
  15843. var $compile, $inline, $macro, $ruleValidate, $validateCode;
  15844. if ($isData && $rDef.$data) {
  15845. $validateCode = 'keywordValidate' + $lvl;
  15846. var $validateSchema = $rDef.validateSchema;
  15847. out += ' var ' + $definition + ' = RULES.custom[\'' + $keyword + '\'].definition; var ' + $validateCode + ' = ' + $definition + '.validate;';
  15848. } else {
  15849. $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
  15850. if (!$ruleValidate) return;
  15851. $schemaValue = 'validate.schema' + $schemaPath;
  15852. $validateCode = $ruleValidate.code;
  15853. $compile = $rDef.compile;
  15854. $inline = $rDef.inline;
  15855. $macro = $rDef.macro;
  15856. }
  15857. var $ruleErrs = $validateCode + '.errors',
  15858. $i = 'i' + $lvl,
  15859. $ruleErr = 'ruleErr' + $lvl,
  15860. $asyncKeyword = $rDef.async;
  15861. if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
  15862. if (!($inline || $macro)) {
  15863. out += '' + $ruleErrs + ' = null;';
  15864. }
  15865. out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
  15866. if ($isData && $rDef.$data) {
  15867. $closingBraces += '}';
  15868. out += ' if (' + $schemaValue + ' === undefined) { ' + $valid + ' = true; } else { ';
  15869. if ($validateSchema) {
  15870. $closingBraces += '}';
  15871. out += ' ' + $valid + ' = ' + $definition + '.validateSchema(' + $schemaValue + '); if (' + $valid + ') { ';
  15872. }
  15873. }
  15874. if ($inline) {
  15875. if ($rDef.statements) {
  15876. out += ' ' + $ruleValidate.validate + ' ';
  15877. } else {
  15878. out += ' ' + $valid + ' = ' + $ruleValidate.validate + '; ';
  15879. }
  15880. } else if ($macro) {
  15881. var $it = it.util.copy(it);
  15882. var $closingBraces = '';
  15883. $it.level++;
  15884. var $nextValid = 'valid' + $it.level;
  15885. $it.schema = $ruleValidate.validate;
  15886. $it.schemaPath = '';
  15887. var $wasComposite = it.compositeRule;
  15888. it.compositeRule = $it.compositeRule = true;
  15889. var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
  15890. it.compositeRule = $it.compositeRule = $wasComposite;
  15891. out += ' ' + $code;
  15892. } else {
  15893. var $$outStack = $$outStack || [];
  15894. $$outStack.push(out);
  15895. out = '';
  15896. out += ' ' + $validateCode + '.call( ';
  15897. if (it.opts.passContext) {
  15898. out += 'this';
  15899. } else {
  15900. out += 'self';
  15901. }
  15902. if ($compile || $rDef.schema === false) {
  15903. out += ' , ' + $data + ' ';
  15904. } else {
  15905. out += ' , ' + $schemaValue + ' , ' + $data + ' , validate.schema' + it.schemaPath + ' ';
  15906. }
  15907. out += ' , (dataPath || \'\')';
  15908. if (it.errorPath != '""') {
  15909. out += ' + ' + it.errorPath;
  15910. }
  15911. var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
  15912. $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
  15913. out += ' , ' + $parentData + ' , ' + $parentDataProperty + ' , rootData ) ';
  15914. var def_callRuleValidate = out;
  15915. out = $$outStack.pop();
  15916. if ($rDef.errors === false) {
  15917. out += ' ' + $valid + ' = ';
  15918. if ($asyncKeyword) {
  15919. out += 'await ';
  15920. }
  15921. out += '' + def_callRuleValidate + '; ';
  15922. } else {
  15923. if ($asyncKeyword) {
  15924. $ruleErrs = 'customErrors' + $lvl;
  15925. out += ' var ' + $ruleErrs + ' = null; try { ' + $valid + ' = await ' + def_callRuleValidate + '; } catch (e) { ' + $valid + ' = false; if (e instanceof ValidationError) ' + $ruleErrs + ' = e.errors; else throw e; } ';
  15926. } else {
  15927. out += ' ' + $ruleErrs + ' = null; ' + $valid + ' = ' + def_callRuleValidate + '; ';
  15928. }
  15929. }
  15930. }
  15931. if ($rDef.modifying) {
  15932. out += ' if (' + $parentData + ') ' + $data + ' = ' + $parentData + '[' + $parentDataProperty + '];';
  15933. }
  15934. out += '' + $closingBraces;
  15935. if ($rDef.valid) {
  15936. if ($breakOnError) {
  15937. out += ' if (true) { ';
  15938. }
  15939. } else {
  15940. out += ' if ( ';
  15941. if ($rDef.valid === undefined) {
  15942. out += ' !';
  15943. if ($macro) {
  15944. out += '' + $nextValid;
  15945. } else {
  15946. out += '' + $valid;
  15947. }
  15948. } else {
  15949. out += ' ' + !$rDef.valid + ' ';
  15950. }
  15951. out += ') { ';
  15952. $errorKeyword = $rule.keyword;
  15953. var $$outStack = $$outStack || [];
  15954. $$outStack.push(out);
  15955. out = '';
  15956. var $$outStack = $$outStack || [];
  15957. $$outStack.push(out);
  15958. out = ''; /* istanbul ignore else */
  15959. if (it.createErrors !== false) {
  15960. out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { keyword: \'' + $rule.keyword + '\' } ';
  15961. if (it.opts.messages !== false) {
  15962. out += ' , message: \'should pass "' + $rule.keyword + '" keyword validation\' ';
  15963. }
  15964. if (it.opts.verbose) {
  15965. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  15966. }
  15967. out += ' } ';
  15968. } else {
  15969. out += ' {} ';
  15970. }
  15971. var __err = out;
  15972. out = $$outStack.pop();
  15973. if (!it.compositeRule && $breakOnError) {
  15974. /* istanbul ignore if */
  15975. if (it.async) {
  15976. out += ' throw new ValidationError([' + __err + ']); ';
  15977. } else {
  15978. out += ' validate.errors = [' + __err + ']; return false; ';
  15979. }
  15980. } else {
  15981. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  15982. }
  15983. var def_customError = out;
  15984. out = $$outStack.pop();
  15985. if ($inline) {
  15986. if ($rDef.errors) {
  15987. if ($rDef.errors != 'full') {
  15988. out += ' for (var ' + $i + '=' + $errs + '; ' + $i + '<errors; ' + $i + '++) { var ' + $ruleErr + ' = vErrors[' + $i + ']; if (' + $ruleErr + '.dataPath === undefined) ' + $ruleErr + '.dataPath = (dataPath || \'\') + ' + it.errorPath + '; if (' + $ruleErr + '.schemaPath === undefined) { ' + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; } ';
  15989. if (it.opts.verbose) {
  15990. out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
  15991. }
  15992. out += ' } ';
  15993. }
  15994. } else {
  15995. if ($rDef.errors === false) {
  15996. out += ' ' + def_customError + ' ';
  15997. } else {
  15998. out += ' if (' + $errs + ' == errors) { ' + def_customError + ' } else { for (var ' + $i + '=' + $errs + '; ' + $i + '<errors; ' + $i + '++) { var ' + $ruleErr + ' = vErrors[' + $i + ']; if (' + $ruleErr + '.dataPath === undefined) ' + $ruleErr + '.dataPath = (dataPath || \'\') + ' + it.errorPath + '; if (' + $ruleErr + '.schemaPath === undefined) { ' + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; } ';
  15999. if (it.opts.verbose) {
  16000. out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
  16001. }
  16002. out += ' } } ';
  16003. }
  16004. }
  16005. } else if ($macro) {
  16006. out += ' var err = '; /* istanbul ignore else */
  16007. if (it.createErrors !== false) {
  16008. out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { keyword: \'' + $rule.keyword + '\' } ';
  16009. if (it.opts.messages !== false) {
  16010. out += ' , message: \'should pass "' + $rule.keyword + '" keyword validation\' ';
  16011. }
  16012. if (it.opts.verbose) {
  16013. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16014. }
  16015. out += ' } ';
  16016. } else {
  16017. out += ' {} ';
  16018. }
  16019. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16020. if (!it.compositeRule && $breakOnError) {
  16021. /* istanbul ignore if */
  16022. if (it.async) {
  16023. out += ' throw new ValidationError(vErrors); ';
  16024. } else {
  16025. out += ' validate.errors = vErrors; return false; ';
  16026. }
  16027. }
  16028. } else {
  16029. if ($rDef.errors === false) {
  16030. out += ' ' + def_customError + ' ';
  16031. } else {
  16032. out += ' if (Array.isArray(' + $ruleErrs + ')) { if (vErrors === null) vErrors = ' + $ruleErrs + '; else vErrors = vErrors.concat(' + $ruleErrs + '); errors = vErrors.length; for (var ' + $i + '=' + $errs + '; ' + $i + '<errors; ' + $i + '++) { var ' + $ruleErr + ' = vErrors[' + $i + ']; if (' + $ruleErr + '.dataPath === undefined) ' + $ruleErr + '.dataPath = (dataPath || \'\') + ' + it.errorPath + '; ' + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; ';
  16033. if (it.opts.verbose) {
  16034. out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
  16035. }
  16036. out += ' } } else { ' + def_customError + ' } ';
  16037. }
  16038. }
  16039. out += ' } ';
  16040. if ($breakOnError) {
  16041. out += ' else { ';
  16042. }
  16043. }
  16044. return out;
  16045. };
  16046. },{}],26:[function(require,module,exports){
  16047. 'use strict';
  16048. module.exports = function generate_dependencies(it, $keyword, $ruleType) {
  16049. var out = ' ';
  16050. var $lvl = it.level;
  16051. var $dataLvl = it.dataLevel;
  16052. var $schema = it.schema[$keyword];
  16053. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16054. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16055. var $breakOnError = !it.opts.allErrors;
  16056. var $data = 'data' + ($dataLvl || '');
  16057. var $errs = 'errs__' + $lvl;
  16058. var $it = it.util.copy(it);
  16059. var $closingBraces = '';
  16060. $it.level++;
  16061. var $nextValid = 'valid' + $it.level;
  16062. var $schemaDeps = {},
  16063. $propertyDeps = {},
  16064. $ownProperties = it.opts.ownProperties;
  16065. for ($property in $schema) {
  16066. var $sch = $schema[$property];
  16067. var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
  16068. $deps[$property] = $sch;
  16069. }
  16070. out += 'var ' + $errs + ' = errors;';
  16071. var $currentErrorPath = it.errorPath;
  16072. out += 'var missing' + $lvl + ';';
  16073. for (var $property in $propertyDeps) {
  16074. $deps = $propertyDeps[$property];
  16075. if ($deps.length) {
  16076. out += ' if ( ' + $data + it.util.getProperty($property) + ' !== undefined ';
  16077. if ($ownProperties) {
  16078. out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($property) + '\') ';
  16079. }
  16080. if ($breakOnError) {
  16081. out += ' && ( ';
  16082. var arr1 = $deps;
  16083. if (arr1) {
  16084. var $propertyKey,
  16085. $i = -1,
  16086. l1 = arr1.length - 1;
  16087. while ($i < l1) {
  16088. $propertyKey = arr1[$i += 1];
  16089. if ($i) {
  16090. out += ' || ';
  16091. }
  16092. var $prop = it.util.getProperty($propertyKey),
  16093. $useData = $data + $prop;
  16094. out += ' ( ( ' + $useData + ' === undefined ';
  16095. if ($ownProperties) {
  16096. out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
  16097. }
  16098. out += ') && (missing' + $lvl + ' = ' + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ') ) ';
  16099. }
  16100. }
  16101. out += ')) { ';
  16102. var $propertyPath = 'missing' + $lvl,
  16103. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  16104. if (it.opts._errorDataPathProperty) {
  16105. it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
  16106. }
  16107. var $$outStack = $$outStack || [];
  16108. $$outStack.push(out);
  16109. out = ''; /* istanbul ignore else */
  16110. if (it.createErrors !== false) {
  16111. out += ' { keyword: \'' + 'dependencies' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { property: \'' + it.util.escapeQuotes($property) + '\', missingProperty: \'' + $missingProperty + '\', depsCount: ' + $deps.length + ', deps: \'' + it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", ")) + '\' } ';
  16112. if (it.opts.messages !== false) {
  16113. out += ' , message: \'should have ';
  16114. if ($deps.length == 1) {
  16115. out += 'property ' + it.util.escapeQuotes($deps[0]);
  16116. } else {
  16117. out += 'properties ' + it.util.escapeQuotes($deps.join(", "));
  16118. }
  16119. out += ' when property ' + it.util.escapeQuotes($property) + ' is present\' ';
  16120. }
  16121. if (it.opts.verbose) {
  16122. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16123. }
  16124. out += ' } ';
  16125. } else {
  16126. out += ' {} ';
  16127. }
  16128. var __err = out;
  16129. out = $$outStack.pop();
  16130. if (!it.compositeRule && $breakOnError) {
  16131. /* istanbul ignore if */
  16132. if (it.async) {
  16133. out += ' throw new ValidationError([' + __err + ']); ';
  16134. } else {
  16135. out += ' validate.errors = [' + __err + ']; return false; ';
  16136. }
  16137. } else {
  16138. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16139. }
  16140. } else {
  16141. out += ' ) { ';
  16142. var arr2 = $deps;
  16143. if (arr2) {
  16144. var $propertyKey,
  16145. i2 = -1,
  16146. l2 = arr2.length - 1;
  16147. while (i2 < l2) {
  16148. $propertyKey = arr2[i2 += 1];
  16149. var $prop = it.util.getProperty($propertyKey),
  16150. $missingProperty = it.util.escapeQuotes($propertyKey),
  16151. $useData = $data + $prop;
  16152. if (it.opts._errorDataPathProperty) {
  16153. it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
  16154. }
  16155. out += ' if ( ' + $useData + ' === undefined ';
  16156. if ($ownProperties) {
  16157. out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
  16158. }
  16159. out += ') { var err = '; /* istanbul ignore else */
  16160. if (it.createErrors !== false) {
  16161. out += ' { keyword: \'' + 'dependencies' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { property: \'' + it.util.escapeQuotes($property) + '\', missingProperty: \'' + $missingProperty + '\', depsCount: ' + $deps.length + ', deps: \'' + it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", ")) + '\' } ';
  16162. if (it.opts.messages !== false) {
  16163. out += ' , message: \'should have ';
  16164. if ($deps.length == 1) {
  16165. out += 'property ' + it.util.escapeQuotes($deps[0]);
  16166. } else {
  16167. out += 'properties ' + it.util.escapeQuotes($deps.join(", "));
  16168. }
  16169. out += ' when property ' + it.util.escapeQuotes($property) + ' is present\' ';
  16170. }
  16171. if (it.opts.verbose) {
  16172. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16173. }
  16174. out += ' } ';
  16175. } else {
  16176. out += ' {} ';
  16177. }
  16178. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
  16179. }
  16180. }
  16181. }
  16182. out += ' } ';
  16183. if ($breakOnError) {
  16184. $closingBraces += '}';
  16185. out += ' else { ';
  16186. }
  16187. }
  16188. }
  16189. it.errorPath = $currentErrorPath;
  16190. var $currentBaseId = $it.baseId;
  16191. for (var $property in $schemaDeps) {
  16192. var $sch = $schemaDeps[$property];
  16193. if (it.util.schemaHasRules($sch, it.RULES.all)) {
  16194. out += ' ' + $nextValid + ' = true; if ( ' + $data + it.util.getProperty($property) + ' !== undefined ';
  16195. if ($ownProperties) {
  16196. out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($property) + '\') ';
  16197. }
  16198. out += ') { ';
  16199. $it.schema = $sch;
  16200. $it.schemaPath = $schemaPath + it.util.getProperty($property);
  16201. $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
  16202. out += ' ' + it.validate($it) + ' ';
  16203. $it.baseId = $currentBaseId;
  16204. out += ' } ';
  16205. if ($breakOnError) {
  16206. out += ' if (' + $nextValid + ') { ';
  16207. $closingBraces += '}';
  16208. }
  16209. }
  16210. }
  16211. if ($breakOnError) {
  16212. out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
  16213. }
  16214. out = it.util.cleanUpCode(out);
  16215. return out;
  16216. };
  16217. },{}],27:[function(require,module,exports){
  16218. 'use strict';
  16219. module.exports = function generate_enum(it, $keyword, $ruleType) {
  16220. var out = ' ';
  16221. var $lvl = it.level;
  16222. var $dataLvl = it.dataLevel;
  16223. var $schema = it.schema[$keyword];
  16224. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16225. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16226. var $breakOnError = !it.opts.allErrors;
  16227. var $data = 'data' + ($dataLvl || '');
  16228. var $valid = 'valid' + $lvl;
  16229. var $isData = it.opts.$data && $schema && $schema.$data,
  16230. $schemaValue;
  16231. if ($isData) {
  16232. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  16233. $schemaValue = 'schema' + $lvl;
  16234. } else {
  16235. $schemaValue = $schema;
  16236. }
  16237. var $i = 'i' + $lvl,
  16238. $vSchema = 'schema' + $lvl;
  16239. if (!$isData) {
  16240. out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + ';';
  16241. }
  16242. out += 'var ' + $valid + ';';
  16243. if ($isData) {
  16244. out += ' if (schema' + $lvl + ' === undefined) ' + $valid + ' = true; else if (!Array.isArray(schema' + $lvl + ')) ' + $valid + ' = false; else {';
  16245. }
  16246. out += '' + $valid + ' = false;for (var ' + $i + '=0; ' + $i + '<' + $vSchema + '.length; ' + $i + '++) if (equal(' + $data + ', ' + $vSchema + '[' + $i + '])) { ' + $valid + ' = true; break; }';
  16247. if ($isData) {
  16248. out += ' } ';
  16249. }
  16250. out += ' if (!' + $valid + ') { ';
  16251. var $$outStack = $$outStack || [];
  16252. $$outStack.push(out);
  16253. out = ''; /* istanbul ignore else */
  16254. if (it.createErrors !== false) {
  16255. out += ' { keyword: \'' + 'enum' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { allowedValues: schema' + $lvl + ' } ';
  16256. if (it.opts.messages !== false) {
  16257. out += ' , message: \'should be equal to one of the allowed values\' ';
  16258. }
  16259. if (it.opts.verbose) {
  16260. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16261. }
  16262. out += ' } ';
  16263. } else {
  16264. out += ' {} ';
  16265. }
  16266. var __err = out;
  16267. out = $$outStack.pop();
  16268. if (!it.compositeRule && $breakOnError) {
  16269. /* istanbul ignore if */
  16270. if (it.async) {
  16271. out += ' throw new ValidationError([' + __err + ']); ';
  16272. } else {
  16273. out += ' validate.errors = [' + __err + ']; return false; ';
  16274. }
  16275. } else {
  16276. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16277. }
  16278. out += ' }';
  16279. if ($breakOnError) {
  16280. out += ' else { ';
  16281. }
  16282. return out;
  16283. };
  16284. },{}],28:[function(require,module,exports){
  16285. 'use strict';
  16286. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  16287. module.exports = function generate_format(it, $keyword, $ruleType) {
  16288. var out = ' ';
  16289. var $lvl = it.level;
  16290. var $dataLvl = it.dataLevel;
  16291. var $schema = it.schema[$keyword];
  16292. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16293. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16294. var $breakOnError = !it.opts.allErrors;
  16295. var $data = 'data' + ($dataLvl || '');
  16296. if (it.opts.format === false) {
  16297. if ($breakOnError) {
  16298. out += ' if (true) { ';
  16299. }
  16300. return out;
  16301. }
  16302. var $isData = it.opts.$data && $schema && $schema.$data,
  16303. $schemaValue;
  16304. if ($isData) {
  16305. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  16306. $schemaValue = 'schema' + $lvl;
  16307. } else {
  16308. $schemaValue = $schema;
  16309. }
  16310. var $unknownFormats = it.opts.unknownFormats,
  16311. $allowUnknown = Array.isArray($unknownFormats);
  16312. if ($isData) {
  16313. var $format = 'format' + $lvl,
  16314. $isObject = 'isObject' + $lvl,
  16315. $formatType = 'formatType' + $lvl;
  16316. out += ' var ' + $format + ' = formats[' + $schemaValue + ']; var ' + $isObject + ' = typeof ' + $format + ' == \'object\' && !(' + $format + ' instanceof RegExp) && ' + $format + '.validate; var ' + $formatType + ' = ' + $isObject + ' && ' + $format + '.type || \'string\'; if (' + $isObject + ') { ';
  16317. if (it.async) {
  16318. out += ' var async' + $lvl + ' = ' + $format + '.async; ';
  16319. }
  16320. out += ' ' + $format + ' = ' + $format + '.validate; } if ( ';
  16321. if ($isData) {
  16322. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'string\') || ';
  16323. }
  16324. out += ' (';
  16325. if ($unknownFormats != 'ignore') {
  16326. out += ' (' + $schemaValue + ' && !' + $format + ' ';
  16327. if ($allowUnknown) {
  16328. out += ' && self._opts.unknownFormats.indexOf(' + $schemaValue + ') == -1 ';
  16329. }
  16330. out += ') || ';
  16331. }
  16332. out += ' (' + $format + ' && ' + $formatType + ' == \'' + $ruleType + '\' && !(typeof ' + $format + ' == \'function\' ? ';
  16333. if (it.async) {
  16334. out += ' (async' + $lvl + ' ? await ' + $format + '(' + $data + ') : ' + $format + '(' + $data + ')) ';
  16335. } else {
  16336. out += ' ' + $format + '(' + $data + ') ';
  16337. }
  16338. out += ' : ' + $format + '.test(' + $data + '))))) {';
  16339. } else {
  16340. var $format = it.formats[$schema];
  16341. if (!$format) {
  16342. if ($unknownFormats == 'ignore') {
  16343. it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
  16344. if ($breakOnError) {
  16345. out += ' if (true) { ';
  16346. }
  16347. return out;
  16348. } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
  16349. if ($breakOnError) {
  16350. out += ' if (true) { ';
  16351. }
  16352. return out;
  16353. } else {
  16354. throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
  16355. }
  16356. }
  16357. var $isObject = (typeof $format === 'undefined' ? 'undefined' : _typeof($format)) == 'object' && !($format instanceof RegExp) && $format.validate;
  16358. var $formatType = $isObject && $format.type || 'string';
  16359. if ($isObject) {
  16360. var $async = $format.async === true;
  16361. $format = $format.validate;
  16362. }
  16363. if ($formatType != $ruleType) {
  16364. if ($breakOnError) {
  16365. out += ' if (true) { ';
  16366. }
  16367. return out;
  16368. }
  16369. if ($async) {
  16370. if (!it.async) throw new Error('async format in sync schema');
  16371. var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
  16372. out += ' if (!(await ' + $formatRef + '(' + $data + '))) { ';
  16373. } else {
  16374. out += ' if (! ';
  16375. var $formatRef = 'formats' + it.util.getProperty($schema);
  16376. if ($isObject) $formatRef += '.validate';
  16377. if (typeof $format == 'function') {
  16378. out += ' ' + $formatRef + '(' + $data + ') ';
  16379. } else {
  16380. out += ' ' + $formatRef + '.test(' + $data + ') ';
  16381. }
  16382. out += ') { ';
  16383. }
  16384. }
  16385. var $$outStack = $$outStack || [];
  16386. $$outStack.push(out);
  16387. out = ''; /* istanbul ignore else */
  16388. if (it.createErrors !== false) {
  16389. out += ' { keyword: \'' + 'format' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { format: ';
  16390. if ($isData) {
  16391. out += '' + $schemaValue;
  16392. } else {
  16393. out += '' + it.util.toQuotedString($schema);
  16394. }
  16395. out += ' } ';
  16396. if (it.opts.messages !== false) {
  16397. out += ' , message: \'should match format "';
  16398. if ($isData) {
  16399. out += '\' + ' + $schemaValue + ' + \'';
  16400. } else {
  16401. out += '' + it.util.escapeQuotes($schema);
  16402. }
  16403. out += '"\' ';
  16404. }
  16405. if (it.opts.verbose) {
  16406. out += ' , schema: ';
  16407. if ($isData) {
  16408. out += 'validate.schema' + $schemaPath;
  16409. } else {
  16410. out += '' + it.util.toQuotedString($schema);
  16411. }
  16412. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16413. }
  16414. out += ' } ';
  16415. } else {
  16416. out += ' {} ';
  16417. }
  16418. var __err = out;
  16419. out = $$outStack.pop();
  16420. if (!it.compositeRule && $breakOnError) {
  16421. /* istanbul ignore if */
  16422. if (it.async) {
  16423. out += ' throw new ValidationError([' + __err + ']); ';
  16424. } else {
  16425. out += ' validate.errors = [' + __err + ']; return false; ';
  16426. }
  16427. } else {
  16428. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16429. }
  16430. out += ' } ';
  16431. if ($breakOnError) {
  16432. out += ' else { ';
  16433. }
  16434. return out;
  16435. };
  16436. },{}],29:[function(require,module,exports){
  16437. 'use strict';
  16438. module.exports = function generate_if(it, $keyword, $ruleType) {
  16439. var out = ' ';
  16440. var $lvl = it.level;
  16441. var $dataLvl = it.dataLevel;
  16442. var $schema = it.schema[$keyword];
  16443. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16444. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16445. var $breakOnError = !it.opts.allErrors;
  16446. var $data = 'data' + ($dataLvl || '');
  16447. var $valid = 'valid' + $lvl;
  16448. var $errs = 'errs__' + $lvl;
  16449. var $it = it.util.copy(it);
  16450. $it.level++;
  16451. var $nextValid = 'valid' + $it.level;
  16452. var $thenSch = it.schema['then'],
  16453. $elseSch = it.schema['else'],
  16454. $thenPresent = $thenSch !== undefined && it.util.schemaHasRules($thenSch, it.RULES.all),
  16455. $elsePresent = $elseSch !== undefined && it.util.schemaHasRules($elseSch, it.RULES.all),
  16456. $currentBaseId = $it.baseId;
  16457. if ($thenPresent || $elsePresent) {
  16458. var $ifClause;
  16459. $it.createErrors = false;
  16460. $it.schema = $schema;
  16461. $it.schemaPath = $schemaPath;
  16462. $it.errSchemaPath = $errSchemaPath;
  16463. out += ' var ' + $errs + ' = errors; var ' + $valid + ' = true; ';
  16464. var $wasComposite = it.compositeRule;
  16465. it.compositeRule = $it.compositeRule = true;
  16466. out += ' ' + it.validate($it) + ' ';
  16467. $it.baseId = $currentBaseId;
  16468. $it.createErrors = true;
  16469. out += ' errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
  16470. it.compositeRule = $it.compositeRule = $wasComposite;
  16471. if ($thenPresent) {
  16472. out += ' if (' + $nextValid + ') { ';
  16473. $it.schema = it.schema['then'];
  16474. $it.schemaPath = it.schemaPath + '.then';
  16475. $it.errSchemaPath = it.errSchemaPath + '/then';
  16476. out += ' ' + it.validate($it) + ' ';
  16477. $it.baseId = $currentBaseId;
  16478. out += ' ' + $valid + ' = ' + $nextValid + '; ';
  16479. if ($thenPresent && $elsePresent) {
  16480. $ifClause = 'ifClause' + $lvl;
  16481. out += ' var ' + $ifClause + ' = \'then\'; ';
  16482. } else {
  16483. $ifClause = '\'then\'';
  16484. }
  16485. out += ' } ';
  16486. if ($elsePresent) {
  16487. out += ' else { ';
  16488. }
  16489. } else {
  16490. out += ' if (!' + $nextValid + ') { ';
  16491. }
  16492. if ($elsePresent) {
  16493. $it.schema = it.schema['else'];
  16494. $it.schemaPath = it.schemaPath + '.else';
  16495. $it.errSchemaPath = it.errSchemaPath + '/else';
  16496. out += ' ' + it.validate($it) + ' ';
  16497. $it.baseId = $currentBaseId;
  16498. out += ' ' + $valid + ' = ' + $nextValid + '; ';
  16499. if ($thenPresent && $elsePresent) {
  16500. $ifClause = 'ifClause' + $lvl;
  16501. out += ' var ' + $ifClause + ' = \'else\'; ';
  16502. } else {
  16503. $ifClause = '\'else\'';
  16504. }
  16505. out += ' } ';
  16506. }
  16507. out += ' if (!' + $valid + ') { var err = '; /* istanbul ignore else */
  16508. if (it.createErrors !== false) {
  16509. out += ' { keyword: \'' + 'if' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { failingKeyword: ' + $ifClause + ' } ';
  16510. if (it.opts.messages !== false) {
  16511. out += ' , message: \'should match "\' + ' + $ifClause + ' + \'" schema\' ';
  16512. }
  16513. if (it.opts.verbose) {
  16514. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16515. }
  16516. out += ' } ';
  16517. } else {
  16518. out += ' {} ';
  16519. }
  16520. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16521. if (!it.compositeRule && $breakOnError) {
  16522. /* istanbul ignore if */
  16523. if (it.async) {
  16524. out += ' throw new ValidationError(vErrors); ';
  16525. } else {
  16526. out += ' validate.errors = vErrors; return false; ';
  16527. }
  16528. }
  16529. out += ' } ';
  16530. if ($breakOnError) {
  16531. out += ' else { ';
  16532. }
  16533. out = it.util.cleanUpCode(out);
  16534. } else {
  16535. if ($breakOnError) {
  16536. out += ' if (true) { ';
  16537. }
  16538. }
  16539. return out;
  16540. };
  16541. },{}],30:[function(require,module,exports){
  16542. 'use strict';
  16543. //all requires must be explicit because browserify won't work with dynamic requires
  16544. module.exports = {
  16545. '$ref': require('./ref'),
  16546. allOf: require('./allOf'),
  16547. anyOf: require('./anyOf'),
  16548. '$comment': require('./comment'),
  16549. const: require('./const'),
  16550. contains: require('./contains'),
  16551. dependencies: require('./dependencies'),
  16552. 'enum': require('./enum'),
  16553. format: require('./format'),
  16554. 'if': require('./if'),
  16555. items: require('./items'),
  16556. maximum: require('./_limit'),
  16557. minimum: require('./_limit'),
  16558. maxItems: require('./_limitItems'),
  16559. minItems: require('./_limitItems'),
  16560. maxLength: require('./_limitLength'),
  16561. minLength: require('./_limitLength'),
  16562. maxProperties: require('./_limitProperties'),
  16563. minProperties: require('./_limitProperties'),
  16564. multipleOf: require('./multipleOf'),
  16565. not: require('./not'),
  16566. oneOf: require('./oneOf'),
  16567. pattern: require('./pattern'),
  16568. properties: require('./properties'),
  16569. propertyNames: require('./propertyNames'),
  16570. required: require('./required'),
  16571. uniqueItems: require('./uniqueItems'),
  16572. validate: require('./validate')
  16573. };
  16574. },{"./_limit":16,"./_limitItems":17,"./_limitLength":18,"./_limitProperties":19,"./allOf":20,"./anyOf":21,"./comment":22,"./const":23,"./contains":24,"./dependencies":26,"./enum":27,"./format":28,"./if":29,"./items":31,"./multipleOf":32,"./not":33,"./oneOf":34,"./pattern":35,"./properties":36,"./propertyNames":37,"./ref":38,"./required":39,"./uniqueItems":40,"./validate":41}],31:[function(require,module,exports){
  16575. 'use strict';
  16576. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  16577. module.exports = function generate_items(it, $keyword, $ruleType) {
  16578. var out = ' ';
  16579. var $lvl = it.level;
  16580. var $dataLvl = it.dataLevel;
  16581. var $schema = it.schema[$keyword];
  16582. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16583. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16584. var $breakOnError = !it.opts.allErrors;
  16585. var $data = 'data' + ($dataLvl || '');
  16586. var $valid = 'valid' + $lvl;
  16587. var $errs = 'errs__' + $lvl;
  16588. var $it = it.util.copy(it);
  16589. var $closingBraces = '';
  16590. $it.level++;
  16591. var $nextValid = 'valid' + $it.level;
  16592. var $idx = 'i' + $lvl,
  16593. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  16594. $nextData = 'data' + $dataNxt,
  16595. $currentBaseId = it.baseId;
  16596. out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
  16597. if (Array.isArray($schema)) {
  16598. var $additionalItems = it.schema.additionalItems;
  16599. if ($additionalItems === false) {
  16600. out += ' ' + $valid + ' = ' + $data + '.length <= ' + $schema.length + '; ';
  16601. var $currErrSchemaPath = $errSchemaPath;
  16602. $errSchemaPath = it.errSchemaPath + '/additionalItems';
  16603. out += ' if (!' + $valid + ') { ';
  16604. var $$outStack = $$outStack || [];
  16605. $$outStack.push(out);
  16606. out = ''; /* istanbul ignore else */
  16607. if (it.createErrors !== false) {
  16608. out += ' { keyword: \'' + 'additionalItems' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schema.length + ' } ';
  16609. if (it.opts.messages !== false) {
  16610. out += ' , message: \'should NOT have more than ' + $schema.length + ' items\' ';
  16611. }
  16612. if (it.opts.verbose) {
  16613. out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16614. }
  16615. out += ' } ';
  16616. } else {
  16617. out += ' {} ';
  16618. }
  16619. var __err = out;
  16620. out = $$outStack.pop();
  16621. if (!it.compositeRule && $breakOnError) {
  16622. /* istanbul ignore if */
  16623. if (it.async) {
  16624. out += ' throw new ValidationError([' + __err + ']); ';
  16625. } else {
  16626. out += ' validate.errors = [' + __err + ']; return false; ';
  16627. }
  16628. } else {
  16629. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16630. }
  16631. out += ' } ';
  16632. $errSchemaPath = $currErrSchemaPath;
  16633. if ($breakOnError) {
  16634. $closingBraces += '}';
  16635. out += ' else { ';
  16636. }
  16637. }
  16638. var arr1 = $schema;
  16639. if (arr1) {
  16640. var $sch,
  16641. $i = -1,
  16642. l1 = arr1.length - 1;
  16643. while ($i < l1) {
  16644. $sch = arr1[$i += 1];
  16645. if (it.util.schemaHasRules($sch, it.RULES.all)) {
  16646. out += ' ' + $nextValid + ' = true; if (' + $data + '.length > ' + $i + ') { ';
  16647. var $passData = $data + '[' + $i + ']';
  16648. $it.schema = $sch;
  16649. $it.schemaPath = $schemaPath + '[' + $i + ']';
  16650. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  16651. $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
  16652. $it.dataPathArr[$dataNxt] = $i;
  16653. var $code = it.validate($it);
  16654. $it.baseId = $currentBaseId;
  16655. if (it.util.varOccurences($code, $nextData) < 2) {
  16656. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  16657. } else {
  16658. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  16659. }
  16660. out += ' } ';
  16661. if ($breakOnError) {
  16662. out += ' if (' + $nextValid + ') { ';
  16663. $closingBraces += '}';
  16664. }
  16665. }
  16666. }
  16667. }
  16668. if ((typeof $additionalItems === 'undefined' ? 'undefined' : _typeof($additionalItems)) == 'object' && it.util.schemaHasRules($additionalItems, it.RULES.all)) {
  16669. $it.schema = $additionalItems;
  16670. $it.schemaPath = it.schemaPath + '.additionalItems';
  16671. $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
  16672. out += ' ' + $nextValid + ' = true; if (' + $data + '.length > ' + $schema.length + ') { for (var ' + $idx + ' = ' + $schema.length + '; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
  16673. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  16674. var $passData = $data + '[' + $idx + ']';
  16675. $it.dataPathArr[$dataNxt] = $idx;
  16676. var $code = it.validate($it);
  16677. $it.baseId = $currentBaseId;
  16678. if (it.util.varOccurences($code, $nextData) < 2) {
  16679. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  16680. } else {
  16681. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  16682. }
  16683. if ($breakOnError) {
  16684. out += ' if (!' + $nextValid + ') break; ';
  16685. }
  16686. out += ' } } ';
  16687. if ($breakOnError) {
  16688. out += ' if (' + $nextValid + ') { ';
  16689. $closingBraces += '}';
  16690. }
  16691. }
  16692. } else if (it.util.schemaHasRules($schema, it.RULES.all)) {
  16693. $it.schema = $schema;
  16694. $it.schemaPath = $schemaPath;
  16695. $it.errSchemaPath = $errSchemaPath;
  16696. out += ' for (var ' + $idx + ' = ' + 0 + '; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
  16697. $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
  16698. var $passData = $data + '[' + $idx + ']';
  16699. $it.dataPathArr[$dataNxt] = $idx;
  16700. var $code = it.validate($it);
  16701. $it.baseId = $currentBaseId;
  16702. if (it.util.varOccurences($code, $nextData) < 2) {
  16703. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  16704. } else {
  16705. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  16706. }
  16707. if ($breakOnError) {
  16708. out += ' if (!' + $nextValid + ') break; ';
  16709. }
  16710. out += ' }';
  16711. }
  16712. if ($breakOnError) {
  16713. out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
  16714. }
  16715. out = it.util.cleanUpCode(out);
  16716. return out;
  16717. };
  16718. },{}],32:[function(require,module,exports){
  16719. 'use strict';
  16720. module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
  16721. var out = ' ';
  16722. var $lvl = it.level;
  16723. var $dataLvl = it.dataLevel;
  16724. var $schema = it.schema[$keyword];
  16725. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16726. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16727. var $breakOnError = !it.opts.allErrors;
  16728. var $data = 'data' + ($dataLvl || '');
  16729. var $isData = it.opts.$data && $schema && $schema.$data,
  16730. $schemaValue;
  16731. if ($isData) {
  16732. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  16733. $schemaValue = 'schema' + $lvl;
  16734. } else {
  16735. $schemaValue = $schema;
  16736. }
  16737. out += 'var division' + $lvl + ';if (';
  16738. if ($isData) {
  16739. out += ' ' + $schemaValue + ' !== undefined && ( typeof ' + $schemaValue + ' != \'number\' || ';
  16740. }
  16741. out += ' (division' + $lvl + ' = ' + $data + ' / ' + $schemaValue + ', ';
  16742. if (it.opts.multipleOfPrecision) {
  16743. out += ' Math.abs(Math.round(division' + $lvl + ') - division' + $lvl + ') > 1e-' + it.opts.multipleOfPrecision + ' ';
  16744. } else {
  16745. out += ' division' + $lvl + ' !== parseInt(division' + $lvl + ') ';
  16746. }
  16747. out += ' ) ';
  16748. if ($isData) {
  16749. out += ' ) ';
  16750. }
  16751. out += ' ) { ';
  16752. var $$outStack = $$outStack || [];
  16753. $$outStack.push(out);
  16754. out = ''; /* istanbul ignore else */
  16755. if (it.createErrors !== false) {
  16756. out += ' { keyword: \'' + 'multipleOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { multipleOf: ' + $schemaValue + ' } ';
  16757. if (it.opts.messages !== false) {
  16758. out += ' , message: \'should be multiple of ';
  16759. if ($isData) {
  16760. out += '\' + ' + $schemaValue;
  16761. } else {
  16762. out += '' + $schemaValue + '\'';
  16763. }
  16764. }
  16765. if (it.opts.verbose) {
  16766. out += ' , schema: ';
  16767. if ($isData) {
  16768. out += 'validate.schema' + $schemaPath;
  16769. } else {
  16770. out += '' + $schema;
  16771. }
  16772. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16773. }
  16774. out += ' } ';
  16775. } else {
  16776. out += ' {} ';
  16777. }
  16778. var __err = out;
  16779. out = $$outStack.pop();
  16780. if (!it.compositeRule && $breakOnError) {
  16781. /* istanbul ignore if */
  16782. if (it.async) {
  16783. out += ' throw new ValidationError([' + __err + ']); ';
  16784. } else {
  16785. out += ' validate.errors = [' + __err + ']; return false; ';
  16786. }
  16787. } else {
  16788. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16789. }
  16790. out += '} ';
  16791. if ($breakOnError) {
  16792. out += ' else { ';
  16793. }
  16794. return out;
  16795. };
  16796. },{}],33:[function(require,module,exports){
  16797. 'use strict';
  16798. module.exports = function generate_not(it, $keyword, $ruleType) {
  16799. var out = ' ';
  16800. var $lvl = it.level;
  16801. var $dataLvl = it.dataLevel;
  16802. var $schema = it.schema[$keyword];
  16803. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16804. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16805. var $breakOnError = !it.opts.allErrors;
  16806. var $data = 'data' + ($dataLvl || '');
  16807. var $errs = 'errs__' + $lvl;
  16808. var $it = it.util.copy(it);
  16809. $it.level++;
  16810. var $nextValid = 'valid' + $it.level;
  16811. if (it.util.schemaHasRules($schema, it.RULES.all)) {
  16812. $it.schema = $schema;
  16813. $it.schemaPath = $schemaPath;
  16814. $it.errSchemaPath = $errSchemaPath;
  16815. out += ' var ' + $errs + ' = errors; ';
  16816. var $wasComposite = it.compositeRule;
  16817. it.compositeRule = $it.compositeRule = true;
  16818. $it.createErrors = false;
  16819. var $allErrorsOption;
  16820. if ($it.opts.allErrors) {
  16821. $allErrorsOption = $it.opts.allErrors;
  16822. $it.opts.allErrors = false;
  16823. }
  16824. out += ' ' + it.validate($it) + ' ';
  16825. $it.createErrors = true;
  16826. if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
  16827. it.compositeRule = $it.compositeRule = $wasComposite;
  16828. out += ' if (' + $nextValid + ') { ';
  16829. var $$outStack = $$outStack || [];
  16830. $$outStack.push(out);
  16831. out = ''; /* istanbul ignore else */
  16832. if (it.createErrors !== false) {
  16833. out += ' { keyword: \'' + 'not' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
  16834. if (it.opts.messages !== false) {
  16835. out += ' , message: \'should NOT be valid\' ';
  16836. }
  16837. if (it.opts.verbose) {
  16838. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16839. }
  16840. out += ' } ';
  16841. } else {
  16842. out += ' {} ';
  16843. }
  16844. var __err = out;
  16845. out = $$outStack.pop();
  16846. if (!it.compositeRule && $breakOnError) {
  16847. /* istanbul ignore if */
  16848. if (it.async) {
  16849. out += ' throw new ValidationError([' + __err + ']); ';
  16850. } else {
  16851. out += ' validate.errors = [' + __err + ']; return false; ';
  16852. }
  16853. } else {
  16854. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16855. }
  16856. out += ' } else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
  16857. if (it.opts.allErrors) {
  16858. out += ' } ';
  16859. }
  16860. } else {
  16861. out += ' var err = '; /* istanbul ignore else */
  16862. if (it.createErrors !== false) {
  16863. out += ' { keyword: \'' + 'not' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
  16864. if (it.opts.messages !== false) {
  16865. out += ' , message: \'should NOT be valid\' ';
  16866. }
  16867. if (it.opts.verbose) {
  16868. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16869. }
  16870. out += ' } ';
  16871. } else {
  16872. out += ' {} ';
  16873. }
  16874. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16875. if ($breakOnError) {
  16876. out += ' if (false) { ';
  16877. }
  16878. }
  16879. return out;
  16880. };
  16881. },{}],34:[function(require,module,exports){
  16882. 'use strict';
  16883. module.exports = function generate_oneOf(it, $keyword, $ruleType) {
  16884. var out = ' ';
  16885. var $lvl = it.level;
  16886. var $dataLvl = it.dataLevel;
  16887. var $schema = it.schema[$keyword];
  16888. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16889. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16890. var $breakOnError = !it.opts.allErrors;
  16891. var $data = 'data' + ($dataLvl || '');
  16892. var $valid = 'valid' + $lvl;
  16893. var $errs = 'errs__' + $lvl;
  16894. var $it = it.util.copy(it);
  16895. var $closingBraces = '';
  16896. $it.level++;
  16897. var $nextValid = 'valid' + $it.level;
  16898. var $currentBaseId = $it.baseId,
  16899. $prevValid = 'prevValid' + $lvl,
  16900. $passingSchemas = 'passingSchemas' + $lvl;
  16901. out += 'var ' + $errs + ' = errors , ' + $prevValid + ' = false , ' + $valid + ' = false , ' + $passingSchemas + ' = null; ';
  16902. var $wasComposite = it.compositeRule;
  16903. it.compositeRule = $it.compositeRule = true;
  16904. var arr1 = $schema;
  16905. if (arr1) {
  16906. var $sch,
  16907. $i = -1,
  16908. l1 = arr1.length - 1;
  16909. while ($i < l1) {
  16910. $sch = arr1[$i += 1];
  16911. if (it.util.schemaHasRules($sch, it.RULES.all)) {
  16912. $it.schema = $sch;
  16913. $it.schemaPath = $schemaPath + '[' + $i + ']';
  16914. $it.errSchemaPath = $errSchemaPath + '/' + $i;
  16915. out += ' ' + it.validate($it) + ' ';
  16916. $it.baseId = $currentBaseId;
  16917. } else {
  16918. out += ' var ' + $nextValid + ' = true; ';
  16919. }
  16920. if ($i) {
  16921. out += ' if (' + $nextValid + ' && ' + $prevValid + ') { ' + $valid + ' = false; ' + $passingSchemas + ' = [' + $passingSchemas + ', ' + $i + ']; } else { ';
  16922. $closingBraces += '}';
  16923. }
  16924. out += ' if (' + $nextValid + ') { ' + $valid + ' = ' + $prevValid + ' = true; ' + $passingSchemas + ' = ' + $i + '; }';
  16925. }
  16926. }
  16927. it.compositeRule = $it.compositeRule = $wasComposite;
  16928. out += '' + $closingBraces + 'if (!' + $valid + ') { var err = '; /* istanbul ignore else */
  16929. if (it.createErrors !== false) {
  16930. out += ' { keyword: \'' + 'oneOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { passingSchemas: ' + $passingSchemas + ' } ';
  16931. if (it.opts.messages !== false) {
  16932. out += ' , message: \'should match exactly one schema in oneOf\' ';
  16933. }
  16934. if (it.opts.verbose) {
  16935. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  16936. }
  16937. out += ' } ';
  16938. } else {
  16939. out += ' {} ';
  16940. }
  16941. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  16942. if (!it.compositeRule && $breakOnError) {
  16943. /* istanbul ignore if */
  16944. if (it.async) {
  16945. out += ' throw new ValidationError(vErrors); ';
  16946. } else {
  16947. out += ' validate.errors = vErrors; return false; ';
  16948. }
  16949. }
  16950. out += '} else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; }';
  16951. if (it.opts.allErrors) {
  16952. out += ' } ';
  16953. }
  16954. return out;
  16955. };
  16956. },{}],35:[function(require,module,exports){
  16957. 'use strict';
  16958. module.exports = function generate_pattern(it, $keyword, $ruleType) {
  16959. var out = ' ';
  16960. var $lvl = it.level;
  16961. var $dataLvl = it.dataLevel;
  16962. var $schema = it.schema[$keyword];
  16963. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  16964. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  16965. var $breakOnError = !it.opts.allErrors;
  16966. var $data = 'data' + ($dataLvl || '');
  16967. var $isData = it.opts.$data && $schema && $schema.$data,
  16968. $schemaValue;
  16969. if ($isData) {
  16970. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  16971. $schemaValue = 'schema' + $lvl;
  16972. } else {
  16973. $schemaValue = $schema;
  16974. }
  16975. var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
  16976. out += 'if ( ';
  16977. if ($isData) {
  16978. out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'string\') || ';
  16979. }
  16980. out += ' !' + $regexp + '.test(' + $data + ') ) { ';
  16981. var $$outStack = $$outStack || [];
  16982. $$outStack.push(out);
  16983. out = ''; /* istanbul ignore else */
  16984. if (it.createErrors !== false) {
  16985. out += ' { keyword: \'' + 'pattern' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { pattern: ';
  16986. if ($isData) {
  16987. out += '' + $schemaValue;
  16988. } else {
  16989. out += '' + it.util.toQuotedString($schema);
  16990. }
  16991. out += ' } ';
  16992. if (it.opts.messages !== false) {
  16993. out += ' , message: \'should match pattern "';
  16994. if ($isData) {
  16995. out += '\' + ' + $schemaValue + ' + \'';
  16996. } else {
  16997. out += '' + it.util.escapeQuotes($schema);
  16998. }
  16999. out += '"\' ';
  17000. }
  17001. if (it.opts.verbose) {
  17002. out += ' , schema: ';
  17003. if ($isData) {
  17004. out += 'validate.schema' + $schemaPath;
  17005. } else {
  17006. out += '' + it.util.toQuotedString($schema);
  17007. }
  17008. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17009. }
  17010. out += ' } ';
  17011. } else {
  17012. out += ' {} ';
  17013. }
  17014. var __err = out;
  17015. out = $$outStack.pop();
  17016. if (!it.compositeRule && $breakOnError) {
  17017. /* istanbul ignore if */
  17018. if (it.async) {
  17019. out += ' throw new ValidationError([' + __err + ']); ';
  17020. } else {
  17021. out += ' validate.errors = [' + __err + ']; return false; ';
  17022. }
  17023. } else {
  17024. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17025. }
  17026. out += '} ';
  17027. if ($breakOnError) {
  17028. out += ' else { ';
  17029. }
  17030. return out;
  17031. };
  17032. },{}],36:[function(require,module,exports){
  17033. 'use strict';
  17034. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  17035. module.exports = function generate_properties(it, $keyword, $ruleType) {
  17036. var out = ' ';
  17037. var $lvl = it.level;
  17038. var $dataLvl = it.dataLevel;
  17039. var $schema = it.schema[$keyword];
  17040. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  17041. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  17042. var $breakOnError = !it.opts.allErrors;
  17043. var $data = 'data' + ($dataLvl || '');
  17044. var $errs = 'errs__' + $lvl;
  17045. var $it = it.util.copy(it);
  17046. var $closingBraces = '';
  17047. $it.level++;
  17048. var $nextValid = 'valid' + $it.level;
  17049. var $key = 'key' + $lvl,
  17050. $idx = 'idx' + $lvl,
  17051. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  17052. $nextData = 'data' + $dataNxt,
  17053. $dataProperties = 'dataProperties' + $lvl;
  17054. var $schemaKeys = Object.keys($schema || {}),
  17055. $pProperties = it.schema.patternProperties || {},
  17056. $pPropertyKeys = Object.keys($pProperties),
  17057. $aProperties = it.schema.additionalProperties,
  17058. $someProperties = $schemaKeys.length || $pPropertyKeys.length,
  17059. $noAdditional = $aProperties === false,
  17060. $additionalIsSchema = (typeof $aProperties === 'undefined' ? 'undefined' : _typeof($aProperties)) == 'object' && Object.keys($aProperties).length,
  17061. $removeAdditional = it.opts.removeAdditional,
  17062. $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
  17063. $ownProperties = it.opts.ownProperties,
  17064. $currentBaseId = it.baseId;
  17065. var $required = it.schema.required;
  17066. if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required);
  17067. out += 'var ' + $errs + ' = errors;var ' + $nextValid + ' = true;';
  17068. if ($ownProperties) {
  17069. out += ' var ' + $dataProperties + ' = undefined;';
  17070. }
  17071. if ($checkAdditional) {
  17072. if ($ownProperties) {
  17073. out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
  17074. } else {
  17075. out += ' for (var ' + $key + ' in ' + $data + ') { ';
  17076. }
  17077. if ($someProperties) {
  17078. out += ' var isAdditional' + $lvl + ' = !(false ';
  17079. if ($schemaKeys.length) {
  17080. if ($schemaKeys.length > 8) {
  17081. out += ' || validate.schema' + $schemaPath + '.hasOwnProperty(' + $key + ') ';
  17082. } else {
  17083. var arr1 = $schemaKeys;
  17084. if (arr1) {
  17085. var $propertyKey,
  17086. i1 = -1,
  17087. l1 = arr1.length - 1;
  17088. while (i1 < l1) {
  17089. $propertyKey = arr1[i1 += 1];
  17090. out += ' || ' + $key + ' == ' + it.util.toQuotedString($propertyKey) + ' ';
  17091. }
  17092. }
  17093. }
  17094. }
  17095. if ($pPropertyKeys.length) {
  17096. var arr2 = $pPropertyKeys;
  17097. if (arr2) {
  17098. var $pProperty,
  17099. $i = -1,
  17100. l2 = arr2.length - 1;
  17101. while ($i < l2) {
  17102. $pProperty = arr2[$i += 1];
  17103. out += ' || ' + it.usePattern($pProperty) + '.test(' + $key + ') ';
  17104. }
  17105. }
  17106. }
  17107. out += ' ); if (isAdditional' + $lvl + ') { ';
  17108. }
  17109. if ($removeAdditional == 'all') {
  17110. out += ' delete ' + $data + '[' + $key + ']; ';
  17111. } else {
  17112. var $currentErrorPath = it.errorPath;
  17113. var $additionalProperty = '\' + ' + $key + ' + \'';
  17114. if (it.opts._errorDataPathProperty) {
  17115. it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  17116. }
  17117. if ($noAdditional) {
  17118. if ($removeAdditional) {
  17119. out += ' delete ' + $data + '[' + $key + ']; ';
  17120. } else {
  17121. out += ' ' + $nextValid + ' = false; ';
  17122. var $currErrSchemaPath = $errSchemaPath;
  17123. $errSchemaPath = it.errSchemaPath + '/additionalProperties';
  17124. var $$outStack = $$outStack || [];
  17125. $$outStack.push(out);
  17126. out = ''; /* istanbul ignore else */
  17127. if (it.createErrors !== false) {
  17128. out += ' { keyword: \'' + 'additionalProperties' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { additionalProperty: \'' + $additionalProperty + '\' } ';
  17129. if (it.opts.messages !== false) {
  17130. out += ' , message: \'';
  17131. if (it.opts._errorDataPathProperty) {
  17132. out += 'is an invalid additional property';
  17133. } else {
  17134. out += 'should NOT have additional properties';
  17135. }
  17136. out += '\' ';
  17137. }
  17138. if (it.opts.verbose) {
  17139. out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17140. }
  17141. out += ' } ';
  17142. } else {
  17143. out += ' {} ';
  17144. }
  17145. var __err = out;
  17146. out = $$outStack.pop();
  17147. if (!it.compositeRule && $breakOnError) {
  17148. /* istanbul ignore if */
  17149. if (it.async) {
  17150. out += ' throw new ValidationError([' + __err + ']); ';
  17151. } else {
  17152. out += ' validate.errors = [' + __err + ']; return false; ';
  17153. }
  17154. } else {
  17155. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17156. }
  17157. $errSchemaPath = $currErrSchemaPath;
  17158. if ($breakOnError) {
  17159. out += ' break; ';
  17160. }
  17161. }
  17162. } else if ($additionalIsSchema) {
  17163. if ($removeAdditional == 'failing') {
  17164. out += ' var ' + $errs + ' = errors; ';
  17165. var $wasComposite = it.compositeRule;
  17166. it.compositeRule = $it.compositeRule = true;
  17167. $it.schema = $aProperties;
  17168. $it.schemaPath = it.schemaPath + '.additionalProperties';
  17169. $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
  17170. $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  17171. var $passData = $data + '[' + $key + ']';
  17172. $it.dataPathArr[$dataNxt] = $key;
  17173. var $code = it.validate($it);
  17174. $it.baseId = $currentBaseId;
  17175. if (it.util.varOccurences($code, $nextData) < 2) {
  17176. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  17177. } else {
  17178. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  17179. }
  17180. out += ' if (!' + $nextValid + ') { errors = ' + $errs + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + $data + '[' + $key + ']; } ';
  17181. it.compositeRule = $it.compositeRule = $wasComposite;
  17182. } else {
  17183. $it.schema = $aProperties;
  17184. $it.schemaPath = it.schemaPath + '.additionalProperties';
  17185. $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
  17186. $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  17187. var $passData = $data + '[' + $key + ']';
  17188. $it.dataPathArr[$dataNxt] = $key;
  17189. var $code = it.validate($it);
  17190. $it.baseId = $currentBaseId;
  17191. if (it.util.varOccurences($code, $nextData) < 2) {
  17192. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  17193. } else {
  17194. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  17195. }
  17196. if ($breakOnError) {
  17197. out += ' if (!' + $nextValid + ') break; ';
  17198. }
  17199. }
  17200. }
  17201. it.errorPath = $currentErrorPath;
  17202. }
  17203. if ($someProperties) {
  17204. out += ' } ';
  17205. }
  17206. out += ' } ';
  17207. if ($breakOnError) {
  17208. out += ' if (' + $nextValid + ') { ';
  17209. $closingBraces += '}';
  17210. }
  17211. }
  17212. var $useDefaults = it.opts.useDefaults && !it.compositeRule;
  17213. if ($schemaKeys.length) {
  17214. var arr3 = $schemaKeys;
  17215. if (arr3) {
  17216. var $propertyKey,
  17217. i3 = -1,
  17218. l3 = arr3.length - 1;
  17219. while (i3 < l3) {
  17220. $propertyKey = arr3[i3 += 1];
  17221. var $sch = $schema[$propertyKey];
  17222. if (it.util.schemaHasRules($sch, it.RULES.all)) {
  17223. var $prop = it.util.getProperty($propertyKey),
  17224. $passData = $data + $prop,
  17225. $hasDefault = $useDefaults && $sch.default !== undefined;
  17226. $it.schema = $sch;
  17227. $it.schemaPath = $schemaPath + $prop;
  17228. $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
  17229. $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
  17230. $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
  17231. var $code = it.validate($it);
  17232. $it.baseId = $currentBaseId;
  17233. if (it.util.varOccurences($code, $nextData) < 2) {
  17234. $code = it.util.varReplace($code, $nextData, $passData);
  17235. var $useData = $passData;
  17236. } else {
  17237. var $useData = $nextData;
  17238. out += ' var ' + $nextData + ' = ' + $passData + '; ';
  17239. }
  17240. if ($hasDefault) {
  17241. out += ' ' + $code + ' ';
  17242. } else {
  17243. if ($requiredHash && $requiredHash[$propertyKey]) {
  17244. out += ' if ( ' + $useData + ' === undefined ';
  17245. if ($ownProperties) {
  17246. out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
  17247. }
  17248. out += ') { ' + $nextValid + ' = false; ';
  17249. var $currentErrorPath = it.errorPath,
  17250. $currErrSchemaPath = $errSchemaPath,
  17251. $missingProperty = it.util.escapeQuotes($propertyKey);
  17252. if (it.opts._errorDataPathProperty) {
  17253. it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
  17254. }
  17255. $errSchemaPath = it.errSchemaPath + '/required';
  17256. var $$outStack = $$outStack || [];
  17257. $$outStack.push(out);
  17258. out = ''; /* istanbul ignore else */
  17259. if (it.createErrors !== false) {
  17260. out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
  17261. if (it.opts.messages !== false) {
  17262. out += ' , message: \'';
  17263. if (it.opts._errorDataPathProperty) {
  17264. out += 'is a required property';
  17265. } else {
  17266. out += 'should have required property \\\'' + $missingProperty + '\\\'';
  17267. }
  17268. out += '\' ';
  17269. }
  17270. if (it.opts.verbose) {
  17271. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17272. }
  17273. out += ' } ';
  17274. } else {
  17275. out += ' {} ';
  17276. }
  17277. var __err = out;
  17278. out = $$outStack.pop();
  17279. if (!it.compositeRule && $breakOnError) {
  17280. /* istanbul ignore if */
  17281. if (it.async) {
  17282. out += ' throw new ValidationError([' + __err + ']); ';
  17283. } else {
  17284. out += ' validate.errors = [' + __err + ']; return false; ';
  17285. }
  17286. } else {
  17287. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17288. }
  17289. $errSchemaPath = $currErrSchemaPath;
  17290. it.errorPath = $currentErrorPath;
  17291. out += ' } else { ';
  17292. } else {
  17293. if ($breakOnError) {
  17294. out += ' if ( ' + $useData + ' === undefined ';
  17295. if ($ownProperties) {
  17296. out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
  17297. }
  17298. out += ') { ' + $nextValid + ' = true; } else { ';
  17299. } else {
  17300. out += ' if (' + $useData + ' !== undefined ';
  17301. if ($ownProperties) {
  17302. out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
  17303. }
  17304. out += ' ) { ';
  17305. }
  17306. }
  17307. out += ' ' + $code + ' } ';
  17308. }
  17309. }
  17310. if ($breakOnError) {
  17311. out += ' if (' + $nextValid + ') { ';
  17312. $closingBraces += '}';
  17313. }
  17314. }
  17315. }
  17316. }
  17317. if ($pPropertyKeys.length) {
  17318. var arr4 = $pPropertyKeys;
  17319. if (arr4) {
  17320. var $pProperty,
  17321. i4 = -1,
  17322. l4 = arr4.length - 1;
  17323. while (i4 < l4) {
  17324. $pProperty = arr4[i4 += 1];
  17325. var $sch = $pProperties[$pProperty];
  17326. if (it.util.schemaHasRules($sch, it.RULES.all)) {
  17327. $it.schema = $sch;
  17328. $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
  17329. $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
  17330. if ($ownProperties) {
  17331. out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
  17332. } else {
  17333. out += ' for (var ' + $key + ' in ' + $data + ') { ';
  17334. }
  17335. out += ' if (' + it.usePattern($pProperty) + '.test(' + $key + ')) { ';
  17336. $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
  17337. var $passData = $data + '[' + $key + ']';
  17338. $it.dataPathArr[$dataNxt] = $key;
  17339. var $code = it.validate($it);
  17340. $it.baseId = $currentBaseId;
  17341. if (it.util.varOccurences($code, $nextData) < 2) {
  17342. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  17343. } else {
  17344. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  17345. }
  17346. if ($breakOnError) {
  17347. out += ' if (!' + $nextValid + ') break; ';
  17348. }
  17349. out += ' } ';
  17350. if ($breakOnError) {
  17351. out += ' else ' + $nextValid + ' = true; ';
  17352. }
  17353. out += ' } ';
  17354. if ($breakOnError) {
  17355. out += ' if (' + $nextValid + ') { ';
  17356. $closingBraces += '}';
  17357. }
  17358. }
  17359. }
  17360. }
  17361. }
  17362. if ($breakOnError) {
  17363. out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
  17364. }
  17365. out = it.util.cleanUpCode(out);
  17366. return out;
  17367. };
  17368. },{}],37:[function(require,module,exports){
  17369. 'use strict';
  17370. module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
  17371. var out = ' ';
  17372. var $lvl = it.level;
  17373. var $dataLvl = it.dataLevel;
  17374. var $schema = it.schema[$keyword];
  17375. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  17376. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  17377. var $breakOnError = !it.opts.allErrors;
  17378. var $data = 'data' + ($dataLvl || '');
  17379. var $errs = 'errs__' + $lvl;
  17380. var $it = it.util.copy(it);
  17381. var $closingBraces = '';
  17382. $it.level++;
  17383. var $nextValid = 'valid' + $it.level;
  17384. out += 'var ' + $errs + ' = errors;';
  17385. if (it.util.schemaHasRules($schema, it.RULES.all)) {
  17386. $it.schema = $schema;
  17387. $it.schemaPath = $schemaPath;
  17388. $it.errSchemaPath = $errSchemaPath;
  17389. var $key = 'key' + $lvl,
  17390. $idx = 'idx' + $lvl,
  17391. $i = 'i' + $lvl,
  17392. $invalidName = '\' + ' + $key + ' + \'',
  17393. $dataNxt = $it.dataLevel = it.dataLevel + 1,
  17394. $nextData = 'data' + $dataNxt,
  17395. $dataProperties = 'dataProperties' + $lvl,
  17396. $ownProperties = it.opts.ownProperties,
  17397. $currentBaseId = it.baseId;
  17398. if ($ownProperties) {
  17399. out += ' var ' + $dataProperties + ' = undefined; ';
  17400. }
  17401. if ($ownProperties) {
  17402. out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
  17403. } else {
  17404. out += ' for (var ' + $key + ' in ' + $data + ') { ';
  17405. }
  17406. out += ' var startErrs' + $lvl + ' = errors; ';
  17407. var $passData = $key;
  17408. var $wasComposite = it.compositeRule;
  17409. it.compositeRule = $it.compositeRule = true;
  17410. var $code = it.validate($it);
  17411. $it.baseId = $currentBaseId;
  17412. if (it.util.varOccurences($code, $nextData) < 2) {
  17413. out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
  17414. } else {
  17415. out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
  17416. }
  17417. it.compositeRule = $it.compositeRule = $wasComposite;
  17418. out += ' if (!' + $nextValid + ') { for (var ' + $i + '=startErrs' + $lvl + '; ' + $i + '<errors; ' + $i + '++) { vErrors[' + $i + '].propertyName = ' + $key + '; } var err = '; /* istanbul ignore else */
  17419. if (it.createErrors !== false) {
  17420. out += ' { keyword: \'' + 'propertyNames' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { propertyName: \'' + $invalidName + '\' } ';
  17421. if (it.opts.messages !== false) {
  17422. out += ' , message: \'property name \\\'' + $invalidName + '\\\' is invalid\' ';
  17423. }
  17424. if (it.opts.verbose) {
  17425. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17426. }
  17427. out += ' } ';
  17428. } else {
  17429. out += ' {} ';
  17430. }
  17431. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17432. if (!it.compositeRule && $breakOnError) {
  17433. /* istanbul ignore if */
  17434. if (it.async) {
  17435. out += ' throw new ValidationError(vErrors); ';
  17436. } else {
  17437. out += ' validate.errors = vErrors; return false; ';
  17438. }
  17439. }
  17440. if ($breakOnError) {
  17441. out += ' break; ';
  17442. }
  17443. out += ' } }';
  17444. }
  17445. if ($breakOnError) {
  17446. out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
  17447. }
  17448. out = it.util.cleanUpCode(out);
  17449. return out;
  17450. };
  17451. },{}],38:[function(require,module,exports){
  17452. 'use strict';
  17453. module.exports = function generate_ref(it, $keyword, $ruleType) {
  17454. var out = ' ';
  17455. var $lvl = it.level;
  17456. var $dataLvl = it.dataLevel;
  17457. var $schema = it.schema[$keyword];
  17458. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  17459. var $breakOnError = !it.opts.allErrors;
  17460. var $data = 'data' + ($dataLvl || '');
  17461. var $valid = 'valid' + $lvl;
  17462. var $async, $refCode;
  17463. if ($schema == '#' || $schema == '#/') {
  17464. if (it.isRoot) {
  17465. $async = it.async;
  17466. $refCode = 'validate';
  17467. } else {
  17468. $async = it.root.schema.$async === true;
  17469. $refCode = 'root.refVal[0]';
  17470. }
  17471. } else {
  17472. var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot);
  17473. if ($refVal === undefined) {
  17474. var $message = it.MissingRefError.message(it.baseId, $schema);
  17475. if (it.opts.missingRefs == 'fail') {
  17476. it.logger.error($message);
  17477. var $$outStack = $$outStack || [];
  17478. $$outStack.push(out);
  17479. out = ''; /* istanbul ignore else */
  17480. if (it.createErrors !== false) {
  17481. out += ' { keyword: \'' + '$ref' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { ref: \'' + it.util.escapeQuotes($schema) + '\' } ';
  17482. if (it.opts.messages !== false) {
  17483. out += ' , message: \'can\\\'t resolve reference ' + it.util.escapeQuotes($schema) + '\' ';
  17484. }
  17485. if (it.opts.verbose) {
  17486. out += ' , schema: ' + it.util.toQuotedString($schema) + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17487. }
  17488. out += ' } ';
  17489. } else {
  17490. out += ' {} ';
  17491. }
  17492. var __err = out;
  17493. out = $$outStack.pop();
  17494. if (!it.compositeRule && $breakOnError) {
  17495. /* istanbul ignore if */
  17496. if (it.async) {
  17497. out += ' throw new ValidationError([' + __err + ']); ';
  17498. } else {
  17499. out += ' validate.errors = [' + __err + ']; return false; ';
  17500. }
  17501. } else {
  17502. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17503. }
  17504. if ($breakOnError) {
  17505. out += ' if (false) { ';
  17506. }
  17507. } else if (it.opts.missingRefs == 'ignore') {
  17508. it.logger.warn($message);
  17509. if ($breakOnError) {
  17510. out += ' if (true) { ';
  17511. }
  17512. } else {
  17513. throw new it.MissingRefError(it.baseId, $schema, $message);
  17514. }
  17515. } else if ($refVal.inline) {
  17516. var $it = it.util.copy(it);
  17517. $it.level++;
  17518. var $nextValid = 'valid' + $it.level;
  17519. $it.schema = $refVal.schema;
  17520. $it.schemaPath = '';
  17521. $it.errSchemaPath = $schema;
  17522. var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code);
  17523. out += ' ' + $code + ' ';
  17524. if ($breakOnError) {
  17525. out += ' if (' + $nextValid + ') { ';
  17526. }
  17527. } else {
  17528. $async = $refVal.$async === true || it.async && $refVal.$async !== false;
  17529. $refCode = $refVal.code;
  17530. }
  17531. }
  17532. if ($refCode) {
  17533. var $$outStack = $$outStack || [];
  17534. $$outStack.push(out);
  17535. out = '';
  17536. if (it.opts.passContext) {
  17537. out += ' ' + $refCode + '.call(this, ';
  17538. } else {
  17539. out += ' ' + $refCode + '( ';
  17540. }
  17541. out += ' ' + $data + ', (dataPath || \'\')';
  17542. if (it.errorPath != '""') {
  17543. out += ' + ' + it.errorPath;
  17544. }
  17545. var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
  17546. $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
  17547. out += ' , ' + $parentData + ' , ' + $parentDataProperty + ', rootData) ';
  17548. var __callValidate = out;
  17549. out = $$outStack.pop();
  17550. if ($async) {
  17551. if (!it.async) throw new Error('async schema referenced by sync schema');
  17552. if ($breakOnError) {
  17553. out += ' var ' + $valid + '; ';
  17554. }
  17555. out += ' try { await ' + __callValidate + '; ';
  17556. if ($breakOnError) {
  17557. out += ' ' + $valid + ' = true; ';
  17558. }
  17559. out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ';
  17560. if ($breakOnError) {
  17561. out += ' ' + $valid + ' = false; ';
  17562. }
  17563. out += ' } ';
  17564. if ($breakOnError) {
  17565. out += ' if (' + $valid + ') { ';
  17566. }
  17567. } else {
  17568. out += ' if (!' + __callValidate + ') { if (vErrors === null) vErrors = ' + $refCode + '.errors; else vErrors = vErrors.concat(' + $refCode + '.errors); errors = vErrors.length; } ';
  17569. if ($breakOnError) {
  17570. out += ' else { ';
  17571. }
  17572. }
  17573. }
  17574. return out;
  17575. };
  17576. },{}],39:[function(require,module,exports){
  17577. 'use strict';
  17578. module.exports = function generate_required(it, $keyword, $ruleType) {
  17579. var out = ' ';
  17580. var $lvl = it.level;
  17581. var $dataLvl = it.dataLevel;
  17582. var $schema = it.schema[$keyword];
  17583. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  17584. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  17585. var $breakOnError = !it.opts.allErrors;
  17586. var $data = 'data' + ($dataLvl || '');
  17587. var $valid = 'valid' + $lvl;
  17588. var $isData = it.opts.$data && $schema && $schema.$data,
  17589. $schemaValue;
  17590. if ($isData) {
  17591. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  17592. $schemaValue = 'schema' + $lvl;
  17593. } else {
  17594. $schemaValue = $schema;
  17595. }
  17596. var $vSchema = 'schema' + $lvl;
  17597. if (!$isData) {
  17598. if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) {
  17599. var $required = [];
  17600. var arr1 = $schema;
  17601. if (arr1) {
  17602. var $property,
  17603. i1 = -1,
  17604. l1 = arr1.length - 1;
  17605. while (i1 < l1) {
  17606. $property = arr1[i1 += 1];
  17607. var $propertySch = it.schema.properties[$property];
  17608. if (!($propertySch && it.util.schemaHasRules($propertySch, it.RULES.all))) {
  17609. $required[$required.length] = $property;
  17610. }
  17611. }
  17612. }
  17613. } else {
  17614. var $required = $schema;
  17615. }
  17616. }
  17617. if ($isData || $required.length) {
  17618. var $currentErrorPath = it.errorPath,
  17619. $loopRequired = $isData || $required.length >= it.opts.loopRequired,
  17620. $ownProperties = it.opts.ownProperties;
  17621. if ($breakOnError) {
  17622. out += ' var missing' + $lvl + '; ';
  17623. if ($loopRequired) {
  17624. if (!$isData) {
  17625. out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ';
  17626. }
  17627. var $i = 'i' + $lvl,
  17628. $propertyPath = 'schema' + $lvl + '[' + $i + ']',
  17629. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  17630. if (it.opts._errorDataPathProperty) {
  17631. it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
  17632. }
  17633. out += ' var ' + $valid + ' = true; ';
  17634. if ($isData) {
  17635. out += ' if (schema' + $lvl + ' === undefined) ' + $valid + ' = true; else if (!Array.isArray(schema' + $lvl + ')) ' + $valid + ' = false; else {';
  17636. }
  17637. out += ' for (var ' + $i + ' = 0; ' + $i + ' < ' + $vSchema + '.length; ' + $i + '++) { ' + $valid + ' = ' + $data + '[' + $vSchema + '[' + $i + ']] !== undefined ';
  17638. if ($ownProperties) {
  17639. out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', ' + $vSchema + '[' + $i + ']) ';
  17640. }
  17641. out += '; if (!' + $valid + ') break; } ';
  17642. if ($isData) {
  17643. out += ' } ';
  17644. }
  17645. out += ' if (!' + $valid + ') { ';
  17646. var $$outStack = $$outStack || [];
  17647. $$outStack.push(out);
  17648. out = ''; /* istanbul ignore else */
  17649. if (it.createErrors !== false) {
  17650. out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
  17651. if (it.opts.messages !== false) {
  17652. out += ' , message: \'';
  17653. if (it.opts._errorDataPathProperty) {
  17654. out += 'is a required property';
  17655. } else {
  17656. out += 'should have required property \\\'' + $missingProperty + '\\\'';
  17657. }
  17658. out += '\' ';
  17659. }
  17660. if (it.opts.verbose) {
  17661. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17662. }
  17663. out += ' } ';
  17664. } else {
  17665. out += ' {} ';
  17666. }
  17667. var __err = out;
  17668. out = $$outStack.pop();
  17669. if (!it.compositeRule && $breakOnError) {
  17670. /* istanbul ignore if */
  17671. if (it.async) {
  17672. out += ' throw new ValidationError([' + __err + ']); ';
  17673. } else {
  17674. out += ' validate.errors = [' + __err + ']; return false; ';
  17675. }
  17676. } else {
  17677. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17678. }
  17679. out += ' } else { ';
  17680. } else {
  17681. out += ' if ( ';
  17682. var arr2 = $required;
  17683. if (arr2) {
  17684. var $propertyKey,
  17685. $i = -1,
  17686. l2 = arr2.length - 1;
  17687. while ($i < l2) {
  17688. $propertyKey = arr2[$i += 1];
  17689. if ($i) {
  17690. out += ' || ';
  17691. }
  17692. var $prop = it.util.getProperty($propertyKey),
  17693. $useData = $data + $prop;
  17694. out += ' ( ( ' + $useData + ' === undefined ';
  17695. if ($ownProperties) {
  17696. out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
  17697. }
  17698. out += ') && (missing' + $lvl + ' = ' + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ') ) ';
  17699. }
  17700. }
  17701. out += ') { ';
  17702. var $propertyPath = 'missing' + $lvl,
  17703. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  17704. if (it.opts._errorDataPathProperty) {
  17705. it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
  17706. }
  17707. var $$outStack = $$outStack || [];
  17708. $$outStack.push(out);
  17709. out = ''; /* istanbul ignore else */
  17710. if (it.createErrors !== false) {
  17711. out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
  17712. if (it.opts.messages !== false) {
  17713. out += ' , message: \'';
  17714. if (it.opts._errorDataPathProperty) {
  17715. out += 'is a required property';
  17716. } else {
  17717. out += 'should have required property \\\'' + $missingProperty + '\\\'';
  17718. }
  17719. out += '\' ';
  17720. }
  17721. if (it.opts.verbose) {
  17722. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17723. }
  17724. out += ' } ';
  17725. } else {
  17726. out += ' {} ';
  17727. }
  17728. var __err = out;
  17729. out = $$outStack.pop();
  17730. if (!it.compositeRule && $breakOnError) {
  17731. /* istanbul ignore if */
  17732. if (it.async) {
  17733. out += ' throw new ValidationError([' + __err + ']); ';
  17734. } else {
  17735. out += ' validate.errors = [' + __err + ']; return false; ';
  17736. }
  17737. } else {
  17738. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17739. }
  17740. out += ' } else { ';
  17741. }
  17742. } else {
  17743. if ($loopRequired) {
  17744. if (!$isData) {
  17745. out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ';
  17746. }
  17747. var $i = 'i' + $lvl,
  17748. $propertyPath = 'schema' + $lvl + '[' + $i + ']',
  17749. $missingProperty = '\' + ' + $propertyPath + ' + \'';
  17750. if (it.opts._errorDataPathProperty) {
  17751. it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
  17752. }
  17753. if ($isData) {
  17754. out += ' if (' + $vSchema + ' && !Array.isArray(' + $vSchema + ')) { var err = '; /* istanbul ignore else */
  17755. if (it.createErrors !== false) {
  17756. out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
  17757. if (it.opts.messages !== false) {
  17758. out += ' , message: \'';
  17759. if (it.opts._errorDataPathProperty) {
  17760. out += 'is a required property';
  17761. } else {
  17762. out += 'should have required property \\\'' + $missingProperty + '\\\'';
  17763. }
  17764. out += '\' ';
  17765. }
  17766. if (it.opts.verbose) {
  17767. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17768. }
  17769. out += ' } ';
  17770. } else {
  17771. out += ' {} ';
  17772. }
  17773. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + $vSchema + ' !== undefined) { ';
  17774. }
  17775. out += ' for (var ' + $i + ' = 0; ' + $i + ' < ' + $vSchema + '.length; ' + $i + '++) { if (' + $data + '[' + $vSchema + '[' + $i + ']] === undefined ';
  17776. if ($ownProperties) {
  17777. out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', ' + $vSchema + '[' + $i + ']) ';
  17778. }
  17779. out += ') { var err = '; /* istanbul ignore else */
  17780. if (it.createErrors !== false) {
  17781. out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
  17782. if (it.opts.messages !== false) {
  17783. out += ' , message: \'';
  17784. if (it.opts._errorDataPathProperty) {
  17785. out += 'is a required property';
  17786. } else {
  17787. out += 'should have required property \\\'' + $missingProperty + '\\\'';
  17788. }
  17789. out += '\' ';
  17790. }
  17791. if (it.opts.verbose) {
  17792. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17793. }
  17794. out += ' } ';
  17795. } else {
  17796. out += ' {} ';
  17797. }
  17798. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ';
  17799. if ($isData) {
  17800. out += ' } ';
  17801. }
  17802. } else {
  17803. var arr3 = $required;
  17804. if (arr3) {
  17805. var $propertyKey,
  17806. i3 = -1,
  17807. l3 = arr3.length - 1;
  17808. while (i3 < l3) {
  17809. $propertyKey = arr3[i3 += 1];
  17810. var $prop = it.util.getProperty($propertyKey),
  17811. $missingProperty = it.util.escapeQuotes($propertyKey),
  17812. $useData = $data + $prop;
  17813. if (it.opts._errorDataPathProperty) {
  17814. it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
  17815. }
  17816. out += ' if ( ' + $useData + ' === undefined ';
  17817. if ($ownProperties) {
  17818. out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
  17819. }
  17820. out += ') { var err = '; /* istanbul ignore else */
  17821. if (it.createErrors !== false) {
  17822. out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
  17823. if (it.opts.messages !== false) {
  17824. out += ' , message: \'';
  17825. if (it.opts._errorDataPathProperty) {
  17826. out += 'is a required property';
  17827. } else {
  17828. out += 'should have required property \\\'' + $missingProperty + '\\\'';
  17829. }
  17830. out += '\' ';
  17831. }
  17832. if (it.opts.verbose) {
  17833. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17834. }
  17835. out += ' } ';
  17836. } else {
  17837. out += ' {} ';
  17838. }
  17839. out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
  17840. }
  17841. }
  17842. }
  17843. }
  17844. it.errorPath = $currentErrorPath;
  17845. } else if ($breakOnError) {
  17846. out += ' if (true) {';
  17847. }
  17848. return out;
  17849. };
  17850. },{}],40:[function(require,module,exports){
  17851. 'use strict';
  17852. module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
  17853. var out = ' ';
  17854. var $lvl = it.level;
  17855. var $dataLvl = it.dataLevel;
  17856. var $schema = it.schema[$keyword];
  17857. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  17858. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  17859. var $breakOnError = !it.opts.allErrors;
  17860. var $data = 'data' + ($dataLvl || '');
  17861. var $valid = 'valid' + $lvl;
  17862. var $isData = it.opts.$data && $schema && $schema.$data,
  17863. $schemaValue;
  17864. if ($isData) {
  17865. out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
  17866. $schemaValue = 'schema' + $lvl;
  17867. } else {
  17868. $schemaValue = $schema;
  17869. }
  17870. if (($schema || $isData) && it.opts.uniqueItems !== false) {
  17871. if ($isData) {
  17872. out += ' var ' + $valid + '; if (' + $schemaValue + ' === false || ' + $schemaValue + ' === undefined) ' + $valid + ' = true; else if (typeof ' + $schemaValue + ' != \'boolean\') ' + $valid + ' = false; else { ';
  17873. }
  17874. out += ' var i = ' + $data + '.length , ' + $valid + ' = true , j; if (i > 1) { ';
  17875. var $itemType = it.schema.items && it.schema.items.type,
  17876. $typeIsArray = Array.isArray($itemType);
  17877. if (!$itemType || $itemType == 'object' || $itemType == 'array' || $typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0)) {
  17878. out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + $data + '[i], ' + $data + '[j])) { ' + $valid + ' = false; break outer; } } } ';
  17879. } else {
  17880. out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + $data + '[i]; ';
  17881. var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
  17882. out += ' if (' + it.util[$method]($itemType, 'item', true) + ') continue; ';
  17883. if ($typeIsArray) {
  17884. out += ' if (typeof item == \'string\') item = \'"\' + item; ';
  17885. }
  17886. out += ' if (typeof itemIndices[item] == \'number\') { ' + $valid + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ';
  17887. }
  17888. out += ' } ';
  17889. if ($isData) {
  17890. out += ' } ';
  17891. }
  17892. out += ' if (!' + $valid + ') { ';
  17893. var $$outStack = $$outStack || [];
  17894. $$outStack.push(out);
  17895. out = ''; /* istanbul ignore else */
  17896. if (it.createErrors !== false) {
  17897. out += ' { keyword: \'' + 'uniqueItems' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { i: i, j: j } ';
  17898. if (it.opts.messages !== false) {
  17899. out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' ';
  17900. }
  17901. if (it.opts.verbose) {
  17902. out += ' , schema: ';
  17903. if ($isData) {
  17904. out += 'validate.schema' + $schemaPath;
  17905. } else {
  17906. out += '' + $schema;
  17907. }
  17908. out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17909. }
  17910. out += ' } ';
  17911. } else {
  17912. out += ' {} ';
  17913. }
  17914. var __err = out;
  17915. out = $$outStack.pop();
  17916. if (!it.compositeRule && $breakOnError) {
  17917. /* istanbul ignore if */
  17918. if (it.async) {
  17919. out += ' throw new ValidationError([' + __err + ']); ';
  17920. } else {
  17921. out += ' validate.errors = [' + __err + ']; return false; ';
  17922. }
  17923. } else {
  17924. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17925. }
  17926. out += ' } ';
  17927. if ($breakOnError) {
  17928. out += ' else { ';
  17929. }
  17930. } else {
  17931. if ($breakOnError) {
  17932. out += ' if (true) { ';
  17933. }
  17934. }
  17935. return out;
  17936. };
  17937. },{}],41:[function(require,module,exports){
  17938. 'use strict';
  17939. module.exports = function generate_validate(it, $keyword, $ruleType) {
  17940. var out = '';
  17941. var $async = it.schema.$async === true,
  17942. $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
  17943. $id = it.self._getId(it.schema);
  17944. if (it.isTop) {
  17945. out += ' var validate = ';
  17946. if ($async) {
  17947. it.async = true;
  17948. out += 'async ';
  17949. }
  17950. out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
  17951. if ($id && (it.opts.sourceCode || it.opts.processCode)) {
  17952. out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
  17953. }
  17954. }
  17955. if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) {
  17956. var $keyword = 'false schema';
  17957. var $lvl = it.level;
  17958. var $dataLvl = it.dataLevel;
  17959. var $schema = it.schema[$keyword];
  17960. var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
  17961. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  17962. var $breakOnError = !it.opts.allErrors;
  17963. var $errorKeyword;
  17964. var $data = 'data' + ($dataLvl || '');
  17965. var $valid = 'valid' + $lvl;
  17966. if (it.schema === false) {
  17967. if (it.isTop) {
  17968. $breakOnError = true;
  17969. } else {
  17970. out += ' var ' + $valid + ' = false; ';
  17971. }
  17972. var $$outStack = $$outStack || [];
  17973. $$outStack.push(out);
  17974. out = ''; /* istanbul ignore else */
  17975. if (it.createErrors !== false) {
  17976. out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
  17977. if (it.opts.messages !== false) {
  17978. out += ' , message: \'boolean schema is false\' ';
  17979. }
  17980. if (it.opts.verbose) {
  17981. out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  17982. }
  17983. out += ' } ';
  17984. } else {
  17985. out += ' {} ';
  17986. }
  17987. var __err = out;
  17988. out = $$outStack.pop();
  17989. if (!it.compositeRule && $breakOnError) {
  17990. /* istanbul ignore if */
  17991. if (it.async) {
  17992. out += ' throw new ValidationError([' + __err + ']); ';
  17993. } else {
  17994. out += ' validate.errors = [' + __err + ']; return false; ';
  17995. }
  17996. } else {
  17997. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  17998. }
  17999. } else {
  18000. if (it.isTop) {
  18001. if ($async) {
  18002. out += ' return data; ';
  18003. } else {
  18004. out += ' validate.errors = null; return true; ';
  18005. }
  18006. } else {
  18007. out += ' var ' + $valid + ' = true; ';
  18008. }
  18009. }
  18010. if (it.isTop) {
  18011. out += ' }; return validate; ';
  18012. }
  18013. return out;
  18014. }
  18015. if (it.isTop) {
  18016. var $top = it.isTop,
  18017. $lvl = it.level = 0,
  18018. $dataLvl = it.dataLevel = 0,
  18019. $data = 'data';
  18020. it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
  18021. it.baseId = it.baseId || it.rootId;
  18022. delete it.isTop;
  18023. it.dataPathArr = [undefined];
  18024. out += ' var vErrors = null; ';
  18025. out += ' var errors = 0; ';
  18026. out += ' if (rootData === undefined) rootData = data; ';
  18027. } else {
  18028. var $lvl = it.level,
  18029. $dataLvl = it.dataLevel,
  18030. $data = 'data' + ($dataLvl || '');
  18031. if ($id) it.baseId = it.resolve.url(it.baseId, $id);
  18032. if ($async && !it.async) throw new Error('async schema in sync schema');
  18033. out += ' var errs_' + $lvl + ' = errors;';
  18034. }
  18035. var $valid = 'valid' + $lvl,
  18036. $breakOnError = !it.opts.allErrors,
  18037. $closingBraces1 = '',
  18038. $closingBraces2 = '';
  18039. var $errorKeyword;
  18040. var $typeSchema = it.schema.type,
  18041. $typeIsArray = Array.isArray($typeSchema);
  18042. if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
  18043. if ($typeIsArray) {
  18044. if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null');
  18045. } else if ($typeSchema != 'null') {
  18046. $typeSchema = [$typeSchema, 'null'];
  18047. $typeIsArray = true;
  18048. }
  18049. }
  18050. if ($typeIsArray && $typeSchema.length == 1) {
  18051. $typeSchema = $typeSchema[0];
  18052. $typeIsArray = false;
  18053. }
  18054. if (it.schema.$ref && $refKeywords) {
  18055. if (it.opts.extendRefs == 'fail') {
  18056. throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
  18057. } else if (it.opts.extendRefs !== true) {
  18058. $refKeywords = false;
  18059. it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
  18060. }
  18061. }
  18062. if (it.schema.$comment && it.opts.$comment) {
  18063. out += ' ' + it.RULES.all.$comment.code(it, '$comment');
  18064. }
  18065. if ($typeSchema) {
  18066. if (it.opts.coerceTypes) {
  18067. var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
  18068. }
  18069. var $rulesGroup = it.RULES.types[$typeSchema];
  18070. if ($coerceToTypes || $typeIsArray || $rulesGroup === true || $rulesGroup && !$shouldUseGroup($rulesGroup)) {
  18071. var $schemaPath = it.schemaPath + '.type',
  18072. $errSchemaPath = it.errSchemaPath + '/type';
  18073. var $schemaPath = it.schemaPath + '.type',
  18074. $errSchemaPath = it.errSchemaPath + '/type',
  18075. $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
  18076. out += ' if (' + it.util[$method]($typeSchema, $data, true) + ') { ';
  18077. if ($coerceToTypes) {
  18078. var $dataType = 'dataType' + $lvl,
  18079. $coerced = 'coerced' + $lvl;
  18080. out += ' var ' + $dataType + ' = typeof ' + $data + '; ';
  18081. if (it.opts.coerceTypes == 'array') {
  18082. out += ' if (' + $dataType + ' == \'object\' && Array.isArray(' + $data + ')) ' + $dataType + ' = \'array\'; ';
  18083. }
  18084. out += ' var ' + $coerced + ' = undefined; ';
  18085. var $bracesCoercion = '';
  18086. var arr1 = $coerceToTypes;
  18087. if (arr1) {
  18088. var $type,
  18089. $i = -1,
  18090. l1 = arr1.length - 1;
  18091. while ($i < l1) {
  18092. $type = arr1[$i += 1];
  18093. if ($i) {
  18094. out += ' if (' + $coerced + ' === undefined) { ';
  18095. $bracesCoercion += '}';
  18096. }
  18097. if (it.opts.coerceTypes == 'array' && $type != 'array') {
  18098. out += ' if (' + $dataType + ' == \'array\' && ' + $data + '.length == 1) { ' + $coerced + ' = ' + $data + ' = ' + $data + '[0]; ' + $dataType + ' = typeof ' + $data + '; } ';
  18099. }
  18100. if ($type == 'string') {
  18101. out += ' if (' + $dataType + ' == \'number\' || ' + $dataType + ' == \'boolean\') ' + $coerced + ' = \'\' + ' + $data + '; else if (' + $data + ' === null) ' + $coerced + ' = \'\'; ';
  18102. } else if ($type == 'number' || $type == 'integer') {
  18103. out += ' if (' + $dataType + ' == \'boolean\' || ' + $data + ' === null || (' + $dataType + ' == \'string\' && ' + $data + ' && ' + $data + ' == +' + $data + ' ';
  18104. if ($type == 'integer') {
  18105. out += ' && !(' + $data + ' % 1)';
  18106. }
  18107. out += ')) ' + $coerced + ' = +' + $data + '; ';
  18108. } else if ($type == 'boolean') {
  18109. out += ' if (' + $data + ' === \'false\' || ' + $data + ' === 0 || ' + $data + ' === null) ' + $coerced + ' = false; else if (' + $data + ' === \'true\' || ' + $data + ' === 1) ' + $coerced + ' = true; ';
  18110. } else if ($type == 'null') {
  18111. out += ' if (' + $data + ' === \'\' || ' + $data + ' === 0 || ' + $data + ' === false) ' + $coerced + ' = null; ';
  18112. } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
  18113. out += ' if (' + $dataType + ' == \'string\' || ' + $dataType + ' == \'number\' || ' + $dataType + ' == \'boolean\' || ' + $data + ' == null) ' + $coerced + ' = [' + $data + ']; ';
  18114. }
  18115. }
  18116. }
  18117. out += ' ' + $bracesCoercion + ' if (' + $coerced + ' === undefined) { ';
  18118. var $$outStack = $$outStack || [];
  18119. $$outStack.push(out);
  18120. out = ''; /* istanbul ignore else */
  18121. if (it.createErrors !== false) {
  18122. out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
  18123. if ($typeIsArray) {
  18124. out += '' + $typeSchema.join(",");
  18125. } else {
  18126. out += '' + $typeSchema;
  18127. }
  18128. out += '\' } ';
  18129. if (it.opts.messages !== false) {
  18130. out += ' , message: \'should be ';
  18131. if ($typeIsArray) {
  18132. out += '' + $typeSchema.join(",");
  18133. } else {
  18134. out += '' + $typeSchema;
  18135. }
  18136. out += '\' ';
  18137. }
  18138. if (it.opts.verbose) {
  18139. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  18140. }
  18141. out += ' } ';
  18142. } else {
  18143. out += ' {} ';
  18144. }
  18145. var __err = out;
  18146. out = $$outStack.pop();
  18147. if (!it.compositeRule && $breakOnError) {
  18148. /* istanbul ignore if */
  18149. if (it.async) {
  18150. out += ' throw new ValidationError([' + __err + ']); ';
  18151. } else {
  18152. out += ' validate.errors = [' + __err + ']; return false; ';
  18153. }
  18154. } else {
  18155. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  18156. }
  18157. out += ' } else { ';
  18158. var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
  18159. $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
  18160. out += ' ' + $data + ' = ' + $coerced + '; ';
  18161. if (!$dataLvl) {
  18162. out += 'if (' + $parentData + ' !== undefined)';
  18163. }
  18164. out += ' ' + $parentData + '[' + $parentDataProperty + '] = ' + $coerced + '; } ';
  18165. } else {
  18166. var $$outStack = $$outStack || [];
  18167. $$outStack.push(out);
  18168. out = ''; /* istanbul ignore else */
  18169. if (it.createErrors !== false) {
  18170. out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
  18171. if ($typeIsArray) {
  18172. out += '' + $typeSchema.join(",");
  18173. } else {
  18174. out += '' + $typeSchema;
  18175. }
  18176. out += '\' } ';
  18177. if (it.opts.messages !== false) {
  18178. out += ' , message: \'should be ';
  18179. if ($typeIsArray) {
  18180. out += '' + $typeSchema.join(",");
  18181. } else {
  18182. out += '' + $typeSchema;
  18183. }
  18184. out += '\' ';
  18185. }
  18186. if (it.opts.verbose) {
  18187. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  18188. }
  18189. out += ' } ';
  18190. } else {
  18191. out += ' {} ';
  18192. }
  18193. var __err = out;
  18194. out = $$outStack.pop();
  18195. if (!it.compositeRule && $breakOnError) {
  18196. /* istanbul ignore if */
  18197. if (it.async) {
  18198. out += ' throw new ValidationError([' + __err + ']); ';
  18199. } else {
  18200. out += ' validate.errors = [' + __err + ']; return false; ';
  18201. }
  18202. } else {
  18203. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  18204. }
  18205. }
  18206. out += ' } ';
  18207. }
  18208. }
  18209. if (it.schema.$ref && !$refKeywords) {
  18210. out += ' ' + it.RULES.all.$ref.code(it, '$ref') + ' ';
  18211. if ($breakOnError) {
  18212. out += ' } if (errors === ';
  18213. if ($top) {
  18214. out += '0';
  18215. } else {
  18216. out += 'errs_' + $lvl;
  18217. }
  18218. out += ') { ';
  18219. $closingBraces2 += '}';
  18220. }
  18221. } else {
  18222. var arr2 = it.RULES;
  18223. if (arr2) {
  18224. var $rulesGroup,
  18225. i2 = -1,
  18226. l2 = arr2.length - 1;
  18227. while (i2 < l2) {
  18228. $rulesGroup = arr2[i2 += 1];
  18229. if ($shouldUseGroup($rulesGroup)) {
  18230. if ($rulesGroup.type) {
  18231. out += ' if (' + it.util.checkDataType($rulesGroup.type, $data) + ') { ';
  18232. }
  18233. if (it.opts.useDefaults && !it.compositeRule) {
  18234. if ($rulesGroup.type == 'object' && it.schema.properties) {
  18235. var $schema = it.schema.properties,
  18236. $schemaKeys = Object.keys($schema);
  18237. var arr3 = $schemaKeys;
  18238. if (arr3) {
  18239. var $propertyKey,
  18240. i3 = -1,
  18241. l3 = arr3.length - 1;
  18242. while (i3 < l3) {
  18243. $propertyKey = arr3[i3 += 1];
  18244. var $sch = $schema[$propertyKey];
  18245. if ($sch.default !== undefined) {
  18246. var $passData = $data + it.util.getProperty($propertyKey);
  18247. out += ' if (' + $passData + ' === undefined) ' + $passData + ' = ';
  18248. if (it.opts.useDefaults == 'shared') {
  18249. out += ' ' + it.useDefault($sch.default) + ' ';
  18250. } else {
  18251. out += ' ' + JSON.stringify($sch.default) + ' ';
  18252. }
  18253. out += '; ';
  18254. }
  18255. }
  18256. }
  18257. } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) {
  18258. var arr4 = it.schema.items;
  18259. if (arr4) {
  18260. var $sch,
  18261. $i = -1,
  18262. l4 = arr4.length - 1;
  18263. while ($i < l4) {
  18264. $sch = arr4[$i += 1];
  18265. if ($sch.default !== undefined) {
  18266. var $passData = $data + '[' + $i + ']';
  18267. out += ' if (' + $passData + ' === undefined) ' + $passData + ' = ';
  18268. if (it.opts.useDefaults == 'shared') {
  18269. out += ' ' + it.useDefault($sch.default) + ' ';
  18270. } else {
  18271. out += ' ' + JSON.stringify($sch.default) + ' ';
  18272. }
  18273. out += '; ';
  18274. }
  18275. }
  18276. }
  18277. }
  18278. }
  18279. var arr5 = $rulesGroup.rules;
  18280. if (arr5) {
  18281. var $rule,
  18282. i5 = -1,
  18283. l5 = arr5.length - 1;
  18284. while (i5 < l5) {
  18285. $rule = arr5[i5 += 1];
  18286. if ($shouldUseRule($rule)) {
  18287. var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
  18288. if ($code) {
  18289. out += ' ' + $code + ' ';
  18290. if ($breakOnError) {
  18291. $closingBraces1 += '}';
  18292. }
  18293. }
  18294. }
  18295. }
  18296. }
  18297. if ($breakOnError) {
  18298. out += ' ' + $closingBraces1 + ' ';
  18299. $closingBraces1 = '';
  18300. }
  18301. if ($rulesGroup.type) {
  18302. out += ' } ';
  18303. if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
  18304. out += ' else { ';
  18305. var $schemaPath = it.schemaPath + '.type',
  18306. $errSchemaPath = it.errSchemaPath + '/type';
  18307. var $$outStack = $$outStack || [];
  18308. $$outStack.push(out);
  18309. out = ''; /* istanbul ignore else */
  18310. if (it.createErrors !== false) {
  18311. out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
  18312. if ($typeIsArray) {
  18313. out += '' + $typeSchema.join(",");
  18314. } else {
  18315. out += '' + $typeSchema;
  18316. }
  18317. out += '\' } ';
  18318. if (it.opts.messages !== false) {
  18319. out += ' , message: \'should be ';
  18320. if ($typeIsArray) {
  18321. out += '' + $typeSchema.join(",");
  18322. } else {
  18323. out += '' + $typeSchema;
  18324. }
  18325. out += '\' ';
  18326. }
  18327. if (it.opts.verbose) {
  18328. out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
  18329. }
  18330. out += ' } ';
  18331. } else {
  18332. out += ' {} ';
  18333. }
  18334. var __err = out;
  18335. out = $$outStack.pop();
  18336. if (!it.compositeRule && $breakOnError) {
  18337. /* istanbul ignore if */
  18338. if (it.async) {
  18339. out += ' throw new ValidationError([' + __err + ']); ';
  18340. } else {
  18341. out += ' validate.errors = [' + __err + ']; return false; ';
  18342. }
  18343. } else {
  18344. out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
  18345. }
  18346. out += ' } ';
  18347. }
  18348. }
  18349. if ($breakOnError) {
  18350. out += ' if (errors === ';
  18351. if ($top) {
  18352. out += '0';
  18353. } else {
  18354. out += 'errs_' + $lvl;
  18355. }
  18356. out += ') { ';
  18357. $closingBraces2 += '}';
  18358. }
  18359. }
  18360. }
  18361. }
  18362. }
  18363. if ($breakOnError) {
  18364. out += ' ' + $closingBraces2 + ' ';
  18365. }
  18366. if ($top) {
  18367. if ($async) {
  18368. out += ' if (errors === 0) return data; ';
  18369. out += ' else throw new ValidationError(vErrors); ';
  18370. } else {
  18371. out += ' validate.errors = vErrors; ';
  18372. out += ' return errors === 0; ';
  18373. }
  18374. out += ' }; return validate;';
  18375. } else {
  18376. out += ' var ' + $valid + ' = errors === errs_' + $lvl + ';';
  18377. }
  18378. out = it.util.cleanUpCode(out);
  18379. if ($top) {
  18380. out = it.util.finalCleanUpCode(out, $async);
  18381. }
  18382. function $shouldUseGroup($rulesGroup) {
  18383. var rules = $rulesGroup.rules;
  18384. for (var i = 0; i < rules.length; i++) {
  18385. if ($shouldUseRule(rules[i])) return true;
  18386. }
  18387. }
  18388. function $shouldUseRule($rule) {
  18389. return it.schema[$rule.keyword] !== undefined || $rule.implements && $ruleImplementsSomeKeyword($rule);
  18390. }
  18391. function $ruleImplementsSomeKeyword($rule) {
  18392. var impl = $rule.implements;
  18393. for (var i = 0; i < impl.length; i++) {
  18394. if (it.schema[impl[i]] !== undefined) return true;
  18395. }
  18396. }
  18397. return out;
  18398. };
  18399. },{}],42:[function(require,module,exports){
  18400. 'use strict';
  18401. var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
  18402. var customRuleCode = require('./dotjs/custom');
  18403. module.exports = {
  18404. add: addKeyword,
  18405. get: getKeyword,
  18406. remove: removeKeyword
  18407. };
  18408. /**
  18409. * Define custom keyword
  18410. * @this Ajv
  18411. * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords).
  18412. * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
  18413. * @return {Ajv} this for method chaining
  18414. */
  18415. function addKeyword(keyword, definition) {
  18416. /* jshint validthis: true */
  18417. /* eslint no-shadow: 0 */
  18418. var RULES = this.RULES;
  18419. if (RULES.keywords[keyword]) throw new Error('Keyword ' + keyword + ' is already defined');
  18420. if (!IDENTIFIER.test(keyword)) throw new Error('Keyword ' + keyword + ' is not a valid identifier');
  18421. if (definition) {
  18422. if (definition.macro && definition.valid !== undefined) throw new Error('"valid" option cannot be used with macro keywords');
  18423. var dataType = definition.type;
  18424. if (Array.isArray(dataType)) {
  18425. var i,
  18426. len = dataType.length;
  18427. for (i = 0; i < len; i++) {
  18428. checkDataType(dataType[i]);
  18429. }for (i = 0; i < len; i++) {
  18430. _addRule(keyword, dataType[i], definition);
  18431. }
  18432. } else {
  18433. if (dataType) checkDataType(dataType);
  18434. _addRule(keyword, dataType, definition);
  18435. }
  18436. var $data = definition.$data === true && this._opts.$data;
  18437. if ($data && !definition.validate) throw new Error('$data support: "validate" function is not defined');
  18438. var metaSchema = definition.metaSchema;
  18439. if (metaSchema) {
  18440. if ($data) {
  18441. metaSchema = {
  18442. anyOf: [metaSchema, { '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' }]
  18443. };
  18444. }
  18445. definition.validateSchema = this.compile(metaSchema, true);
  18446. }
  18447. }
  18448. RULES.keywords[keyword] = RULES.all[keyword] = true;
  18449. function _addRule(keyword, dataType, definition) {
  18450. var ruleGroup;
  18451. for (var i = 0; i < RULES.length; i++) {
  18452. var rg = RULES[i];
  18453. if (rg.type == dataType) {
  18454. ruleGroup = rg;
  18455. break;
  18456. }
  18457. }
  18458. if (!ruleGroup) {
  18459. ruleGroup = { type: dataType, rules: [] };
  18460. RULES.push(ruleGroup);
  18461. }
  18462. var rule = {
  18463. keyword: keyword,
  18464. definition: definition,
  18465. custom: true,
  18466. code: customRuleCode,
  18467. implements: definition.implements
  18468. };
  18469. ruleGroup.rules.push(rule);
  18470. RULES.custom[keyword] = rule;
  18471. }
  18472. function checkDataType(dataType) {
  18473. if (!RULES.types[dataType]) throw new Error('Unknown type ' + dataType);
  18474. }
  18475. return this;
  18476. }
  18477. /**
  18478. * Get keyword
  18479. * @this Ajv
  18480. * @param {String} keyword pre-defined or custom keyword.
  18481. * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
  18482. */
  18483. function getKeyword(keyword) {
  18484. /* jshint validthis: true */
  18485. var rule = this.RULES.custom[keyword];
  18486. return rule ? rule.definition : this.RULES.keywords[keyword] || false;
  18487. }
  18488. /**
  18489. * Remove keyword
  18490. * @this Ajv
  18491. * @param {String} keyword pre-defined or custom keyword.
  18492. * @return {Ajv} this for method chaining
  18493. */
  18494. function removeKeyword(keyword) {
  18495. /* jshint validthis: true */
  18496. var RULES = this.RULES;
  18497. delete RULES.keywords[keyword];
  18498. delete RULES.all[keyword];
  18499. delete RULES.custom[keyword];
  18500. for (var i = 0; i < RULES.length; i++) {
  18501. var rules = RULES[i].rules;
  18502. for (var j = 0; j < rules.length; j++) {
  18503. if (rules[j].keyword == keyword) {
  18504. rules.splice(j, 1);
  18505. break;
  18506. }
  18507. }
  18508. }
  18509. return this;
  18510. }
  18511. },{"./dotjs/custom":25}],43:[function(require,module,exports){
  18512. module.exports={
  18513. "$schema": "http://json-schema.org/draft-07/schema#",
  18514. "$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#",
  18515. "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
  18516. "type": "object",
  18517. "required": [ "$data" ],
  18518. "properties": {
  18519. "$data": {
  18520. "type": "string",
  18521. "anyOf": [
  18522. { "format": "relative-json-pointer" },
  18523. { "format": "json-pointer" }
  18524. ]
  18525. }
  18526. },
  18527. "additionalProperties": false
  18528. }
  18529. },{}],44:[function(require,module,exports){
  18530. module.exports={
  18531. "id": "http://json-schema.org/draft-04/schema#",
  18532. "$schema": "http://json-schema.org/draft-04/schema#",
  18533. "description": "Core schema meta-schema",
  18534. "definitions": {
  18535. "schemaArray": {
  18536. "type": "array",
  18537. "minItems": 1,
  18538. "items": { "$ref": "#" }
  18539. },
  18540. "positiveInteger": {
  18541. "type": "integer",
  18542. "minimum": 0
  18543. },
  18544. "positiveIntegerDefault0": {
  18545. "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
  18546. },
  18547. "simpleTypes": {
  18548. "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
  18549. },
  18550. "stringArray": {
  18551. "type": "array",
  18552. "items": { "type": "string" },
  18553. "minItems": 1,
  18554. "uniqueItems": true
  18555. }
  18556. },
  18557. "type": "object",
  18558. "properties": {
  18559. "id": {
  18560. "type": "string"
  18561. },
  18562. "$schema": {
  18563. "type": "string"
  18564. },
  18565. "title": {
  18566. "type": "string"
  18567. },
  18568. "description": {
  18569. "type": "string"
  18570. },
  18571. "default": {},
  18572. "multipleOf": {
  18573. "type": "number",
  18574. "minimum": 0,
  18575. "exclusiveMinimum": true
  18576. },
  18577. "maximum": {
  18578. "type": "number"
  18579. },
  18580. "exclusiveMaximum": {
  18581. "type": "boolean",
  18582. "default": false
  18583. },
  18584. "minimum": {
  18585. "type": "number"
  18586. },
  18587. "exclusiveMinimum": {
  18588. "type": "boolean",
  18589. "default": false
  18590. },
  18591. "maxLength": { "$ref": "#/definitions/positiveInteger" },
  18592. "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
  18593. "pattern": {
  18594. "type": "string",
  18595. "format": "regex"
  18596. },
  18597. "additionalItems": {
  18598. "anyOf": [
  18599. { "type": "boolean" },
  18600. { "$ref": "#" }
  18601. ],
  18602. "default": {}
  18603. },
  18604. "items": {
  18605. "anyOf": [
  18606. { "$ref": "#" },
  18607. { "$ref": "#/definitions/schemaArray" }
  18608. ],
  18609. "default": {}
  18610. },
  18611. "maxItems": { "$ref": "#/definitions/positiveInteger" },
  18612. "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
  18613. "uniqueItems": {
  18614. "type": "boolean",
  18615. "default": false
  18616. },
  18617. "maxProperties": { "$ref": "#/definitions/positiveInteger" },
  18618. "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
  18619. "required": { "$ref": "#/definitions/stringArray" },
  18620. "additionalProperties": {
  18621. "anyOf": [
  18622. { "type": "boolean" },
  18623. { "$ref": "#" }
  18624. ],
  18625. "default": {}
  18626. },
  18627. "definitions": {
  18628. "type": "object",
  18629. "additionalProperties": { "$ref": "#" },
  18630. "default": {}
  18631. },
  18632. "properties": {
  18633. "type": "object",
  18634. "additionalProperties": { "$ref": "#" },
  18635. "default": {}
  18636. },
  18637. "patternProperties": {
  18638. "type": "object",
  18639. "additionalProperties": { "$ref": "#" },
  18640. "default": {}
  18641. },
  18642. "dependencies": {
  18643. "type": "object",
  18644. "additionalProperties": {
  18645. "anyOf": [
  18646. { "$ref": "#" },
  18647. { "$ref": "#/definitions/stringArray" }
  18648. ]
  18649. }
  18650. },
  18651. "enum": {
  18652. "type": "array",
  18653. "minItems": 1,
  18654. "uniqueItems": true
  18655. },
  18656. "type": {
  18657. "anyOf": [
  18658. { "$ref": "#/definitions/simpleTypes" },
  18659. {
  18660. "type": "array",
  18661. "items": { "$ref": "#/definitions/simpleTypes" },
  18662. "minItems": 1,
  18663. "uniqueItems": true
  18664. }
  18665. ]
  18666. },
  18667. "format": { "type": "string" },
  18668. "allOf": { "$ref": "#/definitions/schemaArray" },
  18669. "anyOf": { "$ref": "#/definitions/schemaArray" },
  18670. "oneOf": { "$ref": "#/definitions/schemaArray" },
  18671. "not": { "$ref": "#" }
  18672. },
  18673. "dependencies": {
  18674. "exclusiveMaximum": [ "maximum" ],
  18675. "exclusiveMinimum": [ "minimum" ]
  18676. },
  18677. "default": {}
  18678. }
  18679. },{}],45:[function(require,module,exports){
  18680. module.exports={
  18681. "$schema": "http://json-schema.org/draft-07/schema#",
  18682. "$id": "http://json-schema.org/draft-07/schema#",
  18683. "title": "Core schema meta-schema",
  18684. "definitions": {
  18685. "schemaArray": {
  18686. "type": "array",
  18687. "minItems": 1,
  18688. "items": { "$ref": "#" }
  18689. },
  18690. "nonNegativeInteger": {
  18691. "type": "integer",
  18692. "minimum": 0
  18693. },
  18694. "nonNegativeIntegerDefault0": {
  18695. "allOf": [
  18696. { "$ref": "#/definitions/nonNegativeInteger" },
  18697. { "default": 0 }
  18698. ]
  18699. },
  18700. "simpleTypes": {
  18701. "enum": [
  18702. "array",
  18703. "boolean",
  18704. "integer",
  18705. "null",
  18706. "number",
  18707. "object",
  18708. "string"
  18709. ]
  18710. },
  18711. "stringArray": {
  18712. "type": "array",
  18713. "items": { "type": "string" },
  18714. "uniqueItems": true,
  18715. "default": []
  18716. }
  18717. },
  18718. "type": ["object", "boolean"],
  18719. "properties": {
  18720. "$id": {
  18721. "type": "string",
  18722. "format": "uri-reference"
  18723. },
  18724. "$schema": {
  18725. "type": "string",
  18726. "format": "uri"
  18727. },
  18728. "$ref": {
  18729. "type": "string",
  18730. "format": "uri-reference"
  18731. },
  18732. "$comment": {
  18733. "type": "string"
  18734. },
  18735. "title": {
  18736. "type": "string"
  18737. },
  18738. "description": {
  18739. "type": "string"
  18740. },
  18741. "default": true,
  18742. "readOnly": {
  18743. "type": "boolean",
  18744. "default": false
  18745. },
  18746. "examples": {
  18747. "type": "array",
  18748. "items": true
  18749. },
  18750. "multipleOf": {
  18751. "type": "number",
  18752. "exclusiveMinimum": 0
  18753. },
  18754. "maximum": {
  18755. "type": "number"
  18756. },
  18757. "exclusiveMaximum": {
  18758. "type": "number"
  18759. },
  18760. "minimum": {
  18761. "type": "number"
  18762. },
  18763. "exclusiveMinimum": {
  18764. "type": "number"
  18765. },
  18766. "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
  18767. "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  18768. "pattern": {
  18769. "type": "string",
  18770. "format": "regex"
  18771. },
  18772. "additionalItems": { "$ref": "#" },
  18773. "items": {
  18774. "anyOf": [
  18775. { "$ref": "#" },
  18776. { "$ref": "#/definitions/schemaArray" }
  18777. ],
  18778. "default": true
  18779. },
  18780. "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
  18781. "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  18782. "uniqueItems": {
  18783. "type": "boolean",
  18784. "default": false
  18785. },
  18786. "contains": { "$ref": "#" },
  18787. "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
  18788. "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  18789. "required": { "$ref": "#/definitions/stringArray" },
  18790. "additionalProperties": { "$ref": "#" },
  18791. "definitions": {
  18792. "type": "object",
  18793. "additionalProperties": { "$ref": "#" },
  18794. "default": {}
  18795. },
  18796. "properties": {
  18797. "type": "object",
  18798. "additionalProperties": { "$ref": "#" },
  18799. "default": {}
  18800. },
  18801. "patternProperties": {
  18802. "type": "object",
  18803. "additionalProperties": { "$ref": "#" },
  18804. "propertyNames": { "format": "regex" },
  18805. "default": {}
  18806. },
  18807. "dependencies": {
  18808. "type": "object",
  18809. "additionalProperties": {
  18810. "anyOf": [
  18811. { "$ref": "#" },
  18812. { "$ref": "#/definitions/stringArray" }
  18813. ]
  18814. }
  18815. },
  18816. "propertyNames": { "$ref": "#" },
  18817. "const": true,
  18818. "enum": {
  18819. "type": "array",
  18820. "items": true,
  18821. "minItems": 1,
  18822. "uniqueItems": true
  18823. },
  18824. "type": {
  18825. "anyOf": [
  18826. { "$ref": "#/definitions/simpleTypes" },
  18827. {
  18828. "type": "array",
  18829. "items": { "$ref": "#/definitions/simpleTypes" },
  18830. "minItems": 1,
  18831. "uniqueItems": true
  18832. }
  18833. ]
  18834. },
  18835. "format": { "type": "string" },
  18836. "contentMediaType": { "type": "string" },
  18837. "contentEncoding": { "type": "string" },
  18838. "if": {"$ref": "#"},
  18839. "then": {"$ref": "#"},
  18840. "else": {"$ref": "#"},
  18841. "allOf": { "$ref": "#/definitions/schemaArray" },
  18842. "anyOf": { "$ref": "#/definitions/schemaArray" },
  18843. "oneOf": { "$ref": "#/definitions/schemaArray" },
  18844. "not": { "$ref": "#" }
  18845. },
  18846. "default": true
  18847. }
  18848. },{}],46:[function(require,module,exports){
  18849. (function (global){
  18850. 'use strict';
  18851. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  18852. // original notice:
  18853. /*!
  18854. * The buffer module from node.js, for the browser.
  18855. *
  18856. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  18857. * @license MIT
  18858. */
  18859. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  18860. function compare(a, b) {
  18861. if (a === b) {
  18862. return 0;
  18863. }
  18864. var x = a.length;
  18865. var y = b.length;
  18866. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  18867. if (a[i] !== b[i]) {
  18868. x = a[i];
  18869. y = b[i];
  18870. break;
  18871. }
  18872. }
  18873. if (x < y) {
  18874. return -1;
  18875. }
  18876. if (y < x) {
  18877. return 1;
  18878. }
  18879. return 0;
  18880. }
  18881. function isBuffer(b) {
  18882. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  18883. return global.Buffer.isBuffer(b);
  18884. }
  18885. return !!(b != null && b._isBuffer);
  18886. }
  18887. // based on node assert, original notice:
  18888. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  18889. //
  18890. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  18891. //
  18892. // Originally from narwhal.js (http://narwhaljs.org)
  18893. // Copyright (c) 2009 Thomas Robinson <280north.com>
  18894. //
  18895. // Permission is hereby granted, free of charge, to any person obtaining a copy
  18896. // of this software and associated documentation files (the 'Software'), to
  18897. // deal in the Software without restriction, including without limitation the
  18898. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18899. // sell copies of the Software, and to permit persons to whom the Software is
  18900. // furnished to do so, subject to the following conditions:
  18901. //
  18902. // The above copyright notice and this permission notice shall be included in
  18903. // all copies or substantial portions of the Software.
  18904. //
  18905. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18906. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18907. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18908. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  18909. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18910. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18911. var util = require('util/');
  18912. var hasOwn = Object.prototype.hasOwnProperty;
  18913. var pSlice = Array.prototype.slice;
  18914. var functionsHaveNames = function () {
  18915. return function foo() {}.name === 'foo';
  18916. }();
  18917. function pToString(obj) {
  18918. return Object.prototype.toString.call(obj);
  18919. }
  18920. function isView(arrbuf) {
  18921. if (isBuffer(arrbuf)) {
  18922. return false;
  18923. }
  18924. if (typeof global.ArrayBuffer !== 'function') {
  18925. return false;
  18926. }
  18927. if (typeof ArrayBuffer.isView === 'function') {
  18928. return ArrayBuffer.isView(arrbuf);
  18929. }
  18930. if (!arrbuf) {
  18931. return false;
  18932. }
  18933. if (arrbuf instanceof DataView) {
  18934. return true;
  18935. }
  18936. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  18937. return true;
  18938. }
  18939. return false;
  18940. }
  18941. // 1. The assert module provides functions that throw
  18942. // AssertionError's when particular conditions are not met. The
  18943. // assert module must conform to the following interface.
  18944. var assert = module.exports = ok;
  18945. // 2. The AssertionError is defined in assert.
  18946. // new assert.AssertionError({ message: message,
  18947. // actual: actual,
  18948. // expected: expected })
  18949. var regex = /\s*function\s+([^\(\s]*)\s*/;
  18950. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  18951. function getName(func) {
  18952. if (!util.isFunction(func)) {
  18953. return;
  18954. }
  18955. if (functionsHaveNames) {
  18956. return func.name;
  18957. }
  18958. var str = func.toString();
  18959. var match = str.match(regex);
  18960. return match && match[1];
  18961. }
  18962. assert.AssertionError = function AssertionError(options) {
  18963. this.name = 'AssertionError';
  18964. this.actual = options.actual;
  18965. this.expected = options.expected;
  18966. this.operator = options.operator;
  18967. if (options.message) {
  18968. this.message = options.message;
  18969. this.generatedMessage = false;
  18970. } else {
  18971. this.message = getMessage(this);
  18972. this.generatedMessage = true;
  18973. }
  18974. var stackStartFunction = options.stackStartFunction || fail;
  18975. if (Error.captureStackTrace) {
  18976. Error.captureStackTrace(this, stackStartFunction);
  18977. } else {
  18978. // non v8 browsers so we can have a stacktrace
  18979. var err = new Error();
  18980. if (err.stack) {
  18981. var out = err.stack;
  18982. // try to strip useless frames
  18983. var fn_name = getName(stackStartFunction);
  18984. var idx = out.indexOf('\n' + fn_name);
  18985. if (idx >= 0) {
  18986. // once we have located the function frame
  18987. // we need to strip out everything before it (and its line)
  18988. var next_line = out.indexOf('\n', idx + 1);
  18989. out = out.substring(next_line + 1);
  18990. }
  18991. this.stack = out;
  18992. }
  18993. }
  18994. };
  18995. // assert.AssertionError instanceof Error
  18996. util.inherits(assert.AssertionError, Error);
  18997. function truncate(s, n) {
  18998. if (typeof s === 'string') {
  18999. return s.length < n ? s : s.slice(0, n);
  19000. } else {
  19001. return s;
  19002. }
  19003. }
  19004. function inspect(something) {
  19005. if (functionsHaveNames || !util.isFunction(something)) {
  19006. return util.inspect(something);
  19007. }
  19008. var rawname = getName(something);
  19009. var name = rawname ? ': ' + rawname : '';
  19010. return '[Function' + name + ']';
  19011. }
  19012. function getMessage(self) {
  19013. return truncate(inspect(self.actual), 128) + ' ' + self.operator + ' ' + truncate(inspect(self.expected), 128);
  19014. }
  19015. // At present only the three keys mentioned above are used and
  19016. // understood by the spec. Implementations or sub modules can pass
  19017. // other keys to the AssertionError's constructor - they will be
  19018. // ignored.
  19019. // 3. All of the following functions must throw an AssertionError
  19020. // when a corresponding condition is not met, with a message that
  19021. // may be undefined if not provided. All assertion methods provide
  19022. // both the actual and expected values to the assertion error for
  19023. // display purposes.
  19024. function fail(actual, expected, message, operator, stackStartFunction) {
  19025. throw new assert.AssertionError({
  19026. message: message,
  19027. actual: actual,
  19028. expected: expected,
  19029. operator: operator,
  19030. stackStartFunction: stackStartFunction
  19031. });
  19032. }
  19033. // EXTENSION! allows for well behaved errors defined elsewhere.
  19034. assert.fail = fail;
  19035. // 4. Pure assertion tests whether a value is truthy, as determined
  19036. // by !!guard.
  19037. // assert.ok(guard, message_opt);
  19038. // This statement is equivalent to assert.equal(true, !!guard,
  19039. // message_opt);. To test strictly for the value true, use
  19040. // assert.strictEqual(true, guard, message_opt);.
  19041. function ok(value, message) {
  19042. if (!value) fail(value, true, message, '==', assert.ok);
  19043. }
  19044. assert.ok = ok;
  19045. // 5. The equality assertion tests shallow, coercive equality with
  19046. // ==.
  19047. // assert.equal(actual, expected, message_opt);
  19048. assert.equal = function equal(actual, expected, message) {
  19049. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  19050. };
  19051. // 6. The non-equality assertion tests for whether two objects are not equal
  19052. // with != assert.notEqual(actual, expected, message_opt);
  19053. assert.notEqual = function notEqual(actual, expected, message) {
  19054. if (actual == expected) {
  19055. fail(actual, expected, message, '!=', assert.notEqual);
  19056. }
  19057. };
  19058. // 7. The equivalence assertion tests a deep equality relation.
  19059. // assert.deepEqual(actual, expected, message_opt);
  19060. assert.deepEqual = function deepEqual(actual, expected, message) {
  19061. if (!_deepEqual(actual, expected, false)) {
  19062. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  19063. }
  19064. };
  19065. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  19066. if (!_deepEqual(actual, expected, true)) {
  19067. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  19068. }
  19069. };
  19070. function _deepEqual(actual, expected, strict, memos) {
  19071. // 7.1. All identical values are equivalent, as determined by ===.
  19072. if (actual === expected) {
  19073. return true;
  19074. } else if (isBuffer(actual) && isBuffer(expected)) {
  19075. return compare(actual, expected) === 0;
  19076. // 7.2. If the expected value is a Date object, the actual value is
  19077. // equivalent if it is also a Date object that refers to the same time.
  19078. } else if (util.isDate(actual) && util.isDate(expected)) {
  19079. return actual.getTime() === expected.getTime();
  19080. // 7.3 If the expected value is a RegExp object, the actual value is
  19081. // equivalent if it is also a RegExp object with the same source and
  19082. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  19083. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  19084. return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase;
  19085. // 7.4. Other pairs that do not both pass typeof value == 'object',
  19086. // equivalence is determined by ==.
  19087. } else if ((actual === null || (typeof actual === 'undefined' ? 'undefined' : _typeof(actual)) !== 'object') && (expected === null || (typeof expected === 'undefined' ? 'undefined' : _typeof(expected)) !== 'object')) {
  19088. return strict ? actual === expected : actual == expected;
  19089. // If both values are instances of typed arrays, wrap their underlying
  19090. // ArrayBuffers in a Buffer each to increase performance
  19091. // This optimization requires the arrays to have the same type as checked by
  19092. // Object.prototype.toString (aka pToString). Never perform binary
  19093. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  19094. // bit patterns are not identical.
  19095. } else if (isView(actual) && isView(expected) && pToString(actual) === pToString(expected) && !(actual instanceof Float32Array || actual instanceof Float64Array)) {
  19096. return compare(new Uint8Array(actual.buffer), new Uint8Array(expected.buffer)) === 0;
  19097. // 7.5 For all other Object pairs, including Array objects, equivalence is
  19098. // determined by having the same number of owned properties (as verified
  19099. // with Object.prototype.hasOwnProperty.call), the same set of keys
  19100. // (although not necessarily the same order), equivalent values for every
  19101. // corresponding key, and an identical 'prototype' property. Note: this
  19102. // accounts for both named and indexed properties on Arrays.
  19103. } else if (isBuffer(actual) !== isBuffer(expected)) {
  19104. return false;
  19105. } else {
  19106. memos = memos || { actual: [], expected: [] };
  19107. var actualIndex = memos.actual.indexOf(actual);
  19108. if (actualIndex !== -1) {
  19109. if (actualIndex === memos.expected.indexOf(expected)) {
  19110. return true;
  19111. }
  19112. }
  19113. memos.actual.push(actual);
  19114. memos.expected.push(expected);
  19115. return objEquiv(actual, expected, strict, memos);
  19116. }
  19117. }
  19118. function isArguments(object) {
  19119. return Object.prototype.toString.call(object) == '[object Arguments]';
  19120. }
  19121. function objEquiv(a, b, strict, actualVisitedObjects) {
  19122. if (a === null || a === undefined || b === null || b === undefined) return false;
  19123. // if one is a primitive, the other must be same
  19124. if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b;
  19125. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
  19126. var aIsArgs = isArguments(a);
  19127. var bIsArgs = isArguments(b);
  19128. if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs) return false;
  19129. if (aIsArgs) {
  19130. a = pSlice.call(a);
  19131. b = pSlice.call(b);
  19132. return _deepEqual(a, b, strict);
  19133. }
  19134. var ka = objectKeys(a);
  19135. var kb = objectKeys(b);
  19136. var key, i;
  19137. // having the same number of owned properties (keys incorporates
  19138. // hasOwnProperty)
  19139. if (ka.length !== kb.length) return false;
  19140. //the same set of keys (although not necessarily the same order),
  19141. ka.sort();
  19142. kb.sort();
  19143. //~~~cheap key test
  19144. for (i = ka.length - 1; i >= 0; i--) {
  19145. if (ka[i] !== kb[i]) return false;
  19146. }
  19147. //equivalent values for every corresponding key, and
  19148. //~~~possibly expensive deep test
  19149. for (i = ka.length - 1; i >= 0; i--) {
  19150. key = ka[i];
  19151. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) return false;
  19152. }
  19153. return true;
  19154. }
  19155. // 8. The non-equivalence assertion tests for any deep inequality.
  19156. // assert.notDeepEqual(actual, expected, message_opt);
  19157. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  19158. if (_deepEqual(actual, expected, false)) {
  19159. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  19160. }
  19161. };
  19162. assert.notDeepStrictEqual = notDeepStrictEqual;
  19163. function notDeepStrictEqual(actual, expected, message) {
  19164. if (_deepEqual(actual, expected, true)) {
  19165. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  19166. }
  19167. }
  19168. // 9. The strict equality assertion tests strict equality, as determined by ===.
  19169. // assert.strictEqual(actual, expected, message_opt);
  19170. assert.strictEqual = function strictEqual(actual, expected, message) {
  19171. if (actual !== expected) {
  19172. fail(actual, expected, message, '===', assert.strictEqual);
  19173. }
  19174. };
  19175. // 10. The strict non-equality assertion tests for strict inequality, as
  19176. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  19177. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  19178. if (actual === expected) {
  19179. fail(actual, expected, message, '!==', assert.notStrictEqual);
  19180. }
  19181. };
  19182. function expectedException(actual, expected) {
  19183. if (!actual || !expected) {
  19184. return false;
  19185. }
  19186. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  19187. return expected.test(actual);
  19188. }
  19189. try {
  19190. if (actual instanceof expected) {
  19191. return true;
  19192. }
  19193. } catch (e) {
  19194. // Ignore. The instanceof check doesn't work for arrow functions.
  19195. }
  19196. if (Error.isPrototypeOf(expected)) {
  19197. return false;
  19198. }
  19199. return expected.call({}, actual) === true;
  19200. }
  19201. function _tryBlock(block) {
  19202. var error;
  19203. try {
  19204. block();
  19205. } catch (e) {
  19206. error = e;
  19207. }
  19208. return error;
  19209. }
  19210. function _throws(shouldThrow, block, expected, message) {
  19211. var actual;
  19212. if (typeof block !== 'function') {
  19213. throw new TypeError('"block" argument must be a function');
  19214. }
  19215. if (typeof expected === 'string') {
  19216. message = expected;
  19217. expected = null;
  19218. }
  19219. actual = _tryBlock(block);
  19220. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.');
  19221. if (shouldThrow && !actual) {
  19222. fail(actual, expected, 'Missing expected exception' + message);
  19223. }
  19224. var userProvidedMessage = typeof message === 'string';
  19225. var isUnwantedException = !shouldThrow && util.isError(actual);
  19226. var isUnexpectedException = !shouldThrow && actual && !expected;
  19227. if (isUnwantedException && userProvidedMessage && expectedException(actual, expected) || isUnexpectedException) {
  19228. fail(actual, expected, 'Got unwanted exception' + message);
  19229. }
  19230. if (shouldThrow && actual && expected && !expectedException(actual, expected) || !shouldThrow && actual) {
  19231. throw actual;
  19232. }
  19233. }
  19234. // 11. Expected to throw an error:
  19235. // assert.throws(block, Error_opt, message_opt);
  19236. assert.throws = function (block, /*optional*/error, /*optional*/message) {
  19237. _throws(true, block, error, message);
  19238. };
  19239. // EXTENSION! This is annoying to write outside this module.
  19240. assert.doesNotThrow = function (block, /*optional*/error, /*optional*/message) {
  19241. _throws(false, block, error, message);
  19242. };
  19243. assert.ifError = function (err) {
  19244. if (err) throw err;
  19245. };
  19246. var objectKeys = Object.keys || function (obj) {
  19247. var keys = [];
  19248. for (var key in obj) {
  19249. if (hasOwn.call(obj, key)) keys.push(key);
  19250. }
  19251. return keys;
  19252. };
  19253. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  19254. },{"util/":49}],47:[function(require,module,exports){
  19255. 'use strict';
  19256. if (typeof Object.create === 'function') {
  19257. // implementation from standard node.js 'util' module
  19258. module.exports = function inherits(ctor, superCtor) {
  19259. ctor.super_ = superCtor;
  19260. ctor.prototype = Object.create(superCtor.prototype, {
  19261. constructor: {
  19262. value: ctor,
  19263. enumerable: false,
  19264. writable: true,
  19265. configurable: true
  19266. }
  19267. });
  19268. };
  19269. } else {
  19270. // old school shim for old browsers
  19271. module.exports = function inherits(ctor, superCtor) {
  19272. ctor.super_ = superCtor;
  19273. var TempCtor = function TempCtor() {};
  19274. TempCtor.prototype = superCtor.prototype;
  19275. ctor.prototype = new TempCtor();
  19276. ctor.prototype.constructor = ctor;
  19277. };
  19278. }
  19279. },{}],48:[function(require,module,exports){
  19280. 'use strict';
  19281. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  19282. module.exports = function isBuffer(arg) {
  19283. return arg && (typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function';
  19284. };
  19285. },{}],49:[function(require,module,exports){
  19286. (function (process,global){
  19287. 'use strict';
  19288. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  19289. // Copyright Joyent, Inc. and other Node contributors.
  19290. //
  19291. // Permission is hereby granted, free of charge, to any person obtaining a
  19292. // copy of this software and associated documentation files (the
  19293. // "Software"), to deal in the Software without restriction, including
  19294. // without limitation the rights to use, copy, modify, merge, publish,
  19295. // distribute, sublicense, and/or sell copies of the Software, and to permit
  19296. // persons to whom the Software is furnished to do so, subject to the
  19297. // following conditions:
  19298. //
  19299. // The above copyright notice and this permission notice shall be included
  19300. // in all copies or substantial portions of the Software.
  19301. //
  19302. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19303. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19304. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  19305. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  19306. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19307. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  19308. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  19309. var formatRegExp = /%[sdj%]/g;
  19310. exports.format = function (f) {
  19311. if (!isString(f)) {
  19312. var objects = [];
  19313. for (var i = 0; i < arguments.length; i++) {
  19314. objects.push(inspect(arguments[i]));
  19315. }
  19316. return objects.join(' ');
  19317. }
  19318. var i = 1;
  19319. var args = arguments;
  19320. var len = args.length;
  19321. var str = String(f).replace(formatRegExp, function (x) {
  19322. if (x === '%%') return '%';
  19323. if (i >= len) return x;
  19324. switch (x) {
  19325. case '%s':
  19326. return String(args[i++]);
  19327. case '%d':
  19328. return Number(args[i++]);
  19329. case '%j':
  19330. try {
  19331. return JSON.stringify(args[i++]);
  19332. } catch (_) {
  19333. return '[Circular]';
  19334. }
  19335. default:
  19336. return x;
  19337. }
  19338. });
  19339. for (var x = args[i]; i < len; x = args[++i]) {
  19340. if (isNull(x) || !isObject(x)) {
  19341. str += ' ' + x;
  19342. } else {
  19343. str += ' ' + inspect(x);
  19344. }
  19345. }
  19346. return str;
  19347. };
  19348. // Mark that a method should not be used.
  19349. // Returns a modified function which warns once by default.
  19350. // If --no-deprecation is set, then it is a no-op.
  19351. exports.deprecate = function (fn, msg) {
  19352. // Allow for deprecating things in the process of starting up.
  19353. if (isUndefined(global.process)) {
  19354. return function () {
  19355. return exports.deprecate(fn, msg).apply(this, arguments);
  19356. };
  19357. }
  19358. if (process.noDeprecation === true) {
  19359. return fn;
  19360. }
  19361. var warned = false;
  19362. function deprecated() {
  19363. if (!warned) {
  19364. if (process.throwDeprecation) {
  19365. throw new Error(msg);
  19366. } else if (process.traceDeprecation) {
  19367. console.trace(msg);
  19368. } else {
  19369. console.error(msg);
  19370. }
  19371. warned = true;
  19372. }
  19373. return fn.apply(this, arguments);
  19374. }
  19375. return deprecated;
  19376. };
  19377. var debugs = {};
  19378. var debugEnviron;
  19379. exports.debuglog = function (set) {
  19380. if (isUndefined(debugEnviron)) debugEnviron = process.env.NODE_DEBUG || '';
  19381. set = set.toUpperCase();
  19382. if (!debugs[set]) {
  19383. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  19384. var pid = process.pid;
  19385. debugs[set] = function () {
  19386. var msg = exports.format.apply(exports, arguments);
  19387. console.error('%s %d: %s', set, pid, msg);
  19388. };
  19389. } else {
  19390. debugs[set] = function () {};
  19391. }
  19392. }
  19393. return debugs[set];
  19394. };
  19395. /**
  19396. * Echos the value of a value. Trys to print the value out
  19397. * in the best way possible given the different types.
  19398. *
  19399. * @param {Object} obj The object to print out.
  19400. * @param {Object} opts Optional options object that alters the output.
  19401. */
  19402. /* legacy: obj, showHidden, depth, colors*/
  19403. function inspect(obj, opts) {
  19404. // default options
  19405. var ctx = {
  19406. seen: [],
  19407. stylize: stylizeNoColor
  19408. };
  19409. // legacy...
  19410. if (arguments.length >= 3) ctx.depth = arguments[2];
  19411. if (arguments.length >= 4) ctx.colors = arguments[3];
  19412. if (isBoolean(opts)) {
  19413. // legacy...
  19414. ctx.showHidden = opts;
  19415. } else if (opts) {
  19416. // got an "options" object
  19417. exports._extend(ctx, opts);
  19418. }
  19419. // set default options
  19420. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  19421. if (isUndefined(ctx.depth)) ctx.depth = 2;
  19422. if (isUndefined(ctx.colors)) ctx.colors = false;
  19423. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  19424. if (ctx.colors) ctx.stylize = stylizeWithColor;
  19425. return formatValue(ctx, obj, ctx.depth);
  19426. }
  19427. exports.inspect = inspect;
  19428. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  19429. inspect.colors = {
  19430. 'bold': [1, 22],
  19431. 'italic': [3, 23],
  19432. 'underline': [4, 24],
  19433. 'inverse': [7, 27],
  19434. 'white': [37, 39],
  19435. 'grey': [90, 39],
  19436. 'black': [30, 39],
  19437. 'blue': [34, 39],
  19438. 'cyan': [36, 39],
  19439. 'green': [32, 39],
  19440. 'magenta': [35, 39],
  19441. 'red': [31, 39],
  19442. 'yellow': [33, 39]
  19443. };
  19444. // Don't use 'blue' not visible on cmd.exe
  19445. inspect.styles = {
  19446. 'special': 'cyan',
  19447. 'number': 'yellow',
  19448. 'boolean': 'yellow',
  19449. 'undefined': 'grey',
  19450. 'null': 'bold',
  19451. 'string': 'green',
  19452. 'date': 'magenta',
  19453. // "name": intentionally not styling
  19454. 'regexp': 'red'
  19455. };
  19456. function stylizeWithColor(str, styleType) {
  19457. var style = inspect.styles[styleType];
  19458. if (style) {
  19459. return '\x1B[' + inspect.colors[style][0] + 'm' + str + '\x1B[' + inspect.colors[style][1] + 'm';
  19460. } else {
  19461. return str;
  19462. }
  19463. }
  19464. function stylizeNoColor(str, styleType) {
  19465. return str;
  19466. }
  19467. function arrayToHash(array) {
  19468. var hash = {};
  19469. array.forEach(function (val, idx) {
  19470. hash[val] = true;
  19471. });
  19472. return hash;
  19473. }
  19474. function formatValue(ctx, value, recurseTimes) {
  19475. // Provide a hook for user-specified inspect functions.
  19476. // Check that value is an object with an inspect function on it
  19477. if (ctx.customInspect && value && isFunction(value.inspect) &&
  19478. // Filter out the util module, it's inspect function is special
  19479. value.inspect !== exports.inspect &&
  19480. // Also filter out any prototype objects using the circular check.
  19481. !(value.constructor && value.constructor.prototype === value)) {
  19482. var ret = value.inspect(recurseTimes, ctx);
  19483. if (!isString(ret)) {
  19484. ret = formatValue(ctx, ret, recurseTimes);
  19485. }
  19486. return ret;
  19487. }
  19488. // Primitive types cannot have properties
  19489. var primitive = formatPrimitive(ctx, value);
  19490. if (primitive) {
  19491. return primitive;
  19492. }
  19493. // Look up the keys of the object.
  19494. var keys = Object.keys(value);
  19495. var visibleKeys = arrayToHash(keys);
  19496. if (ctx.showHidden) {
  19497. keys = Object.getOwnPropertyNames(value);
  19498. }
  19499. // IE doesn't make error fields non-enumerable
  19500. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  19501. if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  19502. return formatError(value);
  19503. }
  19504. // Some type of object without properties can be shortcutted.
  19505. if (keys.length === 0) {
  19506. if (isFunction(value)) {
  19507. var name = value.name ? ': ' + value.name : '';
  19508. return ctx.stylize('[Function' + name + ']', 'special');
  19509. }
  19510. if (isRegExp(value)) {
  19511. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  19512. }
  19513. if (isDate(value)) {
  19514. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  19515. }
  19516. if (isError(value)) {
  19517. return formatError(value);
  19518. }
  19519. }
  19520. var base = '',
  19521. array = false,
  19522. braces = ['{', '}'];
  19523. // Make Array say that they are Array
  19524. if (isArray(value)) {
  19525. array = true;
  19526. braces = ['[', ']'];
  19527. }
  19528. // Make functions say that they are functions
  19529. if (isFunction(value)) {
  19530. var n = value.name ? ': ' + value.name : '';
  19531. base = ' [Function' + n + ']';
  19532. }
  19533. // Make RegExps say that they are RegExps
  19534. if (isRegExp(value)) {
  19535. base = ' ' + RegExp.prototype.toString.call(value);
  19536. }
  19537. // Make dates with properties first say the date
  19538. if (isDate(value)) {
  19539. base = ' ' + Date.prototype.toUTCString.call(value);
  19540. }
  19541. // Make error with message first say the error
  19542. if (isError(value)) {
  19543. base = ' ' + formatError(value);
  19544. }
  19545. if (keys.length === 0 && (!array || value.length == 0)) {
  19546. return braces[0] + base + braces[1];
  19547. }
  19548. if (recurseTimes < 0) {
  19549. if (isRegExp(value)) {
  19550. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  19551. } else {
  19552. return ctx.stylize('[Object]', 'special');
  19553. }
  19554. }
  19555. ctx.seen.push(value);
  19556. var output;
  19557. if (array) {
  19558. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  19559. } else {
  19560. output = keys.map(function (key) {
  19561. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  19562. });
  19563. }
  19564. ctx.seen.pop();
  19565. return reduceToSingleString(output, base, braces);
  19566. }
  19567. function formatPrimitive(ctx, value) {
  19568. if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
  19569. if (isString(value)) {
  19570. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
  19571. return ctx.stylize(simple, 'string');
  19572. }
  19573. if (isNumber(value)) return ctx.stylize('' + value, 'number');
  19574. if (isBoolean(value)) return ctx.stylize('' + value, 'boolean');
  19575. // For some reason typeof null is "object", so special case here.
  19576. if (isNull(value)) return ctx.stylize('null', 'null');
  19577. }
  19578. function formatError(value) {
  19579. return '[' + Error.prototype.toString.call(value) + ']';
  19580. }
  19581. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  19582. var output = [];
  19583. for (var i = 0, l = value.length; i < l; ++i) {
  19584. if (hasOwnProperty(value, String(i))) {
  19585. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
  19586. } else {
  19587. output.push('');
  19588. }
  19589. }
  19590. keys.forEach(function (key) {
  19591. if (!key.match(/^\d+$/)) {
  19592. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
  19593. }
  19594. });
  19595. return output;
  19596. }
  19597. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  19598. var name, str, desc;
  19599. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  19600. if (desc.get) {
  19601. if (desc.set) {
  19602. str = ctx.stylize('[Getter/Setter]', 'special');
  19603. } else {
  19604. str = ctx.stylize('[Getter]', 'special');
  19605. }
  19606. } else {
  19607. if (desc.set) {
  19608. str = ctx.stylize('[Setter]', 'special');
  19609. }
  19610. }
  19611. if (!hasOwnProperty(visibleKeys, key)) {
  19612. name = '[' + key + ']';
  19613. }
  19614. if (!str) {
  19615. if (ctx.seen.indexOf(desc.value) < 0) {
  19616. if (isNull(recurseTimes)) {
  19617. str = formatValue(ctx, desc.value, null);
  19618. } else {
  19619. str = formatValue(ctx, desc.value, recurseTimes - 1);
  19620. }
  19621. if (str.indexOf('\n') > -1) {
  19622. if (array) {
  19623. str = str.split('\n').map(function (line) {
  19624. return ' ' + line;
  19625. }).join('\n').substr(2);
  19626. } else {
  19627. str = '\n' + str.split('\n').map(function (line) {
  19628. return ' ' + line;
  19629. }).join('\n');
  19630. }
  19631. }
  19632. } else {
  19633. str = ctx.stylize('[Circular]', 'special');
  19634. }
  19635. }
  19636. if (isUndefined(name)) {
  19637. if (array && key.match(/^\d+$/)) {
  19638. return str;
  19639. }
  19640. name = JSON.stringify('' + key);
  19641. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  19642. name = name.substr(1, name.length - 2);
  19643. name = ctx.stylize(name, 'name');
  19644. } else {
  19645. name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
  19646. name = ctx.stylize(name, 'string');
  19647. }
  19648. }
  19649. return name + ': ' + str;
  19650. }
  19651. function reduceToSingleString(output, base, braces) {
  19652. var numLinesEst = 0;
  19653. var length = output.reduce(function (prev, cur) {
  19654. numLinesEst++;
  19655. if (cur.indexOf('\n') >= 0) numLinesEst++;
  19656. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  19657. }, 0);
  19658. if (length > 60) {
  19659. return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
  19660. }
  19661. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  19662. }
  19663. // NOTE: These type checking functions intentionally don't use `instanceof`
  19664. // because it is fragile and can be easily faked with `Object.create()`.
  19665. function isArray(ar) {
  19666. return Array.isArray(ar);
  19667. }
  19668. exports.isArray = isArray;
  19669. function isBoolean(arg) {
  19670. return typeof arg === 'boolean';
  19671. }
  19672. exports.isBoolean = isBoolean;
  19673. function isNull(arg) {
  19674. return arg === null;
  19675. }
  19676. exports.isNull = isNull;
  19677. function isNullOrUndefined(arg) {
  19678. return arg == null;
  19679. }
  19680. exports.isNullOrUndefined = isNullOrUndefined;
  19681. function isNumber(arg) {
  19682. return typeof arg === 'number';
  19683. }
  19684. exports.isNumber = isNumber;
  19685. function isString(arg) {
  19686. return typeof arg === 'string';
  19687. }
  19688. exports.isString = isString;
  19689. function isSymbol(arg) {
  19690. return (typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'symbol';
  19691. }
  19692. exports.isSymbol = isSymbol;
  19693. function isUndefined(arg) {
  19694. return arg === void 0;
  19695. }
  19696. exports.isUndefined = isUndefined;
  19697. function isRegExp(re) {
  19698. return isObject(re) && objectToString(re) === '[object RegExp]';
  19699. }
  19700. exports.isRegExp = isRegExp;
  19701. function isObject(arg) {
  19702. return (typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object' && arg !== null;
  19703. }
  19704. exports.isObject = isObject;
  19705. function isDate(d) {
  19706. return isObject(d) && objectToString(d) === '[object Date]';
  19707. }
  19708. exports.isDate = isDate;
  19709. function isError(e) {
  19710. return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
  19711. }
  19712. exports.isError = isError;
  19713. function isFunction(arg) {
  19714. return typeof arg === 'function';
  19715. }
  19716. exports.isFunction = isFunction;
  19717. function isPrimitive(arg) {
  19718. return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || (typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'symbol' || // ES6 symbol
  19719. typeof arg === 'undefined';
  19720. }
  19721. exports.isPrimitive = isPrimitive;
  19722. exports.isBuffer = require('./support/isBuffer');
  19723. function objectToString(o) {
  19724. return Object.prototype.toString.call(o);
  19725. }
  19726. function pad(n) {
  19727. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  19728. }
  19729. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
  19730. // 26 Feb 16:19:34
  19731. function timestamp() {
  19732. var d = new Date();
  19733. var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
  19734. return [d.getDate(), months[d.getMonth()], time].join(' ');
  19735. }
  19736. // log is just a thin wrapper to console.log that prepends a timestamp
  19737. exports.log = function () {
  19738. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  19739. };
  19740. /**
  19741. * Inherit the prototype methods from one constructor into another.
  19742. *
  19743. * The Function.prototype.inherits from lang.js rewritten as a standalone
  19744. * function (not on Function.prototype). NOTE: If this file is to be loaded
  19745. * during bootstrapping this function needs to be rewritten using some native
  19746. * functions as prototype setup using normal JavaScript does not work as
  19747. * expected during bootstrapping (see mirror.js in r114903).
  19748. *
  19749. * @param {function} ctor Constructor function which needs to inherit the
  19750. * prototype.
  19751. * @param {function} superCtor Constructor function to inherit prototype from.
  19752. */
  19753. exports.inherits = require('inherits');
  19754. exports._extend = function (origin, add) {
  19755. // Don't do anything if add isn't an object
  19756. if (!add || !isObject(add)) return origin;
  19757. var keys = Object.keys(add);
  19758. var i = keys.length;
  19759. while (i--) {
  19760. origin[keys[i]] = add[keys[i]];
  19761. }
  19762. return origin;
  19763. };
  19764. function hasOwnProperty(obj, prop) {
  19765. return Object.prototype.hasOwnProperty.call(obj, prop);
  19766. }
  19767. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  19768. },{"./support/isBuffer":48,"_process":103,"inherits":47}],50:[function(require,module,exports){
  19769. 'use strict';
  19770. module.exports = balanced;
  19771. function balanced(a, b, str) {
  19772. if (a instanceof RegExp) a = maybeMatch(a, str);
  19773. if (b instanceof RegExp) b = maybeMatch(b, str);
  19774. var r = range(a, b, str);
  19775. return r && {
  19776. start: r[0],
  19777. end: r[1],
  19778. pre: str.slice(0, r[0]),
  19779. body: str.slice(r[0] + a.length, r[1]),
  19780. post: str.slice(r[1] + b.length)
  19781. };
  19782. }
  19783. function maybeMatch(reg, str) {
  19784. var m = str.match(reg);
  19785. return m ? m[0] : null;
  19786. }
  19787. balanced.range = range;
  19788. function range(a, b, str) {
  19789. var begs, beg, left, right, result;
  19790. var ai = str.indexOf(a);
  19791. var bi = str.indexOf(b, ai + 1);
  19792. var i = ai;
  19793. if (ai >= 0 && bi > 0) {
  19794. begs = [];
  19795. left = str.length;
  19796. while (i >= 0 && !result) {
  19797. if (i == ai) {
  19798. begs.push(i);
  19799. ai = str.indexOf(a, i + 1);
  19800. } else if (begs.length == 1) {
  19801. result = [begs.pop(), bi];
  19802. } else {
  19803. beg = begs.pop();
  19804. if (beg < left) {
  19805. left = beg;
  19806. right = bi;
  19807. }
  19808. bi = str.indexOf(b, i + 1);
  19809. }
  19810. i = ai < bi && ai >= 0 ? ai : bi;
  19811. }
  19812. if (begs.length) {
  19813. result = [left, right];
  19814. }
  19815. }
  19816. return result;
  19817. }
  19818. },{}],51:[function(require,module,exports){
  19819. 'use strict';
  19820. var concatMap = require('concat-map');
  19821. var balanced = require('balanced-match');
  19822. module.exports = expandTop;
  19823. var escSlash = '\0SLASH' + Math.random() + '\0';
  19824. var escOpen = '\0OPEN' + Math.random() + '\0';
  19825. var escClose = '\0CLOSE' + Math.random() + '\0';
  19826. var escComma = '\0COMMA' + Math.random() + '\0';
  19827. var escPeriod = '\0PERIOD' + Math.random() + '\0';
  19828. function numeric(str) {
  19829. return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
  19830. }
  19831. function escapeBraces(str) {
  19832. return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
  19833. }
  19834. function unescapeBraces(str) {
  19835. return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
  19836. }
  19837. // Basically just str.split(","), but handling cases
  19838. // where we have nested braced sections, which should be
  19839. // treated as individual members, like {a,{b,c},d}
  19840. function parseCommaParts(str) {
  19841. if (!str) return [''];
  19842. var parts = [];
  19843. var m = balanced('{', '}', str);
  19844. if (!m) return str.split(',');
  19845. var pre = m.pre;
  19846. var body = m.body;
  19847. var post = m.post;
  19848. var p = pre.split(',');
  19849. p[p.length - 1] += '{' + body + '}';
  19850. var postParts = parseCommaParts(post);
  19851. if (post.length) {
  19852. p[p.length - 1] += postParts.shift();
  19853. p.push.apply(p, postParts);
  19854. }
  19855. parts.push.apply(parts, p);
  19856. return parts;
  19857. }
  19858. function expandTop(str) {
  19859. if (!str) return [];
  19860. // I don't know why Bash 4.3 does this, but it does.
  19861. // Anything starting with {} will have the first two bytes preserved
  19862. // but *only* at the top level, so {},a}b will not expand to anything,
  19863. // but a{},b}c will be expanded to [a}c,abc].
  19864. // One could argue that this is a bug in Bash, but since the goal of
  19865. // this module is to match Bash's rules, we escape a leading {}
  19866. if (str.substr(0, 2) === '{}') {
  19867. str = '\\{\\}' + str.substr(2);
  19868. }
  19869. return expand(escapeBraces(str), true).map(unescapeBraces);
  19870. }
  19871. function identity(e) {
  19872. return e;
  19873. }
  19874. function embrace(str) {
  19875. return '{' + str + '}';
  19876. }
  19877. function isPadded(el) {
  19878. return (/^-?0\d/.test(el)
  19879. );
  19880. }
  19881. function lte(i, y) {
  19882. return i <= y;
  19883. }
  19884. function gte(i, y) {
  19885. return i >= y;
  19886. }
  19887. function expand(str, isTop) {
  19888. var expansions = [];
  19889. var m = balanced('{', '}', str);
  19890. if (!m || /\$$/.test(m.pre)) return [str];
  19891. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  19892. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  19893. var isSequence = isNumericSequence || isAlphaSequence;
  19894. var isOptions = m.body.indexOf(',') >= 0;
  19895. if (!isSequence && !isOptions) {
  19896. // {a},b}
  19897. if (m.post.match(/,.*\}/)) {
  19898. str = m.pre + '{' + m.body + escClose + m.post;
  19899. return expand(str);
  19900. }
  19901. return [str];
  19902. }
  19903. var n;
  19904. if (isSequence) {
  19905. n = m.body.split(/\.\./);
  19906. } else {
  19907. n = parseCommaParts(m.body);
  19908. if (n.length === 1) {
  19909. // x{{a,b}}y ==> x{a}y x{b}y
  19910. n = expand(n[0], false).map(embrace);
  19911. if (n.length === 1) {
  19912. var post = m.post.length ? expand(m.post, false) : [''];
  19913. return post.map(function (p) {
  19914. return m.pre + n[0] + p;
  19915. });
  19916. }
  19917. }
  19918. }
  19919. // at this point, n is the parts, and we know it's not a comma set
  19920. // with a single entry.
  19921. // no need to expand pre, since it is guaranteed to be free of brace-sets
  19922. var pre = m.pre;
  19923. var post = m.post.length ? expand(m.post, false) : [''];
  19924. var N;
  19925. if (isSequence) {
  19926. var x = numeric(n[0]);
  19927. var y = numeric(n[1]);
  19928. var width = Math.max(n[0].length, n[1].length);
  19929. var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
  19930. var test = lte;
  19931. var reverse = y < x;
  19932. if (reverse) {
  19933. incr *= -1;
  19934. test = gte;
  19935. }
  19936. var pad = n.some(isPadded);
  19937. N = [];
  19938. for (var i = x; test(i, y); i += incr) {
  19939. var c;
  19940. if (isAlphaSequence) {
  19941. c = String.fromCharCode(i);
  19942. if (c === '\\') c = '';
  19943. } else {
  19944. c = String(i);
  19945. if (pad) {
  19946. var need = width - c.length;
  19947. if (need > 0) {
  19948. var z = new Array(need + 1).join('0');
  19949. if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
  19950. }
  19951. }
  19952. }
  19953. N.push(c);
  19954. }
  19955. } else {
  19956. N = concatMap(n, function (el) {
  19957. return expand(el, false);
  19958. });
  19959. }
  19960. for (var j = 0; j < N.length; j++) {
  19961. for (var k = 0; k < post.length; k++) {
  19962. var expansion = pre + N[j] + post[k];
  19963. if (!isTop || isSequence || expansion) expansions.push(expansion);
  19964. }
  19965. }
  19966. return expansions;
  19967. }
  19968. },{"balanced-match":50,"concat-map":52}],52:[function(require,module,exports){
  19969. 'use strict';
  19970. module.exports = function (xs, fn) {
  19971. var res = [];
  19972. for (var i = 0; i < xs.length; i++) {
  19973. var x = fn(xs[i], i);
  19974. if (isArray(x)) res.push.apply(res, x);else res.push(x);
  19975. }
  19976. return res;
  19977. };
  19978. var isArray = Array.isArray || function (xs) {
  19979. return Object.prototype.toString.call(xs) === '[object Array]';
  19980. };
  19981. },{}],53:[function(require,module,exports){
  19982. (function (process){
  19983. 'use strict';
  19984. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  19985. /* eslint-env browser */
  19986. /**
  19987. * This is the web browser implementation of `debug()`.
  19988. */
  19989. exports.log = log;
  19990. exports.formatArgs = formatArgs;
  19991. exports.save = save;
  19992. exports.load = load;
  19993. exports.useColors = useColors;
  19994. exports.storage = localstorage();
  19995. /**
  19996. * Colors.
  19997. */
  19998. exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
  19999. /**
  20000. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  20001. * and the Firebug extension (any Firefox version) are known
  20002. * to support "%c" CSS customizations.
  20003. *
  20004. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  20005. */
  20006. // eslint-disable-next-line complexity
  20007. function useColors() {
  20008. // NB: In an Electron preload script, document will be defined but not fully
  20009. // initialized. Since we know we're in Chrome, we'll just detect this case
  20010. // explicitly
  20011. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  20012. return true;
  20013. }
  20014. // Internet Explorer and Edge do not support colors.
  20015. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  20016. return false;
  20017. }
  20018. // Is webkit? http://stackoverflow.com/a/16459606/376773
  20019. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  20020. return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance ||
  20021. // Is firebug? http://stackoverflow.com/a/398120/376773
  20022. typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) ||
  20023. // Is firefox >= v31?
  20024. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  20025. typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 ||
  20026. // Double check webkit in userAgent just in case we are in a worker
  20027. typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
  20028. }
  20029. /**
  20030. * Colorize log arguments if enabled.
  20031. *
  20032. * @api public
  20033. */
  20034. function formatArgs(args) {
  20035. args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
  20036. if (!this.useColors) {
  20037. return;
  20038. }
  20039. var c = 'color: ' + this.color;
  20040. args.splice(1, 0, c, 'color: inherit');
  20041. // The final "%c" is somewhat tricky, because there could be other
  20042. // arguments passed either before or after the %c, so we need to
  20043. // figure out the correct index to insert the CSS into
  20044. var index = 0;
  20045. var lastC = 0;
  20046. args[0].replace(/%[a-zA-Z%]/g, function (match) {
  20047. if (match === '%%') {
  20048. return;
  20049. }
  20050. index++;
  20051. if (match === '%c') {
  20052. // We only are interested in the *last* %c
  20053. // (the user may have provided their own)
  20054. lastC = index;
  20055. }
  20056. });
  20057. args.splice(lastC, 0, c);
  20058. }
  20059. /**
  20060. * Invokes `console.log()` when available.
  20061. * No-op when `console.log` is not a "function".
  20062. *
  20063. * @api public
  20064. */
  20065. function log() {
  20066. var _console;
  20067. // This hackery is required for IE8/9, where
  20068. // the `console.log` function doesn't have 'apply'
  20069. return (typeof console === 'undefined' ? 'undefined' : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
  20070. }
  20071. /**
  20072. * Save `namespaces`.
  20073. *
  20074. * @param {String} namespaces
  20075. * @api private
  20076. */
  20077. function save(namespaces) {
  20078. try {
  20079. if (namespaces) {
  20080. exports.storage.setItem('debug', namespaces);
  20081. } else {
  20082. exports.storage.removeItem('debug');
  20083. }
  20084. } catch (error) {
  20085. // Swallow
  20086. // XXX (@Qix-) should we be logging these?
  20087. }
  20088. }
  20089. /**
  20090. * Load `namespaces`.
  20091. *
  20092. * @return {String} returns the previously persisted debug modes
  20093. * @api private
  20094. */
  20095. function load() {
  20096. var r = void 0;
  20097. try {
  20098. r = exports.storage.getItem('debug');
  20099. } catch (error) {}
  20100. // Swallow
  20101. // XXX (@Qix-) should we be logging these?
  20102. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  20103. if (!r && typeof process !== 'undefined' && 'env' in process) {
  20104. r = process.env.DEBUG;
  20105. }
  20106. return r;
  20107. }
  20108. /**
  20109. * Localstorage attempts to return the localstorage.
  20110. *
  20111. * This is necessary because safari throws
  20112. * when a user disables cookies/localstorage
  20113. * and you attempt to access it.
  20114. *
  20115. * @return {LocalStorage}
  20116. * @api private
  20117. */
  20118. function localstorage() {
  20119. try {
  20120. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  20121. // The Browser also has localStorage in the global context.
  20122. return localStorage;
  20123. } catch (error) {
  20124. // Swallow
  20125. // XXX (@Qix-) should we be logging these?
  20126. }
  20127. }
  20128. module.exports = require('./common')(exports);
  20129. var formatters = module.exports.formatters;
  20130. /**
  20131. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  20132. */
  20133. formatters.j = function (v) {
  20134. try {
  20135. return JSON.stringify(v);
  20136. } catch (error) {
  20137. return '[UnexpectedJSONParseError]: ' + error.message;
  20138. }
  20139. };
  20140. }).call(this,require('_process'))
  20141. },{"./common":54,"_process":103}],54:[function(require,module,exports){
  20142. 'use strict';
  20143. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  20144. /**
  20145. * This is the common logic for both the Node.js and web browser
  20146. * implementations of `debug()`.
  20147. */
  20148. function setup(env) {
  20149. createDebug.debug = createDebug;
  20150. createDebug.default = createDebug;
  20151. createDebug.coerce = coerce;
  20152. createDebug.disable = disable;
  20153. createDebug.enable = enable;
  20154. createDebug.enabled = enabled;
  20155. createDebug.humanize = require('ms');
  20156. Object.keys(env).forEach(function (key) {
  20157. createDebug[key] = env[key];
  20158. });
  20159. /**
  20160. * Active `debug` instances.
  20161. */
  20162. createDebug.instances = [];
  20163. /**
  20164. * The currently active debug mode names, and names to skip.
  20165. */
  20166. createDebug.names = [];
  20167. createDebug.skips = [];
  20168. /**
  20169. * Map of special "%n" handling functions, for the debug "format" argument.
  20170. *
  20171. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  20172. */
  20173. createDebug.formatters = {};
  20174. /**
  20175. * Selects a color for a debug namespace
  20176. * @param {String} namespace The namespace string for the for the debug instance to be colored
  20177. * @return {Number|String} An ANSI color code for the given namespace
  20178. * @api private
  20179. */
  20180. function selectColor(namespace) {
  20181. var hash = 0;
  20182. for (var i = 0; i < namespace.length; i++) {
  20183. hash = (hash << 5) - hash + namespace.charCodeAt(i);
  20184. hash |= 0; // Convert to 32bit integer
  20185. }
  20186. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  20187. }
  20188. createDebug.selectColor = selectColor;
  20189. /**
  20190. * Create a debugger with the given `namespace`.
  20191. *
  20192. * @param {String} namespace
  20193. * @return {Function}
  20194. * @api public
  20195. */
  20196. function createDebug(namespace) {
  20197. var prevTime = void 0;
  20198. function debug() {
  20199. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  20200. args[_key] = arguments[_key];
  20201. }
  20202. // Disabled?
  20203. if (!debug.enabled) {
  20204. return;
  20205. }
  20206. var self = debug;
  20207. // Set `diff` timestamp
  20208. var curr = Number(new Date());
  20209. var ms = curr - (prevTime || curr);
  20210. self.diff = ms;
  20211. self.prev = prevTime;
  20212. self.curr = curr;
  20213. prevTime = curr;
  20214. args[0] = createDebug.coerce(args[0]);
  20215. if (typeof args[0] !== 'string') {
  20216. // Anything else let's inspect with %O
  20217. args.unshift('%O');
  20218. }
  20219. // Apply any `formatters` transformations
  20220. var index = 0;
  20221. args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
  20222. // If we encounter an escaped % then don't increase the array index
  20223. if (match === '%%') {
  20224. return match;
  20225. }
  20226. index++;
  20227. var formatter = createDebug.formatters[format];
  20228. if (typeof formatter === 'function') {
  20229. var val = args[index];
  20230. match = formatter.call(self, val);
  20231. // Now we need to remove `args[index]` since it's inlined in the `format`
  20232. args.splice(index, 1);
  20233. index--;
  20234. }
  20235. return match;
  20236. });
  20237. // Apply env-specific formatting (colors, etc.)
  20238. createDebug.formatArgs.call(self, args);
  20239. var logFn = self.log || createDebug.log;
  20240. logFn.apply(self, args);
  20241. }
  20242. debug.namespace = namespace;
  20243. debug.enabled = createDebug.enabled(namespace);
  20244. debug.useColors = createDebug.useColors();
  20245. debug.color = selectColor(namespace);
  20246. debug.destroy = destroy;
  20247. debug.extend = extend;
  20248. // Debug.formatArgs = formatArgs;
  20249. // debug.rawLog = rawLog;
  20250. // env-specific initialization logic for debug instances
  20251. if (typeof createDebug.init === 'function') {
  20252. createDebug.init(debug);
  20253. }
  20254. createDebug.instances.push(debug);
  20255. return debug;
  20256. }
  20257. function destroy() {
  20258. var index = createDebug.instances.indexOf(this);
  20259. if (index !== -1) {
  20260. createDebug.instances.splice(index, 1);
  20261. return true;
  20262. }
  20263. return false;
  20264. }
  20265. function extend(namespace, delimiter) {
  20266. var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  20267. newDebug.log = this.log;
  20268. return newDebug;
  20269. }
  20270. /**
  20271. * Enables a debug mode by namespaces. This can include modes
  20272. * separated by a colon and wildcards.
  20273. *
  20274. * @param {String} namespaces
  20275. * @api public
  20276. */
  20277. function enable(namespaces) {
  20278. createDebug.save(namespaces);
  20279. createDebug.names = [];
  20280. createDebug.skips = [];
  20281. var i = void 0;
  20282. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  20283. var len = split.length;
  20284. for (i = 0; i < len; i++) {
  20285. if (!split[i]) {
  20286. // ignore empty strings
  20287. continue;
  20288. }
  20289. namespaces = split[i].replace(/\*/g, '.*?');
  20290. if (namespaces[0] === '-') {
  20291. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  20292. } else {
  20293. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  20294. }
  20295. }
  20296. for (i = 0; i < createDebug.instances.length; i++) {
  20297. var instance = createDebug.instances[i];
  20298. instance.enabled = createDebug.enabled(instance.namespace);
  20299. }
  20300. }
  20301. /**
  20302. * Disable debug output.
  20303. *
  20304. * @return {String} namespaces
  20305. * @api public
  20306. */
  20307. function disable() {
  20308. var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) {
  20309. return '-' + namespace;
  20310. }))).join(',');
  20311. createDebug.enable('');
  20312. return namespaces;
  20313. }
  20314. /**
  20315. * Returns true if the given mode name is enabled, false otherwise.
  20316. *
  20317. * @param {String} name
  20318. * @return {Boolean}
  20319. * @api public
  20320. */
  20321. function enabled(name) {
  20322. if (name[name.length - 1] === '*') {
  20323. return true;
  20324. }
  20325. var i = void 0;
  20326. var len = void 0;
  20327. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  20328. if (createDebug.skips[i].test(name)) {
  20329. return false;
  20330. }
  20331. }
  20332. for (i = 0, len = createDebug.names.length; i < len; i++) {
  20333. if (createDebug.names[i].test(name)) {
  20334. return true;
  20335. }
  20336. }
  20337. return false;
  20338. }
  20339. /**
  20340. * Convert regexp to namespace
  20341. *
  20342. * @param {RegExp} regxep
  20343. * @return {String} namespace
  20344. * @api private
  20345. */
  20346. function toNamespace(regexp) {
  20347. return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
  20348. }
  20349. /**
  20350. * Coerce `val`.
  20351. *
  20352. * @param {Mixed} val
  20353. * @return {Mixed}
  20354. * @api private
  20355. */
  20356. function coerce(val) {
  20357. if (val instanceof Error) {
  20358. return val.stack || val.message;
  20359. }
  20360. return val;
  20361. }
  20362. createDebug.enable(createDebug.load());
  20363. return createDebug;
  20364. }
  20365. module.exports = setup;
  20366. },{"ms":94}],55:[function(require,module,exports){
  20367. 'use strict';
  20368. /*
  20369. * @fileoverview Main Doctrine object
  20370. * @author Yusuke Suzuki <utatane.tea@gmail.com>
  20371. * @author Dan Tao <daniel.tao@gmail.com>
  20372. * @author Andrew Eisenberg <andrew@eisenberg.as>
  20373. */
  20374. (function () {
  20375. 'use strict';
  20376. var typed, utility, jsdoc, esutils, hasOwnProperty;
  20377. esutils = require('esutils');
  20378. typed = require('./typed');
  20379. utility = require('./utility');
  20380. function sliceSource(source, index, last) {
  20381. return source.slice(index, last);
  20382. }
  20383. hasOwnProperty = function () {
  20384. var func = Object.prototype.hasOwnProperty;
  20385. return function hasOwnProperty(obj, name) {
  20386. return func.call(obj, name);
  20387. };
  20388. }();
  20389. function shallowCopy(obj) {
  20390. var ret = {},
  20391. key;
  20392. for (key in obj) {
  20393. if (obj.hasOwnProperty(key)) {
  20394. ret[key] = obj[key];
  20395. }
  20396. }
  20397. return ret;
  20398. }
  20399. function isASCIIAlphanumeric(ch) {
  20400. return ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */ || ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */ || ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */;
  20401. }
  20402. function isParamTitle(title) {
  20403. return title === 'param' || title === 'argument' || title === 'arg';
  20404. }
  20405. function isReturnTitle(title) {
  20406. return title === 'return' || title === 'returns';
  20407. }
  20408. function isProperty(title) {
  20409. return title === 'property' || title === 'prop';
  20410. }
  20411. function isNameParameterRequired(title) {
  20412. return isParamTitle(title) || isProperty(title) || title === 'alias' || title === 'this' || title === 'mixes' || title === 'requires';
  20413. }
  20414. function isAllowedName(title) {
  20415. return isNameParameterRequired(title) || title === 'const' || title === 'constant';
  20416. }
  20417. function isAllowedNested(title) {
  20418. return isProperty(title) || isParamTitle(title);
  20419. }
  20420. function isAllowedOptional(title) {
  20421. return isProperty(title) || isParamTitle(title);
  20422. }
  20423. function isTypeParameterRequired(title) {
  20424. return isParamTitle(title) || isReturnTitle(title) || title === 'define' || title === 'enum' || title === 'implements' || title === 'this' || title === 'type' || title === 'typedef' || isProperty(title);
  20425. }
  20426. // Consider deprecation instead using 'isTypeParameterRequired' and 'Rules' declaration to pick when a type is optional/required
  20427. // This would require changes to 'parseType'
  20428. function isAllowedType(title) {
  20429. return isTypeParameterRequired(title) || title === 'throws' || title === 'const' || title === 'constant' || title === 'namespace' || title === 'member' || title === 'var' || title === 'module' || title === 'constructor' || title === 'class' || title === 'extends' || title === 'augments' || title === 'public' || title === 'private' || title === 'protected';
  20430. }
  20431. // A regex character class that contains all whitespace except linebreak characters (\r, \n, \u2028, \u2029)
  20432. var WHITESPACE = '[ \\f\\t\\v\\u00a0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]';
  20433. var STAR_MATCHER = '(' + WHITESPACE + '*(?:\\*' + WHITESPACE + '?)?)(.+|[\r\n\u2028\u2029])';
  20434. function unwrapComment(doc) {
  20435. // JSDoc comment is following form
  20436. // /**
  20437. // * .......
  20438. // */
  20439. return doc.
  20440. // remove /**
  20441. replace(/^\/\*\*?/, '').
  20442. // remove */
  20443. replace(/\*\/$/, '').
  20444. // remove ' * ' at the beginning of a line
  20445. replace(new RegExp(STAR_MATCHER, 'g'), '$2').
  20446. // remove trailing whitespace
  20447. replace(/\s*$/, '');
  20448. }
  20449. /**
  20450. * Converts an index in an "unwrapped" JSDoc comment to the corresponding index in the original "wrapped" version
  20451. * @param {string} originalSource The original wrapped comment
  20452. * @param {number} unwrappedIndex The index of a character in the unwrapped string
  20453. * @returns {number} The index of the corresponding character in the original wrapped string
  20454. */
  20455. function convertUnwrappedCommentIndex(originalSource, unwrappedIndex) {
  20456. var replacedSource = originalSource.replace(/^\/\*\*?/, '');
  20457. var numSkippedChars = 0;
  20458. var matcher = new RegExp(STAR_MATCHER, 'g');
  20459. var match;
  20460. while (match = matcher.exec(replacedSource)) {
  20461. numSkippedChars += match[1].length;
  20462. if (match.index + match[0].length > unwrappedIndex + numSkippedChars) {
  20463. return unwrappedIndex + numSkippedChars + originalSource.length - replacedSource.length;
  20464. }
  20465. }
  20466. return originalSource.replace(/\*\/$/, '').replace(/\s*$/, '').length;
  20467. }
  20468. // JSDoc Tag Parser
  20469. (function (exports) {
  20470. var Rules, index, lineNumber, length, source, originalSource, recoverable, sloppy, strict;
  20471. function advance() {
  20472. var ch = source.charCodeAt(index);
  20473. index += 1;
  20474. if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D /* '\r' */ && source.charCodeAt(index) === 0x0A /* '\n' */)) {
  20475. lineNumber += 1;
  20476. }
  20477. return String.fromCharCode(ch);
  20478. }
  20479. function scanTitle() {
  20480. var title = '';
  20481. // waste '@'
  20482. advance();
  20483. while (index < length && isASCIIAlphanumeric(source.charCodeAt(index))) {
  20484. title += advance();
  20485. }
  20486. return title;
  20487. }
  20488. function seekContent() {
  20489. var ch,
  20490. waiting,
  20491. last = index;
  20492. waiting = false;
  20493. while (last < length) {
  20494. ch = source.charCodeAt(last);
  20495. if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D /* '\r' */ && source.charCodeAt(last + 1) === 0x0A /* '\n' */)) {
  20496. waiting = true;
  20497. } else if (waiting) {
  20498. if (ch === 0x40 /* '@' */) {
  20499. break;
  20500. }
  20501. if (!esutils.code.isWhiteSpace(ch)) {
  20502. waiting = false;
  20503. }
  20504. }
  20505. last += 1;
  20506. }
  20507. return last;
  20508. }
  20509. // type expression may have nest brace, such as,
  20510. // { { ok: string } }
  20511. //
  20512. // therefore, scanning type expression with balancing braces.
  20513. function parseType(title, last, addRange) {
  20514. var ch,
  20515. brace,
  20516. type,
  20517. startIndex,
  20518. direct = false;
  20519. // search '{'
  20520. while (index < last) {
  20521. ch = source.charCodeAt(index);
  20522. if (esutils.code.isWhiteSpace(ch)) {
  20523. advance();
  20524. } else if (ch === 0x7B /* '{' */) {
  20525. advance();
  20526. break;
  20527. } else {
  20528. // this is direct pattern
  20529. direct = true;
  20530. break;
  20531. }
  20532. }
  20533. if (direct) {
  20534. return null;
  20535. }
  20536. // type expression { is found
  20537. brace = 1;
  20538. type = '';
  20539. while (index < last) {
  20540. ch = source.charCodeAt(index);
  20541. if (esutils.code.isLineTerminator(ch)) {
  20542. advance();
  20543. } else {
  20544. if (ch === 0x7D /* '}' */) {
  20545. brace -= 1;
  20546. if (brace === 0) {
  20547. advance();
  20548. break;
  20549. }
  20550. } else if (ch === 0x7B /* '{' */) {
  20551. brace += 1;
  20552. }
  20553. if (type === '') {
  20554. startIndex = index;
  20555. }
  20556. type += advance();
  20557. }
  20558. }
  20559. if (brace !== 0) {
  20560. // braces is not balanced
  20561. return utility.throwError('Braces are not balanced');
  20562. }
  20563. if (isAllowedOptional(title)) {
  20564. return typed.parseParamType(type, { startIndex: convertIndex(startIndex), range: addRange });
  20565. }
  20566. return typed.parseType(type, { startIndex: convertIndex(startIndex), range: addRange });
  20567. }
  20568. function scanIdentifier(last) {
  20569. var identifier;
  20570. if (!esutils.code.isIdentifierStartES5(source.charCodeAt(index)) && !source[index].match(/[0-9]/)) {
  20571. return null;
  20572. }
  20573. identifier = advance();
  20574. while (index < last && esutils.code.isIdentifierPartES5(source.charCodeAt(index))) {
  20575. identifier += advance();
  20576. }
  20577. return identifier;
  20578. }
  20579. function skipWhiteSpace(last) {
  20580. while (index < last && (esutils.code.isWhiteSpace(source.charCodeAt(index)) || esutils.code.isLineTerminator(source.charCodeAt(index)))) {
  20581. advance();
  20582. }
  20583. }
  20584. function parseName(last, allowBrackets, allowNestedParams) {
  20585. var name = '',
  20586. useBrackets,
  20587. insideString;
  20588. skipWhiteSpace(last);
  20589. if (index >= last) {
  20590. return null;
  20591. }
  20592. if (source.charCodeAt(index) === 0x5B /* '[' */) {
  20593. if (allowBrackets) {
  20594. useBrackets = true;
  20595. name = advance();
  20596. } else {
  20597. return null;
  20598. }
  20599. }
  20600. name += scanIdentifier(last);
  20601. if (allowNestedParams) {
  20602. if (source.charCodeAt(index) === 0x3A /* ':' */ && (name === 'module' || name === 'external' || name === 'event')) {
  20603. name += advance();
  20604. name += scanIdentifier(last);
  20605. }
  20606. if (source.charCodeAt(index) === 0x5B /* '[' */ && source.charCodeAt(index + 1) === 0x5D /* ']' */) {
  20607. name += advance();
  20608. name += advance();
  20609. }
  20610. while (source.charCodeAt(index) === 0x2E /* '.' */ || source.charCodeAt(index) === 0x2F /* '/' */ || source.charCodeAt(index) === 0x23 /* '#' */ || source.charCodeAt(index) === 0x2D /* '-' */ || source.charCodeAt(index) === 0x7E /* '~' */) {
  20611. name += advance();
  20612. name += scanIdentifier(last);
  20613. }
  20614. }
  20615. if (useBrackets) {
  20616. skipWhiteSpace(last);
  20617. // do we have a default value for this?
  20618. if (source.charCodeAt(index) === 0x3D /* '=' */) {
  20619. // consume the '='' symbol
  20620. name += advance();
  20621. skipWhiteSpace(last);
  20622. var ch;
  20623. var bracketDepth = 1;
  20624. // scan in the default value
  20625. while (index < last) {
  20626. ch = source.charCodeAt(index);
  20627. if (esutils.code.isWhiteSpace(ch)) {
  20628. if (!insideString) {
  20629. skipWhiteSpace(last);
  20630. ch = source.charCodeAt(index);
  20631. }
  20632. }
  20633. if (ch === 0x27 /* ''' */) {
  20634. if (!insideString) {
  20635. insideString = '\'';
  20636. } else {
  20637. if (insideString === '\'') {
  20638. insideString = '';
  20639. }
  20640. }
  20641. }
  20642. if (ch === 0x22 /* '"' */) {
  20643. if (!insideString) {
  20644. insideString = '"';
  20645. } else {
  20646. if (insideString === '"') {
  20647. insideString = '';
  20648. }
  20649. }
  20650. }
  20651. if (ch === 0x5B /* '[' */) {
  20652. bracketDepth++;
  20653. } else if (ch === 0x5D /* ']' */ && --bracketDepth === 0) {
  20654. break;
  20655. }
  20656. name += advance();
  20657. }
  20658. }
  20659. skipWhiteSpace(last);
  20660. if (index >= last || source.charCodeAt(index) !== 0x5D /* ']' */) {
  20661. // we never found a closing ']'
  20662. return null;
  20663. }
  20664. // collect the last ']'
  20665. name += advance();
  20666. }
  20667. return name;
  20668. }
  20669. function skipToTag() {
  20670. while (index < length && source.charCodeAt(index) !== 0x40 /* '@' */) {
  20671. advance();
  20672. }
  20673. if (index >= length) {
  20674. return false;
  20675. }
  20676. utility.assert(source.charCodeAt(index) === 0x40 /* '@' */);
  20677. return true;
  20678. }
  20679. function convertIndex(rangeIndex) {
  20680. if (source === originalSource) {
  20681. return rangeIndex;
  20682. }
  20683. return convertUnwrappedCommentIndex(originalSource, rangeIndex);
  20684. }
  20685. function TagParser(options, title) {
  20686. this._options = options;
  20687. this._title = title.toLowerCase();
  20688. this._tag = {
  20689. title: title,
  20690. description: null
  20691. };
  20692. if (this._options.lineNumbers) {
  20693. this._tag.lineNumber = lineNumber;
  20694. }
  20695. this._first = index - title.length - 1;
  20696. this._last = 0;
  20697. // space to save special information for title parsers.
  20698. this._extra = {};
  20699. }
  20700. // addError(err, ...)
  20701. TagParser.prototype.addError = function addError(errorText) {
  20702. var args = Array.prototype.slice.call(arguments, 1),
  20703. msg = errorText.replace(/%(\d)/g, function (whole, index) {
  20704. utility.assert(index < args.length, 'Message reference must be in range');
  20705. return args[index];
  20706. });
  20707. if (!this._tag.errors) {
  20708. this._tag.errors = [];
  20709. }
  20710. if (strict) {
  20711. utility.throwError(msg);
  20712. }
  20713. this._tag.errors.push(msg);
  20714. return recoverable;
  20715. };
  20716. TagParser.prototype.parseType = function () {
  20717. // type required titles
  20718. if (isTypeParameterRequired(this._title)) {
  20719. try {
  20720. this._tag.type = parseType(this._title, this._last, this._options.range);
  20721. if (!this._tag.type) {
  20722. if (!isParamTitle(this._title) && !isReturnTitle(this._title)) {
  20723. if (!this.addError('Missing or invalid tag type')) {
  20724. return false;
  20725. }
  20726. }
  20727. }
  20728. } catch (error) {
  20729. this._tag.type = null;
  20730. if (!this.addError(error.message)) {
  20731. return false;
  20732. }
  20733. }
  20734. } else if (isAllowedType(this._title)) {
  20735. // optional types
  20736. try {
  20737. this._tag.type = parseType(this._title, this._last, this._options.range);
  20738. } catch (e) {
  20739. //For optional types, lets drop the thrown error when we hit the end of the file
  20740. }
  20741. }
  20742. return true;
  20743. };
  20744. TagParser.prototype._parseNamePath = function (optional) {
  20745. var name;
  20746. name = parseName(this._last, sloppy && isAllowedOptional(this._title), true);
  20747. if (!name) {
  20748. if (!optional) {
  20749. if (!this.addError('Missing or invalid tag name')) {
  20750. return false;
  20751. }
  20752. }
  20753. }
  20754. this._tag.name = name;
  20755. return true;
  20756. };
  20757. TagParser.prototype.parseNamePath = function () {
  20758. return this._parseNamePath(false);
  20759. };
  20760. TagParser.prototype.parseNamePathOptional = function () {
  20761. return this._parseNamePath(true);
  20762. };
  20763. TagParser.prototype.parseName = function () {
  20764. var assign, name;
  20765. // param, property requires name
  20766. if (isAllowedName(this._title)) {
  20767. this._tag.name = parseName(this._last, sloppy && isAllowedOptional(this._title), isAllowedNested(this._title));
  20768. if (!this._tag.name) {
  20769. if (!isNameParameterRequired(this._title)) {
  20770. return true;
  20771. }
  20772. // it's possible the name has already been parsed but interpreted as a type
  20773. // it's also possible this is a sloppy declaration, in which case it will be
  20774. // fixed at the end
  20775. if (isParamTitle(this._title) && this._tag.type && this._tag.type.name) {
  20776. this._extra.name = this._tag.type;
  20777. this._tag.name = this._tag.type.name;
  20778. this._tag.type = null;
  20779. } else {
  20780. if (!this.addError('Missing or invalid tag name')) {
  20781. return false;
  20782. }
  20783. }
  20784. } else {
  20785. name = this._tag.name;
  20786. if (name.charAt(0) === '[' && name.charAt(name.length - 1) === ']') {
  20787. // extract the default value if there is one
  20788. // example: @param {string} [somebody=John Doe] description
  20789. assign = name.substring(1, name.length - 1).split('=');
  20790. if (assign.length > 1) {
  20791. this._tag['default'] = assign.slice(1).join('=');
  20792. }
  20793. this._tag.name = assign[0];
  20794. // convert to an optional type
  20795. if (this._tag.type && this._tag.type.type !== 'OptionalType') {
  20796. this._tag.type = {
  20797. type: 'OptionalType',
  20798. expression: this._tag.type
  20799. };
  20800. }
  20801. }
  20802. }
  20803. }
  20804. return true;
  20805. };
  20806. TagParser.prototype.parseDescription = function parseDescription() {
  20807. var description = sliceSource(source, index, this._last).trim();
  20808. if (description) {
  20809. if (/^-\s+/.test(description)) {
  20810. description = description.substring(2);
  20811. }
  20812. this._tag.description = description;
  20813. }
  20814. return true;
  20815. };
  20816. TagParser.prototype.parseCaption = function parseDescription() {
  20817. var description = sliceSource(source, index, this._last).trim();
  20818. var captionStartTag = '<caption>';
  20819. var captionEndTag = '</caption>';
  20820. var captionStart = description.indexOf(captionStartTag);
  20821. var captionEnd = description.indexOf(captionEndTag);
  20822. if (captionStart >= 0 && captionEnd >= 0) {
  20823. this._tag.caption = description.substring(captionStart + captionStartTag.length, captionEnd).trim();
  20824. this._tag.description = description.substring(captionEnd + captionEndTag.length).trim();
  20825. } else {
  20826. this._tag.description = description;
  20827. }
  20828. return true;
  20829. };
  20830. TagParser.prototype.parseKind = function parseKind() {
  20831. var kind, kinds;
  20832. kinds = {
  20833. 'class': true,
  20834. 'constant': true,
  20835. 'event': true,
  20836. 'external': true,
  20837. 'file': true,
  20838. 'function': true,
  20839. 'member': true,
  20840. 'mixin': true,
  20841. 'module': true,
  20842. 'namespace': true,
  20843. 'typedef': true
  20844. };
  20845. kind = sliceSource(source, index, this._last).trim();
  20846. this._tag.kind = kind;
  20847. if (!hasOwnProperty(kinds, kind)) {
  20848. if (!this.addError('Invalid kind name \'%0\'', kind)) {
  20849. return false;
  20850. }
  20851. }
  20852. return true;
  20853. };
  20854. TagParser.prototype.parseAccess = function parseAccess() {
  20855. var access;
  20856. access = sliceSource(source, index, this._last).trim();
  20857. this._tag.access = access;
  20858. if (access !== 'private' && access !== 'protected' && access !== 'public') {
  20859. if (!this.addError('Invalid access name \'%0\'', access)) {
  20860. return false;
  20861. }
  20862. }
  20863. return true;
  20864. };
  20865. TagParser.prototype.parseThis = function parseThis() {
  20866. // this name may be a name expression (e.g. {foo.bar}),
  20867. // an union (e.g. {foo.bar|foo.baz}) or a name path (e.g. foo.bar)
  20868. var value = sliceSource(source, index, this._last).trim();
  20869. if (value && value.charAt(0) === '{') {
  20870. var gotType = this.parseType();
  20871. if (gotType && this._tag.type.type === 'NameExpression' || this._tag.type.type === 'UnionType') {
  20872. this._tag.name = this._tag.type.name;
  20873. return true;
  20874. } else {
  20875. return this.addError('Invalid name for this');
  20876. }
  20877. } else {
  20878. return this.parseNamePath();
  20879. }
  20880. };
  20881. TagParser.prototype.parseVariation = function parseVariation() {
  20882. var variation, text;
  20883. text = sliceSource(source, index, this._last).trim();
  20884. variation = parseFloat(text, 10);
  20885. this._tag.variation = variation;
  20886. if (isNaN(variation)) {
  20887. if (!this.addError('Invalid variation \'%0\'', text)) {
  20888. return false;
  20889. }
  20890. }
  20891. return true;
  20892. };
  20893. TagParser.prototype.ensureEnd = function () {
  20894. var shouldBeEmpty = sliceSource(source, index, this._last).trim();
  20895. if (shouldBeEmpty) {
  20896. if (!this.addError('Unknown content \'%0\'', shouldBeEmpty)) {
  20897. return false;
  20898. }
  20899. }
  20900. return true;
  20901. };
  20902. TagParser.prototype.epilogue = function epilogue() {
  20903. var description;
  20904. description = this._tag.description;
  20905. // un-fix potentially sloppy declaration
  20906. if (isAllowedOptional(this._title) && !this._tag.type && description && description.charAt(0) === '[') {
  20907. this._tag.type = this._extra.name;
  20908. if (!this._tag.name) {
  20909. this._tag.name = undefined;
  20910. }
  20911. if (!sloppy) {
  20912. if (!this.addError('Missing or invalid tag name')) {
  20913. return false;
  20914. }
  20915. }
  20916. }
  20917. return true;
  20918. };
  20919. Rules = {
  20920. // http://usejsdoc.org/tags-access.html
  20921. 'access': ['parseAccess'],
  20922. // http://usejsdoc.org/tags-alias.html
  20923. 'alias': ['parseNamePath', 'ensureEnd'],
  20924. // http://usejsdoc.org/tags-augments.html
  20925. 'augments': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20926. // http://usejsdoc.org/tags-constructor.html
  20927. 'constructor': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20928. // Synonym: http://usejsdoc.org/tags-constructor.html
  20929. 'class': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20930. // Synonym: http://usejsdoc.org/tags-extends.html
  20931. 'extends': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20932. // http://usejsdoc.org/tags-example.html
  20933. 'example': ['parseCaption'],
  20934. // http://usejsdoc.org/tags-deprecated.html
  20935. 'deprecated': ['parseDescription'],
  20936. // http://usejsdoc.org/tags-global.html
  20937. 'global': ['ensureEnd'],
  20938. // http://usejsdoc.org/tags-inner.html
  20939. 'inner': ['ensureEnd'],
  20940. // http://usejsdoc.org/tags-instance.html
  20941. 'instance': ['ensureEnd'],
  20942. // http://usejsdoc.org/tags-kind.html
  20943. 'kind': ['parseKind'],
  20944. // http://usejsdoc.org/tags-mixes.html
  20945. 'mixes': ['parseNamePath', 'ensureEnd'],
  20946. // http://usejsdoc.org/tags-mixin.html
  20947. 'mixin': ['parseNamePathOptional', 'ensureEnd'],
  20948. // http://usejsdoc.org/tags-member.html
  20949. 'member': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20950. // http://usejsdoc.org/tags-method.html
  20951. 'method': ['parseNamePathOptional', 'ensureEnd'],
  20952. // http://usejsdoc.org/tags-module.html
  20953. 'module': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20954. // Synonym: http://usejsdoc.org/tags-method.html
  20955. 'func': ['parseNamePathOptional', 'ensureEnd'],
  20956. // Synonym: http://usejsdoc.org/tags-method.html
  20957. 'function': ['parseNamePathOptional', 'ensureEnd'],
  20958. // Synonym: http://usejsdoc.org/tags-member.html
  20959. 'var': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20960. // http://usejsdoc.org/tags-name.html
  20961. 'name': ['parseNamePath', 'ensureEnd'],
  20962. // http://usejsdoc.org/tags-namespace.html
  20963. 'namespace': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
  20964. // http://usejsdoc.org/tags-private.html
  20965. 'private': ['parseType', 'parseDescription'],
  20966. // http://usejsdoc.org/tags-protected.html
  20967. 'protected': ['parseType', 'parseDescription'],
  20968. // http://usejsdoc.org/tags-public.html
  20969. 'public': ['parseType', 'parseDescription'],
  20970. // http://usejsdoc.org/tags-readonly.html
  20971. 'readonly': ['ensureEnd'],
  20972. // http://usejsdoc.org/tags-requires.html
  20973. 'requires': ['parseNamePath', 'ensureEnd'],
  20974. // http://usejsdoc.org/tags-since.html
  20975. 'since': ['parseDescription'],
  20976. // http://usejsdoc.org/tags-static.html
  20977. 'static': ['ensureEnd'],
  20978. // http://usejsdoc.org/tags-summary.html
  20979. 'summary': ['parseDescription'],
  20980. // http://usejsdoc.org/tags-this.html
  20981. 'this': ['parseThis', 'ensureEnd'],
  20982. // http://usejsdoc.org/tags-todo.html
  20983. 'todo': ['parseDescription'],
  20984. // http://usejsdoc.org/tags-typedef.html
  20985. 'typedef': ['parseType', 'parseNamePathOptional'],
  20986. // http://usejsdoc.org/tags-variation.html
  20987. 'variation': ['parseVariation'],
  20988. // http://usejsdoc.org/tags-version.html
  20989. 'version': ['parseDescription']
  20990. };
  20991. TagParser.prototype.parse = function parse() {
  20992. var i, iz, sequences, method;
  20993. // empty title
  20994. if (!this._title) {
  20995. if (!this.addError('Missing or invalid title')) {
  20996. return null;
  20997. }
  20998. }
  20999. // Seek to content last index.
  21000. this._last = seekContent(this._title);
  21001. if (this._options.range) {
  21002. this._tag.range = [this._first, source.slice(0, this._last).replace(/\s*$/, '').length].map(convertIndex);
  21003. }
  21004. if (hasOwnProperty(Rules, this._title)) {
  21005. sequences = Rules[this._title];
  21006. } else {
  21007. // default sequences
  21008. sequences = ['parseType', 'parseName', 'parseDescription', 'epilogue'];
  21009. }
  21010. for (i = 0, iz = sequences.length; i < iz; ++i) {
  21011. method = sequences[i];
  21012. if (!this[method]()) {
  21013. return null;
  21014. }
  21015. }
  21016. return this._tag;
  21017. };
  21018. function parseTag(options) {
  21019. var title, parser, tag;
  21020. // skip to tag
  21021. if (!skipToTag()) {
  21022. return null;
  21023. }
  21024. // scan title
  21025. title = scanTitle();
  21026. // construct tag parser
  21027. parser = new TagParser(options, title);
  21028. tag = parser.parse();
  21029. // Seek global index to end of this tag.
  21030. while (index < parser._last) {
  21031. advance();
  21032. }
  21033. return tag;
  21034. }
  21035. //
  21036. // Parse JSDoc
  21037. //
  21038. function scanJSDocDescription(preserveWhitespace) {
  21039. var description = '',
  21040. ch,
  21041. atAllowed;
  21042. atAllowed = true;
  21043. while (index < length) {
  21044. ch = source.charCodeAt(index);
  21045. if (atAllowed && ch === 0x40 /* '@' */) {
  21046. break;
  21047. }
  21048. if (esutils.code.isLineTerminator(ch)) {
  21049. atAllowed = true;
  21050. } else if (atAllowed && !esutils.code.isWhiteSpace(ch)) {
  21051. atAllowed = false;
  21052. }
  21053. description += advance();
  21054. }
  21055. return preserveWhitespace ? description : description.trim();
  21056. }
  21057. function parse(comment, options) {
  21058. var tags = [],
  21059. tag,
  21060. description,
  21061. interestingTags,
  21062. i,
  21063. iz;
  21064. if (options === undefined) {
  21065. options = {};
  21066. }
  21067. if (typeof options.unwrap === 'boolean' && options.unwrap) {
  21068. source = unwrapComment(comment);
  21069. } else {
  21070. source = comment;
  21071. }
  21072. originalSource = comment;
  21073. // array of relevant tags
  21074. if (options.tags) {
  21075. if (Array.isArray(options.tags)) {
  21076. interestingTags = {};
  21077. for (i = 0, iz = options.tags.length; i < iz; i++) {
  21078. if (typeof options.tags[i] === 'string') {
  21079. interestingTags[options.tags[i]] = true;
  21080. } else {
  21081. utility.throwError('Invalid "tags" parameter: ' + options.tags);
  21082. }
  21083. }
  21084. } else {
  21085. utility.throwError('Invalid "tags" parameter: ' + options.tags);
  21086. }
  21087. }
  21088. length = source.length;
  21089. index = 0;
  21090. lineNumber = 0;
  21091. recoverable = options.recoverable;
  21092. sloppy = options.sloppy;
  21093. strict = options.strict;
  21094. description = scanJSDocDescription(options.preserveWhitespace);
  21095. while (true) {
  21096. tag = parseTag(options);
  21097. if (!tag) {
  21098. break;
  21099. }
  21100. if (!interestingTags || interestingTags.hasOwnProperty(tag.title)) {
  21101. tags.push(tag);
  21102. }
  21103. }
  21104. return {
  21105. description: description,
  21106. tags: tags
  21107. };
  21108. }
  21109. exports.parse = parse;
  21110. })(jsdoc = {});
  21111. exports.version = utility.VERSION;
  21112. exports.parse = jsdoc.parse;
  21113. exports.parseType = typed.parseType;
  21114. exports.parseParamType = typed.parseParamType;
  21115. exports.unwrapComment = unwrapComment;
  21116. exports.Syntax = shallowCopy(typed.Syntax);
  21117. exports.Error = utility.DoctrineError;
  21118. exports.type = {
  21119. Syntax: exports.Syntax,
  21120. parseType: typed.parseType,
  21121. parseParamType: typed.parseParamType,
  21122. stringify: typed.stringify
  21123. };
  21124. })();
  21125. /* vim: set sw=4 ts=4 et tw=80 : */
  21126. },{"./typed":56,"./utility":57,"esutils":80}],56:[function(require,module,exports){
  21127. 'use strict';
  21128. /*
  21129. * @fileoverview Type expression parser.
  21130. * @author Yusuke Suzuki <utatane.tea@gmail.com>
  21131. * @author Dan Tao <daniel.tao@gmail.com>
  21132. * @author Andrew Eisenberg <andrew@eisenberg.as>
  21133. */
  21134. // "typed", the Type Expression Parser for doctrine.
  21135. (function () {
  21136. 'use strict';
  21137. var Syntax, Token, source, length, index, previous, token, value, esutils, utility, rangeOffset, addRange;
  21138. esutils = require('esutils');
  21139. utility = require('./utility');
  21140. Syntax = {
  21141. NullableLiteral: 'NullableLiteral',
  21142. AllLiteral: 'AllLiteral',
  21143. NullLiteral: 'NullLiteral',
  21144. UndefinedLiteral: 'UndefinedLiteral',
  21145. VoidLiteral: 'VoidLiteral',
  21146. UnionType: 'UnionType',
  21147. ArrayType: 'ArrayType',
  21148. RecordType: 'RecordType',
  21149. FieldType: 'FieldType',
  21150. FunctionType: 'FunctionType',
  21151. ParameterType: 'ParameterType',
  21152. RestType: 'RestType',
  21153. NonNullableType: 'NonNullableType',
  21154. OptionalType: 'OptionalType',
  21155. NullableType: 'NullableType',
  21156. NameExpression: 'NameExpression',
  21157. TypeApplication: 'TypeApplication',
  21158. StringLiteralType: 'StringLiteralType',
  21159. NumericLiteralType: 'NumericLiteralType',
  21160. BooleanLiteralType: 'BooleanLiteralType'
  21161. };
  21162. Token = {
  21163. ILLEGAL: 0, // ILLEGAL
  21164. DOT_LT: 1, // .<
  21165. REST: 2, // ...
  21166. LT: 3, // <
  21167. GT: 4, // >
  21168. LPAREN: 5, // (
  21169. RPAREN: 6, // )
  21170. LBRACE: 7, // {
  21171. RBRACE: 8, // }
  21172. LBRACK: 9, // [
  21173. RBRACK: 10, // ]
  21174. COMMA: 11, // ,
  21175. COLON: 12, // :
  21176. STAR: 13, // *
  21177. PIPE: 14, // |
  21178. QUESTION: 15, // ?
  21179. BANG: 16, // !
  21180. EQUAL: 17, // =
  21181. NAME: 18, // name token
  21182. STRING: 19, // string
  21183. NUMBER: 20, // number
  21184. EOF: 21
  21185. };
  21186. function isTypeName(ch) {
  21187. return '><(){}[],:*|?!='.indexOf(String.fromCharCode(ch)) === -1 && !esutils.code.isWhiteSpace(ch) && !esutils.code.isLineTerminator(ch);
  21188. }
  21189. function Context(previous, index, token, value) {
  21190. this._previous = previous;
  21191. this._index = index;
  21192. this._token = token;
  21193. this._value = value;
  21194. }
  21195. Context.prototype.restore = function () {
  21196. previous = this._previous;
  21197. index = this._index;
  21198. token = this._token;
  21199. value = this._value;
  21200. };
  21201. Context.save = function () {
  21202. return new Context(previous, index, token, value);
  21203. };
  21204. function maybeAddRange(node, range) {
  21205. if (addRange) {
  21206. node.range = [range[0] + rangeOffset, range[1] + rangeOffset];
  21207. }
  21208. return node;
  21209. }
  21210. function advance() {
  21211. var ch = source.charAt(index);
  21212. index += 1;
  21213. return ch;
  21214. }
  21215. function scanHexEscape(prefix) {
  21216. var i,
  21217. len,
  21218. ch,
  21219. code = 0;
  21220. len = prefix === 'u' ? 4 : 2;
  21221. for (i = 0; i < len; ++i) {
  21222. if (index < length && esutils.code.isHexDigit(source.charCodeAt(index))) {
  21223. ch = advance();
  21224. code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
  21225. } else {
  21226. return '';
  21227. }
  21228. }
  21229. return String.fromCharCode(code);
  21230. }
  21231. function scanString() {
  21232. var str = '',
  21233. quote,
  21234. ch,
  21235. code,
  21236. unescaped,
  21237. restore; //TODO review removal octal = false
  21238. quote = source.charAt(index);
  21239. ++index;
  21240. while (index < length) {
  21241. ch = advance();
  21242. if (ch === quote) {
  21243. quote = '';
  21244. break;
  21245. } else if (ch === '\\') {
  21246. ch = advance();
  21247. if (!esutils.code.isLineTerminator(ch.charCodeAt(0))) {
  21248. switch (ch) {
  21249. case 'n':
  21250. str += '\n';
  21251. break;
  21252. case 'r':
  21253. str += '\r';
  21254. break;
  21255. case 't':
  21256. str += '\t';
  21257. break;
  21258. case 'u':
  21259. case 'x':
  21260. restore = index;
  21261. unescaped = scanHexEscape(ch);
  21262. if (unescaped) {
  21263. str += unescaped;
  21264. } else {
  21265. index = restore;
  21266. str += ch;
  21267. }
  21268. break;
  21269. case 'b':
  21270. str += '\b';
  21271. break;
  21272. case 'f':
  21273. str += '\f';
  21274. break;
  21275. case 'v':
  21276. str += '\v';
  21277. break;
  21278. default:
  21279. if (esutils.code.isOctalDigit(ch.charCodeAt(0))) {
  21280. code = '01234567'.indexOf(ch);
  21281. // \0 is not octal escape sequence
  21282. // Deprecating unused code. TODO review removal
  21283. //if (code !== 0) {
  21284. // octal = true;
  21285. //}
  21286. if (index < length && esutils.code.isOctalDigit(source.charCodeAt(index))) {
  21287. //TODO Review Removal octal = true;
  21288. code = code * 8 + '01234567'.indexOf(advance());
  21289. // 3 digits are only allowed when string starts
  21290. // with 0, 1, 2, 3
  21291. if ('0123'.indexOf(ch) >= 0 && index < length && esutils.code.isOctalDigit(source.charCodeAt(index))) {
  21292. code = code * 8 + '01234567'.indexOf(advance());
  21293. }
  21294. }
  21295. str += String.fromCharCode(code);
  21296. } else {
  21297. str += ch;
  21298. }
  21299. break;
  21300. }
  21301. } else {
  21302. if (ch === '\r' && source.charCodeAt(index) === 0x0A /* '\n' */) {
  21303. ++index;
  21304. }
  21305. }
  21306. } else if (esutils.code.isLineTerminator(ch.charCodeAt(0))) {
  21307. break;
  21308. } else {
  21309. str += ch;
  21310. }
  21311. }
  21312. if (quote !== '') {
  21313. utility.throwError('unexpected quote');
  21314. }
  21315. value = str;
  21316. return Token.STRING;
  21317. }
  21318. function scanNumber() {
  21319. var number, ch;
  21320. number = '';
  21321. ch = source.charCodeAt(index);
  21322. if (ch !== 0x2E /* '.' */) {
  21323. number = advance();
  21324. ch = source.charCodeAt(index);
  21325. if (number === '0') {
  21326. if (ch === 0x78 /* 'x' */ || ch === 0x58 /* 'X' */) {
  21327. number += advance();
  21328. while (index < length) {
  21329. ch = source.charCodeAt(index);
  21330. if (!esutils.code.isHexDigit(ch)) {
  21331. break;
  21332. }
  21333. number += advance();
  21334. }
  21335. if (number.length <= 2) {
  21336. // only 0x
  21337. utility.throwError('unexpected token');
  21338. }
  21339. if (index < length) {
  21340. ch = source.charCodeAt(index);
  21341. if (esutils.code.isIdentifierStartES5(ch)) {
  21342. utility.throwError('unexpected token');
  21343. }
  21344. }
  21345. value = parseInt(number, 16);
  21346. return Token.NUMBER;
  21347. }
  21348. if (esutils.code.isOctalDigit(ch)) {
  21349. number += advance();
  21350. while (index < length) {
  21351. ch = source.charCodeAt(index);
  21352. if (!esutils.code.isOctalDigit(ch)) {
  21353. break;
  21354. }
  21355. number += advance();
  21356. }
  21357. if (index < length) {
  21358. ch = source.charCodeAt(index);
  21359. if (esutils.code.isIdentifierStartES5(ch) || esutils.code.isDecimalDigit(ch)) {
  21360. utility.throwError('unexpected token');
  21361. }
  21362. }
  21363. value = parseInt(number, 8);
  21364. return Token.NUMBER;
  21365. }
  21366. if (esutils.code.isDecimalDigit(ch)) {
  21367. utility.throwError('unexpected token');
  21368. }
  21369. }
  21370. while (index < length) {
  21371. ch = source.charCodeAt(index);
  21372. if (!esutils.code.isDecimalDigit(ch)) {
  21373. break;
  21374. }
  21375. number += advance();
  21376. }
  21377. }
  21378. if (ch === 0x2E /* '.' */) {
  21379. number += advance();
  21380. while (index < length) {
  21381. ch = source.charCodeAt(index);
  21382. if (!esutils.code.isDecimalDigit(ch)) {
  21383. break;
  21384. }
  21385. number += advance();
  21386. }
  21387. }
  21388. if (ch === 0x65 /* 'e' */ || ch === 0x45 /* 'E' */) {
  21389. number += advance();
  21390. ch = source.charCodeAt(index);
  21391. if (ch === 0x2B /* '+' */ || ch === 0x2D /* '-' */) {
  21392. number += advance();
  21393. }
  21394. ch = source.charCodeAt(index);
  21395. if (esutils.code.isDecimalDigit(ch)) {
  21396. number += advance();
  21397. while (index < length) {
  21398. ch = source.charCodeAt(index);
  21399. if (!esutils.code.isDecimalDigit(ch)) {
  21400. break;
  21401. }
  21402. number += advance();
  21403. }
  21404. } else {
  21405. utility.throwError('unexpected token');
  21406. }
  21407. }
  21408. if (index < length) {
  21409. ch = source.charCodeAt(index);
  21410. if (esutils.code.isIdentifierStartES5(ch)) {
  21411. utility.throwError('unexpected token');
  21412. }
  21413. }
  21414. value = parseFloat(number);
  21415. return Token.NUMBER;
  21416. }
  21417. function scanTypeName() {
  21418. var ch, ch2;
  21419. value = advance();
  21420. while (index < length && isTypeName(source.charCodeAt(index))) {
  21421. ch = source.charCodeAt(index);
  21422. if (ch === 0x2E /* '.' */) {
  21423. if (index + 1 >= length) {
  21424. return Token.ILLEGAL;
  21425. }
  21426. ch2 = source.charCodeAt(index + 1);
  21427. if (ch2 === 0x3C /* '<' */) {
  21428. break;
  21429. }
  21430. }
  21431. value += advance();
  21432. }
  21433. return Token.NAME;
  21434. }
  21435. function next() {
  21436. var ch;
  21437. previous = index;
  21438. while (index < length && esutils.code.isWhiteSpace(source.charCodeAt(index))) {
  21439. advance();
  21440. }
  21441. if (index >= length) {
  21442. token = Token.EOF;
  21443. return token;
  21444. }
  21445. ch = source.charCodeAt(index);
  21446. switch (ch) {
  21447. case 0x27: /* ''' */
  21448. case 0x22:
  21449. /* '"' */
  21450. token = scanString();
  21451. return token;
  21452. case 0x3A:
  21453. /* ':' */
  21454. advance();
  21455. token = Token.COLON;
  21456. return token;
  21457. case 0x2C:
  21458. /* ',' */
  21459. advance();
  21460. token = Token.COMMA;
  21461. return token;
  21462. case 0x28:
  21463. /* '(' */
  21464. advance();
  21465. token = Token.LPAREN;
  21466. return token;
  21467. case 0x29:
  21468. /* ')' */
  21469. advance();
  21470. token = Token.RPAREN;
  21471. return token;
  21472. case 0x5B:
  21473. /* '[' */
  21474. advance();
  21475. token = Token.LBRACK;
  21476. return token;
  21477. case 0x5D:
  21478. /* ']' */
  21479. advance();
  21480. token = Token.RBRACK;
  21481. return token;
  21482. case 0x7B:
  21483. /* '{' */
  21484. advance();
  21485. token = Token.LBRACE;
  21486. return token;
  21487. case 0x7D:
  21488. /* '}' */
  21489. advance();
  21490. token = Token.RBRACE;
  21491. return token;
  21492. case 0x2E:
  21493. /* '.' */
  21494. if (index + 1 < length) {
  21495. ch = source.charCodeAt(index + 1);
  21496. if (ch === 0x3C /* '<' */) {
  21497. advance(); // '.'
  21498. advance(); // '<'
  21499. token = Token.DOT_LT;
  21500. return token;
  21501. }
  21502. if (ch === 0x2E /* '.' */ && index + 2 < length && source.charCodeAt(index + 2) === 0x2E /* '.' */) {
  21503. advance(); // '.'
  21504. advance(); // '.'
  21505. advance(); // '.'
  21506. token = Token.REST;
  21507. return token;
  21508. }
  21509. if (esutils.code.isDecimalDigit(ch)) {
  21510. token = scanNumber();
  21511. return token;
  21512. }
  21513. }
  21514. token = Token.ILLEGAL;
  21515. return token;
  21516. case 0x3C:
  21517. /* '<' */
  21518. advance();
  21519. token = Token.LT;
  21520. return token;
  21521. case 0x3E:
  21522. /* '>' */
  21523. advance();
  21524. token = Token.GT;
  21525. return token;
  21526. case 0x2A:
  21527. /* '*' */
  21528. advance();
  21529. token = Token.STAR;
  21530. return token;
  21531. case 0x7C:
  21532. /* '|' */
  21533. advance();
  21534. token = Token.PIPE;
  21535. return token;
  21536. case 0x3F:
  21537. /* '?' */
  21538. advance();
  21539. token = Token.QUESTION;
  21540. return token;
  21541. case 0x21:
  21542. /* '!' */
  21543. advance();
  21544. token = Token.BANG;
  21545. return token;
  21546. case 0x3D:
  21547. /* '=' */
  21548. advance();
  21549. token = Token.EQUAL;
  21550. return token;
  21551. case 0x2D:
  21552. /* '-' */
  21553. token = scanNumber();
  21554. return token;
  21555. default:
  21556. if (esutils.code.isDecimalDigit(ch)) {
  21557. token = scanNumber();
  21558. return token;
  21559. }
  21560. // type string permits following case,
  21561. //
  21562. // namespace.module.MyClass
  21563. //
  21564. // this reduced 1 token TK_NAME
  21565. utility.assert(isTypeName(ch));
  21566. token = scanTypeName();
  21567. return token;
  21568. }
  21569. }
  21570. function consume(target, text) {
  21571. utility.assert(token === target, text || 'consumed token not matched');
  21572. next();
  21573. }
  21574. function expect(target, message) {
  21575. if (token !== target) {
  21576. utility.throwError(message || 'unexpected token');
  21577. }
  21578. next();
  21579. }
  21580. // UnionType := '(' TypeUnionList ')'
  21581. //
  21582. // TypeUnionList :=
  21583. // <<empty>>
  21584. // | NonemptyTypeUnionList
  21585. //
  21586. // NonemptyTypeUnionList :=
  21587. // TypeExpression
  21588. // | TypeExpression '|' NonemptyTypeUnionList
  21589. function parseUnionType() {
  21590. var elements,
  21591. startIndex = index - 1;
  21592. consume(Token.LPAREN, 'UnionType should start with (');
  21593. elements = [];
  21594. if (token !== Token.RPAREN) {
  21595. while (true) {
  21596. elements.push(parseTypeExpression());
  21597. if (token === Token.RPAREN) {
  21598. break;
  21599. }
  21600. expect(Token.PIPE);
  21601. }
  21602. }
  21603. consume(Token.RPAREN, 'UnionType should end with )');
  21604. return maybeAddRange({
  21605. type: Syntax.UnionType,
  21606. elements: elements
  21607. }, [startIndex, previous]);
  21608. }
  21609. // ArrayType := '[' ElementTypeList ']'
  21610. //
  21611. // ElementTypeList :=
  21612. // <<empty>>
  21613. // | TypeExpression
  21614. // | '...' TypeExpression
  21615. // | TypeExpression ',' ElementTypeList
  21616. function parseArrayType() {
  21617. var elements,
  21618. startIndex = index - 1,
  21619. restStartIndex;
  21620. consume(Token.LBRACK, 'ArrayType should start with [');
  21621. elements = [];
  21622. while (token !== Token.RBRACK) {
  21623. if (token === Token.REST) {
  21624. restStartIndex = index - 3;
  21625. consume(Token.REST);
  21626. elements.push(maybeAddRange({
  21627. type: Syntax.RestType,
  21628. expression: parseTypeExpression()
  21629. }, [restStartIndex, previous]));
  21630. break;
  21631. } else {
  21632. elements.push(parseTypeExpression());
  21633. }
  21634. if (token !== Token.RBRACK) {
  21635. expect(Token.COMMA);
  21636. }
  21637. }
  21638. expect(Token.RBRACK);
  21639. return maybeAddRange({
  21640. type: Syntax.ArrayType,
  21641. elements: elements
  21642. }, [startIndex, previous]);
  21643. }
  21644. function parseFieldName() {
  21645. var v = value;
  21646. if (token === Token.NAME || token === Token.STRING) {
  21647. next();
  21648. return v;
  21649. }
  21650. if (token === Token.NUMBER) {
  21651. consume(Token.NUMBER);
  21652. return String(v);
  21653. }
  21654. utility.throwError('unexpected token');
  21655. }
  21656. // FieldType :=
  21657. // FieldName
  21658. // | FieldName ':' TypeExpression
  21659. //
  21660. // FieldName :=
  21661. // NameExpression
  21662. // | StringLiteral
  21663. // | NumberLiteral
  21664. // | ReservedIdentifier
  21665. function parseFieldType() {
  21666. var key,
  21667. rangeStart = previous;
  21668. key = parseFieldName();
  21669. if (token === Token.COLON) {
  21670. consume(Token.COLON);
  21671. return maybeAddRange({
  21672. type: Syntax.FieldType,
  21673. key: key,
  21674. value: parseTypeExpression()
  21675. }, [rangeStart, previous]);
  21676. }
  21677. return maybeAddRange({
  21678. type: Syntax.FieldType,
  21679. key: key,
  21680. value: null
  21681. }, [rangeStart, previous]);
  21682. }
  21683. // RecordType := '{' FieldTypeList '}'
  21684. //
  21685. // FieldTypeList :=
  21686. // <<empty>>
  21687. // | FieldType
  21688. // | FieldType ',' FieldTypeList
  21689. function parseRecordType() {
  21690. var fields,
  21691. rangeStart = index - 1,
  21692. rangeEnd;
  21693. consume(Token.LBRACE, 'RecordType should start with {');
  21694. fields = [];
  21695. if (token === Token.COMMA) {
  21696. consume(Token.COMMA);
  21697. } else {
  21698. while (token !== Token.RBRACE) {
  21699. fields.push(parseFieldType());
  21700. if (token !== Token.RBRACE) {
  21701. expect(Token.COMMA);
  21702. }
  21703. }
  21704. }
  21705. rangeEnd = index;
  21706. expect(Token.RBRACE);
  21707. return maybeAddRange({
  21708. type: Syntax.RecordType,
  21709. fields: fields
  21710. }, [rangeStart, rangeEnd]);
  21711. }
  21712. // NameExpression :=
  21713. // Identifier
  21714. // | TagIdentifier ':' Identifier
  21715. //
  21716. // Tag identifier is one of "module", "external" or "event"
  21717. // Identifier is the same as Token.NAME, including any dots, something like
  21718. // namespace.module.MyClass
  21719. function parseNameExpression() {
  21720. var name = value,
  21721. rangeStart = index - name.length;
  21722. expect(Token.NAME);
  21723. if (token === Token.COLON && (name === 'module' || name === 'external' || name === 'event')) {
  21724. consume(Token.COLON);
  21725. name += ':' + value;
  21726. expect(Token.NAME);
  21727. }
  21728. return maybeAddRange({
  21729. type: Syntax.NameExpression,
  21730. name: name
  21731. }, [rangeStart, previous]);
  21732. }
  21733. // TypeExpressionList :=
  21734. // TopLevelTypeExpression
  21735. // | TopLevelTypeExpression ',' TypeExpressionList
  21736. function parseTypeExpressionList() {
  21737. var elements = [];
  21738. elements.push(parseTop());
  21739. while (token === Token.COMMA) {
  21740. consume(Token.COMMA);
  21741. elements.push(parseTop());
  21742. }
  21743. return elements;
  21744. }
  21745. // TypeName :=
  21746. // NameExpression
  21747. // | NameExpression TypeApplication
  21748. //
  21749. // TypeApplication :=
  21750. // '.<' TypeExpressionList '>'
  21751. // | '<' TypeExpressionList '>' // this is extension of doctrine
  21752. function parseTypeName() {
  21753. var expr,
  21754. applications,
  21755. startIndex = index - value.length;
  21756. expr = parseNameExpression();
  21757. if (token === Token.DOT_LT || token === Token.LT) {
  21758. next();
  21759. applications = parseTypeExpressionList();
  21760. expect(Token.GT);
  21761. return maybeAddRange({
  21762. type: Syntax.TypeApplication,
  21763. expression: expr,
  21764. applications: applications
  21765. }, [startIndex, previous]);
  21766. }
  21767. return expr;
  21768. }
  21769. // ResultType :=
  21770. // <<empty>>
  21771. // | ':' void
  21772. // | ':' TypeExpression
  21773. //
  21774. // BNF is above
  21775. // but, we remove <<empty>> pattern, so token is always TypeToken::COLON
  21776. function parseResultType() {
  21777. consume(Token.COLON, 'ResultType should start with :');
  21778. if (token === Token.NAME && value === 'void') {
  21779. consume(Token.NAME);
  21780. return {
  21781. type: Syntax.VoidLiteral
  21782. };
  21783. }
  21784. return parseTypeExpression();
  21785. }
  21786. // ParametersType :=
  21787. // RestParameterType
  21788. // | NonRestParametersType
  21789. // | NonRestParametersType ',' RestParameterType
  21790. //
  21791. // RestParameterType :=
  21792. // '...'
  21793. // '...' Identifier
  21794. //
  21795. // NonRestParametersType :=
  21796. // ParameterType ',' NonRestParametersType
  21797. // | ParameterType
  21798. // | OptionalParametersType
  21799. //
  21800. // OptionalParametersType :=
  21801. // OptionalParameterType
  21802. // | OptionalParameterType, OptionalParametersType
  21803. //
  21804. // OptionalParameterType := ParameterType=
  21805. //
  21806. // ParameterType := TypeExpression | Identifier ':' TypeExpression
  21807. //
  21808. // Identifier is "new" or "this"
  21809. function parseParametersType() {
  21810. var params = [],
  21811. optionalSequence = false,
  21812. expr,
  21813. rest = false,
  21814. startIndex,
  21815. restStartIndex = index - 3,
  21816. nameStartIndex;
  21817. while (token !== Token.RPAREN) {
  21818. if (token === Token.REST) {
  21819. // RestParameterType
  21820. consume(Token.REST);
  21821. rest = true;
  21822. }
  21823. startIndex = previous;
  21824. expr = parseTypeExpression();
  21825. if (expr.type === Syntax.NameExpression && token === Token.COLON) {
  21826. nameStartIndex = previous - expr.name.length;
  21827. // Identifier ':' TypeExpression
  21828. consume(Token.COLON);
  21829. expr = maybeAddRange({
  21830. type: Syntax.ParameterType,
  21831. name: expr.name,
  21832. expression: parseTypeExpression()
  21833. }, [nameStartIndex, previous]);
  21834. }
  21835. if (token === Token.EQUAL) {
  21836. consume(Token.EQUAL);
  21837. expr = maybeAddRange({
  21838. type: Syntax.OptionalType,
  21839. expression: expr
  21840. }, [startIndex, previous]);
  21841. optionalSequence = true;
  21842. } else {
  21843. if (optionalSequence) {
  21844. utility.throwError('unexpected token');
  21845. }
  21846. }
  21847. if (rest) {
  21848. expr = maybeAddRange({
  21849. type: Syntax.RestType,
  21850. expression: expr
  21851. }, [restStartIndex, previous]);
  21852. }
  21853. params.push(expr);
  21854. if (token !== Token.RPAREN) {
  21855. expect(Token.COMMA);
  21856. }
  21857. }
  21858. return params;
  21859. }
  21860. // FunctionType := 'function' FunctionSignatureType
  21861. //
  21862. // FunctionSignatureType :=
  21863. // | TypeParameters '(' ')' ResultType
  21864. // | TypeParameters '(' ParametersType ')' ResultType
  21865. // | TypeParameters '(' 'this' ':' TypeName ')' ResultType
  21866. // | TypeParameters '(' 'this' ':' TypeName ',' ParametersType ')' ResultType
  21867. function parseFunctionType() {
  21868. var isNew,
  21869. thisBinding,
  21870. params,
  21871. result,
  21872. fnType,
  21873. startIndex = index - value.length;
  21874. utility.assert(token === Token.NAME && value === 'function', 'FunctionType should start with \'function\'');
  21875. consume(Token.NAME);
  21876. // Google Closure Compiler is not implementing TypeParameters.
  21877. // So we do not. if we don't get '(', we see it as error.
  21878. expect(Token.LPAREN);
  21879. isNew = false;
  21880. params = [];
  21881. thisBinding = null;
  21882. if (token !== Token.RPAREN) {
  21883. // ParametersType or 'this'
  21884. if (token === Token.NAME && (value === 'this' || value === 'new')) {
  21885. // 'this' or 'new'
  21886. // 'new' is Closure Compiler extension
  21887. isNew = value === 'new';
  21888. consume(Token.NAME);
  21889. expect(Token.COLON);
  21890. thisBinding = parseTypeName();
  21891. if (token === Token.COMMA) {
  21892. consume(Token.COMMA);
  21893. params = parseParametersType();
  21894. }
  21895. } else {
  21896. params = parseParametersType();
  21897. }
  21898. }
  21899. expect(Token.RPAREN);
  21900. result = null;
  21901. if (token === Token.COLON) {
  21902. result = parseResultType();
  21903. }
  21904. fnType = maybeAddRange({
  21905. type: Syntax.FunctionType,
  21906. params: params,
  21907. result: result
  21908. }, [startIndex, previous]);
  21909. if (thisBinding) {
  21910. // avoid adding null 'new' and 'this' properties
  21911. fnType['this'] = thisBinding;
  21912. if (isNew) {
  21913. fnType['new'] = true;
  21914. }
  21915. }
  21916. return fnType;
  21917. }
  21918. // BasicTypeExpression :=
  21919. // '*'
  21920. // | 'null'
  21921. // | 'undefined'
  21922. // | TypeName
  21923. // | FunctionType
  21924. // | UnionType
  21925. // | RecordType
  21926. // | ArrayType
  21927. function parseBasicTypeExpression() {
  21928. var context, startIndex;
  21929. switch (token) {
  21930. case Token.STAR:
  21931. consume(Token.STAR);
  21932. return maybeAddRange({
  21933. type: Syntax.AllLiteral
  21934. }, [previous - 1, previous]);
  21935. case Token.LPAREN:
  21936. return parseUnionType();
  21937. case Token.LBRACK:
  21938. return parseArrayType();
  21939. case Token.LBRACE:
  21940. return parseRecordType();
  21941. case Token.NAME:
  21942. startIndex = index - value.length;
  21943. if (value === 'null') {
  21944. consume(Token.NAME);
  21945. return maybeAddRange({
  21946. type: Syntax.NullLiteral
  21947. }, [startIndex, previous]);
  21948. }
  21949. if (value === 'undefined') {
  21950. consume(Token.NAME);
  21951. return maybeAddRange({
  21952. type: Syntax.UndefinedLiteral
  21953. }, [startIndex, previous]);
  21954. }
  21955. if (value === 'true' || value === 'false') {
  21956. consume(Token.NAME);
  21957. return maybeAddRange({
  21958. type: Syntax.BooleanLiteralType,
  21959. value: value === 'true'
  21960. }, [startIndex, previous]);
  21961. }
  21962. context = Context.save();
  21963. if (value === 'function') {
  21964. try {
  21965. return parseFunctionType();
  21966. } catch (e) {
  21967. context.restore();
  21968. }
  21969. }
  21970. return parseTypeName();
  21971. case Token.STRING:
  21972. next();
  21973. return maybeAddRange({
  21974. type: Syntax.StringLiteralType,
  21975. value: value
  21976. }, [previous - value.length - 2, previous]);
  21977. case Token.NUMBER:
  21978. next();
  21979. return maybeAddRange({
  21980. type: Syntax.NumericLiteralType,
  21981. value: value
  21982. }, [previous - String(value).length, previous]);
  21983. default:
  21984. utility.throwError('unexpected token');
  21985. }
  21986. }
  21987. // TypeExpression :=
  21988. // BasicTypeExpression
  21989. // | '?' BasicTypeExpression
  21990. // | '!' BasicTypeExpression
  21991. // | BasicTypeExpression '?'
  21992. // | BasicTypeExpression '!'
  21993. // | '?'
  21994. // | BasicTypeExpression '[]'
  21995. function parseTypeExpression() {
  21996. var expr, rangeStart;
  21997. if (token === Token.QUESTION) {
  21998. rangeStart = index - 1;
  21999. consume(Token.QUESTION);
  22000. if (token === Token.COMMA || token === Token.EQUAL || token === Token.RBRACE || token === Token.RPAREN || token === Token.PIPE || token === Token.EOF || token === Token.RBRACK || token === Token.GT) {
  22001. return maybeAddRange({
  22002. type: Syntax.NullableLiteral
  22003. }, [rangeStart, previous]);
  22004. }
  22005. return maybeAddRange({
  22006. type: Syntax.NullableType,
  22007. expression: parseBasicTypeExpression(),
  22008. prefix: true
  22009. }, [rangeStart, previous]);
  22010. } else if (token === Token.BANG) {
  22011. rangeStart = index - 1;
  22012. consume(Token.BANG);
  22013. return maybeAddRange({
  22014. type: Syntax.NonNullableType,
  22015. expression: parseBasicTypeExpression(),
  22016. prefix: true
  22017. }, [rangeStart, previous]);
  22018. } else {
  22019. rangeStart = previous;
  22020. }
  22021. expr = parseBasicTypeExpression();
  22022. if (token === Token.BANG) {
  22023. consume(Token.BANG);
  22024. return maybeAddRange({
  22025. type: Syntax.NonNullableType,
  22026. expression: expr,
  22027. prefix: false
  22028. }, [rangeStart, previous]);
  22029. }
  22030. if (token === Token.QUESTION) {
  22031. consume(Token.QUESTION);
  22032. return maybeAddRange({
  22033. type: Syntax.NullableType,
  22034. expression: expr,
  22035. prefix: false
  22036. }, [rangeStart, previous]);
  22037. }
  22038. if (token === Token.LBRACK) {
  22039. consume(Token.LBRACK);
  22040. expect(Token.RBRACK, 'expected an array-style type declaration (' + value + '[])');
  22041. return maybeAddRange({
  22042. type: Syntax.TypeApplication,
  22043. expression: maybeAddRange({
  22044. type: Syntax.NameExpression,
  22045. name: 'Array'
  22046. }, [rangeStart, previous]),
  22047. applications: [expr]
  22048. }, [rangeStart, previous]);
  22049. }
  22050. return expr;
  22051. }
  22052. // TopLevelTypeExpression :=
  22053. // TypeExpression
  22054. // | TypeUnionList
  22055. //
  22056. // This rule is Google Closure Compiler extension, not ES4
  22057. // like,
  22058. // { number | string }
  22059. // If strict to ES4, we should write it as
  22060. // { (number|string) }
  22061. function parseTop() {
  22062. var expr, elements;
  22063. expr = parseTypeExpression();
  22064. if (token !== Token.PIPE) {
  22065. return expr;
  22066. }
  22067. elements = [expr];
  22068. consume(Token.PIPE);
  22069. while (true) {
  22070. elements.push(parseTypeExpression());
  22071. if (token !== Token.PIPE) {
  22072. break;
  22073. }
  22074. consume(Token.PIPE);
  22075. }
  22076. return maybeAddRange({
  22077. type: Syntax.UnionType,
  22078. elements: elements
  22079. }, [0, index]);
  22080. }
  22081. function parseTopParamType() {
  22082. var expr;
  22083. if (token === Token.REST) {
  22084. consume(Token.REST);
  22085. return maybeAddRange({
  22086. type: Syntax.RestType,
  22087. expression: parseTop()
  22088. }, [0, index]);
  22089. }
  22090. expr = parseTop();
  22091. if (token === Token.EQUAL) {
  22092. consume(Token.EQUAL);
  22093. return maybeAddRange({
  22094. type: Syntax.OptionalType,
  22095. expression: expr
  22096. }, [0, index]);
  22097. }
  22098. return expr;
  22099. }
  22100. function parseType(src, opt) {
  22101. var expr;
  22102. source = src;
  22103. length = source.length;
  22104. index = 0;
  22105. previous = 0;
  22106. addRange = opt && opt.range;
  22107. rangeOffset = opt && opt.startIndex || 0;
  22108. next();
  22109. expr = parseTop();
  22110. if (opt && opt.midstream) {
  22111. return {
  22112. expression: expr,
  22113. index: previous
  22114. };
  22115. }
  22116. if (token !== Token.EOF) {
  22117. utility.throwError('not reach to EOF');
  22118. }
  22119. return expr;
  22120. }
  22121. function parseParamType(src, opt) {
  22122. var expr;
  22123. source = src;
  22124. length = source.length;
  22125. index = 0;
  22126. previous = 0;
  22127. addRange = opt && opt.range;
  22128. rangeOffset = opt && opt.startIndex || 0;
  22129. next();
  22130. expr = parseTopParamType();
  22131. if (opt && opt.midstream) {
  22132. return {
  22133. expression: expr,
  22134. index: previous
  22135. };
  22136. }
  22137. if (token !== Token.EOF) {
  22138. utility.throwError('not reach to EOF');
  22139. }
  22140. return expr;
  22141. }
  22142. function stringifyImpl(node, compact, topLevel) {
  22143. var result, i, iz;
  22144. switch (node.type) {
  22145. case Syntax.NullableLiteral:
  22146. result = '?';
  22147. break;
  22148. case Syntax.AllLiteral:
  22149. result = '*';
  22150. break;
  22151. case Syntax.NullLiteral:
  22152. result = 'null';
  22153. break;
  22154. case Syntax.UndefinedLiteral:
  22155. result = 'undefined';
  22156. break;
  22157. case Syntax.VoidLiteral:
  22158. result = 'void';
  22159. break;
  22160. case Syntax.UnionType:
  22161. if (!topLevel) {
  22162. result = '(';
  22163. } else {
  22164. result = '';
  22165. }
  22166. for (i = 0, iz = node.elements.length; i < iz; ++i) {
  22167. result += stringifyImpl(node.elements[i], compact);
  22168. if (i + 1 !== iz) {
  22169. result += compact ? '|' : ' | ';
  22170. }
  22171. }
  22172. if (!topLevel) {
  22173. result += ')';
  22174. }
  22175. break;
  22176. case Syntax.ArrayType:
  22177. result = '[';
  22178. for (i = 0, iz = node.elements.length; i < iz; ++i) {
  22179. result += stringifyImpl(node.elements[i], compact);
  22180. if (i + 1 !== iz) {
  22181. result += compact ? ',' : ', ';
  22182. }
  22183. }
  22184. result += ']';
  22185. break;
  22186. case Syntax.RecordType:
  22187. result = '{';
  22188. for (i = 0, iz = node.fields.length; i < iz; ++i) {
  22189. result += stringifyImpl(node.fields[i], compact);
  22190. if (i + 1 !== iz) {
  22191. result += compact ? ',' : ', ';
  22192. }
  22193. }
  22194. result += '}';
  22195. break;
  22196. case Syntax.FieldType:
  22197. if (node.value) {
  22198. result = node.key + (compact ? ':' : ': ') + stringifyImpl(node.value, compact);
  22199. } else {
  22200. result = node.key;
  22201. }
  22202. break;
  22203. case Syntax.FunctionType:
  22204. result = compact ? 'function(' : 'function (';
  22205. if (node['this']) {
  22206. if (node['new']) {
  22207. result += compact ? 'new:' : 'new: ';
  22208. } else {
  22209. result += compact ? 'this:' : 'this: ';
  22210. }
  22211. result += stringifyImpl(node['this'], compact);
  22212. if (node.params.length !== 0) {
  22213. result += compact ? ',' : ', ';
  22214. }
  22215. }
  22216. for (i = 0, iz = node.params.length; i < iz; ++i) {
  22217. result += stringifyImpl(node.params[i], compact);
  22218. if (i + 1 !== iz) {
  22219. result += compact ? ',' : ', ';
  22220. }
  22221. }
  22222. result += ')';
  22223. if (node.result) {
  22224. result += (compact ? ':' : ': ') + stringifyImpl(node.result, compact);
  22225. }
  22226. break;
  22227. case Syntax.ParameterType:
  22228. result = node.name + (compact ? ':' : ': ') + stringifyImpl(node.expression, compact);
  22229. break;
  22230. case Syntax.RestType:
  22231. result = '...';
  22232. if (node.expression) {
  22233. result += stringifyImpl(node.expression, compact);
  22234. }
  22235. break;
  22236. case Syntax.NonNullableType:
  22237. if (node.prefix) {
  22238. result = '!' + stringifyImpl(node.expression, compact);
  22239. } else {
  22240. result = stringifyImpl(node.expression, compact) + '!';
  22241. }
  22242. break;
  22243. case Syntax.OptionalType:
  22244. result = stringifyImpl(node.expression, compact) + '=';
  22245. break;
  22246. case Syntax.NullableType:
  22247. if (node.prefix) {
  22248. result = '?' + stringifyImpl(node.expression, compact);
  22249. } else {
  22250. result = stringifyImpl(node.expression, compact) + '?';
  22251. }
  22252. break;
  22253. case Syntax.NameExpression:
  22254. result = node.name;
  22255. break;
  22256. case Syntax.TypeApplication:
  22257. result = stringifyImpl(node.expression, compact) + '.<';
  22258. for (i = 0, iz = node.applications.length; i < iz; ++i) {
  22259. result += stringifyImpl(node.applications[i], compact);
  22260. if (i + 1 !== iz) {
  22261. result += compact ? ',' : ', ';
  22262. }
  22263. }
  22264. result += '>';
  22265. break;
  22266. case Syntax.StringLiteralType:
  22267. result = '"' + node.value + '"';
  22268. break;
  22269. case Syntax.NumericLiteralType:
  22270. result = String(node.value);
  22271. break;
  22272. case Syntax.BooleanLiteralType:
  22273. result = String(node.value);
  22274. break;
  22275. default:
  22276. utility.throwError('Unknown type ' + node.type);
  22277. }
  22278. return result;
  22279. }
  22280. function stringify(node, options) {
  22281. if (options == null) {
  22282. options = {};
  22283. }
  22284. return stringifyImpl(node, options.compact, options.topLevel);
  22285. }
  22286. exports.parseType = parseType;
  22287. exports.parseParamType = parseParamType;
  22288. exports.stringify = stringify;
  22289. exports.Syntax = Syntax;
  22290. })();
  22291. /* vim: set sw=4 ts=4 et tw=80 : */
  22292. },{"./utility":57,"esutils":80}],57:[function(require,module,exports){
  22293. 'use strict';
  22294. /*
  22295. * @fileoverview Utilities for Doctrine
  22296. * @author Yusuke Suzuki <utatane.tea@gmail.com>
  22297. */
  22298. (function () {
  22299. 'use strict';
  22300. var VERSION;
  22301. VERSION = require('../package.json').version;
  22302. exports.VERSION = VERSION;
  22303. function DoctrineError(message) {
  22304. this.name = 'DoctrineError';
  22305. this.message = message;
  22306. }
  22307. DoctrineError.prototype = function () {
  22308. var Middle = function Middle() {};
  22309. Middle.prototype = Error.prototype;
  22310. return new Middle();
  22311. }();
  22312. DoctrineError.prototype.constructor = DoctrineError;
  22313. exports.DoctrineError = DoctrineError;
  22314. function throwError(message) {
  22315. throw new DoctrineError(message);
  22316. }
  22317. exports.throwError = throwError;
  22318. exports.assert = require('assert');
  22319. })();
  22320. /* vim: set sw=4 ts=4 et tw=80 : */
  22321. },{"../package.json":58,"assert":46}],58:[function(require,module,exports){
  22322. module.exports={
  22323. "_from": "doctrine@^2.1.0",
  22324. "_id": "doctrine@2.1.0",
  22325. "_inBundle": false,
  22326. "_integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
  22327. "_location": "/doctrine",
  22328. "_phantomChildren": {},
  22329. "_requested": {
  22330. "type": "range",
  22331. "registry": true,
  22332. "raw": "doctrine@^2.1.0",
  22333. "name": "doctrine",
  22334. "escapedName": "doctrine",
  22335. "rawSpec": "^2.1.0",
  22336. "saveSpec": null,
  22337. "fetchSpec": "^2.1.0"
  22338. },
  22339. "_requiredBy": [
  22340. "/"
  22341. ],
  22342. "_resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
  22343. "_shasum": "5cd01fc101621b42c4cd7f5d1a66243716d3f39d",
  22344. "_spec": "doctrine@^2.1.0",
  22345. "_where": "/var/lib/jenkins/workspace/Releases/eslint Release/eslint",
  22346. "bugs": {
  22347. "url": "https://github.com/eslint/doctrine/issues"
  22348. },
  22349. "bundleDependencies": false,
  22350. "dependencies": {
  22351. "esutils": "^2.0.2"
  22352. },
  22353. "deprecated": false,
  22354. "description": "JSDoc parser",
  22355. "devDependencies": {
  22356. "coveralls": "^2.11.2",
  22357. "dateformat": "^1.0.11",
  22358. "eslint": "^1.10.3",
  22359. "eslint-release": "^0.10.0",
  22360. "linefix": "^0.1.1",
  22361. "mocha": "^3.4.2",
  22362. "npm-license": "^0.3.1",
  22363. "nyc": "^10.3.2",
  22364. "semver": "^5.0.3",
  22365. "shelljs": "^0.5.3",
  22366. "shelljs-nodecli": "^0.1.1",
  22367. "should": "^5.0.1"
  22368. },
  22369. "directories": {
  22370. "lib": "./lib"
  22371. },
  22372. "engines": {
  22373. "node": ">=0.10.0"
  22374. },
  22375. "files": [
  22376. "lib"
  22377. ],
  22378. "homepage": "https://github.com/eslint/doctrine",
  22379. "license": "Apache-2.0",
  22380. "main": "lib/doctrine.js",
  22381. "maintainers": [
  22382. {
  22383. "name": "Nicholas C. Zakas",
  22384. "email": "nicholas+npm@nczconsulting.com",
  22385. "url": "https://www.nczonline.net"
  22386. },
  22387. {
  22388. "name": "Yusuke Suzuki",
  22389. "email": "utatane.tea@gmail.com",
  22390. "url": "https://github.com/Constellation"
  22391. }
  22392. ],
  22393. "name": "doctrine",
  22394. "repository": {
  22395. "type": "git",
  22396. "url": "git+https://github.com/eslint/doctrine.git"
  22397. },
  22398. "scripts": {
  22399. "alpharelease": "eslint-prerelease alpha",
  22400. "betarelease": "eslint-prerelease beta",
  22401. "ci-release": "eslint-ci-release",
  22402. "coveralls": "nyc report --reporter=text-lcov | coveralls",
  22403. "lint": "eslint lib/",
  22404. "pretest": "npm run lint",
  22405. "release": "eslint-release",
  22406. "test": "nyc mocha"
  22407. },
  22408. "version": "2.1.0"
  22409. }
  22410. },{}],59:[function(require,module,exports){
  22411. /*
  22412. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  22413. Redistribution and use in source and binary forms, with or without
  22414. modification, are permitted provided that the following conditions are met:
  22415. * Redistributions of source code must retain the above copyright
  22416. notice, this list of conditions and the following disclaimer.
  22417. * Redistributions in binary form must reproduce the above copyright
  22418. notice, this list of conditions and the following disclaimer in the
  22419. documentation and/or other materials provided with the distribution.
  22420. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22421. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22422. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22423. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  22424. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22425. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22426. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22427. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22428. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22429. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22430. */
  22431. "use strict";
  22432. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  22433. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  22434. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22435. var Variable = require("./variable");
  22436. /**
  22437. * @class Definition
  22438. */
  22439. var Definition = function Definition(type, name, node, parent, index, kind) {
  22440. _classCallCheck(this, Definition);
  22441. /**
  22442. * @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
  22443. */
  22444. this.type = type;
  22445. /**
  22446. * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
  22447. */
  22448. this.name = name;
  22449. /**
  22450. * @member {espree.Node} Definition#node - the enclosing node of the identifier.
  22451. */
  22452. this.node = node;
  22453. /**
  22454. * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
  22455. */
  22456. this.parent = parent;
  22457. /**
  22458. * @member {Number?} Definition#index - the index in the declaration statement.
  22459. */
  22460. this.index = index;
  22461. /**
  22462. * @member {String?} Definition#kind - the kind of the declaration statement.
  22463. */
  22464. this.kind = kind;
  22465. };
  22466. /**
  22467. * @class ParameterDefinition
  22468. */
  22469. var ParameterDefinition = function (_Definition) {
  22470. _inherits(ParameterDefinition, _Definition);
  22471. function ParameterDefinition(name, node, index, rest) {
  22472. _classCallCheck(this, ParameterDefinition);
  22473. /**
  22474. * Whether the parameter definition is a part of a rest parameter.
  22475. * @member {boolean} ParameterDefinition#rest
  22476. */
  22477. var _this = _possibleConstructorReturn(this, (ParameterDefinition.__proto__ || Object.getPrototypeOf(ParameterDefinition)).call(this, Variable.Parameter, name, node, null, index, null));
  22478. _this.rest = rest;
  22479. return _this;
  22480. }
  22481. return ParameterDefinition;
  22482. }(Definition);
  22483. module.exports = {
  22484. ParameterDefinition: ParameterDefinition,
  22485. Definition: Definition
  22486. };
  22487. /* vim: set sw=4 ts=4 et tw=80 : */
  22488. },{"./variable":66}],60:[function(require,module,exports){
  22489. /*
  22490. Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  22491. Copyright (C) 2013 Alex Seville <hi@alexanderseville.com>
  22492. Copyright (C) 2014 Thiago de Arruda <tpadilha84@gmail.com>
  22493. Redistribution and use in source and binary forms, with or without
  22494. modification, are permitted provided that the following conditions are met:
  22495. * Redistributions of source code must retain the above copyright
  22496. notice, this list of conditions and the following disclaimer.
  22497. * Redistributions in binary form must reproduce the above copyright
  22498. notice, this list of conditions and the following disclaimer in the
  22499. documentation and/or other materials provided with the distribution.
  22500. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22501. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22502. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22503. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  22504. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22505. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22506. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22507. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22508. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22509. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22510. */
  22511. /**
  22512. * Escope (<a href="http://github.com/estools/escope">escope</a>) is an <a
  22513. * href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a>
  22514. * scope analyzer extracted from the <a
  22515. * href="http://github.com/estools/esmangle">esmangle project</a/>.
  22516. * <p>
  22517. * <em>escope</em> finds lexical scopes in a source program, i.e. areas of that
  22518. * program where different occurrences of the same identifier refer to the same
  22519. * variable. With each scope the contained variables are collected, and each
  22520. * identifier reference in code is linked to its corresponding variable (if
  22521. * possible).
  22522. * <p>
  22523. * <em>escope</em> works on a syntax tree of the parsed source code which has
  22524. * to adhere to the <a
  22525. * href="https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API">
  22526. * Mozilla Parser API</a>. E.g. <a href="https://github.com/eslint/espree">espree</a> is a parser
  22527. * that produces such syntax trees.
  22528. * <p>
  22529. * The main interface is the {@link analyze} function.
  22530. * @module escope
  22531. */
  22532. "use strict";
  22533. /* eslint no-underscore-dangle: ["error", { "allow": ["__currentScope"] }] */
  22534. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  22535. var assert = require("assert");
  22536. var ScopeManager = require("./scope-manager");
  22537. var Referencer = require("./referencer");
  22538. var Reference = require("./reference");
  22539. var Variable = require("./variable");
  22540. var Scope = require("./scope").Scope;
  22541. var version = require("../package.json").version;
  22542. /**
  22543. * Set the default options
  22544. * @returns {Object} options
  22545. */
  22546. function defaultOptions() {
  22547. return {
  22548. optimistic: false,
  22549. directive: false,
  22550. nodejsScope: false,
  22551. impliedStrict: false,
  22552. sourceType: "script", // one of ['script', 'module']
  22553. ecmaVersion: 5,
  22554. childVisitorKeys: null,
  22555. fallback: "iteration"
  22556. };
  22557. }
  22558. /**
  22559. * Preform deep update on option object
  22560. * @param {Object} target - Options
  22561. * @param {Object} override - Updates
  22562. * @returns {Object} Updated options
  22563. */
  22564. function updateDeeply(target, override) {
  22565. /**
  22566. * Is hash object
  22567. * @param {Object} value - Test value
  22568. * @returns {boolean} Result
  22569. */
  22570. function isHashObject(value) {
  22571. return (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp);
  22572. }
  22573. for (var key in override) {
  22574. if (override.hasOwnProperty(key)) {
  22575. var val = override[key];
  22576. if (isHashObject(val)) {
  22577. if (isHashObject(target[key])) {
  22578. updateDeeply(target[key], val);
  22579. } else {
  22580. target[key] = updateDeeply({}, val);
  22581. }
  22582. } else {
  22583. target[key] = val;
  22584. }
  22585. }
  22586. }
  22587. return target;
  22588. }
  22589. /**
  22590. * Main interface function. Takes an Espree syntax tree and returns the
  22591. * analyzed scopes.
  22592. * @function analyze
  22593. * @param {espree.Tree} tree - Abstract Syntax Tree
  22594. * @param {Object} providedOptions - Options that tailor the scope analysis
  22595. * @param {boolean} [providedOptions.optimistic=false] - the optimistic flag
  22596. * @param {boolean} [providedOptions.directive=false]- the directive flag
  22597. * @param {boolean} [providedOptions.ignoreEval=false]- whether to check 'eval()' calls
  22598. * @param {boolean} [providedOptions.nodejsScope=false]- whether the whole
  22599. * script is executed under node.js environment. When enabled, escope adds
  22600. * a function scope immediately following the global scope.
  22601. * @param {boolean} [providedOptions.impliedStrict=false]- implied strict mode
  22602. * (if ecmaVersion >= 5).
  22603. * @param {string} [providedOptions.sourceType='script']- the source type of the script. one of 'script' and 'module'
  22604. * @param {number} [providedOptions.ecmaVersion=5]- which ECMAScript version is considered
  22605. * @param {Object} [providedOptions.childVisitorKeys=null] - Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
  22606. * @param {string} [providedOptions.fallback='iteration'] - A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
  22607. * @returns {ScopeManager} ScopeManager
  22608. */
  22609. function analyze(tree, providedOptions) {
  22610. var options = updateDeeply(defaultOptions(), providedOptions);
  22611. var scopeManager = new ScopeManager(options);
  22612. var referencer = new Referencer(options, scopeManager);
  22613. referencer.visit(tree);
  22614. assert(scopeManager.__currentScope === null, "currentScope should be null.");
  22615. return scopeManager;
  22616. }
  22617. module.exports = {
  22618. /** @name module:escope.version */
  22619. version: version,
  22620. /** @name module:escope.Reference */
  22621. Reference: Reference,
  22622. /** @name module:escope.Variable */
  22623. Variable: Variable,
  22624. /** @name module:escope.Scope */
  22625. Scope: Scope,
  22626. /** @name module:escope.ScopeManager */
  22627. ScopeManager: ScopeManager,
  22628. analyze: analyze
  22629. };
  22630. /* vim: set sw=4 ts=4 et tw=80 : */
  22631. },{"../package.json":67,"./reference":62,"./referencer":63,"./scope":65,"./scope-manager":64,"./variable":66,"assert":46}],61:[function(require,module,exports){
  22632. /*
  22633. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  22634. Redistribution and use in source and binary forms, with or without
  22635. modification, are permitted provided that the following conditions are met:
  22636. * Redistributions of source code must retain the above copyright
  22637. notice, this list of conditions and the following disclaimer.
  22638. * Redistributions in binary form must reproduce the above copyright
  22639. notice, this list of conditions and the following disclaimer in the
  22640. documentation and/or other materials provided with the distribution.
  22641. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22642. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22643. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22644. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  22645. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22646. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22647. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22648. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22649. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22650. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22651. */
  22652. "use strict";
  22653. /* eslint-disable no-undefined */
  22654. 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; }; }();
  22655. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22656. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  22657. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  22658. var Syntax = require("estraverse").Syntax;
  22659. var esrecurse = require("esrecurse");
  22660. /**
  22661. * Get last array element
  22662. * @param {array} xs - array
  22663. * @returns {any} Last elment
  22664. */
  22665. function getLast(xs) {
  22666. return xs[xs.length - 1] || null;
  22667. }
  22668. var PatternVisitor = function (_esrecurse$Visitor) {
  22669. _inherits(PatternVisitor, _esrecurse$Visitor);
  22670. _createClass(PatternVisitor, null, [{
  22671. key: "isPattern",
  22672. value: function isPattern(node) {
  22673. var nodeType = node.type;
  22674. return nodeType === Syntax.Identifier || nodeType === Syntax.ObjectPattern || nodeType === Syntax.ArrayPattern || nodeType === Syntax.SpreadElement || nodeType === Syntax.RestElement || nodeType === Syntax.AssignmentPattern;
  22675. }
  22676. }]);
  22677. function PatternVisitor(options, rootPattern, callback) {
  22678. _classCallCheck(this, PatternVisitor);
  22679. var _this = _possibleConstructorReturn(this, (PatternVisitor.__proto__ || Object.getPrototypeOf(PatternVisitor)).call(this, null, options));
  22680. _this.rootPattern = rootPattern;
  22681. _this.callback = callback;
  22682. _this.assignments = [];
  22683. _this.rightHandNodes = [];
  22684. _this.restElements = [];
  22685. return _this;
  22686. }
  22687. _createClass(PatternVisitor, [{
  22688. key: "Identifier",
  22689. value: function Identifier(pattern) {
  22690. var lastRestElement = getLast(this.restElements);
  22691. this.callback(pattern, {
  22692. topLevel: pattern === this.rootPattern,
  22693. rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern,
  22694. assignments: this.assignments
  22695. });
  22696. }
  22697. }, {
  22698. key: "Property",
  22699. value: function Property(property) {
  22700. // Computed property's key is a right hand node.
  22701. if (property.computed) {
  22702. this.rightHandNodes.push(property.key);
  22703. }
  22704. // If it's shorthand, its key is same as its value.
  22705. // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern).
  22706. // If it's not shorthand, the name of new variable is its value's.
  22707. this.visit(property.value);
  22708. }
  22709. }, {
  22710. key: "ArrayPattern",
  22711. value: function ArrayPattern(pattern) {
  22712. for (var i = 0, iz = pattern.elements.length; i < iz; ++i) {
  22713. var element = pattern.elements[i];
  22714. this.visit(element);
  22715. }
  22716. }
  22717. }, {
  22718. key: "AssignmentPattern",
  22719. value: function AssignmentPattern(pattern) {
  22720. this.assignments.push(pattern);
  22721. this.visit(pattern.left);
  22722. this.rightHandNodes.push(pattern.right);
  22723. this.assignments.pop();
  22724. }
  22725. }, {
  22726. key: "RestElement",
  22727. value: function RestElement(pattern) {
  22728. this.restElements.push(pattern);
  22729. this.visit(pattern.argument);
  22730. this.restElements.pop();
  22731. }
  22732. }, {
  22733. key: "MemberExpression",
  22734. value: function MemberExpression(node) {
  22735. // Computed property's key is a right hand node.
  22736. if (node.computed) {
  22737. this.rightHandNodes.push(node.property);
  22738. }
  22739. // the object is only read, write to its property.
  22740. this.rightHandNodes.push(node.object);
  22741. }
  22742. //
  22743. // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
  22744. // By spec, LeftHandSideExpression is Pattern or MemberExpression.
  22745. // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
  22746. // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
  22747. //
  22748. }, {
  22749. key: "SpreadElement",
  22750. value: function SpreadElement(node) {
  22751. this.visit(node.argument);
  22752. }
  22753. }, {
  22754. key: "ArrayExpression",
  22755. value: function ArrayExpression(node) {
  22756. node.elements.forEach(this.visit, this);
  22757. }
  22758. }, {
  22759. key: "AssignmentExpression",
  22760. value: function AssignmentExpression(node) {
  22761. this.assignments.push(node);
  22762. this.visit(node.left);
  22763. this.rightHandNodes.push(node.right);
  22764. this.assignments.pop();
  22765. }
  22766. }, {
  22767. key: "CallExpression",
  22768. value: function CallExpression(node) {
  22769. var _this2 = this;
  22770. // arguments are right hand nodes.
  22771. node.arguments.forEach(function (a) {
  22772. _this2.rightHandNodes.push(a);
  22773. });
  22774. this.visit(node.callee);
  22775. }
  22776. }]);
  22777. return PatternVisitor;
  22778. }(esrecurse.Visitor);
  22779. module.exports = PatternVisitor;
  22780. /* vim: set sw=4 ts=4 et tw=80 : */
  22781. },{"esrecurse":73,"estraverse":75}],62:[function(require,module,exports){
  22782. /*
  22783. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  22784. Redistribution and use in source and binary forms, with or without
  22785. modification, are permitted provided that the following conditions are met:
  22786. * Redistributions of source code must retain the above copyright
  22787. notice, this list of conditions and the following disclaimer.
  22788. * Redistributions in binary form must reproduce the above copyright
  22789. notice, this list of conditions and the following disclaimer in the
  22790. documentation and/or other materials provided with the distribution.
  22791. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22792. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22793. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22794. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  22795. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22796. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22797. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22798. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22799. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22800. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22801. */
  22802. "use strict";
  22803. 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; }; }();
  22804. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22805. var READ = 0x1;
  22806. var WRITE = 0x2;
  22807. var RW = READ | WRITE;
  22808. /**
  22809. * A Reference represents a single occurrence of an identifier in code.
  22810. * @class Reference
  22811. */
  22812. var Reference = function () {
  22813. function Reference(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
  22814. _classCallCheck(this, Reference);
  22815. /**
  22816. * Identifier syntax node.
  22817. * @member {espreeIdentifier} Reference#identifier
  22818. */
  22819. this.identifier = ident;
  22820. /**
  22821. * Reference to the enclosing Scope.
  22822. * @member {Scope} Reference#from
  22823. */
  22824. this.from = scope;
  22825. /**
  22826. * Whether the reference comes from a dynamic scope (such as 'eval',
  22827. * 'with', etc.), and may be trapped by dynamic scopes.
  22828. * @member {boolean} Reference#tainted
  22829. */
  22830. this.tainted = false;
  22831. /**
  22832. * The variable this reference is resolved with.
  22833. * @member {Variable} Reference#resolved
  22834. */
  22835. this.resolved = null;
  22836. /**
  22837. * The read-write mode of the reference. (Value is one of {@link
  22838. * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
  22839. * @member {number} Reference#flag
  22840. * @private
  22841. */
  22842. this.flag = flag;
  22843. if (this.isWrite()) {
  22844. /**
  22845. * If reference is writeable, this is the tree being written to it.
  22846. * @member {espreeNode} Reference#writeExpr
  22847. */
  22848. this.writeExpr = writeExpr;
  22849. /**
  22850. * Whether the Reference might refer to a partial value of writeExpr.
  22851. * @member {boolean} Reference#partial
  22852. */
  22853. this.partial = partial;
  22854. /**
  22855. * Whether the Reference is to write of initialization.
  22856. * @member {boolean} Reference#init
  22857. */
  22858. this.init = init;
  22859. }
  22860. this.__maybeImplicitGlobal = maybeImplicitGlobal;
  22861. }
  22862. /**
  22863. * Whether the reference is static.
  22864. * @method Reference#isStatic
  22865. * @returns {boolean} static
  22866. */
  22867. _createClass(Reference, [{
  22868. key: "isStatic",
  22869. value: function isStatic() {
  22870. return !this.tainted && this.resolved && this.resolved.scope.isStatic();
  22871. }
  22872. /**
  22873. * Whether the reference is writeable.
  22874. * @method Reference#isWrite
  22875. * @returns {boolean} write
  22876. */
  22877. }, {
  22878. key: "isWrite",
  22879. value: function isWrite() {
  22880. return !!(this.flag & Reference.WRITE);
  22881. }
  22882. /**
  22883. * Whether the reference is readable.
  22884. * @method Reference#isRead
  22885. * @returns {boolean} read
  22886. */
  22887. }, {
  22888. key: "isRead",
  22889. value: function isRead() {
  22890. return !!(this.flag & Reference.READ);
  22891. }
  22892. /**
  22893. * Whether the reference is read-only.
  22894. * @method Reference#isReadOnly
  22895. * @returns {boolean} read only
  22896. */
  22897. }, {
  22898. key: "isReadOnly",
  22899. value: function isReadOnly() {
  22900. return this.flag === Reference.READ;
  22901. }
  22902. /**
  22903. * Whether the reference is write-only.
  22904. * @method Reference#isWriteOnly
  22905. * @returns {boolean} write only
  22906. */
  22907. }, {
  22908. key: "isWriteOnly",
  22909. value: function isWriteOnly() {
  22910. return this.flag === Reference.WRITE;
  22911. }
  22912. /**
  22913. * Whether the reference is read-write.
  22914. * @method Reference#isReadWrite
  22915. * @returns {boolean} read write
  22916. */
  22917. }, {
  22918. key: "isReadWrite",
  22919. value: function isReadWrite() {
  22920. return this.flag === Reference.RW;
  22921. }
  22922. }]);
  22923. return Reference;
  22924. }();
  22925. /**
  22926. * @constant Reference.READ
  22927. * @private
  22928. */
  22929. Reference.READ = READ;
  22930. /**
  22931. * @constant Reference.WRITE
  22932. * @private
  22933. */
  22934. Reference.WRITE = WRITE;
  22935. /**
  22936. * @constant Reference.RW
  22937. * @private
  22938. */
  22939. Reference.RW = RW;
  22940. module.exports = Reference;
  22941. /* vim: set sw=4 ts=4 et tw=80 : */
  22942. },{}],63:[function(require,module,exports){
  22943. /*
  22944. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  22945. Redistribution and use in source and binary forms, with or without
  22946. modification, are permitted provided that the following conditions are met:
  22947. * Redistributions of source code must retain the above copyright
  22948. notice, this list of conditions and the following disclaimer.
  22949. * Redistributions in binary form must reproduce the above copyright
  22950. notice, this list of conditions and the following disclaimer in the
  22951. documentation and/or other materials provided with the distribution.
  22952. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22953. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22954. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22955. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  22956. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22957. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22958. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22959. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22960. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22961. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22962. */
  22963. "use strict";
  22964. /* eslint-disable no-underscore-dangle */
  22965. /* eslint-disable no-undefined */
  22966. 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; }; }();
  22967. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22968. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  22969. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  22970. var Syntax = require("estraverse").Syntax;
  22971. var esrecurse = require("esrecurse");
  22972. var Reference = require("./reference");
  22973. var Variable = require("./variable");
  22974. var PatternVisitor = require("./pattern-visitor");
  22975. var definition = require("./definition");
  22976. var assert = require("assert");
  22977. var ParameterDefinition = definition.ParameterDefinition;
  22978. var Definition = definition.Definition;
  22979. /**
  22980. * Traverse identifier in pattern
  22981. * @param {Object} options - options
  22982. * @param {pattern} rootPattern - root pattern
  22983. * @param {Refencer} referencer - referencer
  22984. * @param {callback} callback - callback
  22985. * @returns {void}
  22986. */
  22987. function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
  22988. // Call the callback at left hand identifier nodes, and Collect right hand nodes.
  22989. var visitor = new PatternVisitor(options, rootPattern, callback);
  22990. visitor.visit(rootPattern);
  22991. // Process the right hand nodes recursively.
  22992. if (referencer !== null && referencer !== undefined) {
  22993. visitor.rightHandNodes.forEach(referencer.visit, referencer);
  22994. }
  22995. }
  22996. // Importing ImportDeclaration.
  22997. // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation
  22998. // https://github.com/estree/estree/blob/master/es6.md#importdeclaration
  22999. // FIXME: Now, we don't create module environment, because the context is
  23000. // implementation dependent.
  23001. var Importer = function (_esrecurse$Visitor) {
  23002. _inherits(Importer, _esrecurse$Visitor);
  23003. function Importer(declaration, referencer) {
  23004. _classCallCheck(this, Importer);
  23005. var _this = _possibleConstructorReturn(this, (Importer.__proto__ || Object.getPrototypeOf(Importer)).call(this, null, referencer.options));
  23006. _this.declaration = declaration;
  23007. _this.referencer = referencer;
  23008. return _this;
  23009. }
  23010. _createClass(Importer, [{
  23011. key: "visitImport",
  23012. value: function visitImport(id, specifier) {
  23013. var _this2 = this;
  23014. this.referencer.visitPattern(id, function (pattern) {
  23015. _this2.referencer.currentScope().__define(pattern, new Definition(Variable.ImportBinding, pattern, specifier, _this2.declaration, null, null));
  23016. });
  23017. }
  23018. }, {
  23019. key: "ImportNamespaceSpecifier",
  23020. value: function ImportNamespaceSpecifier(node) {
  23021. var local = node.local || node.id;
  23022. if (local) {
  23023. this.visitImport(local, node);
  23024. }
  23025. }
  23026. }, {
  23027. key: "ImportDefaultSpecifier",
  23028. value: function ImportDefaultSpecifier(node) {
  23029. var local = node.local || node.id;
  23030. this.visitImport(local, node);
  23031. }
  23032. }, {
  23033. key: "ImportSpecifier",
  23034. value: function ImportSpecifier(node) {
  23035. var local = node.local || node.id;
  23036. if (node.name) {
  23037. this.visitImport(node.name, node);
  23038. } else {
  23039. this.visitImport(local, node);
  23040. }
  23041. }
  23042. }]);
  23043. return Importer;
  23044. }(esrecurse.Visitor);
  23045. // Referencing variables and creating bindings.
  23046. var Referencer = function (_esrecurse$Visitor2) {
  23047. _inherits(Referencer, _esrecurse$Visitor2);
  23048. function Referencer(options, scopeManager) {
  23049. _classCallCheck(this, Referencer);
  23050. var _this3 = _possibleConstructorReturn(this, (Referencer.__proto__ || Object.getPrototypeOf(Referencer)).call(this, null, options));
  23051. _this3.options = options;
  23052. _this3.scopeManager = scopeManager;
  23053. _this3.parent = null;
  23054. _this3.isInnerMethodDefinition = false;
  23055. return _this3;
  23056. }
  23057. _createClass(Referencer, [{
  23058. key: "currentScope",
  23059. value: function currentScope() {
  23060. return this.scopeManager.__currentScope;
  23061. }
  23062. }, {
  23063. key: "close",
  23064. value: function close(node) {
  23065. while (this.currentScope() && node === this.currentScope().block) {
  23066. this.scopeManager.__currentScope = this.currentScope().__close(this.scopeManager);
  23067. }
  23068. }
  23069. }, {
  23070. key: "pushInnerMethodDefinition",
  23071. value: function pushInnerMethodDefinition(isInnerMethodDefinition) {
  23072. var previous = this.isInnerMethodDefinition;
  23073. this.isInnerMethodDefinition = isInnerMethodDefinition;
  23074. return previous;
  23075. }
  23076. }, {
  23077. key: "popInnerMethodDefinition",
  23078. value: function popInnerMethodDefinition(isInnerMethodDefinition) {
  23079. this.isInnerMethodDefinition = isInnerMethodDefinition;
  23080. }
  23081. }, {
  23082. key: "referencingDefaultValue",
  23083. value: function referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
  23084. var scope = this.currentScope();
  23085. assignments.forEach(function (assignment) {
  23086. scope.__referencing(pattern, Reference.WRITE, assignment.right, maybeImplicitGlobal, pattern !== assignment.left, init);
  23087. });
  23088. }
  23089. }, {
  23090. key: "visitPattern",
  23091. value: function visitPattern(node, options, callback) {
  23092. if (typeof options === "function") {
  23093. callback = options;
  23094. options = { processRightHandNodes: false };
  23095. }
  23096. traverseIdentifierInPattern(this.options, node, options.processRightHandNodes ? this : null, callback);
  23097. }
  23098. }, {
  23099. key: "visitFunction",
  23100. value: function visitFunction(node) {
  23101. var _this4 = this;
  23102. var i = void 0,
  23103. iz = void 0;
  23104. // FunctionDeclaration name is defined in upper scope
  23105. // NOTE: Not referring variableScope. It is intended.
  23106. // Since
  23107. // in ES5, FunctionDeclaration should be in FunctionBody.
  23108. // in ES6, FunctionDeclaration should be block scoped.
  23109. if (node.type === Syntax.FunctionDeclaration) {
  23110. // id is defined in upper scope
  23111. this.currentScope().__define(node.id, new Definition(Variable.FunctionName, node.id, node, null, null, null));
  23112. }
  23113. // FunctionExpression with name creates its special scope;
  23114. // FunctionExpressionNameScope.
  23115. if (node.type === Syntax.FunctionExpression && node.id) {
  23116. this.scopeManager.__nestFunctionExpressionNameScope(node);
  23117. }
  23118. // Consider this function is in the MethodDefinition.
  23119. this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
  23120. var that = this;
  23121. /**
  23122. * Visit pattern callback
  23123. * @param {pattern} pattern - pattern
  23124. * @param {Object} info - info
  23125. * @returns {void}
  23126. */
  23127. function visitPatternCallback(pattern, info) {
  23128. that.currentScope().__define(pattern, new ParameterDefinition(pattern, node, i, info.rest));
  23129. that.referencingDefaultValue(pattern, info.assignments, null, true);
  23130. }
  23131. // Process parameter declarations.
  23132. for (i = 0, iz = node.params.length; i < iz; ++i) {
  23133. this.visitPattern(node.params[i], { processRightHandNodes: true }, visitPatternCallback);
  23134. }
  23135. // if there's a rest argument, add that
  23136. if (node.rest) {
  23137. this.visitPattern({
  23138. type: "RestElement",
  23139. argument: node.rest
  23140. }, function (pattern) {
  23141. _this4.currentScope().__define(pattern, new ParameterDefinition(pattern, node, node.params.length, true));
  23142. });
  23143. }
  23144. // In TypeScript there are a number of function-like constructs which have no body,
  23145. // so check it exists before traversing
  23146. if (node.body) {
  23147. // Skip BlockStatement to prevent creating BlockStatement scope.
  23148. if (node.body.type === Syntax.BlockStatement) {
  23149. this.visitChildren(node.body);
  23150. } else {
  23151. this.visit(node.body);
  23152. }
  23153. }
  23154. this.close(node);
  23155. }
  23156. }, {
  23157. key: "visitClass",
  23158. value: function visitClass(node) {
  23159. if (node.type === Syntax.ClassDeclaration) {
  23160. this.currentScope().__define(node.id, new Definition(Variable.ClassName, node.id, node, null, null, null));
  23161. }
  23162. this.visit(node.superClass);
  23163. this.scopeManager.__nestClassScope(node);
  23164. if (node.id) {
  23165. this.currentScope().__define(node.id, new Definition(Variable.ClassName, node.id, node));
  23166. }
  23167. this.visit(node.body);
  23168. this.close(node);
  23169. }
  23170. }, {
  23171. key: "visitProperty",
  23172. value: function visitProperty(node) {
  23173. var previous = void 0;
  23174. if (node.computed) {
  23175. this.visit(node.key);
  23176. }
  23177. var isMethodDefinition = node.type === Syntax.MethodDefinition;
  23178. if (isMethodDefinition) {
  23179. previous = this.pushInnerMethodDefinition(true);
  23180. }
  23181. this.visit(node.value);
  23182. if (isMethodDefinition) {
  23183. this.popInnerMethodDefinition(previous);
  23184. }
  23185. }
  23186. }, {
  23187. key: "visitForIn",
  23188. value: function visitForIn(node) {
  23189. var _this5 = this;
  23190. if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
  23191. this.scopeManager.__nestForScope(node);
  23192. }
  23193. if (node.left.type === Syntax.VariableDeclaration) {
  23194. this.visit(node.left);
  23195. this.visitPattern(node.left.declarations[0].id, function (pattern) {
  23196. _this5.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
  23197. });
  23198. } else {
  23199. this.visitPattern(node.left, { processRightHandNodes: true }, function (pattern, info) {
  23200. var maybeImplicitGlobal = null;
  23201. if (!_this5.currentScope().isStrict) {
  23202. maybeImplicitGlobal = {
  23203. pattern: pattern,
  23204. node: node
  23205. };
  23206. }
  23207. _this5.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
  23208. _this5.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
  23209. });
  23210. }
  23211. this.visit(node.right);
  23212. this.visit(node.body);
  23213. this.close(node);
  23214. }
  23215. }, {
  23216. key: "visitVariableDeclaration",
  23217. value: function visitVariableDeclaration(variableTargetScope, type, node, index) {
  23218. var _this6 = this;
  23219. var decl = node.declarations[index];
  23220. var init = decl.init;
  23221. this.visitPattern(decl.id, { processRightHandNodes: true }, function (pattern, info) {
  23222. variableTargetScope.__define(pattern, new Definition(type, pattern, decl, node, index, node.kind));
  23223. _this6.referencingDefaultValue(pattern, info.assignments, null, true);
  23224. if (init) {
  23225. _this6.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true);
  23226. }
  23227. });
  23228. }
  23229. }, {
  23230. key: "AssignmentExpression",
  23231. value: function AssignmentExpression(node) {
  23232. var _this7 = this;
  23233. if (PatternVisitor.isPattern(node.left)) {
  23234. if (node.operator === "=") {
  23235. this.visitPattern(node.left, { processRightHandNodes: true }, function (pattern, info) {
  23236. var maybeImplicitGlobal = null;
  23237. if (!_this7.currentScope().isStrict) {
  23238. maybeImplicitGlobal = {
  23239. pattern: pattern,
  23240. node: node
  23241. };
  23242. }
  23243. _this7.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
  23244. _this7.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, !info.topLevel, false);
  23245. });
  23246. } else {
  23247. this.currentScope().__referencing(node.left, Reference.RW, node.right);
  23248. }
  23249. } else {
  23250. this.visit(node.left);
  23251. }
  23252. this.visit(node.right);
  23253. }
  23254. }, {
  23255. key: "CatchClause",
  23256. value: function CatchClause(node) {
  23257. var _this8 = this;
  23258. this.scopeManager.__nestCatchScope(node);
  23259. this.visitPattern(node.param, { processRightHandNodes: true }, function (pattern, info) {
  23260. _this8.currentScope().__define(pattern, new Definition(Variable.CatchClause, node.param, node, null, null, null));
  23261. _this8.referencingDefaultValue(pattern, info.assignments, null, true);
  23262. });
  23263. this.visit(node.body);
  23264. this.close(node);
  23265. }
  23266. }, {
  23267. key: "Program",
  23268. value: function Program(node) {
  23269. this.scopeManager.__nestGlobalScope(node);
  23270. if (this.scopeManager.__isNodejsScope()) {
  23271. // Force strictness of GlobalScope to false when using node.js scope.
  23272. this.currentScope().isStrict = false;
  23273. this.scopeManager.__nestFunctionScope(node, false);
  23274. }
  23275. if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
  23276. this.scopeManager.__nestModuleScope(node);
  23277. }
  23278. if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) {
  23279. this.currentScope().isStrict = true;
  23280. }
  23281. this.visitChildren(node);
  23282. this.close(node);
  23283. }
  23284. }, {
  23285. key: "Identifier",
  23286. value: function Identifier(node) {
  23287. this.currentScope().__referencing(node);
  23288. }
  23289. }, {
  23290. key: "UpdateExpression",
  23291. value: function UpdateExpression(node) {
  23292. if (PatternVisitor.isPattern(node.argument)) {
  23293. this.currentScope().__referencing(node.argument, Reference.RW, null);
  23294. } else {
  23295. this.visitChildren(node);
  23296. }
  23297. }
  23298. }, {
  23299. key: "MemberExpression",
  23300. value: function MemberExpression(node) {
  23301. this.visit(node.object);
  23302. if (node.computed) {
  23303. this.visit(node.property);
  23304. }
  23305. }
  23306. }, {
  23307. key: "Property",
  23308. value: function Property(node) {
  23309. this.visitProperty(node);
  23310. }
  23311. }, {
  23312. key: "MethodDefinition",
  23313. value: function MethodDefinition(node) {
  23314. this.visitProperty(node);
  23315. }
  23316. }, {
  23317. key: "BreakStatement",
  23318. value: function BreakStatement() {} // eslint-disable-line class-methods-use-this
  23319. }, {
  23320. key: "ContinueStatement",
  23321. value: function ContinueStatement() {} // eslint-disable-line class-methods-use-this
  23322. }, {
  23323. key: "LabeledStatement",
  23324. value: function LabeledStatement(node) {
  23325. this.visit(node.body);
  23326. }
  23327. }, {
  23328. key: "ForStatement",
  23329. value: function ForStatement(node) {
  23330. // Create ForStatement declaration.
  23331. // NOTE: In ES6, ForStatement dynamically generates
  23332. // per iteration environment. However, escope is
  23333. // a static analyzer, we only generate one scope for ForStatement.
  23334. if (node.init && node.init.type === Syntax.VariableDeclaration && node.init.kind !== "var") {
  23335. this.scopeManager.__nestForScope(node);
  23336. }
  23337. this.visitChildren(node);
  23338. this.close(node);
  23339. }
  23340. }, {
  23341. key: "ClassExpression",
  23342. value: function ClassExpression(node) {
  23343. this.visitClass(node);
  23344. }
  23345. }, {
  23346. key: "ClassDeclaration",
  23347. value: function ClassDeclaration(node) {
  23348. this.visitClass(node);
  23349. }
  23350. }, {
  23351. key: "CallExpression",
  23352. value: function CallExpression(node) {
  23353. // Check this is direct call to eval
  23354. if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
  23355. // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
  23356. // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
  23357. this.currentScope().variableScope.__detectEval();
  23358. }
  23359. this.visitChildren(node);
  23360. }
  23361. }, {
  23362. key: "BlockStatement",
  23363. value: function BlockStatement(node) {
  23364. if (this.scopeManager.__isES6()) {
  23365. this.scopeManager.__nestBlockScope(node);
  23366. }
  23367. this.visitChildren(node);
  23368. this.close(node);
  23369. }
  23370. }, {
  23371. key: "ThisExpression",
  23372. value: function ThisExpression() {
  23373. this.currentScope().variableScope.__detectThis();
  23374. }
  23375. }, {
  23376. key: "WithStatement",
  23377. value: function WithStatement(node) {
  23378. this.visit(node.object);
  23379. // Then nest scope for WithStatement.
  23380. this.scopeManager.__nestWithScope(node);
  23381. this.visit(node.body);
  23382. this.close(node);
  23383. }
  23384. }, {
  23385. key: "VariableDeclaration",
  23386. value: function VariableDeclaration(node) {
  23387. var variableTargetScope = node.kind === "var" ? this.currentScope().variableScope : this.currentScope();
  23388. for (var i = 0, iz = node.declarations.length; i < iz; ++i) {
  23389. var decl = node.declarations[i];
  23390. this.visitVariableDeclaration(variableTargetScope, Variable.Variable, node, i);
  23391. if (decl.init) {
  23392. this.visit(decl.init);
  23393. }
  23394. }
  23395. }
  23396. // sec 13.11.8
  23397. }, {
  23398. key: "SwitchStatement",
  23399. value: function SwitchStatement(node) {
  23400. this.visit(node.discriminant);
  23401. if (this.scopeManager.__isES6()) {
  23402. this.scopeManager.__nestSwitchScope(node);
  23403. }
  23404. for (var i = 0, iz = node.cases.length; i < iz; ++i) {
  23405. this.visit(node.cases[i]);
  23406. }
  23407. this.close(node);
  23408. }
  23409. }, {
  23410. key: "FunctionDeclaration",
  23411. value: function FunctionDeclaration(node) {
  23412. this.visitFunction(node);
  23413. }
  23414. }, {
  23415. key: "FunctionExpression",
  23416. value: function FunctionExpression(node) {
  23417. this.visitFunction(node);
  23418. }
  23419. }, {
  23420. key: "ForOfStatement",
  23421. value: function ForOfStatement(node) {
  23422. this.visitForIn(node);
  23423. }
  23424. }, {
  23425. key: "ForInStatement",
  23426. value: function ForInStatement(node) {
  23427. this.visitForIn(node);
  23428. }
  23429. }, {
  23430. key: "ArrowFunctionExpression",
  23431. value: function ArrowFunctionExpression(node) {
  23432. this.visitFunction(node);
  23433. }
  23434. }, {
  23435. key: "ImportDeclaration",
  23436. value: function ImportDeclaration(node) {
  23437. assert(this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
  23438. var importer = new Importer(node, this);
  23439. importer.visit(node);
  23440. }
  23441. }, {
  23442. key: "visitExportDeclaration",
  23443. value: function visitExportDeclaration(node) {
  23444. if (node.source) {
  23445. return;
  23446. }
  23447. if (node.declaration) {
  23448. this.visit(node.declaration);
  23449. return;
  23450. }
  23451. this.visitChildren(node);
  23452. }
  23453. }, {
  23454. key: "ExportDeclaration",
  23455. value: function ExportDeclaration(node) {
  23456. this.visitExportDeclaration(node);
  23457. }
  23458. }, {
  23459. key: "ExportNamedDeclaration",
  23460. value: function ExportNamedDeclaration(node) {
  23461. this.visitExportDeclaration(node);
  23462. }
  23463. }, {
  23464. key: "ExportSpecifier",
  23465. value: function ExportSpecifier(node) {
  23466. var local = node.id || node.local;
  23467. this.visit(local);
  23468. }
  23469. }, {
  23470. key: "MetaProperty",
  23471. value: function MetaProperty() {// eslint-disable-line class-methods-use-this
  23472. // do nothing.
  23473. }
  23474. }]);
  23475. return Referencer;
  23476. }(esrecurse.Visitor);
  23477. module.exports = Referencer;
  23478. /* vim: set sw=4 ts=4 et tw=80 : */
  23479. },{"./definition":59,"./pattern-visitor":61,"./reference":62,"./variable":66,"assert":46,"esrecurse":73,"estraverse":75}],64:[function(require,module,exports){
  23480. /*
  23481. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  23482. Redistribution and use in source and binary forms, with or without
  23483. modification, are permitted provided that the following conditions are met:
  23484. * Redistributions of source code must retain the above copyright
  23485. notice, this list of conditions and the following disclaimer.
  23486. * Redistributions in binary form must reproduce the above copyright
  23487. notice, this list of conditions and the following disclaimer in the
  23488. documentation and/or other materials provided with the distribution.
  23489. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23490. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23491. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23492. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  23493. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23494. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23495. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23496. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23497. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23498. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23499. */
  23500. "use strict";
  23501. /* eslint-disable no-underscore-dangle */
  23502. 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; }; }();
  23503. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  23504. var Scope = require("./scope");
  23505. var assert = require("assert");
  23506. var GlobalScope = Scope.GlobalScope;
  23507. var CatchScope = Scope.CatchScope;
  23508. var WithScope = Scope.WithScope;
  23509. var ModuleScope = Scope.ModuleScope;
  23510. var ClassScope = Scope.ClassScope;
  23511. var SwitchScope = Scope.SwitchScope;
  23512. var FunctionScope = Scope.FunctionScope;
  23513. var ForScope = Scope.ForScope;
  23514. var FunctionExpressionNameScope = Scope.FunctionExpressionNameScope;
  23515. var BlockScope = Scope.BlockScope;
  23516. /**
  23517. * @class ScopeManager
  23518. */
  23519. var ScopeManager = function () {
  23520. function ScopeManager(options) {
  23521. _classCallCheck(this, ScopeManager);
  23522. this.scopes = [];
  23523. this.globalScope = null;
  23524. this.__nodeToScope = new WeakMap();
  23525. this.__currentScope = null;
  23526. this.__options = options;
  23527. this.__declaredVariables = new WeakMap();
  23528. }
  23529. _createClass(ScopeManager, [{
  23530. key: "__useDirective",
  23531. value: function __useDirective() {
  23532. return this.__options.directive;
  23533. }
  23534. }, {
  23535. key: "__isOptimistic",
  23536. value: function __isOptimistic() {
  23537. return this.__options.optimistic;
  23538. }
  23539. }, {
  23540. key: "__ignoreEval",
  23541. value: function __ignoreEval() {
  23542. return this.__options.ignoreEval;
  23543. }
  23544. }, {
  23545. key: "__isNodejsScope",
  23546. value: function __isNodejsScope() {
  23547. return this.__options.nodejsScope;
  23548. }
  23549. }, {
  23550. key: "isModule",
  23551. value: function isModule() {
  23552. return this.__options.sourceType === "module";
  23553. }
  23554. }, {
  23555. key: "isImpliedStrict",
  23556. value: function isImpliedStrict() {
  23557. return this.__options.impliedStrict;
  23558. }
  23559. }, {
  23560. key: "isStrictModeSupported",
  23561. value: function isStrictModeSupported() {
  23562. return this.__options.ecmaVersion >= 5;
  23563. }
  23564. // Returns appropriate scope for this node.
  23565. }, {
  23566. key: "__get",
  23567. value: function __get(node) {
  23568. return this.__nodeToScope.get(node);
  23569. }
  23570. /**
  23571. * Get variables that are declared by the node.
  23572. *
  23573. * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
  23574. * If the node declares nothing, this method returns an empty array.
  23575. * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
  23576. *
  23577. * @param {Espree.Node} node - a node to get.
  23578. * @returns {Variable[]} variables that declared by the node.
  23579. */
  23580. }, {
  23581. key: "getDeclaredVariables",
  23582. value: function getDeclaredVariables(node) {
  23583. return this.__declaredVariables.get(node) || [];
  23584. }
  23585. /**
  23586. * acquire scope from node.
  23587. * @method ScopeManager#acquire
  23588. * @param {Espree.Node} node - node for the acquired scope.
  23589. * @param {boolean=} inner - look up the most inner scope, default value is false.
  23590. * @returns {Scope?} Scope from node
  23591. */
  23592. }, {
  23593. key: "acquire",
  23594. value: function acquire(node, inner) {
  23595. /**
  23596. * predicate
  23597. * @param {Scope} testScope - scope to test
  23598. * @returns {boolean} predicate
  23599. */
  23600. function predicate(testScope) {
  23601. if (testScope.type === "function" && testScope.functionExpressionScope) {
  23602. return false;
  23603. }
  23604. return true;
  23605. }
  23606. var scopes = this.__get(node);
  23607. if (!scopes || scopes.length === 0) {
  23608. return null;
  23609. }
  23610. // Heuristic selection from all scopes.
  23611. // If you would like to get all scopes, please use ScopeManager#acquireAll.
  23612. if (scopes.length === 1) {
  23613. return scopes[0];
  23614. }
  23615. if (inner) {
  23616. for (var i = scopes.length - 1; i >= 0; --i) {
  23617. var scope = scopes[i];
  23618. if (predicate(scope)) {
  23619. return scope;
  23620. }
  23621. }
  23622. } else {
  23623. for (var _i = 0, iz = scopes.length; _i < iz; ++_i) {
  23624. var _scope = scopes[_i];
  23625. if (predicate(_scope)) {
  23626. return _scope;
  23627. }
  23628. }
  23629. }
  23630. return null;
  23631. }
  23632. /**
  23633. * acquire all scopes from node.
  23634. * @method ScopeManager#acquireAll
  23635. * @param {Espree.Node} node - node for the acquired scope.
  23636. * @returns {Scopes?} Scope array
  23637. */
  23638. }, {
  23639. key: "acquireAll",
  23640. value: function acquireAll(node) {
  23641. return this.__get(node);
  23642. }
  23643. /**
  23644. * release the node.
  23645. * @method ScopeManager#release
  23646. * @param {Espree.Node} node - releasing node.
  23647. * @param {boolean=} inner - look up the most inner scope, default value is false.
  23648. * @returns {Scope?} upper scope for the node.
  23649. */
  23650. }, {
  23651. key: "release",
  23652. value: function release(node, inner) {
  23653. var scopes = this.__get(node);
  23654. if (scopes && scopes.length) {
  23655. var scope = scopes[0].upper;
  23656. if (!scope) {
  23657. return null;
  23658. }
  23659. return this.acquire(scope.block, inner);
  23660. }
  23661. return null;
  23662. }
  23663. }, {
  23664. key: "attach",
  23665. value: function attach() {} // eslint-disable-line class-methods-use-this
  23666. }, {
  23667. key: "detach",
  23668. value: function detach() {} // eslint-disable-line class-methods-use-this
  23669. }, {
  23670. key: "__nestScope",
  23671. value: function __nestScope(scope) {
  23672. if (scope instanceof GlobalScope) {
  23673. assert(this.__currentScope === null);
  23674. this.globalScope = scope;
  23675. }
  23676. this.__currentScope = scope;
  23677. return scope;
  23678. }
  23679. }, {
  23680. key: "__nestGlobalScope",
  23681. value: function __nestGlobalScope(node) {
  23682. return this.__nestScope(new GlobalScope(this, node));
  23683. }
  23684. }, {
  23685. key: "__nestBlockScope",
  23686. value: function __nestBlockScope(node) {
  23687. return this.__nestScope(new BlockScope(this, this.__currentScope, node));
  23688. }
  23689. }, {
  23690. key: "__nestFunctionScope",
  23691. value: function __nestFunctionScope(node, isMethodDefinition) {
  23692. return this.__nestScope(new FunctionScope(this, this.__currentScope, node, isMethodDefinition));
  23693. }
  23694. }, {
  23695. key: "__nestForScope",
  23696. value: function __nestForScope(node) {
  23697. return this.__nestScope(new ForScope(this, this.__currentScope, node));
  23698. }
  23699. }, {
  23700. key: "__nestCatchScope",
  23701. value: function __nestCatchScope(node) {
  23702. return this.__nestScope(new CatchScope(this, this.__currentScope, node));
  23703. }
  23704. }, {
  23705. key: "__nestWithScope",
  23706. value: function __nestWithScope(node) {
  23707. return this.__nestScope(new WithScope(this, this.__currentScope, node));
  23708. }
  23709. }, {
  23710. key: "__nestClassScope",
  23711. value: function __nestClassScope(node) {
  23712. return this.__nestScope(new ClassScope(this, this.__currentScope, node));
  23713. }
  23714. }, {
  23715. key: "__nestSwitchScope",
  23716. value: function __nestSwitchScope(node) {
  23717. return this.__nestScope(new SwitchScope(this, this.__currentScope, node));
  23718. }
  23719. }, {
  23720. key: "__nestModuleScope",
  23721. value: function __nestModuleScope(node) {
  23722. return this.__nestScope(new ModuleScope(this, this.__currentScope, node));
  23723. }
  23724. }, {
  23725. key: "__nestFunctionExpressionNameScope",
  23726. value: function __nestFunctionExpressionNameScope(node) {
  23727. return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node));
  23728. }
  23729. }, {
  23730. key: "__isES6",
  23731. value: function __isES6() {
  23732. return this.__options.ecmaVersion >= 6;
  23733. }
  23734. }]);
  23735. return ScopeManager;
  23736. }();
  23737. module.exports = ScopeManager;
  23738. /* vim: set sw=4 ts=4 et tw=80 : */
  23739. },{"./scope":65,"assert":46}],65:[function(require,module,exports){
  23740. /*
  23741. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  23742. Redistribution and use in source and binary forms, with or without
  23743. modification, are permitted provided that the following conditions are met:
  23744. * Redistributions of source code must retain the above copyright
  23745. notice, this list of conditions and the following disclaimer.
  23746. * Redistributions in binary form must reproduce the above copyright
  23747. notice, this list of conditions and the following disclaimer in the
  23748. documentation and/or other materials provided with the distribution.
  23749. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23750. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23751. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23752. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  23753. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23754. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23755. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23756. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23757. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23758. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23759. */
  23760. "use strict";
  23761. /* eslint-disable no-underscore-dangle */
  23762. /* eslint-disable no-undefined */
  23763. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  23764. 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; }; }();
  23765. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  23766. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  23767. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  23768. var Syntax = require("estraverse").Syntax;
  23769. var Reference = require("./reference");
  23770. var Variable = require("./variable");
  23771. var Definition = require("./definition").Definition;
  23772. var assert = require("assert");
  23773. /**
  23774. * Test if scope is struct
  23775. * @param {Scope} scope - scope
  23776. * @param {Block} block - block
  23777. * @param {boolean} isMethodDefinition - is method definiton
  23778. * @param {boolean} useDirective - use directive
  23779. * @returns {boolean} is strict scope
  23780. */
  23781. function isStrictScope(scope, block, isMethodDefinition, useDirective) {
  23782. var body = void 0;
  23783. // When upper scope is exists and strict, inner scope is also strict.
  23784. if (scope.upper && scope.upper.isStrict) {
  23785. return true;
  23786. }
  23787. // ArrowFunctionExpression's scope is always strict scope.
  23788. if (block.type === Syntax.ArrowFunctionExpression) {
  23789. return true;
  23790. }
  23791. if (isMethodDefinition) {
  23792. return true;
  23793. }
  23794. if (scope.type === "class" || scope.type === "module") {
  23795. return true;
  23796. }
  23797. if (scope.type === "block" || scope.type === "switch") {
  23798. return false;
  23799. }
  23800. if (scope.type === "function") {
  23801. if (block.type === Syntax.Program) {
  23802. body = block;
  23803. } else {
  23804. body = block.body;
  23805. }
  23806. if (!body) {
  23807. return false;
  23808. }
  23809. } else if (scope.type === "global") {
  23810. body = block;
  23811. } else {
  23812. return false;
  23813. }
  23814. // Search 'use strict' directive.
  23815. if (useDirective) {
  23816. for (var i = 0, iz = body.body.length; i < iz; ++i) {
  23817. var stmt = body.body[i];
  23818. if (stmt.type !== Syntax.DirectiveStatement) {
  23819. break;
  23820. }
  23821. if (stmt.raw === "\"use strict\"" || stmt.raw === "'use strict'") {
  23822. return true;
  23823. }
  23824. }
  23825. } else {
  23826. for (var _i = 0, _iz = body.body.length; _i < _iz; ++_i) {
  23827. var _stmt = body.body[_i];
  23828. if (_stmt.type !== Syntax.ExpressionStatement) {
  23829. break;
  23830. }
  23831. var expr = _stmt.expression;
  23832. if (expr.type !== Syntax.Literal || typeof expr.value !== "string") {
  23833. break;
  23834. }
  23835. if (expr.raw !== null && expr.raw !== undefined) {
  23836. if (expr.raw === "\"use strict\"" || expr.raw === "'use strict'") {
  23837. return true;
  23838. }
  23839. } else {
  23840. if (expr.value === "use strict") {
  23841. return true;
  23842. }
  23843. }
  23844. }
  23845. }
  23846. return false;
  23847. }
  23848. /**
  23849. * Register scope
  23850. * @param {ScopeManager} scopeManager - scope manager
  23851. * @param {Scope} scope - scope
  23852. * @returns {void}
  23853. */
  23854. function registerScope(scopeManager, scope) {
  23855. scopeManager.scopes.push(scope);
  23856. var scopes = scopeManager.__nodeToScope.get(scope.block);
  23857. if (scopes) {
  23858. scopes.push(scope);
  23859. } else {
  23860. scopeManager.__nodeToScope.set(scope.block, [scope]);
  23861. }
  23862. }
  23863. /**
  23864. * Should be statically
  23865. * @param {Object} def - def
  23866. * @returns {boolean} should be statically
  23867. */
  23868. function shouldBeStatically(def) {
  23869. return def.type === Variable.ClassName || def.type === Variable.Variable && def.parent.kind !== "var";
  23870. }
  23871. /**
  23872. * @class Scope
  23873. */
  23874. var Scope = function () {
  23875. function Scope(scopeManager, type, upperScope, block, isMethodDefinition) {
  23876. _classCallCheck(this, Scope);
  23877. /**
  23878. * One of 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'.
  23879. * @member {String} Scope#type
  23880. */
  23881. this.type = type;
  23882. /**
  23883. * The scoped {@link Variable}s of this scope, as <code>{ Variable.name
  23884. * : Variable }</code>.
  23885. * @member {Map} Scope#set
  23886. */
  23887. this.set = new Map();
  23888. /**
  23889. * The tainted variables of this scope, as <code>{ Variable.name :
  23890. * boolean }</code>.
  23891. * @member {Map} Scope#taints */
  23892. this.taints = new Map();
  23893. /**
  23894. * Generally, through the lexical scoping of JS you can always know
  23895. * which variable an identifier in the source code refers to. There are
  23896. * a few exceptions to this rule. With 'global' and 'with' scopes you
  23897. * can only decide at runtime which variable a reference refers to.
  23898. * Moreover, if 'eval()' is used in a scope, it might introduce new
  23899. * bindings in this or its parent scopes.
  23900. * All those scopes are considered 'dynamic'.
  23901. * @member {boolean} Scope#dynamic
  23902. */
  23903. this.dynamic = this.type === "global" || this.type === "with";
  23904. /**
  23905. * A reference to the scope-defining syntax node.
  23906. * @member {espree.Node} Scope#block
  23907. */
  23908. this.block = block;
  23909. /**
  23910. * The {@link Reference|references} that are not resolved with this scope.
  23911. * @member {Reference[]} Scope#through
  23912. */
  23913. this.through = [];
  23914. /**
  23915. * The scoped {@link Variable}s of this scope. In the case of a
  23916. * 'function' scope this includes the automatic argument <em>arguments</em> as
  23917. * its first element, as well as all further formal arguments.
  23918. * @member {Variable[]} Scope#variables
  23919. */
  23920. this.variables = [];
  23921. /**
  23922. * Any variable {@link Reference|reference} found in this scope. This
  23923. * includes occurrences of local variables as well as variables from
  23924. * parent scopes (including the global scope). For local variables
  23925. * this also includes defining occurrences (like in a 'var' statement).
  23926. * In a 'function' scope this does not include the occurrences of the
  23927. * formal parameter in the parameter list.
  23928. * @member {Reference[]} Scope#references
  23929. */
  23930. this.references = [];
  23931. /**
  23932. * For 'global' and 'function' scopes, this is a self-reference. For
  23933. * other scope types this is the <em>variableScope</em> value of the
  23934. * parent scope.
  23935. * @member {Scope} Scope#variableScope
  23936. */
  23937. this.variableScope = this.type === "global" || this.type === "function" || this.type === "module" ? this : upperScope.variableScope;
  23938. /**
  23939. * Whether this scope is created by a FunctionExpression.
  23940. * @member {boolean} Scope#functionExpressionScope
  23941. */
  23942. this.functionExpressionScope = false;
  23943. /**
  23944. * Whether this is a scope that contains an 'eval()' invocation.
  23945. * @member {boolean} Scope#directCallToEvalScope
  23946. */
  23947. this.directCallToEvalScope = false;
  23948. /**
  23949. * @member {boolean} Scope#thisFound
  23950. */
  23951. this.thisFound = false;
  23952. this.__left = [];
  23953. /**
  23954. * Reference to the parent {@link Scope|scope}.
  23955. * @member {Scope} Scope#upper
  23956. */
  23957. this.upper = upperScope;
  23958. /**
  23959. * Whether 'use strict' is in effect in this scope.
  23960. * @member {boolean} Scope#isStrict
  23961. */
  23962. this.isStrict = isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective());
  23963. /**
  23964. * List of nested {@link Scope}s.
  23965. * @member {Scope[]} Scope#childScopes
  23966. */
  23967. this.childScopes = [];
  23968. if (this.upper) {
  23969. this.upper.childScopes.push(this);
  23970. }
  23971. this.__declaredVariables = scopeManager.__declaredVariables;
  23972. registerScope(scopeManager, this);
  23973. }
  23974. _createClass(Scope, [{
  23975. key: "__shouldStaticallyClose",
  23976. value: function __shouldStaticallyClose(scopeManager) {
  23977. return !this.dynamic || scopeManager.__isOptimistic();
  23978. }
  23979. }, {
  23980. key: "__shouldStaticallyCloseForGlobal",
  23981. value: function __shouldStaticallyCloseForGlobal(ref) {
  23982. // On global scope, let/const/class declarations should be resolved statically.
  23983. var name = ref.identifier.name;
  23984. if (!this.set.has(name)) {
  23985. return false;
  23986. }
  23987. var variable = this.set.get(name);
  23988. var defs = variable.defs;
  23989. return defs.length > 0 && defs.every(shouldBeStatically);
  23990. }
  23991. }, {
  23992. key: "__staticCloseRef",
  23993. value: function __staticCloseRef(ref) {
  23994. if (!this.__resolve(ref)) {
  23995. this.__delegateToUpperScope(ref);
  23996. }
  23997. }
  23998. }, {
  23999. key: "__dynamicCloseRef",
  24000. value: function __dynamicCloseRef(ref) {
  24001. // notify all names are through to global
  24002. var current = this;
  24003. do {
  24004. current.through.push(ref);
  24005. current = current.upper;
  24006. } while (current);
  24007. }
  24008. }, {
  24009. key: "__globalCloseRef",
  24010. value: function __globalCloseRef(ref) {
  24011. // let/const/class declarations should be resolved statically.
  24012. // others should be resolved dynamically.
  24013. if (this.__shouldStaticallyCloseForGlobal(ref)) {
  24014. this.__staticCloseRef(ref);
  24015. } else {
  24016. this.__dynamicCloseRef(ref);
  24017. }
  24018. }
  24019. }, {
  24020. key: "__close",
  24021. value: function __close(scopeManager) {
  24022. var closeRef = void 0;
  24023. if (this.__shouldStaticallyClose(scopeManager)) {
  24024. closeRef = this.__staticCloseRef;
  24025. } else if (this.type !== "global") {
  24026. closeRef = this.__dynamicCloseRef;
  24027. } else {
  24028. closeRef = this.__globalCloseRef;
  24029. }
  24030. // Try Resolving all references in this scope.
  24031. for (var i = 0, iz = this.__left.length; i < iz; ++i) {
  24032. var ref = this.__left[i];
  24033. closeRef.call(this, ref);
  24034. }
  24035. this.__left = null;
  24036. return this.upper;
  24037. }
  24038. // To override by function scopes.
  24039. // References in default parameters isn't resolved to variables which are in their function body.
  24040. }, {
  24041. key: "__isValidResolution",
  24042. value: function __isValidResolution(ref, variable) {
  24043. // eslint-disable-line class-methods-use-this, no-unused-vars
  24044. return true;
  24045. }
  24046. }, {
  24047. key: "__resolve",
  24048. value: function __resolve(ref) {
  24049. var name = ref.identifier.name;
  24050. if (!this.set.has(name)) {
  24051. return false;
  24052. }
  24053. var variable = this.set.get(name);
  24054. if (!this.__isValidResolution(ref, variable)) {
  24055. return false;
  24056. }
  24057. variable.references.push(ref);
  24058. variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
  24059. if (ref.tainted) {
  24060. variable.tainted = true;
  24061. this.taints.set(variable.name, true);
  24062. }
  24063. ref.resolved = variable;
  24064. return true;
  24065. }
  24066. }, {
  24067. key: "__delegateToUpperScope",
  24068. value: function __delegateToUpperScope(ref) {
  24069. if (this.upper) {
  24070. this.upper.__left.push(ref);
  24071. }
  24072. this.through.push(ref);
  24073. }
  24074. }, {
  24075. key: "__addDeclaredVariablesOfNode",
  24076. value: function __addDeclaredVariablesOfNode(variable, node) {
  24077. if (node === null || node === undefined) {
  24078. return;
  24079. }
  24080. var variables = this.__declaredVariables.get(node);
  24081. if (variables === null || variables === undefined) {
  24082. variables = [];
  24083. this.__declaredVariables.set(node, variables);
  24084. }
  24085. if (variables.indexOf(variable) === -1) {
  24086. variables.push(variable);
  24087. }
  24088. }
  24089. }, {
  24090. key: "__defineGeneric",
  24091. value: function __defineGeneric(name, set, variables, node, def) {
  24092. var variable = void 0;
  24093. variable = set.get(name);
  24094. if (!variable) {
  24095. variable = new Variable(name, this);
  24096. set.set(name, variable);
  24097. variables.push(variable);
  24098. }
  24099. if (def) {
  24100. variable.defs.push(def);
  24101. this.__addDeclaredVariablesOfNode(variable, def.node);
  24102. this.__addDeclaredVariablesOfNode(variable, def.parent);
  24103. }
  24104. if (node) {
  24105. variable.identifiers.push(node);
  24106. }
  24107. }
  24108. }, {
  24109. key: "__define",
  24110. value: function __define(node, def) {
  24111. if (node && node.type === Syntax.Identifier) {
  24112. this.__defineGeneric(node.name, this.set, this.variables, node, def);
  24113. }
  24114. }
  24115. }, {
  24116. key: "__referencing",
  24117. value: function __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
  24118. // because Array element may be null
  24119. if (!node || node.type !== Syntax.Identifier) {
  24120. return;
  24121. }
  24122. // Specially handle like `this`.
  24123. if (node.name === "super") {
  24124. return;
  24125. }
  24126. var ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal, !!partial, !!init);
  24127. this.references.push(ref);
  24128. this.__left.push(ref);
  24129. }
  24130. }, {
  24131. key: "__detectEval",
  24132. value: function __detectEval() {
  24133. var current = this;
  24134. this.directCallToEvalScope = true;
  24135. do {
  24136. current.dynamic = true;
  24137. current = current.upper;
  24138. } while (current);
  24139. }
  24140. }, {
  24141. key: "__detectThis",
  24142. value: function __detectThis() {
  24143. this.thisFound = true;
  24144. }
  24145. }, {
  24146. key: "__isClosed",
  24147. value: function __isClosed() {
  24148. return this.__left === null;
  24149. }
  24150. /**
  24151. * returns resolved {Reference}
  24152. * @method Scope#resolve
  24153. * @param {Espree.Identifier} ident - identifier to be resolved.
  24154. * @returns {Reference} reference
  24155. */
  24156. }, {
  24157. key: "resolve",
  24158. value: function resolve(ident) {
  24159. var ref = void 0,
  24160. i = void 0,
  24161. iz = void 0;
  24162. assert(this.__isClosed(), "Scope should be closed.");
  24163. assert(ident.type === Syntax.Identifier, "Target should be identifier.");
  24164. for (i = 0, iz = this.references.length; i < iz; ++i) {
  24165. ref = this.references[i];
  24166. if (ref.identifier === ident) {
  24167. return ref;
  24168. }
  24169. }
  24170. return null;
  24171. }
  24172. /**
  24173. * returns this scope is static
  24174. * @method Scope#isStatic
  24175. * @returns {boolean} static
  24176. */
  24177. }, {
  24178. key: "isStatic",
  24179. value: function isStatic() {
  24180. return !this.dynamic;
  24181. }
  24182. /**
  24183. * returns this scope has materialized arguments
  24184. * @method Scope#isArgumentsMaterialized
  24185. * @returns {boolean} arguemnts materialized
  24186. */
  24187. }, {
  24188. key: "isArgumentsMaterialized",
  24189. value: function isArgumentsMaterialized() {
  24190. // eslint-disable-line class-methods-use-this
  24191. return true;
  24192. }
  24193. /**
  24194. * returns this scope has materialized `this` reference
  24195. * @method Scope#isThisMaterialized
  24196. * @returns {boolean} this materialized
  24197. */
  24198. }, {
  24199. key: "isThisMaterialized",
  24200. value: function isThisMaterialized() {
  24201. // eslint-disable-line class-methods-use-this
  24202. return true;
  24203. }
  24204. }, {
  24205. key: "isUsedName",
  24206. value: function isUsedName(name) {
  24207. if (this.set.has(name)) {
  24208. return true;
  24209. }
  24210. for (var i = 0, iz = this.through.length; i < iz; ++i) {
  24211. if (this.through[i].identifier.name === name) {
  24212. return true;
  24213. }
  24214. }
  24215. return false;
  24216. }
  24217. }]);
  24218. return Scope;
  24219. }();
  24220. var GlobalScope = function (_Scope) {
  24221. _inherits(GlobalScope, _Scope);
  24222. function GlobalScope(scopeManager, block) {
  24223. _classCallCheck(this, GlobalScope);
  24224. var _this = _possibleConstructorReturn(this, (GlobalScope.__proto__ || Object.getPrototypeOf(GlobalScope)).call(this, scopeManager, "global", null, block, false));
  24225. _this.implicit = {
  24226. set: new Map(),
  24227. variables: [],
  24228. /**
  24229. * List of {@link Reference}s that are left to be resolved (i.e. which
  24230. * need to be linked to the variable they refer to).
  24231. * @member {Reference[]} Scope#implicit#left
  24232. */
  24233. left: []
  24234. };
  24235. return _this;
  24236. }
  24237. _createClass(GlobalScope, [{
  24238. key: "__close",
  24239. value: function __close(scopeManager) {
  24240. var implicit = [];
  24241. for (var i = 0, iz = this.__left.length; i < iz; ++i) {
  24242. var ref = this.__left[i];
  24243. if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
  24244. implicit.push(ref.__maybeImplicitGlobal);
  24245. }
  24246. }
  24247. // create an implicit global variable from assignment expression
  24248. for (var _i2 = 0, _iz2 = implicit.length; _i2 < _iz2; ++_i2) {
  24249. var info = implicit[_i2];
  24250. this.__defineImplicit(info.pattern, new Definition(Variable.ImplicitGlobalVariable, info.pattern, info.node, null, null, null));
  24251. }
  24252. this.implicit.left = this.__left;
  24253. return _get(GlobalScope.prototype.__proto__ || Object.getPrototypeOf(GlobalScope.prototype), "__close", this).call(this, scopeManager);
  24254. }
  24255. }, {
  24256. key: "__defineImplicit",
  24257. value: function __defineImplicit(node, def) {
  24258. if (node && node.type === Syntax.Identifier) {
  24259. this.__defineGeneric(node.name, this.implicit.set, this.implicit.variables, node, def);
  24260. }
  24261. }
  24262. }]);
  24263. return GlobalScope;
  24264. }(Scope);
  24265. var ModuleScope = function (_Scope2) {
  24266. _inherits(ModuleScope, _Scope2);
  24267. function ModuleScope(scopeManager, upperScope, block) {
  24268. _classCallCheck(this, ModuleScope);
  24269. return _possibleConstructorReturn(this, (ModuleScope.__proto__ || Object.getPrototypeOf(ModuleScope)).call(this, scopeManager, "module", upperScope, block, false));
  24270. }
  24271. return ModuleScope;
  24272. }(Scope);
  24273. var FunctionExpressionNameScope = function (_Scope3) {
  24274. _inherits(FunctionExpressionNameScope, _Scope3);
  24275. function FunctionExpressionNameScope(scopeManager, upperScope, block) {
  24276. _classCallCheck(this, FunctionExpressionNameScope);
  24277. var _this3 = _possibleConstructorReturn(this, (FunctionExpressionNameScope.__proto__ || Object.getPrototypeOf(FunctionExpressionNameScope)).call(this, scopeManager, "function-expression-name", upperScope, block, false));
  24278. _this3.__define(block.id, new Definition(Variable.FunctionName, block.id, block, null, null, null));
  24279. _this3.functionExpressionScope = true;
  24280. return _this3;
  24281. }
  24282. return FunctionExpressionNameScope;
  24283. }(Scope);
  24284. var CatchScope = function (_Scope4) {
  24285. _inherits(CatchScope, _Scope4);
  24286. function CatchScope(scopeManager, upperScope, block) {
  24287. _classCallCheck(this, CatchScope);
  24288. return _possibleConstructorReturn(this, (CatchScope.__proto__ || Object.getPrototypeOf(CatchScope)).call(this, scopeManager, "catch", upperScope, block, false));
  24289. }
  24290. return CatchScope;
  24291. }(Scope);
  24292. var WithScope = function (_Scope5) {
  24293. _inherits(WithScope, _Scope5);
  24294. function WithScope(scopeManager, upperScope, block) {
  24295. _classCallCheck(this, WithScope);
  24296. return _possibleConstructorReturn(this, (WithScope.__proto__ || Object.getPrototypeOf(WithScope)).call(this, scopeManager, "with", upperScope, block, false));
  24297. }
  24298. _createClass(WithScope, [{
  24299. key: "__close",
  24300. value: function __close(scopeManager) {
  24301. if (this.__shouldStaticallyClose(scopeManager)) {
  24302. return _get(WithScope.prototype.__proto__ || Object.getPrototypeOf(WithScope.prototype), "__close", this).call(this, scopeManager);
  24303. }
  24304. for (var i = 0, iz = this.__left.length; i < iz; ++i) {
  24305. var ref = this.__left[i];
  24306. ref.tainted = true;
  24307. this.__delegateToUpperScope(ref);
  24308. }
  24309. this.__left = null;
  24310. return this.upper;
  24311. }
  24312. }]);
  24313. return WithScope;
  24314. }(Scope);
  24315. var BlockScope = function (_Scope6) {
  24316. _inherits(BlockScope, _Scope6);
  24317. function BlockScope(scopeManager, upperScope, block) {
  24318. _classCallCheck(this, BlockScope);
  24319. return _possibleConstructorReturn(this, (BlockScope.__proto__ || Object.getPrototypeOf(BlockScope)).call(this, scopeManager, "block", upperScope, block, false));
  24320. }
  24321. return BlockScope;
  24322. }(Scope);
  24323. var SwitchScope = function (_Scope7) {
  24324. _inherits(SwitchScope, _Scope7);
  24325. function SwitchScope(scopeManager, upperScope, block) {
  24326. _classCallCheck(this, SwitchScope);
  24327. return _possibleConstructorReturn(this, (SwitchScope.__proto__ || Object.getPrototypeOf(SwitchScope)).call(this, scopeManager, "switch", upperScope, block, false));
  24328. }
  24329. return SwitchScope;
  24330. }(Scope);
  24331. var FunctionScope = function (_Scope8) {
  24332. _inherits(FunctionScope, _Scope8);
  24333. function FunctionScope(scopeManager, upperScope, block, isMethodDefinition) {
  24334. _classCallCheck(this, FunctionScope);
  24335. // section 9.2.13, FunctionDeclarationInstantiation.
  24336. // NOTE Arrow functions never have an arguments objects.
  24337. var _this8 = _possibleConstructorReturn(this, (FunctionScope.__proto__ || Object.getPrototypeOf(FunctionScope)).call(this, scopeManager, "function", upperScope, block, isMethodDefinition));
  24338. if (_this8.block.type !== Syntax.ArrowFunctionExpression) {
  24339. _this8.__defineArguments();
  24340. }
  24341. return _this8;
  24342. }
  24343. _createClass(FunctionScope, [{
  24344. key: "isArgumentsMaterialized",
  24345. value: function isArgumentsMaterialized() {
  24346. // TODO(Constellation)
  24347. // We can more aggressive on this condition like this.
  24348. //
  24349. // function t() {
  24350. // // arguments of t is always hidden.
  24351. // function arguments() {
  24352. // }
  24353. // }
  24354. if (this.block.type === Syntax.ArrowFunctionExpression) {
  24355. return false;
  24356. }
  24357. if (!this.isStatic()) {
  24358. return true;
  24359. }
  24360. var variable = this.set.get("arguments");
  24361. assert(variable, "Always have arguments variable.");
  24362. return variable.tainted || variable.references.length !== 0;
  24363. }
  24364. }, {
  24365. key: "isThisMaterialized",
  24366. value: function isThisMaterialized() {
  24367. if (!this.isStatic()) {
  24368. return true;
  24369. }
  24370. return this.thisFound;
  24371. }
  24372. }, {
  24373. key: "__defineArguments",
  24374. value: function __defineArguments() {
  24375. this.__defineGeneric("arguments", this.set, this.variables, null, null);
  24376. this.taints.set("arguments", true);
  24377. }
  24378. // References in default parameters isn't resolved to variables which are in their function body.
  24379. // const x = 1
  24380. // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
  24381. // const x = 2
  24382. // console.log(a)
  24383. // }
  24384. }, {
  24385. key: "__isValidResolution",
  24386. value: function __isValidResolution(ref, variable) {
  24387. // If `options.nodejsScope` is true, `this.block` becomes a Program node.
  24388. if (this.block.type === "Program") {
  24389. return true;
  24390. }
  24391. var bodyStart = this.block.body.range[0];
  24392. // It's invalid resolution in the following case:
  24393. return !(variable.scope === this && ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
  24394. variable.defs.every(function (d) {
  24395. return d.name.range[0] >= bodyStart;
  24396. }) // the variable is in the body.
  24397. );
  24398. }
  24399. }]);
  24400. return FunctionScope;
  24401. }(Scope);
  24402. var ForScope = function (_Scope9) {
  24403. _inherits(ForScope, _Scope9);
  24404. function ForScope(scopeManager, upperScope, block) {
  24405. _classCallCheck(this, ForScope);
  24406. return _possibleConstructorReturn(this, (ForScope.__proto__ || Object.getPrototypeOf(ForScope)).call(this, scopeManager, "for", upperScope, block, false));
  24407. }
  24408. return ForScope;
  24409. }(Scope);
  24410. var ClassScope = function (_Scope10) {
  24411. _inherits(ClassScope, _Scope10);
  24412. function ClassScope(scopeManager, upperScope, block) {
  24413. _classCallCheck(this, ClassScope);
  24414. return _possibleConstructorReturn(this, (ClassScope.__proto__ || Object.getPrototypeOf(ClassScope)).call(this, scopeManager, "class", upperScope, block, false));
  24415. }
  24416. return ClassScope;
  24417. }(Scope);
  24418. module.exports = {
  24419. Scope: Scope,
  24420. GlobalScope: GlobalScope,
  24421. ModuleScope: ModuleScope,
  24422. FunctionExpressionNameScope: FunctionExpressionNameScope,
  24423. CatchScope: CatchScope,
  24424. WithScope: WithScope,
  24425. BlockScope: BlockScope,
  24426. SwitchScope: SwitchScope,
  24427. FunctionScope: FunctionScope,
  24428. ForScope: ForScope,
  24429. ClassScope: ClassScope
  24430. };
  24431. /* vim: set sw=4 ts=4 et tw=80 : */
  24432. },{"./definition":59,"./reference":62,"./variable":66,"assert":46,"estraverse":75}],66:[function(require,module,exports){
  24433. /*
  24434. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  24435. Redistribution and use in source and binary forms, with or without
  24436. modification, are permitted provided that the following conditions are met:
  24437. * Redistributions of source code must retain the above copyright
  24438. notice, this list of conditions and the following disclaimer.
  24439. * Redistributions in binary form must reproduce the above copyright
  24440. notice, this list of conditions and the following disclaimer in the
  24441. documentation and/or other materials provided with the distribution.
  24442. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24443. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24444. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24445. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  24446. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24447. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24448. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24449. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24450. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24451. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24452. */
  24453. "use strict";
  24454. /**
  24455. * A Variable represents a locally scoped identifier. These include arguments to
  24456. * functions.
  24457. * @class Variable
  24458. */
  24459. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24460. var Variable = function Variable(name, scope) {
  24461. _classCallCheck(this, Variable);
  24462. /**
  24463. * The variable name, as given in the source code.
  24464. * @member {String} Variable#name
  24465. */
  24466. this.name = name;
  24467. /**
  24468. * List of defining occurrences of this variable (like in 'var ...'
  24469. * statements or as parameter), as AST nodes.
  24470. * @member {espree.Identifier[]} Variable#identifiers
  24471. */
  24472. this.identifiers = [];
  24473. /**
  24474. * List of {@link Reference|references} of this variable (excluding parameter entries)
  24475. * in its defining scope and all nested scopes. For defining
  24476. * occurrences only see {@link Variable#defs}.
  24477. * @member {Reference[]} Variable#references
  24478. */
  24479. this.references = [];
  24480. /**
  24481. * List of defining occurrences of this variable (like in 'var ...'
  24482. * statements or as parameter), as custom objects.
  24483. * @member {Definition[]} Variable#defs
  24484. */
  24485. this.defs = [];
  24486. this.tainted = false;
  24487. /**
  24488. * Whether this is a stack variable.
  24489. * @member {boolean} Variable#stack
  24490. */
  24491. this.stack = true;
  24492. /**
  24493. * Reference to the enclosing Scope.
  24494. * @member {Scope} Variable#scope
  24495. */
  24496. this.scope = scope;
  24497. };
  24498. Variable.CatchClause = "CatchClause";
  24499. Variable.Parameter = "Parameter";
  24500. Variable.FunctionName = "FunctionName";
  24501. Variable.ClassName = "ClassName";
  24502. Variable.Variable = "Variable";
  24503. Variable.ImportBinding = "ImportBinding";
  24504. Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
  24505. module.exports = Variable;
  24506. /* vim: set sw=4 ts=4 et tw=80 : */
  24507. },{}],67:[function(require,module,exports){
  24508. module.exports={
  24509. "_from": "eslint-scope@^4.0.0",
  24510. "_id": "eslint-scope@4.0.0",
  24511. "_inBundle": false,
  24512. "_integrity": "sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA==",
  24513. "_location": "/eslint-scope",
  24514. "_phantomChildren": {},
  24515. "_requested": {
  24516. "type": "range",
  24517. "registry": true,
  24518. "raw": "eslint-scope@^4.0.0",
  24519. "name": "eslint-scope",
  24520. "escapedName": "eslint-scope",
  24521. "rawSpec": "^4.0.0",
  24522. "saveSpec": null,
  24523. "fetchSpec": "^4.0.0"
  24524. },
  24525. "_requiredBy": [
  24526. "/"
  24527. ],
  24528. "_resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz",
  24529. "_shasum": "50bf3071e9338bcdc43331794a0cb533f0136172",
  24530. "_spec": "eslint-scope@^4.0.0",
  24531. "_where": "/var/lib/jenkins/workspace/Releases/eslint Release/eslint",
  24532. "bugs": {
  24533. "url": "https://github.com/eslint/eslint-scope/issues"
  24534. },
  24535. "bundleDependencies": false,
  24536. "dependencies": {
  24537. "esrecurse": "^4.1.0",
  24538. "estraverse": "^4.1.1"
  24539. },
  24540. "deprecated": false,
  24541. "description": "ECMAScript scope analyzer for ESLint",
  24542. "devDependencies": {
  24543. "chai": "^3.4.1",
  24544. "eslint": "^3.15.0",
  24545. "eslint-config-eslint": "^4.0.0",
  24546. "eslint-release": "^0.11.1",
  24547. "espree": "^3.1.1",
  24548. "istanbul": "^0.4.5",
  24549. "mocha": "^3.2.0",
  24550. "npm-license": "^0.3.3",
  24551. "shelljs": "^0.7.6",
  24552. "typescript": "~2.0.10",
  24553. "typescript-eslint-parser": "^1.0.0"
  24554. },
  24555. "engines": {
  24556. "node": ">=4.0.0"
  24557. },
  24558. "files": [
  24559. "LICENSE",
  24560. "README.md",
  24561. "lib"
  24562. ],
  24563. "homepage": "http://github.com/eslint/eslint-scope",
  24564. "license": "BSD-2-Clause",
  24565. "main": "lib/index.js",
  24566. "name": "eslint-scope",
  24567. "repository": {
  24568. "type": "git",
  24569. "url": "git+https://github.com/eslint/eslint-scope.git"
  24570. },
  24571. "scripts": {
  24572. "alpharelease": "eslint-prerelease alpha",
  24573. "betarelease": "eslint-prerelease beta",
  24574. "ci-release": "eslint-ci-release",
  24575. "gh-release": "eslint-gh-release",
  24576. "lint": "node Makefile.js lint",
  24577. "rcrelease": "eslint-prerelease rc",
  24578. "release": "eslint-release",
  24579. "test": "node Makefile.js test"
  24580. },
  24581. "version": "4.0.0"
  24582. }
  24583. },{}],68:[function(require,module,exports){
  24584. (function (global){
  24585. /*! @author Toru Nagashima <https://github.com/mysticatea> */
  24586. 'use strict';
  24587. 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; }; }();
  24588. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  24589. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  24590. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24591. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  24592. Object.defineProperty(exports, '__esModule', { value: true });
  24593. /**
  24594. * Get the innermost scope which contains a given location.
  24595. * @param {Scope} initialScope The initial scope to search.
  24596. * @param {Node} node The location to search.
  24597. * @returns {Scope} The innermost scope.
  24598. */
  24599. function getInnermostScope(initialScope, node) {
  24600. var location = node.range[0];
  24601. var scope = initialScope;
  24602. var found = false;
  24603. do {
  24604. found = false;
  24605. var _iteratorNormalCompletion = true;
  24606. var _didIteratorError = false;
  24607. var _iteratorError = undefined;
  24608. try {
  24609. for (var _iterator = scope.childScopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  24610. var childScope = _step.value;
  24611. var range = childScope.block.range;
  24612. if (range[0] <= location && location < range[1]) {
  24613. scope = childScope;
  24614. found = true;
  24615. break;
  24616. }
  24617. }
  24618. } catch (err) {
  24619. _didIteratorError = true;
  24620. _iteratorError = err;
  24621. } finally {
  24622. try {
  24623. if (!_iteratorNormalCompletion && _iterator.return) {
  24624. _iterator.return();
  24625. }
  24626. } finally {
  24627. if (_didIteratorError) {
  24628. throw _iteratorError;
  24629. }
  24630. }
  24631. }
  24632. } while (found);
  24633. return scope;
  24634. }
  24635. /**
  24636. * Find the variable of a given name.
  24637. * @param {Scope} initialScope The scope to start finding.
  24638. * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
  24639. * @returns {Variable|null} The found variable or null.
  24640. */
  24641. function findVariable(initialScope, nameOrNode) {
  24642. var name = "";
  24643. var scope = initialScope;
  24644. if (typeof nameOrNode === "string") {
  24645. name = nameOrNode;
  24646. } else {
  24647. name = nameOrNode.name;
  24648. scope = getInnermostScope(scope, nameOrNode);
  24649. }
  24650. while (scope != null) {
  24651. var variable = scope.set.get(name);
  24652. if (variable != null) {
  24653. return variable;
  24654. }
  24655. scope = scope.upper;
  24656. }
  24657. return null;
  24658. }
  24659. /**
  24660. * Negate the result of `this` calling.
  24661. * @param {Token} token The token to check.
  24662. * @returns {boolean} `true` if the result of `this(token)` is `false`.
  24663. */
  24664. function negate0(token) {
  24665. return !this(token); //eslint-disable-line no-invalid-this
  24666. }
  24667. /**
  24668. * Creates the negate function of the given function.
  24669. * @param {function(Token):boolean} f - The function to negate.
  24670. * @returns {function(Token):boolean} Negated function.
  24671. */
  24672. function negate(f) {
  24673. return negate0.bind(f);
  24674. }
  24675. /**
  24676. * Checks if the given token is an arrow token or not.
  24677. * @param {Token} token - The token to check.
  24678. * @returns {boolean} `true` if the token is an arrow token.
  24679. */
  24680. function isArrowToken(token) {
  24681. return token.value === "=>" && token.type === "Punctuator";
  24682. }
  24683. /**
  24684. * Checks if the given token is a comma token or not.
  24685. * @param {Token} token - The token to check.
  24686. * @returns {boolean} `true` if the token is a comma token.
  24687. */
  24688. function isCommaToken(token) {
  24689. return token.value === "," && token.type === "Punctuator";
  24690. }
  24691. /**
  24692. * Checks if the given token is a semicolon token or not.
  24693. * @param {Token} token - The token to check.
  24694. * @returns {boolean} `true` if the token is a semicolon token.
  24695. */
  24696. function isSemicolonToken(token) {
  24697. return token.value === ";" && token.type === "Punctuator";
  24698. }
  24699. /**
  24700. * Checks if the given token is a colon token or not.
  24701. * @param {Token} token - The token to check.
  24702. * @returns {boolean} `true` if the token is a colon token.
  24703. */
  24704. function isColonToken(token) {
  24705. return token.value === ":" && token.type === "Punctuator";
  24706. }
  24707. /**
  24708. * Checks if the given token is an opening parenthesis token or not.
  24709. * @param {Token} token - The token to check.
  24710. * @returns {boolean} `true` if the token is an opening parenthesis token.
  24711. */
  24712. function isOpeningParenToken(token) {
  24713. return token.value === "(" && token.type === "Punctuator";
  24714. }
  24715. /**
  24716. * Checks if the given token is a closing parenthesis token or not.
  24717. * @param {Token} token - The token to check.
  24718. * @returns {boolean} `true` if the token is a closing parenthesis token.
  24719. */
  24720. function isClosingParenToken(token) {
  24721. return token.value === ")" && token.type === "Punctuator";
  24722. }
  24723. /**
  24724. * Checks if the given token is an opening square bracket token or not.
  24725. * @param {Token} token - The token to check.
  24726. * @returns {boolean} `true` if the token is an opening square bracket token.
  24727. */
  24728. function isOpeningBracketToken(token) {
  24729. return token.value === "[" && token.type === "Punctuator";
  24730. }
  24731. /**
  24732. * Checks if the given token is a closing square bracket token or not.
  24733. * @param {Token} token - The token to check.
  24734. * @returns {boolean} `true` if the token is a closing square bracket token.
  24735. */
  24736. function isClosingBracketToken(token) {
  24737. return token.value === "]" && token.type === "Punctuator";
  24738. }
  24739. /**
  24740. * Checks if the given token is an opening brace token or not.
  24741. * @param {Token} token - The token to check.
  24742. * @returns {boolean} `true` if the token is an opening brace token.
  24743. */
  24744. function isOpeningBraceToken(token) {
  24745. return token.value === "{" && token.type === "Punctuator";
  24746. }
  24747. /**
  24748. * Checks if the given token is a closing brace token or not.
  24749. * @param {Token} token - The token to check.
  24750. * @returns {boolean} `true` if the token is a closing brace token.
  24751. */
  24752. function isClosingBraceToken(token) {
  24753. return token.value === "}" && token.type === "Punctuator";
  24754. }
  24755. /**
  24756. * Checks if the given token is a comment token or not.
  24757. * @param {Token} token - The token to check.
  24758. * @returns {boolean} `true` if the token is a comment token.
  24759. */
  24760. function isCommentToken(token) {
  24761. return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
  24762. }
  24763. var isNotArrowToken = negate(isArrowToken);
  24764. var isNotCommaToken = negate(isCommaToken);
  24765. var isNotSemicolonToken = negate(isSemicolonToken);
  24766. var isNotColonToken = negate(isColonToken);
  24767. var isNotOpeningParenToken = negate(isOpeningParenToken);
  24768. var isNotClosingParenToken = negate(isClosingParenToken);
  24769. var isNotOpeningBracketToken = negate(isOpeningBracketToken);
  24770. var isNotClosingBracketToken = negate(isClosingBracketToken);
  24771. var isNotOpeningBraceToken = negate(isOpeningBraceToken);
  24772. var isNotClosingBraceToken = negate(isClosingBraceToken);
  24773. var isNotCommentToken = negate(isCommentToken);
  24774. /**
  24775. * Get the `(` token of the given function node.
  24776. * @param {Node} node - The function node to get.
  24777. * @param {SourceCode} sourceCode - The source code object to get tokens.
  24778. * @returns {Token} `(` token.
  24779. */
  24780. function getOpeningParenOfParams(node, sourceCode) {
  24781. return node.id ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) : sourceCode.getFirstToken(node, isOpeningParenToken);
  24782. }
  24783. /**
  24784. * Get the location of the given function node for reporting.
  24785. * @param {Node} node - The function node to get.
  24786. * @param {SourceCode} sourceCode - The source code object to get tokens.
  24787. * @returns {string} The location of the function node for reporting.
  24788. */
  24789. function getFunctionHeadLocation(node, sourceCode) {
  24790. var parent = node.parent;
  24791. var start = null;
  24792. var end = null;
  24793. if (node.type === "ArrowFunctionExpression") {
  24794. var arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
  24795. start = arrowToken.loc.start;
  24796. end = arrowToken.loc.end;
  24797. } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
  24798. start = parent.loc.start;
  24799. end = getOpeningParenOfParams(node, sourceCode).loc.start;
  24800. } else {
  24801. start = node.loc.start;
  24802. end = getOpeningParenOfParams(node, sourceCode).loc.start;
  24803. }
  24804. return {
  24805. start: Object.assign({}, start),
  24806. end: Object.assign({}, end)
  24807. };
  24808. }
  24809. var builtinNames = Object.freeze(new Set(["Array", "ArrayBuffer", "Boolean", "DataView", "Date", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "Error", "escape", "EvalError", "Float32Array", "Float64Array", "Function", "Infinity", "Int16Array", "Int32Array", "Int8Array", "isFinite", "isNaN", "isPrototypeOf", "JSON", "Map", "Math", "NaN", "Number", "Object", "parseFloat", "parseInt", "Promise", "Proxy", "RangeError", "ReferenceError", "Reflect", "RegExp", "Set", "String", "Symbol", "SyntaxError", "TypeError", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray", "undefined", "unescape", "URIError", "WeakMap", "WeakSet"]));
  24810. /**
  24811. * Get the element values of a given node list.
  24812. * @param {Node[]} nodeList The node list to get values.
  24813. * @param {Scope|undefined} initialScope The initial scope to find variables.
  24814. * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
  24815. */
  24816. function getElementValues(nodeList, initialScope) {
  24817. var valueList = [];
  24818. for (var i = 0; i < nodeList.length; ++i) {
  24819. var elementNode = nodeList[i];
  24820. if (elementNode == null) {
  24821. valueList.length = i + 1;
  24822. } else if (elementNode.type === "SpreadElement") {
  24823. var argument = getStaticValueR(elementNode.argument, initialScope);
  24824. if (argument == null) {
  24825. return null;
  24826. }
  24827. valueList.push.apply(valueList, _toConsumableArray(argument.value));
  24828. } else {
  24829. var element = getStaticValueR(elementNode, initialScope);
  24830. if (element == null) {
  24831. return null;
  24832. }
  24833. valueList.push(element.value);
  24834. }
  24835. }
  24836. return valueList;
  24837. }
  24838. var operations = Object.freeze({
  24839. ArrayExpression: function ArrayExpression(node, initialScope) {
  24840. var elements = getElementValues(node.elements, initialScope);
  24841. return elements != null ? { value: elements } : null;
  24842. },
  24843. AssignmentExpression: function AssignmentExpression(node, initialScope) {
  24844. if (node.operator === "=") {
  24845. return getStaticValueR(node.right, initialScope);
  24846. }
  24847. return null;
  24848. },
  24849. //eslint-disable-next-line complexity
  24850. BinaryExpression: function BinaryExpression(node, initialScope) {
  24851. if (node.operator === "in" || node.operator === "instanceof") {
  24852. // Not supported.
  24853. return null;
  24854. }
  24855. var left = getStaticValueR(node.left, initialScope);
  24856. var right = getStaticValueR(node.right, initialScope);
  24857. if (left != null && right != null) {
  24858. switch (node.operator) {
  24859. case "==":
  24860. return { value: left.value == right.value //eslint-disable-line eqeqeq
  24861. };case "!=":
  24862. return { value: left.value != right.value //eslint-disable-line eqeqeq
  24863. };case "===":
  24864. return { value: left.value === right.value };
  24865. case "!==":
  24866. return { value: left.value !== right.value };
  24867. case "<":
  24868. return { value: left.value < right.value };
  24869. case "<=":
  24870. return { value: left.value <= right.value };
  24871. case ">":
  24872. return { value: left.value > right.value };
  24873. case ">=":
  24874. return { value: left.value >= right.value };
  24875. case "<<":
  24876. return { value: left.value << right.value };
  24877. case ">>":
  24878. return { value: left.value >> right.value };
  24879. case ">>>":
  24880. return { value: left.value >>> right.value };
  24881. case "+":
  24882. return { value: left.value + right.value };
  24883. case "-":
  24884. return { value: left.value - right.value };
  24885. case "*":
  24886. return { value: left.value * right.value };
  24887. case "/":
  24888. return { value: left.value / right.value };
  24889. case "%":
  24890. return { value: left.value % right.value };
  24891. case "**":
  24892. return { value: Math.pow(left.value, right.value) };
  24893. case "|":
  24894. return { value: left.value | right.value };
  24895. case "^":
  24896. return { value: left.value ^ right.value };
  24897. case "&":
  24898. return { value: left.value & right.value
  24899. // no default
  24900. };}
  24901. }
  24902. return null;
  24903. },
  24904. CallExpression: function CallExpression(node, initialScope) {
  24905. var calleeNode = node.callee;
  24906. var args = getElementValues(node.arguments, initialScope);
  24907. if (args != null) {
  24908. if (calleeNode.type === "MemberExpression") {
  24909. var object = getStaticValueR(calleeNode.object, initialScope);
  24910. var property = calleeNode.computed ? getStaticValueR(calleeNode.property, initialScope) : { value: calleeNode.property.name };
  24911. if (object != null && property != null) {
  24912. var receiver = object.value;
  24913. var methodName = property.value;
  24914. return { value: receiver[methodName].apply(receiver, _toConsumableArray(args)) };
  24915. }
  24916. } else {
  24917. var callee = getStaticValueR(calleeNode, initialScope);
  24918. if (callee != null) {
  24919. var func = callee.value;
  24920. return { value: func.apply(undefined, _toConsumableArray(args)) };
  24921. }
  24922. }
  24923. }
  24924. return null;
  24925. },
  24926. ConditionalExpression: function ConditionalExpression(node, initialScope) {
  24927. var test = getStaticValueR(node.test, initialScope);
  24928. if (test != null) {
  24929. return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
  24930. }
  24931. return null;
  24932. },
  24933. ExpressionStatement: function ExpressionStatement(node, initialScope) {
  24934. return getStaticValueR(node.expression, initialScope);
  24935. },
  24936. Identifier: function Identifier(node, initialScope) {
  24937. if (initialScope != null) {
  24938. var variable = findVariable(initialScope, node);
  24939. // Built-in globals.
  24940. if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in global) {
  24941. return { value: global[variable.name] };
  24942. }
  24943. // Constants.
  24944. if (variable != null && variable.defs.length === 1) {
  24945. var def = variable.defs[0];
  24946. if (def.parent && def.parent.kind === "const" &&
  24947. // TODO(mysticatea): don't support destructuring here.
  24948. def.node.id.type === "Identifier") {
  24949. return getStaticValueR(def.node.init, initialScope);
  24950. }
  24951. }
  24952. }
  24953. return null;
  24954. },
  24955. Literal: function Literal(node) {
  24956. //istanbul ignore if : this is implementation-specific behavior.
  24957. if (node.regex != null && node.value == null) {
  24958. // It was a RegExp literal, but Node.js didn't support it.
  24959. return null;
  24960. }
  24961. return node;
  24962. },
  24963. LogicalExpression: function LogicalExpression(node, initialScope) {
  24964. var left = getStaticValueR(node.left, initialScope);
  24965. if (left != null) {
  24966. if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false) {
  24967. return left;
  24968. }
  24969. var right = getStaticValueR(node.right, initialScope);
  24970. if (right != null) {
  24971. return right;
  24972. }
  24973. }
  24974. return null;
  24975. },
  24976. MemberExpression: function MemberExpression(node, initialScope) {
  24977. var object = getStaticValueR(node.object, initialScope);
  24978. var property = node.computed ? getStaticValueR(node.property, initialScope) : { value: node.property.name };
  24979. if (object != null && property != null) {
  24980. return { value: object.value[property.value] };
  24981. }
  24982. return null;
  24983. },
  24984. NewExpression: function NewExpression(node, initialScope) {
  24985. var callee = getStaticValueR(node.callee, initialScope);
  24986. var args = getElementValues(node.arguments, initialScope);
  24987. if (callee != null && args != null) {
  24988. var Func = callee.value;
  24989. return { value: new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))() };
  24990. }
  24991. return null;
  24992. },
  24993. ObjectExpression: function ObjectExpression(node, initialScope) {
  24994. var object = {};
  24995. var _iteratorNormalCompletion2 = true;
  24996. var _didIteratorError2 = false;
  24997. var _iteratorError2 = undefined;
  24998. try {
  24999. for (var _iterator2 = node.properties[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  25000. var propertyNode = _step2.value;
  25001. if (propertyNode.type === "Property") {
  25002. if (propertyNode.kind !== "init") {
  25003. return null;
  25004. }
  25005. var key = propertyNode.computed ? getStaticValueR(propertyNode.key, initialScope) : { value: propertyNode.key.name };
  25006. var value = getStaticValueR(propertyNode.value, initialScope);
  25007. if (key == null || value == null) {
  25008. return null;
  25009. }
  25010. object[key.value] = value.value;
  25011. } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
  25012. var argument = getStaticValueR(propertyNode.argument, initialScope);
  25013. if (argument == null) {
  25014. return null;
  25015. }
  25016. Object.assign(object, argument.value);
  25017. } else {
  25018. return null;
  25019. }
  25020. }
  25021. } catch (err) {
  25022. _didIteratorError2 = true;
  25023. _iteratorError2 = err;
  25024. } finally {
  25025. try {
  25026. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  25027. _iterator2.return();
  25028. }
  25029. } finally {
  25030. if (_didIteratorError2) {
  25031. throw _iteratorError2;
  25032. }
  25033. }
  25034. }
  25035. return { value: object };
  25036. },
  25037. SequenceExpression: function SequenceExpression(node, initialScope) {
  25038. var last = node.expressions[node.expressions.length - 1];
  25039. return getStaticValueR(last, initialScope);
  25040. },
  25041. TaggedTemplateExpression: function TaggedTemplateExpression(node, initialScope) {
  25042. var tag = getStaticValueR(node.tag, initialScope);
  25043. var expressions = getElementValues(node.quasi.expressions, initialScope);
  25044. if (tag != null && expressions != null) {
  25045. var func = tag.value;
  25046. var strings = node.quasi.quasis.map(function (q) {
  25047. return q.value.cooked;
  25048. });
  25049. strings.raw = node.quasi.quasis.map(function (q) {
  25050. return q.value.raw;
  25051. });
  25052. return { value: func.apply(undefined, [strings].concat(_toConsumableArray(expressions))) };
  25053. }
  25054. return null;
  25055. },
  25056. TemplateLiteral: function TemplateLiteral(node, initialScope) {
  25057. var expressions = getElementValues(node.expressions, initialScope);
  25058. if (expressions != null) {
  25059. var value = node.quasis[0].value.cooked;
  25060. for (var i = 0; i < expressions.length; ++i) {
  25061. value += expressions[i];
  25062. value += node.quasis[i + 1].value.cooked;
  25063. }
  25064. return { value: value };
  25065. }
  25066. return null;
  25067. },
  25068. UnaryExpression: function UnaryExpression(node, initialScope) {
  25069. if (node.operator === "delete") {
  25070. // Not supported.
  25071. return null;
  25072. }
  25073. if (node.operator === "void") {
  25074. return { value: undefined };
  25075. }
  25076. var arg = getStaticValueR(node.argument, initialScope);
  25077. if (arg != null) {
  25078. switch (node.operator) {
  25079. case "-":
  25080. return { value: -arg.value };
  25081. case "+":
  25082. return { value: +arg.value //eslint-disable-line no-implicit-coercion
  25083. };case "!":
  25084. return { value: !arg.value };
  25085. case "~":
  25086. return { value: ~arg.value };
  25087. case "typeof":
  25088. return { value: _typeof(arg.value)
  25089. // no default
  25090. };}
  25091. }
  25092. return null;
  25093. }
  25094. });
  25095. /**
  25096. * Get the value of a given node if it's a static value.
  25097. * @param {Node} node The node to get.
  25098. * @param {Scope|undefined} initialScope The scope to start finding variable.
  25099. * @returns {{value:any}|null} The static value of the node, or `null`.
  25100. */
  25101. function getStaticValueR(node, initialScope) {
  25102. if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
  25103. return operations[node.type](node, initialScope);
  25104. }
  25105. return null;
  25106. }
  25107. /**
  25108. * Get the value of a given node if it's a static value.
  25109. * @param {Node} node The node to get.
  25110. * @param {Scope} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
  25111. * @returns {{value:any}|null} The static value of the node, or `null`.
  25112. */
  25113. function getStaticValue(node) {
  25114. var initialScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  25115. try {
  25116. return getStaticValueR(node, initialScope);
  25117. } catch (_error) {
  25118. return null;
  25119. }
  25120. }
  25121. /**
  25122. * Get the value of a given node if it's a literal or a template literal.
  25123. * @param {Node} node The node to get.
  25124. * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant.
  25125. * @returns {string|null} The value of the node, or `null`.
  25126. */
  25127. function getStringIfConstant(node) {
  25128. var initialScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  25129. var evaluated = getStaticValue(node, initialScope);
  25130. return evaluated && String(evaluated.value);
  25131. }
  25132. /**
  25133. * Get the property name from a MemberExpression node or a Property node.
  25134. * @param {Node} node The node to get.
  25135. * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
  25136. * @returns {string|null} The property name of the node.
  25137. */
  25138. function getPropertyName(node, initialScope) {
  25139. switch (node.type) {
  25140. case "MemberExpression":
  25141. if (node.computed) {
  25142. return getStringIfConstant(node.property, initialScope);
  25143. }
  25144. return node.property.name;
  25145. case "Property":
  25146. case "MethodDefinition":
  25147. if (node.computed) {
  25148. return getStringIfConstant(node.key, initialScope);
  25149. }
  25150. if (node.key.type === "Literal") {
  25151. return String(node.key.value);
  25152. }
  25153. return node.key.name;
  25154. // no default
  25155. }
  25156. return null;
  25157. }
  25158. /**
  25159. * Get the name and kind of the given function node.
  25160. * @param {ASTNode} node - The function node to get.
  25161. * @returns {string} The name and kind of the function node.
  25162. */
  25163. function getFunctionNameWithKind(node) {
  25164. var parent = node.parent;
  25165. var tokens = [];
  25166. if (parent.type === "MethodDefinition" && parent.static) {
  25167. tokens.push("static");
  25168. }
  25169. if (node.async) {
  25170. tokens.push("async");
  25171. }
  25172. if (node.generator) {
  25173. tokens.push("generator");
  25174. }
  25175. if (node.type === "ArrowFunctionExpression") {
  25176. tokens.push("arrow", "function");
  25177. } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
  25178. if (parent.kind === "constructor") {
  25179. return "constructor";
  25180. }
  25181. if (parent.kind === "get") {
  25182. tokens.push("getter");
  25183. } else if (parent.kind === "set") {
  25184. tokens.push("setter");
  25185. } else {
  25186. tokens.push("method");
  25187. }
  25188. } else {
  25189. tokens.push("function");
  25190. }
  25191. if (node.id) {
  25192. tokens.push('\'' + node.id.name + '\'');
  25193. } else {
  25194. var name = getPropertyName(parent);
  25195. if (name) {
  25196. tokens.push('\'' + name + '\'');
  25197. }
  25198. }
  25199. return tokens.join(" ");
  25200. }
  25201. /**
  25202. * @author Toru Nagashima <https://github.com/mysticatea>
  25203. * See LICENSE file in root directory for full license.
  25204. */
  25205. var placeholder = /\$(?:[$&`']|[1-9][0-9]?)/g;
  25206. /** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
  25207. var internal = new WeakMap();
  25208. /**
  25209. * Check whether a given character is escaped or not.
  25210. * @param {string} str The string to check.
  25211. * @param {number} index The location of the character to check.
  25212. * @returns {boolean} `true` if the character is escaped.
  25213. */
  25214. function isEscaped(str, index) {
  25215. var escaped = false;
  25216. for (var i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
  25217. escaped = !escaped;
  25218. }
  25219. return escaped;
  25220. }
  25221. /**
  25222. * Replace a given string by a given matcher.
  25223. * @param {PatternMatcher} matcher The pattern matcher.
  25224. * @param {string} str The string to be replaced.
  25225. * @param {string} replacement The new substring to replace each matched part.
  25226. * @returns {string} The replaced string.
  25227. */
  25228. function replaceS(matcher, str, replacement) {
  25229. var chunks = [];
  25230. var index = 0;
  25231. /** @type {RegExpExecArray} */
  25232. var match = null;
  25233. /**
  25234. * @param {string} key The placeholder.
  25235. * @returns {string} The replaced string.
  25236. */
  25237. function replacer(key) {
  25238. switch (key) {
  25239. case "$$":
  25240. return "$";
  25241. case "$&":
  25242. return match[0];
  25243. case "$`":
  25244. return str.slice(0, match.index);
  25245. case "$'":
  25246. return str.slice(match.index + match[0].length);
  25247. default:
  25248. {
  25249. var i = key.slice(1);
  25250. if (i in match) {
  25251. return match[i];
  25252. }
  25253. return key;
  25254. }
  25255. }
  25256. }
  25257. var _iteratorNormalCompletion3 = true;
  25258. var _didIteratorError3 = false;
  25259. var _iteratorError3 = undefined;
  25260. try {
  25261. for (var _iterator3 = matcher.execAll(str)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  25262. match = _step3.value;
  25263. chunks.push(str.slice(index, match.index));
  25264. chunks.push(replacement.replace(placeholder, replacer));
  25265. index = match.index + match[0].length;
  25266. }
  25267. } catch (err) {
  25268. _didIteratorError3 = true;
  25269. _iteratorError3 = err;
  25270. } finally {
  25271. try {
  25272. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  25273. _iterator3.return();
  25274. }
  25275. } finally {
  25276. if (_didIteratorError3) {
  25277. throw _iteratorError3;
  25278. }
  25279. }
  25280. }
  25281. chunks.push(str.slice(index));
  25282. return chunks.join("");
  25283. }
  25284. //eslint-disable-next-line valid-jsdoc
  25285. /**
  25286. * Replace a given string by a given matcher.
  25287. * @param {PatternMatcher} matcher The pattern matcher.
  25288. * @param {string} str The string to be replaced.
  25289. * @param {(...strs[])=>string} replace The function to replace each matched part.
  25290. * @returns {string} The replaced string.
  25291. */
  25292. function replaceF(matcher, str, replace) {
  25293. var chunks = [];
  25294. var index = 0;
  25295. var _iteratorNormalCompletion4 = true;
  25296. var _didIteratorError4 = false;
  25297. var _iteratorError4 = undefined;
  25298. try {
  25299. for (var _iterator4 = matcher.execAll(str)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  25300. var match = _step4.value;
  25301. chunks.push(str.slice(index, match.index));
  25302. chunks.push(String(replace.apply(undefined, _toConsumableArray(match).concat([match.index, match.input]))));
  25303. index = match.index + match[0].length;
  25304. }
  25305. } catch (err) {
  25306. _didIteratorError4 = true;
  25307. _iteratorError4 = err;
  25308. } finally {
  25309. try {
  25310. if (!_iteratorNormalCompletion4 && _iterator4.return) {
  25311. _iterator4.return();
  25312. }
  25313. } finally {
  25314. if (_didIteratorError4) {
  25315. throw _iteratorError4;
  25316. }
  25317. }
  25318. }
  25319. chunks.push(str.slice(index));
  25320. return chunks.join("");
  25321. }
  25322. /**
  25323. * The class to find patterns as considering escape sequences.
  25324. */
  25325. var PatternMatcher = function () {
  25326. /**
  25327. * Initialize this matcher.
  25328. * @param {RegExp} pattern The pattern to match.
  25329. * @param {{escaped:boolean}} options The options.
  25330. */
  25331. function PatternMatcher(pattern) {
  25332. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  25333. _ref$escaped = _ref.escaped,
  25334. escaped = _ref$escaped === undefined ? false : _ref$escaped;
  25335. _classCallCheck(this, PatternMatcher);
  25336. if (!(pattern instanceof RegExp)) {
  25337. throw new TypeError("'pattern' should be a RegExp instance.");
  25338. }
  25339. if (!pattern.flags.includes("g")) {
  25340. throw new Error("'pattern' should contains 'g' flag.");
  25341. }
  25342. internal.set(this, {
  25343. pattern: new RegExp(pattern.source, pattern.flags),
  25344. escaped: Boolean(escaped)
  25345. });
  25346. }
  25347. /**
  25348. * Find the pattern in a given string.
  25349. * @param {string} str The string to find.
  25350. * @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
  25351. */
  25352. _createClass(PatternMatcher, [{
  25353. key: 'execAll',
  25354. value: /*#__PURE__*/regeneratorRuntime.mark(function execAll(str) {
  25355. var _internal$get, pattern, escaped, match, lastIndex;
  25356. return regeneratorRuntime.wrap(function execAll$(_context) {
  25357. while (1) {
  25358. switch (_context.prev = _context.next) {
  25359. case 0:
  25360. _internal$get = internal.get(this), pattern = _internal$get.pattern, escaped = _internal$get.escaped;
  25361. match = null;
  25362. lastIndex = 0;
  25363. pattern.lastIndex = 0;
  25364. case 4:
  25365. if (!((match = pattern.exec(str)) != null)) {
  25366. _context.next = 12;
  25367. break;
  25368. }
  25369. if (!(escaped || !isEscaped(str, match.index))) {
  25370. _context.next = 10;
  25371. break;
  25372. }
  25373. lastIndex = pattern.lastIndex;
  25374. _context.next = 9;
  25375. return match;
  25376. case 9:
  25377. pattern.lastIndex = lastIndex;
  25378. case 10:
  25379. _context.next = 4;
  25380. break;
  25381. case 12:
  25382. case 'end':
  25383. return _context.stop();
  25384. }
  25385. }
  25386. }, execAll, this);
  25387. })
  25388. /**
  25389. * Check whether the pattern is found in a given string.
  25390. * @param {string} str The string to check.
  25391. * @returns {boolean} `true` if the pattern was found in the string.
  25392. */
  25393. }, {
  25394. key: 'test',
  25395. value: function test(str) {
  25396. var it = this.execAll(str);
  25397. var ret = it.next();
  25398. return !ret.done;
  25399. }
  25400. //eslint-disable-next-line valid-jsdoc
  25401. /**
  25402. * Replace a given string.
  25403. * @param {string} str The string to be replaced.
  25404. * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
  25405. * @returns {string} The replaced string.
  25406. */
  25407. }, {
  25408. key: Symbol.replace,
  25409. value: function value(str, replacer) {
  25410. return typeof replacer === "function" ? replaceF(this, String(str), replacer) : replaceS(this, String(str), String(replacer));
  25411. }
  25412. }]);
  25413. return PatternMatcher;
  25414. }();
  25415. var SENTINEL_TYPE = /^(?:.+?Statement|.+?Declaration|(?:Array|ArrowFunction|Assignment|Call|Class|Function|Member|New|Object)Expression|AssignmentPattern|Program|VariableDeclarator)$/;
  25416. var IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/;
  25417. var has = Function.call.bind(Object.hasOwnProperty);
  25418. var READ = Symbol("read");
  25419. var CALL = Symbol("call");
  25420. var CONSTRUCT = Symbol("construct");
  25421. var ESM = Symbol("esm");
  25422. var requireCall = { require: _defineProperty({}, CALL, true) };
  25423. /**
  25424. * Check whether a given variable is modified or not.
  25425. * @param {Variable} variable The variable to check.
  25426. * @returns {boolean} `true` if the variable is modified.
  25427. */
  25428. function isModifiedGlobal(variable) {
  25429. return variable == null || variable.defs.length !== 0 || variable.references.some(function (r) {
  25430. return r.isWrite();
  25431. });
  25432. }
  25433. /**
  25434. * The reference tracker.
  25435. */
  25436. var ReferenceTracker = function () {
  25437. /**
  25438. * Initialize this tracker.
  25439. * @param {Scope} globalScope The global scope.
  25440. * @param {object} [options] The options.
  25441. * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
  25442. * @param {string[]} [options.globalObjectNames=["global","self","window"]] The variable names for Global Object.
  25443. */
  25444. function ReferenceTracker(globalScope) {
  25445. var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  25446. _ref2$mode = _ref2.mode,
  25447. mode = _ref2$mode === undefined ? "strict" : _ref2$mode,
  25448. _ref2$globalObjectNam = _ref2.globalObjectNames,
  25449. globalObjectNames = _ref2$globalObjectNam === undefined ? ["global", "self", "window"] : _ref2$globalObjectNam;
  25450. _classCallCheck(this, ReferenceTracker);
  25451. this.variableStack = [];
  25452. this.globalScope = globalScope;
  25453. this.mode = mode;
  25454. this.globalObjectNames = globalObjectNames.slice(0);
  25455. }
  25456. /**
  25457. * Iterate the references of global variables.
  25458. * @param {object} traceMap The trace map.
  25459. * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
  25460. */
  25461. _createClass(ReferenceTracker, [{
  25462. key: 'iterateGlobalReferences',
  25463. value: /*#__PURE__*/regeneratorRuntime.mark(function iterateGlobalReferences(traceMap) {
  25464. var _iteratorNormalCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, key, nextTraceMap, path, variable, _iteratorNormalCompletion6, _didIteratorError6, _iteratorError6, _iterator6, _step6, _key, _path, _variable;
  25465. return regeneratorRuntime.wrap(function iterateGlobalReferences$(_context2) {
  25466. while (1) {
  25467. switch (_context2.prev = _context2.next) {
  25468. case 0:
  25469. _iteratorNormalCompletion5 = true;
  25470. _didIteratorError5 = false;
  25471. _iteratorError5 = undefined;
  25472. _context2.prev = 3;
  25473. _iterator5 = Object.keys(traceMap)[Symbol.iterator]();
  25474. case 5:
  25475. if (_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done) {
  25476. _context2.next = 16;
  25477. break;
  25478. }
  25479. key = _step5.value;
  25480. nextTraceMap = traceMap[key];
  25481. path = [key];
  25482. variable = this.globalScope.set.get(key);
  25483. if (!isModifiedGlobal(variable)) {
  25484. _context2.next = 12;
  25485. break;
  25486. }
  25487. return _context2.abrupt('continue', 13);
  25488. case 12:
  25489. return _context2.delegateYield(this._iterateVariableReferences(variable, path, nextTraceMap, true), 't0', 13);
  25490. case 13:
  25491. _iteratorNormalCompletion5 = true;
  25492. _context2.next = 5;
  25493. break;
  25494. case 16:
  25495. _context2.next = 22;
  25496. break;
  25497. case 18:
  25498. _context2.prev = 18;
  25499. _context2.t1 = _context2['catch'](3);
  25500. _didIteratorError5 = true;
  25501. _iteratorError5 = _context2.t1;
  25502. case 22:
  25503. _context2.prev = 22;
  25504. _context2.prev = 23;
  25505. if (!_iteratorNormalCompletion5 && _iterator5.return) {
  25506. _iterator5.return();
  25507. }
  25508. case 25:
  25509. _context2.prev = 25;
  25510. if (!_didIteratorError5) {
  25511. _context2.next = 28;
  25512. break;
  25513. }
  25514. throw _iteratorError5;
  25515. case 28:
  25516. return _context2.finish(25);
  25517. case 29:
  25518. return _context2.finish(22);
  25519. case 30:
  25520. _iteratorNormalCompletion6 = true;
  25521. _didIteratorError6 = false;
  25522. _iteratorError6 = undefined;
  25523. _context2.prev = 33;
  25524. _iterator6 = this.globalObjectNames[Symbol.iterator]();
  25525. case 35:
  25526. if (_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done) {
  25527. _context2.next = 45;
  25528. break;
  25529. }
  25530. _key = _step6.value;
  25531. _path = [];
  25532. _variable = this.globalScope.set.get(_key);
  25533. if (!isModifiedGlobal(_variable)) {
  25534. _context2.next = 41;
  25535. break;
  25536. }
  25537. return _context2.abrupt('continue', 42);
  25538. case 41:
  25539. return _context2.delegateYield(this._iterateVariableReferences(_variable, _path, traceMap, false), 't2', 42);
  25540. case 42:
  25541. _iteratorNormalCompletion6 = true;
  25542. _context2.next = 35;
  25543. break;
  25544. case 45:
  25545. _context2.next = 51;
  25546. break;
  25547. case 47:
  25548. _context2.prev = 47;
  25549. _context2.t3 = _context2['catch'](33);
  25550. _didIteratorError6 = true;
  25551. _iteratorError6 = _context2.t3;
  25552. case 51:
  25553. _context2.prev = 51;
  25554. _context2.prev = 52;
  25555. if (!_iteratorNormalCompletion6 && _iterator6.return) {
  25556. _iterator6.return();
  25557. }
  25558. case 54:
  25559. _context2.prev = 54;
  25560. if (!_didIteratorError6) {
  25561. _context2.next = 57;
  25562. break;
  25563. }
  25564. throw _iteratorError6;
  25565. case 57:
  25566. return _context2.finish(54);
  25567. case 58:
  25568. return _context2.finish(51);
  25569. case 59:
  25570. case 'end':
  25571. return _context2.stop();
  25572. }
  25573. }
  25574. }, iterateGlobalReferences, this, [[3, 18, 22, 30], [23,, 25, 29], [33, 47, 51, 59], [52,, 54, 58]]);
  25575. })
  25576. /**
  25577. * Iterate the references of CommonJS modules.
  25578. * @param {object} traceMap The trace map.
  25579. * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
  25580. */
  25581. }, {
  25582. key: 'iterateCjsReferences',
  25583. value: /*#__PURE__*/regeneratorRuntime.mark(function iterateCjsReferences(traceMap) {
  25584. var _iteratorNormalCompletion7, _didIteratorError7, _iteratorError7, _iterator7, _step7, node, key, nextTraceMap, path;
  25585. return regeneratorRuntime.wrap(function iterateCjsReferences$(_context3) {
  25586. while (1) {
  25587. switch (_context3.prev = _context3.next) {
  25588. case 0:
  25589. _iteratorNormalCompletion7 = true;
  25590. _didIteratorError7 = false;
  25591. _iteratorError7 = undefined;
  25592. _context3.prev = 3;
  25593. _iterator7 = this.iterateGlobalReferences(requireCall)[Symbol.iterator]();
  25594. case 5:
  25595. if (_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done) {
  25596. _context3.next = 19;
  25597. break;
  25598. }
  25599. node = _step7.value.node;
  25600. key = getStringIfConstant(node.arguments[0]);
  25601. if (!(key == null || !has(traceMap, key))) {
  25602. _context3.next = 10;
  25603. break;
  25604. }
  25605. return _context3.abrupt('continue', 16);
  25606. case 10:
  25607. nextTraceMap = traceMap[key];
  25608. path = [key];
  25609. if (!nextTraceMap[READ]) {
  25610. _context3.next = 15;
  25611. break;
  25612. }
  25613. _context3.next = 15;
  25614. return {
  25615. node: node,
  25616. path: path,
  25617. type: READ,
  25618. info: nextTraceMap[READ]
  25619. };
  25620. case 15:
  25621. return _context3.delegateYield(this._iteratePropertyReferences(node, path, nextTraceMap), 't0', 16);
  25622. case 16:
  25623. _iteratorNormalCompletion7 = true;
  25624. _context3.next = 5;
  25625. break;
  25626. case 19:
  25627. _context3.next = 25;
  25628. break;
  25629. case 21:
  25630. _context3.prev = 21;
  25631. _context3.t1 = _context3['catch'](3);
  25632. _didIteratorError7 = true;
  25633. _iteratorError7 = _context3.t1;
  25634. case 25:
  25635. _context3.prev = 25;
  25636. _context3.prev = 26;
  25637. if (!_iteratorNormalCompletion7 && _iterator7.return) {
  25638. _iterator7.return();
  25639. }
  25640. case 28:
  25641. _context3.prev = 28;
  25642. if (!_didIteratorError7) {
  25643. _context3.next = 31;
  25644. break;
  25645. }
  25646. throw _iteratorError7;
  25647. case 31:
  25648. return _context3.finish(28);
  25649. case 32:
  25650. return _context3.finish(25);
  25651. case 33:
  25652. case 'end':
  25653. return _context3.stop();
  25654. }
  25655. }
  25656. }, iterateCjsReferences, this, [[3, 21, 25, 33], [26,, 28, 32]]);
  25657. })
  25658. /**
  25659. * Iterate the references of ES modules.
  25660. * @param {object} traceMap The trace map.
  25661. * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
  25662. */
  25663. }, {
  25664. key: 'iterateEsmReferences',
  25665. value: /*#__PURE__*/regeneratorRuntime.mark(function iterateEsmReferences(traceMap) {
  25666. var programNode, _iteratorNormalCompletion8, _didIteratorError8, _iteratorError8, _iterator8, _step8, node, moduleId, nextTraceMap, path, _iteratorNormalCompletion9, _didIteratorError9, _iteratorError9, _iterator9, _step9, key, exportTraceMap, _iteratorNormalCompletion10, _didIteratorError10, _iteratorError10, _iterator10, _step10, specifier, esm, it, _iteratorNormalCompletion11, _didIteratorError11, _iteratorError11, _iterator11, _step11, report;
  25667. return regeneratorRuntime.wrap(function iterateEsmReferences$(_context4) {
  25668. while (1) {
  25669. switch (_context4.prev = _context4.next) {
  25670. case 0:
  25671. programNode = this.globalScope.block;
  25672. _iteratorNormalCompletion8 = true;
  25673. _didIteratorError8 = false;
  25674. _iteratorError8 = undefined;
  25675. _context4.prev = 4;
  25676. _iterator8 = programNode.body[Symbol.iterator]();
  25677. case 6:
  25678. if (_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done) {
  25679. _context4.next = 110;
  25680. break;
  25681. }
  25682. node = _step8.value;
  25683. if (!(!IMPORT_TYPE.test(node.type) || node.source == null)) {
  25684. _context4.next = 10;
  25685. break;
  25686. }
  25687. return _context4.abrupt('continue', 107);
  25688. case 10:
  25689. moduleId = node.source.value;
  25690. if (has(traceMap, moduleId)) {
  25691. _context4.next = 13;
  25692. break;
  25693. }
  25694. return _context4.abrupt('continue', 107);
  25695. case 13:
  25696. nextTraceMap = traceMap[moduleId];
  25697. path = [moduleId];
  25698. if (!nextTraceMap[READ]) {
  25699. _context4.next = 18;
  25700. break;
  25701. }
  25702. _context4.next = 18;
  25703. return { node: node, path: path, type: READ, info: nextTraceMap[READ] };
  25704. case 18:
  25705. if (!(node.type === "ExportAllDeclaration")) {
  25706. _context4.next = 49;
  25707. break;
  25708. }
  25709. _iteratorNormalCompletion9 = true;
  25710. _didIteratorError9 = false;
  25711. _iteratorError9 = undefined;
  25712. _context4.prev = 22;
  25713. _iterator9 = Object.keys(nextTraceMap)[Symbol.iterator]();
  25714. case 24:
  25715. if (_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done) {
  25716. _context4.next = 33;
  25717. break;
  25718. }
  25719. key = _step9.value;
  25720. exportTraceMap = nextTraceMap[key];
  25721. if (!exportTraceMap[READ]) {
  25722. _context4.next = 30;
  25723. break;
  25724. }
  25725. _context4.next = 30;
  25726. return {
  25727. node: node,
  25728. path: path.concat(key),
  25729. type: READ,
  25730. info: exportTraceMap[READ]
  25731. };
  25732. case 30:
  25733. _iteratorNormalCompletion9 = true;
  25734. _context4.next = 24;
  25735. break;
  25736. case 33:
  25737. _context4.next = 39;
  25738. break;
  25739. case 35:
  25740. _context4.prev = 35;
  25741. _context4.t0 = _context4['catch'](22);
  25742. _didIteratorError9 = true;
  25743. _iteratorError9 = _context4.t0;
  25744. case 39:
  25745. _context4.prev = 39;
  25746. _context4.prev = 40;
  25747. if (!_iteratorNormalCompletion9 && _iterator9.return) {
  25748. _iterator9.return();
  25749. }
  25750. case 42:
  25751. _context4.prev = 42;
  25752. if (!_didIteratorError9) {
  25753. _context4.next = 45;
  25754. break;
  25755. }
  25756. throw _iteratorError9;
  25757. case 45:
  25758. return _context4.finish(42);
  25759. case 46:
  25760. return _context4.finish(39);
  25761. case 47:
  25762. _context4.next = 107;
  25763. break;
  25764. case 49:
  25765. _iteratorNormalCompletion10 = true;
  25766. _didIteratorError10 = false;
  25767. _iteratorError10 = undefined;
  25768. _context4.prev = 52;
  25769. _iterator10 = node.specifiers[Symbol.iterator]();
  25770. case 54:
  25771. if (_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done) {
  25772. _context4.next = 93;
  25773. break;
  25774. }
  25775. specifier = _step10.value;
  25776. esm = has(nextTraceMap, ESM);
  25777. it = this._iterateImportReferences(specifier, path, esm ? nextTraceMap : this.mode === "legacy" ? Object.assign({ default: nextTraceMap }, nextTraceMap) : { default: nextTraceMap });
  25778. if (!esm) {
  25779. _context4.next = 62;
  25780. break;
  25781. }
  25782. return _context4.delegateYield(it, 't1', 60);
  25783. case 60:
  25784. _context4.next = 90;
  25785. break;
  25786. case 62:
  25787. _iteratorNormalCompletion11 = true;
  25788. _didIteratorError11 = false;
  25789. _iteratorError11 = undefined;
  25790. _context4.prev = 65;
  25791. _iterator11 = it[Symbol.iterator]();
  25792. case 67:
  25793. if (_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done) {
  25794. _context4.next = 76;
  25795. break;
  25796. }
  25797. report = _step11.value;
  25798. report.path = report.path.filter(exceptDefault);
  25799. if (!(report.path.length >= 2 || report.type !== READ)) {
  25800. _context4.next = 73;
  25801. break;
  25802. }
  25803. _context4.next = 73;
  25804. return report;
  25805. case 73:
  25806. _iteratorNormalCompletion11 = true;
  25807. _context4.next = 67;
  25808. break;
  25809. case 76:
  25810. _context4.next = 82;
  25811. break;
  25812. case 78:
  25813. _context4.prev = 78;
  25814. _context4.t2 = _context4['catch'](65);
  25815. _didIteratorError11 = true;
  25816. _iteratorError11 = _context4.t2;
  25817. case 82:
  25818. _context4.prev = 82;
  25819. _context4.prev = 83;
  25820. if (!_iteratorNormalCompletion11 && _iterator11.return) {
  25821. _iterator11.return();
  25822. }
  25823. case 85:
  25824. _context4.prev = 85;
  25825. if (!_didIteratorError11) {
  25826. _context4.next = 88;
  25827. break;
  25828. }
  25829. throw _iteratorError11;
  25830. case 88:
  25831. return _context4.finish(85);
  25832. case 89:
  25833. return _context4.finish(82);
  25834. case 90:
  25835. _iteratorNormalCompletion10 = true;
  25836. _context4.next = 54;
  25837. break;
  25838. case 93:
  25839. _context4.next = 99;
  25840. break;
  25841. case 95:
  25842. _context4.prev = 95;
  25843. _context4.t3 = _context4['catch'](52);
  25844. _didIteratorError10 = true;
  25845. _iteratorError10 = _context4.t3;
  25846. case 99:
  25847. _context4.prev = 99;
  25848. _context4.prev = 100;
  25849. if (!_iteratorNormalCompletion10 && _iterator10.return) {
  25850. _iterator10.return();
  25851. }
  25852. case 102:
  25853. _context4.prev = 102;
  25854. if (!_didIteratorError10) {
  25855. _context4.next = 105;
  25856. break;
  25857. }
  25858. throw _iteratorError10;
  25859. case 105:
  25860. return _context4.finish(102);
  25861. case 106:
  25862. return _context4.finish(99);
  25863. case 107:
  25864. _iteratorNormalCompletion8 = true;
  25865. _context4.next = 6;
  25866. break;
  25867. case 110:
  25868. _context4.next = 116;
  25869. break;
  25870. case 112:
  25871. _context4.prev = 112;
  25872. _context4.t4 = _context4['catch'](4);
  25873. _didIteratorError8 = true;
  25874. _iteratorError8 = _context4.t4;
  25875. case 116:
  25876. _context4.prev = 116;
  25877. _context4.prev = 117;
  25878. if (!_iteratorNormalCompletion8 && _iterator8.return) {
  25879. _iterator8.return();
  25880. }
  25881. case 119:
  25882. _context4.prev = 119;
  25883. if (!_didIteratorError8) {
  25884. _context4.next = 122;
  25885. break;
  25886. }
  25887. throw _iteratorError8;
  25888. case 122:
  25889. return _context4.finish(119);
  25890. case 123:
  25891. return _context4.finish(116);
  25892. case 124:
  25893. case 'end':
  25894. return _context4.stop();
  25895. }
  25896. }
  25897. }, iterateEsmReferences, this, [[4, 112, 116, 124], [22, 35, 39, 47], [40,, 42, 46], [52, 95, 99, 107], [65, 78, 82, 90], [83,, 85, 89], [100,, 102, 106], [117,, 119, 123]]);
  25898. })
  25899. /**
  25900. * Iterate the references for a given variable.
  25901. * @param {Variable} variable The variable to iterate that references.
  25902. * @param {string[]} path The current path.
  25903. * @param {object} traceMap The trace map.
  25904. * @param {boolean} shouldReport = The flag to report those references.
  25905. * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
  25906. */
  25907. }, {
  25908. key: '_iterateVariableReferences',
  25909. value: /*#__PURE__*/regeneratorRuntime.mark(function _iterateVariableReferences(variable, path, traceMap, shouldReport) {
  25910. var _iteratorNormalCompletion12, _didIteratorError12, _iteratorError12, _iterator12, _step12, reference, node;
  25911. return regeneratorRuntime.wrap(function _iterateVariableReferences$(_context5) {
  25912. while (1) {
  25913. switch (_context5.prev = _context5.next) {
  25914. case 0:
  25915. if (!this.variableStack.includes(variable)) {
  25916. _context5.next = 2;
  25917. break;
  25918. }
  25919. return _context5.abrupt('return');
  25920. case 2:
  25921. this.variableStack.push(variable);
  25922. _context5.prev = 3;
  25923. _iteratorNormalCompletion12 = true;
  25924. _didIteratorError12 = false;
  25925. _iteratorError12 = undefined;
  25926. _context5.prev = 7;
  25927. _iterator12 = variable.references[Symbol.iterator]();
  25928. case 9:
  25929. if (_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done) {
  25930. _context5.next = 21;
  25931. break;
  25932. }
  25933. reference = _step12.value;
  25934. if (reference.isRead()) {
  25935. _context5.next = 13;
  25936. break;
  25937. }
  25938. return _context5.abrupt('continue', 18);
  25939. case 13:
  25940. node = reference.identifier;
  25941. if (!(shouldReport && traceMap[READ])) {
  25942. _context5.next = 17;
  25943. break;
  25944. }
  25945. _context5.next = 17;
  25946. return { node: node, path: path, type: READ, info: traceMap[READ] };
  25947. case 17:
  25948. return _context5.delegateYield(this._iteratePropertyReferences(node, path, traceMap), 't0', 18);
  25949. case 18:
  25950. _iteratorNormalCompletion12 = true;
  25951. _context5.next = 9;
  25952. break;
  25953. case 21:
  25954. _context5.next = 27;
  25955. break;
  25956. case 23:
  25957. _context5.prev = 23;
  25958. _context5.t1 = _context5['catch'](7);
  25959. _didIteratorError12 = true;
  25960. _iteratorError12 = _context5.t1;
  25961. case 27:
  25962. _context5.prev = 27;
  25963. _context5.prev = 28;
  25964. if (!_iteratorNormalCompletion12 && _iterator12.return) {
  25965. _iterator12.return();
  25966. }
  25967. case 30:
  25968. _context5.prev = 30;
  25969. if (!_didIteratorError12) {
  25970. _context5.next = 33;
  25971. break;
  25972. }
  25973. throw _iteratorError12;
  25974. case 33:
  25975. return _context5.finish(30);
  25976. case 34:
  25977. return _context5.finish(27);
  25978. case 35:
  25979. _context5.prev = 35;
  25980. this.variableStack.pop();
  25981. return _context5.finish(35);
  25982. case 38:
  25983. case 'end':
  25984. return _context5.stop();
  25985. }
  25986. }
  25987. }, _iterateVariableReferences, this, [[3,, 35, 38], [7, 23, 27, 35], [28,, 30, 34]]);
  25988. })
  25989. /**
  25990. * Iterate the references for a given AST node.
  25991. * @param rootNode The AST node to iterate references.
  25992. * @param {string[]} path The current path.
  25993. * @param {object} traceMap The trace map.
  25994. * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
  25995. */
  25996. //eslint-disable-next-line complexity, require-jsdoc
  25997. }, {
  25998. key: '_iteratePropertyReferences',
  25999. value: /*#__PURE__*/regeneratorRuntime.mark(function _iteratePropertyReferences(rootNode, path, traceMap) {
  26000. var node, parent, key, nextTraceMap;
  26001. return regeneratorRuntime.wrap(function _iteratePropertyReferences$(_context6) {
  26002. while (1) {
  26003. switch (_context6.prev = _context6.next) {
  26004. case 0:
  26005. node = rootNode;
  26006. while (!SENTINEL_TYPE.test(node.parent.type)) {
  26007. node = node.parent;
  26008. }
  26009. parent = node.parent;
  26010. if (!(parent.type === "MemberExpression")) {
  26011. _context6.next = 15;
  26012. break;
  26013. }
  26014. if (!(parent.object === node)) {
  26015. _context6.next = 14;
  26016. break;
  26017. }
  26018. key = getPropertyName(parent);
  26019. if (!(key == null || !has(traceMap, key))) {
  26020. _context6.next = 8;
  26021. break;
  26022. }
  26023. return _context6.abrupt('return');
  26024. case 8:
  26025. path = path.concat(key); //eslint-disable-line no-param-reassign
  26026. nextTraceMap = traceMap[key];
  26027. if (!nextTraceMap[READ]) {
  26028. _context6.next = 13;
  26029. break;
  26030. }
  26031. _context6.next = 13;
  26032. return {
  26033. node: parent,
  26034. path: path,
  26035. type: READ,
  26036. info: nextTraceMap[READ]
  26037. };
  26038. case 13:
  26039. return _context6.delegateYield(this._iteratePropertyReferences(parent, path, nextTraceMap), 't0', 14);
  26040. case 14:
  26041. return _context6.abrupt('return');
  26042. case 15:
  26043. if (!(parent.type === "CallExpression")) {
  26044. _context6.next = 20;
  26045. break;
  26046. }
  26047. if (!(parent.callee === node && traceMap[CALL])) {
  26048. _context6.next = 19;
  26049. break;
  26050. }
  26051. _context6.next = 19;
  26052. return { node: parent, path: path, type: CALL, info: traceMap[CALL] };
  26053. case 19:
  26054. return _context6.abrupt('return');
  26055. case 20:
  26056. if (!(parent.type === "NewExpression")) {
  26057. _context6.next = 25;
  26058. break;
  26059. }
  26060. if (!(parent.callee === node && traceMap[CONSTRUCT])) {
  26061. _context6.next = 24;
  26062. break;
  26063. }
  26064. _context6.next = 24;
  26065. return {
  26066. node: parent,
  26067. path: path,
  26068. type: CONSTRUCT,
  26069. info: traceMap[CONSTRUCT]
  26070. };
  26071. case 24:
  26072. return _context6.abrupt('return');
  26073. case 25:
  26074. if (!(parent.type === "AssignmentExpression")) {
  26075. _context6.next = 30;
  26076. break;
  26077. }
  26078. if (!(parent.right === node)) {
  26079. _context6.next = 29;
  26080. break;
  26081. }
  26082. return _context6.delegateYield(this._iterateLhsReferences(parent.left, path, traceMap), 't1', 28);
  26083. case 28:
  26084. return _context6.delegateYield(this._iteratePropertyReferences(parent, path, traceMap), 't2', 29);
  26085. case 29:
  26086. return _context6.abrupt('return');
  26087. case 30:
  26088. if (!(parent.type === "AssignmentPattern")) {
  26089. _context6.next = 34;
  26090. break;
  26091. }
  26092. if (!(parent.right === node)) {
  26093. _context6.next = 33;
  26094. break;
  26095. }
  26096. return _context6.delegateYield(this._iterateLhsReferences(parent.left, path, traceMap), 't3', 33);
  26097. case 33:
  26098. return _context6.abrupt('return');
  26099. case 34:
  26100. if (!(parent.type === "VariableDeclarator")) {
  26101. _context6.next = 37;
  26102. break;
  26103. }
  26104. if (!(parent.init === node)) {
  26105. _context6.next = 37;
  26106. break;
  26107. }
  26108. return _context6.delegateYield(this._iterateLhsReferences(parent.id, path, traceMap), 't4', 37);
  26109. case 37:
  26110. case 'end':
  26111. return _context6.stop();
  26112. }
  26113. }
  26114. }, _iteratePropertyReferences, this);
  26115. })
  26116. /**
  26117. * Iterate the references for a given Pattern node.
  26118. * @param {Node} patternNode The Pattern node to iterate references.
  26119. * @param {string[]} path The current path.
  26120. * @param {object} traceMap The trace map.
  26121. * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
  26122. */
  26123. }, {
  26124. key: '_iterateLhsReferences',
  26125. value: /*#__PURE__*/regeneratorRuntime.mark(function _iterateLhsReferences(patternNode, path, traceMap) {
  26126. var variable, _iteratorNormalCompletion13, _didIteratorError13, _iteratorError13, _iterator13, _step13, property, key, nextPath, nextTraceMap;
  26127. return regeneratorRuntime.wrap(function _iterateLhsReferences$(_context7) {
  26128. while (1) {
  26129. switch (_context7.prev = _context7.next) {
  26130. case 0:
  26131. if (!(patternNode.type === "Identifier")) {
  26132. _context7.next = 5;
  26133. break;
  26134. }
  26135. variable = findVariable(this.globalScope, patternNode);
  26136. if (!(variable != null)) {
  26137. _context7.next = 4;
  26138. break;
  26139. }
  26140. return _context7.delegateYield(this._iterateVariableReferences(variable, path, traceMap, false), 't0', 4);
  26141. case 4:
  26142. return _context7.abrupt('return');
  26143. case 5:
  26144. if (!(patternNode.type === "ObjectPattern")) {
  26145. _context7.next = 40;
  26146. break;
  26147. }
  26148. _iteratorNormalCompletion13 = true;
  26149. _didIteratorError13 = false;
  26150. _iteratorError13 = undefined;
  26151. _context7.prev = 9;
  26152. _iterator13 = patternNode.properties[Symbol.iterator]();
  26153. case 11:
  26154. if (_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done) {
  26155. _context7.next = 25;
  26156. break;
  26157. }
  26158. property = _step13.value;
  26159. key = getPropertyName(property);
  26160. if (!(key == null || !has(traceMap, key))) {
  26161. _context7.next = 16;
  26162. break;
  26163. }
  26164. return _context7.abrupt('continue', 22);
  26165. case 16:
  26166. nextPath = path.concat(key);
  26167. nextTraceMap = traceMap[key];
  26168. if (!nextTraceMap[READ]) {
  26169. _context7.next = 21;
  26170. break;
  26171. }
  26172. _context7.next = 21;
  26173. return {
  26174. node: property,
  26175. path: nextPath,
  26176. type: READ,
  26177. info: nextTraceMap[READ]
  26178. };
  26179. case 21:
  26180. return _context7.delegateYield(this._iterateLhsReferences(property.value, nextPath, nextTraceMap), 't1', 22);
  26181. case 22:
  26182. _iteratorNormalCompletion13 = true;
  26183. _context7.next = 11;
  26184. break;
  26185. case 25:
  26186. _context7.next = 31;
  26187. break;
  26188. case 27:
  26189. _context7.prev = 27;
  26190. _context7.t2 = _context7['catch'](9);
  26191. _didIteratorError13 = true;
  26192. _iteratorError13 = _context7.t2;
  26193. case 31:
  26194. _context7.prev = 31;
  26195. _context7.prev = 32;
  26196. if (!_iteratorNormalCompletion13 && _iterator13.return) {
  26197. _iterator13.return();
  26198. }
  26199. case 34:
  26200. _context7.prev = 34;
  26201. if (!_didIteratorError13) {
  26202. _context7.next = 37;
  26203. break;
  26204. }
  26205. throw _iteratorError13;
  26206. case 37:
  26207. return _context7.finish(34);
  26208. case 38:
  26209. return _context7.finish(31);
  26210. case 39:
  26211. return _context7.abrupt('return');
  26212. case 40:
  26213. if (!(patternNode.type === "AssignmentPattern")) {
  26214. _context7.next = 42;
  26215. break;
  26216. }
  26217. return _context7.delegateYield(this._iterateLhsReferences(patternNode.left, path, traceMap), 't3', 42);
  26218. case 42:
  26219. case 'end':
  26220. return _context7.stop();
  26221. }
  26222. }
  26223. }, _iterateLhsReferences, this, [[9, 27, 31, 39], [32,, 34, 38]]);
  26224. })
  26225. /**
  26226. * Iterate the references for a given ModuleSpecifier node.
  26227. * @param {Node} specifierNode The ModuleSpecifier node to iterate references.
  26228. * @param {string[]} path The current path.
  26229. * @param {object} traceMap The trace map.
  26230. * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
  26231. */
  26232. }, {
  26233. key: '_iterateImportReferences',
  26234. value: /*#__PURE__*/regeneratorRuntime.mark(function _iterateImportReferences(specifierNode, path, traceMap) {
  26235. var type, key, nextTraceMap, _key2, _nextTraceMap;
  26236. return regeneratorRuntime.wrap(function _iterateImportReferences$(_context8) {
  26237. while (1) {
  26238. switch (_context8.prev = _context8.next) {
  26239. case 0:
  26240. type = specifierNode.type;
  26241. if (!(type === "ImportSpecifier" || type === "ImportDefaultSpecifier")) {
  26242. _context8.next = 12;
  26243. break;
  26244. }
  26245. key = type === "ImportDefaultSpecifier" ? "default" : specifierNode.imported.name;
  26246. if (has(traceMap, key)) {
  26247. _context8.next = 5;
  26248. break;
  26249. }
  26250. return _context8.abrupt('return');
  26251. case 5:
  26252. path = path.concat(key); //eslint-disable-line no-param-reassign
  26253. nextTraceMap = traceMap[key];
  26254. if (!nextTraceMap[READ]) {
  26255. _context8.next = 10;
  26256. break;
  26257. }
  26258. _context8.next = 10;
  26259. return {
  26260. node: specifierNode,
  26261. path: path,
  26262. type: READ,
  26263. info: nextTraceMap[READ]
  26264. };
  26265. case 10:
  26266. return _context8.delegateYield(this._iterateVariableReferences(findVariable(this.globalScope, specifierNode.local), path, nextTraceMap, false), 't0', 11);
  26267. case 11:
  26268. return _context8.abrupt('return');
  26269. case 12:
  26270. if (!(type === "ImportNamespaceSpecifier")) {
  26271. _context8.next = 15;
  26272. break;
  26273. }
  26274. return _context8.delegateYield(this._iterateVariableReferences(findVariable(this.globalScope, specifierNode.local), path, traceMap, false), 't1', 14);
  26275. case 14:
  26276. return _context8.abrupt('return');
  26277. case 15:
  26278. if (!(type === "ExportSpecifier")) {
  26279. _context8.next = 24;
  26280. break;
  26281. }
  26282. _key2 = specifierNode.local.name;
  26283. if (has(traceMap, _key2)) {
  26284. _context8.next = 19;
  26285. break;
  26286. }
  26287. return _context8.abrupt('return');
  26288. case 19:
  26289. path = path.concat(_key2); //eslint-disable-line no-param-reassign
  26290. _nextTraceMap = traceMap[_key2];
  26291. if (!_nextTraceMap[READ]) {
  26292. _context8.next = 24;
  26293. break;
  26294. }
  26295. _context8.next = 24;
  26296. return {
  26297. node: specifierNode,
  26298. path: path,
  26299. type: READ,
  26300. info: _nextTraceMap[READ]
  26301. };
  26302. case 24:
  26303. case 'end':
  26304. return _context8.stop();
  26305. }
  26306. }
  26307. }, _iterateImportReferences, this);
  26308. })
  26309. }]);
  26310. return ReferenceTracker;
  26311. }();
  26312. ReferenceTracker.READ = READ;
  26313. ReferenceTracker.CALL = CALL;
  26314. ReferenceTracker.CONSTRUCT = CONSTRUCT;
  26315. ReferenceTracker.ESM = ESM;
  26316. /**
  26317. * This is a predicate function for Array#filter.
  26318. * @param {string} name A name part.
  26319. * @param {number} index The index of the name.
  26320. * @returns {boolean} `false` if it's default.
  26321. */
  26322. function exceptDefault(name, index) {
  26323. return !(index === 1 && name === "default");
  26324. }
  26325. var index = {
  26326. CALL: CALL,
  26327. CONSTRUCT: CONSTRUCT,
  26328. ESM: ESM,
  26329. findVariable: findVariable,
  26330. getFunctionHeadLocation: getFunctionHeadLocation,
  26331. getFunctionNameWithKind: getFunctionNameWithKind,
  26332. getInnermostScope: getInnermostScope,
  26333. getPropertyName: getPropertyName,
  26334. getStaticValue: getStaticValue,
  26335. getStringIfConstant: getStringIfConstant,
  26336. isArrowToken: isArrowToken,
  26337. isClosingBraceToken: isClosingBraceToken,
  26338. isClosingBracketToken: isClosingBracketToken,
  26339. isClosingParenToken: isClosingParenToken,
  26340. isColonToken: isColonToken,
  26341. isCommaToken: isCommaToken,
  26342. isCommentToken: isCommentToken,
  26343. isNotArrowToken: isNotArrowToken,
  26344. isNotClosingBraceToken: isNotClosingBraceToken,
  26345. isNotClosingBracketToken: isNotClosingBracketToken,
  26346. isNotClosingParenToken: isNotClosingParenToken,
  26347. isNotColonToken: isNotColonToken,
  26348. isNotCommaToken: isNotCommaToken,
  26349. isNotCommentToken: isNotCommentToken,
  26350. isNotOpeningBraceToken: isNotOpeningBraceToken,
  26351. isNotOpeningBracketToken: isNotOpeningBracketToken,
  26352. isNotOpeningParenToken: isNotOpeningParenToken,
  26353. isNotSemicolonToken: isNotSemicolonToken,
  26354. isOpeningBraceToken: isOpeningBraceToken,
  26355. isOpeningBracketToken: isOpeningBracketToken,
  26356. isOpeningParenToken: isOpeningParenToken,
  26357. isSemicolonToken: isSemicolonToken,
  26358. PatternMatcher: PatternMatcher,
  26359. READ: READ,
  26360. ReferenceTracker: ReferenceTracker
  26361. };
  26362. exports.default = index;
  26363. exports.CALL = CALL;
  26364. exports.CONSTRUCT = CONSTRUCT;
  26365. exports.ESM = ESM;
  26366. exports.findVariable = findVariable;
  26367. exports.getFunctionHeadLocation = getFunctionHeadLocation;
  26368. exports.getFunctionNameWithKind = getFunctionNameWithKind;
  26369. exports.getInnermostScope = getInnermostScope;
  26370. exports.getPropertyName = getPropertyName;
  26371. exports.getStaticValue = getStaticValue;
  26372. exports.getStringIfConstant = getStringIfConstant;
  26373. exports.isArrowToken = isArrowToken;
  26374. exports.isClosingBraceToken = isClosingBraceToken;
  26375. exports.isClosingBracketToken = isClosingBracketToken;
  26376. exports.isClosingParenToken = isClosingParenToken;
  26377. exports.isColonToken = isColonToken;
  26378. exports.isCommaToken = isCommaToken;
  26379. exports.isCommentToken = isCommentToken;
  26380. exports.isNotArrowToken = isNotArrowToken;
  26381. exports.isNotClosingBraceToken = isNotClosingBraceToken;
  26382. exports.isNotClosingBracketToken = isNotClosingBracketToken;
  26383. exports.isNotClosingParenToken = isNotClosingParenToken;
  26384. exports.isNotColonToken = isNotColonToken;
  26385. exports.isNotCommaToken = isNotCommaToken;
  26386. exports.isNotCommentToken = isNotCommentToken;
  26387. exports.isNotOpeningBraceToken = isNotOpeningBraceToken;
  26388. exports.isNotOpeningBracketToken = isNotOpeningBracketToken;
  26389. exports.isNotOpeningParenToken = isNotOpeningParenToken;
  26390. exports.isNotSemicolonToken = isNotSemicolonToken;
  26391. exports.isOpeningBraceToken = isOpeningBraceToken;
  26392. exports.isOpeningBracketToken = isOpeningBracketToken;
  26393. exports.isOpeningParenToken = isOpeningParenToken;
  26394. exports.isSemicolonToken = isSemicolonToken;
  26395. exports.PatternMatcher = PatternMatcher;
  26396. exports.READ = READ;
  26397. exports.ReferenceTracker = ReferenceTracker;
  26398. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  26399. },{}],69:[function(require,module,exports){
  26400. /**
  26401. * @author Toru Nagashima <https://github.com/mysticatea>
  26402. * See LICENSE file in root directory for full license.
  26403. */
  26404. "use strict";
  26405. var KEYS = require("./visitor-keys.json");
  26406. // Types.
  26407. var NODE_TYPES = Object.freeze(Object.keys(KEYS));
  26408. // Freeze the keys.
  26409. var _iteratorNormalCompletion = true;
  26410. var _didIteratorError = false;
  26411. var _iteratorError = undefined;
  26412. try {
  26413. for (var _iterator = NODE_TYPES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  26414. var type = _step.value;
  26415. Object.freeze(KEYS[type]);
  26416. }
  26417. } catch (err) {
  26418. _didIteratorError = true;
  26419. _iteratorError = err;
  26420. } finally {
  26421. try {
  26422. if (!_iteratorNormalCompletion && _iterator.return) {
  26423. _iterator.return();
  26424. }
  26425. } finally {
  26426. if (_didIteratorError) {
  26427. throw _iteratorError;
  26428. }
  26429. }
  26430. }
  26431. Object.freeze(KEYS);
  26432. // List to ignore keys.
  26433. var KEY_BLACKLIST = new Set(["parent", "leadingComments", "trailingComments"]);
  26434. /**
  26435. * Check whether a given key should be used or not.
  26436. * @param {string} key The key to check.
  26437. * @returns {boolean} `true` if the key should be used.
  26438. */
  26439. function filterKey(key) {
  26440. return !KEY_BLACKLIST.has(key) && key[0] !== "_";
  26441. }
  26442. //------------------------------------------------------------------------------
  26443. // Public interfaces
  26444. //------------------------------------------------------------------------------
  26445. module.exports = Object.freeze({
  26446. /**
  26447. * Visitor keys.
  26448. * @type {{ [type: string]: string[] | undefined }}
  26449. */
  26450. KEYS: KEYS,
  26451. /**
  26452. * Get visitor keys of a given node.
  26453. * @param {Object} node The AST node to get keys.
  26454. * @returns {string[]} Visitor keys of the node.
  26455. */
  26456. getKeys: function getKeys(node) {
  26457. return Object.keys(node).filter(filterKey);
  26458. },
  26459. // Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
  26460. // eslint-disable-next-line valid-jsdoc
  26461. /**
  26462. * Make the union set with `KEYS` and given keys.
  26463. * @param {Object} additionalKeys The additional keys.
  26464. * @returns {{ [type: string]: string[] | undefined }} The union set.
  26465. */
  26466. unionWith: function unionWith(additionalKeys) {
  26467. var retv = Object.assign({}, KEYS);
  26468. var _iteratorNormalCompletion2 = true;
  26469. var _didIteratorError2 = false;
  26470. var _iteratorError2 = undefined;
  26471. try {
  26472. for (var _iterator2 = Object.keys(additionalKeys)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  26473. var type = _step2.value;
  26474. if (retv.hasOwnProperty(type)) {
  26475. var keys = new Set(additionalKeys[type]);
  26476. var _iteratorNormalCompletion3 = true;
  26477. var _didIteratorError3 = false;
  26478. var _iteratorError3 = undefined;
  26479. try {
  26480. for (var _iterator3 = retv[type][Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  26481. var key = _step3.value;
  26482. keys.add(key);
  26483. }
  26484. } catch (err) {
  26485. _didIteratorError3 = true;
  26486. _iteratorError3 = err;
  26487. } finally {
  26488. try {
  26489. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  26490. _iterator3.return();
  26491. }
  26492. } finally {
  26493. if (_didIteratorError3) {
  26494. throw _iteratorError3;
  26495. }
  26496. }
  26497. }
  26498. retv[type] = Object.freeze(Array.from(keys));
  26499. } else {
  26500. retv[type] = Object.freeze(Array.from(additionalKeys[type]));
  26501. }
  26502. }
  26503. } catch (err) {
  26504. _didIteratorError2 = true;
  26505. _iteratorError2 = err;
  26506. } finally {
  26507. try {
  26508. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  26509. _iterator2.return();
  26510. }
  26511. } finally {
  26512. if (_didIteratorError2) {
  26513. throw _iteratorError2;
  26514. }
  26515. }
  26516. }
  26517. return Object.freeze(retv);
  26518. }
  26519. });
  26520. },{"./visitor-keys.json":70}],70:[function(require,module,exports){
  26521. module.exports={
  26522. "AssignmentExpression": [
  26523. "left",
  26524. "right"
  26525. ],
  26526. "AssignmentPattern": [
  26527. "left",
  26528. "right"
  26529. ],
  26530. "ArrayExpression": [
  26531. "elements"
  26532. ],
  26533. "ArrayPattern": [
  26534. "elements"
  26535. ],
  26536. "ArrowFunctionExpression": [
  26537. "params",
  26538. "body"
  26539. ],
  26540. "AwaitExpression": [
  26541. "argument"
  26542. ],
  26543. "BlockStatement": [
  26544. "body"
  26545. ],
  26546. "BinaryExpression": [
  26547. "left",
  26548. "right"
  26549. ],
  26550. "BreakStatement": [
  26551. "label"
  26552. ],
  26553. "CallExpression": [
  26554. "callee",
  26555. "arguments"
  26556. ],
  26557. "CatchClause": [
  26558. "param",
  26559. "body"
  26560. ],
  26561. "ClassBody": [
  26562. "body"
  26563. ],
  26564. "ClassDeclaration": [
  26565. "id",
  26566. "superClass",
  26567. "body"
  26568. ],
  26569. "ClassExpression": [
  26570. "id",
  26571. "superClass",
  26572. "body"
  26573. ],
  26574. "ConditionalExpression": [
  26575. "test",
  26576. "consequent",
  26577. "alternate"
  26578. ],
  26579. "ContinueStatement": [
  26580. "label"
  26581. ],
  26582. "DebuggerStatement": [],
  26583. "DoWhileStatement": [
  26584. "body",
  26585. "test"
  26586. ],
  26587. "EmptyStatement": [],
  26588. "ExportAllDeclaration": [
  26589. "source"
  26590. ],
  26591. "ExportDefaultDeclaration": [
  26592. "declaration"
  26593. ],
  26594. "ExportNamedDeclaration": [
  26595. "declaration",
  26596. "specifiers",
  26597. "source"
  26598. ],
  26599. "ExportSpecifier": [
  26600. "exported",
  26601. "local"
  26602. ],
  26603. "ExpressionStatement": [
  26604. "expression"
  26605. ],
  26606. "ExperimentalRestProperty": [
  26607. "argument"
  26608. ],
  26609. "ExperimentalSpreadProperty": [
  26610. "argument"
  26611. ],
  26612. "ForStatement": [
  26613. "init",
  26614. "test",
  26615. "update",
  26616. "body"
  26617. ],
  26618. "ForInStatement": [
  26619. "left",
  26620. "right",
  26621. "body"
  26622. ],
  26623. "ForOfStatement": [
  26624. "left",
  26625. "right",
  26626. "body"
  26627. ],
  26628. "FunctionDeclaration": [
  26629. "id",
  26630. "params",
  26631. "body"
  26632. ],
  26633. "FunctionExpression": [
  26634. "id",
  26635. "params",
  26636. "body"
  26637. ],
  26638. "Identifier": [],
  26639. "IfStatement": [
  26640. "test",
  26641. "consequent",
  26642. "alternate"
  26643. ],
  26644. "ImportDeclaration": [
  26645. "specifiers",
  26646. "source"
  26647. ],
  26648. "ImportDefaultSpecifier": [
  26649. "local"
  26650. ],
  26651. "ImportNamespaceSpecifier": [
  26652. "local"
  26653. ],
  26654. "ImportSpecifier": [
  26655. "imported",
  26656. "local"
  26657. ],
  26658. "JSXAttribute": [
  26659. "name",
  26660. "value"
  26661. ],
  26662. "JSXClosingElement": [
  26663. "name"
  26664. ],
  26665. "JSXElement": [
  26666. "openingElement",
  26667. "children",
  26668. "closingElement"
  26669. ],
  26670. "JSXEmptyExpression": [],
  26671. "JSXExpressionContainer": [
  26672. "expression"
  26673. ],
  26674. "JSXIdentifier": [],
  26675. "JSXMemberExpression": [
  26676. "object",
  26677. "property"
  26678. ],
  26679. "JSXNamespacedName": [
  26680. "namespace",
  26681. "name"
  26682. ],
  26683. "JSXOpeningElement": [
  26684. "name",
  26685. "attributes"
  26686. ],
  26687. "JSXSpreadAttribute": [
  26688. "argument"
  26689. ],
  26690. "JSXText": [],
  26691. "JSXFragment": [
  26692. "openingFragment",
  26693. "children",
  26694. "closingFragment"
  26695. ],
  26696. "Literal": [],
  26697. "LabeledStatement": [
  26698. "label",
  26699. "body"
  26700. ],
  26701. "LogicalExpression": [
  26702. "left",
  26703. "right"
  26704. ],
  26705. "MemberExpression": [
  26706. "object",
  26707. "property"
  26708. ],
  26709. "MetaProperty": [
  26710. "meta",
  26711. "property"
  26712. ],
  26713. "MethodDefinition": [
  26714. "key",
  26715. "value"
  26716. ],
  26717. "NewExpression": [
  26718. "callee",
  26719. "arguments"
  26720. ],
  26721. "ObjectExpression": [
  26722. "properties"
  26723. ],
  26724. "ObjectPattern": [
  26725. "properties"
  26726. ],
  26727. "Program": [
  26728. "body"
  26729. ],
  26730. "Property": [
  26731. "key",
  26732. "value"
  26733. ],
  26734. "RestElement": [
  26735. "argument"
  26736. ],
  26737. "ReturnStatement": [
  26738. "argument"
  26739. ],
  26740. "SequenceExpression": [
  26741. "expressions"
  26742. ],
  26743. "SpreadElement": [
  26744. "argument"
  26745. ],
  26746. "Super": [],
  26747. "SwitchStatement": [
  26748. "discriminant",
  26749. "cases"
  26750. ],
  26751. "SwitchCase": [
  26752. "test",
  26753. "consequent"
  26754. ],
  26755. "TaggedTemplateExpression": [
  26756. "tag",
  26757. "quasi"
  26758. ],
  26759. "TemplateElement": [],
  26760. "TemplateLiteral": [
  26761. "quasis",
  26762. "expressions"
  26763. ],
  26764. "ThisExpression": [],
  26765. "ThrowStatement": [
  26766. "argument"
  26767. ],
  26768. "TryStatement": [
  26769. "block",
  26770. "handler",
  26771. "finalizer"
  26772. ],
  26773. "UnaryExpression": [
  26774. "argument"
  26775. ],
  26776. "UpdateExpression": [
  26777. "argument"
  26778. ],
  26779. "VariableDeclaration": [
  26780. "declarations"
  26781. ],
  26782. "VariableDeclarator": [
  26783. "id",
  26784. "init"
  26785. ],
  26786. "WhileStatement": [
  26787. "test",
  26788. "body"
  26789. ],
  26790. "WithStatement": [
  26791. "object",
  26792. "body"
  26793. ],
  26794. "YieldExpression": [
  26795. "argument"
  26796. ]
  26797. }
  26798. },{}],71:[function(require,module,exports){
  26799. 'use strict';
  26800. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  26801. /* vim: set sw=4 sts=4 : */
  26802. (function () {
  26803. var estraverse = require('estraverse');
  26804. var parser = require('./parser');
  26805. var isArray = Array.isArray || function isArray(array) {
  26806. return {}.toString.call(array) === '[object Array]';
  26807. };
  26808. var LEFT_SIDE = {};
  26809. var RIGHT_SIDE = {};
  26810. function esqueryModule() {
  26811. /**
  26812. * Get the value of a property which may be multiple levels down in the object.
  26813. */
  26814. function getPath(obj, key) {
  26815. var i,
  26816. keys = key.split(".");
  26817. for (i = 0; i < keys.length; i++) {
  26818. if (obj == null) {
  26819. return obj;
  26820. }
  26821. obj = obj[keys[i]];
  26822. }
  26823. return obj;
  26824. }
  26825. /**
  26826. * Determine whether `node` can be reached by following `path`, starting at `ancestor`.
  26827. */
  26828. function inPath(node, ancestor, path) {
  26829. var field, remainingPath, i;
  26830. if (path.length === 0) {
  26831. return node === ancestor;
  26832. }
  26833. if (ancestor == null) {
  26834. return false;
  26835. }
  26836. field = ancestor[path[0]];
  26837. remainingPath = path.slice(1);
  26838. if (isArray(field)) {
  26839. for (i = 0, l = field.length; i < l; ++i) {
  26840. if (inPath(node, field[i], remainingPath)) {
  26841. return true;
  26842. }
  26843. }
  26844. return false;
  26845. } else {
  26846. return inPath(node, field, remainingPath);
  26847. }
  26848. }
  26849. /**
  26850. * Given a `node` and its ancestors, determine if `node` is matched by `selector`.
  26851. */
  26852. function matches(node, selector, ancestry) {
  26853. var path, ancestor, i, l, p;
  26854. if (!selector) {
  26855. return true;
  26856. }
  26857. if (!node) {
  26858. return false;
  26859. }
  26860. if (!ancestry) {
  26861. ancestry = [];
  26862. }
  26863. switch (selector.type) {
  26864. case 'wildcard':
  26865. return true;
  26866. case 'identifier':
  26867. return selector.value.toLowerCase() === node.type.toLowerCase();
  26868. case 'field':
  26869. path = selector.name.split('.');
  26870. ancestor = ancestry[path.length - 1];
  26871. return inPath(node, ancestor, path);
  26872. case 'matches':
  26873. for (i = 0, l = selector.selectors.length; i < l; ++i) {
  26874. if (matches(node, selector.selectors[i], ancestry)) {
  26875. return true;
  26876. }
  26877. }
  26878. return false;
  26879. case 'compound':
  26880. for (i = 0, l = selector.selectors.length; i < l; ++i) {
  26881. if (!matches(node, selector.selectors[i], ancestry)) {
  26882. return false;
  26883. }
  26884. }
  26885. return true;
  26886. case 'not':
  26887. for (i = 0, l = selector.selectors.length; i < l; ++i) {
  26888. if (matches(node, selector.selectors[i], ancestry)) {
  26889. return false;
  26890. }
  26891. }
  26892. return true;
  26893. case 'has':
  26894. var a,
  26895. collector = [];
  26896. for (i = 0, l = selector.selectors.length; i < l; ++i) {
  26897. a = [];
  26898. estraverse.traverse(node, {
  26899. enter: function enter(node, parent) {
  26900. if (parent != null) {
  26901. a.unshift(parent);
  26902. }
  26903. if (matches(node, selector.selectors[i], a)) {
  26904. collector.push(node);
  26905. }
  26906. },
  26907. leave: function leave() {
  26908. a.shift();
  26909. }
  26910. });
  26911. }
  26912. return collector.length !== 0;
  26913. case 'child':
  26914. if (matches(node, selector.right, ancestry)) {
  26915. return matches(ancestry[0], selector.left, ancestry.slice(1));
  26916. }
  26917. return false;
  26918. case 'descendant':
  26919. if (matches(node, selector.right, ancestry)) {
  26920. for (i = 0, l = ancestry.length; i < l; ++i) {
  26921. if (matches(ancestry[i], selector.left, ancestry.slice(i + 1))) {
  26922. return true;
  26923. }
  26924. }
  26925. }
  26926. return false;
  26927. case 'attribute':
  26928. p = getPath(node, selector.name);
  26929. switch (selector.operator) {
  26930. case null:
  26931. case void 0:
  26932. return p != null;
  26933. case '=':
  26934. switch (selector.value.type) {
  26935. case 'regexp':
  26936. return typeof p === 'string' && selector.value.value.test(p);
  26937. case 'literal':
  26938. return '' + selector.value.value === '' + p;
  26939. case 'type':
  26940. return selector.value.value === (typeof p === 'undefined' ? 'undefined' : _typeof(p));
  26941. }
  26942. case '!=':
  26943. switch (selector.value.type) {
  26944. case 'regexp':
  26945. return !selector.value.value.test(p);
  26946. case 'literal':
  26947. return '' + selector.value.value !== '' + p;
  26948. case 'type':
  26949. return selector.value.value !== (typeof p === 'undefined' ? 'undefined' : _typeof(p));
  26950. }
  26951. case '<=':
  26952. return p <= selector.value.value;
  26953. case '<':
  26954. return p < selector.value.value;
  26955. case '>':
  26956. return p > selector.value.value;
  26957. case '>=':
  26958. return p >= selector.value.value;
  26959. }
  26960. case 'sibling':
  26961. return matches(node, selector.right, ancestry) && sibling(node, selector.left, ancestry, LEFT_SIDE) || selector.left.subject && matches(node, selector.left, ancestry) && sibling(node, selector.right, ancestry, RIGHT_SIDE);
  26962. case 'adjacent':
  26963. return matches(node, selector.right, ancestry) && adjacent(node, selector.left, ancestry, LEFT_SIDE) || selector.right.subject && matches(node, selector.left, ancestry) && adjacent(node, selector.right, ancestry, RIGHT_SIDE);
  26964. case 'nth-child':
  26965. return matches(node, selector.right, ancestry) && nthChild(node, ancestry, function (length) {
  26966. return selector.index.value - 1;
  26967. });
  26968. case 'nth-last-child':
  26969. return matches(node, selector.right, ancestry) && nthChild(node, ancestry, function (length) {
  26970. return length - selector.index.value;
  26971. });
  26972. case 'class':
  26973. if (!node.type) return false;
  26974. switch (selector.name.toLowerCase()) {
  26975. case 'statement':
  26976. if (node.type.slice(-9) === 'Statement') return true;
  26977. // fallthrough: interface Declaration <: Statement { }
  26978. case 'declaration':
  26979. return node.type.slice(-11) === 'Declaration';
  26980. case 'pattern':
  26981. if (node.type.slice(-7) === 'Pattern') return true;
  26982. // fallthrough: interface Expression <: Node, Pattern { }
  26983. case 'expression':
  26984. return node.type.slice(-10) === 'Expression' || node.type.slice(-7) === 'Literal' || node.type === 'Identifier' && (ancestry.length === 0 || ancestry[0].type !== 'MetaProperty') || node.type === 'MetaProperty';
  26985. case 'function':
  26986. return node.type.slice(0, 8) === 'Function' || node.type === 'ArrowFunctionExpression';
  26987. }
  26988. throw new Error('Unknown class name: ' + selector.name);
  26989. }
  26990. throw new Error('Unknown selector type: ' + selector.type);
  26991. }
  26992. /*
  26993. * Determines if the given node has a sibling that matches the given selector.
  26994. */
  26995. function sibling(node, selector, ancestry, side) {
  26996. var parent = ancestry[0],
  26997. listProp,
  26998. startIndex,
  26999. keys,
  27000. i,
  27001. l,
  27002. k,
  27003. lowerBound,
  27004. upperBound;
  27005. if (!parent) {
  27006. return false;
  27007. }
  27008. keys = estraverse.VisitorKeys[parent.type];
  27009. for (i = 0, l = keys.length; i < l; ++i) {
  27010. listProp = parent[keys[i]];
  27011. if (isArray(listProp)) {
  27012. startIndex = listProp.indexOf(node);
  27013. if (startIndex < 0) {
  27014. continue;
  27015. }
  27016. if (side === LEFT_SIDE) {
  27017. lowerBound = 0;
  27018. upperBound = startIndex;
  27019. } else {
  27020. lowerBound = startIndex + 1;
  27021. upperBound = listProp.length;
  27022. }
  27023. for (k = lowerBound; k < upperBound; ++k) {
  27024. if (matches(listProp[k], selector, ancestry)) {
  27025. return true;
  27026. }
  27027. }
  27028. }
  27029. }
  27030. return false;
  27031. }
  27032. /*
  27033. * Determines if the given node has an asjacent sibling that matches the given selector.
  27034. */
  27035. function adjacent(node, selector, ancestry, side) {
  27036. var parent = ancestry[0],
  27037. listProp,
  27038. keys,
  27039. i,
  27040. l,
  27041. idx;
  27042. if (!parent) {
  27043. return false;
  27044. }
  27045. keys = estraverse.VisitorKeys[parent.type];
  27046. for (i = 0, l = keys.length; i < l; ++i) {
  27047. listProp = parent[keys[i]];
  27048. if (isArray(listProp)) {
  27049. idx = listProp.indexOf(node);
  27050. if (idx < 0) {
  27051. continue;
  27052. }
  27053. if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) {
  27054. return true;
  27055. }
  27056. if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) {
  27057. return true;
  27058. }
  27059. }
  27060. }
  27061. return false;
  27062. }
  27063. /*
  27064. * Determines if the given node is the nth child, determined by idxFn, which is given the containing list's length.
  27065. */
  27066. function nthChild(node, ancestry, idxFn) {
  27067. var parent = ancestry[0],
  27068. listProp,
  27069. keys,
  27070. i,
  27071. l,
  27072. idx;
  27073. if (!parent) {
  27074. return false;
  27075. }
  27076. keys = estraverse.VisitorKeys[parent.type];
  27077. for (i = 0, l = keys.length; i < l; ++i) {
  27078. listProp = parent[keys[i]];
  27079. if (isArray(listProp)) {
  27080. idx = listProp.indexOf(node);
  27081. if (idx >= 0 && idx === idxFn(listProp.length)) {
  27082. return true;
  27083. }
  27084. }
  27085. }
  27086. return false;
  27087. }
  27088. /*
  27089. * For each selector node marked as a subject, find the portion of the selector that the subject must match.
  27090. */
  27091. function subjects(selector, ancestor) {
  27092. var results, p;
  27093. if (selector == null || (typeof selector === 'undefined' ? 'undefined' : _typeof(selector)) != 'object') {
  27094. return [];
  27095. }
  27096. if (ancestor == null) {
  27097. ancestor = selector;
  27098. }
  27099. results = selector.subject ? [ancestor] : [];
  27100. for (p in selector) {
  27101. if (!{}.hasOwnProperty.call(selector, p)) {
  27102. continue;
  27103. }
  27104. [].push.apply(results, subjects(selector[p], p === 'left' ? selector[p] : ancestor));
  27105. }
  27106. return results;
  27107. }
  27108. /**
  27109. * From a JS AST and a selector AST, collect all JS AST nodes that match the selector.
  27110. */
  27111. function match(ast, selector) {
  27112. var ancestry = [],
  27113. results = [],
  27114. altSubjects,
  27115. i,
  27116. l,
  27117. k,
  27118. m;
  27119. if (!selector) {
  27120. return results;
  27121. }
  27122. altSubjects = subjects(selector);
  27123. estraverse.traverse(ast, {
  27124. enter: function enter(node, parent) {
  27125. if (parent != null) {
  27126. ancestry.unshift(parent);
  27127. }
  27128. if (matches(node, selector, ancestry)) {
  27129. if (altSubjects.length) {
  27130. for (i = 0, l = altSubjects.length; i < l; ++i) {
  27131. if (matches(node, altSubjects[i], ancestry)) {
  27132. results.push(node);
  27133. }
  27134. for (k = 0, m = ancestry.length; k < m; ++k) {
  27135. if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) {
  27136. results.push(ancestry[k]);
  27137. }
  27138. }
  27139. }
  27140. } else {
  27141. results.push(node);
  27142. }
  27143. }
  27144. },
  27145. leave: function leave() {
  27146. ancestry.shift();
  27147. }
  27148. });
  27149. return results;
  27150. }
  27151. /**
  27152. * Parse a selector string and return its AST.
  27153. */
  27154. function parse(selector) {
  27155. return parser.parse(selector);
  27156. }
  27157. /**
  27158. * Query the code AST using the selector string.
  27159. */
  27160. function query(ast, selector) {
  27161. return match(ast, parse(selector));
  27162. }
  27163. query.parse = parse;
  27164. query.match = match;
  27165. query.matches = matches;
  27166. return query.query = query;
  27167. }
  27168. if (typeof define === "function" && define.amd) {
  27169. define(esqueryModule);
  27170. } else if (typeof module !== 'undefined' && module.exports) {
  27171. module.exports = esqueryModule();
  27172. } else {
  27173. this.esquery = esqueryModule();
  27174. }
  27175. })();
  27176. },{"./parser":72,"estraverse":75}],72:[function(require,module,exports){
  27177. 'use strict';
  27178. var result = function () {
  27179. /*
  27180. * Generated by PEG.js 0.7.0.
  27181. *
  27182. * http://pegjs.majda.cz/
  27183. */
  27184. function quote(s) {
  27185. /*
  27186. * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
  27187. * string literal except for the closing quote character, backslash,
  27188. * carriage return, line separator, paragraph separator, and line feed.
  27189. * Any character may appear in the form of an escape sequence.
  27190. *
  27191. * For portability, we also escape escape all control and non-ASCII
  27192. * characters. Note that "\0" and "\v" escape sequences are not used
  27193. * because JSHint does not like the first and IE the second.
  27194. */
  27195. return '"' + s.replace(/\\/g, '\\\\') // backslash
  27196. .replace(/"/g, '\\"') // closing quote character
  27197. .replace(/\x08/g, '\\b') // backspace
  27198. .replace(/\t/g, '\\t') // horizontal tab
  27199. .replace(/\n/g, '\\n') // line feed
  27200. .replace(/\f/g, '\\f') // form feed
  27201. .replace(/\r/g, '\\r') // carriage return
  27202. .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) + '"';
  27203. }
  27204. var result = {
  27205. /*
  27206. * Parses the input with a generated parser. If the parsing is successfull,
  27207. * returns a value explicitly or implicitly specified by the grammar from
  27208. * which the parser was generated (see |PEG.buildParser|). If the parsing is
  27209. * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
  27210. */
  27211. parse: function parse(input, startRule) {
  27212. var parseFunctions = {
  27213. "start": parse_start,
  27214. "_": parse__,
  27215. "identifierName": parse_identifierName,
  27216. "binaryOp": parse_binaryOp,
  27217. "selectors": parse_selectors,
  27218. "selector": parse_selector,
  27219. "sequence": parse_sequence,
  27220. "atom": parse_atom,
  27221. "wildcard": parse_wildcard,
  27222. "identifier": parse_identifier,
  27223. "attr": parse_attr,
  27224. "attrOps": parse_attrOps,
  27225. "attrEqOps": parse_attrEqOps,
  27226. "attrName": parse_attrName,
  27227. "attrValue": parse_attrValue,
  27228. "string": parse_string,
  27229. "number": parse_number,
  27230. "path": parse_path,
  27231. "type": parse_type,
  27232. "regex": parse_regex,
  27233. "field": parse_field,
  27234. "negation": parse_negation,
  27235. "matches": parse_matches,
  27236. "has": parse_has,
  27237. "firstChild": parse_firstChild,
  27238. "lastChild": parse_lastChild,
  27239. "nthChild": parse_nthChild,
  27240. "nthLastChild": parse_nthLastChild,
  27241. "class": parse_class
  27242. };
  27243. if (startRule !== undefined) {
  27244. if (parseFunctions[startRule] === undefined) {
  27245. throw new Error("Invalid rule name: " + quote(startRule) + ".");
  27246. }
  27247. } else {
  27248. startRule = "start";
  27249. }
  27250. var pos = 0;
  27251. var reportFailures = 0;
  27252. var rightmostFailuresPos = 0;
  27253. var rightmostFailuresExpected = [];
  27254. var cache = {};
  27255. function padLeft(input, padding, length) {
  27256. var result = input;
  27257. var padLength = length - input.length;
  27258. for (var i = 0; i < padLength; i++) {
  27259. result = padding + result;
  27260. }
  27261. return result;
  27262. }
  27263. function escape(ch) {
  27264. var charCode = ch.charCodeAt(0);
  27265. var escapeChar;
  27266. var length;
  27267. if (charCode <= 0xFF) {
  27268. escapeChar = 'x';
  27269. length = 2;
  27270. } else {
  27271. escapeChar = 'u';
  27272. length = 4;
  27273. }
  27274. return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
  27275. }
  27276. function matchFailed(failure) {
  27277. if (pos < rightmostFailuresPos) {
  27278. return;
  27279. }
  27280. if (pos > rightmostFailuresPos) {
  27281. rightmostFailuresPos = pos;
  27282. rightmostFailuresExpected = [];
  27283. }
  27284. rightmostFailuresExpected.push(failure);
  27285. }
  27286. function parse_start() {
  27287. var cacheKey = "start@" + pos;
  27288. var cachedResult = cache[cacheKey];
  27289. if (cachedResult) {
  27290. pos = cachedResult.nextPos;
  27291. return cachedResult.result;
  27292. }
  27293. var result0, result1, result2;
  27294. var pos0, pos1;
  27295. pos0 = pos;
  27296. pos1 = pos;
  27297. result0 = parse__();
  27298. if (result0 !== null) {
  27299. result1 = parse_selectors();
  27300. if (result1 !== null) {
  27301. result2 = parse__();
  27302. if (result2 !== null) {
  27303. result0 = [result0, result1, result2];
  27304. } else {
  27305. result0 = null;
  27306. pos = pos1;
  27307. }
  27308. } else {
  27309. result0 = null;
  27310. pos = pos1;
  27311. }
  27312. } else {
  27313. result0 = null;
  27314. pos = pos1;
  27315. }
  27316. if (result0 !== null) {
  27317. result0 = function (offset, ss) {
  27318. return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss };
  27319. }(pos0, result0[1]);
  27320. }
  27321. if (result0 === null) {
  27322. pos = pos0;
  27323. }
  27324. if (result0 === null) {
  27325. pos0 = pos;
  27326. result0 = parse__();
  27327. if (result0 !== null) {
  27328. result0 = function (offset) {
  27329. return void 0;
  27330. }(pos0);
  27331. }
  27332. if (result0 === null) {
  27333. pos = pos0;
  27334. }
  27335. }
  27336. cache[cacheKey] = {
  27337. nextPos: pos,
  27338. result: result0
  27339. };
  27340. return result0;
  27341. }
  27342. function parse__() {
  27343. var cacheKey = "_@" + pos;
  27344. var cachedResult = cache[cacheKey];
  27345. if (cachedResult) {
  27346. pos = cachedResult.nextPos;
  27347. return cachedResult.result;
  27348. }
  27349. var result0, result1;
  27350. result0 = [];
  27351. if (input.charCodeAt(pos) === 32) {
  27352. result1 = " ";
  27353. pos++;
  27354. } else {
  27355. result1 = null;
  27356. if (reportFailures === 0) {
  27357. matchFailed("\" \"");
  27358. }
  27359. }
  27360. while (result1 !== null) {
  27361. result0.push(result1);
  27362. if (input.charCodeAt(pos) === 32) {
  27363. result1 = " ";
  27364. pos++;
  27365. } else {
  27366. result1 = null;
  27367. if (reportFailures === 0) {
  27368. matchFailed("\" \"");
  27369. }
  27370. }
  27371. }
  27372. cache[cacheKey] = {
  27373. nextPos: pos,
  27374. result: result0
  27375. };
  27376. return result0;
  27377. }
  27378. function parse_identifierName() {
  27379. var cacheKey = "identifierName@" + pos;
  27380. var cachedResult = cache[cacheKey];
  27381. if (cachedResult) {
  27382. pos = cachedResult.nextPos;
  27383. return cachedResult.result;
  27384. }
  27385. var result0, result1;
  27386. var pos0;
  27387. pos0 = pos;
  27388. if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
  27389. result1 = input.charAt(pos);
  27390. pos++;
  27391. } else {
  27392. result1 = null;
  27393. if (reportFailures === 0) {
  27394. matchFailed("[^ [\\],():#!=><~+.]");
  27395. }
  27396. }
  27397. if (result1 !== null) {
  27398. result0 = [];
  27399. while (result1 !== null) {
  27400. result0.push(result1);
  27401. if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
  27402. result1 = input.charAt(pos);
  27403. pos++;
  27404. } else {
  27405. result1 = null;
  27406. if (reportFailures === 0) {
  27407. matchFailed("[^ [\\],():#!=><~+.]");
  27408. }
  27409. }
  27410. }
  27411. } else {
  27412. result0 = null;
  27413. }
  27414. if (result0 !== null) {
  27415. result0 = function (offset, i) {
  27416. return i.join('');
  27417. }(pos0, result0);
  27418. }
  27419. if (result0 === null) {
  27420. pos = pos0;
  27421. }
  27422. cache[cacheKey] = {
  27423. nextPos: pos,
  27424. result: result0
  27425. };
  27426. return result0;
  27427. }
  27428. function parse_binaryOp() {
  27429. var cacheKey = "binaryOp@" + pos;
  27430. var cachedResult = cache[cacheKey];
  27431. if (cachedResult) {
  27432. pos = cachedResult.nextPos;
  27433. return cachedResult.result;
  27434. }
  27435. var result0, result1, result2;
  27436. var pos0, pos1;
  27437. pos0 = pos;
  27438. pos1 = pos;
  27439. result0 = parse__();
  27440. if (result0 !== null) {
  27441. if (input.charCodeAt(pos) === 62) {
  27442. result1 = ">";
  27443. pos++;
  27444. } else {
  27445. result1 = null;
  27446. if (reportFailures === 0) {
  27447. matchFailed("\">\"");
  27448. }
  27449. }
  27450. if (result1 !== null) {
  27451. result2 = parse__();
  27452. if (result2 !== null) {
  27453. result0 = [result0, result1, result2];
  27454. } else {
  27455. result0 = null;
  27456. pos = pos1;
  27457. }
  27458. } else {
  27459. result0 = null;
  27460. pos = pos1;
  27461. }
  27462. } else {
  27463. result0 = null;
  27464. pos = pos1;
  27465. }
  27466. if (result0 !== null) {
  27467. result0 = function (offset) {
  27468. return 'child';
  27469. }(pos0);
  27470. }
  27471. if (result0 === null) {
  27472. pos = pos0;
  27473. }
  27474. if (result0 === null) {
  27475. pos0 = pos;
  27476. pos1 = pos;
  27477. result0 = parse__();
  27478. if (result0 !== null) {
  27479. if (input.charCodeAt(pos) === 126) {
  27480. result1 = "~";
  27481. pos++;
  27482. } else {
  27483. result1 = null;
  27484. if (reportFailures === 0) {
  27485. matchFailed("\"~\"");
  27486. }
  27487. }
  27488. if (result1 !== null) {
  27489. result2 = parse__();
  27490. if (result2 !== null) {
  27491. result0 = [result0, result1, result2];
  27492. } else {
  27493. result0 = null;
  27494. pos = pos1;
  27495. }
  27496. } else {
  27497. result0 = null;
  27498. pos = pos1;
  27499. }
  27500. } else {
  27501. result0 = null;
  27502. pos = pos1;
  27503. }
  27504. if (result0 !== null) {
  27505. result0 = function (offset) {
  27506. return 'sibling';
  27507. }(pos0);
  27508. }
  27509. if (result0 === null) {
  27510. pos = pos0;
  27511. }
  27512. if (result0 === null) {
  27513. pos0 = pos;
  27514. pos1 = pos;
  27515. result0 = parse__();
  27516. if (result0 !== null) {
  27517. if (input.charCodeAt(pos) === 43) {
  27518. result1 = "+";
  27519. pos++;
  27520. } else {
  27521. result1 = null;
  27522. if (reportFailures === 0) {
  27523. matchFailed("\"+\"");
  27524. }
  27525. }
  27526. if (result1 !== null) {
  27527. result2 = parse__();
  27528. if (result2 !== null) {
  27529. result0 = [result0, result1, result2];
  27530. } else {
  27531. result0 = null;
  27532. pos = pos1;
  27533. }
  27534. } else {
  27535. result0 = null;
  27536. pos = pos1;
  27537. }
  27538. } else {
  27539. result0 = null;
  27540. pos = pos1;
  27541. }
  27542. if (result0 !== null) {
  27543. result0 = function (offset) {
  27544. return 'adjacent';
  27545. }(pos0);
  27546. }
  27547. if (result0 === null) {
  27548. pos = pos0;
  27549. }
  27550. if (result0 === null) {
  27551. pos0 = pos;
  27552. pos1 = pos;
  27553. if (input.charCodeAt(pos) === 32) {
  27554. result0 = " ";
  27555. pos++;
  27556. } else {
  27557. result0 = null;
  27558. if (reportFailures === 0) {
  27559. matchFailed("\" \"");
  27560. }
  27561. }
  27562. if (result0 !== null) {
  27563. result1 = parse__();
  27564. if (result1 !== null) {
  27565. result0 = [result0, result1];
  27566. } else {
  27567. result0 = null;
  27568. pos = pos1;
  27569. }
  27570. } else {
  27571. result0 = null;
  27572. pos = pos1;
  27573. }
  27574. if (result0 !== null) {
  27575. result0 = function (offset) {
  27576. return 'descendant';
  27577. }(pos0);
  27578. }
  27579. if (result0 === null) {
  27580. pos = pos0;
  27581. }
  27582. }
  27583. }
  27584. }
  27585. cache[cacheKey] = {
  27586. nextPos: pos,
  27587. result: result0
  27588. };
  27589. return result0;
  27590. }
  27591. function parse_selectors() {
  27592. var cacheKey = "selectors@" + pos;
  27593. var cachedResult = cache[cacheKey];
  27594. if (cachedResult) {
  27595. pos = cachedResult.nextPos;
  27596. return cachedResult.result;
  27597. }
  27598. var result0, result1, result2, result3, result4, result5;
  27599. var pos0, pos1, pos2;
  27600. pos0 = pos;
  27601. pos1 = pos;
  27602. result0 = parse_selector();
  27603. if (result0 !== null) {
  27604. result1 = [];
  27605. pos2 = pos;
  27606. result2 = parse__();
  27607. if (result2 !== null) {
  27608. if (input.charCodeAt(pos) === 44) {
  27609. result3 = ",";
  27610. pos++;
  27611. } else {
  27612. result3 = null;
  27613. if (reportFailures === 0) {
  27614. matchFailed("\",\"");
  27615. }
  27616. }
  27617. if (result3 !== null) {
  27618. result4 = parse__();
  27619. if (result4 !== null) {
  27620. result5 = parse_selector();
  27621. if (result5 !== null) {
  27622. result2 = [result2, result3, result4, result5];
  27623. } else {
  27624. result2 = null;
  27625. pos = pos2;
  27626. }
  27627. } else {
  27628. result2 = null;
  27629. pos = pos2;
  27630. }
  27631. } else {
  27632. result2 = null;
  27633. pos = pos2;
  27634. }
  27635. } else {
  27636. result2 = null;
  27637. pos = pos2;
  27638. }
  27639. while (result2 !== null) {
  27640. result1.push(result2);
  27641. pos2 = pos;
  27642. result2 = parse__();
  27643. if (result2 !== null) {
  27644. if (input.charCodeAt(pos) === 44) {
  27645. result3 = ",";
  27646. pos++;
  27647. } else {
  27648. result3 = null;
  27649. if (reportFailures === 0) {
  27650. matchFailed("\",\"");
  27651. }
  27652. }
  27653. if (result3 !== null) {
  27654. result4 = parse__();
  27655. if (result4 !== null) {
  27656. result5 = parse_selector();
  27657. if (result5 !== null) {
  27658. result2 = [result2, result3, result4, result5];
  27659. } else {
  27660. result2 = null;
  27661. pos = pos2;
  27662. }
  27663. } else {
  27664. result2 = null;
  27665. pos = pos2;
  27666. }
  27667. } else {
  27668. result2 = null;
  27669. pos = pos2;
  27670. }
  27671. } else {
  27672. result2 = null;
  27673. pos = pos2;
  27674. }
  27675. }
  27676. if (result1 !== null) {
  27677. result0 = [result0, result1];
  27678. } else {
  27679. result0 = null;
  27680. pos = pos1;
  27681. }
  27682. } else {
  27683. result0 = null;
  27684. pos = pos1;
  27685. }
  27686. if (result0 !== null) {
  27687. result0 = function (offset, s, ss) {
  27688. return [s].concat(ss.map(function (s) {
  27689. return s[3];
  27690. }));
  27691. }(pos0, result0[0], result0[1]);
  27692. }
  27693. if (result0 === null) {
  27694. pos = pos0;
  27695. }
  27696. cache[cacheKey] = {
  27697. nextPos: pos,
  27698. result: result0
  27699. };
  27700. return result0;
  27701. }
  27702. function parse_selector() {
  27703. var cacheKey = "selector@" + pos;
  27704. var cachedResult = cache[cacheKey];
  27705. if (cachedResult) {
  27706. pos = cachedResult.nextPos;
  27707. return cachedResult.result;
  27708. }
  27709. var result0, result1, result2, result3;
  27710. var pos0, pos1, pos2;
  27711. pos0 = pos;
  27712. pos1 = pos;
  27713. result0 = parse_sequence();
  27714. if (result0 !== null) {
  27715. result1 = [];
  27716. pos2 = pos;
  27717. result2 = parse_binaryOp();
  27718. if (result2 !== null) {
  27719. result3 = parse_sequence();
  27720. if (result3 !== null) {
  27721. result2 = [result2, result3];
  27722. } else {
  27723. result2 = null;
  27724. pos = pos2;
  27725. }
  27726. } else {
  27727. result2 = null;
  27728. pos = pos2;
  27729. }
  27730. while (result2 !== null) {
  27731. result1.push(result2);
  27732. pos2 = pos;
  27733. result2 = parse_binaryOp();
  27734. if (result2 !== null) {
  27735. result3 = parse_sequence();
  27736. if (result3 !== null) {
  27737. result2 = [result2, result3];
  27738. } else {
  27739. result2 = null;
  27740. pos = pos2;
  27741. }
  27742. } else {
  27743. result2 = null;
  27744. pos = pos2;
  27745. }
  27746. }
  27747. if (result1 !== null) {
  27748. result0 = [result0, result1];
  27749. } else {
  27750. result0 = null;
  27751. pos = pos1;
  27752. }
  27753. } else {
  27754. result0 = null;
  27755. pos = pos1;
  27756. }
  27757. if (result0 !== null) {
  27758. result0 = function (offset, a, ops) {
  27759. return ops.reduce(function (memo, rhs) {
  27760. return { type: rhs[0], left: memo, right: rhs[1] };
  27761. }, a);
  27762. }(pos0, result0[0], result0[1]);
  27763. }
  27764. if (result0 === null) {
  27765. pos = pos0;
  27766. }
  27767. cache[cacheKey] = {
  27768. nextPos: pos,
  27769. result: result0
  27770. };
  27771. return result0;
  27772. }
  27773. function parse_sequence() {
  27774. var cacheKey = "sequence@" + pos;
  27775. var cachedResult = cache[cacheKey];
  27776. if (cachedResult) {
  27777. pos = cachedResult.nextPos;
  27778. return cachedResult.result;
  27779. }
  27780. var result0, result1, result2;
  27781. var pos0, pos1;
  27782. pos0 = pos;
  27783. pos1 = pos;
  27784. if (input.charCodeAt(pos) === 33) {
  27785. result0 = "!";
  27786. pos++;
  27787. } else {
  27788. result0 = null;
  27789. if (reportFailures === 0) {
  27790. matchFailed("\"!\"");
  27791. }
  27792. }
  27793. result0 = result0 !== null ? result0 : "";
  27794. if (result0 !== null) {
  27795. result2 = parse_atom();
  27796. if (result2 !== null) {
  27797. result1 = [];
  27798. while (result2 !== null) {
  27799. result1.push(result2);
  27800. result2 = parse_atom();
  27801. }
  27802. } else {
  27803. result1 = null;
  27804. }
  27805. if (result1 !== null) {
  27806. result0 = [result0, result1];
  27807. } else {
  27808. result0 = null;
  27809. pos = pos1;
  27810. }
  27811. } else {
  27812. result0 = null;
  27813. pos = pos1;
  27814. }
  27815. if (result0 !== null) {
  27816. result0 = function (offset, subject, as) {
  27817. var b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
  27818. if (subject) b.subject = true;
  27819. return b;
  27820. }(pos0, result0[0], result0[1]);
  27821. }
  27822. if (result0 === null) {
  27823. pos = pos0;
  27824. }
  27825. cache[cacheKey] = {
  27826. nextPos: pos,
  27827. result: result0
  27828. };
  27829. return result0;
  27830. }
  27831. function parse_atom() {
  27832. var cacheKey = "atom@" + pos;
  27833. var cachedResult = cache[cacheKey];
  27834. if (cachedResult) {
  27835. pos = cachedResult.nextPos;
  27836. return cachedResult.result;
  27837. }
  27838. var result0;
  27839. result0 = parse_wildcard();
  27840. if (result0 === null) {
  27841. result0 = parse_identifier();
  27842. if (result0 === null) {
  27843. result0 = parse_attr();
  27844. if (result0 === null) {
  27845. result0 = parse_field();
  27846. if (result0 === null) {
  27847. result0 = parse_negation();
  27848. if (result0 === null) {
  27849. result0 = parse_matches();
  27850. if (result0 === null) {
  27851. result0 = parse_has();
  27852. if (result0 === null) {
  27853. result0 = parse_firstChild();
  27854. if (result0 === null) {
  27855. result0 = parse_lastChild();
  27856. if (result0 === null) {
  27857. result0 = parse_nthChild();
  27858. if (result0 === null) {
  27859. result0 = parse_nthLastChild();
  27860. if (result0 === null) {
  27861. result0 = parse_class();
  27862. }
  27863. }
  27864. }
  27865. }
  27866. }
  27867. }
  27868. }
  27869. }
  27870. }
  27871. }
  27872. }
  27873. cache[cacheKey] = {
  27874. nextPos: pos,
  27875. result: result0
  27876. };
  27877. return result0;
  27878. }
  27879. function parse_wildcard() {
  27880. var cacheKey = "wildcard@" + pos;
  27881. var cachedResult = cache[cacheKey];
  27882. if (cachedResult) {
  27883. pos = cachedResult.nextPos;
  27884. return cachedResult.result;
  27885. }
  27886. var result0;
  27887. var pos0;
  27888. pos0 = pos;
  27889. if (input.charCodeAt(pos) === 42) {
  27890. result0 = "*";
  27891. pos++;
  27892. } else {
  27893. result0 = null;
  27894. if (reportFailures === 0) {
  27895. matchFailed("\"*\"");
  27896. }
  27897. }
  27898. if (result0 !== null) {
  27899. result0 = function (offset, a) {
  27900. return { type: 'wildcard', value: a };
  27901. }(pos0, result0);
  27902. }
  27903. if (result0 === null) {
  27904. pos = pos0;
  27905. }
  27906. cache[cacheKey] = {
  27907. nextPos: pos,
  27908. result: result0
  27909. };
  27910. return result0;
  27911. }
  27912. function parse_identifier() {
  27913. var cacheKey = "identifier@" + pos;
  27914. var cachedResult = cache[cacheKey];
  27915. if (cachedResult) {
  27916. pos = cachedResult.nextPos;
  27917. return cachedResult.result;
  27918. }
  27919. var result0, result1;
  27920. var pos0, pos1;
  27921. pos0 = pos;
  27922. pos1 = pos;
  27923. if (input.charCodeAt(pos) === 35) {
  27924. result0 = "#";
  27925. pos++;
  27926. } else {
  27927. result0 = null;
  27928. if (reportFailures === 0) {
  27929. matchFailed("\"#\"");
  27930. }
  27931. }
  27932. result0 = result0 !== null ? result0 : "";
  27933. if (result0 !== null) {
  27934. result1 = parse_identifierName();
  27935. if (result1 !== null) {
  27936. result0 = [result0, result1];
  27937. } else {
  27938. result0 = null;
  27939. pos = pos1;
  27940. }
  27941. } else {
  27942. result0 = null;
  27943. pos = pos1;
  27944. }
  27945. if (result0 !== null) {
  27946. result0 = function (offset, i) {
  27947. return { type: 'identifier', value: i };
  27948. }(pos0, result0[1]);
  27949. }
  27950. if (result0 === null) {
  27951. pos = pos0;
  27952. }
  27953. cache[cacheKey] = {
  27954. nextPos: pos,
  27955. result: result0
  27956. };
  27957. return result0;
  27958. }
  27959. function parse_attr() {
  27960. var cacheKey = "attr@" + pos;
  27961. var cachedResult = cache[cacheKey];
  27962. if (cachedResult) {
  27963. pos = cachedResult.nextPos;
  27964. return cachedResult.result;
  27965. }
  27966. var result0, result1, result2, result3, result4;
  27967. var pos0, pos1;
  27968. pos0 = pos;
  27969. pos1 = pos;
  27970. if (input.charCodeAt(pos) === 91) {
  27971. result0 = "[";
  27972. pos++;
  27973. } else {
  27974. result0 = null;
  27975. if (reportFailures === 0) {
  27976. matchFailed("\"[\"");
  27977. }
  27978. }
  27979. if (result0 !== null) {
  27980. result1 = parse__();
  27981. if (result1 !== null) {
  27982. result2 = parse_attrValue();
  27983. if (result2 !== null) {
  27984. result3 = parse__();
  27985. if (result3 !== null) {
  27986. if (input.charCodeAt(pos) === 93) {
  27987. result4 = "]";
  27988. pos++;
  27989. } else {
  27990. result4 = null;
  27991. if (reportFailures === 0) {
  27992. matchFailed("\"]\"");
  27993. }
  27994. }
  27995. if (result4 !== null) {
  27996. result0 = [result0, result1, result2, result3, result4];
  27997. } else {
  27998. result0 = null;
  27999. pos = pos1;
  28000. }
  28001. } else {
  28002. result0 = null;
  28003. pos = pos1;
  28004. }
  28005. } else {
  28006. result0 = null;
  28007. pos = pos1;
  28008. }
  28009. } else {
  28010. result0 = null;
  28011. pos = pos1;
  28012. }
  28013. } else {
  28014. result0 = null;
  28015. pos = pos1;
  28016. }
  28017. if (result0 !== null) {
  28018. result0 = function (offset, v) {
  28019. return v;
  28020. }(pos0, result0[2]);
  28021. }
  28022. if (result0 === null) {
  28023. pos = pos0;
  28024. }
  28025. cache[cacheKey] = {
  28026. nextPos: pos,
  28027. result: result0
  28028. };
  28029. return result0;
  28030. }
  28031. function parse_attrOps() {
  28032. var cacheKey = "attrOps@" + pos;
  28033. var cachedResult = cache[cacheKey];
  28034. if (cachedResult) {
  28035. pos = cachedResult.nextPos;
  28036. return cachedResult.result;
  28037. }
  28038. var result0, result1;
  28039. var pos0, pos1;
  28040. pos0 = pos;
  28041. pos1 = pos;
  28042. if (/^[><!]/.test(input.charAt(pos))) {
  28043. result0 = input.charAt(pos);
  28044. pos++;
  28045. } else {
  28046. result0 = null;
  28047. if (reportFailures === 0) {
  28048. matchFailed("[><!]");
  28049. }
  28050. }
  28051. result0 = result0 !== null ? result0 : "";
  28052. if (result0 !== null) {
  28053. if (input.charCodeAt(pos) === 61) {
  28054. result1 = "=";
  28055. pos++;
  28056. } else {
  28057. result1 = null;
  28058. if (reportFailures === 0) {
  28059. matchFailed("\"=\"");
  28060. }
  28061. }
  28062. if (result1 !== null) {
  28063. result0 = [result0, result1];
  28064. } else {
  28065. result0 = null;
  28066. pos = pos1;
  28067. }
  28068. } else {
  28069. result0 = null;
  28070. pos = pos1;
  28071. }
  28072. if (result0 !== null) {
  28073. result0 = function (offset, a) {
  28074. return a + '=';
  28075. }(pos0, result0[0]);
  28076. }
  28077. if (result0 === null) {
  28078. pos = pos0;
  28079. }
  28080. if (result0 === null) {
  28081. if (/^[><]/.test(input.charAt(pos))) {
  28082. result0 = input.charAt(pos);
  28083. pos++;
  28084. } else {
  28085. result0 = null;
  28086. if (reportFailures === 0) {
  28087. matchFailed("[><]");
  28088. }
  28089. }
  28090. }
  28091. cache[cacheKey] = {
  28092. nextPos: pos,
  28093. result: result0
  28094. };
  28095. return result0;
  28096. }
  28097. function parse_attrEqOps() {
  28098. var cacheKey = "attrEqOps@" + pos;
  28099. var cachedResult = cache[cacheKey];
  28100. if (cachedResult) {
  28101. pos = cachedResult.nextPos;
  28102. return cachedResult.result;
  28103. }
  28104. var result0, result1;
  28105. var pos0, pos1;
  28106. pos0 = pos;
  28107. pos1 = pos;
  28108. if (input.charCodeAt(pos) === 33) {
  28109. result0 = "!";
  28110. pos++;
  28111. } else {
  28112. result0 = null;
  28113. if (reportFailures === 0) {
  28114. matchFailed("\"!\"");
  28115. }
  28116. }
  28117. result0 = result0 !== null ? result0 : "";
  28118. if (result0 !== null) {
  28119. if (input.charCodeAt(pos) === 61) {
  28120. result1 = "=";
  28121. pos++;
  28122. } else {
  28123. result1 = null;
  28124. if (reportFailures === 0) {
  28125. matchFailed("\"=\"");
  28126. }
  28127. }
  28128. if (result1 !== null) {
  28129. result0 = [result0, result1];
  28130. } else {
  28131. result0 = null;
  28132. pos = pos1;
  28133. }
  28134. } else {
  28135. result0 = null;
  28136. pos = pos1;
  28137. }
  28138. if (result0 !== null) {
  28139. result0 = function (offset, a) {
  28140. return a + '=';
  28141. }(pos0, result0[0]);
  28142. }
  28143. if (result0 === null) {
  28144. pos = pos0;
  28145. }
  28146. cache[cacheKey] = {
  28147. nextPos: pos,
  28148. result: result0
  28149. };
  28150. return result0;
  28151. }
  28152. function parse_attrName() {
  28153. var cacheKey = "attrName@" + pos;
  28154. var cachedResult = cache[cacheKey];
  28155. if (cachedResult) {
  28156. pos = cachedResult.nextPos;
  28157. return cachedResult.result;
  28158. }
  28159. var result0, result1;
  28160. var pos0;
  28161. pos0 = pos;
  28162. result1 = parse_identifierName();
  28163. if (result1 === null) {
  28164. if (input.charCodeAt(pos) === 46) {
  28165. result1 = ".";
  28166. pos++;
  28167. } else {
  28168. result1 = null;
  28169. if (reportFailures === 0) {
  28170. matchFailed("\".\"");
  28171. }
  28172. }
  28173. }
  28174. if (result1 !== null) {
  28175. result0 = [];
  28176. while (result1 !== null) {
  28177. result0.push(result1);
  28178. result1 = parse_identifierName();
  28179. if (result1 === null) {
  28180. if (input.charCodeAt(pos) === 46) {
  28181. result1 = ".";
  28182. pos++;
  28183. } else {
  28184. result1 = null;
  28185. if (reportFailures === 0) {
  28186. matchFailed("\".\"");
  28187. }
  28188. }
  28189. }
  28190. }
  28191. } else {
  28192. result0 = null;
  28193. }
  28194. if (result0 !== null) {
  28195. result0 = function (offset, i) {
  28196. return i.join('');
  28197. }(pos0, result0);
  28198. }
  28199. if (result0 === null) {
  28200. pos = pos0;
  28201. }
  28202. cache[cacheKey] = {
  28203. nextPos: pos,
  28204. result: result0
  28205. };
  28206. return result0;
  28207. }
  28208. function parse_attrValue() {
  28209. var cacheKey = "attrValue@" + pos;
  28210. var cachedResult = cache[cacheKey];
  28211. if (cachedResult) {
  28212. pos = cachedResult.nextPos;
  28213. return cachedResult.result;
  28214. }
  28215. var result0, result1, result2, result3, result4;
  28216. var pos0, pos1;
  28217. pos0 = pos;
  28218. pos1 = pos;
  28219. result0 = parse_attrName();
  28220. if (result0 !== null) {
  28221. result1 = parse__();
  28222. if (result1 !== null) {
  28223. result2 = parse_attrEqOps();
  28224. if (result2 !== null) {
  28225. result3 = parse__();
  28226. if (result3 !== null) {
  28227. result4 = parse_type();
  28228. if (result4 === null) {
  28229. result4 = parse_regex();
  28230. }
  28231. if (result4 !== null) {
  28232. result0 = [result0, result1, result2, result3, result4];
  28233. } else {
  28234. result0 = null;
  28235. pos = pos1;
  28236. }
  28237. } else {
  28238. result0 = null;
  28239. pos = pos1;
  28240. }
  28241. } else {
  28242. result0 = null;
  28243. pos = pos1;
  28244. }
  28245. } else {
  28246. result0 = null;
  28247. pos = pos1;
  28248. }
  28249. } else {
  28250. result0 = null;
  28251. pos = pos1;
  28252. }
  28253. if (result0 !== null) {
  28254. result0 = function (offset, name, op, value) {
  28255. return { type: 'attribute', name: name, operator: op, value: value };
  28256. }(pos0, result0[0], result0[2], result0[4]);
  28257. }
  28258. if (result0 === null) {
  28259. pos = pos0;
  28260. }
  28261. if (result0 === null) {
  28262. pos0 = pos;
  28263. pos1 = pos;
  28264. result0 = parse_attrName();
  28265. if (result0 !== null) {
  28266. result1 = parse__();
  28267. if (result1 !== null) {
  28268. result2 = parse_attrOps();
  28269. if (result2 !== null) {
  28270. result3 = parse__();
  28271. if (result3 !== null) {
  28272. result4 = parse_string();
  28273. if (result4 === null) {
  28274. result4 = parse_number();
  28275. if (result4 === null) {
  28276. result4 = parse_path();
  28277. }
  28278. }
  28279. if (result4 !== null) {
  28280. result0 = [result0, result1, result2, result3, result4];
  28281. } else {
  28282. result0 = null;
  28283. pos = pos1;
  28284. }
  28285. } else {
  28286. result0 = null;
  28287. pos = pos1;
  28288. }
  28289. } else {
  28290. result0 = null;
  28291. pos = pos1;
  28292. }
  28293. } else {
  28294. result0 = null;
  28295. pos = pos1;
  28296. }
  28297. } else {
  28298. result0 = null;
  28299. pos = pos1;
  28300. }
  28301. if (result0 !== null) {
  28302. result0 = function (offset, name, op, value) {
  28303. return { type: 'attribute', name: name, operator: op, value: value };
  28304. }(pos0, result0[0], result0[2], result0[4]);
  28305. }
  28306. if (result0 === null) {
  28307. pos = pos0;
  28308. }
  28309. if (result0 === null) {
  28310. pos0 = pos;
  28311. result0 = parse_attrName();
  28312. if (result0 !== null) {
  28313. result0 = function (offset, name) {
  28314. return { type: 'attribute', name: name };
  28315. }(pos0, result0);
  28316. }
  28317. if (result0 === null) {
  28318. pos = pos0;
  28319. }
  28320. }
  28321. }
  28322. cache[cacheKey] = {
  28323. nextPos: pos,
  28324. result: result0
  28325. };
  28326. return result0;
  28327. }
  28328. function parse_string() {
  28329. var cacheKey = "string@" + pos;
  28330. var cachedResult = cache[cacheKey];
  28331. if (cachedResult) {
  28332. pos = cachedResult.nextPos;
  28333. return cachedResult.result;
  28334. }
  28335. var result0, result1, result2, result3;
  28336. var pos0, pos1, pos2, pos3;
  28337. pos0 = pos;
  28338. pos1 = pos;
  28339. if (input.charCodeAt(pos) === 34) {
  28340. result0 = "\"";
  28341. pos++;
  28342. } else {
  28343. result0 = null;
  28344. if (reportFailures === 0) {
  28345. matchFailed("\"\\\"\"");
  28346. }
  28347. }
  28348. if (result0 !== null) {
  28349. result1 = [];
  28350. if (/^[^\\"]/.test(input.charAt(pos))) {
  28351. result2 = input.charAt(pos);
  28352. pos++;
  28353. } else {
  28354. result2 = null;
  28355. if (reportFailures === 0) {
  28356. matchFailed("[^\\\\\"]");
  28357. }
  28358. }
  28359. if (result2 === null) {
  28360. pos2 = pos;
  28361. pos3 = pos;
  28362. if (input.charCodeAt(pos) === 92) {
  28363. result2 = "\\";
  28364. pos++;
  28365. } else {
  28366. result2 = null;
  28367. if (reportFailures === 0) {
  28368. matchFailed("\"\\\\\"");
  28369. }
  28370. }
  28371. if (result2 !== null) {
  28372. if (input.length > pos) {
  28373. result3 = input.charAt(pos);
  28374. pos++;
  28375. } else {
  28376. result3 = null;
  28377. if (reportFailures === 0) {
  28378. matchFailed("any character");
  28379. }
  28380. }
  28381. if (result3 !== null) {
  28382. result2 = [result2, result3];
  28383. } else {
  28384. result2 = null;
  28385. pos = pos3;
  28386. }
  28387. } else {
  28388. result2 = null;
  28389. pos = pos3;
  28390. }
  28391. if (result2 !== null) {
  28392. result2 = function (offset, a, b) {
  28393. return a + b;
  28394. }(pos2, result2[0], result2[1]);
  28395. }
  28396. if (result2 === null) {
  28397. pos = pos2;
  28398. }
  28399. }
  28400. while (result2 !== null) {
  28401. result1.push(result2);
  28402. if (/^[^\\"]/.test(input.charAt(pos))) {
  28403. result2 = input.charAt(pos);
  28404. pos++;
  28405. } else {
  28406. result2 = null;
  28407. if (reportFailures === 0) {
  28408. matchFailed("[^\\\\\"]");
  28409. }
  28410. }
  28411. if (result2 === null) {
  28412. pos2 = pos;
  28413. pos3 = pos;
  28414. if (input.charCodeAt(pos) === 92) {
  28415. result2 = "\\";
  28416. pos++;
  28417. } else {
  28418. result2 = null;
  28419. if (reportFailures === 0) {
  28420. matchFailed("\"\\\\\"");
  28421. }
  28422. }
  28423. if (result2 !== null) {
  28424. if (input.length > pos) {
  28425. result3 = input.charAt(pos);
  28426. pos++;
  28427. } else {
  28428. result3 = null;
  28429. if (reportFailures === 0) {
  28430. matchFailed("any character");
  28431. }
  28432. }
  28433. if (result3 !== null) {
  28434. result2 = [result2, result3];
  28435. } else {
  28436. result2 = null;
  28437. pos = pos3;
  28438. }
  28439. } else {
  28440. result2 = null;
  28441. pos = pos3;
  28442. }
  28443. if (result2 !== null) {
  28444. result2 = function (offset, a, b) {
  28445. return a + b;
  28446. }(pos2, result2[0], result2[1]);
  28447. }
  28448. if (result2 === null) {
  28449. pos = pos2;
  28450. }
  28451. }
  28452. }
  28453. if (result1 !== null) {
  28454. if (input.charCodeAt(pos) === 34) {
  28455. result2 = "\"";
  28456. pos++;
  28457. } else {
  28458. result2 = null;
  28459. if (reportFailures === 0) {
  28460. matchFailed("\"\\\"\"");
  28461. }
  28462. }
  28463. if (result2 !== null) {
  28464. result0 = [result0, result1, result2];
  28465. } else {
  28466. result0 = null;
  28467. pos = pos1;
  28468. }
  28469. } else {
  28470. result0 = null;
  28471. pos = pos1;
  28472. }
  28473. } else {
  28474. result0 = null;
  28475. pos = pos1;
  28476. }
  28477. if (result0 !== null) {
  28478. result0 = function (offset, d) {
  28479. return { type: 'literal', value: strUnescape(d.join('')) };
  28480. }(pos0, result0[1]);
  28481. }
  28482. if (result0 === null) {
  28483. pos = pos0;
  28484. }
  28485. if (result0 === null) {
  28486. pos0 = pos;
  28487. pos1 = pos;
  28488. if (input.charCodeAt(pos) === 39) {
  28489. result0 = "'";
  28490. pos++;
  28491. } else {
  28492. result0 = null;
  28493. if (reportFailures === 0) {
  28494. matchFailed("\"'\"");
  28495. }
  28496. }
  28497. if (result0 !== null) {
  28498. result1 = [];
  28499. if (/^[^\\']/.test(input.charAt(pos))) {
  28500. result2 = input.charAt(pos);
  28501. pos++;
  28502. } else {
  28503. result2 = null;
  28504. if (reportFailures === 0) {
  28505. matchFailed("[^\\\\']");
  28506. }
  28507. }
  28508. if (result2 === null) {
  28509. pos2 = pos;
  28510. pos3 = pos;
  28511. if (input.charCodeAt(pos) === 92) {
  28512. result2 = "\\";
  28513. pos++;
  28514. } else {
  28515. result2 = null;
  28516. if (reportFailures === 0) {
  28517. matchFailed("\"\\\\\"");
  28518. }
  28519. }
  28520. if (result2 !== null) {
  28521. if (input.length > pos) {
  28522. result3 = input.charAt(pos);
  28523. pos++;
  28524. } else {
  28525. result3 = null;
  28526. if (reportFailures === 0) {
  28527. matchFailed("any character");
  28528. }
  28529. }
  28530. if (result3 !== null) {
  28531. result2 = [result2, result3];
  28532. } else {
  28533. result2 = null;
  28534. pos = pos3;
  28535. }
  28536. } else {
  28537. result2 = null;
  28538. pos = pos3;
  28539. }
  28540. if (result2 !== null) {
  28541. result2 = function (offset, a, b) {
  28542. return a + b;
  28543. }(pos2, result2[0], result2[1]);
  28544. }
  28545. if (result2 === null) {
  28546. pos = pos2;
  28547. }
  28548. }
  28549. while (result2 !== null) {
  28550. result1.push(result2);
  28551. if (/^[^\\']/.test(input.charAt(pos))) {
  28552. result2 = input.charAt(pos);
  28553. pos++;
  28554. } else {
  28555. result2 = null;
  28556. if (reportFailures === 0) {
  28557. matchFailed("[^\\\\']");
  28558. }
  28559. }
  28560. if (result2 === null) {
  28561. pos2 = pos;
  28562. pos3 = pos;
  28563. if (input.charCodeAt(pos) === 92) {
  28564. result2 = "\\";
  28565. pos++;
  28566. } else {
  28567. result2 = null;
  28568. if (reportFailures === 0) {
  28569. matchFailed("\"\\\\\"");
  28570. }
  28571. }
  28572. if (result2 !== null) {
  28573. if (input.length > pos) {
  28574. result3 = input.charAt(pos);
  28575. pos++;
  28576. } else {
  28577. result3 = null;
  28578. if (reportFailures === 0) {
  28579. matchFailed("any character");
  28580. }
  28581. }
  28582. if (result3 !== null) {
  28583. result2 = [result2, result3];
  28584. } else {
  28585. result2 = null;
  28586. pos = pos3;
  28587. }
  28588. } else {
  28589. result2 = null;
  28590. pos = pos3;
  28591. }
  28592. if (result2 !== null) {
  28593. result2 = function (offset, a, b) {
  28594. return a + b;
  28595. }(pos2, result2[0], result2[1]);
  28596. }
  28597. if (result2 === null) {
  28598. pos = pos2;
  28599. }
  28600. }
  28601. }
  28602. if (result1 !== null) {
  28603. if (input.charCodeAt(pos) === 39) {
  28604. result2 = "'";
  28605. pos++;
  28606. } else {
  28607. result2 = null;
  28608. if (reportFailures === 0) {
  28609. matchFailed("\"'\"");
  28610. }
  28611. }
  28612. if (result2 !== null) {
  28613. result0 = [result0, result1, result2];
  28614. } else {
  28615. result0 = null;
  28616. pos = pos1;
  28617. }
  28618. } else {
  28619. result0 = null;
  28620. pos = pos1;
  28621. }
  28622. } else {
  28623. result0 = null;
  28624. pos = pos1;
  28625. }
  28626. if (result0 !== null) {
  28627. result0 = function (offset, d) {
  28628. return { type: 'literal', value: strUnescape(d.join('')) };
  28629. }(pos0, result0[1]);
  28630. }
  28631. if (result0 === null) {
  28632. pos = pos0;
  28633. }
  28634. }
  28635. cache[cacheKey] = {
  28636. nextPos: pos,
  28637. result: result0
  28638. };
  28639. return result0;
  28640. }
  28641. function parse_number() {
  28642. var cacheKey = "number@" + pos;
  28643. var cachedResult = cache[cacheKey];
  28644. if (cachedResult) {
  28645. pos = cachedResult.nextPos;
  28646. return cachedResult.result;
  28647. }
  28648. var result0, result1, result2;
  28649. var pos0, pos1, pos2;
  28650. pos0 = pos;
  28651. pos1 = pos;
  28652. pos2 = pos;
  28653. result0 = [];
  28654. if (/^[0-9]/.test(input.charAt(pos))) {
  28655. result1 = input.charAt(pos);
  28656. pos++;
  28657. } else {
  28658. result1 = null;
  28659. if (reportFailures === 0) {
  28660. matchFailed("[0-9]");
  28661. }
  28662. }
  28663. while (result1 !== null) {
  28664. result0.push(result1);
  28665. if (/^[0-9]/.test(input.charAt(pos))) {
  28666. result1 = input.charAt(pos);
  28667. pos++;
  28668. } else {
  28669. result1 = null;
  28670. if (reportFailures === 0) {
  28671. matchFailed("[0-9]");
  28672. }
  28673. }
  28674. }
  28675. if (result0 !== null) {
  28676. if (input.charCodeAt(pos) === 46) {
  28677. result1 = ".";
  28678. pos++;
  28679. } else {
  28680. result1 = null;
  28681. if (reportFailures === 0) {
  28682. matchFailed("\".\"");
  28683. }
  28684. }
  28685. if (result1 !== null) {
  28686. result0 = [result0, result1];
  28687. } else {
  28688. result0 = null;
  28689. pos = pos2;
  28690. }
  28691. } else {
  28692. result0 = null;
  28693. pos = pos2;
  28694. }
  28695. result0 = result0 !== null ? result0 : "";
  28696. if (result0 !== null) {
  28697. if (/^[0-9]/.test(input.charAt(pos))) {
  28698. result2 = input.charAt(pos);
  28699. pos++;
  28700. } else {
  28701. result2 = null;
  28702. if (reportFailures === 0) {
  28703. matchFailed("[0-9]");
  28704. }
  28705. }
  28706. if (result2 !== null) {
  28707. result1 = [];
  28708. while (result2 !== null) {
  28709. result1.push(result2);
  28710. if (/^[0-9]/.test(input.charAt(pos))) {
  28711. result2 = input.charAt(pos);
  28712. pos++;
  28713. } else {
  28714. result2 = null;
  28715. if (reportFailures === 0) {
  28716. matchFailed("[0-9]");
  28717. }
  28718. }
  28719. }
  28720. } else {
  28721. result1 = null;
  28722. }
  28723. if (result1 !== null) {
  28724. result0 = [result0, result1];
  28725. } else {
  28726. result0 = null;
  28727. pos = pos1;
  28728. }
  28729. } else {
  28730. result0 = null;
  28731. pos = pos1;
  28732. }
  28733. if (result0 !== null) {
  28734. result0 = function (offset, a, b) {
  28735. return { type: 'literal', value: parseFloat((a ? a.join('') : '') + b.join('')) };
  28736. }(pos0, result0[0], result0[1]);
  28737. }
  28738. if (result0 === null) {
  28739. pos = pos0;
  28740. }
  28741. cache[cacheKey] = {
  28742. nextPos: pos,
  28743. result: result0
  28744. };
  28745. return result0;
  28746. }
  28747. function parse_path() {
  28748. var cacheKey = "path@" + pos;
  28749. var cachedResult = cache[cacheKey];
  28750. if (cachedResult) {
  28751. pos = cachedResult.nextPos;
  28752. return cachedResult.result;
  28753. }
  28754. var result0;
  28755. var pos0;
  28756. pos0 = pos;
  28757. result0 = parse_identifierName();
  28758. if (result0 !== null) {
  28759. result0 = function (offset, i) {
  28760. return { type: 'literal', value: i };
  28761. }(pos0, result0);
  28762. }
  28763. if (result0 === null) {
  28764. pos = pos0;
  28765. }
  28766. cache[cacheKey] = {
  28767. nextPos: pos,
  28768. result: result0
  28769. };
  28770. return result0;
  28771. }
  28772. function parse_type() {
  28773. var cacheKey = "type@" + pos;
  28774. var cachedResult = cache[cacheKey];
  28775. if (cachedResult) {
  28776. pos = cachedResult.nextPos;
  28777. return cachedResult.result;
  28778. }
  28779. var result0, result1, result2, result3, result4;
  28780. var pos0, pos1;
  28781. pos0 = pos;
  28782. pos1 = pos;
  28783. if (input.substr(pos, 5) === "type(") {
  28784. result0 = "type(";
  28785. pos += 5;
  28786. } else {
  28787. result0 = null;
  28788. if (reportFailures === 0) {
  28789. matchFailed("\"type(\"");
  28790. }
  28791. }
  28792. if (result0 !== null) {
  28793. result1 = parse__();
  28794. if (result1 !== null) {
  28795. if (/^[^ )]/.test(input.charAt(pos))) {
  28796. result3 = input.charAt(pos);
  28797. pos++;
  28798. } else {
  28799. result3 = null;
  28800. if (reportFailures === 0) {
  28801. matchFailed("[^ )]");
  28802. }
  28803. }
  28804. if (result3 !== null) {
  28805. result2 = [];
  28806. while (result3 !== null) {
  28807. result2.push(result3);
  28808. if (/^[^ )]/.test(input.charAt(pos))) {
  28809. result3 = input.charAt(pos);
  28810. pos++;
  28811. } else {
  28812. result3 = null;
  28813. if (reportFailures === 0) {
  28814. matchFailed("[^ )]");
  28815. }
  28816. }
  28817. }
  28818. } else {
  28819. result2 = null;
  28820. }
  28821. if (result2 !== null) {
  28822. result3 = parse__();
  28823. if (result3 !== null) {
  28824. if (input.charCodeAt(pos) === 41) {
  28825. result4 = ")";
  28826. pos++;
  28827. } else {
  28828. result4 = null;
  28829. if (reportFailures === 0) {
  28830. matchFailed("\")\"");
  28831. }
  28832. }
  28833. if (result4 !== null) {
  28834. result0 = [result0, result1, result2, result3, result4];
  28835. } else {
  28836. result0 = null;
  28837. pos = pos1;
  28838. }
  28839. } else {
  28840. result0 = null;
  28841. pos = pos1;
  28842. }
  28843. } else {
  28844. result0 = null;
  28845. pos = pos1;
  28846. }
  28847. } else {
  28848. result0 = null;
  28849. pos = pos1;
  28850. }
  28851. } else {
  28852. result0 = null;
  28853. pos = pos1;
  28854. }
  28855. if (result0 !== null) {
  28856. result0 = function (offset, t) {
  28857. return { type: 'type', value: t.join('') };
  28858. }(pos0, result0[2]);
  28859. }
  28860. if (result0 === null) {
  28861. pos = pos0;
  28862. }
  28863. cache[cacheKey] = {
  28864. nextPos: pos,
  28865. result: result0
  28866. };
  28867. return result0;
  28868. }
  28869. function parse_regex() {
  28870. var cacheKey = "regex@" + pos;
  28871. var cachedResult = cache[cacheKey];
  28872. if (cachedResult) {
  28873. pos = cachedResult.nextPos;
  28874. return cachedResult.result;
  28875. }
  28876. var result0, result1, result2;
  28877. var pos0, pos1;
  28878. pos0 = pos;
  28879. pos1 = pos;
  28880. if (input.charCodeAt(pos) === 47) {
  28881. result0 = "/";
  28882. pos++;
  28883. } else {
  28884. result0 = null;
  28885. if (reportFailures === 0) {
  28886. matchFailed("\"/\"");
  28887. }
  28888. }
  28889. if (result0 !== null) {
  28890. if (/^[^\/]/.test(input.charAt(pos))) {
  28891. result2 = input.charAt(pos);
  28892. pos++;
  28893. } else {
  28894. result2 = null;
  28895. if (reportFailures === 0) {
  28896. matchFailed("[^\\/]");
  28897. }
  28898. }
  28899. if (result2 !== null) {
  28900. result1 = [];
  28901. while (result2 !== null) {
  28902. result1.push(result2);
  28903. if (/^[^\/]/.test(input.charAt(pos))) {
  28904. result2 = input.charAt(pos);
  28905. pos++;
  28906. } else {
  28907. result2 = null;
  28908. if (reportFailures === 0) {
  28909. matchFailed("[^\\/]");
  28910. }
  28911. }
  28912. }
  28913. } else {
  28914. result1 = null;
  28915. }
  28916. if (result1 !== null) {
  28917. if (input.charCodeAt(pos) === 47) {
  28918. result2 = "/";
  28919. pos++;
  28920. } else {
  28921. result2 = null;
  28922. if (reportFailures === 0) {
  28923. matchFailed("\"/\"");
  28924. }
  28925. }
  28926. if (result2 !== null) {
  28927. result0 = [result0, result1, result2];
  28928. } else {
  28929. result0 = null;
  28930. pos = pos1;
  28931. }
  28932. } else {
  28933. result0 = null;
  28934. pos = pos1;
  28935. }
  28936. } else {
  28937. result0 = null;
  28938. pos = pos1;
  28939. }
  28940. if (result0 !== null) {
  28941. result0 = function (offset, d) {
  28942. return { type: 'regexp', value: new RegExp(d.join('')) };
  28943. }(pos0, result0[1]);
  28944. }
  28945. if (result0 === null) {
  28946. pos = pos0;
  28947. }
  28948. cache[cacheKey] = {
  28949. nextPos: pos,
  28950. result: result0
  28951. };
  28952. return result0;
  28953. }
  28954. function parse_field() {
  28955. var cacheKey = "field@" + pos;
  28956. var cachedResult = cache[cacheKey];
  28957. if (cachedResult) {
  28958. pos = cachedResult.nextPos;
  28959. return cachedResult.result;
  28960. }
  28961. var result0, result1, result2, result3, result4;
  28962. var pos0, pos1, pos2;
  28963. pos0 = pos;
  28964. pos1 = pos;
  28965. if (input.charCodeAt(pos) === 46) {
  28966. result0 = ".";
  28967. pos++;
  28968. } else {
  28969. result0 = null;
  28970. if (reportFailures === 0) {
  28971. matchFailed("\".\"");
  28972. }
  28973. }
  28974. if (result0 !== null) {
  28975. result1 = parse_identifierName();
  28976. if (result1 !== null) {
  28977. result2 = [];
  28978. pos2 = pos;
  28979. if (input.charCodeAt(pos) === 46) {
  28980. result3 = ".";
  28981. pos++;
  28982. } else {
  28983. result3 = null;
  28984. if (reportFailures === 0) {
  28985. matchFailed("\".\"");
  28986. }
  28987. }
  28988. if (result3 !== null) {
  28989. result4 = parse_identifierName();
  28990. if (result4 !== null) {
  28991. result3 = [result3, result4];
  28992. } else {
  28993. result3 = null;
  28994. pos = pos2;
  28995. }
  28996. } else {
  28997. result3 = null;
  28998. pos = pos2;
  28999. }
  29000. while (result3 !== null) {
  29001. result2.push(result3);
  29002. pos2 = pos;
  29003. if (input.charCodeAt(pos) === 46) {
  29004. result3 = ".";
  29005. pos++;
  29006. } else {
  29007. result3 = null;
  29008. if (reportFailures === 0) {
  29009. matchFailed("\".\"");
  29010. }
  29011. }
  29012. if (result3 !== null) {
  29013. result4 = parse_identifierName();
  29014. if (result4 !== null) {
  29015. result3 = [result3, result4];
  29016. } else {
  29017. result3 = null;
  29018. pos = pos2;
  29019. }
  29020. } else {
  29021. result3 = null;
  29022. pos = pos2;
  29023. }
  29024. }
  29025. if (result2 !== null) {
  29026. result0 = [result0, result1, result2];
  29027. } else {
  29028. result0 = null;
  29029. pos = pos1;
  29030. }
  29031. } else {
  29032. result0 = null;
  29033. pos = pos1;
  29034. }
  29035. } else {
  29036. result0 = null;
  29037. pos = pos1;
  29038. }
  29039. if (result0 !== null) {
  29040. result0 = function (offset, i, is) {
  29041. return { type: 'field', name: is.reduce(function (memo, p) {
  29042. return memo + p[0] + p[1];
  29043. }, i) };
  29044. }(pos0, result0[1], result0[2]);
  29045. }
  29046. if (result0 === null) {
  29047. pos = pos0;
  29048. }
  29049. cache[cacheKey] = {
  29050. nextPos: pos,
  29051. result: result0
  29052. };
  29053. return result0;
  29054. }
  29055. function parse_negation() {
  29056. var cacheKey = "negation@" + pos;
  29057. var cachedResult = cache[cacheKey];
  29058. if (cachedResult) {
  29059. pos = cachedResult.nextPos;
  29060. return cachedResult.result;
  29061. }
  29062. var result0, result1, result2, result3, result4;
  29063. var pos0, pos1;
  29064. pos0 = pos;
  29065. pos1 = pos;
  29066. if (input.substr(pos, 5) === ":not(") {
  29067. result0 = ":not(";
  29068. pos += 5;
  29069. } else {
  29070. result0 = null;
  29071. if (reportFailures === 0) {
  29072. matchFailed("\":not(\"");
  29073. }
  29074. }
  29075. if (result0 !== null) {
  29076. result1 = parse__();
  29077. if (result1 !== null) {
  29078. result2 = parse_selectors();
  29079. if (result2 !== null) {
  29080. result3 = parse__();
  29081. if (result3 !== null) {
  29082. if (input.charCodeAt(pos) === 41) {
  29083. result4 = ")";
  29084. pos++;
  29085. } else {
  29086. result4 = null;
  29087. if (reportFailures === 0) {
  29088. matchFailed("\")\"");
  29089. }
  29090. }
  29091. if (result4 !== null) {
  29092. result0 = [result0, result1, result2, result3, result4];
  29093. } else {
  29094. result0 = null;
  29095. pos = pos1;
  29096. }
  29097. } else {
  29098. result0 = null;
  29099. pos = pos1;
  29100. }
  29101. } else {
  29102. result0 = null;
  29103. pos = pos1;
  29104. }
  29105. } else {
  29106. result0 = null;
  29107. pos = pos1;
  29108. }
  29109. } else {
  29110. result0 = null;
  29111. pos = pos1;
  29112. }
  29113. if (result0 !== null) {
  29114. result0 = function (offset, ss) {
  29115. return { type: 'not', selectors: ss };
  29116. }(pos0, result0[2]);
  29117. }
  29118. if (result0 === null) {
  29119. pos = pos0;
  29120. }
  29121. cache[cacheKey] = {
  29122. nextPos: pos,
  29123. result: result0
  29124. };
  29125. return result0;
  29126. }
  29127. function parse_matches() {
  29128. var cacheKey = "matches@" + pos;
  29129. var cachedResult = cache[cacheKey];
  29130. if (cachedResult) {
  29131. pos = cachedResult.nextPos;
  29132. return cachedResult.result;
  29133. }
  29134. var result0, result1, result2, result3, result4;
  29135. var pos0, pos1;
  29136. pos0 = pos;
  29137. pos1 = pos;
  29138. if (input.substr(pos, 9) === ":matches(") {
  29139. result0 = ":matches(";
  29140. pos += 9;
  29141. } else {
  29142. result0 = null;
  29143. if (reportFailures === 0) {
  29144. matchFailed("\":matches(\"");
  29145. }
  29146. }
  29147. if (result0 !== null) {
  29148. result1 = parse__();
  29149. if (result1 !== null) {
  29150. result2 = parse_selectors();
  29151. if (result2 !== null) {
  29152. result3 = parse__();
  29153. if (result3 !== null) {
  29154. if (input.charCodeAt(pos) === 41) {
  29155. result4 = ")";
  29156. pos++;
  29157. } else {
  29158. result4 = null;
  29159. if (reportFailures === 0) {
  29160. matchFailed("\")\"");
  29161. }
  29162. }
  29163. if (result4 !== null) {
  29164. result0 = [result0, result1, result2, result3, result4];
  29165. } else {
  29166. result0 = null;
  29167. pos = pos1;
  29168. }
  29169. } else {
  29170. result0 = null;
  29171. pos = pos1;
  29172. }
  29173. } else {
  29174. result0 = null;
  29175. pos = pos1;
  29176. }
  29177. } else {
  29178. result0 = null;
  29179. pos = pos1;
  29180. }
  29181. } else {
  29182. result0 = null;
  29183. pos = pos1;
  29184. }
  29185. if (result0 !== null) {
  29186. result0 = function (offset, ss) {
  29187. return { type: 'matches', selectors: ss };
  29188. }(pos0, result0[2]);
  29189. }
  29190. if (result0 === null) {
  29191. pos = pos0;
  29192. }
  29193. cache[cacheKey] = {
  29194. nextPos: pos,
  29195. result: result0
  29196. };
  29197. return result0;
  29198. }
  29199. function parse_has() {
  29200. var cacheKey = "has@" + pos;
  29201. var cachedResult = cache[cacheKey];
  29202. if (cachedResult) {
  29203. pos = cachedResult.nextPos;
  29204. return cachedResult.result;
  29205. }
  29206. var result0, result1, result2, result3, result4;
  29207. var pos0, pos1;
  29208. pos0 = pos;
  29209. pos1 = pos;
  29210. if (input.substr(pos, 5) === ":has(") {
  29211. result0 = ":has(";
  29212. pos += 5;
  29213. } else {
  29214. result0 = null;
  29215. if (reportFailures === 0) {
  29216. matchFailed("\":has(\"");
  29217. }
  29218. }
  29219. if (result0 !== null) {
  29220. result1 = parse__();
  29221. if (result1 !== null) {
  29222. result2 = parse_selectors();
  29223. if (result2 !== null) {
  29224. result3 = parse__();
  29225. if (result3 !== null) {
  29226. if (input.charCodeAt(pos) === 41) {
  29227. result4 = ")";
  29228. pos++;
  29229. } else {
  29230. result4 = null;
  29231. if (reportFailures === 0) {
  29232. matchFailed("\")\"");
  29233. }
  29234. }
  29235. if (result4 !== null) {
  29236. result0 = [result0, result1, result2, result3, result4];
  29237. } else {
  29238. result0 = null;
  29239. pos = pos1;
  29240. }
  29241. } else {
  29242. result0 = null;
  29243. pos = pos1;
  29244. }
  29245. } else {
  29246. result0 = null;
  29247. pos = pos1;
  29248. }
  29249. } else {
  29250. result0 = null;
  29251. pos = pos1;
  29252. }
  29253. } else {
  29254. result0 = null;
  29255. pos = pos1;
  29256. }
  29257. if (result0 !== null) {
  29258. result0 = function (offset, ss) {
  29259. return { type: 'has', selectors: ss };
  29260. }(pos0, result0[2]);
  29261. }
  29262. if (result0 === null) {
  29263. pos = pos0;
  29264. }
  29265. cache[cacheKey] = {
  29266. nextPos: pos,
  29267. result: result0
  29268. };
  29269. return result0;
  29270. }
  29271. function parse_firstChild() {
  29272. var cacheKey = "firstChild@" + pos;
  29273. var cachedResult = cache[cacheKey];
  29274. if (cachedResult) {
  29275. pos = cachedResult.nextPos;
  29276. return cachedResult.result;
  29277. }
  29278. var result0;
  29279. var pos0;
  29280. pos0 = pos;
  29281. if (input.substr(pos, 12) === ":first-child") {
  29282. result0 = ":first-child";
  29283. pos += 12;
  29284. } else {
  29285. result0 = null;
  29286. if (reportFailures === 0) {
  29287. matchFailed("\":first-child\"");
  29288. }
  29289. }
  29290. if (result0 !== null) {
  29291. result0 = function (offset) {
  29292. return nth(1);
  29293. }(pos0);
  29294. }
  29295. if (result0 === null) {
  29296. pos = pos0;
  29297. }
  29298. cache[cacheKey] = {
  29299. nextPos: pos,
  29300. result: result0
  29301. };
  29302. return result0;
  29303. }
  29304. function parse_lastChild() {
  29305. var cacheKey = "lastChild@" + pos;
  29306. var cachedResult = cache[cacheKey];
  29307. if (cachedResult) {
  29308. pos = cachedResult.nextPos;
  29309. return cachedResult.result;
  29310. }
  29311. var result0;
  29312. var pos0;
  29313. pos0 = pos;
  29314. if (input.substr(pos, 11) === ":last-child") {
  29315. result0 = ":last-child";
  29316. pos += 11;
  29317. } else {
  29318. result0 = null;
  29319. if (reportFailures === 0) {
  29320. matchFailed("\":last-child\"");
  29321. }
  29322. }
  29323. if (result0 !== null) {
  29324. result0 = function (offset) {
  29325. return nthLast(1);
  29326. }(pos0);
  29327. }
  29328. if (result0 === null) {
  29329. pos = pos0;
  29330. }
  29331. cache[cacheKey] = {
  29332. nextPos: pos,
  29333. result: result0
  29334. };
  29335. return result0;
  29336. }
  29337. function parse_nthChild() {
  29338. var cacheKey = "nthChild@" + pos;
  29339. var cachedResult = cache[cacheKey];
  29340. if (cachedResult) {
  29341. pos = cachedResult.nextPos;
  29342. return cachedResult.result;
  29343. }
  29344. var result0, result1, result2, result3, result4;
  29345. var pos0, pos1;
  29346. pos0 = pos;
  29347. pos1 = pos;
  29348. if (input.substr(pos, 11) === ":nth-child(") {
  29349. result0 = ":nth-child(";
  29350. pos += 11;
  29351. } else {
  29352. result0 = null;
  29353. if (reportFailures === 0) {
  29354. matchFailed("\":nth-child(\"");
  29355. }
  29356. }
  29357. if (result0 !== null) {
  29358. result1 = parse__();
  29359. if (result1 !== null) {
  29360. if (/^[0-9]/.test(input.charAt(pos))) {
  29361. result3 = input.charAt(pos);
  29362. pos++;
  29363. } else {
  29364. result3 = null;
  29365. if (reportFailures === 0) {
  29366. matchFailed("[0-9]");
  29367. }
  29368. }
  29369. if (result3 !== null) {
  29370. result2 = [];
  29371. while (result3 !== null) {
  29372. result2.push(result3);
  29373. if (/^[0-9]/.test(input.charAt(pos))) {
  29374. result3 = input.charAt(pos);
  29375. pos++;
  29376. } else {
  29377. result3 = null;
  29378. if (reportFailures === 0) {
  29379. matchFailed("[0-9]");
  29380. }
  29381. }
  29382. }
  29383. } else {
  29384. result2 = null;
  29385. }
  29386. if (result2 !== null) {
  29387. result3 = parse__();
  29388. if (result3 !== null) {
  29389. if (input.charCodeAt(pos) === 41) {
  29390. result4 = ")";
  29391. pos++;
  29392. } else {
  29393. result4 = null;
  29394. if (reportFailures === 0) {
  29395. matchFailed("\")\"");
  29396. }
  29397. }
  29398. if (result4 !== null) {
  29399. result0 = [result0, result1, result2, result3, result4];
  29400. } else {
  29401. result0 = null;
  29402. pos = pos1;
  29403. }
  29404. } else {
  29405. result0 = null;
  29406. pos = pos1;
  29407. }
  29408. } else {
  29409. result0 = null;
  29410. pos = pos1;
  29411. }
  29412. } else {
  29413. result0 = null;
  29414. pos = pos1;
  29415. }
  29416. } else {
  29417. result0 = null;
  29418. pos = pos1;
  29419. }
  29420. if (result0 !== null) {
  29421. result0 = function (offset, n) {
  29422. return nth(parseInt(n.join(''), 10));
  29423. }(pos0, result0[2]);
  29424. }
  29425. if (result0 === null) {
  29426. pos = pos0;
  29427. }
  29428. cache[cacheKey] = {
  29429. nextPos: pos,
  29430. result: result0
  29431. };
  29432. return result0;
  29433. }
  29434. function parse_nthLastChild() {
  29435. var cacheKey = "nthLastChild@" + pos;
  29436. var cachedResult = cache[cacheKey];
  29437. if (cachedResult) {
  29438. pos = cachedResult.nextPos;
  29439. return cachedResult.result;
  29440. }
  29441. var result0, result1, result2, result3, result4;
  29442. var pos0, pos1;
  29443. pos0 = pos;
  29444. pos1 = pos;
  29445. if (input.substr(pos, 16) === ":nth-last-child(") {
  29446. result0 = ":nth-last-child(";
  29447. pos += 16;
  29448. } else {
  29449. result0 = null;
  29450. if (reportFailures === 0) {
  29451. matchFailed("\":nth-last-child(\"");
  29452. }
  29453. }
  29454. if (result0 !== null) {
  29455. result1 = parse__();
  29456. if (result1 !== null) {
  29457. if (/^[0-9]/.test(input.charAt(pos))) {
  29458. result3 = input.charAt(pos);
  29459. pos++;
  29460. } else {
  29461. result3 = null;
  29462. if (reportFailures === 0) {
  29463. matchFailed("[0-9]");
  29464. }
  29465. }
  29466. if (result3 !== null) {
  29467. result2 = [];
  29468. while (result3 !== null) {
  29469. result2.push(result3);
  29470. if (/^[0-9]/.test(input.charAt(pos))) {
  29471. result3 = input.charAt(pos);
  29472. pos++;
  29473. } else {
  29474. result3 = null;
  29475. if (reportFailures === 0) {
  29476. matchFailed("[0-9]");
  29477. }
  29478. }
  29479. }
  29480. } else {
  29481. result2 = null;
  29482. }
  29483. if (result2 !== null) {
  29484. result3 = parse__();
  29485. if (result3 !== null) {
  29486. if (input.charCodeAt(pos) === 41) {
  29487. result4 = ")";
  29488. pos++;
  29489. } else {
  29490. result4 = null;
  29491. if (reportFailures === 0) {
  29492. matchFailed("\")\"");
  29493. }
  29494. }
  29495. if (result4 !== null) {
  29496. result0 = [result0, result1, result2, result3, result4];
  29497. } else {
  29498. result0 = null;
  29499. pos = pos1;
  29500. }
  29501. } else {
  29502. result0 = null;
  29503. pos = pos1;
  29504. }
  29505. } else {
  29506. result0 = null;
  29507. pos = pos1;
  29508. }
  29509. } else {
  29510. result0 = null;
  29511. pos = pos1;
  29512. }
  29513. } else {
  29514. result0 = null;
  29515. pos = pos1;
  29516. }
  29517. if (result0 !== null) {
  29518. result0 = function (offset, n) {
  29519. return nthLast(parseInt(n.join(''), 10));
  29520. }(pos0, result0[2]);
  29521. }
  29522. if (result0 === null) {
  29523. pos = pos0;
  29524. }
  29525. cache[cacheKey] = {
  29526. nextPos: pos,
  29527. result: result0
  29528. };
  29529. return result0;
  29530. }
  29531. function parse_class() {
  29532. var cacheKey = "class@" + pos;
  29533. var cachedResult = cache[cacheKey];
  29534. if (cachedResult) {
  29535. pos = cachedResult.nextPos;
  29536. return cachedResult.result;
  29537. }
  29538. var result0, result1;
  29539. var pos0, pos1;
  29540. pos0 = pos;
  29541. pos1 = pos;
  29542. if (input.charCodeAt(pos) === 58) {
  29543. result0 = ":";
  29544. pos++;
  29545. } else {
  29546. result0 = null;
  29547. if (reportFailures === 0) {
  29548. matchFailed("\":\"");
  29549. }
  29550. }
  29551. if (result0 !== null) {
  29552. if (input.substr(pos, 9).toLowerCase() === "statement") {
  29553. result1 = input.substr(pos, 9);
  29554. pos += 9;
  29555. } else {
  29556. result1 = null;
  29557. if (reportFailures === 0) {
  29558. matchFailed("\"statement\"");
  29559. }
  29560. }
  29561. if (result1 === null) {
  29562. if (input.substr(pos, 10).toLowerCase() === "expression") {
  29563. result1 = input.substr(pos, 10);
  29564. pos += 10;
  29565. } else {
  29566. result1 = null;
  29567. if (reportFailures === 0) {
  29568. matchFailed("\"expression\"");
  29569. }
  29570. }
  29571. if (result1 === null) {
  29572. if (input.substr(pos, 11).toLowerCase() === "declaration") {
  29573. result1 = input.substr(pos, 11);
  29574. pos += 11;
  29575. } else {
  29576. result1 = null;
  29577. if (reportFailures === 0) {
  29578. matchFailed("\"declaration\"");
  29579. }
  29580. }
  29581. if (result1 === null) {
  29582. if (input.substr(pos, 8).toLowerCase() === "function") {
  29583. result1 = input.substr(pos, 8);
  29584. pos += 8;
  29585. } else {
  29586. result1 = null;
  29587. if (reportFailures === 0) {
  29588. matchFailed("\"function\"");
  29589. }
  29590. }
  29591. if (result1 === null) {
  29592. if (input.substr(pos, 7).toLowerCase() === "pattern") {
  29593. result1 = input.substr(pos, 7);
  29594. pos += 7;
  29595. } else {
  29596. result1 = null;
  29597. if (reportFailures === 0) {
  29598. matchFailed("\"pattern\"");
  29599. }
  29600. }
  29601. }
  29602. }
  29603. }
  29604. }
  29605. if (result1 !== null) {
  29606. result0 = [result0, result1];
  29607. } else {
  29608. result0 = null;
  29609. pos = pos1;
  29610. }
  29611. } else {
  29612. result0 = null;
  29613. pos = pos1;
  29614. }
  29615. if (result0 !== null) {
  29616. result0 = function (offset, c) {
  29617. return { type: 'class', name: c };
  29618. }(pos0, result0[1]);
  29619. }
  29620. if (result0 === null) {
  29621. pos = pos0;
  29622. }
  29623. cache[cacheKey] = {
  29624. nextPos: pos,
  29625. result: result0
  29626. };
  29627. return result0;
  29628. }
  29629. function cleanupExpected(expected) {
  29630. expected.sort();
  29631. var lastExpected = null;
  29632. var cleanExpected = [];
  29633. for (var i = 0; i < expected.length; i++) {
  29634. if (expected[i] !== lastExpected) {
  29635. cleanExpected.push(expected[i]);
  29636. lastExpected = expected[i];
  29637. }
  29638. }
  29639. return cleanExpected;
  29640. }
  29641. function computeErrorPosition() {
  29642. /*
  29643. * The first idea was to use |String.split| to break the input up to the
  29644. * error position along newlines and derive the line and column from
  29645. * there. However IE's |split| implementation is so broken that it was
  29646. * enough to prevent it.
  29647. */
  29648. var line = 1;
  29649. var column = 1;
  29650. var seenCR = false;
  29651. for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {
  29652. var ch = input.charAt(i);
  29653. if (ch === "\n") {
  29654. if (!seenCR) {
  29655. line++;
  29656. }
  29657. column = 1;
  29658. seenCR = false;
  29659. } else if (ch === "\r" || ch === '\u2028' || ch === '\u2029') {
  29660. line++;
  29661. column = 1;
  29662. seenCR = true;
  29663. } else {
  29664. column++;
  29665. seenCR = false;
  29666. }
  29667. }
  29668. return { line: line, column: column };
  29669. }
  29670. function nth(n) {
  29671. return { type: 'nth-child', index: { type: 'literal', value: n } };
  29672. }
  29673. function nthLast(n) {
  29674. return { type: 'nth-last-child', index: { type: 'literal', value: n } };
  29675. }
  29676. function strUnescape(s) {
  29677. return s.replace(/\\(.)/g, function (match, ch) {
  29678. switch (ch) {
  29679. case 'a':
  29680. return '\a';
  29681. case 'b':
  29682. return '\b';
  29683. case 'f':
  29684. return '\f';
  29685. case 'n':
  29686. return '\n';
  29687. case 'r':
  29688. return '\r';
  29689. case 't':
  29690. return '\t';
  29691. case 'v':
  29692. return '\v';
  29693. default:
  29694. return ch;
  29695. }
  29696. });
  29697. }
  29698. var result = parseFunctions[startRule]();
  29699. /*
  29700. * The parser is now in one of the following three states:
  29701. *
  29702. * 1. The parser successfully parsed the whole input.
  29703. *
  29704. * - |result !== null|
  29705. * - |pos === input.length|
  29706. * - |rightmostFailuresExpected| may or may not contain something
  29707. *
  29708. * 2. The parser successfully parsed only a part of the input.
  29709. *
  29710. * - |result !== null|
  29711. * - |pos < input.length|
  29712. * - |rightmostFailuresExpected| may or may not contain something
  29713. *
  29714. * 3. The parser did not successfully parse any part of the input.
  29715. *
  29716. * - |result === null|
  29717. * - |pos === 0|
  29718. * - |rightmostFailuresExpected| contains at least one failure
  29719. *
  29720. * All code following this comment (including called functions) must
  29721. * handle these states.
  29722. */
  29723. if (result === null || pos !== input.length) {
  29724. var offset = Math.max(pos, rightmostFailuresPos);
  29725. var found = offset < input.length ? input.charAt(offset) : null;
  29726. var errorPosition = computeErrorPosition();
  29727. throw new this.SyntaxError(cleanupExpected(rightmostFailuresExpected), found, offset, errorPosition.line, errorPosition.column);
  29728. }
  29729. return result;
  29730. },
  29731. /* Returns the parser source code. */
  29732. toSource: function toSource() {
  29733. return this._source;
  29734. }
  29735. };
  29736. /* Thrown when a parser encounters a syntax error. */
  29737. result.SyntaxError = function (expected, found, offset, line, column) {
  29738. function buildMessage(expected, found) {
  29739. var expectedHumanized, foundHumanized;
  29740. switch (expected.length) {
  29741. case 0:
  29742. expectedHumanized = "end of input";
  29743. break;
  29744. case 1:
  29745. expectedHumanized = expected[0];
  29746. break;
  29747. default:
  29748. expectedHumanized = expected.slice(0, expected.length - 1).join(", ") + " or " + expected[expected.length - 1];
  29749. }
  29750. foundHumanized = found ? quote(found) : "end of input";
  29751. return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
  29752. }
  29753. this.name = "SyntaxError";
  29754. this.expected = expected;
  29755. this.found = found;
  29756. this.message = buildMessage(expected, found);
  29757. this.offset = offset;
  29758. this.line = line;
  29759. this.column = column;
  29760. };
  29761. result.SyntaxError.prototype = Error.prototype;
  29762. return result;
  29763. }();
  29764. if (typeof define === "function" && define.amd) {
  29765. define(function () {
  29766. return result;
  29767. });
  29768. } else if (typeof module !== "undefined" && module.exports) {
  29769. module.exports = result;
  29770. } else {
  29771. undefined.esquery = result;
  29772. }
  29773. },{}],73:[function(require,module,exports){
  29774. 'use strict';
  29775. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  29776. /*
  29777. Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
  29778. Redistribution and use in source and binary forms, with or without
  29779. modification, are permitted provided that the following conditions are met:
  29780. * Redistributions of source code must retain the above copyright
  29781. notice, this list of conditions and the following disclaimer.
  29782. * Redistributions in binary form must reproduce the above copyright
  29783. notice, this list of conditions and the following disclaimer in the
  29784. documentation and/or other materials provided with the distribution.
  29785. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  29786. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29787. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29788. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  29789. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  29790. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29791. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  29792. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29793. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29794. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29795. */
  29796. (function () {
  29797. 'use strict';
  29798. var estraverse = require('estraverse');
  29799. function isNode(node) {
  29800. if (node == null) {
  29801. return false;
  29802. }
  29803. return (typeof node === 'undefined' ? 'undefined' : _typeof(node)) === 'object' && typeof node.type === 'string';
  29804. }
  29805. function isProperty(nodeType, key) {
  29806. return (nodeType === estraverse.Syntax.ObjectExpression || nodeType === estraverse.Syntax.ObjectPattern) && key === 'properties';
  29807. }
  29808. function Visitor(visitor, options) {
  29809. options = options || {};
  29810. this.__visitor = visitor || this;
  29811. this.__childVisitorKeys = options.childVisitorKeys ? Object.assign({}, estraverse.VisitorKeys, options.childVisitorKeys) : estraverse.VisitorKeys;
  29812. if (options.fallback === 'iteration') {
  29813. this.__fallback = Object.keys;
  29814. } else if (typeof options.fallback === 'function') {
  29815. this.__fallback = options.fallback;
  29816. }
  29817. }
  29818. /* Default method for visiting children.
  29819. * When you need to call default visiting operation inside custom visiting
  29820. * operation, you can use it with `this.visitChildren(node)`.
  29821. */
  29822. Visitor.prototype.visitChildren = function (node) {
  29823. var type, children, i, iz, j, jz, child;
  29824. if (node == null) {
  29825. return;
  29826. }
  29827. type = node.type || estraverse.Syntax.Property;
  29828. children = this.__childVisitorKeys[type];
  29829. if (!children) {
  29830. if (this.__fallback) {
  29831. children = this.__fallback(node);
  29832. } else {
  29833. throw new Error('Unknown node type ' + type + '.');
  29834. }
  29835. }
  29836. for (i = 0, iz = children.length; i < iz; ++i) {
  29837. child = node[children[i]];
  29838. if (child) {
  29839. if (Array.isArray(child)) {
  29840. for (j = 0, jz = child.length; j < jz; ++j) {
  29841. if (child[j]) {
  29842. if (isNode(child[j]) || isProperty(type, children[i])) {
  29843. this.visit(child[j]);
  29844. }
  29845. }
  29846. }
  29847. } else if (isNode(child)) {
  29848. this.visit(child);
  29849. }
  29850. }
  29851. }
  29852. };
  29853. /* Dispatching node. */
  29854. Visitor.prototype.visit = function (node) {
  29855. var type;
  29856. if (node == null) {
  29857. return;
  29858. }
  29859. type = node.type || estraverse.Syntax.Property;
  29860. if (this.__visitor[type]) {
  29861. this.__visitor[type].call(this, node);
  29862. return;
  29863. }
  29864. this.visitChildren(node);
  29865. };
  29866. exports.version = require('./package.json').version;
  29867. exports.Visitor = Visitor;
  29868. exports.visit = function (node, visitor, options) {
  29869. var v = new Visitor(visitor, options);
  29870. v.visit(node);
  29871. };
  29872. })();
  29873. /* vim: set sw=4 ts=4 et tw=80 : */
  29874. },{"./package.json":74,"estraverse":75}],74:[function(require,module,exports){
  29875. module.exports={
  29876. "_from": "esrecurse@^4.1.0",
  29877. "_id": "esrecurse@4.2.1",
  29878. "_inBundle": false,
  29879. "_integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==",
  29880. "_location": "/esrecurse",
  29881. "_phantomChildren": {},
  29882. "_requested": {
  29883. "type": "range",
  29884. "registry": true,
  29885. "raw": "esrecurse@^4.1.0",
  29886. "name": "esrecurse",
  29887. "escapedName": "esrecurse",
  29888. "rawSpec": "^4.1.0",
  29889. "saveSpec": null,
  29890. "fetchSpec": "^4.1.0"
  29891. },
  29892. "_requiredBy": [
  29893. "/babel-eslint/eslint-scope",
  29894. "/eslint-scope"
  29895. ],
  29896. "_resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz",
  29897. "_shasum": "007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf",
  29898. "_spec": "esrecurse@^4.1.0",
  29899. "_where": "/var/lib/jenkins/workspace/Releases/eslint Release/eslint/node_modules/eslint-scope",
  29900. "babel": {
  29901. "presets": [
  29902. "es2015"
  29903. ]
  29904. },
  29905. "bugs": {
  29906. "url": "https://github.com/estools/esrecurse/issues"
  29907. },
  29908. "bundleDependencies": false,
  29909. "dependencies": {
  29910. "estraverse": "^4.1.0"
  29911. },
  29912. "deprecated": false,
  29913. "description": "ECMAScript AST recursive visitor",
  29914. "devDependencies": {
  29915. "babel-cli": "^6.24.1",
  29916. "babel-eslint": "^7.2.3",
  29917. "babel-preset-es2015": "^6.24.1",
  29918. "babel-register": "^6.24.1",
  29919. "chai": "^4.0.2",
  29920. "esprima": "^4.0.0",
  29921. "gulp": "^3.9.0",
  29922. "gulp-bump": "^2.7.0",
  29923. "gulp-eslint": "^4.0.0",
  29924. "gulp-filter": "^5.0.0",
  29925. "gulp-git": "^2.4.1",
  29926. "gulp-mocha": "^4.3.1",
  29927. "gulp-tag-version": "^1.2.1",
  29928. "jsdoc": "^3.3.0-alpha10",
  29929. "minimist": "^1.1.0"
  29930. },
  29931. "engines": {
  29932. "node": ">=4.0"
  29933. },
  29934. "homepage": "https://github.com/estools/esrecurse",
  29935. "license": "BSD-2-Clause",
  29936. "main": "esrecurse.js",
  29937. "maintainers": [
  29938. {
  29939. "name": "Yusuke Suzuki",
  29940. "email": "utatane.tea@gmail.com",
  29941. "url": "https://github.com/Constellation"
  29942. }
  29943. ],
  29944. "name": "esrecurse",
  29945. "repository": {
  29946. "type": "git",
  29947. "url": "git+https://github.com/estools/esrecurse.git"
  29948. },
  29949. "scripts": {
  29950. "lint": "gulp lint",
  29951. "test": "gulp travis",
  29952. "unit-test": "gulp test"
  29953. },
  29954. "version": "4.2.1"
  29955. }
  29956. },{}],75:[function(require,module,exports){
  29957. 'use strict';
  29958. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  29959. /*
  29960. Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
  29961. Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
  29962. Redistribution and use in source and binary forms, with or without
  29963. modification, are permitted provided that the following conditions are met:
  29964. * Redistributions of source code must retain the above copyright
  29965. notice, this list of conditions and the following disclaimer.
  29966. * Redistributions in binary form must reproduce the above copyright
  29967. notice, this list of conditions and the following disclaimer in the
  29968. documentation and/or other materials provided with the distribution.
  29969. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  29970. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29971. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29972. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  29973. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  29974. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29975. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  29976. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29977. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29978. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29979. */
  29980. /*jslint vars:false, bitwise:true*/
  29981. /*jshint indent:4*/
  29982. /*global exports:true*/
  29983. (function clone(exports) {
  29984. 'use strict';
  29985. var Syntax, isArray, VisitorOption, VisitorKeys, objectCreate, objectKeys, BREAK, SKIP, REMOVE;
  29986. function ignoreJSHintError() {}
  29987. isArray = Array.isArray;
  29988. if (!isArray) {
  29989. isArray = function isArray(array) {
  29990. return Object.prototype.toString.call(array) === '[object Array]';
  29991. };
  29992. }
  29993. function deepCopy(obj) {
  29994. var ret = {},
  29995. key,
  29996. val;
  29997. for (key in obj) {
  29998. if (obj.hasOwnProperty(key)) {
  29999. val = obj[key];
  30000. if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object' && val !== null) {
  30001. ret[key] = deepCopy(val);
  30002. } else {
  30003. ret[key] = val;
  30004. }
  30005. }
  30006. }
  30007. return ret;
  30008. }
  30009. function shallowCopy(obj) {
  30010. var ret = {},
  30011. key;
  30012. for (key in obj) {
  30013. if (obj.hasOwnProperty(key)) {
  30014. ret[key] = obj[key];
  30015. }
  30016. }
  30017. return ret;
  30018. }
  30019. ignoreJSHintError(shallowCopy);
  30020. // based on LLVM libc++ upper_bound / lower_bound
  30021. // MIT License
  30022. function upperBound(array, func) {
  30023. var diff, len, i, current;
  30024. len = array.length;
  30025. i = 0;
  30026. while (len) {
  30027. diff = len >>> 1;
  30028. current = i + diff;
  30029. if (func(array[current])) {
  30030. len = diff;
  30031. } else {
  30032. i = current + 1;
  30033. len -= diff + 1;
  30034. }
  30035. }
  30036. return i;
  30037. }
  30038. function lowerBound(array, func) {
  30039. var diff, len, i, current;
  30040. len = array.length;
  30041. i = 0;
  30042. while (len) {
  30043. diff = len >>> 1;
  30044. current = i + diff;
  30045. if (func(array[current])) {
  30046. i = current + 1;
  30047. len -= diff + 1;
  30048. } else {
  30049. len = diff;
  30050. }
  30051. }
  30052. return i;
  30053. }
  30054. ignoreJSHintError(lowerBound);
  30055. objectCreate = Object.create || function () {
  30056. function F() {}
  30057. return function (o) {
  30058. F.prototype = o;
  30059. return new F();
  30060. };
  30061. }();
  30062. objectKeys = Object.keys || function (o) {
  30063. var keys = [],
  30064. key;
  30065. for (key in o) {
  30066. keys.push(key);
  30067. }
  30068. return keys;
  30069. };
  30070. function extend(to, from) {
  30071. var keys = objectKeys(from),
  30072. key,
  30073. i,
  30074. len;
  30075. for (i = 0, len = keys.length; i < len; i += 1) {
  30076. key = keys[i];
  30077. to[key] = from[key];
  30078. }
  30079. return to;
  30080. }
  30081. Syntax = {
  30082. AssignmentExpression: 'AssignmentExpression',
  30083. AssignmentPattern: 'AssignmentPattern',
  30084. ArrayExpression: 'ArrayExpression',
  30085. ArrayPattern: 'ArrayPattern',
  30086. ArrowFunctionExpression: 'ArrowFunctionExpression',
  30087. AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
  30088. BlockStatement: 'BlockStatement',
  30089. BinaryExpression: 'BinaryExpression',
  30090. BreakStatement: 'BreakStatement',
  30091. CallExpression: 'CallExpression',
  30092. CatchClause: 'CatchClause',
  30093. ClassBody: 'ClassBody',
  30094. ClassDeclaration: 'ClassDeclaration',
  30095. ClassExpression: 'ClassExpression',
  30096. ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
  30097. ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
  30098. ConditionalExpression: 'ConditionalExpression',
  30099. ContinueStatement: 'ContinueStatement',
  30100. DebuggerStatement: 'DebuggerStatement',
  30101. DirectiveStatement: 'DirectiveStatement',
  30102. DoWhileStatement: 'DoWhileStatement',
  30103. EmptyStatement: 'EmptyStatement',
  30104. ExportAllDeclaration: 'ExportAllDeclaration',
  30105. ExportDefaultDeclaration: 'ExportDefaultDeclaration',
  30106. ExportNamedDeclaration: 'ExportNamedDeclaration',
  30107. ExportSpecifier: 'ExportSpecifier',
  30108. ExpressionStatement: 'ExpressionStatement',
  30109. ForStatement: 'ForStatement',
  30110. ForInStatement: 'ForInStatement',
  30111. ForOfStatement: 'ForOfStatement',
  30112. FunctionDeclaration: 'FunctionDeclaration',
  30113. FunctionExpression: 'FunctionExpression',
  30114. GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
  30115. Identifier: 'Identifier',
  30116. IfStatement: 'IfStatement',
  30117. ImportDeclaration: 'ImportDeclaration',
  30118. ImportDefaultSpecifier: 'ImportDefaultSpecifier',
  30119. ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
  30120. ImportSpecifier: 'ImportSpecifier',
  30121. Literal: 'Literal',
  30122. LabeledStatement: 'LabeledStatement',
  30123. LogicalExpression: 'LogicalExpression',
  30124. MemberExpression: 'MemberExpression',
  30125. MetaProperty: 'MetaProperty',
  30126. MethodDefinition: 'MethodDefinition',
  30127. ModuleSpecifier: 'ModuleSpecifier',
  30128. NewExpression: 'NewExpression',
  30129. ObjectExpression: 'ObjectExpression',
  30130. ObjectPattern: 'ObjectPattern',
  30131. Program: 'Program',
  30132. Property: 'Property',
  30133. RestElement: 'RestElement',
  30134. ReturnStatement: 'ReturnStatement',
  30135. SequenceExpression: 'SequenceExpression',
  30136. SpreadElement: 'SpreadElement',
  30137. Super: 'Super',
  30138. SwitchStatement: 'SwitchStatement',
  30139. SwitchCase: 'SwitchCase',
  30140. TaggedTemplateExpression: 'TaggedTemplateExpression',
  30141. TemplateElement: 'TemplateElement',
  30142. TemplateLiteral: 'TemplateLiteral',
  30143. ThisExpression: 'ThisExpression',
  30144. ThrowStatement: 'ThrowStatement',
  30145. TryStatement: 'TryStatement',
  30146. UnaryExpression: 'UnaryExpression',
  30147. UpdateExpression: 'UpdateExpression',
  30148. VariableDeclaration: 'VariableDeclaration',
  30149. VariableDeclarator: 'VariableDeclarator',
  30150. WhileStatement: 'WhileStatement',
  30151. WithStatement: 'WithStatement',
  30152. YieldExpression: 'YieldExpression'
  30153. };
  30154. VisitorKeys = {
  30155. AssignmentExpression: ['left', 'right'],
  30156. AssignmentPattern: ['left', 'right'],
  30157. ArrayExpression: ['elements'],
  30158. ArrayPattern: ['elements'],
  30159. ArrowFunctionExpression: ['params', 'body'],
  30160. AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
  30161. BlockStatement: ['body'],
  30162. BinaryExpression: ['left', 'right'],
  30163. BreakStatement: ['label'],
  30164. CallExpression: ['callee', 'arguments'],
  30165. CatchClause: ['param', 'body'],
  30166. ClassBody: ['body'],
  30167. ClassDeclaration: ['id', 'superClass', 'body'],
  30168. ClassExpression: ['id', 'superClass', 'body'],
  30169. ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
  30170. ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
  30171. ConditionalExpression: ['test', 'consequent', 'alternate'],
  30172. ContinueStatement: ['label'],
  30173. DebuggerStatement: [],
  30174. DirectiveStatement: [],
  30175. DoWhileStatement: ['body', 'test'],
  30176. EmptyStatement: [],
  30177. ExportAllDeclaration: ['source'],
  30178. ExportDefaultDeclaration: ['declaration'],
  30179. ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
  30180. ExportSpecifier: ['exported', 'local'],
  30181. ExpressionStatement: ['expression'],
  30182. ForStatement: ['init', 'test', 'update', 'body'],
  30183. ForInStatement: ['left', 'right', 'body'],
  30184. ForOfStatement: ['left', 'right', 'body'],
  30185. FunctionDeclaration: ['id', 'params', 'body'],
  30186. FunctionExpression: ['id', 'params', 'body'],
  30187. GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
  30188. Identifier: [],
  30189. IfStatement: ['test', 'consequent', 'alternate'],
  30190. ImportDeclaration: ['specifiers', 'source'],
  30191. ImportDefaultSpecifier: ['local'],
  30192. ImportNamespaceSpecifier: ['local'],
  30193. ImportSpecifier: ['imported', 'local'],
  30194. Literal: [],
  30195. LabeledStatement: ['label', 'body'],
  30196. LogicalExpression: ['left', 'right'],
  30197. MemberExpression: ['object', 'property'],
  30198. MetaProperty: ['meta', 'property'],
  30199. MethodDefinition: ['key', 'value'],
  30200. ModuleSpecifier: [],
  30201. NewExpression: ['callee', 'arguments'],
  30202. ObjectExpression: ['properties'],
  30203. ObjectPattern: ['properties'],
  30204. Program: ['body'],
  30205. Property: ['key', 'value'],
  30206. RestElement: ['argument'],
  30207. ReturnStatement: ['argument'],
  30208. SequenceExpression: ['expressions'],
  30209. SpreadElement: ['argument'],
  30210. Super: [],
  30211. SwitchStatement: ['discriminant', 'cases'],
  30212. SwitchCase: ['test', 'consequent'],
  30213. TaggedTemplateExpression: ['tag', 'quasi'],
  30214. TemplateElement: [],
  30215. TemplateLiteral: ['quasis', 'expressions'],
  30216. ThisExpression: [],
  30217. ThrowStatement: ['argument'],
  30218. TryStatement: ['block', 'handler', 'finalizer'],
  30219. UnaryExpression: ['argument'],
  30220. UpdateExpression: ['argument'],
  30221. VariableDeclaration: ['declarations'],
  30222. VariableDeclarator: ['id', 'init'],
  30223. WhileStatement: ['test', 'body'],
  30224. WithStatement: ['object', 'body'],
  30225. YieldExpression: ['argument']
  30226. };
  30227. // unique id
  30228. BREAK = {};
  30229. SKIP = {};
  30230. REMOVE = {};
  30231. VisitorOption = {
  30232. Break: BREAK,
  30233. Skip: SKIP,
  30234. Remove: REMOVE
  30235. };
  30236. function Reference(parent, key) {
  30237. this.parent = parent;
  30238. this.key = key;
  30239. }
  30240. Reference.prototype.replace = function replace(node) {
  30241. this.parent[this.key] = node;
  30242. };
  30243. Reference.prototype.remove = function remove() {
  30244. if (isArray(this.parent)) {
  30245. this.parent.splice(this.key, 1);
  30246. return true;
  30247. } else {
  30248. this.replace(null);
  30249. return false;
  30250. }
  30251. };
  30252. function Element(node, path, wrap, ref) {
  30253. this.node = node;
  30254. this.path = path;
  30255. this.wrap = wrap;
  30256. this.ref = ref;
  30257. }
  30258. function Controller() {}
  30259. // API:
  30260. // return property path array from root to current node
  30261. Controller.prototype.path = function path() {
  30262. var i, iz, j, jz, result, element;
  30263. function addToPath(result, path) {
  30264. if (isArray(path)) {
  30265. for (j = 0, jz = path.length; j < jz; ++j) {
  30266. result.push(path[j]);
  30267. }
  30268. } else {
  30269. result.push(path);
  30270. }
  30271. }
  30272. // root node
  30273. if (!this.__current.path) {
  30274. return null;
  30275. }
  30276. // first node is sentinel, second node is root element
  30277. result = [];
  30278. for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
  30279. element = this.__leavelist[i];
  30280. addToPath(result, element.path);
  30281. }
  30282. addToPath(result, this.__current.path);
  30283. return result;
  30284. };
  30285. // API:
  30286. // return type of current node
  30287. Controller.prototype.type = function () {
  30288. var node = this.current();
  30289. return node.type || this.__current.wrap;
  30290. };
  30291. // API:
  30292. // return array of parent elements
  30293. Controller.prototype.parents = function parents() {
  30294. var i, iz, result;
  30295. // first node is sentinel
  30296. result = [];
  30297. for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
  30298. result.push(this.__leavelist[i].node);
  30299. }
  30300. return result;
  30301. };
  30302. // API:
  30303. // return current node
  30304. Controller.prototype.current = function current() {
  30305. return this.__current.node;
  30306. };
  30307. Controller.prototype.__execute = function __execute(callback, element) {
  30308. var previous, result;
  30309. result = undefined;
  30310. previous = this.__current;
  30311. this.__current = element;
  30312. this.__state = null;
  30313. if (callback) {
  30314. result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
  30315. }
  30316. this.__current = previous;
  30317. return result;
  30318. };
  30319. // API:
  30320. // notify control skip / break
  30321. Controller.prototype.notify = function notify(flag) {
  30322. this.__state = flag;
  30323. };
  30324. // API:
  30325. // skip child nodes of current node
  30326. Controller.prototype.skip = function () {
  30327. this.notify(SKIP);
  30328. };
  30329. // API:
  30330. // break traversals
  30331. Controller.prototype['break'] = function () {
  30332. this.notify(BREAK);
  30333. };
  30334. // API:
  30335. // remove node
  30336. Controller.prototype.remove = function () {
  30337. this.notify(REMOVE);
  30338. };
  30339. Controller.prototype.__initialize = function (root, visitor) {
  30340. this.visitor = visitor;
  30341. this.root = root;
  30342. this.__worklist = [];
  30343. this.__leavelist = [];
  30344. this.__current = null;
  30345. this.__state = null;
  30346. this.__fallback = null;
  30347. if (visitor.fallback === 'iteration') {
  30348. this.__fallback = objectKeys;
  30349. } else if (typeof visitor.fallback === 'function') {
  30350. this.__fallback = visitor.fallback;
  30351. }
  30352. this.__keys = VisitorKeys;
  30353. if (visitor.keys) {
  30354. this.__keys = extend(objectCreate(this.__keys), visitor.keys);
  30355. }
  30356. };
  30357. function isNode(node) {
  30358. if (node == null) {
  30359. return false;
  30360. }
  30361. return (typeof node === 'undefined' ? 'undefined' : _typeof(node)) === 'object' && typeof node.type === 'string';
  30362. }
  30363. function isProperty(nodeType, key) {
  30364. return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
  30365. }
  30366. Controller.prototype.traverse = function traverse(root, visitor) {
  30367. var worklist, leavelist, element, node, nodeType, ret, key, current, current2, candidates, candidate, sentinel;
  30368. this.__initialize(root, visitor);
  30369. sentinel = {};
  30370. // reference
  30371. worklist = this.__worklist;
  30372. leavelist = this.__leavelist;
  30373. // initialize
  30374. worklist.push(new Element(root, null, null, null));
  30375. leavelist.push(new Element(null, null, null, null));
  30376. while (worklist.length) {
  30377. element = worklist.pop();
  30378. if (element === sentinel) {
  30379. element = leavelist.pop();
  30380. ret = this.__execute(visitor.leave, element);
  30381. if (this.__state === BREAK || ret === BREAK) {
  30382. return;
  30383. }
  30384. continue;
  30385. }
  30386. if (element.node) {
  30387. ret = this.__execute(visitor.enter, element);
  30388. if (this.__state === BREAK || ret === BREAK) {
  30389. return;
  30390. }
  30391. worklist.push(sentinel);
  30392. leavelist.push(element);
  30393. if (this.__state === SKIP || ret === SKIP) {
  30394. continue;
  30395. }
  30396. node = element.node;
  30397. nodeType = node.type || element.wrap;
  30398. candidates = this.__keys[nodeType];
  30399. if (!candidates) {
  30400. if (this.__fallback) {
  30401. candidates = this.__fallback(node);
  30402. } else {
  30403. throw new Error('Unknown node type ' + nodeType + '.');
  30404. }
  30405. }
  30406. current = candidates.length;
  30407. while ((current -= 1) >= 0) {
  30408. key = candidates[current];
  30409. candidate = node[key];
  30410. if (!candidate) {
  30411. continue;
  30412. }
  30413. if (isArray(candidate)) {
  30414. current2 = candidate.length;
  30415. while ((current2 -= 1) >= 0) {
  30416. if (!candidate[current2]) {
  30417. continue;
  30418. }
  30419. if (isProperty(nodeType, candidates[current])) {
  30420. element = new Element(candidate[current2], [key, current2], 'Property', null);
  30421. } else if (isNode(candidate[current2])) {
  30422. element = new Element(candidate[current2], [key, current2], null, null);
  30423. } else {
  30424. continue;
  30425. }
  30426. worklist.push(element);
  30427. }
  30428. } else if (isNode(candidate)) {
  30429. worklist.push(new Element(candidate, key, null, null));
  30430. }
  30431. }
  30432. }
  30433. }
  30434. };
  30435. Controller.prototype.replace = function replace(root, visitor) {
  30436. var worklist, leavelist, node, nodeType, target, element, current, current2, candidates, candidate, sentinel, outer, key;
  30437. function removeElem(element) {
  30438. var i, key, nextElem, parent;
  30439. if (element.ref.remove()) {
  30440. // When the reference is an element of an array.
  30441. key = element.ref.key;
  30442. parent = element.ref.parent;
  30443. // If removed from array, then decrease following items' keys.
  30444. i = worklist.length;
  30445. while (i--) {
  30446. nextElem = worklist[i];
  30447. if (nextElem.ref && nextElem.ref.parent === parent) {
  30448. if (nextElem.ref.key < key) {
  30449. break;
  30450. }
  30451. --nextElem.ref.key;
  30452. }
  30453. }
  30454. }
  30455. }
  30456. this.__initialize(root, visitor);
  30457. sentinel = {};
  30458. // reference
  30459. worklist = this.__worklist;
  30460. leavelist = this.__leavelist;
  30461. // initialize
  30462. outer = {
  30463. root: root
  30464. };
  30465. element = new Element(root, null, null, new Reference(outer, 'root'));
  30466. worklist.push(element);
  30467. leavelist.push(element);
  30468. while (worklist.length) {
  30469. element = worklist.pop();
  30470. if (element === sentinel) {
  30471. element = leavelist.pop();
  30472. target = this.__execute(visitor.leave, element);
  30473. // node may be replaced with null,
  30474. // so distinguish between undefined and null in this place
  30475. if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
  30476. // replace
  30477. element.ref.replace(target);
  30478. }
  30479. if (this.__state === REMOVE || target === REMOVE) {
  30480. removeElem(element);
  30481. }
  30482. if (this.__state === BREAK || target === BREAK) {
  30483. return outer.root;
  30484. }
  30485. continue;
  30486. }
  30487. target = this.__execute(visitor.enter, element);
  30488. // node may be replaced with null,
  30489. // so distinguish between undefined and null in this place
  30490. if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
  30491. // replace
  30492. element.ref.replace(target);
  30493. element.node = target;
  30494. }
  30495. if (this.__state === REMOVE || target === REMOVE) {
  30496. removeElem(element);
  30497. element.node = null;
  30498. }
  30499. if (this.__state === BREAK || target === BREAK) {
  30500. return outer.root;
  30501. }
  30502. // node may be null
  30503. node = element.node;
  30504. if (!node) {
  30505. continue;
  30506. }
  30507. worklist.push(sentinel);
  30508. leavelist.push(element);
  30509. if (this.__state === SKIP || target === SKIP) {
  30510. continue;
  30511. }
  30512. nodeType = node.type || element.wrap;
  30513. candidates = this.__keys[nodeType];
  30514. if (!candidates) {
  30515. if (this.__fallback) {
  30516. candidates = this.__fallback(node);
  30517. } else {
  30518. throw new Error('Unknown node type ' + nodeType + '.');
  30519. }
  30520. }
  30521. current = candidates.length;
  30522. while ((current -= 1) >= 0) {
  30523. key = candidates[current];
  30524. candidate = node[key];
  30525. if (!candidate) {
  30526. continue;
  30527. }
  30528. if (isArray(candidate)) {
  30529. current2 = candidate.length;
  30530. while ((current2 -= 1) >= 0) {
  30531. if (!candidate[current2]) {
  30532. continue;
  30533. }
  30534. if (isProperty(nodeType, candidates[current])) {
  30535. element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
  30536. } else if (isNode(candidate[current2])) {
  30537. element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
  30538. } else {
  30539. continue;
  30540. }
  30541. worklist.push(element);
  30542. }
  30543. } else if (isNode(candidate)) {
  30544. worklist.push(new Element(candidate, key, null, new Reference(node, key)));
  30545. }
  30546. }
  30547. }
  30548. return outer.root;
  30549. };
  30550. function traverse(root, visitor) {
  30551. var controller = new Controller();
  30552. return controller.traverse(root, visitor);
  30553. }
  30554. function replace(root, visitor) {
  30555. var controller = new Controller();
  30556. return controller.replace(root, visitor);
  30557. }
  30558. function extendCommentRange(comment, tokens) {
  30559. var target;
  30560. target = upperBound(tokens, function search(token) {
  30561. return token.range[0] > comment.range[0];
  30562. });
  30563. comment.extendedRange = [comment.range[0], comment.range[1]];
  30564. if (target !== tokens.length) {
  30565. comment.extendedRange[1] = tokens[target].range[0];
  30566. }
  30567. target -= 1;
  30568. if (target >= 0) {
  30569. comment.extendedRange[0] = tokens[target].range[1];
  30570. }
  30571. return comment;
  30572. }
  30573. function attachComments(tree, providedComments, tokens) {
  30574. // At first, we should calculate extended comment ranges.
  30575. var comments = [],
  30576. comment,
  30577. len,
  30578. i,
  30579. cursor;
  30580. if (!tree.range) {
  30581. throw new Error('attachComments needs range information');
  30582. }
  30583. // tokens array is empty, we attach comments to tree as 'leadingComments'
  30584. if (!tokens.length) {
  30585. if (providedComments.length) {
  30586. for (i = 0, len = providedComments.length; i < len; i += 1) {
  30587. comment = deepCopy(providedComments[i]);
  30588. comment.extendedRange = [0, tree.range[0]];
  30589. comments.push(comment);
  30590. }
  30591. tree.leadingComments = comments;
  30592. }
  30593. return tree;
  30594. }
  30595. for (i = 0, len = providedComments.length; i < len; i += 1) {
  30596. comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
  30597. }
  30598. // This is based on John Freeman's implementation.
  30599. cursor = 0;
  30600. traverse(tree, {
  30601. enter: function enter(node) {
  30602. var comment;
  30603. while (cursor < comments.length) {
  30604. comment = comments[cursor];
  30605. if (comment.extendedRange[1] > node.range[0]) {
  30606. break;
  30607. }
  30608. if (comment.extendedRange[1] === node.range[0]) {
  30609. if (!node.leadingComments) {
  30610. node.leadingComments = [];
  30611. }
  30612. node.leadingComments.push(comment);
  30613. comments.splice(cursor, 1);
  30614. } else {
  30615. cursor += 1;
  30616. }
  30617. }
  30618. // already out of owned node
  30619. if (cursor === comments.length) {
  30620. return VisitorOption.Break;
  30621. }
  30622. if (comments[cursor].extendedRange[0] > node.range[1]) {
  30623. return VisitorOption.Skip;
  30624. }
  30625. }
  30626. });
  30627. cursor = 0;
  30628. traverse(tree, {
  30629. leave: function leave(node) {
  30630. var comment;
  30631. while (cursor < comments.length) {
  30632. comment = comments[cursor];
  30633. if (node.range[1] < comment.extendedRange[0]) {
  30634. break;
  30635. }
  30636. if (node.range[1] === comment.extendedRange[0]) {
  30637. if (!node.trailingComments) {
  30638. node.trailingComments = [];
  30639. }
  30640. node.trailingComments.push(comment);
  30641. comments.splice(cursor, 1);
  30642. } else {
  30643. cursor += 1;
  30644. }
  30645. }
  30646. // already out of owned node
  30647. if (cursor === comments.length) {
  30648. return VisitorOption.Break;
  30649. }
  30650. if (comments[cursor].extendedRange[0] > node.range[1]) {
  30651. return VisitorOption.Skip;
  30652. }
  30653. }
  30654. });
  30655. return tree;
  30656. }
  30657. exports.version = require('./package.json').version;
  30658. exports.Syntax = Syntax;
  30659. exports.traverse = traverse;
  30660. exports.replace = replace;
  30661. exports.attachComments = attachComments;
  30662. exports.VisitorKeys = VisitorKeys;
  30663. exports.VisitorOption = VisitorOption;
  30664. exports.Controller = Controller;
  30665. exports.cloneEnvironment = function () {
  30666. return clone({});
  30667. };
  30668. return exports;
  30669. })(exports);
  30670. /* vim: set sw=4 ts=4 et tw=80 : */
  30671. },{"./package.json":76}],76:[function(require,module,exports){
  30672. module.exports={
  30673. "_from": "estraverse@^4.1.1",
  30674. "_id": "estraverse@4.2.0",
  30675. "_inBundle": false,
  30676. "_integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=",
  30677. "_location": "/estraverse",
  30678. "_phantomChildren": {},
  30679. "_requested": {
  30680. "type": "range",
  30681. "registry": true,
  30682. "raw": "estraverse@^4.1.1",
  30683. "name": "estraverse",
  30684. "escapedName": "estraverse",
  30685. "rawSpec": "^4.1.1",
  30686. "saveSpec": null,
  30687. "fetchSpec": "^4.1.1"
  30688. },
  30689. "_requiredBy": [
  30690. "/babel-eslint/eslint-scope",
  30691. "/escodegen",
  30692. "/eslint-scope",
  30693. "/esquery",
  30694. "/esrecurse"
  30695. ],
  30696. "_resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
  30697. "_shasum": "0dee3fed31fcd469618ce7342099fc1afa0bdb13",
  30698. "_spec": "estraverse@^4.1.1",
  30699. "_where": "/var/lib/jenkins/workspace/Releases/eslint Release/eslint/node_modules/eslint-scope",
  30700. "bugs": {
  30701. "url": "https://github.com/estools/estraverse/issues"
  30702. },
  30703. "bundleDependencies": false,
  30704. "deprecated": false,
  30705. "description": "ECMAScript JS AST traversal functions",
  30706. "devDependencies": {
  30707. "babel-preset-es2015": "^6.3.13",
  30708. "babel-register": "^6.3.13",
  30709. "chai": "^2.1.1",
  30710. "espree": "^1.11.0",
  30711. "gulp": "^3.8.10",
  30712. "gulp-bump": "^0.2.2",
  30713. "gulp-filter": "^2.0.0",
  30714. "gulp-git": "^1.0.1",
  30715. "gulp-tag-version": "^1.2.1",
  30716. "jshint": "^2.5.6",
  30717. "mocha": "^2.1.0"
  30718. },
  30719. "engines": {
  30720. "node": ">=0.10.0"
  30721. },
  30722. "homepage": "https://github.com/estools/estraverse",
  30723. "license": "BSD-2-Clause",
  30724. "main": "estraverse.js",
  30725. "maintainers": [
  30726. {
  30727. "name": "Yusuke Suzuki",
  30728. "email": "utatane.tea@gmail.com",
  30729. "url": "http://github.com/Constellation"
  30730. }
  30731. ],
  30732. "name": "estraverse",
  30733. "repository": {
  30734. "type": "git",
  30735. "url": "git+ssh://git@github.com/estools/estraverse.git"
  30736. },
  30737. "scripts": {
  30738. "lint": "jshint estraverse.js",
  30739. "test": "npm run-script lint && npm run-script unit-test",
  30740. "unit-test": "mocha --compilers js:babel-register"
  30741. },
  30742. "version": "4.2.0"
  30743. }
  30744. },{}],77:[function(require,module,exports){
  30745. 'use strict';
  30746. /*
  30747. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  30748. Redistribution and use in source and binary forms, with or without
  30749. modification, are permitted provided that the following conditions are met:
  30750. * Redistributions of source code must retain the above copyright
  30751. notice, this list of conditions and the following disclaimer.
  30752. * Redistributions in binary form must reproduce the above copyright
  30753. notice, this list of conditions and the following disclaimer in the
  30754. documentation and/or other materials provided with the distribution.
  30755. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  30756. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30757. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30758. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  30759. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30760. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30761. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  30762. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30763. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30764. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30765. */
  30766. (function () {
  30767. 'use strict';
  30768. function isExpression(node) {
  30769. if (node == null) {
  30770. return false;
  30771. }
  30772. switch (node.type) {
  30773. case 'ArrayExpression':
  30774. case 'AssignmentExpression':
  30775. case 'BinaryExpression':
  30776. case 'CallExpression':
  30777. case 'ConditionalExpression':
  30778. case 'FunctionExpression':
  30779. case 'Identifier':
  30780. case 'Literal':
  30781. case 'LogicalExpression':
  30782. case 'MemberExpression':
  30783. case 'NewExpression':
  30784. case 'ObjectExpression':
  30785. case 'SequenceExpression':
  30786. case 'ThisExpression':
  30787. case 'UnaryExpression':
  30788. case 'UpdateExpression':
  30789. return true;
  30790. }
  30791. return false;
  30792. }
  30793. function isIterationStatement(node) {
  30794. if (node == null) {
  30795. return false;
  30796. }
  30797. switch (node.type) {
  30798. case 'DoWhileStatement':
  30799. case 'ForInStatement':
  30800. case 'ForStatement':
  30801. case 'WhileStatement':
  30802. return true;
  30803. }
  30804. return false;
  30805. }
  30806. function isStatement(node) {
  30807. if (node == null) {
  30808. return false;
  30809. }
  30810. switch (node.type) {
  30811. case 'BlockStatement':
  30812. case 'BreakStatement':
  30813. case 'ContinueStatement':
  30814. case 'DebuggerStatement':
  30815. case 'DoWhileStatement':
  30816. case 'EmptyStatement':
  30817. case 'ExpressionStatement':
  30818. case 'ForInStatement':
  30819. case 'ForStatement':
  30820. case 'IfStatement':
  30821. case 'LabeledStatement':
  30822. case 'ReturnStatement':
  30823. case 'SwitchStatement':
  30824. case 'ThrowStatement':
  30825. case 'TryStatement':
  30826. case 'VariableDeclaration':
  30827. case 'WhileStatement':
  30828. case 'WithStatement':
  30829. return true;
  30830. }
  30831. return false;
  30832. }
  30833. function isSourceElement(node) {
  30834. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  30835. }
  30836. function trailingStatement(node) {
  30837. switch (node.type) {
  30838. case 'IfStatement':
  30839. if (node.alternate != null) {
  30840. return node.alternate;
  30841. }
  30842. return node.consequent;
  30843. case 'LabeledStatement':
  30844. case 'ForStatement':
  30845. case 'ForInStatement':
  30846. case 'WhileStatement':
  30847. case 'WithStatement':
  30848. return node.body;
  30849. }
  30850. return null;
  30851. }
  30852. function isProblematicIfStatement(node) {
  30853. var current;
  30854. if (node.type !== 'IfStatement') {
  30855. return false;
  30856. }
  30857. if (node.alternate == null) {
  30858. return false;
  30859. }
  30860. current = node.consequent;
  30861. do {
  30862. if (current.type === 'IfStatement') {
  30863. if (current.alternate == null) {
  30864. return true;
  30865. }
  30866. }
  30867. current = trailingStatement(current);
  30868. } while (current);
  30869. return false;
  30870. }
  30871. module.exports = {
  30872. isExpression: isExpression,
  30873. isStatement: isStatement,
  30874. isIterationStatement: isIterationStatement,
  30875. isSourceElement: isSourceElement,
  30876. isProblematicIfStatement: isProblematicIfStatement,
  30877. trailingStatement: trailingStatement
  30878. };
  30879. })();
  30880. /* vim: set sw=4 ts=4 et tw=80 : */
  30881. },{}],78:[function(require,module,exports){
  30882. 'use strict';
  30883. /*
  30884. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  30885. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  30886. Redistribution and use in source and binary forms, with or without
  30887. modification, are permitted provided that the following conditions are met:
  30888. * Redistributions of source code must retain the above copyright
  30889. notice, this list of conditions and the following disclaimer.
  30890. * Redistributions in binary form must reproduce the above copyright
  30891. notice, this list of conditions and the following disclaimer in the
  30892. documentation and/or other materials provided with the distribution.
  30893. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  30894. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30895. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30896. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  30897. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30898. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30899. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  30900. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30901. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30902. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30903. */
  30904. (function () {
  30905. 'use strict';
  30906. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch;
  30907. // See `tools/generate-identifier-regex.js`.
  30908. ES5Regex = {
  30909. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  30910. 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]/,
  30911. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  30912. 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]/
  30913. };
  30914. ES6Regex = {
  30915. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  30916. 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]/,
  30917. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  30918. 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]/
  30919. };
  30920. function isDecimalDigit(ch) {
  30921. return 0x30 <= ch && ch <= 0x39; // 0..9
  30922. }
  30923. function isHexDigit(ch) {
  30924. return 0x30 <= ch && ch <= 0x39 || // 0..9
  30925. 0x61 <= ch && ch <= 0x66 || // a..f
  30926. 0x41 <= ch && ch <= 0x46; // A..F
  30927. }
  30928. function isOctalDigit(ch) {
  30929. return ch >= 0x30 && ch <= 0x37; // 0..7
  30930. }
  30931. // 7.2 White Space
  30932. NON_ASCII_WHITESPACES = [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  30933. function isWhiteSpace(ch) {
  30934. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  30935. }
  30936. // 7.3 Line Terminators
  30937. function isLineTerminator(ch) {
  30938. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  30939. }
  30940. // 7.6 Identifier Names and Identifiers
  30941. function fromCodePoint(cp) {
  30942. if (cp <= 0xFFFF) {
  30943. return String.fromCharCode(cp);
  30944. }
  30945. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  30946. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  30947. return cu1 + cu2;
  30948. }
  30949. IDENTIFIER_START = new Array(0x80);
  30950. for (ch = 0; ch < 0x80; ++ch) {
  30951. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  30952. ch >= 0x41 && ch <= 0x5A || // A..Z
  30953. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  30954. }
  30955. IDENTIFIER_PART = new Array(0x80);
  30956. for (ch = 0; ch < 0x80; ++ch) {
  30957. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  30958. ch >= 0x41 && ch <= 0x5A || // A..Z
  30959. ch >= 0x30 && ch <= 0x39 || // 0..9
  30960. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  30961. }
  30962. function isIdentifierStartES5(ch) {
  30963. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  30964. }
  30965. function isIdentifierPartES5(ch) {
  30966. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  30967. }
  30968. function isIdentifierStartES6(ch) {
  30969. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  30970. }
  30971. function isIdentifierPartES6(ch) {
  30972. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  30973. }
  30974. module.exports = {
  30975. isDecimalDigit: isDecimalDigit,
  30976. isHexDigit: isHexDigit,
  30977. isOctalDigit: isOctalDigit,
  30978. isWhiteSpace: isWhiteSpace,
  30979. isLineTerminator: isLineTerminator,
  30980. isIdentifierStartES5: isIdentifierStartES5,
  30981. isIdentifierPartES5: isIdentifierPartES5,
  30982. isIdentifierStartES6: isIdentifierStartES6,
  30983. isIdentifierPartES6: isIdentifierPartES6
  30984. };
  30985. })();
  30986. /* vim: set sw=4 ts=4 et tw=80 : */
  30987. },{}],79:[function(require,module,exports){
  30988. 'use strict';
  30989. /*
  30990. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  30991. Redistribution and use in source and binary forms, with or without
  30992. modification, are permitted provided that the following conditions are met:
  30993. * Redistributions of source code must retain the above copyright
  30994. notice, this list of conditions and the following disclaimer.
  30995. * Redistributions in binary form must reproduce the above copyright
  30996. notice, this list of conditions and the following disclaimer in the
  30997. documentation and/or other materials provided with the distribution.
  30998. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  30999. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31000. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31001. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  31002. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  31003. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31004. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  31005. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31006. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31007. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31008. */
  31009. (function () {
  31010. 'use strict';
  31011. var code = require('./code');
  31012. function isStrictModeReservedWordES6(id) {
  31013. switch (id) {
  31014. case 'implements':
  31015. case 'interface':
  31016. case 'package':
  31017. case 'private':
  31018. case 'protected':
  31019. case 'public':
  31020. case 'static':
  31021. case 'let':
  31022. return true;
  31023. default:
  31024. return false;
  31025. }
  31026. }
  31027. function isKeywordES5(id, strict) {
  31028. // yield should not be treated as keyword under non-strict mode.
  31029. if (!strict && id === 'yield') {
  31030. return false;
  31031. }
  31032. return isKeywordES6(id, strict);
  31033. }
  31034. function isKeywordES6(id, strict) {
  31035. if (strict && isStrictModeReservedWordES6(id)) {
  31036. return true;
  31037. }
  31038. switch (id.length) {
  31039. case 2:
  31040. return id === 'if' || id === 'in' || id === 'do';
  31041. case 3:
  31042. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  31043. case 4:
  31044. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  31045. case 5:
  31046. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  31047. case 6:
  31048. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  31049. case 7:
  31050. return id === 'default' || id === 'finally' || id === 'extends';
  31051. case 8:
  31052. return id === 'function' || id === 'continue' || id === 'debugger';
  31053. case 10:
  31054. return id === 'instanceof';
  31055. default:
  31056. return false;
  31057. }
  31058. }
  31059. function isReservedWordES5(id, strict) {
  31060. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  31061. }
  31062. function isReservedWordES6(id, strict) {
  31063. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  31064. }
  31065. function isRestrictedWord(id) {
  31066. return id === 'eval' || id === 'arguments';
  31067. }
  31068. function isIdentifierNameES5(id) {
  31069. var i, iz, ch;
  31070. if (id.length === 0) {
  31071. return false;
  31072. }
  31073. ch = id.charCodeAt(0);
  31074. if (!code.isIdentifierStartES5(ch)) {
  31075. return false;
  31076. }
  31077. for (i = 1, iz = id.length; i < iz; ++i) {
  31078. ch = id.charCodeAt(i);
  31079. if (!code.isIdentifierPartES5(ch)) {
  31080. return false;
  31081. }
  31082. }
  31083. return true;
  31084. }
  31085. function decodeUtf16(lead, trail) {
  31086. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  31087. }
  31088. function isIdentifierNameES6(id) {
  31089. var i, iz, ch, lowCh, check;
  31090. if (id.length === 0) {
  31091. return false;
  31092. }
  31093. check = code.isIdentifierStartES6;
  31094. for (i = 0, iz = id.length; i < iz; ++i) {
  31095. ch = id.charCodeAt(i);
  31096. if (0xD800 <= ch && ch <= 0xDBFF) {
  31097. ++i;
  31098. if (i >= iz) {
  31099. return false;
  31100. }
  31101. lowCh = id.charCodeAt(i);
  31102. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  31103. return false;
  31104. }
  31105. ch = decodeUtf16(ch, lowCh);
  31106. }
  31107. if (!check(ch)) {
  31108. return false;
  31109. }
  31110. check = code.isIdentifierPartES6;
  31111. }
  31112. return true;
  31113. }
  31114. function isIdentifierES5(id, strict) {
  31115. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  31116. }
  31117. function isIdentifierES6(id, strict) {
  31118. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  31119. }
  31120. module.exports = {
  31121. isKeywordES5: isKeywordES5,
  31122. isKeywordES6: isKeywordES6,
  31123. isReservedWordES5: isReservedWordES5,
  31124. isReservedWordES6: isReservedWordES6,
  31125. isRestrictedWord: isRestrictedWord,
  31126. isIdentifierNameES5: isIdentifierNameES5,
  31127. isIdentifierNameES6: isIdentifierNameES6,
  31128. isIdentifierES5: isIdentifierES5,
  31129. isIdentifierES6: isIdentifierES6
  31130. };
  31131. })();
  31132. /* vim: set sw=4 ts=4 et tw=80 : */
  31133. },{"./code":78}],80:[function(require,module,exports){
  31134. 'use strict';
  31135. /*
  31136. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  31137. Redistribution and use in source and binary forms, with or without
  31138. modification, are permitted provided that the following conditions are met:
  31139. * Redistributions of source code must retain the above copyright
  31140. notice, this list of conditions and the following disclaimer.
  31141. * Redistributions in binary form must reproduce the above copyright
  31142. notice, this list of conditions and the following disclaimer in the
  31143. documentation and/or other materials provided with the distribution.
  31144. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  31145. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31146. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31147. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  31148. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  31149. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31150. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  31151. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31152. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31153. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31154. */
  31155. (function () {
  31156. 'use strict';
  31157. exports.ast = require('./ast');
  31158. exports.code = require('./code');
  31159. exports.keyword = require('./keyword');
  31160. })();
  31161. /* vim: set sw=4 ts=4 et tw=80 : */
  31162. },{"./ast":77,"./code":78,"./keyword":79}],81:[function(require,module,exports){
  31163. 'use strict';
  31164. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  31165. var isArray = Array.isArray;
  31166. var keyList = Object.keys;
  31167. var hasProp = Object.prototype.hasOwnProperty;
  31168. module.exports = function equal(a, b) {
  31169. if (a === b) return true;
  31170. if (a && b && (typeof a === 'undefined' ? 'undefined' : _typeof(a)) == 'object' && (typeof b === 'undefined' ? 'undefined' : _typeof(b)) == 'object') {
  31171. var arrA = isArray(a),
  31172. arrB = isArray(b),
  31173. i,
  31174. length,
  31175. key;
  31176. if (arrA && arrB) {
  31177. length = a.length;
  31178. if (length != b.length) return false;
  31179. for (i = length; i-- !== 0;) {
  31180. if (!equal(a[i], b[i])) return false;
  31181. }return true;
  31182. }
  31183. if (arrA != arrB) return false;
  31184. var dateA = a instanceof Date,
  31185. dateB = b instanceof Date;
  31186. if (dateA != dateB) return false;
  31187. if (dateA && dateB) return a.getTime() == b.getTime();
  31188. var regexpA = a instanceof RegExp,
  31189. regexpB = b instanceof RegExp;
  31190. if (regexpA != regexpB) return false;
  31191. if (regexpA && regexpB) return a.toString() == b.toString();
  31192. var keys = keyList(a);
  31193. length = keys.length;
  31194. if (length !== keyList(b).length) return false;
  31195. for (i = length; i-- !== 0;) {
  31196. if (!hasProp.call(b, keys[i])) return false;
  31197. }for (i = length; i-- !== 0;) {
  31198. key = keys[i];
  31199. if (!equal(a[key], b[key])) return false;
  31200. }
  31201. return true;
  31202. }
  31203. return a !== a && b !== b;
  31204. };
  31205. },{}],82:[function(require,module,exports){
  31206. 'use strict';
  31207. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  31208. module.exports = function (data, opts) {
  31209. if (!opts) opts = {};
  31210. if (typeof opts === 'function') opts = { cmp: opts };
  31211. var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
  31212. var cmp = opts.cmp && function (f) {
  31213. return function (node) {
  31214. return function (a, b) {
  31215. var aobj = { key: a, value: node[a] };
  31216. var bobj = { key: b, value: node[b] };
  31217. return f(aobj, bobj);
  31218. };
  31219. };
  31220. }(opts.cmp);
  31221. var seen = [];
  31222. return function stringify(node) {
  31223. if (node && node.toJSON && typeof node.toJSON === 'function') {
  31224. node = node.toJSON();
  31225. }
  31226. if (node === undefined) return;
  31227. if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
  31228. if ((typeof node === 'undefined' ? 'undefined' : _typeof(node)) !== 'object') return JSON.stringify(node);
  31229. var i, out;
  31230. if (Array.isArray(node)) {
  31231. out = '[';
  31232. for (i = 0; i < node.length; i++) {
  31233. if (i) out += ',';
  31234. out += stringify(node[i]) || 'null';
  31235. }
  31236. return out + ']';
  31237. }
  31238. if (node === null) return 'null';
  31239. if (seen.indexOf(node) !== -1) {
  31240. if (cycles) return JSON.stringify('__cycle__');
  31241. throw new TypeError('Converting circular structure to JSON');
  31242. }
  31243. var seenIndex = seen.push(node) - 1;
  31244. var keys = Object.keys(node).sort(cmp && cmp(node));
  31245. out = '';
  31246. for (i = 0; i < keys.length; i++) {
  31247. var key = keys[i];
  31248. var value = stringify(node[key]);
  31249. if (!value) continue;
  31250. if (out) out += ',';
  31251. out += JSON.stringify(key) + ':' + value;
  31252. }
  31253. seen.splice(seenIndex, 1);
  31254. return '{' + out + '}';
  31255. }(data);
  31256. };
  31257. },{}],83:[function(require,module,exports){
  31258. "use strict";
  31259. module.exports = createRBTree;
  31260. var RED = 0;
  31261. var BLACK = 1;
  31262. function RBNode(color, key, value, left, right, count) {
  31263. this._color = color;
  31264. this.key = key;
  31265. this.value = value;
  31266. this.left = left;
  31267. this.right = right;
  31268. this._count = count;
  31269. }
  31270. function cloneNode(node) {
  31271. return new RBNode(node._color, node.key, node.value, node.left, node.right, node._count);
  31272. }
  31273. function repaint(color, node) {
  31274. return new RBNode(color, node.key, node.value, node.left, node.right, node._count);
  31275. }
  31276. function recount(node) {
  31277. node._count = 1 + (node.left ? node.left._count : 0) + (node.right ? node.right._count : 0);
  31278. }
  31279. function RedBlackTree(compare, root) {
  31280. this._compare = compare;
  31281. this.root = root;
  31282. }
  31283. var proto = RedBlackTree.prototype;
  31284. Object.defineProperty(proto, "keys", {
  31285. get: function get() {
  31286. var result = [];
  31287. this.forEach(function (k, v) {
  31288. result.push(k);
  31289. });
  31290. return result;
  31291. }
  31292. });
  31293. Object.defineProperty(proto, "values", {
  31294. get: function get() {
  31295. var result = [];
  31296. this.forEach(function (k, v) {
  31297. result.push(v);
  31298. });
  31299. return result;
  31300. }
  31301. });
  31302. //Returns the number of nodes in the tree
  31303. Object.defineProperty(proto, "length", {
  31304. get: function get() {
  31305. if (this.root) {
  31306. return this.root._count;
  31307. }
  31308. return 0;
  31309. }
  31310. });
  31311. //Insert a new item into the tree
  31312. proto.insert = function (key, value) {
  31313. var cmp = this._compare;
  31314. //Find point to insert new node at
  31315. var n = this.root;
  31316. var n_stack = [];
  31317. var d_stack = [];
  31318. while (n) {
  31319. var d = cmp(key, n.key);
  31320. n_stack.push(n);
  31321. d_stack.push(d);
  31322. if (d <= 0) {
  31323. n = n.left;
  31324. } else {
  31325. n = n.right;
  31326. }
  31327. }
  31328. //Rebuild path to leaf node
  31329. n_stack.push(new RBNode(RED, key, value, null, null, 1));
  31330. for (var s = n_stack.length - 2; s >= 0; --s) {
  31331. var n = n_stack[s];
  31332. if (d_stack[s] <= 0) {
  31333. n_stack[s] = new RBNode(n._color, n.key, n.value, n_stack[s + 1], n.right, n._count + 1);
  31334. } else {
  31335. n_stack[s] = new RBNode(n._color, n.key, n.value, n.left, n_stack[s + 1], n._count + 1);
  31336. }
  31337. }
  31338. //Rebalance tree using rotations
  31339. //console.log("start insert", key, d_stack)
  31340. for (var s = n_stack.length - 1; s > 1; --s) {
  31341. var p = n_stack[s - 1];
  31342. var n = n_stack[s];
  31343. if (p._color === BLACK || n._color === BLACK) {
  31344. break;
  31345. }
  31346. var pp = n_stack[s - 2];
  31347. if (pp.left === p) {
  31348. if (p.left === n) {
  31349. var y = pp.right;
  31350. if (y && y._color === RED) {
  31351. //console.log("LLr")
  31352. p._color = BLACK;
  31353. pp.right = repaint(BLACK, y);
  31354. pp._color = RED;
  31355. s -= 1;
  31356. } else {
  31357. //console.log("LLb")
  31358. pp._color = RED;
  31359. pp.left = p.right;
  31360. p._color = BLACK;
  31361. p.right = pp;
  31362. n_stack[s - 2] = p;
  31363. n_stack[s - 1] = n;
  31364. recount(pp);
  31365. recount(p);
  31366. if (s >= 3) {
  31367. var ppp = n_stack[s - 3];
  31368. if (ppp.left === pp) {
  31369. ppp.left = p;
  31370. } else {
  31371. ppp.right = p;
  31372. }
  31373. }
  31374. break;
  31375. }
  31376. } else {
  31377. var y = pp.right;
  31378. if (y && y._color === RED) {
  31379. //console.log("LRr")
  31380. p._color = BLACK;
  31381. pp.right = repaint(BLACK, y);
  31382. pp._color = RED;
  31383. s -= 1;
  31384. } else {
  31385. //console.log("LRb")
  31386. p.right = n.left;
  31387. pp._color = RED;
  31388. pp.left = n.right;
  31389. n._color = BLACK;
  31390. n.left = p;
  31391. n.right = pp;
  31392. n_stack[s - 2] = n;
  31393. n_stack[s - 1] = p;
  31394. recount(pp);
  31395. recount(p);
  31396. recount(n);
  31397. if (s >= 3) {
  31398. var ppp = n_stack[s - 3];
  31399. if (ppp.left === pp) {
  31400. ppp.left = n;
  31401. } else {
  31402. ppp.right = n;
  31403. }
  31404. }
  31405. break;
  31406. }
  31407. }
  31408. } else {
  31409. if (p.right === n) {
  31410. var y = pp.left;
  31411. if (y && y._color === RED) {
  31412. //console.log("RRr", y.key)
  31413. p._color = BLACK;
  31414. pp.left = repaint(BLACK, y);
  31415. pp._color = RED;
  31416. s -= 1;
  31417. } else {
  31418. //console.log("RRb")
  31419. pp._color = RED;
  31420. pp.right = p.left;
  31421. p._color = BLACK;
  31422. p.left = pp;
  31423. n_stack[s - 2] = p;
  31424. n_stack[s - 1] = n;
  31425. recount(pp);
  31426. recount(p);
  31427. if (s >= 3) {
  31428. var ppp = n_stack[s - 3];
  31429. if (ppp.right === pp) {
  31430. ppp.right = p;
  31431. } else {
  31432. ppp.left = p;
  31433. }
  31434. }
  31435. break;
  31436. }
  31437. } else {
  31438. var y = pp.left;
  31439. if (y && y._color === RED) {
  31440. //console.log("RLr")
  31441. p._color = BLACK;
  31442. pp.left = repaint(BLACK, y);
  31443. pp._color = RED;
  31444. s -= 1;
  31445. } else {
  31446. //console.log("RLb")
  31447. p.left = n.right;
  31448. pp._color = RED;
  31449. pp.right = n.left;
  31450. n._color = BLACK;
  31451. n.right = p;
  31452. n.left = pp;
  31453. n_stack[s - 2] = n;
  31454. n_stack[s - 1] = p;
  31455. recount(pp);
  31456. recount(p);
  31457. recount(n);
  31458. if (s >= 3) {
  31459. var ppp = n_stack[s - 3];
  31460. if (ppp.right === pp) {
  31461. ppp.right = n;
  31462. } else {
  31463. ppp.left = n;
  31464. }
  31465. }
  31466. break;
  31467. }
  31468. }
  31469. }
  31470. }
  31471. //Return new tree
  31472. n_stack[0]._color = BLACK;
  31473. return new RedBlackTree(cmp, n_stack[0]);
  31474. };
  31475. //Visit all nodes inorder
  31476. function doVisitFull(visit, node) {
  31477. if (node.left) {
  31478. var v = doVisitFull(visit, node.left);
  31479. if (v) {
  31480. return v;
  31481. }
  31482. }
  31483. var v = visit(node.key, node.value);
  31484. if (v) {
  31485. return v;
  31486. }
  31487. if (node.right) {
  31488. return doVisitFull(visit, node.right);
  31489. }
  31490. }
  31491. //Visit half nodes in order
  31492. function doVisitHalf(lo, compare, visit, node) {
  31493. var l = compare(lo, node.key);
  31494. if (l <= 0) {
  31495. if (node.left) {
  31496. var v = doVisitHalf(lo, compare, visit, node.left);
  31497. if (v) {
  31498. return v;
  31499. }
  31500. }
  31501. var v = visit(node.key, node.value);
  31502. if (v) {
  31503. return v;
  31504. }
  31505. }
  31506. if (node.right) {
  31507. return doVisitHalf(lo, compare, visit, node.right);
  31508. }
  31509. }
  31510. //Visit all nodes within a range
  31511. function doVisit(lo, hi, compare, visit, node) {
  31512. var l = compare(lo, node.key);
  31513. var h = compare(hi, node.key);
  31514. var v;
  31515. if (l <= 0) {
  31516. if (node.left) {
  31517. v = doVisit(lo, hi, compare, visit, node.left);
  31518. if (v) {
  31519. return v;
  31520. }
  31521. }
  31522. if (h > 0) {
  31523. v = visit(node.key, node.value);
  31524. if (v) {
  31525. return v;
  31526. }
  31527. }
  31528. }
  31529. if (h > 0 && node.right) {
  31530. return doVisit(lo, hi, compare, visit, node.right);
  31531. }
  31532. }
  31533. proto.forEach = function rbTreeForEach(visit, lo, hi) {
  31534. if (!this.root) {
  31535. return;
  31536. }
  31537. switch (arguments.length) {
  31538. case 1:
  31539. return doVisitFull(visit, this.root);
  31540. break;
  31541. case 2:
  31542. return doVisitHalf(lo, this._compare, visit, this.root);
  31543. break;
  31544. case 3:
  31545. if (this._compare(lo, hi) >= 0) {
  31546. return;
  31547. }
  31548. return doVisit(lo, hi, this._compare, visit, this.root);
  31549. break;
  31550. }
  31551. };
  31552. //First item in list
  31553. Object.defineProperty(proto, "begin", {
  31554. get: function get() {
  31555. var stack = [];
  31556. var n = this.root;
  31557. while (n) {
  31558. stack.push(n);
  31559. n = n.left;
  31560. }
  31561. return new RedBlackTreeIterator(this, stack);
  31562. }
  31563. });
  31564. //Last item in list
  31565. Object.defineProperty(proto, "end", {
  31566. get: function get() {
  31567. var stack = [];
  31568. var n = this.root;
  31569. while (n) {
  31570. stack.push(n);
  31571. n = n.right;
  31572. }
  31573. return new RedBlackTreeIterator(this, stack);
  31574. }
  31575. });
  31576. //Find the ith item in the tree
  31577. proto.at = function (idx) {
  31578. if (idx < 0) {
  31579. return new RedBlackTreeIterator(this, []);
  31580. }
  31581. var n = this.root;
  31582. var stack = [];
  31583. while (true) {
  31584. stack.push(n);
  31585. if (n.left) {
  31586. if (idx < n.left._count) {
  31587. n = n.left;
  31588. continue;
  31589. }
  31590. idx -= n.left._count;
  31591. }
  31592. if (!idx) {
  31593. return new RedBlackTreeIterator(this, stack);
  31594. }
  31595. idx -= 1;
  31596. if (n.right) {
  31597. if (idx >= n.right._count) {
  31598. break;
  31599. }
  31600. n = n.right;
  31601. } else {
  31602. break;
  31603. }
  31604. }
  31605. return new RedBlackTreeIterator(this, []);
  31606. };
  31607. proto.ge = function (key) {
  31608. var cmp = this._compare;
  31609. var n = this.root;
  31610. var stack = [];
  31611. var last_ptr = 0;
  31612. while (n) {
  31613. var d = cmp(key, n.key);
  31614. stack.push(n);
  31615. if (d <= 0) {
  31616. last_ptr = stack.length;
  31617. }
  31618. if (d <= 0) {
  31619. n = n.left;
  31620. } else {
  31621. n = n.right;
  31622. }
  31623. }
  31624. stack.length = last_ptr;
  31625. return new RedBlackTreeIterator(this, stack);
  31626. };
  31627. proto.gt = function (key) {
  31628. var cmp = this._compare;
  31629. var n = this.root;
  31630. var stack = [];
  31631. var last_ptr = 0;
  31632. while (n) {
  31633. var d = cmp(key, n.key);
  31634. stack.push(n);
  31635. if (d < 0) {
  31636. last_ptr = stack.length;
  31637. }
  31638. if (d < 0) {
  31639. n = n.left;
  31640. } else {
  31641. n = n.right;
  31642. }
  31643. }
  31644. stack.length = last_ptr;
  31645. return new RedBlackTreeIterator(this, stack);
  31646. };
  31647. proto.lt = function (key) {
  31648. var cmp = this._compare;
  31649. var n = this.root;
  31650. var stack = [];
  31651. var last_ptr = 0;
  31652. while (n) {
  31653. var d = cmp(key, n.key);
  31654. stack.push(n);
  31655. if (d > 0) {
  31656. last_ptr = stack.length;
  31657. }
  31658. if (d <= 0) {
  31659. n = n.left;
  31660. } else {
  31661. n = n.right;
  31662. }
  31663. }
  31664. stack.length = last_ptr;
  31665. return new RedBlackTreeIterator(this, stack);
  31666. };
  31667. proto.le = function (key) {
  31668. var cmp = this._compare;
  31669. var n = this.root;
  31670. var stack = [];
  31671. var last_ptr = 0;
  31672. while (n) {
  31673. var d = cmp(key, n.key);
  31674. stack.push(n);
  31675. if (d >= 0) {
  31676. last_ptr = stack.length;
  31677. }
  31678. if (d < 0) {
  31679. n = n.left;
  31680. } else {
  31681. n = n.right;
  31682. }
  31683. }
  31684. stack.length = last_ptr;
  31685. return new RedBlackTreeIterator(this, stack);
  31686. };
  31687. //Finds the item with key if it exists
  31688. proto.find = function (key) {
  31689. var cmp = this._compare;
  31690. var n = this.root;
  31691. var stack = [];
  31692. while (n) {
  31693. var d = cmp(key, n.key);
  31694. stack.push(n);
  31695. if (d === 0) {
  31696. return new RedBlackTreeIterator(this, stack);
  31697. }
  31698. if (d <= 0) {
  31699. n = n.left;
  31700. } else {
  31701. n = n.right;
  31702. }
  31703. }
  31704. return new RedBlackTreeIterator(this, []);
  31705. };
  31706. //Removes item with key from tree
  31707. proto.remove = function (key) {
  31708. var iter = this.find(key);
  31709. if (iter) {
  31710. return iter.remove();
  31711. }
  31712. return this;
  31713. };
  31714. //Returns the item at `key`
  31715. proto.get = function (key) {
  31716. var cmp = this._compare;
  31717. var n = this.root;
  31718. while (n) {
  31719. var d = cmp(key, n.key);
  31720. if (d === 0) {
  31721. return n.value;
  31722. }
  31723. if (d <= 0) {
  31724. n = n.left;
  31725. } else {
  31726. n = n.right;
  31727. }
  31728. }
  31729. return;
  31730. };
  31731. //Iterator for red black tree
  31732. function RedBlackTreeIterator(tree, stack) {
  31733. this.tree = tree;
  31734. this._stack = stack;
  31735. }
  31736. var iproto = RedBlackTreeIterator.prototype;
  31737. //Test if iterator is valid
  31738. Object.defineProperty(iproto, "valid", {
  31739. get: function get() {
  31740. return this._stack.length > 0;
  31741. }
  31742. });
  31743. //Node of the iterator
  31744. Object.defineProperty(iproto, "node", {
  31745. get: function get() {
  31746. if (this._stack.length > 0) {
  31747. return this._stack[this._stack.length - 1];
  31748. }
  31749. return null;
  31750. },
  31751. enumerable: true
  31752. });
  31753. //Makes a copy of an iterator
  31754. iproto.clone = function () {
  31755. return new RedBlackTreeIterator(this.tree, this._stack.slice());
  31756. };
  31757. //Swaps two nodes
  31758. function swapNode(n, v) {
  31759. n.key = v.key;
  31760. n.value = v.value;
  31761. n.left = v.left;
  31762. n.right = v.right;
  31763. n._color = v._color;
  31764. n._count = v._count;
  31765. }
  31766. //Fix up a double black node in a tree
  31767. function fixDoubleBlack(stack) {
  31768. var n, p, s, z;
  31769. for (var i = stack.length - 1; i >= 0; --i) {
  31770. n = stack[i];
  31771. if (i === 0) {
  31772. n._color = BLACK;
  31773. return;
  31774. }
  31775. //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key)
  31776. p = stack[i - 1];
  31777. if (p.left === n) {
  31778. //console.log("left child")
  31779. s = p.right;
  31780. if (s.right && s.right._color === RED) {
  31781. //console.log("case 1: right sibling child red")
  31782. s = p.right = cloneNode(s);
  31783. z = s.right = cloneNode(s.right);
  31784. p.right = s.left;
  31785. s.left = p;
  31786. s.right = z;
  31787. s._color = p._color;
  31788. n._color = BLACK;
  31789. p._color = BLACK;
  31790. z._color = BLACK;
  31791. recount(p);
  31792. recount(s);
  31793. if (i > 1) {
  31794. var pp = stack[i - 2];
  31795. if (pp.left === p) {
  31796. pp.left = s;
  31797. } else {
  31798. pp.right = s;
  31799. }
  31800. }
  31801. stack[i - 1] = s;
  31802. return;
  31803. } else if (s.left && s.left._color === RED) {
  31804. //console.log("case 1: left sibling child red")
  31805. s = p.right = cloneNode(s);
  31806. z = s.left = cloneNode(s.left);
  31807. p.right = z.left;
  31808. s.left = z.right;
  31809. z.left = p;
  31810. z.right = s;
  31811. z._color = p._color;
  31812. p._color = BLACK;
  31813. s._color = BLACK;
  31814. n._color = BLACK;
  31815. recount(p);
  31816. recount(s);
  31817. recount(z);
  31818. if (i > 1) {
  31819. var pp = stack[i - 2];
  31820. if (pp.left === p) {
  31821. pp.left = z;
  31822. } else {
  31823. pp.right = z;
  31824. }
  31825. }
  31826. stack[i - 1] = z;
  31827. return;
  31828. }
  31829. if (s._color === BLACK) {
  31830. if (p._color === RED) {
  31831. //console.log("case 2: black sibling, red parent", p.right.value)
  31832. p._color = BLACK;
  31833. p.right = repaint(RED, s);
  31834. return;
  31835. } else {
  31836. //console.log("case 2: black sibling, black parent", p.right.value)
  31837. p.right = repaint(RED, s);
  31838. continue;
  31839. }
  31840. } else {
  31841. //console.log("case 3: red sibling")
  31842. s = cloneNode(s);
  31843. p.right = s.left;
  31844. s.left = p;
  31845. s._color = p._color;
  31846. p._color = RED;
  31847. recount(p);
  31848. recount(s);
  31849. if (i > 1) {
  31850. var pp = stack[i - 2];
  31851. if (pp.left === p) {
  31852. pp.left = s;
  31853. } else {
  31854. pp.right = s;
  31855. }
  31856. }
  31857. stack[i - 1] = s;
  31858. stack[i] = p;
  31859. if (i + 1 < stack.length) {
  31860. stack[i + 1] = n;
  31861. } else {
  31862. stack.push(n);
  31863. }
  31864. i = i + 2;
  31865. }
  31866. } else {
  31867. //console.log("right child")
  31868. s = p.left;
  31869. if (s.left && s.left._color === RED) {
  31870. //console.log("case 1: left sibling child red", p.value, p._color)
  31871. s = p.left = cloneNode(s);
  31872. z = s.left = cloneNode(s.left);
  31873. p.left = s.right;
  31874. s.right = p;
  31875. s.left = z;
  31876. s._color = p._color;
  31877. n._color = BLACK;
  31878. p._color = BLACK;
  31879. z._color = BLACK;
  31880. recount(p);
  31881. recount(s);
  31882. if (i > 1) {
  31883. var pp = stack[i - 2];
  31884. if (pp.right === p) {
  31885. pp.right = s;
  31886. } else {
  31887. pp.left = s;
  31888. }
  31889. }
  31890. stack[i - 1] = s;
  31891. return;
  31892. } else if (s.right && s.right._color === RED) {
  31893. //console.log("case 1: right sibling child red")
  31894. s = p.left = cloneNode(s);
  31895. z = s.right = cloneNode(s.right);
  31896. p.left = z.right;
  31897. s.right = z.left;
  31898. z.right = p;
  31899. z.left = s;
  31900. z._color = p._color;
  31901. p._color = BLACK;
  31902. s._color = BLACK;
  31903. n._color = BLACK;
  31904. recount(p);
  31905. recount(s);
  31906. recount(z);
  31907. if (i > 1) {
  31908. var pp = stack[i - 2];
  31909. if (pp.right === p) {
  31910. pp.right = z;
  31911. } else {
  31912. pp.left = z;
  31913. }
  31914. }
  31915. stack[i - 1] = z;
  31916. return;
  31917. }
  31918. if (s._color === BLACK) {
  31919. if (p._color === RED) {
  31920. //console.log("case 2: black sibling, red parent")
  31921. p._color = BLACK;
  31922. p.left = repaint(RED, s);
  31923. return;
  31924. } else {
  31925. //console.log("case 2: black sibling, black parent")
  31926. p.left = repaint(RED, s);
  31927. continue;
  31928. }
  31929. } else {
  31930. //console.log("case 3: red sibling")
  31931. s = cloneNode(s);
  31932. p.left = s.right;
  31933. s.right = p;
  31934. s._color = p._color;
  31935. p._color = RED;
  31936. recount(p);
  31937. recount(s);
  31938. if (i > 1) {
  31939. var pp = stack[i - 2];
  31940. if (pp.right === p) {
  31941. pp.right = s;
  31942. } else {
  31943. pp.left = s;
  31944. }
  31945. }
  31946. stack[i - 1] = s;
  31947. stack[i] = p;
  31948. if (i + 1 < stack.length) {
  31949. stack[i + 1] = n;
  31950. } else {
  31951. stack.push(n);
  31952. }
  31953. i = i + 2;
  31954. }
  31955. }
  31956. }
  31957. }
  31958. //Removes item at iterator from tree
  31959. iproto.remove = function () {
  31960. var stack = this._stack;
  31961. if (stack.length === 0) {
  31962. return this.tree;
  31963. }
  31964. //First copy path to node
  31965. var cstack = new Array(stack.length);
  31966. var n = stack[stack.length - 1];
  31967. cstack[cstack.length - 1] = new RBNode(n._color, n.key, n.value, n.left, n.right, n._count);
  31968. for (var i = stack.length - 2; i >= 0; --i) {
  31969. var n = stack[i];
  31970. if (n.left === stack[i + 1]) {
  31971. cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i + 1], n.right, n._count);
  31972. } else {
  31973. cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
  31974. }
  31975. }
  31976. //Get node
  31977. n = cstack[cstack.length - 1];
  31978. //console.log("start remove: ", n.value)
  31979. //If not leaf, then swap with previous node
  31980. if (n.left && n.right) {
  31981. //console.log("moving to leaf")
  31982. //First walk to previous leaf
  31983. var split = cstack.length;
  31984. n = n.left;
  31985. while (n.right) {
  31986. cstack.push(n);
  31987. n = n.right;
  31988. }
  31989. //Copy path to leaf
  31990. var v = cstack[split - 1];
  31991. cstack.push(new RBNode(n._color, v.key, v.value, n.left, n.right, n._count));
  31992. cstack[split - 1].key = n.key;
  31993. cstack[split - 1].value = n.value;
  31994. //Fix up stack
  31995. for (var i = cstack.length - 2; i >= split; --i) {
  31996. n = cstack[i];
  31997. cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
  31998. }
  31999. cstack[split - 1].left = cstack[split];
  32000. }
  32001. //console.log("stack=", cstack.map(function(v) { return v.value }))
  32002. //Remove leaf node
  32003. n = cstack[cstack.length - 1];
  32004. if (n._color === RED) {
  32005. //Easy case: removing red leaf
  32006. //console.log("RED leaf")
  32007. var p = cstack[cstack.length - 2];
  32008. if (p.left === n) {
  32009. p.left = null;
  32010. } else if (p.right === n) {
  32011. p.right = null;
  32012. }
  32013. cstack.pop();
  32014. for (var i = 0; i < cstack.length; ++i) {
  32015. cstack[i]._count--;
  32016. }
  32017. return new RedBlackTree(this.tree._compare, cstack[0]);
  32018. } else {
  32019. if (n.left || n.right) {
  32020. //Second easy case: Single child black parent
  32021. //console.log("BLACK single child")
  32022. if (n.left) {
  32023. swapNode(n, n.left);
  32024. } else if (n.right) {
  32025. swapNode(n, n.right);
  32026. }
  32027. //Child must be red, so repaint it black to balance color
  32028. n._color = BLACK;
  32029. for (var i = 0; i < cstack.length - 1; ++i) {
  32030. cstack[i]._count--;
  32031. }
  32032. return new RedBlackTree(this.tree._compare, cstack[0]);
  32033. } else if (cstack.length === 1) {
  32034. //Third easy case: root
  32035. //console.log("ROOT")
  32036. return new RedBlackTree(this.tree._compare, null);
  32037. } else {
  32038. //Hard case: Repaint n, and then do some nasty stuff
  32039. //console.log("BLACK leaf no children")
  32040. for (var i = 0; i < cstack.length; ++i) {
  32041. cstack[i]._count--;
  32042. }
  32043. var parent = cstack[cstack.length - 2];
  32044. fixDoubleBlack(cstack);
  32045. //Fix up links
  32046. if (parent.left === n) {
  32047. parent.left = null;
  32048. } else {
  32049. parent.right = null;
  32050. }
  32051. }
  32052. }
  32053. return new RedBlackTree(this.tree._compare, cstack[0]);
  32054. };
  32055. //Returns key
  32056. Object.defineProperty(iproto, "key", {
  32057. get: function get() {
  32058. if (this._stack.length > 0) {
  32059. return this._stack[this._stack.length - 1].key;
  32060. }
  32061. return;
  32062. },
  32063. enumerable: true
  32064. });
  32065. //Returns value
  32066. Object.defineProperty(iproto, "value", {
  32067. get: function get() {
  32068. if (this._stack.length > 0) {
  32069. return this._stack[this._stack.length - 1].value;
  32070. }
  32071. return;
  32072. },
  32073. enumerable: true
  32074. });
  32075. //Returns the position of this iterator in the sorted list
  32076. Object.defineProperty(iproto, "index", {
  32077. get: function get() {
  32078. var idx = 0;
  32079. var stack = this._stack;
  32080. if (stack.length === 0) {
  32081. var r = this.tree.root;
  32082. if (r) {
  32083. return r._count;
  32084. }
  32085. return 0;
  32086. } else if (stack[stack.length - 1].left) {
  32087. idx = stack[stack.length - 1].left._count;
  32088. }
  32089. for (var s = stack.length - 2; s >= 0; --s) {
  32090. if (stack[s + 1] === stack[s].right) {
  32091. ++idx;
  32092. if (stack[s].left) {
  32093. idx += stack[s].left._count;
  32094. }
  32095. }
  32096. }
  32097. return idx;
  32098. },
  32099. enumerable: true
  32100. });
  32101. //Advances iterator to next element in list
  32102. iproto.next = function () {
  32103. var stack = this._stack;
  32104. if (stack.length === 0) {
  32105. return;
  32106. }
  32107. var n = stack[stack.length - 1];
  32108. if (n.right) {
  32109. n = n.right;
  32110. while (n) {
  32111. stack.push(n);
  32112. n = n.left;
  32113. }
  32114. } else {
  32115. stack.pop();
  32116. while (stack.length > 0 && stack[stack.length - 1].right === n) {
  32117. n = stack[stack.length - 1];
  32118. stack.pop();
  32119. }
  32120. }
  32121. };
  32122. //Checks if iterator is at end of tree
  32123. Object.defineProperty(iproto, "hasNext", {
  32124. get: function get() {
  32125. var stack = this._stack;
  32126. if (stack.length === 0) {
  32127. return false;
  32128. }
  32129. if (stack[stack.length - 1].right) {
  32130. return true;
  32131. }
  32132. for (var s = stack.length - 1; s > 0; --s) {
  32133. if (stack[s - 1].left === stack[s]) {
  32134. return true;
  32135. }
  32136. }
  32137. return false;
  32138. }
  32139. });
  32140. //Update value
  32141. iproto.update = function (value) {
  32142. var stack = this._stack;
  32143. if (stack.length === 0) {
  32144. throw new Error("Can't update empty node!");
  32145. }
  32146. var cstack = new Array(stack.length);
  32147. var n = stack[stack.length - 1];
  32148. cstack[cstack.length - 1] = new RBNode(n._color, n.key, value, n.left, n.right, n._count);
  32149. for (var i = stack.length - 2; i >= 0; --i) {
  32150. n = stack[i];
  32151. if (n.left === stack[i + 1]) {
  32152. cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i + 1], n.right, n._count);
  32153. } else {
  32154. cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
  32155. }
  32156. }
  32157. return new RedBlackTree(this.tree._compare, cstack[0]);
  32158. };
  32159. //Moves iterator backward one element
  32160. iproto.prev = function () {
  32161. var stack = this._stack;
  32162. if (stack.length === 0) {
  32163. return;
  32164. }
  32165. var n = stack[stack.length - 1];
  32166. if (n.left) {
  32167. n = n.left;
  32168. while (n) {
  32169. stack.push(n);
  32170. n = n.right;
  32171. }
  32172. } else {
  32173. stack.pop();
  32174. while (stack.length > 0 && stack[stack.length - 1].left === n) {
  32175. n = stack[stack.length - 1];
  32176. stack.pop();
  32177. }
  32178. }
  32179. };
  32180. //Checks if iterator is at start of tree
  32181. Object.defineProperty(iproto, "hasPrev", {
  32182. get: function get() {
  32183. var stack = this._stack;
  32184. if (stack.length === 0) {
  32185. return false;
  32186. }
  32187. if (stack[stack.length - 1].left) {
  32188. return true;
  32189. }
  32190. for (var s = stack.length - 1; s > 0; --s) {
  32191. if (stack[s - 1].right === stack[s]) {
  32192. return true;
  32193. }
  32194. }
  32195. return false;
  32196. }
  32197. });
  32198. //Default comparison function
  32199. function defaultCompare(a, b) {
  32200. if (a < b) {
  32201. return -1;
  32202. }
  32203. if (a > b) {
  32204. return 1;
  32205. }
  32206. return 0;
  32207. }
  32208. //Build a tree
  32209. function createRBTree(compare) {
  32210. return new RedBlackTree(compare || defaultCompare, null);
  32211. }
  32212. },{}],84:[function(require,module,exports){
  32213. module.exports={
  32214. "builtin": {
  32215. "Array": false,
  32216. "ArrayBuffer": false,
  32217. "Atomics": false,
  32218. "BigInt": false,
  32219. "BigInt64Array": false,
  32220. "BigUint64Array": false,
  32221. "Boolean": false,
  32222. "constructor": false,
  32223. "DataView": false,
  32224. "Date": false,
  32225. "decodeURI": false,
  32226. "decodeURIComponent": false,
  32227. "encodeURI": false,
  32228. "encodeURIComponent": false,
  32229. "Error": false,
  32230. "escape": false,
  32231. "eval": false,
  32232. "EvalError": false,
  32233. "Float32Array": false,
  32234. "Float64Array": false,
  32235. "Function": false,
  32236. "hasOwnProperty": false,
  32237. "Infinity": false,
  32238. "Int16Array": false,
  32239. "Int32Array": false,
  32240. "Int8Array": false,
  32241. "isFinite": false,
  32242. "isNaN": false,
  32243. "isPrototypeOf": false,
  32244. "JSON": false,
  32245. "Map": false,
  32246. "Math": false,
  32247. "NaN": false,
  32248. "Number": false,
  32249. "Object": false,
  32250. "parseFloat": false,
  32251. "parseInt": false,
  32252. "Promise": false,
  32253. "propertyIsEnumerable": false,
  32254. "Proxy": false,
  32255. "RangeError": false,
  32256. "ReferenceError": false,
  32257. "Reflect": false,
  32258. "RegExp": false,
  32259. "Set": false,
  32260. "SharedArrayBuffer": false,
  32261. "String": false,
  32262. "Symbol": false,
  32263. "SyntaxError": false,
  32264. "toLocaleString": false,
  32265. "toString": false,
  32266. "TypeError": false,
  32267. "Uint16Array": false,
  32268. "Uint32Array": false,
  32269. "Uint8Array": false,
  32270. "Uint8ClampedArray": false,
  32271. "undefined": false,
  32272. "unescape": false,
  32273. "URIError": false,
  32274. "valueOf": false,
  32275. "WeakMap": false,
  32276. "WeakSet": false
  32277. },
  32278. "es5": {
  32279. "Array": false,
  32280. "Boolean": false,
  32281. "constructor": false,
  32282. "Date": false,
  32283. "decodeURI": false,
  32284. "decodeURIComponent": false,
  32285. "encodeURI": false,
  32286. "encodeURIComponent": false,
  32287. "Error": false,
  32288. "escape": false,
  32289. "eval": false,
  32290. "EvalError": false,
  32291. "Function": false,
  32292. "hasOwnProperty": false,
  32293. "Infinity": false,
  32294. "isFinite": false,
  32295. "isNaN": false,
  32296. "isPrototypeOf": false,
  32297. "JSON": false,
  32298. "Math": false,
  32299. "NaN": false,
  32300. "Number": false,
  32301. "Object": false,
  32302. "parseFloat": false,
  32303. "parseInt": false,
  32304. "propertyIsEnumerable": false,
  32305. "RangeError": false,
  32306. "ReferenceError": false,
  32307. "RegExp": false,
  32308. "String": false,
  32309. "SyntaxError": false,
  32310. "toLocaleString": false,
  32311. "toString": false,
  32312. "TypeError": false,
  32313. "undefined": false,
  32314. "unescape": false,
  32315. "URIError": false,
  32316. "valueOf": false
  32317. },
  32318. "es2015": {
  32319. "Array": false,
  32320. "ArrayBuffer": false,
  32321. "Boolean": false,
  32322. "constructor": false,
  32323. "DataView": false,
  32324. "Date": false,
  32325. "decodeURI": false,
  32326. "decodeURIComponent": false,
  32327. "encodeURI": false,
  32328. "encodeURIComponent": false,
  32329. "Error": false,
  32330. "escape": false,
  32331. "eval": false,
  32332. "EvalError": false,
  32333. "Float32Array": false,
  32334. "Float64Array": false,
  32335. "Function": false,
  32336. "hasOwnProperty": false,
  32337. "Infinity": false,
  32338. "Int16Array": false,
  32339. "Int32Array": false,
  32340. "Int8Array": false,
  32341. "isFinite": false,
  32342. "isNaN": false,
  32343. "isPrototypeOf": false,
  32344. "JSON": false,
  32345. "Map": false,
  32346. "Math": false,
  32347. "NaN": false,
  32348. "Number": false,
  32349. "Object": false,
  32350. "parseFloat": false,
  32351. "parseInt": false,
  32352. "Promise": false,
  32353. "propertyIsEnumerable": false,
  32354. "Proxy": false,
  32355. "RangeError": false,
  32356. "ReferenceError": false,
  32357. "Reflect": false,
  32358. "RegExp": false,
  32359. "Set": false,
  32360. "String": false,
  32361. "Symbol": false,
  32362. "SyntaxError": false,
  32363. "toLocaleString": false,
  32364. "toString": false,
  32365. "TypeError": false,
  32366. "Uint16Array": false,
  32367. "Uint32Array": false,
  32368. "Uint8Array": false,
  32369. "Uint8ClampedArray": false,
  32370. "undefined": false,
  32371. "unescape": false,
  32372. "URIError": false,
  32373. "valueOf": false,
  32374. "WeakMap": false,
  32375. "WeakSet": false
  32376. },
  32377. "es2017": {
  32378. "Array": false,
  32379. "ArrayBuffer": false,
  32380. "Atomics": false,
  32381. "Boolean": false,
  32382. "constructor": false,
  32383. "DataView": false,
  32384. "Date": false,
  32385. "decodeURI": false,
  32386. "decodeURIComponent": false,
  32387. "encodeURI": false,
  32388. "encodeURIComponent": false,
  32389. "Error": false,
  32390. "escape": false,
  32391. "eval": false,
  32392. "EvalError": false,
  32393. "Float32Array": false,
  32394. "Float64Array": false,
  32395. "Function": false,
  32396. "hasOwnProperty": false,
  32397. "Infinity": false,
  32398. "Int16Array": false,
  32399. "Int32Array": false,
  32400. "Int8Array": false,
  32401. "isFinite": false,
  32402. "isNaN": false,
  32403. "isPrototypeOf": false,
  32404. "JSON": false,
  32405. "Map": false,
  32406. "Math": false,
  32407. "NaN": false,
  32408. "Number": false,
  32409. "Object": false,
  32410. "parseFloat": false,
  32411. "parseInt": false,
  32412. "Promise": false,
  32413. "propertyIsEnumerable": false,
  32414. "Proxy": false,
  32415. "RangeError": false,
  32416. "ReferenceError": false,
  32417. "Reflect": false,
  32418. "RegExp": false,
  32419. "Set": false,
  32420. "SharedArrayBuffer": false,
  32421. "String": false,
  32422. "Symbol": false,
  32423. "SyntaxError": false,
  32424. "toLocaleString": false,
  32425. "toString": false,
  32426. "TypeError": false,
  32427. "Uint16Array": false,
  32428. "Uint32Array": false,
  32429. "Uint8Array": false,
  32430. "Uint8ClampedArray": false,
  32431. "undefined": false,
  32432. "unescape": false,
  32433. "URIError": false,
  32434. "valueOf": false,
  32435. "WeakMap": false,
  32436. "WeakSet": false
  32437. },
  32438. "browser": {
  32439. "AbortController": false,
  32440. "AbortSignal": false,
  32441. "addEventListener": false,
  32442. "alert": false,
  32443. "AnalyserNode": false,
  32444. "Animation": false,
  32445. "AnimationEffectReadOnly": false,
  32446. "AnimationEffectTiming": false,
  32447. "AnimationEffectTimingReadOnly": false,
  32448. "AnimationEvent": false,
  32449. "AnimationPlaybackEvent": false,
  32450. "AnimationTimeline": false,
  32451. "applicationCache": false,
  32452. "ApplicationCache": false,
  32453. "ApplicationCacheErrorEvent": false,
  32454. "atob": false,
  32455. "Attr": false,
  32456. "Audio": false,
  32457. "AudioBuffer": false,
  32458. "AudioBufferSourceNode": false,
  32459. "AudioContext": false,
  32460. "AudioDestinationNode": false,
  32461. "AudioListener": false,
  32462. "AudioNode": false,
  32463. "AudioParam": false,
  32464. "AudioProcessingEvent": false,
  32465. "AudioScheduledSourceNode": false,
  32466. "AudioWorkletGlobalScope ": false,
  32467. "AudioWorkletNode": false,
  32468. "AudioWorkletProcessor": false,
  32469. "BarProp": false,
  32470. "BaseAudioContext": false,
  32471. "BatteryManager": false,
  32472. "BeforeUnloadEvent": false,
  32473. "BiquadFilterNode": false,
  32474. "Blob": false,
  32475. "BlobEvent": false,
  32476. "blur": false,
  32477. "BroadcastChannel": false,
  32478. "btoa": false,
  32479. "BudgetService": false,
  32480. "ByteLengthQueuingStrategy": false,
  32481. "Cache": false,
  32482. "caches": false,
  32483. "CacheStorage": false,
  32484. "cancelAnimationFrame": false,
  32485. "cancelIdleCallback": false,
  32486. "CanvasCaptureMediaStreamTrack": false,
  32487. "CanvasGradient": false,
  32488. "CanvasPattern": false,
  32489. "CanvasRenderingContext2D": false,
  32490. "ChannelMergerNode": false,
  32491. "ChannelSplitterNode": false,
  32492. "CharacterData": false,
  32493. "clearInterval": false,
  32494. "clearTimeout": false,
  32495. "clientInformation": false,
  32496. "ClipboardEvent": false,
  32497. "close": false,
  32498. "closed": false,
  32499. "CloseEvent": false,
  32500. "Comment": false,
  32501. "CompositionEvent": false,
  32502. "confirm": false,
  32503. "console": false,
  32504. "ConstantSourceNode": false,
  32505. "ConvolverNode": false,
  32506. "CountQueuingStrategy": false,
  32507. "createImageBitmap": false,
  32508. "Credential": false,
  32509. "CredentialsContainer": false,
  32510. "crypto": false,
  32511. "Crypto": false,
  32512. "CryptoKey": false,
  32513. "CSS": false,
  32514. "CSSConditionRule": false,
  32515. "CSSFontFaceRule": false,
  32516. "CSSGroupingRule": false,
  32517. "CSSImportRule": false,
  32518. "CSSKeyframeRule": false,
  32519. "CSSKeyframesRule": false,
  32520. "CSSMediaRule": false,
  32521. "CSSNamespaceRule": false,
  32522. "CSSPageRule": false,
  32523. "CSSRule": false,
  32524. "CSSRuleList": false,
  32525. "CSSStyleDeclaration": false,
  32526. "CSSStyleRule": false,
  32527. "CSSStyleSheet": false,
  32528. "CSSSupportsRule": false,
  32529. "CustomElementRegistry": false,
  32530. "customElements": false,
  32531. "CustomEvent": false,
  32532. "DataTransfer": false,
  32533. "DataTransferItem": false,
  32534. "DataTransferItemList": false,
  32535. "defaultstatus": false,
  32536. "defaultStatus": false,
  32537. "DelayNode": false,
  32538. "DeviceMotionEvent": false,
  32539. "DeviceOrientationEvent": false,
  32540. "devicePixelRatio": false,
  32541. "dispatchEvent": false,
  32542. "document": false,
  32543. "Document": false,
  32544. "DocumentFragment": false,
  32545. "DocumentType": false,
  32546. "DOMError": false,
  32547. "DOMException": false,
  32548. "DOMImplementation": false,
  32549. "DOMMatrix": false,
  32550. "DOMMatrixReadOnly": false,
  32551. "DOMParser": false,
  32552. "DOMPoint": false,
  32553. "DOMPointReadOnly": false,
  32554. "DOMQuad": false,
  32555. "DOMRect": false,
  32556. "DOMRectReadOnly": false,
  32557. "DOMStringList": false,
  32558. "DOMStringMap": false,
  32559. "DOMTokenList": false,
  32560. "DragEvent": false,
  32561. "DynamicsCompressorNode": false,
  32562. "Element": false,
  32563. "ErrorEvent": false,
  32564. "event": false,
  32565. "Event": false,
  32566. "EventSource": false,
  32567. "EventTarget": false,
  32568. "external": false,
  32569. "fetch": false,
  32570. "File": false,
  32571. "FileList": false,
  32572. "FileReader": false,
  32573. "find": false,
  32574. "focus": false,
  32575. "FocusEvent": false,
  32576. "FontFace": false,
  32577. "FontFaceSetLoadEvent": false,
  32578. "FormData": false,
  32579. "frameElement": false,
  32580. "frames": false,
  32581. "GainNode": false,
  32582. "Gamepad": false,
  32583. "GamepadButton": false,
  32584. "GamepadEvent": false,
  32585. "getComputedStyle": false,
  32586. "getSelection": false,
  32587. "HashChangeEvent": false,
  32588. "Headers": false,
  32589. "history": false,
  32590. "History": false,
  32591. "HTMLAllCollection": false,
  32592. "HTMLAnchorElement": false,
  32593. "HTMLAreaElement": false,
  32594. "HTMLAudioElement": false,
  32595. "HTMLBaseElement": false,
  32596. "HTMLBodyElement": false,
  32597. "HTMLBRElement": false,
  32598. "HTMLButtonElement": false,
  32599. "HTMLCanvasElement": false,
  32600. "HTMLCollection": false,
  32601. "HTMLContentElement": false,
  32602. "HTMLDataElement": false,
  32603. "HTMLDataListElement": false,
  32604. "HTMLDetailsElement": false,
  32605. "HTMLDialogElement": false,
  32606. "HTMLDirectoryElement": false,
  32607. "HTMLDivElement": false,
  32608. "HTMLDListElement": false,
  32609. "HTMLDocument": false,
  32610. "HTMLElement": false,
  32611. "HTMLEmbedElement": false,
  32612. "HTMLFieldSetElement": false,
  32613. "HTMLFontElement": false,
  32614. "HTMLFormControlsCollection": false,
  32615. "HTMLFormElement": false,
  32616. "HTMLFrameElement": false,
  32617. "HTMLFrameSetElement": false,
  32618. "HTMLHeadElement": false,
  32619. "HTMLHeadingElement": false,
  32620. "HTMLHRElement": false,
  32621. "HTMLHtmlElement": false,
  32622. "HTMLIFrameElement": false,
  32623. "HTMLImageElement": false,
  32624. "HTMLInputElement": false,
  32625. "HTMLLabelElement": false,
  32626. "HTMLLegendElement": false,
  32627. "HTMLLIElement": false,
  32628. "HTMLLinkElement": false,
  32629. "HTMLMapElement": false,
  32630. "HTMLMarqueeElement": false,
  32631. "HTMLMediaElement": false,
  32632. "HTMLMenuElement": false,
  32633. "HTMLMetaElement": false,
  32634. "HTMLMeterElement": false,
  32635. "HTMLModElement": false,
  32636. "HTMLObjectElement": false,
  32637. "HTMLOListElement": false,
  32638. "HTMLOptGroupElement": false,
  32639. "HTMLOptionElement": false,
  32640. "HTMLOptionsCollection": false,
  32641. "HTMLOutputElement": false,
  32642. "HTMLParagraphElement": false,
  32643. "HTMLParamElement": false,
  32644. "HTMLPictureElement": false,
  32645. "HTMLPreElement": false,
  32646. "HTMLProgressElement": false,
  32647. "HTMLQuoteElement": false,
  32648. "HTMLScriptElement": false,
  32649. "HTMLSelectElement": false,
  32650. "HTMLShadowElement": false,
  32651. "HTMLSlotElement": false,
  32652. "HTMLSourceElement": false,
  32653. "HTMLSpanElement": false,
  32654. "HTMLStyleElement": false,
  32655. "HTMLTableCaptionElement": false,
  32656. "HTMLTableCellElement": false,
  32657. "HTMLTableColElement": false,
  32658. "HTMLTableElement": false,
  32659. "HTMLTableRowElement": false,
  32660. "HTMLTableSectionElement": false,
  32661. "HTMLTemplateElement": false,
  32662. "HTMLTextAreaElement": false,
  32663. "HTMLTimeElement": false,
  32664. "HTMLTitleElement": false,
  32665. "HTMLTrackElement": false,
  32666. "HTMLUListElement": false,
  32667. "HTMLUnknownElement": false,
  32668. "HTMLVideoElement": false,
  32669. "IDBCursor": false,
  32670. "IDBCursorWithValue": false,
  32671. "IDBDatabase": false,
  32672. "IDBFactory": false,
  32673. "IDBIndex": false,
  32674. "IDBKeyRange": false,
  32675. "IDBObjectStore": false,
  32676. "IDBOpenDBRequest": false,
  32677. "IDBRequest": false,
  32678. "IDBTransaction": false,
  32679. "IDBVersionChangeEvent": false,
  32680. "IdleDeadline": false,
  32681. "IIRFilterNode": false,
  32682. "Image": false,
  32683. "ImageBitmap": false,
  32684. "ImageBitmapRenderingContext": false,
  32685. "ImageCapture": false,
  32686. "ImageData": false,
  32687. "indexedDB": false,
  32688. "innerHeight": false,
  32689. "innerWidth": false,
  32690. "InputEvent": false,
  32691. "IntersectionObserver": false,
  32692. "IntersectionObserverEntry": false,
  32693. "Intl": false,
  32694. "isSecureContext": false,
  32695. "KeyboardEvent": false,
  32696. "KeyframeEffect": false,
  32697. "KeyframeEffectReadOnly": false,
  32698. "length": false,
  32699. "localStorage": false,
  32700. "location": false,
  32701. "Location": false,
  32702. "locationbar": false,
  32703. "matchMedia": false,
  32704. "MediaDeviceInfo": false,
  32705. "MediaDevices": false,
  32706. "MediaElementAudioSourceNode": false,
  32707. "MediaEncryptedEvent": false,
  32708. "MediaError": false,
  32709. "MediaKeyMessageEvent": false,
  32710. "MediaKeySession": false,
  32711. "MediaKeyStatusMap": false,
  32712. "MediaKeySystemAccess": false,
  32713. "MediaList": false,
  32714. "MediaQueryList": false,
  32715. "MediaQueryListEvent": false,
  32716. "MediaRecorder": false,
  32717. "MediaSettingsRange": false,
  32718. "MediaSource": false,
  32719. "MediaStream": false,
  32720. "MediaStreamAudioDestinationNode": false,
  32721. "MediaStreamAudioSourceNode": false,
  32722. "MediaStreamEvent": false,
  32723. "MediaStreamTrack": false,
  32724. "MediaStreamTrackEvent": false,
  32725. "menubar": false,
  32726. "MessageChannel": false,
  32727. "MessageEvent": false,
  32728. "MessagePort": false,
  32729. "MIDIAccess": false,
  32730. "MIDIConnectionEvent": false,
  32731. "MIDIInput": false,
  32732. "MIDIInputMap": false,
  32733. "MIDIMessageEvent": false,
  32734. "MIDIOutput": false,
  32735. "MIDIOutputMap": false,
  32736. "MIDIPort": false,
  32737. "MimeType": false,
  32738. "MimeTypeArray": false,
  32739. "MouseEvent": false,
  32740. "moveBy": false,
  32741. "moveTo": false,
  32742. "MutationEvent": false,
  32743. "MutationObserver": false,
  32744. "MutationRecord": false,
  32745. "name": false,
  32746. "NamedNodeMap": false,
  32747. "NavigationPreloadManager": false,
  32748. "navigator": false,
  32749. "Navigator": false,
  32750. "NetworkInformation": false,
  32751. "Node": false,
  32752. "NodeFilter": false,
  32753. "NodeIterator": false,
  32754. "NodeList": false,
  32755. "Notification": false,
  32756. "OfflineAudioCompletionEvent": false,
  32757. "OfflineAudioContext": false,
  32758. "offscreenBuffering": false,
  32759. "OffscreenCanvas": true,
  32760. "onabort": true,
  32761. "onafterprint": true,
  32762. "onanimationend": true,
  32763. "onanimationiteration": true,
  32764. "onanimationstart": true,
  32765. "onappinstalled": true,
  32766. "onauxclick": true,
  32767. "onbeforeinstallprompt": true,
  32768. "onbeforeprint": true,
  32769. "onbeforeunload": true,
  32770. "onblur": true,
  32771. "oncancel": true,
  32772. "oncanplay": true,
  32773. "oncanplaythrough": true,
  32774. "onchange": true,
  32775. "onclick": true,
  32776. "onclose": true,
  32777. "oncontextmenu": true,
  32778. "oncuechange": true,
  32779. "ondblclick": true,
  32780. "ondevicemotion": true,
  32781. "ondeviceorientation": true,
  32782. "ondeviceorientationabsolute": true,
  32783. "ondrag": true,
  32784. "ondragend": true,
  32785. "ondragenter": true,
  32786. "ondragleave": true,
  32787. "ondragover": true,
  32788. "ondragstart": true,
  32789. "ondrop": true,
  32790. "ondurationchange": true,
  32791. "onemptied": true,
  32792. "onended": true,
  32793. "onerror": true,
  32794. "onfocus": true,
  32795. "ongotpointercapture": true,
  32796. "onhashchange": true,
  32797. "oninput": true,
  32798. "oninvalid": true,
  32799. "onkeydown": true,
  32800. "onkeypress": true,
  32801. "onkeyup": true,
  32802. "onlanguagechange": true,
  32803. "onload": true,
  32804. "onloadeddata": true,
  32805. "onloadedmetadata": true,
  32806. "onloadstart": true,
  32807. "onlostpointercapture": true,
  32808. "onmessage": true,
  32809. "onmessageerror": true,
  32810. "onmousedown": true,
  32811. "onmouseenter": true,
  32812. "onmouseleave": true,
  32813. "onmousemove": true,
  32814. "onmouseout": true,
  32815. "onmouseover": true,
  32816. "onmouseup": true,
  32817. "onmousewheel": true,
  32818. "onoffline": true,
  32819. "ononline": true,
  32820. "onpagehide": true,
  32821. "onpageshow": true,
  32822. "onpause": true,
  32823. "onplay": true,
  32824. "onplaying": true,
  32825. "onpointercancel": true,
  32826. "onpointerdown": true,
  32827. "onpointerenter": true,
  32828. "onpointerleave": true,
  32829. "onpointermove": true,
  32830. "onpointerout": true,
  32831. "onpointerover": true,
  32832. "onpointerup": true,
  32833. "onpopstate": true,
  32834. "onprogress": true,
  32835. "onratechange": true,
  32836. "onrejectionhandled": true,
  32837. "onreset": true,
  32838. "onresize": true,
  32839. "onscroll": true,
  32840. "onsearch": true,
  32841. "onseeked": true,
  32842. "onseeking": true,
  32843. "onselect": true,
  32844. "onstalled": true,
  32845. "onstorage": true,
  32846. "onsubmit": true,
  32847. "onsuspend": true,
  32848. "ontimeupdate": true,
  32849. "ontoggle": true,
  32850. "ontransitionend": true,
  32851. "onunhandledrejection": true,
  32852. "onunload": true,
  32853. "onvolumechange": true,
  32854. "onwaiting": true,
  32855. "onwheel": true,
  32856. "open": false,
  32857. "openDatabase": false,
  32858. "opener": false,
  32859. "Option": false,
  32860. "origin": false,
  32861. "OscillatorNode": false,
  32862. "outerHeight": false,
  32863. "outerWidth": false,
  32864. "PageTransitionEvent": false,
  32865. "pageXOffset": false,
  32866. "pageYOffset": false,
  32867. "PannerNode": false,
  32868. "parent": false,
  32869. "Path2D": false,
  32870. "PaymentAddress": false,
  32871. "PaymentRequest": false,
  32872. "PaymentRequestUpdateEvent": false,
  32873. "PaymentResponse": false,
  32874. "performance": false,
  32875. "Performance": false,
  32876. "PerformanceEntry": false,
  32877. "PerformanceLongTaskTiming": false,
  32878. "PerformanceMark": false,
  32879. "PerformanceMeasure": false,
  32880. "PerformanceNavigation": false,
  32881. "PerformanceNavigationTiming": false,
  32882. "PerformanceObserver": false,
  32883. "PerformanceObserverEntryList": false,
  32884. "PerformancePaintTiming": false,
  32885. "PerformanceResourceTiming": false,
  32886. "PerformanceTiming": false,
  32887. "PeriodicWave": false,
  32888. "Permissions": false,
  32889. "PermissionStatus": false,
  32890. "personalbar": false,
  32891. "PhotoCapabilities": false,
  32892. "Plugin": false,
  32893. "PluginArray": false,
  32894. "PointerEvent": false,
  32895. "PopStateEvent": false,
  32896. "postMessage": false,
  32897. "Presentation": false,
  32898. "PresentationAvailability": false,
  32899. "PresentationConnection": false,
  32900. "PresentationConnectionAvailableEvent": false,
  32901. "PresentationConnectionCloseEvent": false,
  32902. "PresentationConnectionList": false,
  32903. "PresentationReceiver": false,
  32904. "PresentationRequest": false,
  32905. "print": false,
  32906. "ProcessingInstruction": false,
  32907. "ProgressEvent": false,
  32908. "PromiseRejectionEvent": false,
  32909. "prompt": false,
  32910. "PushManager": false,
  32911. "PushSubscription": false,
  32912. "PushSubscriptionOptions": false,
  32913. "queueMicrotask": false,
  32914. "RadioNodeList": false,
  32915. "Range": false,
  32916. "ReadableStream": false,
  32917. "registerProcessor": false,
  32918. "RemotePlayback": false,
  32919. "removeEventListener": false,
  32920. "Request": false,
  32921. "requestAnimationFrame": false,
  32922. "requestIdleCallback": false,
  32923. "resizeBy": false,
  32924. "ResizeObserver": false,
  32925. "ResizeObserverEntry": false,
  32926. "resizeTo": false,
  32927. "Response": false,
  32928. "RTCCertificate": false,
  32929. "RTCDataChannel": false,
  32930. "RTCDataChannelEvent": false,
  32931. "RTCDtlsTransport": false,
  32932. "RTCIceCandidate": false,
  32933. "RTCIceGatherer": false,
  32934. "RTCIceTransport": false,
  32935. "RTCPeerConnection": false,
  32936. "RTCPeerConnectionIceEvent": false,
  32937. "RTCRtpContributingSource": false,
  32938. "RTCRtpReceiver": false,
  32939. "RTCRtpSender": false,
  32940. "RTCSctpTransport": false,
  32941. "RTCSessionDescription": false,
  32942. "RTCStatsReport": false,
  32943. "RTCTrackEvent": false,
  32944. "screen": false,
  32945. "Screen": false,
  32946. "screenLeft": false,
  32947. "ScreenOrientation": false,
  32948. "screenTop": false,
  32949. "screenX": false,
  32950. "screenY": false,
  32951. "ScriptProcessorNode": false,
  32952. "scroll": false,
  32953. "scrollbars": false,
  32954. "scrollBy": false,
  32955. "scrollTo": false,
  32956. "scrollX": false,
  32957. "scrollY": false,
  32958. "SecurityPolicyViolationEvent": false,
  32959. "Selection": false,
  32960. "self": false,
  32961. "ServiceWorker": false,
  32962. "ServiceWorkerContainer": false,
  32963. "ServiceWorkerRegistration": false,
  32964. "sessionStorage": false,
  32965. "setInterval": false,
  32966. "setTimeout": false,
  32967. "ShadowRoot": false,
  32968. "SharedWorker": false,
  32969. "SourceBuffer": false,
  32970. "SourceBufferList": false,
  32971. "speechSynthesis": false,
  32972. "SpeechSynthesisEvent": false,
  32973. "SpeechSynthesisUtterance": false,
  32974. "StaticRange": false,
  32975. "status": false,
  32976. "statusbar": false,
  32977. "StereoPannerNode": false,
  32978. "stop": false,
  32979. "Storage": false,
  32980. "StorageEvent": false,
  32981. "StorageManager": false,
  32982. "styleMedia": false,
  32983. "StyleSheet": false,
  32984. "StyleSheetList": false,
  32985. "SubtleCrypto": false,
  32986. "SVGAElement": false,
  32987. "SVGAngle": false,
  32988. "SVGAnimatedAngle": false,
  32989. "SVGAnimatedBoolean": false,
  32990. "SVGAnimatedEnumeration": false,
  32991. "SVGAnimatedInteger": false,
  32992. "SVGAnimatedLength": false,
  32993. "SVGAnimatedLengthList": false,
  32994. "SVGAnimatedNumber": false,
  32995. "SVGAnimatedNumberList": false,
  32996. "SVGAnimatedPreserveAspectRatio": false,
  32997. "SVGAnimatedRect": false,
  32998. "SVGAnimatedString": false,
  32999. "SVGAnimatedTransformList": false,
  33000. "SVGAnimateElement": false,
  33001. "SVGAnimateMotionElement": false,
  33002. "SVGAnimateTransformElement": false,
  33003. "SVGAnimationElement": false,
  33004. "SVGCircleElement": false,
  33005. "SVGClipPathElement": false,
  33006. "SVGComponentTransferFunctionElement": false,
  33007. "SVGDefsElement": false,
  33008. "SVGDescElement": false,
  33009. "SVGDiscardElement": false,
  33010. "SVGElement": false,
  33011. "SVGEllipseElement": false,
  33012. "SVGFEBlendElement": false,
  33013. "SVGFEColorMatrixElement": false,
  33014. "SVGFEComponentTransferElement": false,
  33015. "SVGFECompositeElement": false,
  33016. "SVGFEConvolveMatrixElement": false,
  33017. "SVGFEDiffuseLightingElement": false,
  33018. "SVGFEDisplacementMapElement": false,
  33019. "SVGFEDistantLightElement": false,
  33020. "SVGFEDropShadowElement": false,
  33021. "SVGFEFloodElement": false,
  33022. "SVGFEFuncAElement": false,
  33023. "SVGFEFuncBElement": false,
  33024. "SVGFEFuncGElement": false,
  33025. "SVGFEFuncRElement": false,
  33026. "SVGFEGaussianBlurElement": false,
  33027. "SVGFEImageElement": false,
  33028. "SVGFEMergeElement": false,
  33029. "SVGFEMergeNodeElement": false,
  33030. "SVGFEMorphologyElement": false,
  33031. "SVGFEOffsetElement": false,
  33032. "SVGFEPointLightElement": false,
  33033. "SVGFESpecularLightingElement": false,
  33034. "SVGFESpotLightElement": false,
  33035. "SVGFETileElement": false,
  33036. "SVGFETurbulenceElement": false,
  33037. "SVGFilterElement": false,
  33038. "SVGForeignObjectElement": false,
  33039. "SVGGElement": false,
  33040. "SVGGeometryElement": false,
  33041. "SVGGradientElement": false,
  33042. "SVGGraphicsElement": false,
  33043. "SVGImageElement": false,
  33044. "SVGLength": false,
  33045. "SVGLengthList": false,
  33046. "SVGLinearGradientElement": false,
  33047. "SVGLineElement": false,
  33048. "SVGMarkerElement": false,
  33049. "SVGMaskElement": false,
  33050. "SVGMatrix": false,
  33051. "SVGMetadataElement": false,
  33052. "SVGMPathElement": false,
  33053. "SVGNumber": false,
  33054. "SVGNumberList": false,
  33055. "SVGPathElement": false,
  33056. "SVGPatternElement": false,
  33057. "SVGPoint": false,
  33058. "SVGPointList": false,
  33059. "SVGPolygonElement": false,
  33060. "SVGPolylineElement": false,
  33061. "SVGPreserveAspectRatio": false,
  33062. "SVGRadialGradientElement": false,
  33063. "SVGRect": false,
  33064. "SVGRectElement": false,
  33065. "SVGScriptElement": false,
  33066. "SVGSetElement": false,
  33067. "SVGStopElement": false,
  33068. "SVGStringList": false,
  33069. "SVGStyleElement": false,
  33070. "SVGSVGElement": false,
  33071. "SVGSwitchElement": false,
  33072. "SVGSymbolElement": false,
  33073. "SVGTextContentElement": false,
  33074. "SVGTextElement": false,
  33075. "SVGTextPathElement": false,
  33076. "SVGTextPositioningElement": false,
  33077. "SVGTitleElement": false,
  33078. "SVGTransform": false,
  33079. "SVGTransformList": false,
  33080. "SVGTSpanElement": false,
  33081. "SVGUnitTypes": false,
  33082. "SVGUseElement": false,
  33083. "SVGViewElement": false,
  33084. "TaskAttributionTiming": false,
  33085. "Text": false,
  33086. "TextDecoder": false,
  33087. "TextEncoder": false,
  33088. "TextEvent": false,
  33089. "TextMetrics": false,
  33090. "TextTrack": false,
  33091. "TextTrackCue": false,
  33092. "TextTrackCueList": false,
  33093. "TextTrackList": false,
  33094. "TimeRanges": false,
  33095. "toolbar": false,
  33096. "top": false,
  33097. "Touch": false,
  33098. "TouchEvent": false,
  33099. "TouchList": false,
  33100. "TrackEvent": false,
  33101. "TransitionEvent": false,
  33102. "TreeWalker": false,
  33103. "UIEvent": false,
  33104. "URL": false,
  33105. "URLSearchParams": false,
  33106. "ValidityState": false,
  33107. "visualViewport": false,
  33108. "VisualViewport": false,
  33109. "VTTCue": false,
  33110. "WaveShaperNode": false,
  33111. "WebAssembly": false,
  33112. "WebGL2RenderingContext": false,
  33113. "WebGLActiveInfo": false,
  33114. "WebGLBuffer": false,
  33115. "WebGLContextEvent": false,
  33116. "WebGLFramebuffer": false,
  33117. "WebGLProgram": false,
  33118. "WebGLQuery": false,
  33119. "WebGLRenderbuffer": false,
  33120. "WebGLRenderingContext": false,
  33121. "WebGLSampler": false,
  33122. "WebGLShader": false,
  33123. "WebGLShaderPrecisionFormat": false,
  33124. "WebGLSync": false,
  33125. "WebGLTexture": false,
  33126. "WebGLTransformFeedback": false,
  33127. "WebGLUniformLocation": false,
  33128. "WebGLVertexArrayObject": false,
  33129. "WebSocket": false,
  33130. "WheelEvent": false,
  33131. "window": false,
  33132. "Window": false,
  33133. "Worker": false,
  33134. "WritableStream": false,
  33135. "XMLDocument": false,
  33136. "XMLHttpRequest": false,
  33137. "XMLHttpRequestEventTarget": false,
  33138. "XMLHttpRequestUpload": false,
  33139. "XMLSerializer": false,
  33140. "XPathEvaluator": false,
  33141. "XPathExpression": false,
  33142. "XPathResult": false,
  33143. "XSLTProcessor": false
  33144. },
  33145. "worker": {
  33146. "applicationCache": false,
  33147. "atob": false,
  33148. "Blob": false,
  33149. "BroadcastChannel": false,
  33150. "btoa": false,
  33151. "Cache": false,
  33152. "caches": false,
  33153. "clearInterval": false,
  33154. "clearTimeout": false,
  33155. "close": true,
  33156. "console": false,
  33157. "fetch": false,
  33158. "FileReaderSync": false,
  33159. "FormData": false,
  33160. "Headers": false,
  33161. "IDBCursor": false,
  33162. "IDBCursorWithValue": false,
  33163. "IDBDatabase": false,
  33164. "IDBFactory": false,
  33165. "IDBIndex": false,
  33166. "IDBKeyRange": false,
  33167. "IDBObjectStore": false,
  33168. "IDBOpenDBRequest": false,
  33169. "IDBRequest": false,
  33170. "IDBTransaction": false,
  33171. "IDBVersionChangeEvent": false,
  33172. "ImageData": false,
  33173. "importScripts": true,
  33174. "indexedDB": false,
  33175. "location": false,
  33176. "MessageChannel": false,
  33177. "MessagePort": false,
  33178. "name": false,
  33179. "navigator": false,
  33180. "Notification": false,
  33181. "onclose": true,
  33182. "onconnect": true,
  33183. "onerror": true,
  33184. "onlanguagechange": true,
  33185. "onmessage": true,
  33186. "onoffline": true,
  33187. "ononline": true,
  33188. "onrejectionhandled": true,
  33189. "onunhandledrejection": true,
  33190. "performance": false,
  33191. "Performance": false,
  33192. "PerformanceEntry": false,
  33193. "PerformanceMark": false,
  33194. "PerformanceMeasure": false,
  33195. "PerformanceNavigation": false,
  33196. "PerformanceResourceTiming": false,
  33197. "PerformanceTiming": false,
  33198. "postMessage": true,
  33199. "Promise": false,
  33200. "queueMicrotask": false,
  33201. "Request": false,
  33202. "Response": false,
  33203. "self": true,
  33204. "ServiceWorkerRegistration": false,
  33205. "setInterval": false,
  33206. "setTimeout": false,
  33207. "TextDecoder": false,
  33208. "TextEncoder": false,
  33209. "URL": false,
  33210. "URLSearchParams": false,
  33211. "WebSocket": false,
  33212. "Worker": false,
  33213. "WorkerGlobalScope": false,
  33214. "XMLHttpRequest": false
  33215. },
  33216. "node": {
  33217. "__dirname": false,
  33218. "__filename": false,
  33219. "Buffer": false,
  33220. "clearImmediate": false,
  33221. "clearInterval": false,
  33222. "clearTimeout": false,
  33223. "console": false,
  33224. "exports": true,
  33225. "global": false,
  33226. "Intl": false,
  33227. "module": false,
  33228. "process": false,
  33229. "queueMicrotask": false,
  33230. "require": false,
  33231. "setImmediate": false,
  33232. "setInterval": false,
  33233. "setTimeout": false,
  33234. "TextDecoder": false,
  33235. "TextEncoder": false,
  33236. "URL": false,
  33237. "URLSearchParams": false
  33238. },
  33239. "commonjs": {
  33240. "exports": true,
  33241. "global": false,
  33242. "module": false,
  33243. "require": false
  33244. },
  33245. "amd": {
  33246. "define": false,
  33247. "require": false
  33248. },
  33249. "mocha": {
  33250. "after": false,
  33251. "afterEach": false,
  33252. "before": false,
  33253. "beforeEach": false,
  33254. "context": false,
  33255. "describe": false,
  33256. "it": false,
  33257. "mocha": false,
  33258. "run": false,
  33259. "setup": false,
  33260. "specify": false,
  33261. "suite": false,
  33262. "suiteSetup": false,
  33263. "suiteTeardown": false,
  33264. "teardown": false,
  33265. "test": false,
  33266. "xcontext": false,
  33267. "xdescribe": false,
  33268. "xit": false,
  33269. "xspecify": false
  33270. },
  33271. "jasmine": {
  33272. "afterAll": false,
  33273. "afterEach": false,
  33274. "beforeAll": false,
  33275. "beforeEach": false,
  33276. "describe": false,
  33277. "expect": false,
  33278. "fail": false,
  33279. "fdescribe": false,
  33280. "fit": false,
  33281. "it": false,
  33282. "jasmine": false,
  33283. "pending": false,
  33284. "runs": false,
  33285. "spyOn": false,
  33286. "spyOnProperty": false,
  33287. "waits": false,
  33288. "waitsFor": false,
  33289. "xdescribe": false,
  33290. "xit": false
  33291. },
  33292. "jest": {
  33293. "afterAll": false,
  33294. "afterEach": false,
  33295. "beforeAll": false,
  33296. "beforeEach": false,
  33297. "describe": false,
  33298. "expect": false,
  33299. "fdescribe": false,
  33300. "fit": false,
  33301. "it": false,
  33302. "jest": false,
  33303. "pit": false,
  33304. "require": false,
  33305. "test": false,
  33306. "xdescribe": false,
  33307. "xit": false,
  33308. "xtest": false
  33309. },
  33310. "qunit": {
  33311. "asyncTest": false,
  33312. "deepEqual": false,
  33313. "equal": false,
  33314. "expect": false,
  33315. "module": false,
  33316. "notDeepEqual": false,
  33317. "notEqual": false,
  33318. "notOk": false,
  33319. "notPropEqual": false,
  33320. "notStrictEqual": false,
  33321. "ok": false,
  33322. "propEqual": false,
  33323. "QUnit": false,
  33324. "raises": false,
  33325. "start": false,
  33326. "stop": false,
  33327. "strictEqual": false,
  33328. "test": false,
  33329. "throws": false
  33330. },
  33331. "phantomjs": {
  33332. "console": true,
  33333. "exports": true,
  33334. "phantom": true,
  33335. "require": true,
  33336. "WebPage": true
  33337. },
  33338. "couch": {
  33339. "emit": false,
  33340. "exports": false,
  33341. "getRow": false,
  33342. "log": false,
  33343. "module": false,
  33344. "provides": false,
  33345. "require": false,
  33346. "respond": false,
  33347. "send": false,
  33348. "start": false,
  33349. "sum": false
  33350. },
  33351. "rhino": {
  33352. "defineClass": false,
  33353. "deserialize": false,
  33354. "gc": false,
  33355. "help": false,
  33356. "importClass": false,
  33357. "importPackage": false,
  33358. "java": false,
  33359. "load": false,
  33360. "loadClass": false,
  33361. "Packages": false,
  33362. "print": false,
  33363. "quit": false,
  33364. "readFile": false,
  33365. "readUrl": false,
  33366. "runCommand": false,
  33367. "seal": false,
  33368. "serialize": false,
  33369. "spawn": false,
  33370. "sync": false,
  33371. "toint32": false,
  33372. "version": false
  33373. },
  33374. "nashorn": {
  33375. "__DIR__": false,
  33376. "__FILE__": false,
  33377. "__LINE__": false,
  33378. "com": false,
  33379. "edu": false,
  33380. "exit": false,
  33381. "java": false,
  33382. "Java": false,
  33383. "javafx": false,
  33384. "JavaImporter": false,
  33385. "javax": false,
  33386. "JSAdapter": false,
  33387. "load": false,
  33388. "loadWithNewGlobal": false,
  33389. "org": false,
  33390. "Packages": false,
  33391. "print": false,
  33392. "quit": false
  33393. },
  33394. "wsh": {
  33395. "ActiveXObject": true,
  33396. "Enumerator": true,
  33397. "GetObject": true,
  33398. "ScriptEngine": true,
  33399. "ScriptEngineBuildVersion": true,
  33400. "ScriptEngineMajorVersion": true,
  33401. "ScriptEngineMinorVersion": true,
  33402. "VBArray": true,
  33403. "WScript": true,
  33404. "WSH": true,
  33405. "XDomainRequest": true
  33406. },
  33407. "jquery": {
  33408. "$": false,
  33409. "jQuery": false
  33410. },
  33411. "yui": {
  33412. "YAHOO": false,
  33413. "YAHOO_config": false,
  33414. "YUI": false,
  33415. "YUI_config": false
  33416. },
  33417. "shelljs": {
  33418. "cat": false,
  33419. "cd": false,
  33420. "chmod": false,
  33421. "config": false,
  33422. "cp": false,
  33423. "dirs": false,
  33424. "echo": false,
  33425. "env": false,
  33426. "error": false,
  33427. "exec": false,
  33428. "exit": false,
  33429. "find": false,
  33430. "grep": false,
  33431. "ln": false,
  33432. "ls": false,
  33433. "mkdir": false,
  33434. "mv": false,
  33435. "popd": false,
  33436. "pushd": false,
  33437. "pwd": false,
  33438. "rm": false,
  33439. "sed": false,
  33440. "set": false,
  33441. "target": false,
  33442. "tempdir": false,
  33443. "test": false,
  33444. "touch": false,
  33445. "which": false
  33446. },
  33447. "prototypejs": {
  33448. "$": false,
  33449. "$$": false,
  33450. "$A": false,
  33451. "$break": false,
  33452. "$continue": false,
  33453. "$F": false,
  33454. "$H": false,
  33455. "$R": false,
  33456. "$w": false,
  33457. "Abstract": false,
  33458. "Ajax": false,
  33459. "Autocompleter": false,
  33460. "Builder": false,
  33461. "Class": false,
  33462. "Control": false,
  33463. "Draggable": false,
  33464. "Draggables": false,
  33465. "Droppables": false,
  33466. "Effect": false,
  33467. "Element": false,
  33468. "Enumerable": false,
  33469. "Event": false,
  33470. "Field": false,
  33471. "Form": false,
  33472. "Hash": false,
  33473. "Insertion": false,
  33474. "ObjectRange": false,
  33475. "PeriodicalExecuter": false,
  33476. "Position": false,
  33477. "Prototype": false,
  33478. "Scriptaculous": false,
  33479. "Selector": false,
  33480. "Sortable": false,
  33481. "SortableObserver": false,
  33482. "Sound": false,
  33483. "Template": false,
  33484. "Toggle": false,
  33485. "Try": false
  33486. },
  33487. "meteor": {
  33488. "_": false,
  33489. "$": false,
  33490. "Accounts": false,
  33491. "AccountsClient": false,
  33492. "AccountsCommon": false,
  33493. "AccountsServer": false,
  33494. "App": false,
  33495. "Assets": false,
  33496. "Blaze": false,
  33497. "check": false,
  33498. "Cordova": false,
  33499. "DDP": false,
  33500. "DDPRateLimiter": false,
  33501. "DDPServer": false,
  33502. "Deps": false,
  33503. "EJSON": false,
  33504. "Email": false,
  33505. "HTTP": false,
  33506. "Log": false,
  33507. "Match": false,
  33508. "Meteor": false,
  33509. "Mongo": false,
  33510. "MongoInternals": false,
  33511. "Npm": false,
  33512. "Package": false,
  33513. "Plugin": false,
  33514. "process": false,
  33515. "Random": false,
  33516. "ReactiveDict": false,
  33517. "ReactiveVar": false,
  33518. "Router": false,
  33519. "ServiceConfiguration": false,
  33520. "Session": false,
  33521. "share": false,
  33522. "Spacebars": false,
  33523. "Template": false,
  33524. "Tinytest": false,
  33525. "Tracker": false,
  33526. "UI": false,
  33527. "Utils": false,
  33528. "WebApp": false,
  33529. "WebAppInternals": false
  33530. },
  33531. "mongo": {
  33532. "_isWindows": false,
  33533. "_rand": false,
  33534. "BulkWriteResult": false,
  33535. "cat": false,
  33536. "cd": false,
  33537. "connect": false,
  33538. "db": false,
  33539. "getHostName": false,
  33540. "getMemInfo": false,
  33541. "hostname": false,
  33542. "ISODate": false,
  33543. "listFiles": false,
  33544. "load": false,
  33545. "ls": false,
  33546. "md5sumFile": false,
  33547. "mkdir": false,
  33548. "Mongo": false,
  33549. "NumberInt": false,
  33550. "NumberLong": false,
  33551. "ObjectId": false,
  33552. "PlanCache": false,
  33553. "print": false,
  33554. "printjson": false,
  33555. "pwd": false,
  33556. "quit": false,
  33557. "removeFile": false,
  33558. "rs": false,
  33559. "sh": false,
  33560. "UUID": false,
  33561. "version": false,
  33562. "WriteResult": false
  33563. },
  33564. "applescript": {
  33565. "$": false,
  33566. "Application": false,
  33567. "Automation": false,
  33568. "console": false,
  33569. "delay": false,
  33570. "Library": false,
  33571. "ObjC": false,
  33572. "ObjectSpecifier": false,
  33573. "Path": false,
  33574. "Progress": false,
  33575. "Ref": false
  33576. },
  33577. "serviceworker": {
  33578. "Cache": false,
  33579. "caches": false,
  33580. "CacheStorage": false,
  33581. "Client": false,
  33582. "clients": false,
  33583. "Clients": false,
  33584. "ExtendableEvent": false,
  33585. "ExtendableMessageEvent": false,
  33586. "FetchEvent": false,
  33587. "importScripts": false,
  33588. "registration": false,
  33589. "self": false,
  33590. "ServiceWorker": false,
  33591. "ServiceWorkerContainer": false,
  33592. "ServiceWorkerGlobalScope": false,
  33593. "ServiceWorkerMessageEvent": false,
  33594. "ServiceWorkerRegistration": false,
  33595. "skipWaiting": false,
  33596. "WindowClient": false
  33597. },
  33598. "atomtest": {
  33599. "advanceClock": false,
  33600. "fakeClearInterval": false,
  33601. "fakeClearTimeout": false,
  33602. "fakeSetInterval": false,
  33603. "fakeSetTimeout": false,
  33604. "resetTimeouts": false,
  33605. "waitsForPromise": false
  33606. },
  33607. "embertest": {
  33608. "andThen": false,
  33609. "click": false,
  33610. "currentPath": false,
  33611. "currentRouteName": false,
  33612. "currentURL": false,
  33613. "fillIn": false,
  33614. "find": false,
  33615. "findAll": false,
  33616. "findWithAssert": false,
  33617. "keyEvent": false,
  33618. "pauseTest": false,
  33619. "resumeTest": false,
  33620. "triggerEvent": false,
  33621. "visit": false,
  33622. "wait": false
  33623. },
  33624. "protractor": {
  33625. "$": false,
  33626. "$$": false,
  33627. "browser": false,
  33628. "by": false,
  33629. "By": false,
  33630. "DartObject": false,
  33631. "element": false,
  33632. "protractor": false
  33633. },
  33634. "shared-node-browser": {
  33635. "clearInterval": false,
  33636. "clearTimeout": false,
  33637. "console": false,
  33638. "setInterval": false,
  33639. "setTimeout": false,
  33640. "URL": false,
  33641. "URLSearchParams": false
  33642. },
  33643. "webextensions": {
  33644. "browser": false,
  33645. "chrome": false,
  33646. "opr": false
  33647. },
  33648. "greasemonkey": {
  33649. "GM": false,
  33650. "GM_addStyle": false,
  33651. "GM_deleteValue": false,
  33652. "GM_getResourceText": false,
  33653. "GM_getResourceURL": false,
  33654. "GM_getValue": false,
  33655. "GM_info": false,
  33656. "GM_listValues": false,
  33657. "GM_log": false,
  33658. "GM_openInTab": false,
  33659. "GM_registerMenuCommand": false,
  33660. "GM_setClipboard": false,
  33661. "GM_setValue": false,
  33662. "GM_xmlhttpRequest": false,
  33663. "unsafeWindow": false
  33664. },
  33665. "devtools": {
  33666. "$": false,
  33667. "$_": false,
  33668. "$$": false,
  33669. "$0": false,
  33670. "$1": false,
  33671. "$2": false,
  33672. "$3": false,
  33673. "$4": false,
  33674. "$x": false,
  33675. "chrome": false,
  33676. "clear": false,
  33677. "copy": false,
  33678. "debug": false,
  33679. "dir": false,
  33680. "dirxml": false,
  33681. "getEventListeners": false,
  33682. "inspect": false,
  33683. "keys": false,
  33684. "monitor": false,
  33685. "monitorEvents": false,
  33686. "profile": false,
  33687. "profileEnd": false,
  33688. "queryObjects": false,
  33689. "table": false,
  33690. "undebug": false,
  33691. "unmonitor": false,
  33692. "unmonitorEvents": false,
  33693. "values": false
  33694. }
  33695. }
  33696. },{}],85:[function(require,module,exports){
  33697. 'use strict';
  33698. module.exports = require('./globals.json');
  33699. },{"./globals.json":84}],86:[function(require,module,exports){
  33700. (function (process){
  33701. 'use strict';
  33702. 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; }; }();
  33703. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33704. // A simple implementation of make-array
  33705. function make_array(subject) {
  33706. return Array.isArray(subject) ? subject : [subject];
  33707. }
  33708. var REGEX_BLANK_LINE = /^\s+$/;
  33709. var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
  33710. var REGEX_LEADING_EXCAPED_HASH = /^\\#/;
  33711. var SLASH = '/';
  33712. var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
  33713. /* istanbul ignore next */
  33714. : 'node-ignore';
  33715. var define = function define(object, key, value) {
  33716. return Object.defineProperty(object, key, { value: value });
  33717. };
  33718. var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
  33719. // Sanitize the range of a regular expression
  33720. // The cases are complicated, see test cases for details
  33721. var sanitizeRange = function sanitizeRange(range) {
  33722. return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
  33723. return from.charCodeAt(0) <= to.charCodeAt(0) ? match
  33724. // Invalid range (out of order) which is ok for gitignore rules but
  33725. // fatal for JavaScript regular expression, so eliminate it.
  33726. : '';
  33727. });
  33728. };
  33729. // > If the pattern ends with a slash,
  33730. // > it is removed for the purpose of the following description,
  33731. // > but it would only find a match with a directory.
  33732. // > In other words, foo/ will match a directory foo and paths underneath it,
  33733. // > but will not match a regular file or a symbolic link foo
  33734. // > (this is consistent with the way how pathspec works in general in Git).
  33735. // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
  33736. // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
  33737. // you could use option `mark: true` with `glob`
  33738. // '`foo/`' should not continue with the '`..`'
  33739. var DEFAULT_REPLACER_PREFIX = [
  33740. // > Trailing spaces are ignored unless they are quoted with backslash ("\")
  33741. [
  33742. // (a\ ) -> (a )
  33743. // (a ) -> (a)
  33744. // (a \ ) -> (a )
  33745. /\\?\s+$/, function (match) {
  33746. return match.indexOf('\\') === 0 ? ' ' : '';
  33747. }],
  33748. // replace (\ ) with ' '
  33749. [/\\\s/g, function () {
  33750. return ' ';
  33751. }],
  33752. // Escape metacharacters
  33753. // which is written down by users but means special for regular expressions.
  33754. // > There are 12 characters with special meanings:
  33755. // > - the backslash \,
  33756. // > - the caret ^,
  33757. // > - the dollar sign $,
  33758. // > - the period or dot .,
  33759. // > - the vertical bar or pipe symbol |,
  33760. // > - the question mark ?,
  33761. // > - the asterisk or star *,
  33762. // > - the plus sign +,
  33763. // > - the opening parenthesis (,
  33764. // > - the closing parenthesis ),
  33765. // > - and the opening square bracket [,
  33766. // > - the opening curly brace {,
  33767. // > These special characters are often called "metacharacters".
  33768. [/[\\^$.|*+(){]/g, function (match) {
  33769. return '\\' + match;
  33770. }], [
  33771. // > [abc] matches any character inside the brackets
  33772. // > (in this case a, b, or c);
  33773. /\[([^\]/]*)($|\])/g, function (match, p1, p2) {
  33774. return p2 === ']' ? '[' + sanitizeRange(p1) + ']' : '\\' + match;
  33775. }], [
  33776. // > a question mark (?) matches a single character
  33777. /(?!\\)\?/g, function () {
  33778. return '[^/]';
  33779. }],
  33780. // leading slash
  33781. [
  33782. // > A leading slash matches the beginning of the pathname.
  33783. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  33784. // A leading slash matches the beginning of the pathname
  33785. /^\//, function () {
  33786. return '^';
  33787. }],
  33788. // replace special metacharacter slash after the leading slash
  33789. [/\//g, function () {
  33790. return '\\/';
  33791. }], [
  33792. // > A leading "**" followed by a slash means match in all directories.
  33793. // > For example, "**/foo" matches file or directory "foo" anywhere,
  33794. // > the same as pattern "foo".
  33795. // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
  33796. // > under directory "foo".
  33797. // Notice that the '*'s have been replaced as '\\*'
  33798. /^\^*\\\*\\\*\\\//,
  33799. // '**/foo' <-> 'foo'
  33800. function () {
  33801. return '^(?:.*\\/)?';
  33802. }]];
  33803. var DEFAULT_REPLACER_SUFFIX = [
  33804. // starting
  33805. [
  33806. // there will be no leading '/'
  33807. // (which has been replaced by section "leading slash")
  33808. // If starts with '**', adding a '^' to the regular expression also works
  33809. /^(?=[^^])/, function startingReplacer() {
  33810. return !/\/(?!$)/.test(this)
  33811. // > If the pattern does not contain a slash /,
  33812. // > Git treats it as a shell glob pattern
  33813. // Actually, if there is only a trailing slash,
  33814. // git also treats it as a shell glob pattern
  33815. ? '(?:^|\\/)'
  33816. // > Otherwise, Git treats the pattern as a shell glob suitable for
  33817. // > consumption by fnmatch(3)
  33818. : '^';
  33819. }],
  33820. // two globstars
  33821. [
  33822. // Use lookahead assertions so that we could match more than one `'/**'`
  33823. /\\\/\\\*\\\*(?=\\\/|$)/g,
  33824. // Zero, one or several directories
  33825. // should not use '*', or it will be replaced by the next replacer
  33826. // Check if it is not the last `'/**'`
  33827. function (match, index, str) {
  33828. return index + 6 < str.length
  33829. // case: /**/
  33830. // > A slash followed by two consecutive asterisks then a slash matches
  33831. // > zero or more directories.
  33832. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
  33833. // '/**/'
  33834. ? '(?:\\/[^\\/]+)*'
  33835. // case: /**
  33836. // > A trailing `"/**"` matches everything inside.
  33837. // #21: everything inside but it should not include the current folder
  33838. : '\\/.+';
  33839. }],
  33840. // intermediate wildcards
  33841. [
  33842. // Never replace escaped '*'
  33843. // ignore rule '\*' will match the path '*'
  33844. // 'abc.*/' -> go
  33845. // 'abc.*' -> skip this rule
  33846. /(^|[^\\]+)\\\*(?=.+)/g,
  33847. // '*.js' matches '.js'
  33848. // '*.js' doesn't match 'abc'
  33849. function (match, p1) {
  33850. return p1 + '[^\\/]*';
  33851. }],
  33852. // trailing wildcard
  33853. [/(\^|\\\/)?\\\*$/, function (match, p1) {
  33854. var prefix = p1
  33855. // '\^':
  33856. // '/*' does not match ''
  33857. // '/*' does not match everything
  33858. // '\\\/':
  33859. // 'abc/*' does not match 'abc/'
  33860. ? p1 + '[^/]+'
  33861. // 'a*' matches 'a'
  33862. // 'a*' matches 'aa'
  33863. : '[^/]*';
  33864. return prefix + '(?=$|\\/$)';
  33865. }], [
  33866. // unescape
  33867. /\\\\\\/g, function () {
  33868. return '\\';
  33869. }]];
  33870. var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [
  33871. // 'f'
  33872. // matches
  33873. // - /f(end)
  33874. // - /f/
  33875. // - (start)f(end)
  33876. // - (start)f/
  33877. // doesn't match
  33878. // - oof
  33879. // - foo
  33880. // pseudo:
  33881. // -> (^|/)f(/|$)
  33882. // ending
  33883. [
  33884. // 'js' will not match 'js.'
  33885. // 'ab' will not match 'abc'
  33886. /(?:[^*/])$/,
  33887. // 'js*' will not match 'a.js'
  33888. // 'js/' will not match 'a.js'
  33889. // 'js' will match 'a.js' and 'a.js/'
  33890. function (match) {
  33891. return match + '(?=$|\\/)';
  33892. }]], DEFAULT_REPLACER_SUFFIX);
  33893. var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [
  33894. // #24, #38
  33895. // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
  33896. // A negative pattern without a trailing wildcard should not
  33897. // re-include the things inside that directory.
  33898. // eg:
  33899. // ['node_modules/*', '!node_modules']
  33900. // should ignore `node_modules/a.js`
  33901. [/(?:[^*])$/, function (match) {
  33902. return match + '(?=$|\\/$)';
  33903. }]], DEFAULT_REPLACER_SUFFIX);
  33904. // A simple cache, because an ignore rule only has only one certain meaning
  33905. var cache = Object.create(null);
  33906. // @param {pattern}
  33907. var make_regex = function make_regex(pattern, negative, ignorecase) {
  33908. var r = cache[pattern];
  33909. if (r) {
  33910. return r;
  33911. }
  33912. var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
  33913. var source = replacers.reduce(function (prev, current) {
  33914. return prev.replace(current[0], current[1].bind(pattern));
  33915. }, pattern);
  33916. return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
  33917. };
  33918. // > A blank line matches no files, so it can serve as a separator for readability.
  33919. var checkPattern = function checkPattern(pattern) {
  33920. return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern)
  33921. // > A line starting with # serves as a comment.
  33922. && pattern.indexOf('#') !== 0;
  33923. };
  33924. var createRule = function createRule(pattern, ignorecase) {
  33925. var origin = pattern;
  33926. var negative = false;
  33927. // > An optional prefix "!" which negates the pattern;
  33928. if (pattern.indexOf('!') === 0) {
  33929. negative = true;
  33930. pattern = pattern.substr(1);
  33931. }
  33932. pattern = pattern
  33933. // > Put a backslash ("\") in front of the first "!" for patterns that
  33934. // > begin with a literal "!", for example, `"\!important!.txt"`.
  33935. .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!')
  33936. // > Put a backslash ("\") in front of the first hash for patterns that
  33937. // > begin with a hash.
  33938. .replace(REGEX_LEADING_EXCAPED_HASH, '#');
  33939. var regex = make_regex(pattern, negative, ignorecase);
  33940. return {
  33941. origin: origin,
  33942. pattern: pattern,
  33943. negative: negative,
  33944. regex: regex
  33945. };
  33946. };
  33947. var IgnoreBase = function () {
  33948. function IgnoreBase() {
  33949. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  33950. _ref$ignorecase = _ref.ignorecase,
  33951. ignorecase = _ref$ignorecase === undefined ? true : _ref$ignorecase;
  33952. _classCallCheck(this, IgnoreBase);
  33953. this._rules = [];
  33954. this._ignorecase = ignorecase;
  33955. define(this, KEY_IGNORE, true);
  33956. this._initCache();
  33957. }
  33958. _createClass(IgnoreBase, [{
  33959. key: '_initCache',
  33960. value: function _initCache() {
  33961. this._cache = Object.create(null);
  33962. }
  33963. // @param {Array.<string>|string|Ignore} pattern
  33964. }, {
  33965. key: 'add',
  33966. value: function add(pattern) {
  33967. this._added = false;
  33968. if (typeof pattern === 'string') {
  33969. pattern = pattern.split(/\r?\n/g);
  33970. }
  33971. make_array(pattern).forEach(this._addPattern, this);
  33972. // Some rules have just added to the ignore,
  33973. // making the behavior changed.
  33974. if (this._added) {
  33975. this._initCache();
  33976. }
  33977. return this;
  33978. }
  33979. // legacy
  33980. }, {
  33981. key: 'addPattern',
  33982. value: function addPattern(pattern) {
  33983. return this.add(pattern);
  33984. }
  33985. }, {
  33986. key: '_addPattern',
  33987. value: function _addPattern(pattern) {
  33988. // #32
  33989. if (pattern && pattern[KEY_IGNORE]) {
  33990. this._rules = this._rules.concat(pattern._rules);
  33991. this._added = true;
  33992. return;
  33993. }
  33994. if (checkPattern(pattern)) {
  33995. var rule = createRule(pattern, this._ignorecase);
  33996. this._added = true;
  33997. this._rules.push(rule);
  33998. }
  33999. }
  34000. }, {
  34001. key: 'filter',
  34002. value: function filter(paths) {
  34003. var _this = this;
  34004. return make_array(paths).filter(function (path) {
  34005. return _this._filter(path);
  34006. });
  34007. }
  34008. }, {
  34009. key: 'createFilter',
  34010. value: function createFilter() {
  34011. var _this2 = this;
  34012. return function (path) {
  34013. return _this2._filter(path);
  34014. };
  34015. }
  34016. }, {
  34017. key: 'ignores',
  34018. value: function ignores(path) {
  34019. return !this._filter(path);
  34020. }
  34021. // @returns `Boolean` true if the `path` is NOT ignored
  34022. }, {
  34023. key: '_filter',
  34024. value: function _filter(path, slices) {
  34025. if (!path) {
  34026. return false;
  34027. }
  34028. if (path in this._cache) {
  34029. return this._cache[path];
  34030. }
  34031. if (!slices) {
  34032. // path/to/a.js
  34033. // ['path', 'to', 'a.js']
  34034. slices = path.split(SLASH);
  34035. }
  34036. slices.pop();
  34037. return this._cache[path] = slices.length
  34038. // > It is not possible to re-include a file if a parent directory of
  34039. // > that file is excluded.
  34040. // If the path contains a parent directory, check the parent first
  34041. ? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path)
  34042. // Or only test the path
  34043. : this._test(path);
  34044. }
  34045. // @returns {Boolean} true if a file is NOT ignored
  34046. }, {
  34047. key: '_test',
  34048. value: function _test(path) {
  34049. // Explicitly define variable type by setting matched to `0`
  34050. var matched = 0;
  34051. this._rules.forEach(function (rule) {
  34052. // if matched = true, then we only test negative rules
  34053. // if matched = false, then we test non-negative rules
  34054. if (!(matched ^ rule.negative)) {
  34055. matched = rule.negative ^ rule.regex.test(path);
  34056. }
  34057. });
  34058. return !matched;
  34059. }
  34060. }]);
  34061. return IgnoreBase;
  34062. }();
  34063. // Windows
  34064. // --------------------------------------------------------------
  34065. /* istanbul ignore if */
  34066. if (
  34067. // Detect `process` so that it can run in browsers.
  34068. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
  34069. var filter = IgnoreBase.prototype._filter;
  34070. /* eslint no-control-regex: "off" */
  34071. var make_posix = function make_posix(str) {
  34072. return (/^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/')
  34073. );
  34074. };
  34075. IgnoreBase.prototype._filter = function filterWin32(path, slices) {
  34076. path = make_posix(path);
  34077. return filter.call(this, path, slices);
  34078. };
  34079. }
  34080. module.exports = function (options) {
  34081. return new IgnoreBase(options);
  34082. };
  34083. }).call(this,require('_process'))
  34084. },{"_process":103}],87:[function(require,module,exports){
  34085. arguments[4][47][0].apply(exports,arguments)
  34086. },{"dup":47}],88:[function(require,module,exports){
  34087. 'use strict';
  34088. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  34089. var traverse = module.exports = function (schema, opts, cb) {
  34090. // Legacy support for v0.3.1 and earlier.
  34091. if (typeof opts == 'function') {
  34092. cb = opts;
  34093. opts = {};
  34094. }
  34095. cb = opts.cb || cb;
  34096. var pre = typeof cb == 'function' ? cb : cb.pre || function () {};
  34097. var post = cb.post || function () {};
  34098. _traverse(opts, pre, post, schema, '', schema);
  34099. };
  34100. traverse.keywords = {
  34101. additionalItems: true,
  34102. items: true,
  34103. contains: true,
  34104. additionalProperties: true,
  34105. propertyNames: true,
  34106. not: true
  34107. };
  34108. traverse.arrayKeywords = {
  34109. items: true,
  34110. allOf: true,
  34111. anyOf: true,
  34112. oneOf: true
  34113. };
  34114. traverse.propsKeywords = {
  34115. definitions: true,
  34116. properties: true,
  34117. patternProperties: true,
  34118. dependencies: true
  34119. };
  34120. traverse.skipKeywords = {
  34121. default: true,
  34122. enum: true,
  34123. const: true,
  34124. required: true,
  34125. maximum: true,
  34126. minimum: true,
  34127. exclusiveMaximum: true,
  34128. exclusiveMinimum: true,
  34129. multipleOf: true,
  34130. maxLength: true,
  34131. minLength: true,
  34132. pattern: true,
  34133. format: true,
  34134. maxItems: true,
  34135. minItems: true,
  34136. uniqueItems: true,
  34137. maxProperties: true,
  34138. minProperties: true
  34139. };
  34140. function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
  34141. if (schema && (typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) == 'object' && !Array.isArray(schema)) {
  34142. pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
  34143. for (var key in schema) {
  34144. var sch = schema[key];
  34145. if (Array.isArray(sch)) {
  34146. if (key in traverse.arrayKeywords) {
  34147. for (var i = 0; i < sch.length; i++) {
  34148. _traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i);
  34149. }
  34150. }
  34151. } else if (key in traverse.propsKeywords) {
  34152. if (sch && (typeof sch === 'undefined' ? 'undefined' : _typeof(sch)) == 'object') {
  34153. for (var prop in sch) {
  34154. _traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
  34155. }
  34156. }
  34157. } else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
  34158. _traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema);
  34159. }
  34160. }
  34161. post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
  34162. }
  34163. }
  34164. function escapeJsonPtr(str) {
  34165. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  34166. }
  34167. },{}],89:[function(require,module,exports){
  34168. 'use strict';
  34169. // Generated by LiveScript 1.4.0
  34170. (function () {
  34171. var parsedTypeCheck,
  34172. types,
  34173. toString$ = {}.toString;
  34174. parsedTypeCheck = require('type-check').parsedTypeCheck;
  34175. types = {
  34176. '*': function _(value, options) {
  34177. switch (toString$.call(value).slice(8, -1)) {
  34178. case 'Array':
  34179. return typeCast(value, {
  34180. type: 'Array'
  34181. }, options);
  34182. case 'Object':
  34183. return typeCast(value, {
  34184. type: 'Object'
  34185. }, options);
  34186. default:
  34187. return {
  34188. type: 'Just',
  34189. value: typesCast(value, [{
  34190. type: 'Undefined'
  34191. }, {
  34192. type: 'Null'
  34193. }, {
  34194. type: 'NaN'
  34195. }, {
  34196. type: 'Boolean'
  34197. }, {
  34198. type: 'Number'
  34199. }, {
  34200. type: 'Date'
  34201. }, {
  34202. type: 'RegExp'
  34203. }, {
  34204. type: 'Array'
  34205. }, {
  34206. type: 'Object'
  34207. }, {
  34208. type: 'String'
  34209. }], (options.explicit = true, options))
  34210. };
  34211. }
  34212. },
  34213. Undefined: function Undefined(it) {
  34214. if (it === 'undefined' || it === void 8) {
  34215. return {
  34216. type: 'Just',
  34217. value: void 8
  34218. };
  34219. } else {
  34220. return {
  34221. type: 'Nothing'
  34222. };
  34223. }
  34224. },
  34225. Null: function Null(it) {
  34226. if (it === 'null') {
  34227. return {
  34228. type: 'Just',
  34229. value: null
  34230. };
  34231. } else {
  34232. return {
  34233. type: 'Nothing'
  34234. };
  34235. }
  34236. },
  34237. NaN: function (_NaN) {
  34238. function NaN(_x) {
  34239. return _NaN.apply(this, arguments);
  34240. }
  34241. NaN.toString = function () {
  34242. return _NaN.toString();
  34243. };
  34244. return NaN;
  34245. }(function (it) {
  34246. if (it === 'NaN') {
  34247. return {
  34248. type: 'Just',
  34249. value: NaN
  34250. };
  34251. } else {
  34252. return {
  34253. type: 'Nothing'
  34254. };
  34255. }
  34256. }),
  34257. Boolean: function Boolean(it) {
  34258. if (it === 'true') {
  34259. return {
  34260. type: 'Just',
  34261. value: true
  34262. };
  34263. } else if (it === 'false') {
  34264. return {
  34265. type: 'Just',
  34266. value: false
  34267. };
  34268. } else {
  34269. return {
  34270. type: 'Nothing'
  34271. };
  34272. }
  34273. },
  34274. Number: function Number(it) {
  34275. return {
  34276. type: 'Just',
  34277. value: +it
  34278. };
  34279. },
  34280. Int: function Int(it) {
  34281. return {
  34282. type: 'Just',
  34283. value: +it
  34284. };
  34285. },
  34286. Float: function Float(it) {
  34287. return {
  34288. type: 'Just',
  34289. value: +it
  34290. };
  34291. },
  34292. Date: function (_Date) {
  34293. function Date(_x2, _x3) {
  34294. return _Date.apply(this, arguments);
  34295. }
  34296. Date.toString = function () {
  34297. return _Date.toString();
  34298. };
  34299. return Date;
  34300. }(function (value, options) {
  34301. var that;
  34302. if (that = /^\#([\s\S]*)\#$/.exec(value)) {
  34303. return {
  34304. type: 'Just',
  34305. value: new Date(+that[1] || that[1])
  34306. };
  34307. } else if (options.explicit) {
  34308. return {
  34309. type: 'Nothing'
  34310. };
  34311. } else {
  34312. return {
  34313. type: 'Just',
  34314. value: new Date(+value || value)
  34315. };
  34316. }
  34317. }),
  34318. RegExp: function (_RegExp) {
  34319. function RegExp(_x4, _x5) {
  34320. return _RegExp.apply(this, arguments);
  34321. }
  34322. RegExp.toString = function () {
  34323. return _RegExp.toString();
  34324. };
  34325. return RegExp;
  34326. }(function (value, options) {
  34327. var that;
  34328. if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) {
  34329. return {
  34330. type: 'Just',
  34331. value: new RegExp(that[1], that[2])
  34332. };
  34333. } else if (options.explicit) {
  34334. return {
  34335. type: 'Nothing'
  34336. };
  34337. } else {
  34338. return {
  34339. type: 'Just',
  34340. value: new RegExp(value)
  34341. };
  34342. }
  34343. }),
  34344. Array: function Array(value, options) {
  34345. return castArray(value, {
  34346. of: [{
  34347. type: '*'
  34348. }]
  34349. }, options);
  34350. },
  34351. Object: function Object(value, options) {
  34352. return castFields(value, {
  34353. of: {}
  34354. }, options);
  34355. },
  34356. String: function String(it) {
  34357. var that;
  34358. if (toString$.call(it).slice(8, -1) !== 'String') {
  34359. return {
  34360. type: 'Nothing'
  34361. };
  34362. }
  34363. if (that = it.match(/^'([\s\S]*)'$/)) {
  34364. return {
  34365. type: 'Just',
  34366. value: that[1].replace(/\\'/g, "'")
  34367. };
  34368. } else if (that = it.match(/^"([\s\S]*)"$/)) {
  34369. return {
  34370. type: 'Just',
  34371. value: that[1].replace(/\\"/g, '"')
  34372. };
  34373. } else {
  34374. return {
  34375. type: 'Just',
  34376. value: it
  34377. };
  34378. }
  34379. }
  34380. };
  34381. function castArray(node, type, options) {
  34382. var typeOf, element;
  34383. if (toString$.call(node).slice(8, -1) !== 'Array') {
  34384. return {
  34385. type: 'Nothing'
  34386. };
  34387. }
  34388. typeOf = type.of;
  34389. return {
  34390. type: 'Just',
  34391. value: function () {
  34392. var i$,
  34393. ref$,
  34394. len$,
  34395. results$ = [];
  34396. for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) {
  34397. element = ref$[i$];
  34398. results$.push(typesCast(element, typeOf, options));
  34399. }
  34400. return results$;
  34401. }()
  34402. };
  34403. }
  34404. function castTuple(node, type, options) {
  34405. var result, i, i$, ref$, len$, types, cast;
  34406. if (toString$.call(node).slice(8, -1) !== 'Array') {
  34407. return {
  34408. type: 'Nothing'
  34409. };
  34410. }
  34411. result = [];
  34412. i = 0;
  34413. for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
  34414. types = ref$[i$];
  34415. cast = typesCast(node[i], types, options);
  34416. if (toString$.call(cast).slice(8, -1) !== 'Undefined') {
  34417. result.push(cast);
  34418. }
  34419. i++;
  34420. }
  34421. if (node.length <= i) {
  34422. return {
  34423. type: 'Just',
  34424. value: result
  34425. };
  34426. } else {
  34427. return {
  34428. type: 'Nothing'
  34429. };
  34430. }
  34431. }
  34432. function castFields(node, type, options) {
  34433. var typeOf, key, value;
  34434. if (toString$.call(node).slice(8, -1) !== 'Object') {
  34435. return {
  34436. type: 'Nothing'
  34437. };
  34438. }
  34439. typeOf = type.of;
  34440. return {
  34441. type: 'Just',
  34442. value: function () {
  34443. var ref$,
  34444. resultObj$ = {};
  34445. for (key in ref$ = node) {
  34446. value = ref$[key];
  34447. resultObj$[typesCast(key, [{
  34448. type: 'String'
  34449. }], options)] = typesCast(value, typeOf[key] || [{
  34450. type: '*'
  34451. }], options);
  34452. }
  34453. return resultObj$;
  34454. }()
  34455. };
  34456. }
  34457. function typeCast(node, typeObj, options) {
  34458. var type, structure, castFunc, ref$;
  34459. type = typeObj.type, structure = typeObj.structure;
  34460. if (type) {
  34461. castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 8) || types[type];
  34462. if (!castFunc) {
  34463. throw new Error("Type not defined: " + type + ".");
  34464. }
  34465. return castFunc(node, options, typesCast);
  34466. } else {
  34467. switch (structure) {
  34468. case 'array':
  34469. return castArray(node, typeObj, options);
  34470. case 'tuple':
  34471. return castTuple(node, typeObj, options);
  34472. case 'fields':
  34473. return castFields(node, typeObj, options);
  34474. }
  34475. }
  34476. }
  34477. function typesCast(node, types, options) {
  34478. var i$, len$, type, ref$, valueType, value;
  34479. for (i$ = 0, len$ = types.length; i$ < len$; ++i$) {
  34480. type = types[i$];
  34481. ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value;
  34482. if (valueType === 'Nothing') {
  34483. continue;
  34484. }
  34485. if (parsedTypeCheck([type], value, {
  34486. customTypes: options.customTypes
  34487. })) {
  34488. return value;
  34489. }
  34490. }
  34491. throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + ".");
  34492. }
  34493. module.exports = typesCast;
  34494. }).call(undefined);
  34495. },{"type-check":106}],90:[function(require,module,exports){
  34496. 'use strict';
  34497. // Generated by LiveScript 1.4.0
  34498. (function () {
  34499. var parseString, cast, parseType, VERSION, parsedTypeParse, parse;
  34500. parseString = require('./parse-string');
  34501. cast = require('./cast');
  34502. parseType = require('type-check').parseType;
  34503. VERSION = '0.3.0';
  34504. parsedTypeParse = function parsedTypeParse(parsedType, string, options) {
  34505. options == null && (options = {});
  34506. options.explicit == null && (options.explicit = false);
  34507. options.customTypes == null && (options.customTypes = {});
  34508. return cast(parseString(parsedType, string, options), parsedType, options);
  34509. };
  34510. parse = function parse(type, string, options) {
  34511. return parsedTypeParse(parseType(type), string, options);
  34512. };
  34513. module.exports = {
  34514. VERSION: VERSION,
  34515. parse: parse,
  34516. parsedTypeParse: parsedTypeParse
  34517. };
  34518. }).call(undefined);
  34519. },{"./cast":89,"./parse-string":91,"type-check":106}],91:[function(require,module,exports){
  34520. "use strict";
  34521. // Generated by LiveScript 1.4.0
  34522. (function () {
  34523. var reject, special, tokenRegex;
  34524. reject = require('prelude-ls').reject;
  34525. function consumeOp(tokens, op) {
  34526. if (tokens[0] === op) {
  34527. return tokens.shift();
  34528. } else {
  34529. throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + ".");
  34530. }
  34531. }
  34532. function maybeConsumeOp(tokens, op) {
  34533. if (tokens[0] === op) {
  34534. return tokens.shift();
  34535. }
  34536. }
  34537. function consumeList(tokens, arg$, hasDelimiters) {
  34538. var open, close, result, untilTest;
  34539. open = arg$[0], close = arg$[1];
  34540. if (hasDelimiters) {
  34541. consumeOp(tokens, open);
  34542. }
  34543. result = [];
  34544. untilTest = "," + (hasDelimiters ? close : '');
  34545. while (tokens.length && hasDelimiters && tokens[0] !== close) {
  34546. result.push(consumeElement(tokens, untilTest));
  34547. maybeConsumeOp(tokens, ',');
  34548. }
  34549. if (hasDelimiters) {
  34550. consumeOp(tokens, close);
  34551. }
  34552. return result;
  34553. }
  34554. function consumeArray(tokens, hasDelimiters) {
  34555. return consumeList(tokens, ['[', ']'], hasDelimiters);
  34556. }
  34557. function consumeTuple(tokens, hasDelimiters) {
  34558. return consumeList(tokens, ['(', ')'], hasDelimiters);
  34559. }
  34560. function consumeFields(tokens, hasDelimiters) {
  34561. var result, untilTest, key;
  34562. if (hasDelimiters) {
  34563. consumeOp(tokens, '{');
  34564. }
  34565. result = {};
  34566. untilTest = "," + (hasDelimiters ? '}' : '');
  34567. while (tokens.length && (!hasDelimiters || tokens[0] !== '}')) {
  34568. key = consumeValue(tokens, ':');
  34569. consumeOp(tokens, ':');
  34570. result[key] = consumeElement(tokens, untilTest);
  34571. maybeConsumeOp(tokens, ',');
  34572. }
  34573. if (hasDelimiters) {
  34574. consumeOp(tokens, '}');
  34575. }
  34576. return result;
  34577. }
  34578. function consumeValue(tokens, untilTest) {
  34579. var out;
  34580. untilTest == null && (untilTest = '');
  34581. out = '';
  34582. while (tokens.length && -1 === untilTest.indexOf(tokens[0])) {
  34583. out += tokens.shift();
  34584. }
  34585. return out;
  34586. }
  34587. function consumeElement(tokens, untilTest) {
  34588. switch (tokens[0]) {
  34589. case '[':
  34590. return consumeArray(tokens, true);
  34591. case '(':
  34592. return consumeTuple(tokens, true);
  34593. case '{':
  34594. return consumeFields(tokens, true);
  34595. default:
  34596. return consumeValue(tokens, untilTest);
  34597. }
  34598. }
  34599. function consumeTopLevel(tokens, types, options) {
  34600. var ref$, type, structure, origTokens, result, finalResult, x$, y$;
  34601. ref$ = types[0], type = ref$.type, structure = ref$.structure;
  34602. origTokens = tokens.concat();
  34603. if (!options.explicit && types.length === 1 && (!type && structure || type === 'Array' || type === 'Object')) {
  34604. result = structure === 'array' || type === 'Array' ? consumeArray(tokens, tokens[0] === '[') : structure === 'tuple' ? consumeTuple(tokens, tokens[0] === '(') : consumeFields(tokens, tokens[0] === '{');
  34605. finalResult = tokens.length ? consumeElement(structure === 'array' || type === 'Array' ? (x$ = origTokens, x$.unshift('['), x$.push(']'), x$) : (y$ = origTokens, y$.unshift('('), y$.push(')'), y$)) : result;
  34606. } else {
  34607. finalResult = consumeElement(tokens);
  34608. }
  34609. return finalResult;
  34610. }
  34611. special = /\[\]\(\)}{:,/.source;
  34612. tokenRegex = RegExp('("(?:\\\\"|[^"])*")|(\'(?:\\\\\'|[^\'])*\')|(/(?:\\\\/|[^/])*/[a-zA-Z]*)|(#.*#)|([' + special + '])|([^\\s' + special + '](?:\\s*[^\\s' + special + ']+)*)|\\s*');
  34613. module.exports = function (types, string, options) {
  34614. var tokens, node;
  34615. options == null && (options = {});
  34616. if (!options.explicit && types.length === 1 && types[0].type === 'String') {
  34617. return "'" + string.replace(/\\'/g, "\\\\'") + "'";
  34618. }
  34619. tokens = reject(not$, string.split(tokenRegex));
  34620. node = consumeTopLevel(tokens, types, options);
  34621. if (!node) {
  34622. throw new Error("Error parsing '" + string + "'.");
  34623. }
  34624. return node;
  34625. };
  34626. function not$(x) {
  34627. return !x;
  34628. }
  34629. }).call(undefined);
  34630. },{"prelude-ls":102}],92:[function(require,module,exports){
  34631. (function (global){
  34632. 'use strict';var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};/**
  34633. * @license
  34634. * Lodash <https://lodash.com/>
  34635. * Copyright JS Foundation and other contributors <https://js.foundation/>
  34636. * Released under MIT license <https://lodash.com/license>
  34637. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  34638. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  34639. */;(function(){/** Used as a safe reference for `undefined` in pre-ES5 environments. */var undefined;/** Used as the semantic version number. */var VERSION='4.17.11';/** Used as the size to enable large array optimizations. */var LARGE_ARRAY_SIZE=200;/** Error message constants. */var CORE_ERROR_TEXT='Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',FUNC_ERROR_TEXT='Expected a function';/** Used to stand-in for `undefined` hash values. */var HASH_UNDEFINED='__lodash_hash_undefined__';/** Used as the maximum memoize cache size. */var MAX_MEMOIZE_SIZE=500;/** Used as the internal argument placeholder. */var PLACEHOLDER='__lodash_placeholder__';/** Used to compose bitmasks for cloning. */var CLONE_DEEP_FLAG=1,CLONE_FLAT_FLAG=2,CLONE_SYMBOLS_FLAG=4;/** Used to compose bitmasks for value comparisons. */var COMPARE_PARTIAL_FLAG=1,COMPARE_UNORDERED_FLAG=2;/** Used to compose bitmasks for function metadata. */var WRAP_BIND_FLAG=1,WRAP_BIND_KEY_FLAG=2,WRAP_CURRY_BOUND_FLAG=4,WRAP_CURRY_FLAG=8,WRAP_CURRY_RIGHT_FLAG=16,WRAP_PARTIAL_FLAG=32,WRAP_PARTIAL_RIGHT_FLAG=64,WRAP_ARY_FLAG=128,WRAP_REARG_FLAG=256,WRAP_FLIP_FLAG=512;/** Used as default options for `_.truncate`. */var DEFAULT_TRUNC_LENGTH=30,DEFAULT_TRUNC_OMISSION='...';/** Used to detect hot functions by number of calls within a span of milliseconds. */var HOT_COUNT=800,HOT_SPAN=16;/** Used to indicate the type of lazy iteratees. */var LAZY_FILTER_FLAG=1,LAZY_MAP_FLAG=2,LAZY_WHILE_FLAG=3;/** Used as references for various `Number` constants. */var INFINITY=1/0,MAX_SAFE_INTEGER=9007199254740991,MAX_INTEGER=1.7976931348623157e+308,NAN=0/0;/** Used as references for the maximum length and index of an array. */var MAX_ARRAY_LENGTH=4294967295,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1;/** Used to associate wrap methods with their bit flags. */var wrapFlags=[['ary',WRAP_ARY_FLAG],['bind',WRAP_BIND_FLAG],['bindKey',WRAP_BIND_KEY_FLAG],['curry',WRAP_CURRY_FLAG],['curryRight',WRAP_CURRY_RIGHT_FLAG],['flip',WRAP_FLIP_FLAG],['partial',WRAP_PARTIAL_FLAG],['partialRight',WRAP_PARTIAL_RIGHT_FLAG],['rearg',WRAP_REARG_FLAG]];/** `Object#toString` result references. */var argsTag='[object Arguments]',arrayTag='[object Array]',asyncTag='[object AsyncFunction]',boolTag='[object Boolean]',dateTag='[object Date]',domExcTag='[object DOMException]',errorTag='[object Error]',funcTag='[object Function]',genTag='[object GeneratorFunction]',mapTag='[object Map]',numberTag='[object Number]',nullTag='[object Null]',objectTag='[object Object]',promiseTag='[object Promise]',proxyTag='[object Proxy]',regexpTag='[object RegExp]',setTag='[object Set]',stringTag='[object String]',symbolTag='[object Symbol]',undefinedTag='[object Undefined]',weakMapTag='[object WeakMap]',weakSetTag='[object WeakSet]';var arrayBufferTag='[object ArrayBuffer]',dataViewTag='[object DataView]',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 empty string literals in compiled template source. */var reEmptyStringLeading=/\b__p \+= '';/g,reEmptyStringMiddle=/\b(__p \+=) '' \+/g,reEmptyStringTrailing=/(__e\(.*?\)|\b__t\)) \+\n'';/g;/** Used to match HTML entities and HTML characters. */var reEscapedHtml=/&(?:amp|lt|gt|quot|#39);/g,reUnescapedHtml=/[&<>"']/g,reHasEscapedHtml=RegExp(reEscapedHtml.source),reHasUnescapedHtml=RegExp(reUnescapedHtml.source);/** Used to match template delimiters. */var reEscape=/<%-([\s\S]+?)%>/g,reEvaluate=/<%([\s\S]+?)%>/g,reInterpolate=/<%=([\s\S]+?)%>/g;/** Used to match property names within property paths. */var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;/**
  34640. * Used to match `RegExp`
  34641. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  34642. */var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reHasRegExpChar=RegExp(reRegExpChar.source);/** Used to match leading and trailing whitespace. */var reTrim=/^\s+|\s+$/g,reTrimStart=/^\s+/,reTrimEnd=/\s+$/;/** Used to match wrap detail comments. */var reWrapComment=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,reWrapDetails=/\{\n\/\* \[wrapped with (.+)\] \*/,reSplitDetails=/,? & /;/** Used to match words composed of alphanumeric characters. */var reAsciiWord=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;/** Used to match backslashes in property paths. */var reEscapeChar=/\\(\\)?/g;/**
  34643. * Used to match
  34644. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  34645. */var reEsTemplate=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;/** Used to match `RegExp` flags from their coerced string values. */var reFlags=/\w*$/;/** Used to detect bad signed hexadecimal string values. */var reIsBadHex=/^[-+]0x[0-9a-f]+$/i;/** Used to detect binary string values. */var reIsBinary=/^0b[01]+$/i;/** Used to detect host constructors (Safari). */var reIsHostCtor=/^\[object .+?Constructor\]$/;/** Used to detect octal string values. */var reIsOctal=/^0o[0-7]+$/i;/** Used to detect unsigned integer values. */var reIsUint=/^(?:0|[1-9]\d*)$/;/** Used to match Latin Unicode letters (excluding mathematical operators). */var reLatin=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;/** Used to ensure capturing order of template delimiters. */var reNoMatch=/($^)/;/** Used to match unescaped characters in compiled string literals. */var reUnescapedString=/['\n\r\u2028\u2029\\]/g;/** Used to compose unicode character classes. */var rsAstralRange='\\ud800-\\udfff',rsComboMarksRange='\\u0300-\\u036f',reComboHalfMarksRange='\\ufe20-\\ufe2f',rsComboSymbolsRange='\\u20d0-\\u20ff',rsComboRange=rsComboMarksRange+reComboHalfMarksRange+rsComboSymbolsRange,rsDingbatRange='\\u2700-\\u27bf',rsLowerRange='a-z\\xdf-\\xf6\\xf8-\\xff',rsMathOpRange='\\xac\\xb1\\xd7\\xf7',rsNonCharRange='\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',rsPunctuationRange='\\u2000-\\u206f',rsSpaceRange=' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',rsUpperRange='A-Z\\xc0-\\xd6\\xd8-\\xde',rsVarRange='\\ufe0e\\ufe0f',rsBreakRange=rsMathOpRange+rsNonCharRange+rsPunctuationRange+rsSpaceRange;/** Used to compose unicode capture groups. */var rsApos='[\'\u2019]',rsAstral='['+rsAstralRange+']',rsBreak='['+rsBreakRange+']',rsCombo='['+rsComboRange+']',rsDigits='\\d+',rsDingbat='['+rsDingbatRange+']',rsLower='['+rsLowerRange+']',rsMisc='[^'+rsAstralRange+rsBreakRange+rsDigits+rsDingbatRange+rsLowerRange+rsUpperRange+']',rsFitz='\\ud83c[\\udffb-\\udfff]',rsModifier='(?:'+rsCombo+'|'+rsFitz+')',rsNonAstral='[^'+rsAstralRange+']',rsRegional='(?:\\ud83c[\\udde6-\\uddff]){2}',rsSurrPair='[\\ud800-\\udbff][\\udc00-\\udfff]',rsUpper='['+rsUpperRange+']',rsZWJ='\\u200d';/** Used to compose unicode regexes. */var rsMiscLower='(?:'+rsLower+'|'+rsMisc+')',rsMiscUpper='(?:'+rsUpper+'|'+rsMisc+')',rsOptContrLower='(?:'+rsApos+'(?:d|ll|m|re|s|t|ve))?',rsOptContrUpper='(?:'+rsApos+'(?:D|LL|M|RE|S|T|VE))?',reOptMod=rsModifier+'?',rsOptVar='['+rsVarRange+']?',rsOptJoin='(?:'+rsZWJ+'(?:'+[rsNonAstral,rsRegional,rsSurrPair].join('|')+')'+rsOptVar+reOptMod+')*',rsOrdLower='\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',rsOrdUpper='\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',rsSeq=rsOptVar+reOptMod+rsOptJoin,rsEmoji='(?:'+[rsDingbat,rsRegional,rsSurrPair].join('|')+')'+rsSeq,rsSymbol='(?:'+[rsNonAstral+rsCombo+'?',rsCombo,rsRegional,rsSurrPair,rsAstral].join('|')+')';/** Used to match apostrophes. */var reApos=RegExp(rsApos,'g');/**
  34646. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  34647. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  34648. */var reComboMark=RegExp(rsCombo,'g');/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */var reUnicode=RegExp(rsFitz+'(?='+rsFitz+')|'+rsSymbol+rsSeq,'g');/** Used to match complex or compound words. */var reUnicodeWord=RegExp([rsUpper+'?'+rsLower+'+'+rsOptContrLower+'(?='+[rsBreak,rsUpper,'$'].join('|')+')',rsMiscUpper+'+'+rsOptContrUpper+'(?='+[rsBreak,rsUpper+rsMiscLower,'$'].join('|')+')',rsUpper+'?'+rsMiscLower+'+'+rsOptContrLower,rsUpper+'+'+rsOptContrUpper,rsOrdUpper,rsOrdLower,rsDigits,rsEmoji].join('|'),'g');/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */var reHasUnicode=RegExp('['+rsZWJ+rsAstralRange+rsComboRange+rsVarRange+']');/** Used to detect strings that need a more robust regexp to match words. */var reHasUnicodeWord=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;/** Used to assign default `context` object properties. */var contextProps=['Array','Buffer','DataView','Date','Error','Float32Array','Float64Array','Function','Int8Array','Int16Array','Int32Array','Map','Math','Object','Promise','RegExp','Set','String','Symbol','TypeError','Uint8Array','Uint8ClampedArray','Uint16Array','Uint32Array','WeakMap','_','clearTimeout','isFinite','parseInt','setTimeout'];/** Used to make template sourceURLs easier to identify. */var templateCounter=-1;/** 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[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;/** Used to identify `toStringTag` values supported by `_.clone`. */var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[dataViewTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[setTag]=cloneableTags[stringTag]=cloneableTags[symbolTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=true;cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=false;/** Used to map Latin Unicode letters to basic Latin letters. */var deburredLetters={// Latin-1 Supplement block.
  34649. '\xc0':'A','\xc1':'A','\xc2':'A','\xc3':'A','\xc4':'A','\xc5':'A','\xe0':'a','\xe1':'a','\xe2':'a','\xe3':'a','\xe4':'a','\xe5':'a','\xc7':'C','\xe7':'c','\xd0':'D','\xf0':'d','\xc8':'E','\xc9':'E','\xca':'E','\xcb':'E','\xe8':'e','\xe9':'e','\xea':'e','\xeb':'e','\xcc':'I','\xcd':'I','\xce':'I','\xcf':'I','\xec':'i','\xed':'i','\xee':'i','\xef':'i','\xd1':'N','\xf1':'n','\xd2':'O','\xd3':'O','\xd4':'O','\xd5':'O','\xd6':'O','\xd8':'O','\xf2':'o','\xf3':'o','\xf4':'o','\xf5':'o','\xf6':'o','\xf8':'o','\xd9':'U','\xda':'U','\xdb':'U','\xdc':'U','\xf9':'u','\xfa':'u','\xfb':'u','\xfc':'u','\xdd':'Y','\xfd':'y','\xff':'y','\xc6':'Ae','\xe6':'ae','\xde':'Th','\xfe':'th','\xdf':'ss',// Latin Extended-A block.
  34650. '\u0100':'A','\u0102':'A','\u0104':'A','\u0101':'a','\u0103':'a','\u0105':'a','\u0106':'C','\u0108':'C','\u010A':'C','\u010C':'C','\u0107':'c','\u0109':'c','\u010B':'c','\u010D':'c','\u010E':'D','\u0110':'D','\u010F':'d','\u0111':'d','\u0112':'E','\u0114':'E','\u0116':'E','\u0118':'E','\u011A':'E','\u0113':'e','\u0115':'e','\u0117':'e','\u0119':'e','\u011B':'e','\u011C':'G','\u011E':'G','\u0120':'G','\u0122':'G','\u011D':'g','\u011F':'g','\u0121':'g','\u0123':'g','\u0124':'H','\u0126':'H','\u0125':'h','\u0127':'h','\u0128':'I','\u012A':'I','\u012C':'I','\u012E':'I','\u0130':'I','\u0129':'i','\u012B':'i','\u012D':'i','\u012F':'i','\u0131':'i','\u0134':'J','\u0135':'j','\u0136':'K','\u0137':'k','\u0138':'k','\u0139':'L','\u013B':'L','\u013D':'L','\u013F':'L','\u0141':'L','\u013A':'l','\u013C':'l','\u013E':'l','\u0140':'l','\u0142':'l','\u0143':'N','\u0145':'N','\u0147':'N','\u014A':'N','\u0144':'n','\u0146':'n','\u0148':'n','\u014B':'n','\u014C':'O','\u014E':'O','\u0150':'O','\u014D':'o','\u014F':'o','\u0151':'o','\u0154':'R','\u0156':'R','\u0158':'R','\u0155':'r','\u0157':'r','\u0159':'r','\u015A':'S','\u015C':'S','\u015E':'S','\u0160':'S','\u015B':'s','\u015D':'s','\u015F':'s','\u0161':'s','\u0162':'T','\u0164':'T','\u0166':'T','\u0163':'t','\u0165':'t','\u0167':'t','\u0168':'U','\u016A':'U','\u016C':'U','\u016E':'U','\u0170':'U','\u0172':'U','\u0169':'u','\u016B':'u','\u016D':'u','\u016F':'u','\u0171':'u','\u0173':'u','\u0174':'W','\u0175':'w','\u0176':'Y','\u0177':'y','\u0178':'Y','\u0179':'Z','\u017B':'Z','\u017D':'Z','\u017A':'z','\u017C':'z','\u017E':'z','\u0132':'IJ','\u0133':'ij','\u0152':'Oe','\u0153':'oe','\u0149':"'n",'\u017F':'s'};/** Used to map characters to HTML entities. */var htmlEscapes={'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'};/** Used to map HTML entities to characters. */var htmlUnescapes={'&amp;':'&','&lt;':'<','&gt;':'>','&quot;':'"','&#39;':"'"};/** Used to escape characters for inclusion in compiled string literals. */var stringEscapes={'\\':'\\',"'":"'",'\n':'n','\r':'r','\u2028':'u2028','\u2029':'u2029'};/** Built-in method references without a dependency on `root`. */var freeParseFloat=parseFloat,freeParseInt=parseInt;/** Detect free variable `global` from Node.js. */var freeGlobal=(typeof global==='undefined'?'undefined':_typeof(global))=='object'&&global&&global.Object===Object&&global;/** Detect free variable `self`. */var freeSelf=(typeof self==='undefined'?'undefined':_typeof(self))=='object'&&self&&self.Object===Object&&self;/** Used as a reference to the global object. */var root=freeGlobal||freeSelf||Function('return this')();/** Detect free variable `exports`. */var freeExports=(typeof exports==='undefined'?'undefined':_typeof(exports))=='object'&&exports&&!exports.nodeType&&exports;/** Detect free variable `module`. */var freeModule=freeExports&&(typeof module==='undefined'?'undefined':_typeof(module))=='object'&&module&&!module.nodeType&&module;/** Detect the popular CommonJS extension `module.exports`. */var moduleExports=freeModule&&freeModule.exports===freeExports;/** Detect free variable `process` from Node.js. */var freeProcess=moduleExports&&freeGlobal.process;/** Used to access faster Node.js helpers. */var nodeUtil=function(){try{// Use `util.types` for Node.js 10+.
  34651. var types=freeModule&&freeModule.require&&freeModule.require('util').types;if(types){return types;}// Legacy `process.binding('util')` for Node.js < 10.
  34652. return freeProcess&&freeProcess.binding&&freeProcess.binding('util');}catch(e){}}();/* Node.js helper references. */var nodeIsArrayBuffer=nodeUtil&&nodeUtil.isArrayBuffer,nodeIsDate=nodeUtil&&nodeUtil.isDate,nodeIsMap=nodeUtil&&nodeUtil.isMap,nodeIsRegExp=nodeUtil&&nodeUtil.isRegExp,nodeIsSet=nodeUtil&&nodeUtil.isSet,nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray;/*--------------------------------------------------------------------------*//**
  34653. * A faster alternative to `Function#apply`, this function invokes `func`
  34654. * with the `this` binding of `thisArg` and the arguments of `args`.
  34655. *
  34656. * @private
  34657. * @param {Function} func The function to invoke.
  34658. * @param {*} thisArg The `this` binding of `func`.
  34659. * @param {Array} args The arguments to invoke `func` with.
  34660. * @returns {*} Returns the result of `func`.
  34661. */function apply(func,thisArg,args){switch(args.length){case 0:return func.call(thisArg);case 1:return func.call(thisArg,args[0]);case 2:return func.call(thisArg,args[0],args[1]);case 3:return func.call(thisArg,args[0],args[1],args[2]);}return func.apply(thisArg,args);}/**
  34662. * A specialized version of `baseAggregator` for arrays.
  34663. *
  34664. * @private
  34665. * @param {Array} [array] The array to iterate over.
  34666. * @param {Function} setter The function to set `accumulator` values.
  34667. * @param {Function} iteratee The iteratee to transform keys.
  34668. * @param {Object} accumulator The initial aggregated object.
  34669. * @returns {Function} Returns `accumulator`.
  34670. */function arrayAggregator(array,setter,iteratee,accumulator){var index=-1,length=array==null?0:array.length;while(++index<length){var value=array[index];setter(accumulator,value,iteratee(value),array);}return accumulator;}/**
  34671. * A specialized version of `_.forEach` for arrays without support for
  34672. * iteratee shorthands.
  34673. *
  34674. * @private
  34675. * @param {Array} [array] The array to iterate over.
  34676. * @param {Function} iteratee The function invoked per iteration.
  34677. * @returns {Array} Returns `array`.
  34678. */function arrayEach(array,iteratee){var index=-1,length=array==null?0:array.length;while(++index<length){if(iteratee(array[index],index,array)===false){break;}}return array;}/**
  34679. * A specialized version of `_.forEachRight` for arrays without support for
  34680. * iteratee shorthands.
  34681. *
  34682. * @private
  34683. * @param {Array} [array] The array to iterate over.
  34684. * @param {Function} iteratee The function invoked per iteration.
  34685. * @returns {Array} Returns `array`.
  34686. */function arrayEachRight(array,iteratee){var length=array==null?0:array.length;while(length--){if(iteratee(array[length],length,array)===false){break;}}return array;}/**
  34687. * A specialized version of `_.every` for arrays without support for
  34688. * iteratee shorthands.
  34689. *
  34690. * @private
  34691. * @param {Array} [array] The array to iterate over.
  34692. * @param {Function} predicate The function invoked per iteration.
  34693. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  34694. * else `false`.
  34695. */function arrayEvery(array,predicate){var index=-1,length=array==null?0:array.length;while(++index<length){if(!predicate(array[index],index,array)){return false;}}return true;}/**
  34696. * A specialized version of `_.filter` for arrays without support for
  34697. * iteratee shorthands.
  34698. *
  34699. * @private
  34700. * @param {Array} [array] The array to iterate over.
  34701. * @param {Function} predicate The function invoked per iteration.
  34702. * @returns {Array} Returns the new filtered array.
  34703. */function arrayFilter(array,predicate){var index=-1,length=array==null?0:array.length,resIndex=0,result=[];while(++index<length){var value=array[index];if(predicate(value,index,array)){result[resIndex++]=value;}}return result;}/**
  34704. * A specialized version of `_.includes` for arrays without support for
  34705. * specifying an index to search from.
  34706. *
  34707. * @private
  34708. * @param {Array} [array] The array to inspect.
  34709. * @param {*} target The value to search for.
  34710. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  34711. */function arrayIncludes(array,value){var length=array==null?0:array.length;return!!length&&baseIndexOf(array,value,0)>-1;}/**
  34712. * This function is like `arrayIncludes` except that it accepts a comparator.
  34713. *
  34714. * @private
  34715. * @param {Array} [array] The array to inspect.
  34716. * @param {*} target The value to search for.
  34717. * @param {Function} comparator The comparator invoked per element.
  34718. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  34719. */function arrayIncludesWith(array,value,comparator){var index=-1,length=array==null?0:array.length;while(++index<length){if(comparator(value,array[index])){return true;}}return false;}/**
  34720. * A specialized version of `_.map` for arrays without support for iteratee
  34721. * shorthands.
  34722. *
  34723. * @private
  34724. * @param {Array} [array] The array to iterate over.
  34725. * @param {Function} iteratee The function invoked per iteration.
  34726. * @returns {Array} Returns the new mapped array.
  34727. */function arrayMap(array,iteratee){var index=-1,length=array==null?0:array.length,result=Array(length);while(++index<length){result[index]=iteratee(array[index],index,array);}return result;}/**
  34728. * Appends the elements of `values` to `array`.
  34729. *
  34730. * @private
  34731. * @param {Array} array The array to modify.
  34732. * @param {Array} values The values to append.
  34733. * @returns {Array} Returns `array`.
  34734. */function arrayPush(array,values){var index=-1,length=values.length,offset=array.length;while(++index<length){array[offset+index]=values[index];}return array;}/**
  34735. * A specialized version of `_.reduce` for arrays without support for
  34736. * iteratee shorthands.
  34737. *
  34738. * @private
  34739. * @param {Array} [array] The array to iterate over.
  34740. * @param {Function} iteratee The function invoked per iteration.
  34741. * @param {*} [accumulator] The initial value.
  34742. * @param {boolean} [initAccum] Specify using the first element of `array` as
  34743. * the initial value.
  34744. * @returns {*} Returns the accumulated value.
  34745. */function arrayReduce(array,iteratee,accumulator,initAccum){var index=-1,length=array==null?0:array.length;if(initAccum&&length){accumulator=array[++index];}while(++index<length){accumulator=iteratee(accumulator,array[index],index,array);}return accumulator;}/**
  34746. * A specialized version of `_.reduceRight` for arrays without support for
  34747. * iteratee shorthands.
  34748. *
  34749. * @private
  34750. * @param {Array} [array] The array to iterate over.
  34751. * @param {Function} iteratee The function invoked per iteration.
  34752. * @param {*} [accumulator] The initial value.
  34753. * @param {boolean} [initAccum] Specify using the last element of `array` as
  34754. * the initial value.
  34755. * @returns {*} Returns the accumulated value.
  34756. */function arrayReduceRight(array,iteratee,accumulator,initAccum){var length=array==null?0:array.length;if(initAccum&&length){accumulator=array[--length];}while(length--){accumulator=iteratee(accumulator,array[length],length,array);}return accumulator;}/**
  34757. * A specialized version of `_.some` for arrays without support for iteratee
  34758. * shorthands.
  34759. *
  34760. * @private
  34761. * @param {Array} [array] The array to iterate over.
  34762. * @param {Function} predicate The function invoked per iteration.
  34763. * @returns {boolean} Returns `true` if any element passes the predicate check,
  34764. * else `false`.
  34765. */function arraySome(array,predicate){var index=-1,length=array==null?0:array.length;while(++index<length){if(predicate(array[index],index,array)){return true;}}return false;}/**
  34766. * Gets the size of an ASCII `string`.
  34767. *
  34768. * @private
  34769. * @param {string} string The string inspect.
  34770. * @returns {number} Returns the string size.
  34771. */var asciiSize=baseProperty('length');/**
  34772. * Converts an ASCII `string` to an array.
  34773. *
  34774. * @private
  34775. * @param {string} string The string to convert.
  34776. * @returns {Array} Returns the converted array.
  34777. */function asciiToArray(string){return string.split('');}/**
  34778. * Splits an ASCII `string` into an array of its words.
  34779. *
  34780. * @private
  34781. * @param {string} The string to inspect.
  34782. * @returns {Array} Returns the words of `string`.
  34783. */function asciiWords(string){return string.match(reAsciiWord)||[];}/**
  34784. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  34785. * without support for iteratee shorthands, which iterates over `collection`
  34786. * using `eachFunc`.
  34787. *
  34788. * @private
  34789. * @param {Array|Object} collection The collection to inspect.
  34790. * @param {Function} predicate The function invoked per iteration.
  34791. * @param {Function} eachFunc The function to iterate over `collection`.
  34792. * @returns {*} Returns the found element or its key, else `undefined`.
  34793. */function baseFindKey(collection,predicate,eachFunc){var result;eachFunc(collection,function(value,key,collection){if(predicate(value,key,collection)){result=key;return false;}});return result;}/**
  34794. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  34795. * support for iteratee shorthands.
  34796. *
  34797. * @private
  34798. * @param {Array} array The array to inspect.
  34799. * @param {Function} predicate The function invoked per iteration.
  34800. * @param {number} fromIndex The index to search from.
  34801. * @param {boolean} [fromRight] Specify iterating from right to left.
  34802. * @returns {number} Returns the index of the matched value, else `-1`.
  34803. */function baseFindIndex(array,predicate,fromIndex,fromRight){var length=array.length,index=fromIndex+(fromRight?1:-1);while(fromRight?index--:++index<length){if(predicate(array[index],index,array)){return index;}}return-1;}/**
  34804. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  34805. *
  34806. * @private
  34807. * @param {Array} array The array to inspect.
  34808. * @param {*} value The value to search for.
  34809. * @param {number} fromIndex The index to search from.
  34810. * @returns {number} Returns the index of the matched value, else `-1`.
  34811. */function baseIndexOf(array,value,fromIndex){return value===value?strictIndexOf(array,value,fromIndex):baseFindIndex(array,baseIsNaN,fromIndex);}/**
  34812. * This function is like `baseIndexOf` except that it accepts a comparator.
  34813. *
  34814. * @private
  34815. * @param {Array} array The array to inspect.
  34816. * @param {*} value The value to search for.
  34817. * @param {number} fromIndex The index to search from.
  34818. * @param {Function} comparator The comparator invoked per element.
  34819. * @returns {number} Returns the index of the matched value, else `-1`.
  34820. */function baseIndexOfWith(array,value,fromIndex,comparator){var index=fromIndex-1,length=array.length;while(++index<length){if(comparator(array[index],value)){return index;}}return-1;}/**
  34821. * The base implementation of `_.isNaN` without support for number objects.
  34822. *
  34823. * @private
  34824. * @param {*} value The value to check.
  34825. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  34826. */function baseIsNaN(value){return value!==value;}/**
  34827. * The base implementation of `_.mean` and `_.meanBy` without support for
  34828. * iteratee shorthands.
  34829. *
  34830. * @private
  34831. * @param {Array} array The array to iterate over.
  34832. * @param {Function} iteratee The function invoked per iteration.
  34833. * @returns {number} Returns the mean.
  34834. */function baseMean(array,iteratee){var length=array==null?0:array.length;return length?baseSum(array,iteratee)/length:NAN;}/**
  34835. * The base implementation of `_.property` without support for deep paths.
  34836. *
  34837. * @private
  34838. * @param {string} key The key of the property to get.
  34839. * @returns {Function} Returns the new accessor function.
  34840. */function baseProperty(key){return function(object){return object==null?undefined:object[key];};}/**
  34841. * The base implementation of `_.propertyOf` without support for deep paths.
  34842. *
  34843. * @private
  34844. * @param {Object} object The object to query.
  34845. * @returns {Function} Returns the new accessor function.
  34846. */function basePropertyOf(object){return function(key){return object==null?undefined:object[key];};}/**
  34847. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  34848. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  34849. *
  34850. * @private
  34851. * @param {Array|Object} collection The collection to iterate over.
  34852. * @param {Function} iteratee The function invoked per iteration.
  34853. * @param {*} accumulator The initial value.
  34854. * @param {boolean} initAccum Specify using the first or last element of
  34855. * `collection` as the initial value.
  34856. * @param {Function} eachFunc The function to iterate over `collection`.
  34857. * @returns {*} Returns the accumulated value.
  34858. */function baseReduce(collection,iteratee,accumulator,initAccum,eachFunc){eachFunc(collection,function(value,index,collection){accumulator=initAccum?(initAccum=false,value):iteratee(accumulator,value,index,collection);});return accumulator;}/**
  34859. * The base implementation of `_.sortBy` which uses `comparer` to define the
  34860. * sort order of `array` and replaces criteria objects with their corresponding
  34861. * values.
  34862. *
  34863. * @private
  34864. * @param {Array} array The array to sort.
  34865. * @param {Function} comparer The function to define sort order.
  34866. * @returns {Array} Returns `array`.
  34867. */function baseSortBy(array,comparer){var length=array.length;array.sort(comparer);while(length--){array[length]=array[length].value;}return array;}/**
  34868. * The base implementation of `_.sum` and `_.sumBy` without support for
  34869. * iteratee shorthands.
  34870. *
  34871. * @private
  34872. * @param {Array} array The array to iterate over.
  34873. * @param {Function} iteratee The function invoked per iteration.
  34874. * @returns {number} Returns the sum.
  34875. */function baseSum(array,iteratee){var result,index=-1,length=array.length;while(++index<length){var current=iteratee(array[index]);if(current!==undefined){result=result===undefined?current:result+current;}}return result;}/**
  34876. * The base implementation of `_.times` without support for iteratee shorthands
  34877. * or max array length checks.
  34878. *
  34879. * @private
  34880. * @param {number} n The number of times to invoke `iteratee`.
  34881. * @param {Function} iteratee The function invoked per iteration.
  34882. * @returns {Array} Returns the array of results.
  34883. */function baseTimes(n,iteratee){var index=-1,result=Array(n);while(++index<n){result[index]=iteratee(index);}return result;}/**
  34884. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  34885. * of key-value pairs for `object` corresponding to the property names of `props`.
  34886. *
  34887. * @private
  34888. * @param {Object} object The object to query.
  34889. * @param {Array} props The property names to get values for.
  34890. * @returns {Object} Returns the key-value pairs.
  34891. */function baseToPairs(object,props){return arrayMap(props,function(key){return[key,object[key]];});}/**
  34892. * The base implementation of `_.unary` without support for storing metadata.
  34893. *
  34894. * @private
  34895. * @param {Function} func The function to cap arguments for.
  34896. * @returns {Function} Returns the new capped function.
  34897. */function baseUnary(func){return function(value){return func(value);};}/**
  34898. * The base implementation of `_.values` and `_.valuesIn` which creates an
  34899. * array of `object` property values corresponding to the property names
  34900. * of `props`.
  34901. *
  34902. * @private
  34903. * @param {Object} object The object to query.
  34904. * @param {Array} props The property names to get values for.
  34905. * @returns {Object} Returns the array of property values.
  34906. */function baseValues(object,props){return arrayMap(props,function(key){return object[key];});}/**
  34907. * Checks if a `cache` value for `key` exists.
  34908. *
  34909. * @private
  34910. * @param {Object} cache The cache to query.
  34911. * @param {string} key The key of the entry to check.
  34912. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  34913. */function cacheHas(cache,key){return cache.has(key);}/**
  34914. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  34915. * that is not found in the character symbols.
  34916. *
  34917. * @private
  34918. * @param {Array} strSymbols The string symbols to inspect.
  34919. * @param {Array} chrSymbols The character symbols to find.
  34920. * @returns {number} Returns the index of the first unmatched string symbol.
  34921. */function charsStartIndex(strSymbols,chrSymbols){var index=-1,length=strSymbols.length;while(++index<length&&baseIndexOf(chrSymbols,strSymbols[index],0)>-1){}return index;}/**
  34922. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  34923. * that is not found in the character symbols.
  34924. *
  34925. * @private
  34926. * @param {Array} strSymbols The string symbols to inspect.
  34927. * @param {Array} chrSymbols The character symbols to find.
  34928. * @returns {number} Returns the index of the last unmatched string symbol.
  34929. */function charsEndIndex(strSymbols,chrSymbols){var index=strSymbols.length;while(index--&&baseIndexOf(chrSymbols,strSymbols[index],0)>-1){}return index;}/**
  34930. * Gets the number of `placeholder` occurrences in `array`.
  34931. *
  34932. * @private
  34933. * @param {Array} array The array to inspect.
  34934. * @param {*} placeholder The placeholder to search for.
  34935. * @returns {number} Returns the placeholder count.
  34936. */function countHolders(array,placeholder){var length=array.length,result=0;while(length--){if(array[length]===placeholder){++result;}}return result;}/**
  34937. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  34938. * letters to basic Latin letters.
  34939. *
  34940. * @private
  34941. * @param {string} letter The matched letter to deburr.
  34942. * @returns {string} Returns the deburred letter.
  34943. */var deburrLetter=basePropertyOf(deburredLetters);/**
  34944. * Used by `_.escape` to convert characters to HTML entities.
  34945. *
  34946. * @private
  34947. * @param {string} chr The matched character to escape.
  34948. * @returns {string} Returns the escaped character.
  34949. */var escapeHtmlChar=basePropertyOf(htmlEscapes);/**
  34950. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  34951. *
  34952. * @private
  34953. * @param {string} chr The matched character to escape.
  34954. * @returns {string} Returns the escaped character.
  34955. */function escapeStringChar(chr){return'\\'+stringEscapes[chr];}/**
  34956. * Gets the value at `key` of `object`.
  34957. *
  34958. * @private
  34959. * @param {Object} [object] The object to query.
  34960. * @param {string} key The key of the property to get.
  34961. * @returns {*} Returns the property value.
  34962. */function getValue(object,key){return object==null?undefined:object[key];}/**
  34963. * Checks if `string` contains Unicode symbols.
  34964. *
  34965. * @private
  34966. * @param {string} string The string to inspect.
  34967. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  34968. */function hasUnicode(string){return reHasUnicode.test(string);}/**
  34969. * Checks if `string` contains a word composed of Unicode symbols.
  34970. *
  34971. * @private
  34972. * @param {string} string The string to inspect.
  34973. * @returns {boolean} Returns `true` if a word is found, else `false`.
  34974. */function hasUnicodeWord(string){return reHasUnicodeWord.test(string);}/**
  34975. * Converts `iterator` to an array.
  34976. *
  34977. * @private
  34978. * @param {Object} iterator The iterator to convert.
  34979. * @returns {Array} Returns the converted array.
  34980. */function iteratorToArray(iterator){var data,result=[];while(!(data=iterator.next()).done){result.push(data.value);}return result;}/**
  34981. * Converts `map` to its key-value pairs.
  34982. *
  34983. * @private
  34984. * @param {Object} map The map to convert.
  34985. * @returns {Array} Returns the key-value pairs.
  34986. */function mapToArray(map){var index=-1,result=Array(map.size);map.forEach(function(value,key){result[++index]=[key,value];});return result;}/**
  34987. * Creates a unary function that invokes `func` with its argument transformed.
  34988. *
  34989. * @private
  34990. * @param {Function} func The function to wrap.
  34991. * @param {Function} transform The argument transform.
  34992. * @returns {Function} Returns the new function.
  34993. */function overArg(func,transform){return function(arg){return func(transform(arg));};}/**
  34994. * Replaces all `placeholder` elements in `array` with an internal placeholder
  34995. * and returns an array of their indexes.
  34996. *
  34997. * @private
  34998. * @param {Array} array The array to modify.
  34999. * @param {*} placeholder The placeholder to replace.
  35000. * @returns {Array} Returns the new array of placeholder indexes.
  35001. */function replaceHolders(array,placeholder){var index=-1,length=array.length,resIndex=0,result=[];while(++index<length){var value=array[index];if(value===placeholder||value===PLACEHOLDER){array[index]=PLACEHOLDER;result[resIndex++]=index;}}return result;}/**
  35002. * Converts `set` to an array of its values.
  35003. *
  35004. * @private
  35005. * @param {Object} set The set to convert.
  35006. * @returns {Array} Returns the values.
  35007. */function setToArray(set){var index=-1,result=Array(set.size);set.forEach(function(value){result[++index]=value;});return result;}/**
  35008. * Converts `set` to its value-value pairs.
  35009. *
  35010. * @private
  35011. * @param {Object} set The set to convert.
  35012. * @returns {Array} Returns the value-value pairs.
  35013. */function setToPairs(set){var index=-1,result=Array(set.size);set.forEach(function(value){result[++index]=[value,value];});return result;}/**
  35014. * A specialized version of `_.indexOf` which performs strict equality
  35015. * comparisons of values, i.e. `===`.
  35016. *
  35017. * @private
  35018. * @param {Array} array The array to inspect.
  35019. * @param {*} value The value to search for.
  35020. * @param {number} fromIndex The index to search from.
  35021. * @returns {number} Returns the index of the matched value, else `-1`.
  35022. */function strictIndexOf(array,value,fromIndex){var index=fromIndex-1,length=array.length;while(++index<length){if(array[index]===value){return index;}}return-1;}/**
  35023. * A specialized version of `_.lastIndexOf` which performs strict equality
  35024. * comparisons of values, i.e. `===`.
  35025. *
  35026. * @private
  35027. * @param {Array} array The array to inspect.
  35028. * @param {*} value The value to search for.
  35029. * @param {number} fromIndex The index to search from.
  35030. * @returns {number} Returns the index of the matched value, else `-1`.
  35031. */function strictLastIndexOf(array,value,fromIndex){var index=fromIndex+1;while(index--){if(array[index]===value){return index;}}return index;}/**
  35032. * Gets the number of symbols in `string`.
  35033. *
  35034. * @private
  35035. * @param {string} string The string to inspect.
  35036. * @returns {number} Returns the string size.
  35037. */function stringSize(string){return hasUnicode(string)?unicodeSize(string):asciiSize(string);}/**
  35038. * Converts `string` to an array.
  35039. *
  35040. * @private
  35041. * @param {string} string The string to convert.
  35042. * @returns {Array} Returns the converted array.
  35043. */function stringToArray(string){return hasUnicode(string)?unicodeToArray(string):asciiToArray(string);}/**
  35044. * Used by `_.unescape` to convert HTML entities to characters.
  35045. *
  35046. * @private
  35047. * @param {string} chr The matched character to unescape.
  35048. * @returns {string} Returns the unescaped character.
  35049. */var unescapeHtmlChar=basePropertyOf(htmlUnescapes);/**
  35050. * Gets the size of a Unicode `string`.
  35051. *
  35052. * @private
  35053. * @param {string} string The string inspect.
  35054. * @returns {number} Returns the string size.
  35055. */function unicodeSize(string){var result=reUnicode.lastIndex=0;while(reUnicode.test(string)){++result;}return result;}/**
  35056. * Converts a Unicode `string` to an array.
  35057. *
  35058. * @private
  35059. * @param {string} string The string to convert.
  35060. * @returns {Array} Returns the converted array.
  35061. */function unicodeToArray(string){return string.match(reUnicode)||[];}/**
  35062. * Splits a Unicode `string` into an array of its words.
  35063. *
  35064. * @private
  35065. * @param {string} The string to inspect.
  35066. * @returns {Array} Returns the words of `string`.
  35067. */function unicodeWords(string){return string.match(reUnicodeWord)||[];}/*--------------------------------------------------------------------------*//**
  35068. * Create a new pristine `lodash` function using the `context` object.
  35069. *
  35070. * @static
  35071. * @memberOf _
  35072. * @since 1.1.0
  35073. * @category Util
  35074. * @param {Object} [context=root] The context object.
  35075. * @returns {Function} Returns a new `lodash` function.
  35076. * @example
  35077. *
  35078. * _.mixin({ 'foo': _.constant('foo') });
  35079. *
  35080. * var lodash = _.runInContext();
  35081. * lodash.mixin({ 'bar': lodash.constant('bar') });
  35082. *
  35083. * _.isFunction(_.foo);
  35084. * // => true
  35085. * _.isFunction(_.bar);
  35086. * // => false
  35087. *
  35088. * lodash.isFunction(lodash.foo);
  35089. * // => false
  35090. * lodash.isFunction(lodash.bar);
  35091. * // => true
  35092. *
  35093. * // Create a suped-up `defer` in Node.js.
  35094. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  35095. */var runInContext=function runInContext(context){context=context==null?root:_.defaults(root.Object(),context,_.pick(root,contextProps));/** Built-in constructor references. */var Array=context.Array,Date=context.Date,Error=context.Error,Function=context.Function,Math=context.Math,Object=context.Object,RegExp=context.RegExp,String=context.String,TypeError=context.TypeError;/** Used for built-in method references. */var arrayProto=Array.prototype,funcProto=Function.prototype,objectProto=Object.prototype;/** Used to detect overreaching core-js shims. */var coreJsData=context['__core-js_shared__'];/** Used to resolve the decompiled source of functions. */var funcToString=funcProto.toString;/** Used to check objects for own properties. */var hasOwnProperty=objectProto.hasOwnProperty;/** Used to generate unique IDs. */var idCounter=0;/** Used to detect methods masquerading as native. */var maskSrcKey=function(){var uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||'');return uid?'Symbol(src)_1.'+uid:'';}();/**
  35096. * Used to resolve the
  35097. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  35098. * of values.
  35099. */var nativeObjectToString=objectProto.toString;/** Used to infer the `Object` constructor. */var objectCtorString=funcToString.call(Object);/** Used to restore the original `_` reference in `_.noConflict`. */var oldDash=root._;/** Used to detect if a method is native. */var reIsNative=RegExp('^'+funcToString.call(hasOwnProperty).replace(reRegExpChar,'\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,'$1.*?')+'$');/** Built-in value references. */var Buffer=moduleExports?context.Buffer:undefined,_Symbol=context.Symbol,Uint8Array=context.Uint8Array,allocUnsafe=Buffer?Buffer.allocUnsafe:undefined,getPrototype=overArg(Object.getPrototypeOf,Object),objectCreate=Object.create,propertyIsEnumerable=objectProto.propertyIsEnumerable,splice=arrayProto.splice,spreadableSymbol=_Symbol?_Symbol.isConcatSpreadable:undefined,symIterator=_Symbol?_Symbol.iterator:undefined,symToStringTag=_Symbol?_Symbol.toStringTag:undefined;var defineProperty=function(){try{var func=getNative(Object,'defineProperty');func({},'',{});return func;}catch(e){}}();/** Mocked built-ins. */var ctxClearTimeout=context.clearTimeout!==root.clearTimeout&&context.clearTimeout,ctxNow=Date&&Date.now!==root.Date.now&&Date.now,ctxSetTimeout=context.setTimeout!==root.setTimeout&&context.setTimeout;/* Built-in method references for those with the same name as other `lodash` methods. */var nativeCeil=Math.ceil,nativeFloor=Math.floor,nativeGetSymbols=Object.getOwnPropertySymbols,nativeIsBuffer=Buffer?Buffer.isBuffer:undefined,nativeIsFinite=context.isFinite,nativeJoin=arrayProto.join,nativeKeys=overArg(Object.keys,Object),nativeMax=Math.max,nativeMin=Math.min,nativeNow=Date.now,nativeParseInt=context.parseInt,nativeRandom=Math.random,nativeReverse=arrayProto.reverse;/* Built-in method references that are verified to be native. */var DataView=getNative(context,'DataView'),Map=getNative(context,'Map'),Promise=getNative(context,'Promise'),Set=getNative(context,'Set'),WeakMap=getNative(context,'WeakMap'),nativeCreate=getNative(Object,'create');/** Used to store function metadata. */var metaMap=WeakMap&&new WeakMap();/** Used to lookup unminified function names. */var realNames={};/** Used to detect maps, sets, and weakmaps. */var dataViewCtorString=toSource(DataView),mapCtorString=toSource(Map),promiseCtorString=toSource(Promise),setCtorString=toSource(Set),weakMapCtorString=toSource(WeakMap);/** Used to convert symbols to primitives and strings. */var symbolProto=_Symbol?_Symbol.prototype:undefined,symbolValueOf=symbolProto?symbolProto.valueOf:undefined,symbolToString=symbolProto?symbolProto.toString:undefined;/*------------------------------------------------------------------------*//**
  35100. * Creates a `lodash` object which wraps `value` to enable implicit method
  35101. * chain sequences. Methods that operate on and return arrays, collections,
  35102. * and functions can be chained together. Methods that retrieve a single value
  35103. * or may return a primitive value will automatically end the chain sequence
  35104. * and return the unwrapped value. Otherwise, the value must be unwrapped
  35105. * with `_#value`.
  35106. *
  35107. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  35108. * enabled using `_.chain`.
  35109. *
  35110. * The execution of chained methods is lazy, that is, it's deferred until
  35111. * `_#value` is implicitly or explicitly called.
  35112. *
  35113. * Lazy evaluation allows several methods to support shortcut fusion.
  35114. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  35115. * the creation of intermediate arrays and can greatly reduce the number of
  35116. * iteratee executions. Sections of a chain sequence qualify for shortcut
  35117. * fusion if the section is applied to an array and iteratees accept only
  35118. * one argument. The heuristic for whether a section qualifies for shortcut
  35119. * fusion is subject to change.
  35120. *
  35121. * Chaining is supported in custom builds as long as the `_#value` method is
  35122. * directly or indirectly included in the build.
  35123. *
  35124. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  35125. *
  35126. * The wrapper `Array` methods are:
  35127. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  35128. *
  35129. * The wrapper `String` methods are:
  35130. * `replace` and `split`
  35131. *
  35132. * The wrapper methods that support shortcut fusion are:
  35133. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  35134. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  35135. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  35136. *
  35137. * The chainable wrapper methods are:
  35138. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  35139. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  35140. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  35141. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  35142. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  35143. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  35144. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  35145. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  35146. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  35147. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  35148. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  35149. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  35150. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  35151. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  35152. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  35153. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  35154. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  35155. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  35156. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  35157. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  35158. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  35159. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  35160. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  35161. * `zipObject`, `zipObjectDeep`, and `zipWith`
  35162. *
  35163. * The wrapper methods that are **not** chainable by default are:
  35164. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  35165. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  35166. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  35167. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  35168. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  35169. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  35170. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  35171. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  35172. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  35173. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  35174. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  35175. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  35176. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  35177. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  35178. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  35179. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  35180. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  35181. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  35182. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  35183. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  35184. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  35185. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  35186. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  35187. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  35188. * `upperFirst`, `value`, and `words`
  35189. *
  35190. * @name _
  35191. * @constructor
  35192. * @category Seq
  35193. * @param {*} value The value to wrap in a `lodash` instance.
  35194. * @returns {Object} Returns the new `lodash` wrapper instance.
  35195. * @example
  35196. *
  35197. * function square(n) {
  35198. * return n * n;
  35199. * }
  35200. *
  35201. * var wrapped = _([1, 2, 3]);
  35202. *
  35203. * // Returns an unwrapped value.
  35204. * wrapped.reduce(_.add);
  35205. * // => 6
  35206. *
  35207. * // Returns a wrapped value.
  35208. * var squares = wrapped.map(square);
  35209. *
  35210. * _.isArray(squares);
  35211. * // => false
  35212. *
  35213. * _.isArray(squares.value());
  35214. * // => true
  35215. */function lodash(value){if(isObjectLike(value)&&!isArray(value)&&!(value instanceof LazyWrapper)){if(value instanceof LodashWrapper){return value;}if(hasOwnProperty.call(value,'__wrapped__')){return wrapperClone(value);}}return new LodashWrapper(value);}/**
  35216. * The base implementation of `_.create` without support for assigning
  35217. * properties to the created object.
  35218. *
  35219. * @private
  35220. * @param {Object} proto The object to inherit from.
  35221. * @returns {Object} Returns the new object.
  35222. */var baseCreate=function(){function object(){}return function(proto){if(!isObject(proto)){return{};}if(objectCreate){return objectCreate(proto);}object.prototype=proto;var result=new object();object.prototype=undefined;return result;};}();/**
  35223. * The function whose prototype chain sequence wrappers inherit from.
  35224. *
  35225. * @private
  35226. */function baseLodash(){}// No operation performed.
  35227. /**
  35228. * The base constructor for creating `lodash` wrapper objects.
  35229. *
  35230. * @private
  35231. * @param {*} value The value to wrap.
  35232. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  35233. */function LodashWrapper(value,chainAll){this.__wrapped__=value;this.__actions__=[];this.__chain__=!!chainAll;this.__index__=0;this.__values__=undefined;}/**
  35234. * By default, the template delimiters used by lodash are like those in
  35235. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  35236. * following template settings to use alternative delimiters.
  35237. *
  35238. * @static
  35239. * @memberOf _
  35240. * @type {Object}
  35241. */lodash.templateSettings={/**
  35242. * Used to detect `data` property values to be HTML-escaped.
  35243. *
  35244. * @memberOf _.templateSettings
  35245. * @type {RegExp}
  35246. */'escape':reEscape,/**
  35247. * Used to detect code to be evaluated.
  35248. *
  35249. * @memberOf _.templateSettings
  35250. * @type {RegExp}
  35251. */'evaluate':reEvaluate,/**
  35252. * Used to detect `data` property values to inject.
  35253. *
  35254. * @memberOf _.templateSettings
  35255. * @type {RegExp}
  35256. */'interpolate':reInterpolate,/**
  35257. * Used to reference the data object in the template text.
  35258. *
  35259. * @memberOf _.templateSettings
  35260. * @type {string}
  35261. */'variable':'',/**
  35262. * Used to import variables into the compiled template.
  35263. *
  35264. * @memberOf _.templateSettings
  35265. * @type {Object}
  35266. */'imports':{/**
  35267. * A reference to the `lodash` function.
  35268. *
  35269. * @memberOf _.templateSettings.imports
  35270. * @type {Function}
  35271. */'_':lodash}};// Ensure wrappers are instances of `baseLodash`.
  35272. lodash.prototype=baseLodash.prototype;lodash.prototype.constructor=lodash;LodashWrapper.prototype=baseCreate(baseLodash.prototype);LodashWrapper.prototype.constructor=LodashWrapper;/*------------------------------------------------------------------------*//**
  35273. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  35274. *
  35275. * @private
  35276. * @constructor
  35277. * @param {*} value The value to wrap.
  35278. */function LazyWrapper(value){this.__wrapped__=value;this.__actions__=[];this.__dir__=1;this.__filtered__=false;this.__iteratees__=[];this.__takeCount__=MAX_ARRAY_LENGTH;this.__views__=[];}/**
  35279. * Creates a clone of the lazy wrapper object.
  35280. *
  35281. * @private
  35282. * @name clone
  35283. * @memberOf LazyWrapper
  35284. * @returns {Object} Returns the cloned `LazyWrapper` object.
  35285. */function lazyClone(){var result=new LazyWrapper(this.__wrapped__);result.__actions__=copyArray(this.__actions__);result.__dir__=this.__dir__;result.__filtered__=this.__filtered__;result.__iteratees__=copyArray(this.__iteratees__);result.__takeCount__=this.__takeCount__;result.__views__=copyArray(this.__views__);return result;}/**
  35286. * Reverses the direction of lazy iteration.
  35287. *
  35288. * @private
  35289. * @name reverse
  35290. * @memberOf LazyWrapper
  35291. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  35292. */function lazyReverse(){if(this.__filtered__){var result=new LazyWrapper(this);result.__dir__=-1;result.__filtered__=true;}else{result=this.clone();result.__dir__*=-1;}return result;}/**
  35293. * Extracts the unwrapped value from its lazy wrapper.
  35294. *
  35295. * @private
  35296. * @name value
  35297. * @memberOf LazyWrapper
  35298. * @returns {*} Returns the unwrapped value.
  35299. */function lazyValue(){var array=this.__wrapped__.value(),dir=this.__dir__,isArr=isArray(array),isRight=dir<0,arrLength=isArr?array.length:0,view=getView(0,arrLength,this.__views__),start=view.start,end=view.end,length=end-start,index=isRight?end:start-1,iteratees=this.__iteratees__,iterLength=iteratees.length,resIndex=0,takeCount=nativeMin(length,this.__takeCount__);if(!isArr||!isRight&&arrLength==length&&takeCount==length){return baseWrapperValue(array,this.__actions__);}var result=[];outer:while(length--&&resIndex<takeCount){index+=dir;var iterIndex=-1,value=array[index];while(++iterIndex<iterLength){var data=iteratees[iterIndex],iteratee=data.iteratee,type=data.type,computed=iteratee(value);if(type==LAZY_MAP_FLAG){value=computed;}else if(!computed){if(type==LAZY_FILTER_FLAG){continue outer;}else{break outer;}}}result[resIndex++]=value;}return result;}// Ensure `LazyWrapper` is an instance of `baseLodash`.
  35300. LazyWrapper.prototype=baseCreate(baseLodash.prototype);LazyWrapper.prototype.constructor=LazyWrapper;/*------------------------------------------------------------------------*//**
  35301. * Creates a hash object.
  35302. *
  35303. * @private
  35304. * @constructor
  35305. * @param {Array} [entries] The key-value pairs to cache.
  35306. */function Hash(entries){var index=-1,length=entries==null?0:entries.length;this.clear();while(++index<length){var entry=entries[index];this.set(entry[0],entry[1]);}}/**
  35307. * Removes all key-value entries from the hash.
  35308. *
  35309. * @private
  35310. * @name clear
  35311. * @memberOf Hash
  35312. */function hashClear(){this.__data__=nativeCreate?nativeCreate(null):{};this.size=0;}/**
  35313. * Removes `key` and its value from the hash.
  35314. *
  35315. * @private
  35316. * @name delete
  35317. * @memberOf Hash
  35318. * @param {Object} hash The hash to modify.
  35319. * @param {string} key The key of the value to remove.
  35320. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  35321. */function hashDelete(key){var result=this.has(key)&&delete this.__data__[key];this.size-=result?1:0;return result;}/**
  35322. * Gets the hash value for `key`.
  35323. *
  35324. * @private
  35325. * @name get
  35326. * @memberOf Hash
  35327. * @param {string} key The key of the value to get.
  35328. * @returns {*} Returns the entry value.
  35329. */function hashGet(key){var data=this.__data__;if(nativeCreate){var result=data[key];return result===HASH_UNDEFINED?undefined:result;}return hasOwnProperty.call(data,key)?data[key]:undefined;}/**
  35330. * Checks if a hash value for `key` exists.
  35331. *
  35332. * @private
  35333. * @name has
  35334. * @memberOf Hash
  35335. * @param {string} key The key of the entry to check.
  35336. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  35337. */function hashHas(key){var data=this.__data__;return nativeCreate?data[key]!==undefined:hasOwnProperty.call(data,key);}/**
  35338. * Sets the hash `key` to `value`.
  35339. *
  35340. * @private
  35341. * @name set
  35342. * @memberOf Hash
  35343. * @param {string} key The key of the value to set.
  35344. * @param {*} value The value to set.
  35345. * @returns {Object} Returns the hash instance.
  35346. */function hashSet(key,value){var data=this.__data__;this.size+=this.has(key)?0:1;data[key]=nativeCreate&&value===undefined?HASH_UNDEFINED:value;return this;}// Add methods to `Hash`.
  35347. Hash.prototype.clear=hashClear;Hash.prototype['delete']=hashDelete;Hash.prototype.get=hashGet;Hash.prototype.has=hashHas;Hash.prototype.set=hashSet;/*------------------------------------------------------------------------*//**
  35348. * Creates an list cache object.
  35349. *
  35350. * @private
  35351. * @constructor
  35352. * @param {Array} [entries] The key-value pairs to cache.
  35353. */function ListCache(entries){var index=-1,length=entries==null?0:entries.length;this.clear();while(++index<length){var entry=entries[index];this.set(entry[0],entry[1]);}}/**
  35354. * Removes all key-value entries from the list cache.
  35355. *
  35356. * @private
  35357. * @name clear
  35358. * @memberOf ListCache
  35359. */function listCacheClear(){this.__data__=[];this.size=0;}/**
  35360. * Removes `key` and its value from the list cache.
  35361. *
  35362. * @private
  35363. * @name delete
  35364. * @memberOf ListCache
  35365. * @param {string} key The key of the value to remove.
  35366. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  35367. */function listCacheDelete(key){var data=this.__data__,index=assocIndexOf(data,key);if(index<0){return false;}var lastIndex=data.length-1;if(index==lastIndex){data.pop();}else{splice.call(data,index,1);}--this.size;return true;}/**
  35368. * Gets the list cache value for `key`.
  35369. *
  35370. * @private
  35371. * @name get
  35372. * @memberOf ListCache
  35373. * @param {string} key The key of the value to get.
  35374. * @returns {*} Returns the entry value.
  35375. */function listCacheGet(key){var data=this.__data__,index=assocIndexOf(data,key);return index<0?undefined:data[index][1];}/**
  35376. * Checks if a list cache value for `key` exists.
  35377. *
  35378. * @private
  35379. * @name has
  35380. * @memberOf ListCache
  35381. * @param {string} key The key of the entry to check.
  35382. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  35383. */function listCacheHas(key){return assocIndexOf(this.__data__,key)>-1;}/**
  35384. * Sets the list cache `key` to `value`.
  35385. *
  35386. * @private
  35387. * @name set
  35388. * @memberOf ListCache
  35389. * @param {string} key The key of the value to set.
  35390. * @param {*} value The value to set.
  35391. * @returns {Object} Returns the list cache instance.
  35392. */function listCacheSet(key,value){var data=this.__data__,index=assocIndexOf(data,key);if(index<0){++this.size;data.push([key,value]);}else{data[index][1]=value;}return this;}// Add methods to `ListCache`.
  35393. ListCache.prototype.clear=listCacheClear;ListCache.prototype['delete']=listCacheDelete;ListCache.prototype.get=listCacheGet;ListCache.prototype.has=listCacheHas;ListCache.prototype.set=listCacheSet;/*------------------------------------------------------------------------*//**
  35394. * Creates a map cache object to store key-value pairs.
  35395. *
  35396. * @private
  35397. * @constructor
  35398. * @param {Array} [entries] The key-value pairs to cache.
  35399. */function MapCache(entries){var index=-1,length=entries==null?0:entries.length;this.clear();while(++index<length){var entry=entries[index];this.set(entry[0],entry[1]);}}/**
  35400. * Removes all key-value entries from the map.
  35401. *
  35402. * @private
  35403. * @name clear
  35404. * @memberOf MapCache
  35405. */function mapCacheClear(){this.size=0;this.__data__={'hash':new Hash(),'map':new(Map||ListCache)(),'string':new Hash()};}/**
  35406. * Removes `key` and its value from the map.
  35407. *
  35408. * @private
  35409. * @name delete
  35410. * @memberOf MapCache
  35411. * @param {string} key The key of the value to remove.
  35412. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  35413. */function mapCacheDelete(key){var result=getMapData(this,key)['delete'](key);this.size-=result?1:0;return result;}/**
  35414. * Gets the map value for `key`.
  35415. *
  35416. * @private
  35417. * @name get
  35418. * @memberOf MapCache
  35419. * @param {string} key The key of the value to get.
  35420. * @returns {*} Returns the entry value.
  35421. */function mapCacheGet(key){return getMapData(this,key).get(key);}/**
  35422. * Checks if a map value for `key` exists.
  35423. *
  35424. * @private
  35425. * @name has
  35426. * @memberOf MapCache
  35427. * @param {string} key The key of the entry to check.
  35428. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  35429. */function mapCacheHas(key){return getMapData(this,key).has(key);}/**
  35430. * Sets the map `key` to `value`.
  35431. *
  35432. * @private
  35433. * @name set
  35434. * @memberOf MapCache
  35435. * @param {string} key The key of the value to set.
  35436. * @param {*} value The value to set.
  35437. * @returns {Object} Returns the map cache instance.
  35438. */function mapCacheSet(key,value){var data=getMapData(this,key),size=data.size;data.set(key,value);this.size+=data.size==size?0:1;return this;}// Add methods to `MapCache`.
  35439. MapCache.prototype.clear=mapCacheClear;MapCache.prototype['delete']=mapCacheDelete;MapCache.prototype.get=mapCacheGet;MapCache.prototype.has=mapCacheHas;MapCache.prototype.set=mapCacheSet;/*------------------------------------------------------------------------*//**
  35440. *
  35441. * Creates an array cache object to store unique values.
  35442. *
  35443. * @private
  35444. * @constructor
  35445. * @param {Array} [values] The values to cache.
  35446. */function SetCache(values){var index=-1,length=values==null?0:values.length;this.__data__=new MapCache();while(++index<length){this.add(values[index]);}}/**
  35447. * Adds `value` to the array cache.
  35448. *
  35449. * @private
  35450. * @name add
  35451. * @memberOf SetCache
  35452. * @alias push
  35453. * @param {*} value The value to cache.
  35454. * @returns {Object} Returns the cache instance.
  35455. */function setCacheAdd(value){this.__data__.set(value,HASH_UNDEFINED);return this;}/**
  35456. * Checks if `value` is in the array cache.
  35457. *
  35458. * @private
  35459. * @name has
  35460. * @memberOf SetCache
  35461. * @param {*} value The value to search for.
  35462. * @returns {number} Returns `true` if `value` is found, else `false`.
  35463. */function setCacheHas(value){return this.__data__.has(value);}// Add methods to `SetCache`.
  35464. SetCache.prototype.add=SetCache.prototype.push=setCacheAdd;SetCache.prototype.has=setCacheHas;/*------------------------------------------------------------------------*//**
  35465. * Creates a stack cache object to store key-value pairs.
  35466. *
  35467. * @private
  35468. * @constructor
  35469. * @param {Array} [entries] The key-value pairs to cache.
  35470. */function Stack(entries){var data=this.__data__=new ListCache(entries);this.size=data.size;}/**
  35471. * Removes all key-value entries from the stack.
  35472. *
  35473. * @private
  35474. * @name clear
  35475. * @memberOf Stack
  35476. */function stackClear(){this.__data__=new ListCache();this.size=0;}/**
  35477. * Removes `key` and its value from the stack.
  35478. *
  35479. * @private
  35480. * @name delete
  35481. * @memberOf Stack
  35482. * @param {string} key The key of the value to remove.
  35483. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  35484. */function stackDelete(key){var data=this.__data__,result=data['delete'](key);this.size=data.size;return result;}/**
  35485. * Gets the stack value for `key`.
  35486. *
  35487. * @private
  35488. * @name get
  35489. * @memberOf Stack
  35490. * @param {string} key The key of the value to get.
  35491. * @returns {*} Returns the entry value.
  35492. */function stackGet(key){return this.__data__.get(key);}/**
  35493. * Checks if a stack value for `key` exists.
  35494. *
  35495. * @private
  35496. * @name has
  35497. * @memberOf Stack
  35498. * @param {string} key The key of the entry to check.
  35499. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  35500. */function stackHas(key){return this.__data__.has(key);}/**
  35501. * Sets the stack `key` to `value`.
  35502. *
  35503. * @private
  35504. * @name set
  35505. * @memberOf Stack
  35506. * @param {string} key The key of the value to set.
  35507. * @param {*} value The value to set.
  35508. * @returns {Object} Returns the stack cache instance.
  35509. */function stackSet(key,value){var data=this.__data__;if(data instanceof ListCache){var pairs=data.__data__;if(!Map||pairs.length<LARGE_ARRAY_SIZE-1){pairs.push([key,value]);this.size=++data.size;return this;}data=this.__data__=new MapCache(pairs);}data.set(key,value);this.size=data.size;return this;}// Add methods to `Stack`.
  35510. Stack.prototype.clear=stackClear;Stack.prototype['delete']=stackDelete;Stack.prototype.get=stackGet;Stack.prototype.has=stackHas;Stack.prototype.set=stackSet;/*------------------------------------------------------------------------*//**
  35511. * Creates an array of the enumerable property names of the array-like `value`.
  35512. *
  35513. * @private
  35514. * @param {*} value The value to query.
  35515. * @param {boolean} inherited Specify returning inherited property names.
  35516. * @returns {Array} Returns the array of property names.
  35517. */function arrayLikeKeys(value,inherited){var isArr=isArray(value),isArg=!isArr&&isArguments(value),isBuff=!isArr&&!isArg&&isBuffer(value),isType=!isArr&&!isArg&&!isBuff&&isTypedArray(value),skipIndexes=isArr||isArg||isBuff||isType,result=skipIndexes?baseTimes(value.length,String):[],length=result.length;for(var key in value){if((inherited||hasOwnProperty.call(value,key))&&!(skipIndexes&&(// Safari 9 has enumerable `arguments.length` in strict mode.
  35518. key=='length'||// Node.js 0.10 has enumerable non-index properties on buffers.
  35519. isBuff&&(key=='offset'||key=='parent')||// PhantomJS 2 has enumerable non-index properties on typed arrays.
  35520. isType&&(key=='buffer'||key=='byteLength'||key=='byteOffset')||// Skip index properties.
  35521. isIndex(key,length)))){result.push(key);}}return result;}/**
  35522. * A specialized version of `_.sample` for arrays.
  35523. *
  35524. * @private
  35525. * @param {Array} array The array to sample.
  35526. * @returns {*} Returns the random element.
  35527. */function arraySample(array){var length=array.length;return length?array[baseRandom(0,length-1)]:undefined;}/**
  35528. * A specialized version of `_.sampleSize` for arrays.
  35529. *
  35530. * @private
  35531. * @param {Array} array The array to sample.
  35532. * @param {number} n The number of elements to sample.
  35533. * @returns {Array} Returns the random elements.
  35534. */function arraySampleSize(array,n){return shuffleSelf(copyArray(array),baseClamp(n,0,array.length));}/**
  35535. * A specialized version of `_.shuffle` for arrays.
  35536. *
  35537. * @private
  35538. * @param {Array} array The array to shuffle.
  35539. * @returns {Array} Returns the new shuffled array.
  35540. */function arrayShuffle(array){return shuffleSelf(copyArray(array));}/**
  35541. * This function is like `assignValue` except that it doesn't assign
  35542. * `undefined` values.
  35543. *
  35544. * @private
  35545. * @param {Object} object The object to modify.
  35546. * @param {string} key The key of the property to assign.
  35547. * @param {*} value The value to assign.
  35548. */function assignMergeValue(object,key,value){if(value!==undefined&&!eq(object[key],value)||value===undefined&&!(key in object)){baseAssignValue(object,key,value);}}/**
  35549. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  35550. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  35551. * for equality comparisons.
  35552. *
  35553. * @private
  35554. * @param {Object} object The object to modify.
  35555. * @param {string} key The key of the property to assign.
  35556. * @param {*} value The value to assign.
  35557. */function assignValue(object,key,value){var objValue=object[key];if(!(hasOwnProperty.call(object,key)&&eq(objValue,value))||value===undefined&&!(key in object)){baseAssignValue(object,key,value);}}/**
  35558. * Gets the index at which the `key` is found in `array` of key-value pairs.
  35559. *
  35560. * @private
  35561. * @param {Array} array The array to inspect.
  35562. * @param {*} key The key to search for.
  35563. * @returns {number} Returns the index of the matched value, else `-1`.
  35564. */function assocIndexOf(array,key){var length=array.length;while(length--){if(eq(array[length][0],key)){return length;}}return-1;}/**
  35565. * Aggregates elements of `collection` on `accumulator` with keys transformed
  35566. * by `iteratee` and values set by `setter`.
  35567. *
  35568. * @private
  35569. * @param {Array|Object} collection The collection to iterate over.
  35570. * @param {Function} setter The function to set `accumulator` values.
  35571. * @param {Function} iteratee The iteratee to transform keys.
  35572. * @param {Object} accumulator The initial aggregated object.
  35573. * @returns {Function} Returns `accumulator`.
  35574. */function baseAggregator(collection,setter,iteratee,accumulator){baseEach(collection,function(value,key,collection){setter(accumulator,value,iteratee(value),collection);});return accumulator;}/**
  35575. * The base implementation of `_.assign` without support for multiple sources
  35576. * or `customizer` functions.
  35577. *
  35578. * @private
  35579. * @param {Object} object The destination object.
  35580. * @param {Object} source The source object.
  35581. * @returns {Object} Returns `object`.
  35582. */function baseAssign(object,source){return object&&copyObject(source,keys(source),object);}/**
  35583. * The base implementation of `_.assignIn` without support for multiple sources
  35584. * or `customizer` functions.
  35585. *
  35586. * @private
  35587. * @param {Object} object The destination object.
  35588. * @param {Object} source The source object.
  35589. * @returns {Object} Returns `object`.
  35590. */function baseAssignIn(object,source){return object&&copyObject(source,keysIn(source),object);}/**
  35591. * The base implementation of `assignValue` and `assignMergeValue` without
  35592. * value checks.
  35593. *
  35594. * @private
  35595. * @param {Object} object The object to modify.
  35596. * @param {string} key The key of the property to assign.
  35597. * @param {*} value The value to assign.
  35598. */function baseAssignValue(object,key,value){if(key=='__proto__'&&defineProperty){defineProperty(object,key,{'configurable':true,'enumerable':true,'value':value,'writable':true});}else{object[key]=value;}}/**
  35599. * The base implementation of `_.at` without support for individual paths.
  35600. *
  35601. * @private
  35602. * @param {Object} object The object to iterate over.
  35603. * @param {string[]} paths The property paths to pick.
  35604. * @returns {Array} Returns the picked elements.
  35605. */function baseAt(object,paths){var index=-1,length=paths.length,result=Array(length),skip=object==null;while(++index<length){result[index]=skip?undefined:get(object,paths[index]);}return result;}/**
  35606. * The base implementation of `_.clamp` which doesn't coerce arguments.
  35607. *
  35608. * @private
  35609. * @param {number} number The number to clamp.
  35610. * @param {number} [lower] The lower bound.
  35611. * @param {number} upper The upper bound.
  35612. * @returns {number} Returns the clamped number.
  35613. */function baseClamp(number,lower,upper){if(number===number){if(upper!==undefined){number=number<=upper?number:upper;}if(lower!==undefined){number=number>=lower?number:lower;}}return number;}/**
  35614. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  35615. * traversed objects.
  35616. *
  35617. * @private
  35618. * @param {*} value The value to clone.
  35619. * @param {boolean} bitmask The bitmask flags.
  35620. * 1 - Deep clone
  35621. * 2 - Flatten inherited properties
  35622. * 4 - Clone symbols
  35623. * @param {Function} [customizer] The function to customize cloning.
  35624. * @param {string} [key] The key of `value`.
  35625. * @param {Object} [object] The parent object of `value`.
  35626. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  35627. * @returns {*} Returns the cloned value.
  35628. */function baseClone(value,bitmask,customizer,key,object,stack){var result,isDeep=bitmask&CLONE_DEEP_FLAG,isFlat=bitmask&CLONE_FLAT_FLAG,isFull=bitmask&CLONE_SYMBOLS_FLAG;if(customizer){result=object?customizer(value,key,object,stack):customizer(value);}if(result!==undefined){return result;}if(!isObject(value)){return value;}var isArr=isArray(value);if(isArr){result=initCloneArray(value);if(!isDeep){return copyArray(value,result);}}else{var tag=getTag(value),isFunc=tag==funcTag||tag==genTag;if(isBuffer(value)){return cloneBuffer(value,isDeep);}if(tag==objectTag||tag==argsTag||isFunc&&!object){result=isFlat||isFunc?{}:initCloneObject(value);if(!isDeep){return isFlat?copySymbolsIn(value,baseAssignIn(result,value)):copySymbols(value,baseAssign(result,value));}}else{if(!cloneableTags[tag]){return object?value:{};}result=initCloneByTag(value,tag,isDeep);}}// Check for circular references and return its corresponding clone.
  35629. stack||(stack=new Stack());var stacked=stack.get(value);if(stacked){return stacked;}stack.set(value,result);if(isSet(value)){value.forEach(function(subValue){result.add(baseClone(subValue,bitmask,customizer,subValue,value,stack));});return result;}if(isMap(value)){value.forEach(function(subValue,key){result.set(key,baseClone(subValue,bitmask,customizer,key,value,stack));});return result;}var keysFunc=isFull?isFlat?getAllKeysIn:getAllKeys:isFlat?keysIn:keys;var props=isArr?undefined:keysFunc(value);arrayEach(props||value,function(subValue,key){if(props){key=subValue;subValue=value[key];}// Recursively populate clone (susceptible to call stack limits).
  35630. assignValue(result,key,baseClone(subValue,bitmask,customizer,key,value,stack));});return result;}/**
  35631. * The base implementation of `_.conforms` which doesn't clone `source`.
  35632. *
  35633. * @private
  35634. * @param {Object} source The object of property predicates to conform to.
  35635. * @returns {Function} Returns the new spec function.
  35636. */function baseConforms(source){var props=keys(source);return function(object){return baseConformsTo(object,source,props);};}/**
  35637. * The base implementation of `_.conformsTo` which accepts `props` to check.
  35638. *
  35639. * @private
  35640. * @param {Object} object The object to inspect.
  35641. * @param {Object} source The object of property predicates to conform to.
  35642. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  35643. */function baseConformsTo(object,source,props){var length=props.length;if(object==null){return!length;}object=Object(object);while(length--){var key=props[length],predicate=source[key],value=object[key];if(value===undefined&&!(key in object)||!predicate(value)){return false;}}return true;}/**
  35644. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  35645. * to provide to `func`.
  35646. *
  35647. * @private
  35648. * @param {Function} func The function to delay.
  35649. * @param {number} wait The number of milliseconds to delay invocation.
  35650. * @param {Array} args The arguments to provide to `func`.
  35651. * @returns {number|Object} Returns the timer id or timeout object.
  35652. */function baseDelay(func,wait,args){if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}return setTimeout(function(){func.apply(undefined,args);},wait);}/**
  35653. * The base implementation of methods like `_.difference` without support
  35654. * for excluding multiple arrays or iteratee shorthands.
  35655. *
  35656. * @private
  35657. * @param {Array} array The array to inspect.
  35658. * @param {Array} values The values to exclude.
  35659. * @param {Function} [iteratee] The iteratee invoked per element.
  35660. * @param {Function} [comparator] The comparator invoked per element.
  35661. * @returns {Array} Returns the new array of filtered values.
  35662. */function baseDifference(array,values,iteratee,comparator){var index=-1,includes=arrayIncludes,isCommon=true,length=array.length,result=[],valuesLength=values.length;if(!length){return result;}if(iteratee){values=arrayMap(values,baseUnary(iteratee));}if(comparator){includes=arrayIncludesWith;isCommon=false;}else if(values.length>=LARGE_ARRAY_SIZE){includes=cacheHas;isCommon=false;values=new SetCache(values);}outer:while(++index<length){var value=array[index],computed=iteratee==null?value:iteratee(value);value=comparator||value!==0?value:0;if(isCommon&&computed===computed){var valuesIndex=valuesLength;while(valuesIndex--){if(values[valuesIndex]===computed){continue outer;}}result.push(value);}else if(!includes(values,computed,comparator)){result.push(value);}}return result;}/**
  35663. * The base implementation of `_.forEach` without support for iteratee shorthands.
  35664. *
  35665. * @private
  35666. * @param {Array|Object} collection The collection to iterate over.
  35667. * @param {Function} iteratee The function invoked per iteration.
  35668. * @returns {Array|Object} Returns `collection`.
  35669. */var baseEach=createBaseEach(baseForOwn);/**
  35670. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  35671. *
  35672. * @private
  35673. * @param {Array|Object} collection The collection to iterate over.
  35674. * @param {Function} iteratee The function invoked per iteration.
  35675. * @returns {Array|Object} Returns `collection`.
  35676. */var baseEachRight=createBaseEach(baseForOwnRight,true);/**
  35677. * The base implementation of `_.every` without support for iteratee shorthands.
  35678. *
  35679. * @private
  35680. * @param {Array|Object} collection The collection to iterate over.
  35681. * @param {Function} predicate The function invoked per iteration.
  35682. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  35683. * else `false`
  35684. */function baseEvery(collection,predicate){var result=true;baseEach(collection,function(value,index,collection){result=!!predicate(value,index,collection);return result;});return result;}/**
  35685. * The base implementation of methods like `_.max` and `_.min` which accepts a
  35686. * `comparator` to determine the extremum value.
  35687. *
  35688. * @private
  35689. * @param {Array} array The array to iterate over.
  35690. * @param {Function} iteratee The iteratee invoked per iteration.
  35691. * @param {Function} comparator The comparator used to compare values.
  35692. * @returns {*} Returns the extremum value.
  35693. */function baseExtremum(array,iteratee,comparator){var index=-1,length=array.length;while(++index<length){var value=array[index],current=iteratee(value);if(current!=null&&(computed===undefined?current===current&&!isSymbol(current):comparator(current,computed))){var computed=current,result=value;}}return result;}/**
  35694. * The base implementation of `_.fill` without an iteratee call guard.
  35695. *
  35696. * @private
  35697. * @param {Array} array The array to fill.
  35698. * @param {*} value The value to fill `array` with.
  35699. * @param {number} [start=0] The start position.
  35700. * @param {number} [end=array.length] The end position.
  35701. * @returns {Array} Returns `array`.
  35702. */function baseFill(array,value,start,end){var length=array.length;start=toInteger(start);if(start<0){start=-start>length?0:length+start;}end=end===undefined||end>length?length:toInteger(end);if(end<0){end+=length;}end=start>end?0:toLength(end);while(start<end){array[start++]=value;}return array;}/**
  35703. * The base implementation of `_.filter` without support for iteratee shorthands.
  35704. *
  35705. * @private
  35706. * @param {Array|Object} collection The collection to iterate over.
  35707. * @param {Function} predicate The function invoked per iteration.
  35708. * @returns {Array} Returns the new filtered array.
  35709. */function baseFilter(collection,predicate){var result=[];baseEach(collection,function(value,index,collection){if(predicate(value,index,collection)){result.push(value);}});return result;}/**
  35710. * The base implementation of `_.flatten` with support for restricting flattening.
  35711. *
  35712. * @private
  35713. * @param {Array} array The array to flatten.
  35714. * @param {number} depth The maximum recursion depth.
  35715. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  35716. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  35717. * @param {Array} [result=[]] The initial result value.
  35718. * @returns {Array} Returns the new flattened array.
  35719. */function baseFlatten(array,depth,predicate,isStrict,result){var index=-1,length=array.length;predicate||(predicate=isFlattenable);result||(result=[]);while(++index<length){var value=array[index];if(depth>0&&predicate(value)){if(depth>1){// Recursively flatten arrays (susceptible to call stack limits).
  35720. baseFlatten(value,depth-1,predicate,isStrict,result);}else{arrayPush(result,value);}}else if(!isStrict){result[result.length]=value;}}return result;}/**
  35721. * The base implementation of `baseForOwn` which iterates over `object`
  35722. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  35723. * Iteratee functions may exit iteration early by explicitly returning `false`.
  35724. *
  35725. * @private
  35726. * @param {Object} object The object to iterate over.
  35727. * @param {Function} iteratee The function invoked per iteration.
  35728. * @param {Function} keysFunc The function to get the keys of `object`.
  35729. * @returns {Object} Returns `object`.
  35730. */var baseFor=createBaseFor();/**
  35731. * This function is like `baseFor` except that it iterates over properties
  35732. * in the opposite order.
  35733. *
  35734. * @private
  35735. * @param {Object} object The object to iterate over.
  35736. * @param {Function} iteratee The function invoked per iteration.
  35737. * @param {Function} keysFunc The function to get the keys of `object`.
  35738. * @returns {Object} Returns `object`.
  35739. */var baseForRight=createBaseFor(true);/**
  35740. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  35741. *
  35742. * @private
  35743. * @param {Object} object The object to iterate over.
  35744. * @param {Function} iteratee The function invoked per iteration.
  35745. * @returns {Object} Returns `object`.
  35746. */function baseForOwn(object,iteratee){return object&&baseFor(object,iteratee,keys);}/**
  35747. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  35748. *
  35749. * @private
  35750. * @param {Object} object The object to iterate over.
  35751. * @param {Function} iteratee The function invoked per iteration.
  35752. * @returns {Object} Returns `object`.
  35753. */function baseForOwnRight(object,iteratee){return object&&baseForRight(object,iteratee,keys);}/**
  35754. * The base implementation of `_.functions` which creates an array of
  35755. * `object` function property names filtered from `props`.
  35756. *
  35757. * @private
  35758. * @param {Object} object The object to inspect.
  35759. * @param {Array} props The property names to filter.
  35760. * @returns {Array} Returns the function names.
  35761. */function baseFunctions(object,props){return arrayFilter(props,function(key){return isFunction(object[key]);});}/**
  35762. * The base implementation of `_.get` without support for default values.
  35763. *
  35764. * @private
  35765. * @param {Object} object The object to query.
  35766. * @param {Array|string} path The path of the property to get.
  35767. * @returns {*} Returns the resolved value.
  35768. */function baseGet(object,path){path=castPath(path,object);var index=0,length=path.length;while(object!=null&&index<length){object=object[toKey(path[index++])];}return index&&index==length?object:undefined;}/**
  35769. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  35770. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  35771. * symbols of `object`.
  35772. *
  35773. * @private
  35774. * @param {Object} object The object to query.
  35775. * @param {Function} keysFunc The function to get the keys of `object`.
  35776. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  35777. * @returns {Array} Returns the array of property names and symbols.
  35778. */function baseGetAllKeys(object,keysFunc,symbolsFunc){var result=keysFunc(object);return isArray(object)?result:arrayPush(result,symbolsFunc(object));}/**
  35779. * The base implementation of `getTag` without fallbacks for buggy environments.
  35780. *
  35781. * @private
  35782. * @param {*} value The value to query.
  35783. * @returns {string} Returns the `toStringTag`.
  35784. */function baseGetTag(value){if(value==null){return value===undefined?undefinedTag:nullTag;}return symToStringTag&&symToStringTag in Object(value)?getRawTag(value):objectToString(value);}/**
  35785. * The base implementation of `_.gt` which doesn't coerce arguments.
  35786. *
  35787. * @private
  35788. * @param {*} value The value to compare.
  35789. * @param {*} other The other value to compare.
  35790. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  35791. * else `false`.
  35792. */function baseGt(value,other){return value>other;}/**
  35793. * The base implementation of `_.has` without support for deep paths.
  35794. *
  35795. * @private
  35796. * @param {Object} [object] The object to query.
  35797. * @param {Array|string} key The key to check.
  35798. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  35799. */function baseHas(object,key){return object!=null&&hasOwnProperty.call(object,key);}/**
  35800. * The base implementation of `_.hasIn` without support for deep paths.
  35801. *
  35802. * @private
  35803. * @param {Object} [object] The object to query.
  35804. * @param {Array|string} key The key to check.
  35805. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  35806. */function baseHasIn(object,key){return object!=null&&key in Object(object);}/**
  35807. * The base implementation of `_.inRange` which doesn't coerce arguments.
  35808. *
  35809. * @private
  35810. * @param {number} number The number to check.
  35811. * @param {number} start The start of the range.
  35812. * @param {number} end The end of the range.
  35813. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  35814. */function baseInRange(number,start,end){return number>=nativeMin(start,end)&&number<nativeMax(start,end);}/**
  35815. * The base implementation of methods like `_.intersection`, without support
  35816. * for iteratee shorthands, that accepts an array of arrays to inspect.
  35817. *
  35818. * @private
  35819. * @param {Array} arrays The arrays to inspect.
  35820. * @param {Function} [iteratee] The iteratee invoked per element.
  35821. * @param {Function} [comparator] The comparator invoked per element.
  35822. * @returns {Array} Returns the new array of shared values.
  35823. */function baseIntersection(arrays,iteratee,comparator){var includes=comparator?arrayIncludesWith:arrayIncludes,length=arrays[0].length,othLength=arrays.length,othIndex=othLength,caches=Array(othLength),maxLength=Infinity,result=[];while(othIndex--){var array=arrays[othIndex];if(othIndex&&iteratee){array=arrayMap(array,baseUnary(iteratee));}maxLength=nativeMin(array.length,maxLength);caches[othIndex]=!comparator&&(iteratee||length>=120&&array.length>=120)?new SetCache(othIndex&&array):undefined;}array=arrays[0];var index=-1,seen=caches[0];outer:while(++index<length&&result.length<maxLength){var value=array[index],computed=iteratee?iteratee(value):value;value=comparator||value!==0?value:0;if(!(seen?cacheHas(seen,computed):includes(result,computed,comparator))){othIndex=othLength;while(--othIndex){var cache=caches[othIndex];if(!(cache?cacheHas(cache,computed):includes(arrays[othIndex],computed,comparator))){continue outer;}}if(seen){seen.push(computed);}result.push(value);}}return result;}/**
  35824. * The base implementation of `_.invert` and `_.invertBy` which inverts
  35825. * `object` with values transformed by `iteratee` and set by `setter`.
  35826. *
  35827. * @private
  35828. * @param {Object} object The object to iterate over.
  35829. * @param {Function} setter The function to set `accumulator` values.
  35830. * @param {Function} iteratee The iteratee to transform values.
  35831. * @param {Object} accumulator The initial inverted object.
  35832. * @returns {Function} Returns `accumulator`.
  35833. */function baseInverter(object,setter,iteratee,accumulator){baseForOwn(object,function(value,key,object){setter(accumulator,iteratee(value),key,object);});return accumulator;}/**
  35834. * The base implementation of `_.invoke` without support for individual
  35835. * method arguments.
  35836. *
  35837. * @private
  35838. * @param {Object} object The object to query.
  35839. * @param {Array|string} path The path of the method to invoke.
  35840. * @param {Array} args The arguments to invoke the method with.
  35841. * @returns {*} Returns the result of the invoked method.
  35842. */function baseInvoke(object,path,args){path=castPath(path,object);object=parent(object,path);var func=object==null?object:object[toKey(last(path))];return func==null?undefined:apply(func,object,args);}/**
  35843. * The base implementation of `_.isArguments`.
  35844. *
  35845. * @private
  35846. * @param {*} value The value to check.
  35847. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  35848. */function baseIsArguments(value){return isObjectLike(value)&&baseGetTag(value)==argsTag;}/**
  35849. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  35850. *
  35851. * @private
  35852. * @param {*} value The value to check.
  35853. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  35854. */function baseIsArrayBuffer(value){return isObjectLike(value)&&baseGetTag(value)==arrayBufferTag;}/**
  35855. * The base implementation of `_.isDate` without Node.js optimizations.
  35856. *
  35857. * @private
  35858. * @param {*} value The value to check.
  35859. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  35860. */function baseIsDate(value){return isObjectLike(value)&&baseGetTag(value)==dateTag;}/**
  35861. * The base implementation of `_.isEqual` which supports partial comparisons
  35862. * and tracks traversed objects.
  35863. *
  35864. * @private
  35865. * @param {*} value The value to compare.
  35866. * @param {*} other The other value to compare.
  35867. * @param {boolean} bitmask The bitmask flags.
  35868. * 1 - Unordered comparison
  35869. * 2 - Partial comparison
  35870. * @param {Function} [customizer] The function to customize comparisons.
  35871. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  35872. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  35873. */function baseIsEqual(value,other,bitmask,customizer,stack){if(value===other){return true;}if(value==null||other==null||!isObjectLike(value)&&!isObjectLike(other)){return value!==value&&other!==other;}return baseIsEqualDeep(value,other,bitmask,customizer,baseIsEqual,stack);}/**
  35874. * A specialized version of `baseIsEqual` for arrays and objects which performs
  35875. * deep comparisons and tracks traversed objects enabling objects with circular
  35876. * references to be compared.
  35877. *
  35878. * @private
  35879. * @param {Object} object The object to compare.
  35880. * @param {Object} other The other object to compare.
  35881. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  35882. * @param {Function} customizer The function to customize comparisons.
  35883. * @param {Function} equalFunc The function to determine equivalents of values.
  35884. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  35885. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  35886. */function baseIsEqualDeep(object,other,bitmask,customizer,equalFunc,stack){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=objIsArr?arrayTag:getTag(object),othTag=othIsArr?arrayTag:getTag(other);objTag=objTag==argsTag?objectTag:objTag;othTag=othTag==argsTag?objectTag:othTag;var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&isBuffer(object)){if(!isBuffer(other)){return false;}objIsArr=true;objIsObj=false;}if(isSameTag&&!objIsObj){stack||(stack=new Stack());return objIsArr||isTypedArray(object)?equalArrays(object,other,bitmask,customizer,equalFunc,stack):equalByTag(object,other,objTag,bitmask,customizer,equalFunc,stack);}if(!(bitmask&COMPARE_PARTIAL_FLAG)){var objIsWrapped=objIsObj&&hasOwnProperty.call(object,'__wrapped__'),othIsWrapped=othIsObj&&hasOwnProperty.call(other,'__wrapped__');if(objIsWrapped||othIsWrapped){var objUnwrapped=objIsWrapped?object.value():object,othUnwrapped=othIsWrapped?other.value():other;stack||(stack=new Stack());return equalFunc(objUnwrapped,othUnwrapped,bitmask,customizer,stack);}}if(!isSameTag){return false;}stack||(stack=new Stack());return equalObjects(object,other,bitmask,customizer,equalFunc,stack);}/**
  35887. * The base implementation of `_.isMap` without Node.js optimizations.
  35888. *
  35889. * @private
  35890. * @param {*} value The value to check.
  35891. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  35892. */function baseIsMap(value){return isObjectLike(value)&&getTag(value)==mapTag;}/**
  35893. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  35894. *
  35895. * @private
  35896. * @param {Object} object The object to inspect.
  35897. * @param {Object} source The object of property values to match.
  35898. * @param {Array} matchData The property names, values, and compare flags to match.
  35899. * @param {Function} [customizer] The function to customize comparisons.
  35900. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  35901. */function baseIsMatch(object,source,matchData,customizer){var index=matchData.length,length=index,noCustomizer=!customizer;if(object==null){return!length;}object=Object(object);while(index--){var data=matchData[index];if(noCustomizer&&data[2]?data[1]!==object[data[0]]:!(data[0]in object)){return false;}}while(++index<length){data=matchData[index];var key=data[0],objValue=object[key],srcValue=data[1];if(noCustomizer&&data[2]){if(objValue===undefined&&!(key in object)){return false;}}else{var stack=new Stack();if(customizer){var result=customizer(objValue,srcValue,key,object,source,stack);}if(!(result===undefined?baseIsEqual(srcValue,objValue,COMPARE_PARTIAL_FLAG|COMPARE_UNORDERED_FLAG,customizer,stack):result)){return false;}}}return true;}/**
  35902. * The base implementation of `_.isNative` without bad shim checks.
  35903. *
  35904. * @private
  35905. * @param {*} value The value to check.
  35906. * @returns {boolean} Returns `true` if `value` is a native function,
  35907. * else `false`.
  35908. */function baseIsNative(value){if(!isObject(value)||isMasked(value)){return false;}var pattern=isFunction(value)?reIsNative:reIsHostCtor;return pattern.test(toSource(value));}/**
  35909. * The base implementation of `_.isRegExp` without Node.js optimizations.
  35910. *
  35911. * @private
  35912. * @param {*} value The value to check.
  35913. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  35914. */function baseIsRegExp(value){return isObjectLike(value)&&baseGetTag(value)==regexpTag;}/**
  35915. * The base implementation of `_.isSet` without Node.js optimizations.
  35916. *
  35917. * @private
  35918. * @param {*} value The value to check.
  35919. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  35920. */function baseIsSet(value){return isObjectLike(value)&&getTag(value)==setTag;}/**
  35921. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  35922. *
  35923. * @private
  35924. * @param {*} value The value to check.
  35925. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  35926. */function baseIsTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[baseGetTag(value)];}/**
  35927. * The base implementation of `_.iteratee`.
  35928. *
  35929. * @private
  35930. * @param {*} [value=_.identity] The value to convert to an iteratee.
  35931. * @returns {Function} Returns the iteratee.
  35932. */function baseIteratee(value){// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  35933. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  35934. if(typeof value=='function'){return value;}if(value==null){return identity;}if((typeof value==='undefined'?'undefined':_typeof(value))=='object'){return isArray(value)?baseMatchesProperty(value[0],value[1]):baseMatches(value);}return property(value);}/**
  35935. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  35936. *
  35937. * @private
  35938. * @param {Object} object The object to query.
  35939. * @returns {Array} Returns the array of property names.
  35940. */function baseKeys(object){if(!isPrototype(object)){return nativeKeys(object);}var result=[];for(var key in Object(object)){if(hasOwnProperty.call(object,key)&&key!='constructor'){result.push(key);}}return result;}/**
  35941. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  35942. *
  35943. * @private
  35944. * @param {Object} object The object to query.
  35945. * @returns {Array} Returns the array of property names.
  35946. */function baseKeysIn(object){if(!isObject(object)){return nativeKeysIn(object);}var isProto=isPrototype(object),result=[];for(var key in object){if(!(key=='constructor'&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key);}}return result;}/**
  35947. * The base implementation of `_.lt` which doesn't coerce arguments.
  35948. *
  35949. * @private
  35950. * @param {*} value The value to compare.
  35951. * @param {*} other The other value to compare.
  35952. * @returns {boolean} Returns `true` if `value` is less than `other`,
  35953. * else `false`.
  35954. */function baseLt(value,other){return value<other;}/**
  35955. * The base implementation of `_.map` without support for iteratee shorthands.
  35956. *
  35957. * @private
  35958. * @param {Array|Object} collection The collection to iterate over.
  35959. * @param {Function} iteratee The function invoked per iteration.
  35960. * @returns {Array} Returns the new mapped array.
  35961. */function baseMap(collection,iteratee){var index=-1,result=isArrayLike(collection)?Array(collection.length):[];baseEach(collection,function(value,key,collection){result[++index]=iteratee(value,key,collection);});return result;}/**
  35962. * The base implementation of `_.matches` which doesn't clone `source`.
  35963. *
  35964. * @private
  35965. * @param {Object} source The object of property values to match.
  35966. * @returns {Function} Returns the new spec function.
  35967. */function baseMatches(source){var matchData=getMatchData(source);if(matchData.length==1&&matchData[0][2]){return matchesStrictComparable(matchData[0][0],matchData[0][1]);}return function(object){return object===source||baseIsMatch(object,source,matchData);};}/**
  35968. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  35969. *
  35970. * @private
  35971. * @param {string} path The path of the property to get.
  35972. * @param {*} srcValue The value to match.
  35973. * @returns {Function} Returns the new spec function.
  35974. */function baseMatchesProperty(path,srcValue){if(isKey(path)&&isStrictComparable(srcValue)){return matchesStrictComparable(toKey(path),srcValue);}return function(object){var objValue=get(object,path);return objValue===undefined&&objValue===srcValue?hasIn(object,path):baseIsEqual(srcValue,objValue,COMPARE_PARTIAL_FLAG|COMPARE_UNORDERED_FLAG);};}/**
  35975. * The base implementation of `_.merge` without support for multiple sources.
  35976. *
  35977. * @private
  35978. * @param {Object} object The destination object.
  35979. * @param {Object} source The source object.
  35980. * @param {number} srcIndex The index of `source`.
  35981. * @param {Function} [customizer] The function to customize merged values.
  35982. * @param {Object} [stack] Tracks traversed source values and their merged
  35983. * counterparts.
  35984. */function baseMerge(object,source,srcIndex,customizer,stack){if(object===source){return;}baseFor(source,function(srcValue,key){if(isObject(srcValue)){stack||(stack=new Stack());baseMergeDeep(object,source,key,srcIndex,baseMerge,customizer,stack);}else{var newValue=customizer?customizer(safeGet(object,key),srcValue,key+'',object,source,stack):undefined;if(newValue===undefined){newValue=srcValue;}assignMergeValue(object,key,newValue);}},keysIn);}/**
  35985. * A specialized version of `baseMerge` for arrays and objects which performs
  35986. * deep merges and tracks traversed objects enabling objects with circular
  35987. * references to be merged.
  35988. *
  35989. * @private
  35990. * @param {Object} object The destination object.
  35991. * @param {Object} source The source object.
  35992. * @param {string} key The key of the value to merge.
  35993. * @param {number} srcIndex The index of `source`.
  35994. * @param {Function} mergeFunc The function to merge values.
  35995. * @param {Function} [customizer] The function to customize assigned values.
  35996. * @param {Object} [stack] Tracks traversed source values and their merged
  35997. * counterparts.
  35998. */function baseMergeDeep(object,source,key,srcIndex,mergeFunc,customizer,stack){var objValue=safeGet(object,key),srcValue=safeGet(source,key),stacked=stack.get(srcValue);if(stacked){assignMergeValue(object,key,stacked);return;}var newValue=customizer?customizer(objValue,srcValue,key+'',object,source,stack):undefined;var isCommon=newValue===undefined;if(isCommon){var isArr=isArray(srcValue),isBuff=!isArr&&isBuffer(srcValue),isTyped=!isArr&&!isBuff&&isTypedArray(srcValue);newValue=srcValue;if(isArr||isBuff||isTyped){if(isArray(objValue)){newValue=objValue;}else if(isArrayLikeObject(objValue)){newValue=copyArray(objValue);}else if(isBuff){isCommon=false;newValue=cloneBuffer(srcValue,true);}else if(isTyped){isCommon=false;newValue=cloneTypedArray(srcValue,true);}else{newValue=[];}}else if(isPlainObject(srcValue)||isArguments(srcValue)){newValue=objValue;if(isArguments(objValue)){newValue=toPlainObject(objValue);}else if(!isObject(objValue)||isFunction(objValue)){newValue=initCloneObject(srcValue);}}else{isCommon=false;}}if(isCommon){// Recursively merge objects and arrays (susceptible to call stack limits).
  35999. stack.set(srcValue,newValue);mergeFunc(newValue,srcValue,srcIndex,customizer,stack);stack['delete'](srcValue);}assignMergeValue(object,key,newValue);}/**
  36000. * The base implementation of `_.nth` which doesn't coerce arguments.
  36001. *
  36002. * @private
  36003. * @param {Array} array The array to query.
  36004. * @param {number} n The index of the element to return.
  36005. * @returns {*} Returns the nth element of `array`.
  36006. */function baseNth(array,n){var length=array.length;if(!length){return;}n+=n<0?length:0;return isIndex(n,length)?array[n]:undefined;}/**
  36007. * The base implementation of `_.orderBy` without param guards.
  36008. *
  36009. * @private
  36010. * @param {Array|Object} collection The collection to iterate over.
  36011. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  36012. * @param {string[]} orders The sort orders of `iteratees`.
  36013. * @returns {Array} Returns the new sorted array.
  36014. */function baseOrderBy(collection,iteratees,orders){var index=-1;iteratees=arrayMap(iteratees.length?iteratees:[identity],baseUnary(getIteratee()));var result=baseMap(collection,function(value,key,collection){var criteria=arrayMap(iteratees,function(iteratee){return iteratee(value);});return{'criteria':criteria,'index':++index,'value':value};});return baseSortBy(result,function(object,other){return compareMultiple(object,other,orders);});}/**
  36015. * The base implementation of `_.pick` without support for individual
  36016. * property identifiers.
  36017. *
  36018. * @private
  36019. * @param {Object} object The source object.
  36020. * @param {string[]} paths The property paths to pick.
  36021. * @returns {Object} Returns the new object.
  36022. */function basePick(object,paths){return basePickBy(object,paths,function(value,path){return hasIn(object,path);});}/**
  36023. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  36024. *
  36025. * @private
  36026. * @param {Object} object The source object.
  36027. * @param {string[]} paths The property paths to pick.
  36028. * @param {Function} predicate The function invoked per property.
  36029. * @returns {Object} Returns the new object.
  36030. */function basePickBy(object,paths,predicate){var index=-1,length=paths.length,result={};while(++index<length){var path=paths[index],value=baseGet(object,path);if(predicate(value,path)){baseSet(result,castPath(path,object),value);}}return result;}/**
  36031. * A specialized version of `baseProperty` which supports deep paths.
  36032. *
  36033. * @private
  36034. * @param {Array|string} path The path of the property to get.
  36035. * @returns {Function} Returns the new accessor function.
  36036. */function basePropertyDeep(path){return function(object){return baseGet(object,path);};}/**
  36037. * The base implementation of `_.pullAllBy` without support for iteratee
  36038. * shorthands.
  36039. *
  36040. * @private
  36041. * @param {Array} array The array to modify.
  36042. * @param {Array} values The values to remove.
  36043. * @param {Function} [iteratee] The iteratee invoked per element.
  36044. * @param {Function} [comparator] The comparator invoked per element.
  36045. * @returns {Array} Returns `array`.
  36046. */function basePullAll(array,values,iteratee,comparator){var indexOf=comparator?baseIndexOfWith:baseIndexOf,index=-1,length=values.length,seen=array;if(array===values){values=copyArray(values);}if(iteratee){seen=arrayMap(array,baseUnary(iteratee));}while(++index<length){var fromIndex=0,value=values[index],computed=iteratee?iteratee(value):value;while((fromIndex=indexOf(seen,computed,fromIndex,comparator))>-1){if(seen!==array){splice.call(seen,fromIndex,1);}splice.call(array,fromIndex,1);}}return array;}/**
  36047. * The base implementation of `_.pullAt` without support for individual
  36048. * indexes or capturing the removed elements.
  36049. *
  36050. * @private
  36051. * @param {Array} array The array to modify.
  36052. * @param {number[]} indexes The indexes of elements to remove.
  36053. * @returns {Array} Returns `array`.
  36054. */function basePullAt(array,indexes){var length=array?indexes.length:0,lastIndex=length-1;while(length--){var index=indexes[length];if(length==lastIndex||index!==previous){var previous=index;if(isIndex(index)){splice.call(array,index,1);}else{baseUnset(array,index);}}}return array;}/**
  36055. * The base implementation of `_.random` without support for returning
  36056. * floating-point numbers.
  36057. *
  36058. * @private
  36059. * @param {number} lower The lower bound.
  36060. * @param {number} upper The upper bound.
  36061. * @returns {number} Returns the random number.
  36062. */function baseRandom(lower,upper){return lower+nativeFloor(nativeRandom()*(upper-lower+1));}/**
  36063. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  36064. * coerce arguments.
  36065. *
  36066. * @private
  36067. * @param {number} start The start of the range.
  36068. * @param {number} end The end of the range.
  36069. * @param {number} step The value to increment or decrement by.
  36070. * @param {boolean} [fromRight] Specify iterating from right to left.
  36071. * @returns {Array} Returns the range of numbers.
  36072. */function baseRange(start,end,step,fromRight){var index=-1,length=nativeMax(nativeCeil((end-start)/(step||1)),0),result=Array(length);while(length--){result[fromRight?length:++index]=start;start+=step;}return result;}/**
  36073. * The base implementation of `_.repeat` which doesn't coerce arguments.
  36074. *
  36075. * @private
  36076. * @param {string} string The string to repeat.
  36077. * @param {number} n The number of times to repeat the string.
  36078. * @returns {string} Returns the repeated string.
  36079. */function baseRepeat(string,n){var result='';if(!string||n<1||n>MAX_SAFE_INTEGER){return result;}// Leverage the exponentiation by squaring algorithm for a faster repeat.
  36080. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  36081. do{if(n%2){result+=string;}n=nativeFloor(n/2);if(n){string+=string;}}while(n);return result;}/**
  36082. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  36083. *
  36084. * @private
  36085. * @param {Function} func The function to apply a rest parameter to.
  36086. * @param {number} [start=func.length-1] The start position of the rest parameter.
  36087. * @returns {Function} Returns the new function.
  36088. */function baseRest(func,start){return setToString(overRest(func,start,identity),func+'');}/**
  36089. * The base implementation of `_.sample`.
  36090. *
  36091. * @private
  36092. * @param {Array|Object} collection The collection to sample.
  36093. * @returns {*} Returns the random element.
  36094. */function baseSample(collection){return arraySample(values(collection));}/**
  36095. * The base implementation of `_.sampleSize` without param guards.
  36096. *
  36097. * @private
  36098. * @param {Array|Object} collection The collection to sample.
  36099. * @param {number} n The number of elements to sample.
  36100. * @returns {Array} Returns the random elements.
  36101. */function baseSampleSize(collection,n){var array=values(collection);return shuffleSelf(array,baseClamp(n,0,array.length));}/**
  36102. * The base implementation of `_.set`.
  36103. *
  36104. * @private
  36105. * @param {Object} object The object to modify.
  36106. * @param {Array|string} path The path of the property to set.
  36107. * @param {*} value The value to set.
  36108. * @param {Function} [customizer] The function to customize path creation.
  36109. * @returns {Object} Returns `object`.
  36110. */function baseSet(object,path,value,customizer){if(!isObject(object)){return object;}path=castPath(path,object);var index=-1,length=path.length,lastIndex=length-1,nested=object;while(nested!=null&&++index<length){var key=toKey(path[index]),newValue=value;if(index!=lastIndex){var objValue=nested[key];newValue=customizer?customizer(objValue,key,nested):undefined;if(newValue===undefined){newValue=isObject(objValue)?objValue:isIndex(path[index+1])?[]:{};}}assignValue(nested,key,newValue);nested=nested[key];}return object;}/**
  36111. * The base implementation of `setData` without support for hot loop shorting.
  36112. *
  36113. * @private
  36114. * @param {Function} func The function to associate metadata with.
  36115. * @param {*} data The metadata.
  36116. * @returns {Function} Returns `func`.
  36117. */var baseSetData=!metaMap?identity:function(func,data){metaMap.set(func,data);return func;};/**
  36118. * The base implementation of `setToString` without support for hot loop shorting.
  36119. *
  36120. * @private
  36121. * @param {Function} func The function to modify.
  36122. * @param {Function} string The `toString` result.
  36123. * @returns {Function} Returns `func`.
  36124. */var baseSetToString=!defineProperty?identity:function(func,string){return defineProperty(func,'toString',{'configurable':true,'enumerable':false,'value':constant(string),'writable':true});};/**
  36125. * The base implementation of `_.shuffle`.
  36126. *
  36127. * @private
  36128. * @param {Array|Object} collection The collection to shuffle.
  36129. * @returns {Array} Returns the new shuffled array.
  36130. */function baseShuffle(collection){return shuffleSelf(values(collection));}/**
  36131. * The base implementation of `_.slice` without an iteratee call guard.
  36132. *
  36133. * @private
  36134. * @param {Array} array The array to slice.
  36135. * @param {number} [start=0] The start position.
  36136. * @param {number} [end=array.length] The end position.
  36137. * @returns {Array} Returns the slice of `array`.
  36138. */function baseSlice(array,start,end){var index=-1,length=array.length;if(start<0){start=-start>length?0:length+start;}end=end>length?length:end;if(end<0){end+=length;}length=start>end?0:end-start>>>0;start>>>=0;var result=Array(length);while(++index<length){result[index]=array[index+start];}return result;}/**
  36139. * The base implementation of `_.some` without support for iteratee shorthands.
  36140. *
  36141. * @private
  36142. * @param {Array|Object} collection The collection to iterate over.
  36143. * @param {Function} predicate The function invoked per iteration.
  36144. * @returns {boolean} Returns `true` if any element passes the predicate check,
  36145. * else `false`.
  36146. */function baseSome(collection,predicate){var result;baseEach(collection,function(value,index,collection){result=predicate(value,index,collection);return!result;});return!!result;}/**
  36147. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  36148. * performs a binary search of `array` to determine the index at which `value`
  36149. * should be inserted into `array` in order to maintain its sort order.
  36150. *
  36151. * @private
  36152. * @param {Array} array The sorted array to inspect.
  36153. * @param {*} value The value to evaluate.
  36154. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  36155. * @returns {number} Returns the index at which `value` should be inserted
  36156. * into `array`.
  36157. */function baseSortedIndex(array,value,retHighest){var low=0,high=array==null?low:array.length;if(typeof value=='number'&&value===value&&high<=HALF_MAX_ARRAY_LENGTH){while(low<high){var mid=low+high>>>1,computed=array[mid];if(computed!==null&&!isSymbol(computed)&&(retHighest?computed<=value:computed<value)){low=mid+1;}else{high=mid;}}return high;}return baseSortedIndexBy(array,value,identity,retHighest);}/**
  36158. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  36159. * which invokes `iteratee` for `value` and each element of `array` to compute
  36160. * their sort ranking. The iteratee is invoked with one argument; (value).
  36161. *
  36162. * @private
  36163. * @param {Array} array The sorted array to inspect.
  36164. * @param {*} value The value to evaluate.
  36165. * @param {Function} iteratee The iteratee invoked per element.
  36166. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  36167. * @returns {number} Returns the index at which `value` should be inserted
  36168. * into `array`.
  36169. */function baseSortedIndexBy(array,value,iteratee,retHighest){value=iteratee(value);var low=0,high=array==null?0:array.length,valIsNaN=value!==value,valIsNull=value===null,valIsSymbol=isSymbol(value),valIsUndefined=value===undefined;while(low<high){var mid=nativeFloor((low+high)/2),computed=iteratee(array[mid]),othIsDefined=computed!==undefined,othIsNull=computed===null,othIsReflexive=computed===computed,othIsSymbol=isSymbol(computed);if(valIsNaN){var setLow=retHighest||othIsReflexive;}else if(valIsUndefined){setLow=othIsReflexive&&(retHighest||othIsDefined);}else if(valIsNull){setLow=othIsReflexive&&othIsDefined&&(retHighest||!othIsNull);}else if(valIsSymbol){setLow=othIsReflexive&&othIsDefined&&!othIsNull&&(retHighest||!othIsSymbol);}else if(othIsNull||othIsSymbol){setLow=false;}else{setLow=retHighest?computed<=value:computed<value;}if(setLow){low=mid+1;}else{high=mid;}}return nativeMin(high,MAX_ARRAY_INDEX);}/**
  36170. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  36171. * support for iteratee shorthands.
  36172. *
  36173. * @private
  36174. * @param {Array} array The array to inspect.
  36175. * @param {Function} [iteratee] The iteratee invoked per element.
  36176. * @returns {Array} Returns the new duplicate free array.
  36177. */function baseSortedUniq(array,iteratee){var index=-1,length=array.length,resIndex=0,result=[];while(++index<length){var value=array[index],computed=iteratee?iteratee(value):value;if(!index||!eq(computed,seen)){var seen=computed;result[resIndex++]=value===0?0:value;}}return result;}/**
  36178. * The base implementation of `_.toNumber` which doesn't ensure correct
  36179. * conversions of binary, hexadecimal, or octal string values.
  36180. *
  36181. * @private
  36182. * @param {*} value The value to process.
  36183. * @returns {number} Returns the number.
  36184. */function baseToNumber(value){if(typeof value=='number'){return value;}if(isSymbol(value)){return NAN;}return+value;}/**
  36185. * The base implementation of `_.toString` which doesn't convert nullish
  36186. * values to empty strings.
  36187. *
  36188. * @private
  36189. * @param {*} value The value to process.
  36190. * @returns {string} Returns the string.
  36191. */function baseToString(value){// Exit early for strings to avoid a performance hit in some environments.
  36192. if(typeof value=='string'){return value;}if(isArray(value)){// Recursively convert values (susceptible to call stack limits).
  36193. return arrayMap(value,baseToString)+'';}if(isSymbol(value)){return symbolToString?symbolToString.call(value):'';}var result=value+'';return result=='0'&&1/value==-INFINITY?'-0':result;}/**
  36194. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  36195. *
  36196. * @private
  36197. * @param {Array} array The array to inspect.
  36198. * @param {Function} [iteratee] The iteratee invoked per element.
  36199. * @param {Function} [comparator] The comparator invoked per element.
  36200. * @returns {Array} Returns the new duplicate free array.
  36201. */function baseUniq(array,iteratee,comparator){var index=-1,includes=arrayIncludes,length=array.length,isCommon=true,result=[],seen=result;if(comparator){isCommon=false;includes=arrayIncludesWith;}else if(length>=LARGE_ARRAY_SIZE){var set=iteratee?null:createSet(array);if(set){return setToArray(set);}isCommon=false;includes=cacheHas;seen=new SetCache();}else{seen=iteratee?[]:result;}outer:while(++index<length){var value=array[index],computed=iteratee?iteratee(value):value;value=comparator||value!==0?value:0;if(isCommon&&computed===computed){var seenIndex=seen.length;while(seenIndex--){if(seen[seenIndex]===computed){continue outer;}}if(iteratee){seen.push(computed);}result.push(value);}else if(!includes(seen,computed,comparator)){if(seen!==result){seen.push(computed);}result.push(value);}}return result;}/**
  36202. * The base implementation of `_.unset`.
  36203. *
  36204. * @private
  36205. * @param {Object} object The object to modify.
  36206. * @param {Array|string} path The property path to unset.
  36207. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  36208. */function baseUnset(object,path){path=castPath(path,object);object=parent(object,path);return object==null||delete object[toKey(last(path))];}/**
  36209. * The base implementation of `_.update`.
  36210. *
  36211. * @private
  36212. * @param {Object} object The object to modify.
  36213. * @param {Array|string} path The path of the property to update.
  36214. * @param {Function} updater The function to produce the updated value.
  36215. * @param {Function} [customizer] The function to customize path creation.
  36216. * @returns {Object} Returns `object`.
  36217. */function baseUpdate(object,path,updater,customizer){return baseSet(object,path,updater(baseGet(object,path)),customizer);}/**
  36218. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  36219. * without support for iteratee shorthands.
  36220. *
  36221. * @private
  36222. * @param {Array} array The array to query.
  36223. * @param {Function} predicate The function invoked per iteration.
  36224. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  36225. * @param {boolean} [fromRight] Specify iterating from right to left.
  36226. * @returns {Array} Returns the slice of `array`.
  36227. */function baseWhile(array,predicate,isDrop,fromRight){var length=array.length,index=fromRight?length:-1;while((fromRight?index--:++index<length)&&predicate(array[index],index,array)){}return isDrop?baseSlice(array,fromRight?0:index,fromRight?index+1:length):baseSlice(array,fromRight?index+1:0,fromRight?length:index);}/**
  36228. * The base implementation of `wrapperValue` which returns the result of
  36229. * performing a sequence of actions on the unwrapped `value`, where each
  36230. * successive action is supplied the return value of the previous.
  36231. *
  36232. * @private
  36233. * @param {*} value The unwrapped value.
  36234. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  36235. * @returns {*} Returns the resolved value.
  36236. */function baseWrapperValue(value,actions){var result=value;if(result instanceof LazyWrapper){result=result.value();}return arrayReduce(actions,function(result,action){return action.func.apply(action.thisArg,arrayPush([result],action.args));},result);}/**
  36237. * The base implementation of methods like `_.xor`, without support for
  36238. * iteratee shorthands, that accepts an array of arrays to inspect.
  36239. *
  36240. * @private
  36241. * @param {Array} arrays The arrays to inspect.
  36242. * @param {Function} [iteratee] The iteratee invoked per element.
  36243. * @param {Function} [comparator] The comparator invoked per element.
  36244. * @returns {Array} Returns the new array of values.
  36245. */function baseXor(arrays,iteratee,comparator){var length=arrays.length;if(length<2){return length?baseUniq(arrays[0]):[];}var index=-1,result=Array(length);while(++index<length){var array=arrays[index],othIndex=-1;while(++othIndex<length){if(othIndex!=index){result[index]=baseDifference(result[index]||array,arrays[othIndex],iteratee,comparator);}}}return baseUniq(baseFlatten(result,1),iteratee,comparator);}/**
  36246. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  36247. *
  36248. * @private
  36249. * @param {Array} props The property identifiers.
  36250. * @param {Array} values The property values.
  36251. * @param {Function} assignFunc The function to assign values.
  36252. * @returns {Object} Returns the new object.
  36253. */function baseZipObject(props,values,assignFunc){var index=-1,length=props.length,valsLength=values.length,result={};while(++index<length){var value=index<valsLength?values[index]:undefined;assignFunc(result,props[index],value);}return result;}/**
  36254. * Casts `value` to an empty array if it's not an array like object.
  36255. *
  36256. * @private
  36257. * @param {*} value The value to inspect.
  36258. * @returns {Array|Object} Returns the cast array-like object.
  36259. */function castArrayLikeObject(value){return isArrayLikeObject(value)?value:[];}/**
  36260. * Casts `value` to `identity` if it's not a function.
  36261. *
  36262. * @private
  36263. * @param {*} value The value to inspect.
  36264. * @returns {Function} Returns cast function.
  36265. */function castFunction(value){return typeof value=='function'?value:identity;}/**
  36266. * Casts `value` to a path array if it's not one.
  36267. *
  36268. * @private
  36269. * @param {*} value The value to inspect.
  36270. * @param {Object} [object] The object to query keys on.
  36271. * @returns {Array} Returns the cast property path array.
  36272. */function castPath(value,object){if(isArray(value)){return value;}return isKey(value,object)?[value]:stringToPath(toString(value));}/**
  36273. * A `baseRest` alias which can be replaced with `identity` by module
  36274. * replacement plugins.
  36275. *
  36276. * @private
  36277. * @type {Function}
  36278. * @param {Function} func The function to apply a rest parameter to.
  36279. * @returns {Function} Returns the new function.
  36280. */var castRest=baseRest;/**
  36281. * Casts `array` to a slice if it's needed.
  36282. *
  36283. * @private
  36284. * @param {Array} array The array to inspect.
  36285. * @param {number} start The start position.
  36286. * @param {number} [end=array.length] The end position.
  36287. * @returns {Array} Returns the cast slice.
  36288. */function castSlice(array,start,end){var length=array.length;end=end===undefined?length:end;return!start&&end>=length?array:baseSlice(array,start,end);}/**
  36289. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  36290. *
  36291. * @private
  36292. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  36293. */var clearTimeout=ctxClearTimeout||function(id){return root.clearTimeout(id);};/**
  36294. * Creates a clone of `buffer`.
  36295. *
  36296. * @private
  36297. * @param {Buffer} buffer The buffer to clone.
  36298. * @param {boolean} [isDeep] Specify a deep clone.
  36299. * @returns {Buffer} Returns the cloned buffer.
  36300. */function cloneBuffer(buffer,isDeep){if(isDeep){return buffer.slice();}var length=buffer.length,result=allocUnsafe?allocUnsafe(length):new buffer.constructor(length);buffer.copy(result);return result;}/**
  36301. * Creates a clone of `arrayBuffer`.
  36302. *
  36303. * @private
  36304. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  36305. * @returns {ArrayBuffer} Returns the cloned array buffer.
  36306. */function cloneArrayBuffer(arrayBuffer){var result=new arrayBuffer.constructor(arrayBuffer.byteLength);new Uint8Array(result).set(new Uint8Array(arrayBuffer));return result;}/**
  36307. * Creates a clone of `dataView`.
  36308. *
  36309. * @private
  36310. * @param {Object} dataView The data view to clone.
  36311. * @param {boolean} [isDeep] Specify a deep clone.
  36312. * @returns {Object} Returns the cloned data view.
  36313. */function cloneDataView(dataView,isDeep){var buffer=isDeep?cloneArrayBuffer(dataView.buffer):dataView.buffer;return new dataView.constructor(buffer,dataView.byteOffset,dataView.byteLength);}/**
  36314. * Creates a clone of `regexp`.
  36315. *
  36316. * @private
  36317. * @param {Object} regexp The regexp to clone.
  36318. * @returns {Object} Returns the cloned regexp.
  36319. */function cloneRegExp(regexp){var result=new regexp.constructor(regexp.source,reFlags.exec(regexp));result.lastIndex=regexp.lastIndex;return result;}/**
  36320. * Creates a clone of the `symbol` object.
  36321. *
  36322. * @private
  36323. * @param {Object} symbol The symbol object to clone.
  36324. * @returns {Object} Returns the cloned symbol object.
  36325. */function cloneSymbol(symbol){return symbolValueOf?Object(symbolValueOf.call(symbol)):{};}/**
  36326. * Creates a clone of `typedArray`.
  36327. *
  36328. * @private
  36329. * @param {Object} typedArray The typed array to clone.
  36330. * @param {boolean} [isDeep] Specify a deep clone.
  36331. * @returns {Object} Returns the cloned typed array.
  36332. */function cloneTypedArray(typedArray,isDeep){var buffer=isDeep?cloneArrayBuffer(typedArray.buffer):typedArray.buffer;return new typedArray.constructor(buffer,typedArray.byteOffset,typedArray.length);}/**
  36333. * Compares values to sort them in ascending order.
  36334. *
  36335. * @private
  36336. * @param {*} value The value to compare.
  36337. * @param {*} other The other value to compare.
  36338. * @returns {number} Returns the sort order indicator for `value`.
  36339. */function compareAscending(value,other){if(value!==other){var valIsDefined=value!==undefined,valIsNull=value===null,valIsReflexive=value===value,valIsSymbol=isSymbol(value);var othIsDefined=other!==undefined,othIsNull=other===null,othIsReflexive=other===other,othIsSymbol=isSymbol(other);if(!othIsNull&&!othIsSymbol&&!valIsSymbol&&value>other||valIsSymbol&&othIsDefined&&othIsReflexive&&!othIsNull&&!othIsSymbol||valIsNull&&othIsDefined&&othIsReflexive||!valIsDefined&&othIsReflexive||!valIsReflexive){return 1;}if(!valIsNull&&!valIsSymbol&&!othIsSymbol&&value<other||othIsSymbol&&valIsDefined&&valIsReflexive&&!valIsNull&&!valIsSymbol||othIsNull&&valIsDefined&&valIsReflexive||!othIsDefined&&valIsReflexive||!othIsReflexive){return-1;}}return 0;}/**
  36340. * Used by `_.orderBy` to compare multiple properties of a value to another
  36341. * and stable sort them.
  36342. *
  36343. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  36344. * specify an order of "desc" for descending or "asc" for ascending sort order
  36345. * of corresponding values.
  36346. *
  36347. * @private
  36348. * @param {Object} object The object to compare.
  36349. * @param {Object} other The other object to compare.
  36350. * @param {boolean[]|string[]} orders The order to sort by for each property.
  36351. * @returns {number} Returns the sort order indicator for `object`.
  36352. */function compareMultiple(object,other,orders){var index=-1,objCriteria=object.criteria,othCriteria=other.criteria,length=objCriteria.length,ordersLength=orders.length;while(++index<length){var result=compareAscending(objCriteria[index],othCriteria[index]);if(result){if(index>=ordersLength){return result;}var order=orders[index];return result*(order=='desc'?-1:1);}}// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  36353. // that causes it, under certain circumstances, to provide the same value for
  36354. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  36355. // for more details.
  36356. //
  36357. // This also ensures a stable sort in V8 and other engines.
  36358. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  36359. return object.index-other.index;}/**
  36360. * Creates an array that is the composition of partially applied arguments,
  36361. * placeholders, and provided arguments into a single array of arguments.
  36362. *
  36363. * @private
  36364. * @param {Array} args The provided arguments.
  36365. * @param {Array} partials The arguments to prepend to those provided.
  36366. * @param {Array} holders The `partials` placeholder indexes.
  36367. * @params {boolean} [isCurried] Specify composing for a curried function.
  36368. * @returns {Array} Returns the new array of composed arguments.
  36369. */function composeArgs(args,partials,holders,isCurried){var argsIndex=-1,argsLength=args.length,holdersLength=holders.length,leftIndex=-1,leftLength=partials.length,rangeLength=nativeMax(argsLength-holdersLength,0),result=Array(leftLength+rangeLength),isUncurried=!isCurried;while(++leftIndex<leftLength){result[leftIndex]=partials[leftIndex];}while(++argsIndex<holdersLength){if(isUncurried||argsIndex<argsLength){result[holders[argsIndex]]=args[argsIndex];}}while(rangeLength--){result[leftIndex++]=args[argsIndex++];}return result;}/**
  36370. * This function is like `composeArgs` except that the arguments composition
  36371. * is tailored for `_.partialRight`.
  36372. *
  36373. * @private
  36374. * @param {Array} args The provided arguments.
  36375. * @param {Array} partials The arguments to append to those provided.
  36376. * @param {Array} holders The `partials` placeholder indexes.
  36377. * @params {boolean} [isCurried] Specify composing for a curried function.
  36378. * @returns {Array} Returns the new array of composed arguments.
  36379. */function composeArgsRight(args,partials,holders,isCurried){var argsIndex=-1,argsLength=args.length,holdersIndex=-1,holdersLength=holders.length,rightIndex=-1,rightLength=partials.length,rangeLength=nativeMax(argsLength-holdersLength,0),result=Array(rangeLength+rightLength),isUncurried=!isCurried;while(++argsIndex<rangeLength){result[argsIndex]=args[argsIndex];}var offset=argsIndex;while(++rightIndex<rightLength){result[offset+rightIndex]=partials[rightIndex];}while(++holdersIndex<holdersLength){if(isUncurried||argsIndex<argsLength){result[offset+holders[holdersIndex]]=args[argsIndex++];}}return result;}/**
  36380. * Copies the values of `source` to `array`.
  36381. *
  36382. * @private
  36383. * @param {Array} source The array to copy values from.
  36384. * @param {Array} [array=[]] The array to copy values to.
  36385. * @returns {Array} Returns `array`.
  36386. */function copyArray(source,array){var index=-1,length=source.length;array||(array=Array(length));while(++index<length){array[index]=source[index];}return array;}/**
  36387. * Copies properties of `source` to `object`.
  36388. *
  36389. * @private
  36390. * @param {Object} source The object to copy properties from.
  36391. * @param {Array} props The property identifiers to copy.
  36392. * @param {Object} [object={}] The object to copy properties to.
  36393. * @param {Function} [customizer] The function to customize copied values.
  36394. * @returns {Object} Returns `object`.
  36395. */function copyObject(source,props,object,customizer){var isNew=!object;object||(object={});var index=-1,length=props.length;while(++index<length){var key=props[index];var newValue=customizer?customizer(object[key],source[key],key,object,source):undefined;if(newValue===undefined){newValue=source[key];}if(isNew){baseAssignValue(object,key,newValue);}else{assignValue(object,key,newValue);}}return object;}/**
  36396. * Copies own symbols of `source` to `object`.
  36397. *
  36398. * @private
  36399. * @param {Object} source The object to copy symbols from.
  36400. * @param {Object} [object={}] The object to copy symbols to.
  36401. * @returns {Object} Returns `object`.
  36402. */function copySymbols(source,object){return copyObject(source,getSymbols(source),object);}/**
  36403. * Copies own and inherited symbols of `source` to `object`.
  36404. *
  36405. * @private
  36406. * @param {Object} source The object to copy symbols from.
  36407. * @param {Object} [object={}] The object to copy symbols to.
  36408. * @returns {Object} Returns `object`.
  36409. */function copySymbolsIn(source,object){return copyObject(source,getSymbolsIn(source),object);}/**
  36410. * Creates a function like `_.groupBy`.
  36411. *
  36412. * @private
  36413. * @param {Function} setter The function to set accumulator values.
  36414. * @param {Function} [initializer] The accumulator object initializer.
  36415. * @returns {Function} Returns the new aggregator function.
  36416. */function createAggregator(setter,initializer){return function(collection,iteratee){var func=isArray(collection)?arrayAggregator:baseAggregator,accumulator=initializer?initializer():{};return func(collection,setter,getIteratee(iteratee,2),accumulator);};}/**
  36417. * Creates a function like `_.assign`.
  36418. *
  36419. * @private
  36420. * @param {Function} assigner The function to assign values.
  36421. * @returns {Function} Returns the new assigner function.
  36422. */function createAssigner(assigner){return baseRest(function(object,sources){var index=-1,length=sources.length,customizer=length>1?sources[length-1]:undefined,guard=length>2?sources[2]:undefined;customizer=assigner.length>3&&typeof customizer=='function'?(length--,customizer):undefined;if(guard&&isIterateeCall(sources[0],sources[1],guard)){customizer=length<3?undefined:customizer;length=1;}object=Object(object);while(++index<length){var source=sources[index];if(source){assigner(object,source,index,customizer);}}return object;});}/**
  36423. * Creates a `baseEach` or `baseEachRight` function.
  36424. *
  36425. * @private
  36426. * @param {Function} eachFunc The function to iterate over a collection.
  36427. * @param {boolean} [fromRight] Specify iterating from right to left.
  36428. * @returns {Function} Returns the new base function.
  36429. */function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){if(collection==null){return collection;}if(!isArrayLike(collection)){return eachFunc(collection,iteratee);}var length=collection.length,index=fromRight?length:-1,iterable=Object(collection);while(fromRight?index--:++index<length){if(iteratee(iterable[index],index,iterable)===false){break;}}return collection;};}/**
  36430. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  36431. *
  36432. * @private
  36433. * @param {boolean} [fromRight] Specify iterating from right to left.
  36434. * @returns {Function} Returns the new base function.
  36435. */function createBaseFor(fromRight){return function(object,iteratee,keysFunc){var index=-1,iterable=Object(object),props=keysFunc(object),length=props.length;while(length--){var key=props[fromRight?length:++index];if(iteratee(iterable[key],key,iterable)===false){break;}}return object;};}/**
  36436. * Creates a function that wraps `func` to invoke it with the optional `this`
  36437. * binding of `thisArg`.
  36438. *
  36439. * @private
  36440. * @param {Function} func The function to wrap.
  36441. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  36442. * @param {*} [thisArg] The `this` binding of `func`.
  36443. * @returns {Function} Returns the new wrapped function.
  36444. */function createBind(func,bitmask,thisArg){var isBind=bitmask&WRAP_BIND_FLAG,Ctor=createCtor(func);function wrapper(){var fn=this&&this!==root&&this instanceof wrapper?Ctor:func;return fn.apply(isBind?thisArg:this,arguments);}return wrapper;}/**
  36445. * Creates a function like `_.lowerFirst`.
  36446. *
  36447. * @private
  36448. * @param {string} methodName The name of the `String` case method to use.
  36449. * @returns {Function} Returns the new case function.
  36450. */function createCaseFirst(methodName){return function(string){string=toString(string);var strSymbols=hasUnicode(string)?stringToArray(string):undefined;var chr=strSymbols?strSymbols[0]:string.charAt(0);var trailing=strSymbols?castSlice(strSymbols,1).join(''):string.slice(1);return chr[methodName]()+trailing;};}/**
  36451. * Creates a function like `_.camelCase`.
  36452. *
  36453. * @private
  36454. * @param {Function} callback The function to combine each word.
  36455. * @returns {Function} Returns the new compounder function.
  36456. */function createCompounder(callback){return function(string){return arrayReduce(words(deburr(string).replace(reApos,'')),callback,'');};}/**
  36457. * Creates a function that produces an instance of `Ctor` regardless of
  36458. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  36459. *
  36460. * @private
  36461. * @param {Function} Ctor The constructor to wrap.
  36462. * @returns {Function} Returns the new wrapped function.
  36463. */function createCtor(Ctor){return function(){// Use a `switch` statement to work with class constructors. See
  36464. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  36465. // for more details.
  36466. var args=arguments;switch(args.length){case 0:return new Ctor();case 1:return new Ctor(args[0]);case 2:return new Ctor(args[0],args[1]);case 3:return new Ctor(args[0],args[1],args[2]);case 4:return new Ctor(args[0],args[1],args[2],args[3]);case 5:return new Ctor(args[0],args[1],args[2],args[3],args[4]);case 6:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5]);case 7:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);}var thisBinding=baseCreate(Ctor.prototype),result=Ctor.apply(thisBinding,args);// Mimic the constructor's `return` behavior.
  36467. // See https://es5.github.io/#x13.2.2 for more details.
  36468. return isObject(result)?result:thisBinding;};}/**
  36469. * Creates a function that wraps `func` to enable currying.
  36470. *
  36471. * @private
  36472. * @param {Function} func The function to wrap.
  36473. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  36474. * @param {number} arity The arity of `func`.
  36475. * @returns {Function} Returns the new wrapped function.
  36476. */function createCurry(func,bitmask,arity){var Ctor=createCtor(func);function wrapper(){var length=arguments.length,args=Array(length),index=length,placeholder=getHolder(wrapper);while(index--){args[index]=arguments[index];}var holders=length<3&&args[0]!==placeholder&&args[length-1]!==placeholder?[]:replaceHolders(args,placeholder);length-=holders.length;if(length<arity){return createRecurry(func,bitmask,createHybrid,wrapper.placeholder,undefined,args,holders,undefined,undefined,arity-length);}var fn=this&&this!==root&&this instanceof wrapper?Ctor:func;return apply(fn,this,args);}return wrapper;}/**
  36477. * Creates a `_.find` or `_.findLast` function.
  36478. *
  36479. * @private
  36480. * @param {Function} findIndexFunc The function to find the collection index.
  36481. * @returns {Function} Returns the new find function.
  36482. */function createFind(findIndexFunc){return function(collection,predicate,fromIndex){var iterable=Object(collection);if(!isArrayLike(collection)){var iteratee=getIteratee(predicate,3);collection=keys(collection);predicate=function predicate(key){return iteratee(iterable[key],key,iterable);};}var index=findIndexFunc(collection,predicate,fromIndex);return index>-1?iterable[iteratee?collection[index]:index]:undefined;};}/**
  36483. * Creates a `_.flow` or `_.flowRight` function.
  36484. *
  36485. * @private
  36486. * @param {boolean} [fromRight] Specify iterating from right to left.
  36487. * @returns {Function} Returns the new flow function.
  36488. */function createFlow(fromRight){return flatRest(function(funcs){var length=funcs.length,index=length,prereq=LodashWrapper.prototype.thru;if(fromRight){funcs.reverse();}while(index--){var func=funcs[index];if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}if(prereq&&!wrapper&&getFuncName(func)=='wrapper'){var wrapper=new LodashWrapper([],true);}}index=wrapper?index:length;while(++index<length){func=funcs[index];var funcName=getFuncName(func),data=funcName=='wrapper'?getData(func):undefined;if(data&&isLaziable(data[0])&&data[1]==(WRAP_ARY_FLAG|WRAP_CURRY_FLAG|WRAP_PARTIAL_FLAG|WRAP_REARG_FLAG)&&!data[4].length&&data[9]==1){wrapper=wrapper[getFuncName(data[0])].apply(wrapper,data[3]);}else{wrapper=func.length==1&&isLaziable(func)?wrapper[funcName]():wrapper.thru(func);}}return function(){var args=arguments,value=args[0];if(wrapper&&args.length==1&&isArray(value)){return wrapper.plant(value).value();}var index=0,result=length?funcs[index].apply(this,args):value;while(++index<length){result=funcs[index].call(this,result);}return result;};});}/**
  36489. * Creates a function that wraps `func` to invoke it with optional `this`
  36490. * binding of `thisArg`, partial application, and currying.
  36491. *
  36492. * @private
  36493. * @param {Function|string} func The function or method name to wrap.
  36494. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  36495. * @param {*} [thisArg] The `this` binding of `func`.
  36496. * @param {Array} [partials] The arguments to prepend to those provided to
  36497. * the new function.
  36498. * @param {Array} [holders] The `partials` placeholder indexes.
  36499. * @param {Array} [partialsRight] The arguments to append to those provided
  36500. * to the new function.
  36501. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  36502. * @param {Array} [argPos] The argument positions of the new function.
  36503. * @param {number} [ary] The arity cap of `func`.
  36504. * @param {number} [arity] The arity of `func`.
  36505. * @returns {Function} Returns the new wrapped function.
  36506. */function createHybrid(func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity){var isAry=bitmask&WRAP_ARY_FLAG,isBind=bitmask&WRAP_BIND_FLAG,isBindKey=bitmask&WRAP_BIND_KEY_FLAG,isCurried=bitmask&(WRAP_CURRY_FLAG|WRAP_CURRY_RIGHT_FLAG),isFlip=bitmask&WRAP_FLIP_FLAG,Ctor=isBindKey?undefined:createCtor(func);function wrapper(){var length=arguments.length,args=Array(length),index=length;while(index--){args[index]=arguments[index];}if(isCurried){var placeholder=getHolder(wrapper),holdersCount=countHolders(args,placeholder);}if(partials){args=composeArgs(args,partials,holders,isCurried);}if(partialsRight){args=composeArgsRight(args,partialsRight,holdersRight,isCurried);}length-=holdersCount;if(isCurried&&length<arity){var newHolders=replaceHolders(args,placeholder);return createRecurry(func,bitmask,createHybrid,wrapper.placeholder,thisArg,args,newHolders,argPos,ary,arity-length);}var thisBinding=isBind?thisArg:this,fn=isBindKey?thisBinding[func]:func;length=args.length;if(argPos){args=reorder(args,argPos);}else if(isFlip&&length>1){args.reverse();}if(isAry&&ary<length){args.length=ary;}if(this&&this!==root&&this instanceof wrapper){fn=Ctor||createCtor(fn);}return fn.apply(thisBinding,args);}return wrapper;}/**
  36507. * Creates a function like `_.invertBy`.
  36508. *
  36509. * @private
  36510. * @param {Function} setter The function to set accumulator values.
  36511. * @param {Function} toIteratee The function to resolve iteratees.
  36512. * @returns {Function} Returns the new inverter function.
  36513. */function createInverter(setter,toIteratee){return function(object,iteratee){return baseInverter(object,setter,toIteratee(iteratee),{});};}/**
  36514. * Creates a function that performs a mathematical operation on two values.
  36515. *
  36516. * @private
  36517. * @param {Function} operator The function to perform the operation.
  36518. * @param {number} [defaultValue] The value used for `undefined` arguments.
  36519. * @returns {Function} Returns the new mathematical operation function.
  36520. */function createMathOperation(operator,defaultValue){return function(value,other){var result;if(value===undefined&&other===undefined){return defaultValue;}if(value!==undefined){result=value;}if(other!==undefined){if(result===undefined){return other;}if(typeof value=='string'||typeof other=='string'){value=baseToString(value);other=baseToString(other);}else{value=baseToNumber(value);other=baseToNumber(other);}result=operator(value,other);}return result;};}/**
  36521. * Creates a function like `_.over`.
  36522. *
  36523. * @private
  36524. * @param {Function} arrayFunc The function to iterate over iteratees.
  36525. * @returns {Function} Returns the new over function.
  36526. */function createOver(arrayFunc){return flatRest(function(iteratees){iteratees=arrayMap(iteratees,baseUnary(getIteratee()));return baseRest(function(args){var thisArg=this;return arrayFunc(iteratees,function(iteratee){return apply(iteratee,thisArg,args);});});});}/**
  36527. * Creates the padding for `string` based on `length`. The `chars` string
  36528. * is truncated if the number of characters exceeds `length`.
  36529. *
  36530. * @private
  36531. * @param {number} length The padding length.
  36532. * @param {string} [chars=' '] The string used as padding.
  36533. * @returns {string} Returns the padding for `string`.
  36534. */function createPadding(length,chars){chars=chars===undefined?' ':baseToString(chars);var charsLength=chars.length;if(charsLength<2){return charsLength?baseRepeat(chars,length):chars;}var result=baseRepeat(chars,nativeCeil(length/stringSize(chars)));return hasUnicode(chars)?castSlice(stringToArray(result),0,length).join(''):result.slice(0,length);}/**
  36535. * Creates a function that wraps `func` to invoke it with the `this` binding
  36536. * of `thisArg` and `partials` prepended to the arguments it receives.
  36537. *
  36538. * @private
  36539. * @param {Function} func The function to wrap.
  36540. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  36541. * @param {*} thisArg The `this` binding of `func`.
  36542. * @param {Array} partials The arguments to prepend to those provided to
  36543. * the new function.
  36544. * @returns {Function} Returns the new wrapped function.
  36545. */function createPartial(func,bitmask,thisArg,partials){var isBind=bitmask&WRAP_BIND_FLAG,Ctor=createCtor(func);function wrapper(){var argsIndex=-1,argsLength=arguments.length,leftIndex=-1,leftLength=partials.length,args=Array(leftLength+argsLength),fn=this&&this!==root&&this instanceof wrapper?Ctor:func;while(++leftIndex<leftLength){args[leftIndex]=partials[leftIndex];}while(argsLength--){args[leftIndex++]=arguments[++argsIndex];}return apply(fn,isBind?thisArg:this,args);}return wrapper;}/**
  36546. * Creates a `_.range` or `_.rangeRight` function.
  36547. *
  36548. * @private
  36549. * @param {boolean} [fromRight] Specify iterating from right to left.
  36550. * @returns {Function} Returns the new range function.
  36551. */function createRange(fromRight){return function(start,end,step){if(step&&typeof step!='number'&&isIterateeCall(start,end,step)){end=step=undefined;}// Ensure the sign of `-0` is preserved.
  36552. start=toFinite(start);if(end===undefined){end=start;start=0;}else{end=toFinite(end);}step=step===undefined?start<end?1:-1:toFinite(step);return baseRange(start,end,step,fromRight);};}/**
  36553. * Creates a function that performs a relational operation on two values.
  36554. *
  36555. * @private
  36556. * @param {Function} operator The function to perform the operation.
  36557. * @returns {Function} Returns the new relational operation function.
  36558. */function createRelationalOperation(operator){return function(value,other){if(!(typeof value=='string'&&typeof other=='string')){value=toNumber(value);other=toNumber(other);}return operator(value,other);};}/**
  36559. * Creates a function that wraps `func` to continue currying.
  36560. *
  36561. * @private
  36562. * @param {Function} func The function to wrap.
  36563. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  36564. * @param {Function} wrapFunc The function to create the `func` wrapper.
  36565. * @param {*} placeholder The placeholder value.
  36566. * @param {*} [thisArg] The `this` binding of `func`.
  36567. * @param {Array} [partials] The arguments to prepend to those provided to
  36568. * the new function.
  36569. * @param {Array} [holders] The `partials` placeholder indexes.
  36570. * @param {Array} [argPos] The argument positions of the new function.
  36571. * @param {number} [ary] The arity cap of `func`.
  36572. * @param {number} [arity] The arity of `func`.
  36573. * @returns {Function} Returns the new wrapped function.
  36574. */function createRecurry(func,bitmask,wrapFunc,placeholder,thisArg,partials,holders,argPos,ary,arity){var isCurry=bitmask&WRAP_CURRY_FLAG,newHolders=isCurry?holders:undefined,newHoldersRight=isCurry?undefined:holders,newPartials=isCurry?partials:undefined,newPartialsRight=isCurry?undefined:partials;bitmask|=isCurry?WRAP_PARTIAL_FLAG:WRAP_PARTIAL_RIGHT_FLAG;bitmask&=~(isCurry?WRAP_PARTIAL_RIGHT_FLAG:WRAP_PARTIAL_FLAG);if(!(bitmask&WRAP_CURRY_BOUND_FLAG)){bitmask&=~(WRAP_BIND_FLAG|WRAP_BIND_KEY_FLAG);}var newData=[func,bitmask,thisArg,newPartials,newHolders,newPartialsRight,newHoldersRight,argPos,ary,arity];var result=wrapFunc.apply(undefined,newData);if(isLaziable(func)){setData(result,newData);}result.placeholder=placeholder;return setWrapToString(result,func,bitmask);}/**
  36575. * Creates a function like `_.round`.
  36576. *
  36577. * @private
  36578. * @param {string} methodName The name of the `Math` method to use when rounding.
  36579. * @returns {Function} Returns the new round function.
  36580. */function createRound(methodName){var func=Math[methodName];return function(number,precision){number=toNumber(number);precision=precision==null?0:nativeMin(toInteger(precision),292);if(precision){// Shift with exponential notation to avoid floating-point issues.
  36581. // See [MDN](https://mdn.io/round#Examples) for more details.
  36582. var pair=(toString(number)+'e').split('e'),value=func(pair[0]+'e'+(+pair[1]+precision));pair=(toString(value)+'e').split('e');return+(pair[0]+'e'+(+pair[1]-precision));}return func(number);};}/**
  36583. * Creates a set object of `values`.
  36584. *
  36585. * @private
  36586. * @param {Array} values The values to add to the set.
  36587. * @returns {Object} Returns the new set.
  36588. */var createSet=!(Set&&1/setToArray(new Set([,-0]))[1]==INFINITY)?noop:function(values){return new Set(values);};/**
  36589. * Creates a `_.toPairs` or `_.toPairsIn` function.
  36590. *
  36591. * @private
  36592. * @param {Function} keysFunc The function to get the keys of a given object.
  36593. * @returns {Function} Returns the new pairs function.
  36594. */function createToPairs(keysFunc){return function(object){var tag=getTag(object);if(tag==mapTag){return mapToArray(object);}if(tag==setTag){return setToPairs(object);}return baseToPairs(object,keysFunc(object));};}/**
  36595. * Creates a function that either curries or invokes `func` with optional
  36596. * `this` binding and partially applied arguments.
  36597. *
  36598. * @private
  36599. * @param {Function|string} func The function or method name to wrap.
  36600. * @param {number} bitmask The bitmask flags.
  36601. * 1 - `_.bind`
  36602. * 2 - `_.bindKey`
  36603. * 4 - `_.curry` or `_.curryRight` of a bound function
  36604. * 8 - `_.curry`
  36605. * 16 - `_.curryRight`
  36606. * 32 - `_.partial`
  36607. * 64 - `_.partialRight`
  36608. * 128 - `_.rearg`
  36609. * 256 - `_.ary`
  36610. * 512 - `_.flip`
  36611. * @param {*} [thisArg] The `this` binding of `func`.
  36612. * @param {Array} [partials] The arguments to be partially applied.
  36613. * @param {Array} [holders] The `partials` placeholder indexes.
  36614. * @param {Array} [argPos] The argument positions of the new function.
  36615. * @param {number} [ary] The arity cap of `func`.
  36616. * @param {number} [arity] The arity of `func`.
  36617. * @returns {Function} Returns the new wrapped function.
  36618. */function createWrap(func,bitmask,thisArg,partials,holders,argPos,ary,arity){var isBindKey=bitmask&WRAP_BIND_KEY_FLAG;if(!isBindKey&&typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}var length=partials?partials.length:0;if(!length){bitmask&=~(WRAP_PARTIAL_FLAG|WRAP_PARTIAL_RIGHT_FLAG);partials=holders=undefined;}ary=ary===undefined?ary:nativeMax(toInteger(ary),0);arity=arity===undefined?arity:toInteger(arity);length-=holders?holders.length:0;if(bitmask&WRAP_PARTIAL_RIGHT_FLAG){var partialsRight=partials,holdersRight=holders;partials=holders=undefined;}var data=isBindKey?undefined:getData(func);var newData=[func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity];if(data){mergeData(newData,data);}func=newData[0];bitmask=newData[1];thisArg=newData[2];partials=newData[3];holders=newData[4];arity=newData[9]=newData[9]===undefined?isBindKey?0:func.length:nativeMax(newData[9]-length,0);if(!arity&&bitmask&(WRAP_CURRY_FLAG|WRAP_CURRY_RIGHT_FLAG)){bitmask&=~(WRAP_CURRY_FLAG|WRAP_CURRY_RIGHT_FLAG);}if(!bitmask||bitmask==WRAP_BIND_FLAG){var result=createBind(func,bitmask,thisArg);}else if(bitmask==WRAP_CURRY_FLAG||bitmask==WRAP_CURRY_RIGHT_FLAG){result=createCurry(func,bitmask,arity);}else if((bitmask==WRAP_PARTIAL_FLAG||bitmask==(WRAP_BIND_FLAG|WRAP_PARTIAL_FLAG))&&!holders.length){result=createPartial(func,bitmask,thisArg,partials);}else{result=createHybrid.apply(undefined,newData);}var setter=data?baseSetData:setData;return setWrapToString(setter(result,newData),func,bitmask);}/**
  36619. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  36620. * of source objects to the destination object for all destination properties
  36621. * that resolve to `undefined`.
  36622. *
  36623. * @private
  36624. * @param {*} objValue The destination value.
  36625. * @param {*} srcValue The source value.
  36626. * @param {string} key The key of the property to assign.
  36627. * @param {Object} object The parent object of `objValue`.
  36628. * @returns {*} Returns the value to assign.
  36629. */function customDefaultsAssignIn(objValue,srcValue,key,object){if(objValue===undefined||eq(objValue,objectProto[key])&&!hasOwnProperty.call(object,key)){return srcValue;}return objValue;}/**
  36630. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  36631. * objects into destination objects that are passed thru.
  36632. *
  36633. * @private
  36634. * @param {*} objValue The destination value.
  36635. * @param {*} srcValue The source value.
  36636. * @param {string} key The key of the property to merge.
  36637. * @param {Object} object The parent object of `objValue`.
  36638. * @param {Object} source The parent object of `srcValue`.
  36639. * @param {Object} [stack] Tracks traversed source values and their merged
  36640. * counterparts.
  36641. * @returns {*} Returns the value to assign.
  36642. */function customDefaultsMerge(objValue,srcValue,key,object,source,stack){if(isObject(objValue)&&isObject(srcValue)){// Recursively merge objects and arrays (susceptible to call stack limits).
  36643. stack.set(srcValue,objValue);baseMerge(objValue,srcValue,undefined,customDefaultsMerge,stack);stack['delete'](srcValue);}return objValue;}/**
  36644. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  36645. * objects.
  36646. *
  36647. * @private
  36648. * @param {*} value The value to inspect.
  36649. * @param {string} key The key of the property to inspect.
  36650. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  36651. */function customOmitClone(value){return isPlainObject(value)?undefined:value;}/**
  36652. * A specialized version of `baseIsEqualDeep` for arrays with support for
  36653. * partial deep comparisons.
  36654. *
  36655. * @private
  36656. * @param {Array} array The array to compare.
  36657. * @param {Array} other The other array to compare.
  36658. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  36659. * @param {Function} customizer The function to customize comparisons.
  36660. * @param {Function} equalFunc The function to determine equivalents of values.
  36661. * @param {Object} stack Tracks traversed `array` and `other` objects.
  36662. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  36663. */function equalArrays(array,other,bitmask,customizer,equalFunc,stack){var isPartial=bitmask&COMPARE_PARTIAL_FLAG,arrLength=array.length,othLength=other.length;if(arrLength!=othLength&&!(isPartial&&othLength>arrLength)){return false;}// Assume cyclic values are equal.
  36664. var stacked=stack.get(array);if(stacked&&stack.get(other)){return stacked==other;}var index=-1,result=true,seen=bitmask&COMPARE_UNORDERED_FLAG?new SetCache():undefined;stack.set(array,other);stack.set(other,array);// Ignore non-index properties.
  36665. while(++index<arrLength){var arrValue=array[index],othValue=other[index];if(customizer){var compared=isPartial?customizer(othValue,arrValue,index,other,array,stack):customizer(arrValue,othValue,index,array,other,stack);}if(compared!==undefined){if(compared){continue;}result=false;break;}// Recursively compare arrays (susceptible to call stack limits).
  36666. if(seen){if(!arraySome(other,function(othValue,othIndex){if(!cacheHas(seen,othIndex)&&(arrValue===othValue||equalFunc(arrValue,othValue,bitmask,customizer,stack))){return seen.push(othIndex);}})){result=false;break;}}else if(!(arrValue===othValue||equalFunc(arrValue,othValue,bitmask,customizer,stack))){result=false;break;}}stack['delete'](array);stack['delete'](other);return result;}/**
  36667. * A specialized version of `baseIsEqualDeep` for comparing objects of
  36668. * the same `toStringTag`.
  36669. *
  36670. * **Note:** This function only supports comparing values with tags of
  36671. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  36672. *
  36673. * @private
  36674. * @param {Object} object The object to compare.
  36675. * @param {Object} other The other object to compare.
  36676. * @param {string} tag The `toStringTag` of the objects to compare.
  36677. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  36678. * @param {Function} customizer The function to customize comparisons.
  36679. * @param {Function} equalFunc The function to determine equivalents of values.
  36680. * @param {Object} stack Tracks traversed `object` and `other` objects.
  36681. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  36682. */function equalByTag(object,other,tag,bitmask,customizer,equalFunc,stack){switch(tag){case dataViewTag:if(object.byteLength!=other.byteLength||object.byteOffset!=other.byteOffset){return false;}object=object.buffer;other=other.buffer;case arrayBufferTag:if(object.byteLength!=other.byteLength||!equalFunc(new Uint8Array(object),new Uint8Array(other))){return false;}return true;case boolTag:case dateTag:case numberTag:// Coerce booleans to `1` or `0` and dates to milliseconds.
  36683. // Invalid dates are coerced to `NaN`.
  36684. return eq(+object,+other);case errorTag:return object.name==other.name&&object.message==other.message;case regexpTag:case stringTag:// Coerce regexes to strings and treat strings, primitives and objects,
  36685. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  36686. // for more details.
  36687. return object==other+'';case mapTag:var convert=mapToArray;case setTag:var isPartial=bitmask&COMPARE_PARTIAL_FLAG;convert||(convert=setToArray);if(object.size!=other.size&&!isPartial){return false;}// Assume cyclic values are equal.
  36688. var stacked=stack.get(object);if(stacked){return stacked==other;}bitmask|=COMPARE_UNORDERED_FLAG;// Recursively compare objects (susceptible to call stack limits).
  36689. stack.set(object,other);var result=equalArrays(convert(object),convert(other),bitmask,customizer,equalFunc,stack);stack['delete'](object);return result;case symbolTag:if(symbolValueOf){return symbolValueOf.call(object)==symbolValueOf.call(other);}}return false;}/**
  36690. * A specialized version of `baseIsEqualDeep` for objects with support for
  36691. * partial deep comparisons.
  36692. *
  36693. * @private
  36694. * @param {Object} object The object to compare.
  36695. * @param {Object} other The other object to compare.
  36696. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  36697. * @param {Function} customizer The function to customize comparisons.
  36698. * @param {Function} equalFunc The function to determine equivalents of values.
  36699. * @param {Object} stack Tracks traversed `object` and `other` objects.
  36700. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  36701. */function equalObjects(object,other,bitmask,customizer,equalFunc,stack){var isPartial=bitmask&COMPARE_PARTIAL_FLAG,objProps=getAllKeys(object),objLength=objProps.length,othProps=getAllKeys(other),othLength=othProps.length;if(objLength!=othLength&&!isPartial){return false;}var index=objLength;while(index--){var key=objProps[index];if(!(isPartial?key in other:hasOwnProperty.call(other,key))){return false;}}// Assume cyclic values are equal.
  36702. var stacked=stack.get(object);if(stacked&&stack.get(other)){return stacked==other;}var result=true;stack.set(object,other);stack.set(other,object);var skipCtor=isPartial;while(++index<objLength){key=objProps[index];var objValue=object[key],othValue=other[key];if(customizer){var compared=isPartial?customizer(othValue,objValue,key,other,object,stack):customizer(objValue,othValue,key,object,other,stack);}// Recursively compare objects (susceptible to call stack limits).
  36703. if(!(compared===undefined?objValue===othValue||equalFunc(objValue,othValue,bitmask,customizer,stack):compared)){result=false;break;}skipCtor||(skipCtor=key=='constructor');}if(result&&!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;// Non `Object` object instances with different constructors are not equal.
  36704. if(objCtor!=othCtor&&'constructor'in object&&'constructor'in other&&!(typeof objCtor=='function'&&objCtor instanceof objCtor&&typeof othCtor=='function'&&othCtor instanceof othCtor)){result=false;}}stack['delete'](object);stack['delete'](other);return result;}/**
  36705. * A specialized version of `baseRest` which flattens the rest array.
  36706. *
  36707. * @private
  36708. * @param {Function} func The function to apply a rest parameter to.
  36709. * @returns {Function} Returns the new function.
  36710. */function flatRest(func){return setToString(overRest(func,undefined,flatten),func+'');}/**
  36711. * Creates an array of own enumerable property names and symbols of `object`.
  36712. *
  36713. * @private
  36714. * @param {Object} object The object to query.
  36715. * @returns {Array} Returns the array of property names and symbols.
  36716. */function getAllKeys(object){return baseGetAllKeys(object,keys,getSymbols);}/**
  36717. * Creates an array of own and inherited enumerable property names and
  36718. * symbols of `object`.
  36719. *
  36720. * @private
  36721. * @param {Object} object The object to query.
  36722. * @returns {Array} Returns the array of property names and symbols.
  36723. */function getAllKeysIn(object){return baseGetAllKeys(object,keysIn,getSymbolsIn);}/**
  36724. * Gets metadata for `func`.
  36725. *
  36726. * @private
  36727. * @param {Function} func The function to query.
  36728. * @returns {*} Returns the metadata for `func`.
  36729. */var getData=!metaMap?noop:function(func){return metaMap.get(func);};/**
  36730. * Gets the name of `func`.
  36731. *
  36732. * @private
  36733. * @param {Function} func The function to query.
  36734. * @returns {string} Returns the function name.
  36735. */function getFuncName(func){var result=func.name+'',array=realNames[result],length=hasOwnProperty.call(realNames,result)?array.length:0;while(length--){var data=array[length],otherFunc=data.func;if(otherFunc==null||otherFunc==func){return data.name;}}return result;}/**
  36736. * Gets the argument placeholder value for `func`.
  36737. *
  36738. * @private
  36739. * @param {Function} func The function to inspect.
  36740. * @returns {*} Returns the placeholder value.
  36741. */function getHolder(func){var object=hasOwnProperty.call(lodash,'placeholder')?lodash:func;return object.placeholder;}/**
  36742. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  36743. * this function returns the custom method, otherwise it returns `baseIteratee`.
  36744. * If arguments are provided, the chosen function is invoked with them and
  36745. * its result is returned.
  36746. *
  36747. * @private
  36748. * @param {*} [value] The value to convert to an iteratee.
  36749. * @param {number} [arity] The arity of the created iteratee.
  36750. * @returns {Function} Returns the chosen function or its result.
  36751. */function getIteratee(){var result=lodash.iteratee||iteratee;result=result===iteratee?baseIteratee:result;return arguments.length?result(arguments[0],arguments[1]):result;}/**
  36752. * Gets the data for `map`.
  36753. *
  36754. * @private
  36755. * @param {Object} map The map to query.
  36756. * @param {string} key The reference key.
  36757. * @returns {*} Returns the map data.
  36758. */function getMapData(map,key){var data=map.__data__;return isKeyable(key)?data[typeof key=='string'?'string':'hash']:data.map;}/**
  36759. * Gets the property names, values, and compare flags of `object`.
  36760. *
  36761. * @private
  36762. * @param {Object} object The object to query.
  36763. * @returns {Array} Returns the match data of `object`.
  36764. */function getMatchData(object){var result=keys(object),length=result.length;while(length--){var key=result[length],value=object[key];result[length]=[key,value,isStrictComparable(value)];}return result;}/**
  36765. * Gets the native function at `key` of `object`.
  36766. *
  36767. * @private
  36768. * @param {Object} object The object to query.
  36769. * @param {string} key The key of the method to get.
  36770. * @returns {*} Returns the function if it's native, else `undefined`.
  36771. */function getNative(object,key){var value=getValue(object,key);return baseIsNative(value)?value:undefined;}/**
  36772. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  36773. *
  36774. * @private
  36775. * @param {*} value The value to query.
  36776. * @returns {string} Returns the raw `toStringTag`.
  36777. */function getRawTag(value){var isOwn=hasOwnProperty.call(value,symToStringTag),tag=value[symToStringTag];try{value[symToStringTag]=undefined;var unmasked=true;}catch(e){}var result=nativeObjectToString.call(value);if(unmasked){if(isOwn){value[symToStringTag]=tag;}else{delete value[symToStringTag];}}return result;}/**
  36778. * Creates an array of the own enumerable symbols of `object`.
  36779. *
  36780. * @private
  36781. * @param {Object} object The object to query.
  36782. * @returns {Array} Returns the array of symbols.
  36783. */var getSymbols=!nativeGetSymbols?stubArray:function(object){if(object==null){return[];}object=Object(object);return arrayFilter(nativeGetSymbols(object),function(symbol){return propertyIsEnumerable.call(object,symbol);});};/**
  36784. * Creates an array of the own and inherited enumerable symbols of `object`.
  36785. *
  36786. * @private
  36787. * @param {Object} object The object to query.
  36788. * @returns {Array} Returns the array of symbols.
  36789. */var getSymbolsIn=!nativeGetSymbols?stubArray:function(object){var result=[];while(object){arrayPush(result,getSymbols(object));object=getPrototype(object);}return result;};/**
  36790. * Gets the `toStringTag` of `value`.
  36791. *
  36792. * @private
  36793. * @param {*} value The value to query.
  36794. * @returns {string} Returns the `toStringTag`.
  36795. */var getTag=baseGetTag;// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  36796. if(DataView&&getTag(new DataView(new ArrayBuffer(1)))!=dataViewTag||Map&&getTag(new Map())!=mapTag||Promise&&getTag(Promise.resolve())!=promiseTag||Set&&getTag(new Set())!=setTag||WeakMap&&getTag(new WeakMap())!=weakMapTag){getTag=function getTag(value){var result=baseGetTag(value),Ctor=result==objectTag?value.constructor:undefined,ctorString=Ctor?toSource(Ctor):'';if(ctorString){switch(ctorString){case dataViewCtorString:return dataViewTag;case mapCtorString:return mapTag;case promiseCtorString:return promiseTag;case setCtorString:return setTag;case weakMapCtorString:return weakMapTag;}}return result;};}/**
  36797. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  36798. *
  36799. * @private
  36800. * @param {number} start The start of the view.
  36801. * @param {number} end The end of the view.
  36802. * @param {Array} transforms The transformations to apply to the view.
  36803. * @returns {Object} Returns an object containing the `start` and `end`
  36804. * positions of the view.
  36805. */function getView(start,end,transforms){var index=-1,length=transforms.length;while(++index<length){var data=transforms[index],size=data.size;switch(data.type){case'drop':start+=size;break;case'dropRight':end-=size;break;case'take':end=nativeMin(end,start+size);break;case'takeRight':start=nativeMax(start,end-size);break;}}return{'start':start,'end':end};}/**
  36806. * Extracts wrapper details from the `source` body comment.
  36807. *
  36808. * @private
  36809. * @param {string} source The source to inspect.
  36810. * @returns {Array} Returns the wrapper details.
  36811. */function getWrapDetails(source){var match=source.match(reWrapDetails);return match?match[1].split(reSplitDetails):[];}/**
  36812. * Checks if `path` exists on `object`.
  36813. *
  36814. * @private
  36815. * @param {Object} object The object to query.
  36816. * @param {Array|string} path The path to check.
  36817. * @param {Function} hasFunc The function to check properties.
  36818. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  36819. */function hasPath(object,path,hasFunc){path=castPath(path,object);var index=-1,length=path.length,result=false;while(++index<length){var key=toKey(path[index]);if(!(result=object!=null&&hasFunc(object,key))){break;}object=object[key];}if(result||++index!=length){return result;}length=object==null?0:object.length;return!!length&&isLength(length)&&isIndex(key,length)&&(isArray(object)||isArguments(object));}/**
  36820. * Initializes an array clone.
  36821. *
  36822. * @private
  36823. * @param {Array} array The array to clone.
  36824. * @returns {Array} Returns the initialized clone.
  36825. */function initCloneArray(array){var length=array.length,result=new array.constructor(length);// Add properties assigned by `RegExp#exec`.
  36826. if(length&&typeof array[0]=='string'&&hasOwnProperty.call(array,'index')){result.index=array.index;result.input=array.input;}return result;}/**
  36827. * Initializes an object clone.
  36828. *
  36829. * @private
  36830. * @param {Object} object The object to clone.
  36831. * @returns {Object} Returns the initialized clone.
  36832. */function initCloneObject(object){return typeof object.constructor=='function'&&!isPrototype(object)?baseCreate(getPrototype(object)):{};}/**
  36833. * Initializes an object clone based on its `toStringTag`.
  36834. *
  36835. * **Note:** This function only supports cloning values with tags of
  36836. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  36837. *
  36838. * @private
  36839. * @param {Object} object The object to clone.
  36840. * @param {string} tag The `toStringTag` of the object to clone.
  36841. * @param {boolean} [isDeep] Specify a deep clone.
  36842. * @returns {Object} Returns the initialized clone.
  36843. */function initCloneByTag(object,tag,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return cloneArrayBuffer(object);case boolTag:case dateTag:return new Ctor(+object);case dataViewTag:return cloneDataView(object,isDeep);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:return cloneTypedArray(object,isDeep);case mapTag:return new Ctor();case numberTag:case stringTag:return new Ctor(object);case regexpTag:return cloneRegExp(object);case setTag:return new Ctor();case symbolTag:return cloneSymbol(object);}}/**
  36844. * Inserts wrapper `details` in a comment at the top of the `source` body.
  36845. *
  36846. * @private
  36847. * @param {string} source The source to modify.
  36848. * @returns {Array} details The details to insert.
  36849. * @returns {string} Returns the modified source.
  36850. */function insertWrapDetails(source,details){var length=details.length;if(!length){return source;}var lastIndex=length-1;details[lastIndex]=(length>1?'& ':'')+details[lastIndex];details=details.join(length>2?', ':' ');return source.replace(reWrapComment,'{\n/* [wrapped with '+details+'] */\n');}/**
  36851. * Checks if `value` is a flattenable `arguments` object or array.
  36852. *
  36853. * @private
  36854. * @param {*} value The value to check.
  36855. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  36856. */function isFlattenable(value){return isArray(value)||isArguments(value)||!!(spreadableSymbol&&value&&value[spreadableSymbol]);}/**
  36857. * Checks if `value` is a valid array-like index.
  36858. *
  36859. * @private
  36860. * @param {*} value The value to check.
  36861. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  36862. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  36863. */function isIndex(value,length){var type=typeof value==='undefined'?'undefined':_typeof(value);length=length==null?MAX_SAFE_INTEGER:length;return!!length&&(type=='number'||type!='symbol'&&reIsUint.test(value))&&value>-1&&value%1==0&&value<length;}/**
  36864. * Checks if the given arguments are from an iteratee call.
  36865. *
  36866. * @private
  36867. * @param {*} value The potential iteratee value argument.
  36868. * @param {*} index The potential iteratee index or key argument.
  36869. * @param {*} object The potential iteratee object argument.
  36870. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  36871. * else `false`.
  36872. */function isIterateeCall(value,index,object){if(!isObject(object)){return false;}var type=typeof index==='undefined'?'undefined':_typeof(index);if(type=='number'?isArrayLike(object)&&isIndex(index,object.length):type=='string'&&index in object){return eq(object[index],value);}return false;}/**
  36873. * Checks if `value` is a property name and not a property path.
  36874. *
  36875. * @private
  36876. * @param {*} value The value to check.
  36877. * @param {Object} [object] The object to query keys on.
  36878. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  36879. */function isKey(value,object){if(isArray(value)){return false;}var type=typeof value==='undefined'?'undefined':_typeof(value);if(type=='number'||type=='symbol'||type=='boolean'||value==null||isSymbol(value)){return true;}return reIsPlainProp.test(value)||!reIsDeepProp.test(value)||object!=null&&value in Object(object);}/**
  36880. * Checks if `value` is suitable for use as unique object key.
  36881. *
  36882. * @private
  36883. * @param {*} value The value to check.
  36884. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  36885. */function isKeyable(value){var type=typeof value==='undefined'?'undefined':_typeof(value);return type=='string'||type=='number'||type=='symbol'||type=='boolean'?value!=='__proto__':value===null;}/**
  36886. * Checks if `func` has a lazy counterpart.
  36887. *
  36888. * @private
  36889. * @param {Function} func The function to check.
  36890. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  36891. * else `false`.
  36892. */function isLaziable(func){var funcName=getFuncName(func),other=lodash[funcName];if(typeof other!='function'||!(funcName in LazyWrapper.prototype)){return false;}if(func===other){return true;}var data=getData(other);return!!data&&func===data[0];}/**
  36893. * Checks if `func` has its source masked.
  36894. *
  36895. * @private
  36896. * @param {Function} func The function to check.
  36897. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  36898. */function isMasked(func){return!!maskSrcKey&&maskSrcKey in func;}/**
  36899. * Checks if `func` is capable of being masked.
  36900. *
  36901. * @private
  36902. * @param {*} value The value to check.
  36903. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  36904. */var isMaskable=coreJsData?isFunction:stubFalse;/**
  36905. * Checks if `value` is likely a prototype object.
  36906. *
  36907. * @private
  36908. * @param {*} value The value to check.
  36909. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  36910. */function isPrototype(value){var Ctor=value&&value.constructor,proto=typeof Ctor=='function'&&Ctor.prototype||objectProto;return value===proto;}/**
  36911. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  36912. *
  36913. * @private
  36914. * @param {*} value The value to check.
  36915. * @returns {boolean} Returns `true` if `value` if suitable for strict
  36916. * equality comparisons, else `false`.
  36917. */function isStrictComparable(value){return value===value&&!isObject(value);}/**
  36918. * A specialized version of `matchesProperty` for source values suitable
  36919. * for strict equality comparisons, i.e. `===`.
  36920. *
  36921. * @private
  36922. * @param {string} key The key of the property to get.
  36923. * @param {*} srcValue The value to match.
  36924. * @returns {Function} Returns the new spec function.
  36925. */function matchesStrictComparable(key,srcValue){return function(object){if(object==null){return false;}return object[key]===srcValue&&(srcValue!==undefined||key in Object(object));};}/**
  36926. * A specialized version of `_.memoize` which clears the memoized function's
  36927. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  36928. *
  36929. * @private
  36930. * @param {Function} func The function to have its output memoized.
  36931. * @returns {Function} Returns the new memoized function.
  36932. */function memoizeCapped(func){var result=memoize(func,function(key){if(cache.size===MAX_MEMOIZE_SIZE){cache.clear();}return key;});var cache=result.cache;return result;}/**
  36933. * Merges the function metadata of `source` into `data`.
  36934. *
  36935. * Merging metadata reduces the number of wrappers used to invoke a function.
  36936. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  36937. * may be applied regardless of execution order. Methods like `_.ary` and
  36938. * `_.rearg` modify function arguments, making the order in which they are
  36939. * executed important, preventing the merging of metadata. However, we make
  36940. * an exception for a safe combined case where curried functions have `_.ary`
  36941. * and or `_.rearg` applied.
  36942. *
  36943. * @private
  36944. * @param {Array} data The destination metadata.
  36945. * @param {Array} source The source metadata.
  36946. * @returns {Array} Returns `data`.
  36947. */function mergeData(data,source){var bitmask=data[1],srcBitmask=source[1],newBitmask=bitmask|srcBitmask,isCommon=newBitmask<(WRAP_BIND_FLAG|WRAP_BIND_KEY_FLAG|WRAP_ARY_FLAG);var isCombo=srcBitmask==WRAP_ARY_FLAG&&bitmask==WRAP_CURRY_FLAG||srcBitmask==WRAP_ARY_FLAG&&bitmask==WRAP_REARG_FLAG&&data[7].length<=source[8]||srcBitmask==(WRAP_ARY_FLAG|WRAP_REARG_FLAG)&&source[7].length<=source[8]&&bitmask==WRAP_CURRY_FLAG;// Exit early if metadata can't be merged.
  36948. if(!(isCommon||isCombo)){return data;}// Use source `thisArg` if available.
  36949. if(srcBitmask&WRAP_BIND_FLAG){data[2]=source[2];// Set when currying a bound function.
  36950. newBitmask|=bitmask&WRAP_BIND_FLAG?0:WRAP_CURRY_BOUND_FLAG;}// Compose partial arguments.
  36951. var value=source[3];if(value){var partials=data[3];data[3]=partials?composeArgs(partials,value,source[4]):value;data[4]=partials?replaceHolders(data[3],PLACEHOLDER):source[4];}// Compose partial right arguments.
  36952. value=source[5];if(value){partials=data[5];data[5]=partials?composeArgsRight(partials,value,source[6]):value;data[6]=partials?replaceHolders(data[5],PLACEHOLDER):source[6];}// Use source `argPos` if available.
  36953. value=source[7];if(value){data[7]=value;}// Use source `ary` if it's smaller.
  36954. if(srcBitmask&WRAP_ARY_FLAG){data[8]=data[8]==null?source[8]:nativeMin(data[8],source[8]);}// Use source `arity` if one is not provided.
  36955. if(data[9]==null){data[9]=source[9];}// Use source `func` and merge bitmasks.
  36956. data[0]=source[0];data[1]=newBitmask;return data;}/**
  36957. * This function is like
  36958. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  36959. * except that it includes inherited enumerable properties.
  36960. *
  36961. * @private
  36962. * @param {Object} object The object to query.
  36963. * @returns {Array} Returns the array of property names.
  36964. */function nativeKeysIn(object){var result=[];if(object!=null){for(var key in Object(object)){result.push(key);}}return result;}/**
  36965. * Converts `value` to a string using `Object.prototype.toString`.
  36966. *
  36967. * @private
  36968. * @param {*} value The value to convert.
  36969. * @returns {string} Returns the converted string.
  36970. */function objectToString(value){return nativeObjectToString.call(value);}/**
  36971. * A specialized version of `baseRest` which transforms the rest array.
  36972. *
  36973. * @private
  36974. * @param {Function} func The function to apply a rest parameter to.
  36975. * @param {number} [start=func.length-1] The start position of the rest parameter.
  36976. * @param {Function} transform The rest array transform.
  36977. * @returns {Function} Returns the new function.
  36978. */function overRest(func,start,transform){start=nativeMax(start===undefined?func.length-1:start,0);return function(){var args=arguments,index=-1,length=nativeMax(args.length-start,0),array=Array(length);while(++index<length){array[index]=args[start+index];}index=-1;var otherArgs=Array(start+1);while(++index<start){otherArgs[index]=args[index];}otherArgs[start]=transform(array);return apply(func,this,otherArgs);};}/**
  36979. * Gets the parent value at `path` of `object`.
  36980. *
  36981. * @private
  36982. * @param {Object} object The object to query.
  36983. * @param {Array} path The path to get the parent value of.
  36984. * @returns {*} Returns the parent value.
  36985. */function parent(object,path){return path.length<2?object:baseGet(object,baseSlice(path,0,-1));}/**
  36986. * Reorder `array` according to the specified indexes where the element at
  36987. * the first index is assigned as the first element, the element at
  36988. * the second index is assigned as the second element, and so on.
  36989. *
  36990. * @private
  36991. * @param {Array} array The array to reorder.
  36992. * @param {Array} indexes The arranged array indexes.
  36993. * @returns {Array} Returns `array`.
  36994. */function reorder(array,indexes){var arrLength=array.length,length=nativeMin(indexes.length,arrLength),oldArray=copyArray(array);while(length--){var index=indexes[length];array[length]=isIndex(index,arrLength)?oldArray[index]:undefined;}return array;}/**
  36995. * Gets the value at `key`, unless `key` is "__proto__".
  36996. *
  36997. * @private
  36998. * @param {Object} object The object to query.
  36999. * @param {string} key The key of the property to get.
  37000. * @returns {*} Returns the property value.
  37001. */function safeGet(object,key){if(key=='__proto__'){return;}return object[key];}/**
  37002. * Sets metadata for `func`.
  37003. *
  37004. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  37005. * period of time, it will trip its breaker and transition to an identity
  37006. * function to avoid garbage collection pauses in V8. See
  37007. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  37008. * for more details.
  37009. *
  37010. * @private
  37011. * @param {Function} func The function to associate metadata with.
  37012. * @param {*} data The metadata.
  37013. * @returns {Function} Returns `func`.
  37014. */var setData=shortOut(baseSetData);/**
  37015. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  37016. *
  37017. * @private
  37018. * @param {Function} func The function to delay.
  37019. * @param {number} wait The number of milliseconds to delay invocation.
  37020. * @returns {number|Object} Returns the timer id or timeout object.
  37021. */var setTimeout=ctxSetTimeout||function(func,wait){return root.setTimeout(func,wait);};/**
  37022. * Sets the `toString` method of `func` to return `string`.
  37023. *
  37024. * @private
  37025. * @param {Function} func The function to modify.
  37026. * @param {Function} string The `toString` result.
  37027. * @returns {Function} Returns `func`.
  37028. */var setToString=shortOut(baseSetToString);/**
  37029. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  37030. * with wrapper details in a comment at the top of the source body.
  37031. *
  37032. * @private
  37033. * @param {Function} wrapper The function to modify.
  37034. * @param {Function} reference The reference function.
  37035. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  37036. * @returns {Function} Returns `wrapper`.
  37037. */function setWrapToString(wrapper,reference,bitmask){var source=reference+'';return setToString(wrapper,insertWrapDetails(source,updateWrapDetails(getWrapDetails(source),bitmask)));}/**
  37038. * Creates a function that'll short out and invoke `identity` instead
  37039. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  37040. * milliseconds.
  37041. *
  37042. * @private
  37043. * @param {Function} func The function to restrict.
  37044. * @returns {Function} Returns the new shortable function.
  37045. */function shortOut(func){var count=0,lastCalled=0;return function(){var stamp=nativeNow(),remaining=HOT_SPAN-(stamp-lastCalled);lastCalled=stamp;if(remaining>0){if(++count>=HOT_COUNT){return arguments[0];}}else{count=0;}return func.apply(undefined,arguments);};}/**
  37046. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  37047. *
  37048. * @private
  37049. * @param {Array} array The array to shuffle.
  37050. * @param {number} [size=array.length] The size of `array`.
  37051. * @returns {Array} Returns `array`.
  37052. */function shuffleSelf(array,size){var index=-1,length=array.length,lastIndex=length-1;size=size===undefined?length:size;while(++index<size){var rand=baseRandom(index,lastIndex),value=array[rand];array[rand]=array[index];array[index]=value;}array.length=size;return array;}/**
  37053. * Converts `string` to a property path array.
  37054. *
  37055. * @private
  37056. * @param {string} string The string to convert.
  37057. * @returns {Array} Returns the property path array.
  37058. */var stringToPath=memoizeCapped(function(string){var result=[];if(string.charCodeAt(0)===46/* . */){result.push('');}string.replace(rePropName,function(match,number,quote,subString){result.push(quote?subString.replace(reEscapeChar,'$1'):number||match);});return result;});/**
  37059. * Converts `value` to a string key if it's not a string or symbol.
  37060. *
  37061. * @private
  37062. * @param {*} value The value to inspect.
  37063. * @returns {string|symbol} Returns the key.
  37064. */function toKey(value){if(typeof value=='string'||isSymbol(value)){return value;}var result=value+'';return result=='0'&&1/value==-INFINITY?'-0':result;}/**
  37065. * Converts `func` to its source code.
  37066. *
  37067. * @private
  37068. * @param {Function} func The function to convert.
  37069. * @returns {string} Returns the source code.
  37070. */function toSource(func){if(func!=null){try{return funcToString.call(func);}catch(e){}try{return func+'';}catch(e){}}return'';}/**
  37071. * Updates wrapper `details` based on `bitmask` flags.
  37072. *
  37073. * @private
  37074. * @returns {Array} details The details to modify.
  37075. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  37076. * @returns {Array} Returns `details`.
  37077. */function updateWrapDetails(details,bitmask){arrayEach(wrapFlags,function(pair){var value='_.'+pair[0];if(bitmask&pair[1]&&!arrayIncludes(details,value)){details.push(value);}});return details.sort();}/**
  37078. * Creates a clone of `wrapper`.
  37079. *
  37080. * @private
  37081. * @param {Object} wrapper The wrapper to clone.
  37082. * @returns {Object} Returns the cloned wrapper.
  37083. */function wrapperClone(wrapper){if(wrapper instanceof LazyWrapper){return wrapper.clone();}var result=new LodashWrapper(wrapper.__wrapped__,wrapper.__chain__);result.__actions__=copyArray(wrapper.__actions__);result.__index__=wrapper.__index__;result.__values__=wrapper.__values__;return result;}/*------------------------------------------------------------------------*//**
  37084. * Creates an array of elements split into groups the length of `size`.
  37085. * If `array` can't be split evenly, the final chunk will be the remaining
  37086. * elements.
  37087. *
  37088. * @static
  37089. * @memberOf _
  37090. * @since 3.0.0
  37091. * @category Array
  37092. * @param {Array} array The array to process.
  37093. * @param {number} [size=1] The length of each chunk
  37094. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  37095. * @returns {Array} Returns the new array of chunks.
  37096. * @example
  37097. *
  37098. * _.chunk(['a', 'b', 'c', 'd'], 2);
  37099. * // => [['a', 'b'], ['c', 'd']]
  37100. *
  37101. * _.chunk(['a', 'b', 'c', 'd'], 3);
  37102. * // => [['a', 'b', 'c'], ['d']]
  37103. */function chunk(array,size,guard){if(guard?isIterateeCall(array,size,guard):size===undefined){size=1;}else{size=nativeMax(toInteger(size),0);}var length=array==null?0:array.length;if(!length||size<1){return[];}var index=0,resIndex=0,result=Array(nativeCeil(length/size));while(index<length){result[resIndex++]=baseSlice(array,index,index+=size);}return result;}/**
  37104. * Creates an array with all falsey values removed. The values `false`, `null`,
  37105. * `0`, `""`, `undefined`, and `NaN` are falsey.
  37106. *
  37107. * @static
  37108. * @memberOf _
  37109. * @since 0.1.0
  37110. * @category Array
  37111. * @param {Array} array The array to compact.
  37112. * @returns {Array} Returns the new array of filtered values.
  37113. * @example
  37114. *
  37115. * _.compact([0, 1, false, 2, '', 3]);
  37116. * // => [1, 2, 3]
  37117. */function compact(array){var index=-1,length=array==null?0:array.length,resIndex=0,result=[];while(++index<length){var value=array[index];if(value){result[resIndex++]=value;}}return result;}/**
  37118. * Creates a new array concatenating `array` with any additional arrays
  37119. * and/or values.
  37120. *
  37121. * @static
  37122. * @memberOf _
  37123. * @since 4.0.0
  37124. * @category Array
  37125. * @param {Array} array The array to concatenate.
  37126. * @param {...*} [values] The values to concatenate.
  37127. * @returns {Array} Returns the new concatenated array.
  37128. * @example
  37129. *
  37130. * var array = [1];
  37131. * var other = _.concat(array, 2, [3], [[4]]);
  37132. *
  37133. * console.log(other);
  37134. * // => [1, 2, 3, [4]]
  37135. *
  37136. * console.log(array);
  37137. * // => [1]
  37138. */function concat(){var length=arguments.length;if(!length){return[];}var args=Array(length-1),array=arguments[0],index=length;while(index--){args[index-1]=arguments[index];}return arrayPush(isArray(array)?copyArray(array):[array],baseFlatten(args,1));}/**
  37139. * Creates an array of `array` values not included in the other given arrays
  37140. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  37141. * for equality comparisons. The order and references of result values are
  37142. * determined by the first array.
  37143. *
  37144. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  37145. *
  37146. * @static
  37147. * @memberOf _
  37148. * @since 0.1.0
  37149. * @category Array
  37150. * @param {Array} array The array to inspect.
  37151. * @param {...Array} [values] The values to exclude.
  37152. * @returns {Array} Returns the new array of filtered values.
  37153. * @see _.without, _.xor
  37154. * @example
  37155. *
  37156. * _.difference([2, 1], [2, 3]);
  37157. * // => [1]
  37158. */var difference=baseRest(function(array,values){return isArrayLikeObject(array)?baseDifference(array,baseFlatten(values,1,isArrayLikeObject,true)):[];});/**
  37159. * This method is like `_.difference` except that it accepts `iteratee` which
  37160. * is invoked for each element of `array` and `values` to generate the criterion
  37161. * by which they're compared. The order and references of result values are
  37162. * determined by the first array. The iteratee is invoked with one argument:
  37163. * (value).
  37164. *
  37165. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  37166. *
  37167. * @static
  37168. * @memberOf _
  37169. * @since 4.0.0
  37170. * @category Array
  37171. * @param {Array} array The array to inspect.
  37172. * @param {...Array} [values] The values to exclude.
  37173. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  37174. * @returns {Array} Returns the new array of filtered values.
  37175. * @example
  37176. *
  37177. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  37178. * // => [1.2]
  37179. *
  37180. * // The `_.property` iteratee shorthand.
  37181. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  37182. * // => [{ 'x': 2 }]
  37183. */var differenceBy=baseRest(function(array,values){var iteratee=last(values);if(isArrayLikeObject(iteratee)){iteratee=undefined;}return isArrayLikeObject(array)?baseDifference(array,baseFlatten(values,1,isArrayLikeObject,true),getIteratee(iteratee,2)):[];});/**
  37184. * This method is like `_.difference` except that it accepts `comparator`
  37185. * which is invoked to compare elements of `array` to `values`. The order and
  37186. * references of result values are determined by the first array. The comparator
  37187. * is invoked with two arguments: (arrVal, othVal).
  37188. *
  37189. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  37190. *
  37191. * @static
  37192. * @memberOf _
  37193. * @since 4.0.0
  37194. * @category Array
  37195. * @param {Array} array The array to inspect.
  37196. * @param {...Array} [values] The values to exclude.
  37197. * @param {Function} [comparator] The comparator invoked per element.
  37198. * @returns {Array} Returns the new array of filtered values.
  37199. * @example
  37200. *
  37201. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  37202. *
  37203. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  37204. * // => [{ 'x': 2, 'y': 1 }]
  37205. */var differenceWith=baseRest(function(array,values){var comparator=last(values);if(isArrayLikeObject(comparator)){comparator=undefined;}return isArrayLikeObject(array)?baseDifference(array,baseFlatten(values,1,isArrayLikeObject,true),undefined,comparator):[];});/**
  37206. * Creates a slice of `array` with `n` elements dropped from the beginning.
  37207. *
  37208. * @static
  37209. * @memberOf _
  37210. * @since 0.5.0
  37211. * @category Array
  37212. * @param {Array} array The array to query.
  37213. * @param {number} [n=1] The number of elements to drop.
  37214. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  37215. * @returns {Array} Returns the slice of `array`.
  37216. * @example
  37217. *
  37218. * _.drop([1, 2, 3]);
  37219. * // => [2, 3]
  37220. *
  37221. * _.drop([1, 2, 3], 2);
  37222. * // => [3]
  37223. *
  37224. * _.drop([1, 2, 3], 5);
  37225. * // => []
  37226. *
  37227. * _.drop([1, 2, 3], 0);
  37228. * // => [1, 2, 3]
  37229. */function drop(array,n,guard){var length=array==null?0:array.length;if(!length){return[];}n=guard||n===undefined?1:toInteger(n);return baseSlice(array,n<0?0:n,length);}/**
  37230. * Creates a slice of `array` with `n` elements dropped from the end.
  37231. *
  37232. * @static
  37233. * @memberOf _
  37234. * @since 3.0.0
  37235. * @category Array
  37236. * @param {Array} array The array to query.
  37237. * @param {number} [n=1] The number of elements to drop.
  37238. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  37239. * @returns {Array} Returns the slice of `array`.
  37240. * @example
  37241. *
  37242. * _.dropRight([1, 2, 3]);
  37243. * // => [1, 2]
  37244. *
  37245. * _.dropRight([1, 2, 3], 2);
  37246. * // => [1]
  37247. *
  37248. * _.dropRight([1, 2, 3], 5);
  37249. * // => []
  37250. *
  37251. * _.dropRight([1, 2, 3], 0);
  37252. * // => [1, 2, 3]
  37253. */function dropRight(array,n,guard){var length=array==null?0:array.length;if(!length){return[];}n=guard||n===undefined?1:toInteger(n);n=length-n;return baseSlice(array,0,n<0?0:n);}/**
  37254. * Creates a slice of `array` excluding elements dropped from the end.
  37255. * Elements are dropped until `predicate` returns falsey. The predicate is
  37256. * invoked with three arguments: (value, index, array).
  37257. *
  37258. * @static
  37259. * @memberOf _
  37260. * @since 3.0.0
  37261. * @category Array
  37262. * @param {Array} array The array to query.
  37263. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  37264. * @returns {Array} Returns the slice of `array`.
  37265. * @example
  37266. *
  37267. * var users = [
  37268. * { 'user': 'barney', 'active': true },
  37269. * { 'user': 'fred', 'active': false },
  37270. * { 'user': 'pebbles', 'active': false }
  37271. * ];
  37272. *
  37273. * _.dropRightWhile(users, function(o) { return !o.active; });
  37274. * // => objects for ['barney']
  37275. *
  37276. * // The `_.matches` iteratee shorthand.
  37277. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  37278. * // => objects for ['barney', 'fred']
  37279. *
  37280. * // The `_.matchesProperty` iteratee shorthand.
  37281. * _.dropRightWhile(users, ['active', false]);
  37282. * // => objects for ['barney']
  37283. *
  37284. * // The `_.property` iteratee shorthand.
  37285. * _.dropRightWhile(users, 'active');
  37286. * // => objects for ['barney', 'fred', 'pebbles']
  37287. */function dropRightWhile(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3),true,true):[];}/**
  37288. * Creates a slice of `array` excluding elements dropped from the beginning.
  37289. * Elements are dropped until `predicate` returns falsey. The predicate is
  37290. * invoked with three arguments: (value, index, array).
  37291. *
  37292. * @static
  37293. * @memberOf _
  37294. * @since 3.0.0
  37295. * @category Array
  37296. * @param {Array} array The array to query.
  37297. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  37298. * @returns {Array} Returns the slice of `array`.
  37299. * @example
  37300. *
  37301. * var users = [
  37302. * { 'user': 'barney', 'active': false },
  37303. * { 'user': 'fred', 'active': false },
  37304. * { 'user': 'pebbles', 'active': true }
  37305. * ];
  37306. *
  37307. * _.dropWhile(users, function(o) { return !o.active; });
  37308. * // => objects for ['pebbles']
  37309. *
  37310. * // The `_.matches` iteratee shorthand.
  37311. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  37312. * // => objects for ['fred', 'pebbles']
  37313. *
  37314. * // The `_.matchesProperty` iteratee shorthand.
  37315. * _.dropWhile(users, ['active', false]);
  37316. * // => objects for ['pebbles']
  37317. *
  37318. * // The `_.property` iteratee shorthand.
  37319. * _.dropWhile(users, 'active');
  37320. * // => objects for ['barney', 'fred', 'pebbles']
  37321. */function dropWhile(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3),true):[];}/**
  37322. * Fills elements of `array` with `value` from `start` up to, but not
  37323. * including, `end`.
  37324. *
  37325. * **Note:** This method mutates `array`.
  37326. *
  37327. * @static
  37328. * @memberOf _
  37329. * @since 3.2.0
  37330. * @category Array
  37331. * @param {Array} array The array to fill.
  37332. * @param {*} value The value to fill `array` with.
  37333. * @param {number} [start=0] The start position.
  37334. * @param {number} [end=array.length] The end position.
  37335. * @returns {Array} Returns `array`.
  37336. * @example
  37337. *
  37338. * var array = [1, 2, 3];
  37339. *
  37340. * _.fill(array, 'a');
  37341. * console.log(array);
  37342. * // => ['a', 'a', 'a']
  37343. *
  37344. * _.fill(Array(3), 2);
  37345. * // => [2, 2, 2]
  37346. *
  37347. * _.fill([4, 6, 8, 10], '*', 1, 3);
  37348. * // => [4, '*', '*', 10]
  37349. */function fill(array,value,start,end){var length=array==null?0:array.length;if(!length){return[];}if(start&&typeof start!='number'&&isIterateeCall(array,value,start)){start=0;end=length;}return baseFill(array,value,start,end);}/**
  37350. * This method is like `_.find` except that it returns the index of the first
  37351. * element `predicate` returns truthy for instead of the element itself.
  37352. *
  37353. * @static
  37354. * @memberOf _
  37355. * @since 1.1.0
  37356. * @category Array
  37357. * @param {Array} array The array to inspect.
  37358. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  37359. * @param {number} [fromIndex=0] The index to search from.
  37360. * @returns {number} Returns the index of the found element, else `-1`.
  37361. * @example
  37362. *
  37363. * var users = [
  37364. * { 'user': 'barney', 'active': false },
  37365. * { 'user': 'fred', 'active': false },
  37366. * { 'user': 'pebbles', 'active': true }
  37367. * ];
  37368. *
  37369. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  37370. * // => 0
  37371. *
  37372. * // The `_.matches` iteratee shorthand.
  37373. * _.findIndex(users, { 'user': 'fred', 'active': false });
  37374. * // => 1
  37375. *
  37376. * // The `_.matchesProperty` iteratee shorthand.
  37377. * _.findIndex(users, ['active', false]);
  37378. * // => 0
  37379. *
  37380. * // The `_.property` iteratee shorthand.
  37381. * _.findIndex(users, 'active');
  37382. * // => 2
  37383. */function findIndex(array,predicate,fromIndex){var length=array==null?0:array.length;if(!length){return-1;}var index=fromIndex==null?0:toInteger(fromIndex);if(index<0){index=nativeMax(length+index,0);}return baseFindIndex(array,getIteratee(predicate,3),index);}/**
  37384. * This method is like `_.findIndex` except that it iterates over elements
  37385. * of `collection` from right to left.
  37386. *
  37387. * @static
  37388. * @memberOf _
  37389. * @since 2.0.0
  37390. * @category Array
  37391. * @param {Array} array The array to inspect.
  37392. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  37393. * @param {number} [fromIndex=array.length-1] The index to search from.
  37394. * @returns {number} Returns the index of the found element, else `-1`.
  37395. * @example
  37396. *
  37397. * var users = [
  37398. * { 'user': 'barney', 'active': true },
  37399. * { 'user': 'fred', 'active': false },
  37400. * { 'user': 'pebbles', 'active': false }
  37401. * ];
  37402. *
  37403. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  37404. * // => 2
  37405. *
  37406. * // The `_.matches` iteratee shorthand.
  37407. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  37408. * // => 0
  37409. *
  37410. * // The `_.matchesProperty` iteratee shorthand.
  37411. * _.findLastIndex(users, ['active', false]);
  37412. * // => 2
  37413. *
  37414. * // The `_.property` iteratee shorthand.
  37415. * _.findLastIndex(users, 'active');
  37416. * // => 0
  37417. */function findLastIndex(array,predicate,fromIndex){var length=array==null?0:array.length;if(!length){return-1;}var index=length-1;if(fromIndex!==undefined){index=toInteger(fromIndex);index=fromIndex<0?nativeMax(length+index,0):nativeMin(index,length-1);}return baseFindIndex(array,getIteratee(predicate,3),index,true);}/**
  37418. * Flattens `array` a single level deep.
  37419. *
  37420. * @static
  37421. * @memberOf _
  37422. * @since 0.1.0
  37423. * @category Array
  37424. * @param {Array} array The array to flatten.
  37425. * @returns {Array} Returns the new flattened array.
  37426. * @example
  37427. *
  37428. * _.flatten([1, [2, [3, [4]], 5]]);
  37429. * // => [1, 2, [3, [4]], 5]
  37430. */function flatten(array){var length=array==null?0:array.length;return length?baseFlatten(array,1):[];}/**
  37431. * Recursively flattens `array`.
  37432. *
  37433. * @static
  37434. * @memberOf _
  37435. * @since 3.0.0
  37436. * @category Array
  37437. * @param {Array} array The array to flatten.
  37438. * @returns {Array} Returns the new flattened array.
  37439. * @example
  37440. *
  37441. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  37442. * // => [1, 2, 3, 4, 5]
  37443. */function flattenDeep(array){var length=array==null?0:array.length;return length?baseFlatten(array,INFINITY):[];}/**
  37444. * Recursively flatten `array` up to `depth` times.
  37445. *
  37446. * @static
  37447. * @memberOf _
  37448. * @since 4.4.0
  37449. * @category Array
  37450. * @param {Array} array The array to flatten.
  37451. * @param {number} [depth=1] The maximum recursion depth.
  37452. * @returns {Array} Returns the new flattened array.
  37453. * @example
  37454. *
  37455. * var array = [1, [2, [3, [4]], 5]];
  37456. *
  37457. * _.flattenDepth(array, 1);
  37458. * // => [1, 2, [3, [4]], 5]
  37459. *
  37460. * _.flattenDepth(array, 2);
  37461. * // => [1, 2, 3, [4], 5]
  37462. */function flattenDepth(array,depth){var length=array==null?0:array.length;if(!length){return[];}depth=depth===undefined?1:toInteger(depth);return baseFlatten(array,depth);}/**
  37463. * The inverse of `_.toPairs`; this method returns an object composed
  37464. * from key-value `pairs`.
  37465. *
  37466. * @static
  37467. * @memberOf _
  37468. * @since 4.0.0
  37469. * @category Array
  37470. * @param {Array} pairs The key-value pairs.
  37471. * @returns {Object} Returns the new object.
  37472. * @example
  37473. *
  37474. * _.fromPairs([['a', 1], ['b', 2]]);
  37475. * // => { 'a': 1, 'b': 2 }
  37476. */function fromPairs(pairs){var index=-1,length=pairs==null?0:pairs.length,result={};while(++index<length){var pair=pairs[index];result[pair[0]]=pair[1];}return result;}/**
  37477. * Gets the first element of `array`.
  37478. *
  37479. * @static
  37480. * @memberOf _
  37481. * @since 0.1.0
  37482. * @alias first
  37483. * @category Array
  37484. * @param {Array} array The array to query.
  37485. * @returns {*} Returns the first element of `array`.
  37486. * @example
  37487. *
  37488. * _.head([1, 2, 3]);
  37489. * // => 1
  37490. *
  37491. * _.head([]);
  37492. * // => undefined
  37493. */function head(array){return array&&array.length?array[0]:undefined;}/**
  37494. * Gets the index at which the first occurrence of `value` is found in `array`
  37495. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  37496. * for equality comparisons. If `fromIndex` is negative, it's used as the
  37497. * offset from the end of `array`.
  37498. *
  37499. * @static
  37500. * @memberOf _
  37501. * @since 0.1.0
  37502. * @category Array
  37503. * @param {Array} array The array to inspect.
  37504. * @param {*} value The value to search for.
  37505. * @param {number} [fromIndex=0] The index to search from.
  37506. * @returns {number} Returns the index of the matched value, else `-1`.
  37507. * @example
  37508. *
  37509. * _.indexOf([1, 2, 1, 2], 2);
  37510. * // => 1
  37511. *
  37512. * // Search from the `fromIndex`.
  37513. * _.indexOf([1, 2, 1, 2], 2, 2);
  37514. * // => 3
  37515. */function indexOf(array,value,fromIndex){var length=array==null?0:array.length;if(!length){return-1;}var index=fromIndex==null?0:toInteger(fromIndex);if(index<0){index=nativeMax(length+index,0);}return baseIndexOf(array,value,index);}/**
  37516. * Gets all but the last element of `array`.
  37517. *
  37518. * @static
  37519. * @memberOf _
  37520. * @since 0.1.0
  37521. * @category Array
  37522. * @param {Array} array The array to query.
  37523. * @returns {Array} Returns the slice of `array`.
  37524. * @example
  37525. *
  37526. * _.initial([1, 2, 3]);
  37527. * // => [1, 2]
  37528. */function initial(array){var length=array==null?0:array.length;return length?baseSlice(array,0,-1):[];}/**
  37529. * Creates an array of unique values that are included in all given arrays
  37530. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  37531. * for equality comparisons. The order and references of result values are
  37532. * determined by the first array.
  37533. *
  37534. * @static
  37535. * @memberOf _
  37536. * @since 0.1.0
  37537. * @category Array
  37538. * @param {...Array} [arrays] The arrays to inspect.
  37539. * @returns {Array} Returns the new array of intersecting values.
  37540. * @example
  37541. *
  37542. * _.intersection([2, 1], [2, 3]);
  37543. * // => [2]
  37544. */var intersection=baseRest(function(arrays){var mapped=arrayMap(arrays,castArrayLikeObject);return mapped.length&&mapped[0]===arrays[0]?baseIntersection(mapped):[];});/**
  37545. * This method is like `_.intersection` except that it accepts `iteratee`
  37546. * which is invoked for each element of each `arrays` to generate the criterion
  37547. * by which they're compared. The order and references of result values are
  37548. * determined by the first array. The iteratee is invoked with one argument:
  37549. * (value).
  37550. *
  37551. * @static
  37552. * @memberOf _
  37553. * @since 4.0.0
  37554. * @category Array
  37555. * @param {...Array} [arrays] The arrays to inspect.
  37556. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  37557. * @returns {Array} Returns the new array of intersecting values.
  37558. * @example
  37559. *
  37560. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  37561. * // => [2.1]
  37562. *
  37563. * // The `_.property` iteratee shorthand.
  37564. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  37565. * // => [{ 'x': 1 }]
  37566. */var intersectionBy=baseRest(function(arrays){var iteratee=last(arrays),mapped=arrayMap(arrays,castArrayLikeObject);if(iteratee===last(mapped)){iteratee=undefined;}else{mapped.pop();}return mapped.length&&mapped[0]===arrays[0]?baseIntersection(mapped,getIteratee(iteratee,2)):[];});/**
  37567. * This method is like `_.intersection` except that it accepts `comparator`
  37568. * which is invoked to compare elements of `arrays`. The order and references
  37569. * of result values are determined by the first array. The comparator is
  37570. * invoked with two arguments: (arrVal, othVal).
  37571. *
  37572. * @static
  37573. * @memberOf _
  37574. * @since 4.0.0
  37575. * @category Array
  37576. * @param {...Array} [arrays] The arrays to inspect.
  37577. * @param {Function} [comparator] The comparator invoked per element.
  37578. * @returns {Array} Returns the new array of intersecting values.
  37579. * @example
  37580. *
  37581. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  37582. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  37583. *
  37584. * _.intersectionWith(objects, others, _.isEqual);
  37585. * // => [{ 'x': 1, 'y': 2 }]
  37586. */var intersectionWith=baseRest(function(arrays){var comparator=last(arrays),mapped=arrayMap(arrays,castArrayLikeObject);comparator=typeof comparator=='function'?comparator:undefined;if(comparator){mapped.pop();}return mapped.length&&mapped[0]===arrays[0]?baseIntersection(mapped,undefined,comparator):[];});/**
  37587. * Converts all elements in `array` into a string separated by `separator`.
  37588. *
  37589. * @static
  37590. * @memberOf _
  37591. * @since 4.0.0
  37592. * @category Array
  37593. * @param {Array} array The array to convert.
  37594. * @param {string} [separator=','] The element separator.
  37595. * @returns {string} Returns the joined string.
  37596. * @example
  37597. *
  37598. * _.join(['a', 'b', 'c'], '~');
  37599. * // => 'a~b~c'
  37600. */function join(array,separator){return array==null?'':nativeJoin.call(array,separator);}/**
  37601. * Gets the last element of `array`.
  37602. *
  37603. * @static
  37604. * @memberOf _
  37605. * @since 0.1.0
  37606. * @category Array
  37607. * @param {Array} array The array to query.
  37608. * @returns {*} Returns the last element of `array`.
  37609. * @example
  37610. *
  37611. * _.last([1, 2, 3]);
  37612. * // => 3
  37613. */function last(array){var length=array==null?0:array.length;return length?array[length-1]:undefined;}/**
  37614. * This method is like `_.indexOf` except that it iterates over elements of
  37615. * `array` from right to left.
  37616. *
  37617. * @static
  37618. * @memberOf _
  37619. * @since 0.1.0
  37620. * @category Array
  37621. * @param {Array} array The array to inspect.
  37622. * @param {*} value The value to search for.
  37623. * @param {number} [fromIndex=array.length-1] The index to search from.
  37624. * @returns {number} Returns the index of the matched value, else `-1`.
  37625. * @example
  37626. *
  37627. * _.lastIndexOf([1, 2, 1, 2], 2);
  37628. * // => 3
  37629. *
  37630. * // Search from the `fromIndex`.
  37631. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  37632. * // => 1
  37633. */function lastIndexOf(array,value,fromIndex){var length=array==null?0:array.length;if(!length){return-1;}var index=length;if(fromIndex!==undefined){index=toInteger(fromIndex);index=index<0?nativeMax(length+index,0):nativeMin(index,length-1);}return value===value?strictLastIndexOf(array,value,index):baseFindIndex(array,baseIsNaN,index,true);}/**
  37634. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  37635. * element from the end is returned.
  37636. *
  37637. * @static
  37638. * @memberOf _
  37639. * @since 4.11.0
  37640. * @category Array
  37641. * @param {Array} array The array to query.
  37642. * @param {number} [n=0] The index of the element to return.
  37643. * @returns {*} Returns the nth element of `array`.
  37644. * @example
  37645. *
  37646. * var array = ['a', 'b', 'c', 'd'];
  37647. *
  37648. * _.nth(array, 1);
  37649. * // => 'b'
  37650. *
  37651. * _.nth(array, -2);
  37652. * // => 'c';
  37653. */function nth(array,n){return array&&array.length?baseNth(array,toInteger(n)):undefined;}/**
  37654. * Removes all given values from `array` using
  37655. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  37656. * for equality comparisons.
  37657. *
  37658. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  37659. * to remove elements from an array by predicate.
  37660. *
  37661. * @static
  37662. * @memberOf _
  37663. * @since 2.0.0
  37664. * @category Array
  37665. * @param {Array} array The array to modify.
  37666. * @param {...*} [values] The values to remove.
  37667. * @returns {Array} Returns `array`.
  37668. * @example
  37669. *
  37670. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  37671. *
  37672. * _.pull(array, 'a', 'c');
  37673. * console.log(array);
  37674. * // => ['b', 'b']
  37675. */var pull=baseRest(pullAll);/**
  37676. * This method is like `_.pull` except that it accepts an array of values to remove.
  37677. *
  37678. * **Note:** Unlike `_.difference`, this method mutates `array`.
  37679. *
  37680. * @static
  37681. * @memberOf _
  37682. * @since 4.0.0
  37683. * @category Array
  37684. * @param {Array} array The array to modify.
  37685. * @param {Array} values The values to remove.
  37686. * @returns {Array} Returns `array`.
  37687. * @example
  37688. *
  37689. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  37690. *
  37691. * _.pullAll(array, ['a', 'c']);
  37692. * console.log(array);
  37693. * // => ['b', 'b']
  37694. */function pullAll(array,values){return array&&array.length&&values&&values.length?basePullAll(array,values):array;}/**
  37695. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  37696. * invoked for each element of `array` and `values` to generate the criterion
  37697. * by which they're compared. The iteratee is invoked with one argument: (value).
  37698. *
  37699. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  37700. *
  37701. * @static
  37702. * @memberOf _
  37703. * @since 4.0.0
  37704. * @category Array
  37705. * @param {Array} array The array to modify.
  37706. * @param {Array} values The values to remove.
  37707. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  37708. * @returns {Array} Returns `array`.
  37709. * @example
  37710. *
  37711. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  37712. *
  37713. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  37714. * console.log(array);
  37715. * // => [{ 'x': 2 }]
  37716. */function pullAllBy(array,values,iteratee){return array&&array.length&&values&&values.length?basePullAll(array,values,getIteratee(iteratee,2)):array;}/**
  37717. * This method is like `_.pullAll` except that it accepts `comparator` which
  37718. * is invoked to compare elements of `array` to `values`. The comparator is
  37719. * invoked with two arguments: (arrVal, othVal).
  37720. *
  37721. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  37722. *
  37723. * @static
  37724. * @memberOf _
  37725. * @since 4.6.0
  37726. * @category Array
  37727. * @param {Array} array The array to modify.
  37728. * @param {Array} values The values to remove.
  37729. * @param {Function} [comparator] The comparator invoked per element.
  37730. * @returns {Array} Returns `array`.
  37731. * @example
  37732. *
  37733. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  37734. *
  37735. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  37736. * console.log(array);
  37737. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  37738. */function pullAllWith(array,values,comparator){return array&&array.length&&values&&values.length?basePullAll(array,values,undefined,comparator):array;}/**
  37739. * Removes elements from `array` corresponding to `indexes` and returns an
  37740. * array of removed elements.
  37741. *
  37742. * **Note:** Unlike `_.at`, this method mutates `array`.
  37743. *
  37744. * @static
  37745. * @memberOf _
  37746. * @since 3.0.0
  37747. * @category Array
  37748. * @param {Array} array The array to modify.
  37749. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  37750. * @returns {Array} Returns the new array of removed elements.
  37751. * @example
  37752. *
  37753. * var array = ['a', 'b', 'c', 'd'];
  37754. * var pulled = _.pullAt(array, [1, 3]);
  37755. *
  37756. * console.log(array);
  37757. * // => ['a', 'c']
  37758. *
  37759. * console.log(pulled);
  37760. * // => ['b', 'd']
  37761. */var pullAt=flatRest(function(array,indexes){var length=array==null?0:array.length,result=baseAt(array,indexes);basePullAt(array,arrayMap(indexes,function(index){return isIndex(index,length)?+index:index;}).sort(compareAscending));return result;});/**
  37762. * Removes all elements from `array` that `predicate` returns truthy for
  37763. * and returns an array of the removed elements. The predicate is invoked
  37764. * with three arguments: (value, index, array).
  37765. *
  37766. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  37767. * to pull elements from an array by value.
  37768. *
  37769. * @static
  37770. * @memberOf _
  37771. * @since 2.0.0
  37772. * @category Array
  37773. * @param {Array} array The array to modify.
  37774. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  37775. * @returns {Array} Returns the new array of removed elements.
  37776. * @example
  37777. *
  37778. * var array = [1, 2, 3, 4];
  37779. * var evens = _.remove(array, function(n) {
  37780. * return n % 2 == 0;
  37781. * });
  37782. *
  37783. * console.log(array);
  37784. * // => [1, 3]
  37785. *
  37786. * console.log(evens);
  37787. * // => [2, 4]
  37788. */function remove(array,predicate){var result=[];if(!(array&&array.length)){return result;}var index=-1,indexes=[],length=array.length;predicate=getIteratee(predicate,3);while(++index<length){var value=array[index];if(predicate(value,index,array)){result.push(value);indexes.push(index);}}basePullAt(array,indexes);return result;}/**
  37789. * Reverses `array` so that the first element becomes the last, the second
  37790. * element becomes the second to last, and so on.
  37791. *
  37792. * **Note:** This method mutates `array` and is based on
  37793. * [`Array#reverse`](https://mdn.io/Array/reverse).
  37794. *
  37795. * @static
  37796. * @memberOf _
  37797. * @since 4.0.0
  37798. * @category Array
  37799. * @param {Array} array The array to modify.
  37800. * @returns {Array} Returns `array`.
  37801. * @example
  37802. *
  37803. * var array = [1, 2, 3];
  37804. *
  37805. * _.reverse(array);
  37806. * // => [3, 2, 1]
  37807. *
  37808. * console.log(array);
  37809. * // => [3, 2, 1]
  37810. */function reverse(array){return array==null?array:nativeReverse.call(array);}/**
  37811. * Creates a slice of `array` from `start` up to, but not including, `end`.
  37812. *
  37813. * **Note:** This method is used instead of
  37814. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  37815. * returned.
  37816. *
  37817. * @static
  37818. * @memberOf _
  37819. * @since 3.0.0
  37820. * @category Array
  37821. * @param {Array} array The array to slice.
  37822. * @param {number} [start=0] The start position.
  37823. * @param {number} [end=array.length] The end position.
  37824. * @returns {Array} Returns the slice of `array`.
  37825. */function slice(array,start,end){var length=array==null?0:array.length;if(!length){return[];}if(end&&typeof end!='number'&&isIterateeCall(array,start,end)){start=0;end=length;}else{start=start==null?0:toInteger(start);end=end===undefined?length:toInteger(end);}return baseSlice(array,start,end);}/**
  37826. * Uses a binary search to determine the lowest index at which `value`
  37827. * should be inserted into `array` in order to maintain its sort order.
  37828. *
  37829. * @static
  37830. * @memberOf _
  37831. * @since 0.1.0
  37832. * @category Array
  37833. * @param {Array} array The sorted array to inspect.
  37834. * @param {*} value The value to evaluate.
  37835. * @returns {number} Returns the index at which `value` should be inserted
  37836. * into `array`.
  37837. * @example
  37838. *
  37839. * _.sortedIndex([30, 50], 40);
  37840. * // => 1
  37841. */function sortedIndex(array,value){return baseSortedIndex(array,value);}/**
  37842. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  37843. * which is invoked for `value` and each element of `array` to compute their
  37844. * sort ranking. The iteratee is invoked with one argument: (value).
  37845. *
  37846. * @static
  37847. * @memberOf _
  37848. * @since 4.0.0
  37849. * @category Array
  37850. * @param {Array} array The sorted array to inspect.
  37851. * @param {*} value The value to evaluate.
  37852. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  37853. * @returns {number} Returns the index at which `value` should be inserted
  37854. * into `array`.
  37855. * @example
  37856. *
  37857. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  37858. *
  37859. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  37860. * // => 0
  37861. *
  37862. * // The `_.property` iteratee shorthand.
  37863. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  37864. * // => 0
  37865. */function sortedIndexBy(array,value,iteratee){return baseSortedIndexBy(array,value,getIteratee(iteratee,2));}/**
  37866. * This method is like `_.indexOf` except that it performs a binary
  37867. * search on a sorted `array`.
  37868. *
  37869. * @static
  37870. * @memberOf _
  37871. * @since 4.0.0
  37872. * @category Array
  37873. * @param {Array} array The array to inspect.
  37874. * @param {*} value The value to search for.
  37875. * @returns {number} Returns the index of the matched value, else `-1`.
  37876. * @example
  37877. *
  37878. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  37879. * // => 1
  37880. */function sortedIndexOf(array,value){var length=array==null?0:array.length;if(length){var index=baseSortedIndex(array,value);if(index<length&&eq(array[index],value)){return index;}}return-1;}/**
  37881. * This method is like `_.sortedIndex` except that it returns the highest
  37882. * index at which `value` should be inserted into `array` in order to
  37883. * maintain its sort order.
  37884. *
  37885. * @static
  37886. * @memberOf _
  37887. * @since 3.0.0
  37888. * @category Array
  37889. * @param {Array} array The sorted array to inspect.
  37890. * @param {*} value The value to evaluate.
  37891. * @returns {number} Returns the index at which `value` should be inserted
  37892. * into `array`.
  37893. * @example
  37894. *
  37895. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  37896. * // => 4
  37897. */function sortedLastIndex(array,value){return baseSortedIndex(array,value,true);}/**
  37898. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  37899. * which is invoked for `value` and each element of `array` to compute their
  37900. * sort ranking. The iteratee is invoked with one argument: (value).
  37901. *
  37902. * @static
  37903. * @memberOf _
  37904. * @since 4.0.0
  37905. * @category Array
  37906. * @param {Array} array The sorted array to inspect.
  37907. * @param {*} value The value to evaluate.
  37908. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  37909. * @returns {number} Returns the index at which `value` should be inserted
  37910. * into `array`.
  37911. * @example
  37912. *
  37913. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  37914. *
  37915. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  37916. * // => 1
  37917. *
  37918. * // The `_.property` iteratee shorthand.
  37919. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  37920. * // => 1
  37921. */function sortedLastIndexBy(array,value,iteratee){return baseSortedIndexBy(array,value,getIteratee(iteratee,2),true);}/**
  37922. * This method is like `_.lastIndexOf` except that it performs a binary
  37923. * search on a sorted `array`.
  37924. *
  37925. * @static
  37926. * @memberOf _
  37927. * @since 4.0.0
  37928. * @category Array
  37929. * @param {Array} array The array to inspect.
  37930. * @param {*} value The value to search for.
  37931. * @returns {number} Returns the index of the matched value, else `-1`.
  37932. * @example
  37933. *
  37934. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  37935. * // => 3
  37936. */function sortedLastIndexOf(array,value){var length=array==null?0:array.length;if(length){var index=baseSortedIndex(array,value,true)-1;if(eq(array[index],value)){return index;}}return-1;}/**
  37937. * This method is like `_.uniq` except that it's designed and optimized
  37938. * for sorted arrays.
  37939. *
  37940. * @static
  37941. * @memberOf _
  37942. * @since 4.0.0
  37943. * @category Array
  37944. * @param {Array} array The array to inspect.
  37945. * @returns {Array} Returns the new duplicate free array.
  37946. * @example
  37947. *
  37948. * _.sortedUniq([1, 1, 2]);
  37949. * // => [1, 2]
  37950. */function sortedUniq(array){return array&&array.length?baseSortedUniq(array):[];}/**
  37951. * This method is like `_.uniqBy` except that it's designed and optimized
  37952. * for sorted arrays.
  37953. *
  37954. * @static
  37955. * @memberOf _
  37956. * @since 4.0.0
  37957. * @category Array
  37958. * @param {Array} array The array to inspect.
  37959. * @param {Function} [iteratee] The iteratee invoked per element.
  37960. * @returns {Array} Returns the new duplicate free array.
  37961. * @example
  37962. *
  37963. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  37964. * // => [1.1, 2.3]
  37965. */function sortedUniqBy(array,iteratee){return array&&array.length?baseSortedUniq(array,getIteratee(iteratee,2)):[];}/**
  37966. * Gets all but the first element of `array`.
  37967. *
  37968. * @static
  37969. * @memberOf _
  37970. * @since 4.0.0
  37971. * @category Array
  37972. * @param {Array} array The array to query.
  37973. * @returns {Array} Returns the slice of `array`.
  37974. * @example
  37975. *
  37976. * _.tail([1, 2, 3]);
  37977. * // => [2, 3]
  37978. */function tail(array){var length=array==null?0:array.length;return length?baseSlice(array,1,length):[];}/**
  37979. * Creates a slice of `array` with `n` elements taken from the beginning.
  37980. *
  37981. * @static
  37982. * @memberOf _
  37983. * @since 0.1.0
  37984. * @category Array
  37985. * @param {Array} array The array to query.
  37986. * @param {number} [n=1] The number of elements to take.
  37987. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  37988. * @returns {Array} Returns the slice of `array`.
  37989. * @example
  37990. *
  37991. * _.take([1, 2, 3]);
  37992. * // => [1]
  37993. *
  37994. * _.take([1, 2, 3], 2);
  37995. * // => [1, 2]
  37996. *
  37997. * _.take([1, 2, 3], 5);
  37998. * // => [1, 2, 3]
  37999. *
  38000. * _.take([1, 2, 3], 0);
  38001. * // => []
  38002. */function take(array,n,guard){if(!(array&&array.length)){return[];}n=guard||n===undefined?1:toInteger(n);return baseSlice(array,0,n<0?0:n);}/**
  38003. * Creates a slice of `array` with `n` elements taken from the end.
  38004. *
  38005. * @static
  38006. * @memberOf _
  38007. * @since 3.0.0
  38008. * @category Array
  38009. * @param {Array} array The array to query.
  38010. * @param {number} [n=1] The number of elements to take.
  38011. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  38012. * @returns {Array} Returns the slice of `array`.
  38013. * @example
  38014. *
  38015. * _.takeRight([1, 2, 3]);
  38016. * // => [3]
  38017. *
  38018. * _.takeRight([1, 2, 3], 2);
  38019. * // => [2, 3]
  38020. *
  38021. * _.takeRight([1, 2, 3], 5);
  38022. * // => [1, 2, 3]
  38023. *
  38024. * _.takeRight([1, 2, 3], 0);
  38025. * // => []
  38026. */function takeRight(array,n,guard){var length=array==null?0:array.length;if(!length){return[];}n=guard||n===undefined?1:toInteger(n);n=length-n;return baseSlice(array,n<0?0:n,length);}/**
  38027. * Creates a slice of `array` with elements taken from the end. Elements are
  38028. * taken until `predicate` returns falsey. The predicate is invoked with
  38029. * three arguments: (value, index, array).
  38030. *
  38031. * @static
  38032. * @memberOf _
  38033. * @since 3.0.0
  38034. * @category Array
  38035. * @param {Array} array The array to query.
  38036. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  38037. * @returns {Array} Returns the slice of `array`.
  38038. * @example
  38039. *
  38040. * var users = [
  38041. * { 'user': 'barney', 'active': true },
  38042. * { 'user': 'fred', 'active': false },
  38043. * { 'user': 'pebbles', 'active': false }
  38044. * ];
  38045. *
  38046. * _.takeRightWhile(users, function(o) { return !o.active; });
  38047. * // => objects for ['fred', 'pebbles']
  38048. *
  38049. * // The `_.matches` iteratee shorthand.
  38050. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  38051. * // => objects for ['pebbles']
  38052. *
  38053. * // The `_.matchesProperty` iteratee shorthand.
  38054. * _.takeRightWhile(users, ['active', false]);
  38055. * // => objects for ['fred', 'pebbles']
  38056. *
  38057. * // The `_.property` iteratee shorthand.
  38058. * _.takeRightWhile(users, 'active');
  38059. * // => []
  38060. */function takeRightWhile(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3),false,true):[];}/**
  38061. * Creates a slice of `array` with elements taken from the beginning. Elements
  38062. * are taken until `predicate` returns falsey. The predicate is invoked with
  38063. * three arguments: (value, index, array).
  38064. *
  38065. * @static
  38066. * @memberOf _
  38067. * @since 3.0.0
  38068. * @category Array
  38069. * @param {Array} array The array to query.
  38070. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  38071. * @returns {Array} Returns the slice of `array`.
  38072. * @example
  38073. *
  38074. * var users = [
  38075. * { 'user': 'barney', 'active': false },
  38076. * { 'user': 'fred', 'active': false },
  38077. * { 'user': 'pebbles', 'active': true }
  38078. * ];
  38079. *
  38080. * _.takeWhile(users, function(o) { return !o.active; });
  38081. * // => objects for ['barney', 'fred']
  38082. *
  38083. * // The `_.matches` iteratee shorthand.
  38084. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  38085. * // => objects for ['barney']
  38086. *
  38087. * // The `_.matchesProperty` iteratee shorthand.
  38088. * _.takeWhile(users, ['active', false]);
  38089. * // => objects for ['barney', 'fred']
  38090. *
  38091. * // The `_.property` iteratee shorthand.
  38092. * _.takeWhile(users, 'active');
  38093. * // => []
  38094. */function takeWhile(array,predicate){return array&&array.length?baseWhile(array,getIteratee(predicate,3)):[];}/**
  38095. * Creates an array of unique values, in order, from all given arrays using
  38096. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  38097. * for equality comparisons.
  38098. *
  38099. * @static
  38100. * @memberOf _
  38101. * @since 0.1.0
  38102. * @category Array
  38103. * @param {...Array} [arrays] The arrays to inspect.
  38104. * @returns {Array} Returns the new array of combined values.
  38105. * @example
  38106. *
  38107. * _.union([2], [1, 2]);
  38108. * // => [2, 1]
  38109. */var union=baseRest(function(arrays){return baseUniq(baseFlatten(arrays,1,isArrayLikeObject,true));});/**
  38110. * This method is like `_.union` except that it accepts `iteratee` which is
  38111. * invoked for each element of each `arrays` to generate the criterion by
  38112. * which uniqueness is computed. Result values are chosen from the first
  38113. * array in which the value occurs. The iteratee is invoked with one argument:
  38114. * (value).
  38115. *
  38116. * @static
  38117. * @memberOf _
  38118. * @since 4.0.0
  38119. * @category Array
  38120. * @param {...Array} [arrays] The arrays to inspect.
  38121. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  38122. * @returns {Array} Returns the new array of combined values.
  38123. * @example
  38124. *
  38125. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  38126. * // => [2.1, 1.2]
  38127. *
  38128. * // The `_.property` iteratee shorthand.
  38129. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  38130. * // => [{ 'x': 1 }, { 'x': 2 }]
  38131. */var unionBy=baseRest(function(arrays){var iteratee=last(arrays);if(isArrayLikeObject(iteratee)){iteratee=undefined;}return baseUniq(baseFlatten(arrays,1,isArrayLikeObject,true),getIteratee(iteratee,2));});/**
  38132. * This method is like `_.union` except that it accepts `comparator` which
  38133. * is invoked to compare elements of `arrays`. Result values are chosen from
  38134. * the first array in which the value occurs. The comparator is invoked
  38135. * with two arguments: (arrVal, othVal).
  38136. *
  38137. * @static
  38138. * @memberOf _
  38139. * @since 4.0.0
  38140. * @category Array
  38141. * @param {...Array} [arrays] The arrays to inspect.
  38142. * @param {Function} [comparator] The comparator invoked per element.
  38143. * @returns {Array} Returns the new array of combined values.
  38144. * @example
  38145. *
  38146. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  38147. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  38148. *
  38149. * _.unionWith(objects, others, _.isEqual);
  38150. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  38151. */var unionWith=baseRest(function(arrays){var comparator=last(arrays);comparator=typeof comparator=='function'?comparator:undefined;return baseUniq(baseFlatten(arrays,1,isArrayLikeObject,true),undefined,comparator);});/**
  38152. * Creates a duplicate-free version of an array, using
  38153. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  38154. * for equality comparisons, in which only the first occurrence of each element
  38155. * is kept. The order of result values is determined by the order they occur
  38156. * in the array.
  38157. *
  38158. * @static
  38159. * @memberOf _
  38160. * @since 0.1.0
  38161. * @category Array
  38162. * @param {Array} array The array to inspect.
  38163. * @returns {Array} Returns the new duplicate free array.
  38164. * @example
  38165. *
  38166. * _.uniq([2, 1, 2]);
  38167. * // => [2, 1]
  38168. */function uniq(array){return array&&array.length?baseUniq(array):[];}/**
  38169. * This method is like `_.uniq` except that it accepts `iteratee` which is
  38170. * invoked for each element in `array` to generate the criterion by which
  38171. * uniqueness is computed. The order of result values is determined by the
  38172. * order they occur in the array. The iteratee is invoked with one argument:
  38173. * (value).
  38174. *
  38175. * @static
  38176. * @memberOf _
  38177. * @since 4.0.0
  38178. * @category Array
  38179. * @param {Array} array The array to inspect.
  38180. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  38181. * @returns {Array} Returns the new duplicate free array.
  38182. * @example
  38183. *
  38184. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  38185. * // => [2.1, 1.2]
  38186. *
  38187. * // The `_.property` iteratee shorthand.
  38188. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  38189. * // => [{ 'x': 1 }, { 'x': 2 }]
  38190. */function uniqBy(array,iteratee){return array&&array.length?baseUniq(array,getIteratee(iteratee,2)):[];}/**
  38191. * This method is like `_.uniq` except that it accepts `comparator` which
  38192. * is invoked to compare elements of `array`. The order of result values is
  38193. * determined by the order they occur in the array.The comparator is invoked
  38194. * with two arguments: (arrVal, othVal).
  38195. *
  38196. * @static
  38197. * @memberOf _
  38198. * @since 4.0.0
  38199. * @category Array
  38200. * @param {Array} array The array to inspect.
  38201. * @param {Function} [comparator] The comparator invoked per element.
  38202. * @returns {Array} Returns the new duplicate free array.
  38203. * @example
  38204. *
  38205. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  38206. *
  38207. * _.uniqWith(objects, _.isEqual);
  38208. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  38209. */function uniqWith(array,comparator){comparator=typeof comparator=='function'?comparator:undefined;return array&&array.length?baseUniq(array,undefined,comparator):[];}/**
  38210. * This method is like `_.zip` except that it accepts an array of grouped
  38211. * elements and creates an array regrouping the elements to their pre-zip
  38212. * configuration.
  38213. *
  38214. * @static
  38215. * @memberOf _
  38216. * @since 1.2.0
  38217. * @category Array
  38218. * @param {Array} array The array of grouped elements to process.
  38219. * @returns {Array} Returns the new array of regrouped elements.
  38220. * @example
  38221. *
  38222. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  38223. * // => [['a', 1, true], ['b', 2, false]]
  38224. *
  38225. * _.unzip(zipped);
  38226. * // => [['a', 'b'], [1, 2], [true, false]]
  38227. */function unzip(array){if(!(array&&array.length)){return[];}var length=0;array=arrayFilter(array,function(group){if(isArrayLikeObject(group)){length=nativeMax(group.length,length);return true;}});return baseTimes(length,function(index){return arrayMap(array,baseProperty(index));});}/**
  38228. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  38229. * how regrouped values should be combined. The iteratee is invoked with the
  38230. * elements of each group: (...group).
  38231. *
  38232. * @static
  38233. * @memberOf _
  38234. * @since 3.8.0
  38235. * @category Array
  38236. * @param {Array} array The array of grouped elements to process.
  38237. * @param {Function} [iteratee=_.identity] The function to combine
  38238. * regrouped values.
  38239. * @returns {Array} Returns the new array of regrouped elements.
  38240. * @example
  38241. *
  38242. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  38243. * // => [[1, 10, 100], [2, 20, 200]]
  38244. *
  38245. * _.unzipWith(zipped, _.add);
  38246. * // => [3, 30, 300]
  38247. */function unzipWith(array,iteratee){if(!(array&&array.length)){return[];}var result=unzip(array);if(iteratee==null){return result;}return arrayMap(result,function(group){return apply(iteratee,undefined,group);});}/**
  38248. * Creates an array excluding all given values using
  38249. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  38250. * for equality comparisons.
  38251. *
  38252. * **Note:** Unlike `_.pull`, this method returns a new array.
  38253. *
  38254. * @static
  38255. * @memberOf _
  38256. * @since 0.1.0
  38257. * @category Array
  38258. * @param {Array} array The array to inspect.
  38259. * @param {...*} [values] The values to exclude.
  38260. * @returns {Array} Returns the new array of filtered values.
  38261. * @see _.difference, _.xor
  38262. * @example
  38263. *
  38264. * _.without([2, 1, 2, 3], 1, 2);
  38265. * // => [3]
  38266. */var without=baseRest(function(array,values){return isArrayLikeObject(array)?baseDifference(array,values):[];});/**
  38267. * Creates an array of unique values that is the
  38268. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  38269. * of the given arrays. The order of result values is determined by the order
  38270. * they occur in the arrays.
  38271. *
  38272. * @static
  38273. * @memberOf _
  38274. * @since 2.4.0
  38275. * @category Array
  38276. * @param {...Array} [arrays] The arrays to inspect.
  38277. * @returns {Array} Returns the new array of filtered values.
  38278. * @see _.difference, _.without
  38279. * @example
  38280. *
  38281. * _.xor([2, 1], [2, 3]);
  38282. * // => [1, 3]
  38283. */var xor=baseRest(function(arrays){return baseXor(arrayFilter(arrays,isArrayLikeObject));});/**
  38284. * This method is like `_.xor` except that it accepts `iteratee` which is
  38285. * invoked for each element of each `arrays` to generate the criterion by
  38286. * which by which they're compared. The order of result values is determined
  38287. * by the order they occur in the arrays. The iteratee is invoked with one
  38288. * argument: (value).
  38289. *
  38290. * @static
  38291. * @memberOf _
  38292. * @since 4.0.0
  38293. * @category Array
  38294. * @param {...Array} [arrays] The arrays to inspect.
  38295. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  38296. * @returns {Array} Returns the new array of filtered values.
  38297. * @example
  38298. *
  38299. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  38300. * // => [1.2, 3.4]
  38301. *
  38302. * // The `_.property` iteratee shorthand.
  38303. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  38304. * // => [{ 'x': 2 }]
  38305. */var xorBy=baseRest(function(arrays){var iteratee=last(arrays);if(isArrayLikeObject(iteratee)){iteratee=undefined;}return baseXor(arrayFilter(arrays,isArrayLikeObject),getIteratee(iteratee,2));});/**
  38306. * This method is like `_.xor` except that it accepts `comparator` which is
  38307. * invoked to compare elements of `arrays`. The order of result values is
  38308. * determined by the order they occur in the arrays. The comparator is invoked
  38309. * with two arguments: (arrVal, othVal).
  38310. *
  38311. * @static
  38312. * @memberOf _
  38313. * @since 4.0.0
  38314. * @category Array
  38315. * @param {...Array} [arrays] The arrays to inspect.
  38316. * @param {Function} [comparator] The comparator invoked per element.
  38317. * @returns {Array} Returns the new array of filtered values.
  38318. * @example
  38319. *
  38320. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  38321. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  38322. *
  38323. * _.xorWith(objects, others, _.isEqual);
  38324. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  38325. */var xorWith=baseRest(function(arrays){var comparator=last(arrays);comparator=typeof comparator=='function'?comparator:undefined;return baseXor(arrayFilter(arrays,isArrayLikeObject),undefined,comparator);});/**
  38326. * Creates an array of grouped elements, the first of which contains the
  38327. * first elements of the given arrays, the second of which contains the
  38328. * second elements of the given arrays, and so on.
  38329. *
  38330. * @static
  38331. * @memberOf _
  38332. * @since 0.1.0
  38333. * @category Array
  38334. * @param {...Array} [arrays] The arrays to process.
  38335. * @returns {Array} Returns the new array of grouped elements.
  38336. * @example
  38337. *
  38338. * _.zip(['a', 'b'], [1, 2], [true, false]);
  38339. * // => [['a', 1, true], ['b', 2, false]]
  38340. */var zip=baseRest(unzip);/**
  38341. * This method is like `_.fromPairs` except that it accepts two arrays,
  38342. * one of property identifiers and one of corresponding values.
  38343. *
  38344. * @static
  38345. * @memberOf _
  38346. * @since 0.4.0
  38347. * @category Array
  38348. * @param {Array} [props=[]] The property identifiers.
  38349. * @param {Array} [values=[]] The property values.
  38350. * @returns {Object} Returns the new object.
  38351. * @example
  38352. *
  38353. * _.zipObject(['a', 'b'], [1, 2]);
  38354. * // => { 'a': 1, 'b': 2 }
  38355. */function zipObject(props,values){return baseZipObject(props||[],values||[],assignValue);}/**
  38356. * This method is like `_.zipObject` except that it supports property paths.
  38357. *
  38358. * @static
  38359. * @memberOf _
  38360. * @since 4.1.0
  38361. * @category Array
  38362. * @param {Array} [props=[]] The property identifiers.
  38363. * @param {Array} [values=[]] The property values.
  38364. * @returns {Object} Returns the new object.
  38365. * @example
  38366. *
  38367. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  38368. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  38369. */function zipObjectDeep(props,values){return baseZipObject(props||[],values||[],baseSet);}/**
  38370. * This method is like `_.zip` except that it accepts `iteratee` to specify
  38371. * how grouped values should be combined. The iteratee is invoked with the
  38372. * elements of each group: (...group).
  38373. *
  38374. * @static
  38375. * @memberOf _
  38376. * @since 3.8.0
  38377. * @category Array
  38378. * @param {...Array} [arrays] The arrays to process.
  38379. * @param {Function} [iteratee=_.identity] The function to combine
  38380. * grouped values.
  38381. * @returns {Array} Returns the new array of grouped elements.
  38382. * @example
  38383. *
  38384. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  38385. * return a + b + c;
  38386. * });
  38387. * // => [111, 222]
  38388. */var zipWith=baseRest(function(arrays){var length=arrays.length,iteratee=length>1?arrays[length-1]:undefined;iteratee=typeof iteratee=='function'?(arrays.pop(),iteratee):undefined;return unzipWith(arrays,iteratee);});/*------------------------------------------------------------------------*//**
  38389. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  38390. * chain sequences enabled. The result of such sequences must be unwrapped
  38391. * with `_#value`.
  38392. *
  38393. * @static
  38394. * @memberOf _
  38395. * @since 1.3.0
  38396. * @category Seq
  38397. * @param {*} value The value to wrap.
  38398. * @returns {Object} Returns the new `lodash` wrapper instance.
  38399. * @example
  38400. *
  38401. * var users = [
  38402. * { 'user': 'barney', 'age': 36 },
  38403. * { 'user': 'fred', 'age': 40 },
  38404. * { 'user': 'pebbles', 'age': 1 }
  38405. * ];
  38406. *
  38407. * var youngest = _
  38408. * .chain(users)
  38409. * .sortBy('age')
  38410. * .map(function(o) {
  38411. * return o.user + ' is ' + o.age;
  38412. * })
  38413. * .head()
  38414. * .value();
  38415. * // => 'pebbles is 1'
  38416. */function chain(value){var result=lodash(value);result.__chain__=true;return result;}/**
  38417. * This method invokes `interceptor` and returns `value`. The interceptor
  38418. * is invoked with one argument; (value). The purpose of this method is to
  38419. * "tap into" a method chain sequence in order to modify intermediate results.
  38420. *
  38421. * @static
  38422. * @memberOf _
  38423. * @since 0.1.0
  38424. * @category Seq
  38425. * @param {*} value The value to provide to `interceptor`.
  38426. * @param {Function} interceptor The function to invoke.
  38427. * @returns {*} Returns `value`.
  38428. * @example
  38429. *
  38430. * _([1, 2, 3])
  38431. * .tap(function(array) {
  38432. * // Mutate input array.
  38433. * array.pop();
  38434. * })
  38435. * .reverse()
  38436. * .value();
  38437. * // => [2, 1]
  38438. */function tap(value,interceptor){interceptor(value);return value;}/**
  38439. * This method is like `_.tap` except that it returns the result of `interceptor`.
  38440. * The purpose of this method is to "pass thru" values replacing intermediate
  38441. * results in a method chain sequence.
  38442. *
  38443. * @static
  38444. * @memberOf _
  38445. * @since 3.0.0
  38446. * @category Seq
  38447. * @param {*} value The value to provide to `interceptor`.
  38448. * @param {Function} interceptor The function to invoke.
  38449. * @returns {*} Returns the result of `interceptor`.
  38450. * @example
  38451. *
  38452. * _(' abc ')
  38453. * .chain()
  38454. * .trim()
  38455. * .thru(function(value) {
  38456. * return [value];
  38457. * })
  38458. * .value();
  38459. * // => ['abc']
  38460. */function thru(value,interceptor){return interceptor(value);}/**
  38461. * This method is the wrapper version of `_.at`.
  38462. *
  38463. * @name at
  38464. * @memberOf _
  38465. * @since 1.0.0
  38466. * @category Seq
  38467. * @param {...(string|string[])} [paths] The property paths to pick.
  38468. * @returns {Object} Returns the new `lodash` wrapper instance.
  38469. * @example
  38470. *
  38471. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  38472. *
  38473. * _(object).at(['a[0].b.c', 'a[1]']).value();
  38474. * // => [3, 4]
  38475. */var wrapperAt=flatRest(function(paths){var length=paths.length,start=length?paths[0]:0,value=this.__wrapped__,interceptor=function interceptor(object){return baseAt(object,paths);};if(length>1||this.__actions__.length||!(value instanceof LazyWrapper)||!isIndex(start)){return this.thru(interceptor);}value=value.slice(start,+start+(length?1:0));value.__actions__.push({'func':thru,'args':[interceptor],'thisArg':undefined});return new LodashWrapper(value,this.__chain__).thru(function(array){if(length&&!array.length){array.push(undefined);}return array;});});/**
  38476. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  38477. *
  38478. * @name chain
  38479. * @memberOf _
  38480. * @since 0.1.0
  38481. * @category Seq
  38482. * @returns {Object} Returns the new `lodash` wrapper instance.
  38483. * @example
  38484. *
  38485. * var users = [
  38486. * { 'user': 'barney', 'age': 36 },
  38487. * { 'user': 'fred', 'age': 40 }
  38488. * ];
  38489. *
  38490. * // A sequence without explicit chaining.
  38491. * _(users).head();
  38492. * // => { 'user': 'barney', 'age': 36 }
  38493. *
  38494. * // A sequence with explicit chaining.
  38495. * _(users)
  38496. * .chain()
  38497. * .head()
  38498. * .pick('user')
  38499. * .value();
  38500. * // => { 'user': 'barney' }
  38501. */function wrapperChain(){return chain(this);}/**
  38502. * Executes the chain sequence and returns the wrapped result.
  38503. *
  38504. * @name commit
  38505. * @memberOf _
  38506. * @since 3.2.0
  38507. * @category Seq
  38508. * @returns {Object} Returns the new `lodash` wrapper instance.
  38509. * @example
  38510. *
  38511. * var array = [1, 2];
  38512. * var wrapped = _(array).push(3);
  38513. *
  38514. * console.log(array);
  38515. * // => [1, 2]
  38516. *
  38517. * wrapped = wrapped.commit();
  38518. * console.log(array);
  38519. * // => [1, 2, 3]
  38520. *
  38521. * wrapped.last();
  38522. * // => 3
  38523. *
  38524. * console.log(array);
  38525. * // => [1, 2, 3]
  38526. */function wrapperCommit(){return new LodashWrapper(this.value(),this.__chain__);}/**
  38527. * Gets the next value on a wrapped object following the
  38528. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  38529. *
  38530. * @name next
  38531. * @memberOf _
  38532. * @since 4.0.0
  38533. * @category Seq
  38534. * @returns {Object} Returns the next iterator value.
  38535. * @example
  38536. *
  38537. * var wrapped = _([1, 2]);
  38538. *
  38539. * wrapped.next();
  38540. * // => { 'done': false, 'value': 1 }
  38541. *
  38542. * wrapped.next();
  38543. * // => { 'done': false, 'value': 2 }
  38544. *
  38545. * wrapped.next();
  38546. * // => { 'done': true, 'value': undefined }
  38547. */function wrapperNext(){if(this.__values__===undefined){this.__values__=toArray(this.value());}var done=this.__index__>=this.__values__.length,value=done?undefined:this.__values__[this.__index__++];return{'done':done,'value':value};}/**
  38548. * Enables the wrapper to be iterable.
  38549. *
  38550. * @name Symbol.iterator
  38551. * @memberOf _
  38552. * @since 4.0.0
  38553. * @category Seq
  38554. * @returns {Object} Returns the wrapper object.
  38555. * @example
  38556. *
  38557. * var wrapped = _([1, 2]);
  38558. *
  38559. * wrapped[Symbol.iterator]() === wrapped;
  38560. * // => true
  38561. *
  38562. * Array.from(wrapped);
  38563. * // => [1, 2]
  38564. */function wrapperToIterator(){return this;}/**
  38565. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  38566. *
  38567. * @name plant
  38568. * @memberOf _
  38569. * @since 3.2.0
  38570. * @category Seq
  38571. * @param {*} value The value to plant.
  38572. * @returns {Object} Returns the new `lodash` wrapper instance.
  38573. * @example
  38574. *
  38575. * function square(n) {
  38576. * return n * n;
  38577. * }
  38578. *
  38579. * var wrapped = _([1, 2]).map(square);
  38580. * var other = wrapped.plant([3, 4]);
  38581. *
  38582. * other.value();
  38583. * // => [9, 16]
  38584. *
  38585. * wrapped.value();
  38586. * // => [1, 4]
  38587. */function wrapperPlant(value){var result,parent=this;while(parent instanceof baseLodash){var clone=wrapperClone(parent);clone.__index__=0;clone.__values__=undefined;if(result){previous.__wrapped__=clone;}else{result=clone;}var previous=clone;parent=parent.__wrapped__;}previous.__wrapped__=value;return result;}/**
  38588. * This method is the wrapper version of `_.reverse`.
  38589. *
  38590. * **Note:** This method mutates the wrapped array.
  38591. *
  38592. * @name reverse
  38593. * @memberOf _
  38594. * @since 0.1.0
  38595. * @category Seq
  38596. * @returns {Object} Returns the new `lodash` wrapper instance.
  38597. * @example
  38598. *
  38599. * var array = [1, 2, 3];
  38600. *
  38601. * _(array).reverse().value()
  38602. * // => [3, 2, 1]
  38603. *
  38604. * console.log(array);
  38605. * // => [3, 2, 1]
  38606. */function wrapperReverse(){var value=this.__wrapped__;if(value instanceof LazyWrapper){var wrapped=value;if(this.__actions__.length){wrapped=new LazyWrapper(this);}wrapped=wrapped.reverse();wrapped.__actions__.push({'func':thru,'args':[reverse],'thisArg':undefined});return new LodashWrapper(wrapped,this.__chain__);}return this.thru(reverse);}/**
  38607. * Executes the chain sequence to resolve the unwrapped value.
  38608. *
  38609. * @name value
  38610. * @memberOf _
  38611. * @since 0.1.0
  38612. * @alias toJSON, valueOf
  38613. * @category Seq
  38614. * @returns {*} Returns the resolved unwrapped value.
  38615. * @example
  38616. *
  38617. * _([1, 2, 3]).value();
  38618. * // => [1, 2, 3]
  38619. */function wrapperValue(){return baseWrapperValue(this.__wrapped__,this.__actions__);}/*------------------------------------------------------------------------*//**
  38620. * Creates an object composed of keys generated from the results of running
  38621. * each element of `collection` thru `iteratee`. The corresponding value of
  38622. * each key is the number of times the key was returned by `iteratee`. The
  38623. * iteratee is invoked with one argument: (value).
  38624. *
  38625. * @static
  38626. * @memberOf _
  38627. * @since 0.5.0
  38628. * @category Collection
  38629. * @param {Array|Object} collection The collection to iterate over.
  38630. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  38631. * @returns {Object} Returns the composed aggregate object.
  38632. * @example
  38633. *
  38634. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  38635. * // => { '4': 1, '6': 2 }
  38636. *
  38637. * // The `_.property` iteratee shorthand.
  38638. * _.countBy(['one', 'two', 'three'], 'length');
  38639. * // => { '3': 2, '5': 1 }
  38640. */var countBy=createAggregator(function(result,value,key){if(hasOwnProperty.call(result,key)){++result[key];}else{baseAssignValue(result,key,1);}});/**
  38641. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  38642. * Iteration is stopped once `predicate` returns falsey. The predicate is
  38643. * invoked with three arguments: (value, index|key, collection).
  38644. *
  38645. * **Note:** This method returns `true` for
  38646. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  38647. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  38648. * elements of empty collections.
  38649. *
  38650. * @static
  38651. * @memberOf _
  38652. * @since 0.1.0
  38653. * @category Collection
  38654. * @param {Array|Object} collection The collection to iterate over.
  38655. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  38656. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  38657. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  38658. * else `false`.
  38659. * @example
  38660. *
  38661. * _.every([true, 1, null, 'yes'], Boolean);
  38662. * // => false
  38663. *
  38664. * var users = [
  38665. * { 'user': 'barney', 'age': 36, 'active': false },
  38666. * { 'user': 'fred', 'age': 40, 'active': false }
  38667. * ];
  38668. *
  38669. * // The `_.matches` iteratee shorthand.
  38670. * _.every(users, { 'user': 'barney', 'active': false });
  38671. * // => false
  38672. *
  38673. * // The `_.matchesProperty` iteratee shorthand.
  38674. * _.every(users, ['active', false]);
  38675. * // => true
  38676. *
  38677. * // The `_.property` iteratee shorthand.
  38678. * _.every(users, 'active');
  38679. * // => false
  38680. */function every(collection,predicate,guard){var func=isArray(collection)?arrayEvery:baseEvery;if(guard&&isIterateeCall(collection,predicate,guard)){predicate=undefined;}return func(collection,getIteratee(predicate,3));}/**
  38681. * Iterates over elements of `collection`, returning an array of all elements
  38682. * `predicate` returns truthy for. The predicate is invoked with three
  38683. * arguments: (value, index|key, collection).
  38684. *
  38685. * **Note:** Unlike `_.remove`, this method returns a new array.
  38686. *
  38687. * @static
  38688. * @memberOf _
  38689. * @since 0.1.0
  38690. * @category Collection
  38691. * @param {Array|Object} collection The collection to iterate over.
  38692. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  38693. * @returns {Array} Returns the new filtered array.
  38694. * @see _.reject
  38695. * @example
  38696. *
  38697. * var users = [
  38698. * { 'user': 'barney', 'age': 36, 'active': true },
  38699. * { 'user': 'fred', 'age': 40, 'active': false }
  38700. * ];
  38701. *
  38702. * _.filter(users, function(o) { return !o.active; });
  38703. * // => objects for ['fred']
  38704. *
  38705. * // The `_.matches` iteratee shorthand.
  38706. * _.filter(users, { 'age': 36, 'active': true });
  38707. * // => objects for ['barney']
  38708. *
  38709. * // The `_.matchesProperty` iteratee shorthand.
  38710. * _.filter(users, ['active', false]);
  38711. * // => objects for ['fred']
  38712. *
  38713. * // The `_.property` iteratee shorthand.
  38714. * _.filter(users, 'active');
  38715. * // => objects for ['barney']
  38716. */function filter(collection,predicate){var func=isArray(collection)?arrayFilter:baseFilter;return func(collection,getIteratee(predicate,3));}/**
  38717. * Iterates over elements of `collection`, returning the first element
  38718. * `predicate` returns truthy for. The predicate is invoked with three
  38719. * arguments: (value, index|key, collection).
  38720. *
  38721. * @static
  38722. * @memberOf _
  38723. * @since 0.1.0
  38724. * @category Collection
  38725. * @param {Array|Object} collection The collection to inspect.
  38726. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  38727. * @param {number} [fromIndex=0] The index to search from.
  38728. * @returns {*} Returns the matched element, else `undefined`.
  38729. * @example
  38730. *
  38731. * var users = [
  38732. * { 'user': 'barney', 'age': 36, 'active': true },
  38733. * { 'user': 'fred', 'age': 40, 'active': false },
  38734. * { 'user': 'pebbles', 'age': 1, 'active': true }
  38735. * ];
  38736. *
  38737. * _.find(users, function(o) { return o.age < 40; });
  38738. * // => object for 'barney'
  38739. *
  38740. * // The `_.matches` iteratee shorthand.
  38741. * _.find(users, { 'age': 1, 'active': true });
  38742. * // => object for 'pebbles'
  38743. *
  38744. * // The `_.matchesProperty` iteratee shorthand.
  38745. * _.find(users, ['active', false]);
  38746. * // => object for 'fred'
  38747. *
  38748. * // The `_.property` iteratee shorthand.
  38749. * _.find(users, 'active');
  38750. * // => object for 'barney'
  38751. */var find=createFind(findIndex);/**
  38752. * This method is like `_.find` except that it iterates over elements of
  38753. * `collection` from right to left.
  38754. *
  38755. * @static
  38756. * @memberOf _
  38757. * @since 2.0.0
  38758. * @category Collection
  38759. * @param {Array|Object} collection The collection to inspect.
  38760. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  38761. * @param {number} [fromIndex=collection.length-1] The index to search from.
  38762. * @returns {*} Returns the matched element, else `undefined`.
  38763. * @example
  38764. *
  38765. * _.findLast([1, 2, 3, 4], function(n) {
  38766. * return n % 2 == 1;
  38767. * });
  38768. * // => 3
  38769. */var findLast=createFind(findLastIndex);/**
  38770. * Creates a flattened array of values by running each element in `collection`
  38771. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  38772. * with three arguments: (value, index|key, collection).
  38773. *
  38774. * @static
  38775. * @memberOf _
  38776. * @since 4.0.0
  38777. * @category Collection
  38778. * @param {Array|Object} collection The collection to iterate over.
  38779. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  38780. * @returns {Array} Returns the new flattened array.
  38781. * @example
  38782. *
  38783. * function duplicate(n) {
  38784. * return [n, n];
  38785. * }
  38786. *
  38787. * _.flatMap([1, 2], duplicate);
  38788. * // => [1, 1, 2, 2]
  38789. */function flatMap(collection,iteratee){return baseFlatten(map(collection,iteratee),1);}/**
  38790. * This method is like `_.flatMap` except that it recursively flattens the
  38791. * mapped results.
  38792. *
  38793. * @static
  38794. * @memberOf _
  38795. * @since 4.7.0
  38796. * @category Collection
  38797. * @param {Array|Object} collection The collection to iterate over.
  38798. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  38799. * @returns {Array} Returns the new flattened array.
  38800. * @example
  38801. *
  38802. * function duplicate(n) {
  38803. * return [[[n, n]]];
  38804. * }
  38805. *
  38806. * _.flatMapDeep([1, 2], duplicate);
  38807. * // => [1, 1, 2, 2]
  38808. */function flatMapDeep(collection,iteratee){return baseFlatten(map(collection,iteratee),INFINITY);}/**
  38809. * This method is like `_.flatMap` except that it recursively flattens the
  38810. * mapped results up to `depth` times.
  38811. *
  38812. * @static
  38813. * @memberOf _
  38814. * @since 4.7.0
  38815. * @category Collection
  38816. * @param {Array|Object} collection The collection to iterate over.
  38817. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  38818. * @param {number} [depth=1] The maximum recursion depth.
  38819. * @returns {Array} Returns the new flattened array.
  38820. * @example
  38821. *
  38822. * function duplicate(n) {
  38823. * return [[[n, n]]];
  38824. * }
  38825. *
  38826. * _.flatMapDepth([1, 2], duplicate, 2);
  38827. * // => [[1, 1], [2, 2]]
  38828. */function flatMapDepth(collection,iteratee,depth){depth=depth===undefined?1:toInteger(depth);return baseFlatten(map(collection,iteratee),depth);}/**
  38829. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  38830. * The iteratee is invoked with three arguments: (value, index|key, collection).
  38831. * Iteratee functions may exit iteration early by explicitly returning `false`.
  38832. *
  38833. * **Note:** As with other "Collections" methods, objects with a "length"
  38834. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  38835. * or `_.forOwn` for object iteration.
  38836. *
  38837. * @static
  38838. * @memberOf _
  38839. * @since 0.1.0
  38840. * @alias each
  38841. * @category Collection
  38842. * @param {Array|Object} collection The collection to iterate over.
  38843. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  38844. * @returns {Array|Object} Returns `collection`.
  38845. * @see _.forEachRight
  38846. * @example
  38847. *
  38848. * _.forEach([1, 2], function(value) {
  38849. * console.log(value);
  38850. * });
  38851. * // => Logs `1` then `2`.
  38852. *
  38853. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  38854. * console.log(key);
  38855. * });
  38856. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  38857. */function forEach(collection,iteratee){var func=isArray(collection)?arrayEach:baseEach;return func(collection,getIteratee(iteratee,3));}/**
  38858. * This method is like `_.forEach` except that it iterates over elements of
  38859. * `collection` from right to left.
  38860. *
  38861. * @static
  38862. * @memberOf _
  38863. * @since 2.0.0
  38864. * @alias eachRight
  38865. * @category Collection
  38866. * @param {Array|Object} collection The collection to iterate over.
  38867. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  38868. * @returns {Array|Object} Returns `collection`.
  38869. * @see _.forEach
  38870. * @example
  38871. *
  38872. * _.forEachRight([1, 2], function(value) {
  38873. * console.log(value);
  38874. * });
  38875. * // => Logs `2` then `1`.
  38876. */function forEachRight(collection,iteratee){var func=isArray(collection)?arrayEachRight:baseEachRight;return func(collection,getIteratee(iteratee,3));}/**
  38877. * Creates an object composed of keys generated from the results of running
  38878. * each element of `collection` thru `iteratee`. The order of grouped values
  38879. * is determined by the order they occur in `collection`. The corresponding
  38880. * value of each key is an array of elements responsible for generating the
  38881. * key. The iteratee is invoked with one argument: (value).
  38882. *
  38883. * @static
  38884. * @memberOf _
  38885. * @since 0.1.0
  38886. * @category Collection
  38887. * @param {Array|Object} collection The collection to iterate over.
  38888. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  38889. * @returns {Object} Returns the composed aggregate object.
  38890. * @example
  38891. *
  38892. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  38893. * // => { '4': [4.2], '6': [6.1, 6.3] }
  38894. *
  38895. * // The `_.property` iteratee shorthand.
  38896. * _.groupBy(['one', 'two', 'three'], 'length');
  38897. * // => { '3': ['one', 'two'], '5': ['three'] }
  38898. */var groupBy=createAggregator(function(result,value,key){if(hasOwnProperty.call(result,key)){result[key].push(value);}else{baseAssignValue(result,key,[value]);}});/**
  38899. * Checks if `value` is in `collection`. If `collection` is a string, it's
  38900. * checked for a substring of `value`, otherwise
  38901. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  38902. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  38903. * the offset from the end of `collection`.
  38904. *
  38905. * @static
  38906. * @memberOf _
  38907. * @since 0.1.0
  38908. * @category Collection
  38909. * @param {Array|Object|string} collection The collection to inspect.
  38910. * @param {*} value The value to search for.
  38911. * @param {number} [fromIndex=0] The index to search from.
  38912. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  38913. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  38914. * @example
  38915. *
  38916. * _.includes([1, 2, 3], 1);
  38917. * // => true
  38918. *
  38919. * _.includes([1, 2, 3], 1, 2);
  38920. * // => false
  38921. *
  38922. * _.includes({ 'a': 1, 'b': 2 }, 1);
  38923. * // => true
  38924. *
  38925. * _.includes('abcd', 'bc');
  38926. * // => true
  38927. */function includes(collection,value,fromIndex,guard){collection=isArrayLike(collection)?collection:values(collection);fromIndex=fromIndex&&!guard?toInteger(fromIndex):0;var length=collection.length;if(fromIndex<0){fromIndex=nativeMax(length+fromIndex,0);}return isString(collection)?fromIndex<=length&&collection.indexOf(value,fromIndex)>-1:!!length&&baseIndexOf(collection,value,fromIndex)>-1;}/**
  38928. * Invokes the method at `path` of each element in `collection`, returning
  38929. * an array of the results of each invoked method. Any additional arguments
  38930. * are provided to each invoked method. If `path` is a function, it's invoked
  38931. * for, and `this` bound to, each element in `collection`.
  38932. *
  38933. * @static
  38934. * @memberOf _
  38935. * @since 4.0.0
  38936. * @category Collection
  38937. * @param {Array|Object} collection The collection to iterate over.
  38938. * @param {Array|Function|string} path The path of the method to invoke or
  38939. * the function invoked per iteration.
  38940. * @param {...*} [args] The arguments to invoke each method with.
  38941. * @returns {Array} Returns the array of results.
  38942. * @example
  38943. *
  38944. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  38945. * // => [[1, 5, 7], [1, 2, 3]]
  38946. *
  38947. * _.invokeMap([123, 456], String.prototype.split, '');
  38948. * // => [['1', '2', '3'], ['4', '5', '6']]
  38949. */var invokeMap=baseRest(function(collection,path,args){var index=-1,isFunc=typeof path=='function',result=isArrayLike(collection)?Array(collection.length):[];baseEach(collection,function(value){result[++index]=isFunc?apply(path,value,args):baseInvoke(value,path,args);});return result;});/**
  38950. * Creates an object composed of keys generated from the results of running
  38951. * each element of `collection` thru `iteratee`. The corresponding value of
  38952. * each key is the last element responsible for generating the key. The
  38953. * iteratee is invoked with one argument: (value).
  38954. *
  38955. * @static
  38956. * @memberOf _
  38957. * @since 4.0.0
  38958. * @category Collection
  38959. * @param {Array|Object} collection The collection to iterate over.
  38960. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  38961. * @returns {Object} Returns the composed aggregate object.
  38962. * @example
  38963. *
  38964. * var array = [
  38965. * { 'dir': 'left', 'code': 97 },
  38966. * { 'dir': 'right', 'code': 100 }
  38967. * ];
  38968. *
  38969. * _.keyBy(array, function(o) {
  38970. * return String.fromCharCode(o.code);
  38971. * });
  38972. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  38973. *
  38974. * _.keyBy(array, 'dir');
  38975. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  38976. */var keyBy=createAggregator(function(result,value,key){baseAssignValue(result,key,value);});/**
  38977. * Creates an array of values by running each element in `collection` thru
  38978. * `iteratee`. The iteratee is invoked with three arguments:
  38979. * (value, index|key, collection).
  38980. *
  38981. * Many lodash methods are guarded to work as iteratees for methods like
  38982. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  38983. *
  38984. * The guarded methods are:
  38985. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  38986. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  38987. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  38988. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  38989. *
  38990. * @static
  38991. * @memberOf _
  38992. * @since 0.1.0
  38993. * @category Collection
  38994. * @param {Array|Object} collection The collection to iterate over.
  38995. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  38996. * @returns {Array} Returns the new mapped array.
  38997. * @example
  38998. *
  38999. * function square(n) {
  39000. * return n * n;
  39001. * }
  39002. *
  39003. * _.map([4, 8], square);
  39004. * // => [16, 64]
  39005. *
  39006. * _.map({ 'a': 4, 'b': 8 }, square);
  39007. * // => [16, 64] (iteration order is not guaranteed)
  39008. *
  39009. * var users = [
  39010. * { 'user': 'barney' },
  39011. * { 'user': 'fred' }
  39012. * ];
  39013. *
  39014. * // The `_.property` iteratee shorthand.
  39015. * _.map(users, 'user');
  39016. * // => ['barney', 'fred']
  39017. */function map(collection,iteratee){var func=isArray(collection)?arrayMap:baseMap;return func(collection,getIteratee(iteratee,3));}/**
  39018. * This method is like `_.sortBy` except that it allows specifying the sort
  39019. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  39020. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  39021. * descending or "asc" for ascending sort order of corresponding values.
  39022. *
  39023. * @static
  39024. * @memberOf _
  39025. * @since 4.0.0
  39026. * @category Collection
  39027. * @param {Array|Object} collection The collection to iterate over.
  39028. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  39029. * The iteratees to sort by.
  39030. * @param {string[]} [orders] The sort orders of `iteratees`.
  39031. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  39032. * @returns {Array} Returns the new sorted array.
  39033. * @example
  39034. *
  39035. * var users = [
  39036. * { 'user': 'fred', 'age': 48 },
  39037. * { 'user': 'barney', 'age': 34 },
  39038. * { 'user': 'fred', 'age': 40 },
  39039. * { 'user': 'barney', 'age': 36 }
  39040. * ];
  39041. *
  39042. * // Sort by `user` in ascending order and by `age` in descending order.
  39043. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  39044. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  39045. */function orderBy(collection,iteratees,orders,guard){if(collection==null){return[];}if(!isArray(iteratees)){iteratees=iteratees==null?[]:[iteratees];}orders=guard?undefined:orders;if(!isArray(orders)){orders=orders==null?[]:[orders];}return baseOrderBy(collection,iteratees,orders);}/**
  39046. * Creates an array of elements split into two groups, the first of which
  39047. * contains elements `predicate` returns truthy for, the second of which
  39048. * contains elements `predicate` returns falsey for. The predicate is
  39049. * invoked with one argument: (value).
  39050. *
  39051. * @static
  39052. * @memberOf _
  39053. * @since 3.0.0
  39054. * @category Collection
  39055. * @param {Array|Object} collection The collection to iterate over.
  39056. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39057. * @returns {Array} Returns the array of grouped elements.
  39058. * @example
  39059. *
  39060. * var users = [
  39061. * { 'user': 'barney', 'age': 36, 'active': false },
  39062. * { 'user': 'fred', 'age': 40, 'active': true },
  39063. * { 'user': 'pebbles', 'age': 1, 'active': false }
  39064. * ];
  39065. *
  39066. * _.partition(users, function(o) { return o.active; });
  39067. * // => objects for [['fred'], ['barney', 'pebbles']]
  39068. *
  39069. * // The `_.matches` iteratee shorthand.
  39070. * _.partition(users, { 'age': 1, 'active': false });
  39071. * // => objects for [['pebbles'], ['barney', 'fred']]
  39072. *
  39073. * // The `_.matchesProperty` iteratee shorthand.
  39074. * _.partition(users, ['active', false]);
  39075. * // => objects for [['barney', 'pebbles'], ['fred']]
  39076. *
  39077. * // The `_.property` iteratee shorthand.
  39078. * _.partition(users, 'active');
  39079. * // => objects for [['fred'], ['barney', 'pebbles']]
  39080. */var partition=createAggregator(function(result,value,key){result[key?0:1].push(value);},function(){return[[],[]];});/**
  39081. * Reduces `collection` to a value which is the accumulated result of running
  39082. * each element in `collection` thru `iteratee`, where each successive
  39083. * invocation is supplied the return value of the previous. If `accumulator`
  39084. * is not given, the first element of `collection` is used as the initial
  39085. * value. The iteratee is invoked with four arguments:
  39086. * (accumulator, value, index|key, collection).
  39087. *
  39088. * Many lodash methods are guarded to work as iteratees for methods like
  39089. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  39090. *
  39091. * The guarded methods are:
  39092. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  39093. * and `sortBy`
  39094. *
  39095. * @static
  39096. * @memberOf _
  39097. * @since 0.1.0
  39098. * @category Collection
  39099. * @param {Array|Object} collection The collection to iterate over.
  39100. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  39101. * @param {*} [accumulator] The initial value.
  39102. * @returns {*} Returns the accumulated value.
  39103. * @see _.reduceRight
  39104. * @example
  39105. *
  39106. * _.reduce([1, 2], function(sum, n) {
  39107. * return sum + n;
  39108. * }, 0);
  39109. * // => 3
  39110. *
  39111. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  39112. * (result[value] || (result[value] = [])).push(key);
  39113. * return result;
  39114. * }, {});
  39115. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  39116. */function reduce(collection,iteratee,accumulator){var func=isArray(collection)?arrayReduce:baseReduce,initAccum=arguments.length<3;return func(collection,getIteratee(iteratee,4),accumulator,initAccum,baseEach);}/**
  39117. * This method is like `_.reduce` except that it iterates over elements of
  39118. * `collection` from right to left.
  39119. *
  39120. * @static
  39121. * @memberOf _
  39122. * @since 0.1.0
  39123. * @category Collection
  39124. * @param {Array|Object} collection The collection to iterate over.
  39125. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  39126. * @param {*} [accumulator] The initial value.
  39127. * @returns {*} Returns the accumulated value.
  39128. * @see _.reduce
  39129. * @example
  39130. *
  39131. * var array = [[0, 1], [2, 3], [4, 5]];
  39132. *
  39133. * _.reduceRight(array, function(flattened, other) {
  39134. * return flattened.concat(other);
  39135. * }, []);
  39136. * // => [4, 5, 2, 3, 0, 1]
  39137. */function reduceRight(collection,iteratee,accumulator){var func=isArray(collection)?arrayReduceRight:baseReduce,initAccum=arguments.length<3;return func(collection,getIteratee(iteratee,4),accumulator,initAccum,baseEachRight);}/**
  39138. * The opposite of `_.filter`; this method returns the elements of `collection`
  39139. * that `predicate` does **not** return truthy for.
  39140. *
  39141. * @static
  39142. * @memberOf _
  39143. * @since 0.1.0
  39144. * @category Collection
  39145. * @param {Array|Object} collection The collection to iterate over.
  39146. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39147. * @returns {Array} Returns the new filtered array.
  39148. * @see _.filter
  39149. * @example
  39150. *
  39151. * var users = [
  39152. * { 'user': 'barney', 'age': 36, 'active': false },
  39153. * { 'user': 'fred', 'age': 40, 'active': true }
  39154. * ];
  39155. *
  39156. * _.reject(users, function(o) { return !o.active; });
  39157. * // => objects for ['fred']
  39158. *
  39159. * // The `_.matches` iteratee shorthand.
  39160. * _.reject(users, { 'age': 40, 'active': true });
  39161. * // => objects for ['barney']
  39162. *
  39163. * // The `_.matchesProperty` iteratee shorthand.
  39164. * _.reject(users, ['active', false]);
  39165. * // => objects for ['fred']
  39166. *
  39167. * // The `_.property` iteratee shorthand.
  39168. * _.reject(users, 'active');
  39169. * // => objects for ['barney']
  39170. */function reject(collection,predicate){var func=isArray(collection)?arrayFilter:baseFilter;return func(collection,negate(getIteratee(predicate,3)));}/**
  39171. * Gets a random element from `collection`.
  39172. *
  39173. * @static
  39174. * @memberOf _
  39175. * @since 2.0.0
  39176. * @category Collection
  39177. * @param {Array|Object} collection The collection to sample.
  39178. * @returns {*} Returns the random element.
  39179. * @example
  39180. *
  39181. * _.sample([1, 2, 3, 4]);
  39182. * // => 2
  39183. */function sample(collection){var func=isArray(collection)?arraySample:baseSample;return func(collection);}/**
  39184. * Gets `n` random elements at unique keys from `collection` up to the
  39185. * size of `collection`.
  39186. *
  39187. * @static
  39188. * @memberOf _
  39189. * @since 4.0.0
  39190. * @category Collection
  39191. * @param {Array|Object} collection The collection to sample.
  39192. * @param {number} [n=1] The number of elements to sample.
  39193. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39194. * @returns {Array} Returns the random elements.
  39195. * @example
  39196. *
  39197. * _.sampleSize([1, 2, 3], 2);
  39198. * // => [3, 1]
  39199. *
  39200. * _.sampleSize([1, 2, 3], 4);
  39201. * // => [2, 3, 1]
  39202. */function sampleSize(collection,n,guard){if(guard?isIterateeCall(collection,n,guard):n===undefined){n=1;}else{n=toInteger(n);}var func=isArray(collection)?arraySampleSize:baseSampleSize;return func(collection,n);}/**
  39203. * Creates an array of shuffled values, using a version of the
  39204. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  39205. *
  39206. * @static
  39207. * @memberOf _
  39208. * @since 0.1.0
  39209. * @category Collection
  39210. * @param {Array|Object} collection The collection to shuffle.
  39211. * @returns {Array} Returns the new shuffled array.
  39212. * @example
  39213. *
  39214. * _.shuffle([1, 2, 3, 4]);
  39215. * // => [4, 1, 3, 2]
  39216. */function shuffle(collection){var func=isArray(collection)?arrayShuffle:baseShuffle;return func(collection);}/**
  39217. * Gets the size of `collection` by returning its length for array-like
  39218. * values or the number of own enumerable string keyed properties for objects.
  39219. *
  39220. * @static
  39221. * @memberOf _
  39222. * @since 0.1.0
  39223. * @category Collection
  39224. * @param {Array|Object|string} collection The collection to inspect.
  39225. * @returns {number} Returns the collection size.
  39226. * @example
  39227. *
  39228. * _.size([1, 2, 3]);
  39229. * // => 3
  39230. *
  39231. * _.size({ 'a': 1, 'b': 2 });
  39232. * // => 2
  39233. *
  39234. * _.size('pebbles');
  39235. * // => 7
  39236. */function size(collection){if(collection==null){return 0;}if(isArrayLike(collection)){return isString(collection)?stringSize(collection):collection.length;}var tag=getTag(collection);if(tag==mapTag||tag==setTag){return collection.size;}return baseKeys(collection).length;}/**
  39237. * Checks if `predicate` returns truthy for **any** element of `collection`.
  39238. * Iteration is stopped once `predicate` returns truthy. The predicate is
  39239. * invoked with three arguments: (value, index|key, collection).
  39240. *
  39241. * @static
  39242. * @memberOf _
  39243. * @since 0.1.0
  39244. * @category Collection
  39245. * @param {Array|Object} collection The collection to iterate over.
  39246. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39247. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39248. * @returns {boolean} Returns `true` if any element passes the predicate check,
  39249. * else `false`.
  39250. * @example
  39251. *
  39252. * _.some([null, 0, 'yes', false], Boolean);
  39253. * // => true
  39254. *
  39255. * var users = [
  39256. * { 'user': 'barney', 'active': true },
  39257. * { 'user': 'fred', 'active': false }
  39258. * ];
  39259. *
  39260. * // The `_.matches` iteratee shorthand.
  39261. * _.some(users, { 'user': 'barney', 'active': false });
  39262. * // => false
  39263. *
  39264. * // The `_.matchesProperty` iteratee shorthand.
  39265. * _.some(users, ['active', false]);
  39266. * // => true
  39267. *
  39268. * // The `_.property` iteratee shorthand.
  39269. * _.some(users, 'active');
  39270. * // => true
  39271. */function some(collection,predicate,guard){var func=isArray(collection)?arraySome:baseSome;if(guard&&isIterateeCall(collection,predicate,guard)){predicate=undefined;}return func(collection,getIteratee(predicate,3));}/**
  39272. * Creates an array of elements, sorted in ascending order by the results of
  39273. * running each element in a collection thru each iteratee. This method
  39274. * performs a stable sort, that is, it preserves the original sort order of
  39275. * equal elements. The iteratees are invoked with one argument: (value).
  39276. *
  39277. * @static
  39278. * @memberOf _
  39279. * @since 0.1.0
  39280. * @category Collection
  39281. * @param {Array|Object} collection The collection to iterate over.
  39282. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  39283. * The iteratees to sort by.
  39284. * @returns {Array} Returns the new sorted array.
  39285. * @example
  39286. *
  39287. * var users = [
  39288. * { 'user': 'fred', 'age': 48 },
  39289. * { 'user': 'barney', 'age': 36 },
  39290. * { 'user': 'fred', 'age': 40 },
  39291. * { 'user': 'barney', 'age': 34 }
  39292. * ];
  39293. *
  39294. * _.sortBy(users, [function(o) { return o.user; }]);
  39295. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  39296. *
  39297. * _.sortBy(users, ['user', 'age']);
  39298. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  39299. */var sortBy=baseRest(function(collection,iteratees){if(collection==null){return[];}var length=iteratees.length;if(length>1&&isIterateeCall(collection,iteratees[0],iteratees[1])){iteratees=[];}else if(length>2&&isIterateeCall(iteratees[0],iteratees[1],iteratees[2])){iteratees=[iteratees[0]];}return baseOrderBy(collection,baseFlatten(iteratees,1),[]);});/*------------------------------------------------------------------------*//**
  39300. * Gets the timestamp of the number of milliseconds that have elapsed since
  39301. * the Unix epoch (1 January 1970 00:00:00 UTC).
  39302. *
  39303. * @static
  39304. * @memberOf _
  39305. * @since 2.4.0
  39306. * @category Date
  39307. * @returns {number} Returns the timestamp.
  39308. * @example
  39309. *
  39310. * _.defer(function(stamp) {
  39311. * console.log(_.now() - stamp);
  39312. * }, _.now());
  39313. * // => Logs the number of milliseconds it took for the deferred invocation.
  39314. */var now=ctxNow||function(){return root.Date.now();};/*------------------------------------------------------------------------*//**
  39315. * The opposite of `_.before`; this method creates a function that invokes
  39316. * `func` once it's called `n` or more times.
  39317. *
  39318. * @static
  39319. * @memberOf _
  39320. * @since 0.1.0
  39321. * @category Function
  39322. * @param {number} n The number of calls before `func` is invoked.
  39323. * @param {Function} func The function to restrict.
  39324. * @returns {Function} Returns the new restricted function.
  39325. * @example
  39326. *
  39327. * var saves = ['profile', 'settings'];
  39328. *
  39329. * var done = _.after(saves.length, function() {
  39330. * console.log('done saving!');
  39331. * });
  39332. *
  39333. * _.forEach(saves, function(type) {
  39334. * asyncSave({ 'type': type, 'complete': done });
  39335. * });
  39336. * // => Logs 'done saving!' after the two async saves have completed.
  39337. */function after(n,func){if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}n=toInteger(n);return function(){if(--n<1){return func.apply(this,arguments);}};}/**
  39338. * Creates a function that invokes `func`, with up to `n` arguments,
  39339. * ignoring any additional arguments.
  39340. *
  39341. * @static
  39342. * @memberOf _
  39343. * @since 3.0.0
  39344. * @category Function
  39345. * @param {Function} func The function to cap arguments for.
  39346. * @param {number} [n=func.length] The arity cap.
  39347. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39348. * @returns {Function} Returns the new capped function.
  39349. * @example
  39350. *
  39351. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  39352. * // => [6, 8, 10]
  39353. */function ary(func,n,guard){n=guard?undefined:n;n=func&&n==null?func.length:n;return createWrap(func,WRAP_ARY_FLAG,undefined,undefined,undefined,undefined,n);}/**
  39354. * Creates a function that invokes `func`, with the `this` binding and arguments
  39355. * of the created function, while it's called less than `n` times. Subsequent
  39356. * calls to the created function return the result of the last `func` invocation.
  39357. *
  39358. * @static
  39359. * @memberOf _
  39360. * @since 3.0.0
  39361. * @category Function
  39362. * @param {number} n The number of calls at which `func` is no longer invoked.
  39363. * @param {Function} func The function to restrict.
  39364. * @returns {Function} Returns the new restricted function.
  39365. * @example
  39366. *
  39367. * jQuery(element).on('click', _.before(5, addContactToList));
  39368. * // => Allows adding up to 4 contacts to the list.
  39369. */function before(n,func){var result;if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}n=toInteger(n);return function(){if(--n>0){result=func.apply(this,arguments);}if(n<=1){func=undefined;}return result;};}/**
  39370. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  39371. * and `partials` prepended to the arguments it receives.
  39372. *
  39373. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  39374. * may be used as a placeholder for partially applied arguments.
  39375. *
  39376. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  39377. * property of bound functions.
  39378. *
  39379. * @static
  39380. * @memberOf _
  39381. * @since 0.1.0
  39382. * @category Function
  39383. * @param {Function} func The function to bind.
  39384. * @param {*} thisArg The `this` binding of `func`.
  39385. * @param {...*} [partials] The arguments to be partially applied.
  39386. * @returns {Function} Returns the new bound function.
  39387. * @example
  39388. *
  39389. * function greet(greeting, punctuation) {
  39390. * return greeting + ' ' + this.user + punctuation;
  39391. * }
  39392. *
  39393. * var object = { 'user': 'fred' };
  39394. *
  39395. * var bound = _.bind(greet, object, 'hi');
  39396. * bound('!');
  39397. * // => 'hi fred!'
  39398. *
  39399. * // Bound with placeholders.
  39400. * var bound = _.bind(greet, object, _, '!');
  39401. * bound('hi');
  39402. * // => 'hi fred!'
  39403. */var bind=baseRest(function(func,thisArg,partials){var bitmask=WRAP_BIND_FLAG;if(partials.length){var holders=replaceHolders(partials,getHolder(bind));bitmask|=WRAP_PARTIAL_FLAG;}return createWrap(func,bitmask,thisArg,partials,holders);});/**
  39404. * Creates a function that invokes the method at `object[key]` with `partials`
  39405. * prepended to the arguments it receives.
  39406. *
  39407. * This method differs from `_.bind` by allowing bound functions to reference
  39408. * methods that may be redefined or don't yet exist. See
  39409. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  39410. * for more details.
  39411. *
  39412. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  39413. * builds, may be used as a placeholder for partially applied arguments.
  39414. *
  39415. * @static
  39416. * @memberOf _
  39417. * @since 0.10.0
  39418. * @category Function
  39419. * @param {Object} object The object to invoke the method on.
  39420. * @param {string} key The key of the method.
  39421. * @param {...*} [partials] The arguments to be partially applied.
  39422. * @returns {Function} Returns the new bound function.
  39423. * @example
  39424. *
  39425. * var object = {
  39426. * 'user': 'fred',
  39427. * 'greet': function(greeting, punctuation) {
  39428. * return greeting + ' ' + this.user + punctuation;
  39429. * }
  39430. * };
  39431. *
  39432. * var bound = _.bindKey(object, 'greet', 'hi');
  39433. * bound('!');
  39434. * // => 'hi fred!'
  39435. *
  39436. * object.greet = function(greeting, punctuation) {
  39437. * return greeting + 'ya ' + this.user + punctuation;
  39438. * };
  39439. *
  39440. * bound('!');
  39441. * // => 'hiya fred!'
  39442. *
  39443. * // Bound with placeholders.
  39444. * var bound = _.bindKey(object, 'greet', _, '!');
  39445. * bound('hi');
  39446. * // => 'hiya fred!'
  39447. */var bindKey=baseRest(function(object,key,partials){var bitmask=WRAP_BIND_FLAG|WRAP_BIND_KEY_FLAG;if(partials.length){var holders=replaceHolders(partials,getHolder(bindKey));bitmask|=WRAP_PARTIAL_FLAG;}return createWrap(key,bitmask,object,partials,holders);});/**
  39448. * Creates a function that accepts arguments of `func` and either invokes
  39449. * `func` returning its result, if at least `arity` number of arguments have
  39450. * been provided, or returns a function that accepts the remaining `func`
  39451. * arguments, and so on. The arity of `func` may be specified if `func.length`
  39452. * is not sufficient.
  39453. *
  39454. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  39455. * may be used as a placeholder for provided arguments.
  39456. *
  39457. * **Note:** This method doesn't set the "length" property of curried functions.
  39458. *
  39459. * @static
  39460. * @memberOf _
  39461. * @since 2.0.0
  39462. * @category Function
  39463. * @param {Function} func The function to curry.
  39464. * @param {number} [arity=func.length] The arity of `func`.
  39465. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39466. * @returns {Function} Returns the new curried function.
  39467. * @example
  39468. *
  39469. * var abc = function(a, b, c) {
  39470. * return [a, b, c];
  39471. * };
  39472. *
  39473. * var curried = _.curry(abc);
  39474. *
  39475. * curried(1)(2)(3);
  39476. * // => [1, 2, 3]
  39477. *
  39478. * curried(1, 2)(3);
  39479. * // => [1, 2, 3]
  39480. *
  39481. * curried(1, 2, 3);
  39482. * // => [1, 2, 3]
  39483. *
  39484. * // Curried with placeholders.
  39485. * curried(1)(_, 3)(2);
  39486. * // => [1, 2, 3]
  39487. */function curry(func,arity,guard){arity=guard?undefined:arity;var result=createWrap(func,WRAP_CURRY_FLAG,undefined,undefined,undefined,undefined,undefined,arity);result.placeholder=curry.placeholder;return result;}/**
  39488. * This method is like `_.curry` except that arguments are applied to `func`
  39489. * in the manner of `_.partialRight` instead of `_.partial`.
  39490. *
  39491. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  39492. * builds, may be used as a placeholder for provided arguments.
  39493. *
  39494. * **Note:** This method doesn't set the "length" property of curried functions.
  39495. *
  39496. * @static
  39497. * @memberOf _
  39498. * @since 3.0.0
  39499. * @category Function
  39500. * @param {Function} func The function to curry.
  39501. * @param {number} [arity=func.length] The arity of `func`.
  39502. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39503. * @returns {Function} Returns the new curried function.
  39504. * @example
  39505. *
  39506. * var abc = function(a, b, c) {
  39507. * return [a, b, c];
  39508. * };
  39509. *
  39510. * var curried = _.curryRight(abc);
  39511. *
  39512. * curried(3)(2)(1);
  39513. * // => [1, 2, 3]
  39514. *
  39515. * curried(2, 3)(1);
  39516. * // => [1, 2, 3]
  39517. *
  39518. * curried(1, 2, 3);
  39519. * // => [1, 2, 3]
  39520. *
  39521. * // Curried with placeholders.
  39522. * curried(3)(1, _)(2);
  39523. * // => [1, 2, 3]
  39524. */function curryRight(func,arity,guard){arity=guard?undefined:arity;var result=createWrap(func,WRAP_CURRY_RIGHT_FLAG,undefined,undefined,undefined,undefined,undefined,arity);result.placeholder=curryRight.placeholder;return result;}/**
  39525. * Creates a debounced function that delays invoking `func` until after `wait`
  39526. * milliseconds have elapsed since the last time the debounced function was
  39527. * invoked. The debounced function comes with a `cancel` method to cancel
  39528. * delayed `func` invocations and a `flush` method to immediately invoke them.
  39529. * Provide `options` to indicate whether `func` should be invoked on the
  39530. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  39531. * with the last arguments provided to the debounced function. Subsequent
  39532. * calls to the debounced function return the result of the last `func`
  39533. * invocation.
  39534. *
  39535. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  39536. * invoked on the trailing edge of the timeout only if the debounced function
  39537. * is invoked more than once during the `wait` timeout.
  39538. *
  39539. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  39540. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  39541. *
  39542. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  39543. * for details over the differences between `_.debounce` and `_.throttle`.
  39544. *
  39545. * @static
  39546. * @memberOf _
  39547. * @since 0.1.0
  39548. * @category Function
  39549. * @param {Function} func The function to debounce.
  39550. * @param {number} [wait=0] The number of milliseconds to delay.
  39551. * @param {Object} [options={}] The options object.
  39552. * @param {boolean} [options.leading=false]
  39553. * Specify invoking on the leading edge of the timeout.
  39554. * @param {number} [options.maxWait]
  39555. * The maximum time `func` is allowed to be delayed before it's invoked.
  39556. * @param {boolean} [options.trailing=true]
  39557. * Specify invoking on the trailing edge of the timeout.
  39558. * @returns {Function} Returns the new debounced function.
  39559. * @example
  39560. *
  39561. * // Avoid costly calculations while the window size is in flux.
  39562. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  39563. *
  39564. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  39565. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  39566. * 'leading': true,
  39567. * 'trailing': false
  39568. * }));
  39569. *
  39570. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  39571. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  39572. * var source = new EventSource('/stream');
  39573. * jQuery(source).on('message', debounced);
  39574. *
  39575. * // Cancel the trailing debounced invocation.
  39576. * jQuery(window).on('popstate', debounced.cancel);
  39577. */function debounce(func,wait,options){var lastArgs,lastThis,maxWait,result,timerId,lastCallTime,lastInvokeTime=0,leading=false,maxing=false,trailing=true;if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}wait=toNumber(wait)||0;if(isObject(options)){leading=!!options.leading;maxing='maxWait'in options;maxWait=maxing?nativeMax(toNumber(options.maxWait)||0,wait):maxWait;trailing='trailing'in options?!!options.trailing:trailing;}function invokeFunc(time){var args=lastArgs,thisArg=lastThis;lastArgs=lastThis=undefined;lastInvokeTime=time;result=func.apply(thisArg,args);return result;}function leadingEdge(time){// Reset any `maxWait` timer.
  39578. lastInvokeTime=time;// Start the timer for the trailing edge.
  39579. timerId=setTimeout(timerExpired,wait);// Invoke the leading edge.
  39580. return leading?invokeFunc(time):result;}function remainingWait(time){var timeSinceLastCall=time-lastCallTime,timeSinceLastInvoke=time-lastInvokeTime,timeWaiting=wait-timeSinceLastCall;return maxing?nativeMin(timeWaiting,maxWait-timeSinceLastInvoke):timeWaiting;}function shouldInvoke(time){var timeSinceLastCall=time-lastCallTime,timeSinceLastInvoke=time-lastInvokeTime;// Either this is the first call, activity has stopped and we're at the
  39581. // trailing edge, the system time has gone backwards and we're treating
  39582. // it as the trailing edge, or we've hit the `maxWait` limit.
  39583. return lastCallTime===undefined||timeSinceLastCall>=wait||timeSinceLastCall<0||maxing&&timeSinceLastInvoke>=maxWait;}function timerExpired(){var time=now();if(shouldInvoke(time)){return trailingEdge(time);}// Restart the timer.
  39584. timerId=setTimeout(timerExpired,remainingWait(time));}function trailingEdge(time){timerId=undefined;// Only invoke if we have `lastArgs` which means `func` has been
  39585. // debounced at least once.
  39586. if(trailing&&lastArgs){return invokeFunc(time);}lastArgs=lastThis=undefined;return result;}function cancel(){if(timerId!==undefined){clearTimeout(timerId);}lastInvokeTime=0;lastArgs=lastCallTime=lastThis=timerId=undefined;}function flush(){return timerId===undefined?result:trailingEdge(now());}function debounced(){var time=now(),isInvoking=shouldInvoke(time);lastArgs=arguments;lastThis=this;lastCallTime=time;if(isInvoking){if(timerId===undefined){return leadingEdge(lastCallTime);}if(maxing){// Handle invocations in a tight loop.
  39587. timerId=setTimeout(timerExpired,wait);return invokeFunc(lastCallTime);}}if(timerId===undefined){timerId=setTimeout(timerExpired,wait);}return result;}debounced.cancel=cancel;debounced.flush=flush;return debounced;}/**
  39588. * Defers invoking the `func` until the current call stack has cleared. Any
  39589. * additional arguments are provided to `func` when it's invoked.
  39590. *
  39591. * @static
  39592. * @memberOf _
  39593. * @since 0.1.0
  39594. * @category Function
  39595. * @param {Function} func The function to defer.
  39596. * @param {...*} [args] The arguments to invoke `func` with.
  39597. * @returns {number} Returns the timer id.
  39598. * @example
  39599. *
  39600. * _.defer(function(text) {
  39601. * console.log(text);
  39602. * }, 'deferred');
  39603. * // => Logs 'deferred' after one millisecond.
  39604. */var defer=baseRest(function(func,args){return baseDelay(func,1,args);});/**
  39605. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  39606. * provided to `func` when it's invoked.
  39607. *
  39608. * @static
  39609. * @memberOf _
  39610. * @since 0.1.0
  39611. * @category Function
  39612. * @param {Function} func The function to delay.
  39613. * @param {number} wait The number of milliseconds to delay invocation.
  39614. * @param {...*} [args] The arguments to invoke `func` with.
  39615. * @returns {number} Returns the timer id.
  39616. * @example
  39617. *
  39618. * _.delay(function(text) {
  39619. * console.log(text);
  39620. * }, 1000, 'later');
  39621. * // => Logs 'later' after one second.
  39622. */var delay=baseRest(function(func,wait,args){return baseDelay(func,toNumber(wait)||0,args);});/**
  39623. * Creates a function that invokes `func` with arguments reversed.
  39624. *
  39625. * @static
  39626. * @memberOf _
  39627. * @since 4.0.0
  39628. * @category Function
  39629. * @param {Function} func The function to flip arguments for.
  39630. * @returns {Function} Returns the new flipped function.
  39631. * @example
  39632. *
  39633. * var flipped = _.flip(function() {
  39634. * return _.toArray(arguments);
  39635. * });
  39636. *
  39637. * flipped('a', 'b', 'c', 'd');
  39638. * // => ['d', 'c', 'b', 'a']
  39639. */function flip(func){return createWrap(func,WRAP_FLIP_FLAG);}/**
  39640. * Creates a function that memoizes the result of `func`. If `resolver` is
  39641. * provided, it determines the cache key for storing the result based on the
  39642. * arguments provided to the memoized function. By default, the first argument
  39643. * provided to the memoized function is used as the map cache key. The `func`
  39644. * is invoked with the `this` binding of the memoized function.
  39645. *
  39646. * **Note:** The cache is exposed as the `cache` property on the memoized
  39647. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  39648. * constructor with one whose instances implement the
  39649. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  39650. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  39651. *
  39652. * @static
  39653. * @memberOf _
  39654. * @since 0.1.0
  39655. * @category Function
  39656. * @param {Function} func The function to have its output memoized.
  39657. * @param {Function} [resolver] The function to resolve the cache key.
  39658. * @returns {Function} Returns the new memoized function.
  39659. * @example
  39660. *
  39661. * var object = { 'a': 1, 'b': 2 };
  39662. * var other = { 'c': 3, 'd': 4 };
  39663. *
  39664. * var values = _.memoize(_.values);
  39665. * values(object);
  39666. * // => [1, 2]
  39667. *
  39668. * values(other);
  39669. * // => [3, 4]
  39670. *
  39671. * object.a = 2;
  39672. * values(object);
  39673. * // => [1, 2]
  39674. *
  39675. * // Modify the result cache.
  39676. * values.cache.set(object, ['a', 'b']);
  39677. * values(object);
  39678. * // => ['a', 'b']
  39679. *
  39680. * // Replace `_.memoize.Cache`.
  39681. * _.memoize.Cache = WeakMap;
  39682. */function memoize(func,resolver){if(typeof func!='function'||resolver!=null&&typeof resolver!='function'){throw new TypeError(FUNC_ERROR_TEXT);}var memoized=function memoized(){var args=arguments,key=resolver?resolver.apply(this,args):args[0],cache=memoized.cache;if(cache.has(key)){return cache.get(key);}var result=func.apply(this,args);memoized.cache=cache.set(key,result)||cache;return result;};memoized.cache=new(memoize.Cache||MapCache)();return memoized;}// Expose `MapCache`.
  39683. memoize.Cache=MapCache;/**
  39684. * Creates a function that negates the result of the predicate `func`. The
  39685. * `func` predicate is invoked with the `this` binding and arguments of the
  39686. * created function.
  39687. *
  39688. * @static
  39689. * @memberOf _
  39690. * @since 3.0.0
  39691. * @category Function
  39692. * @param {Function} predicate The predicate to negate.
  39693. * @returns {Function} Returns the new negated function.
  39694. * @example
  39695. *
  39696. * function isEven(n) {
  39697. * return n % 2 == 0;
  39698. * }
  39699. *
  39700. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  39701. * // => [1, 3, 5]
  39702. */function negate(predicate){if(typeof predicate!='function'){throw new TypeError(FUNC_ERROR_TEXT);}return function(){var args=arguments;switch(args.length){case 0:return!predicate.call(this);case 1:return!predicate.call(this,args[0]);case 2:return!predicate.call(this,args[0],args[1]);case 3:return!predicate.call(this,args[0],args[1],args[2]);}return!predicate.apply(this,args);};}/**
  39703. * Creates a function that is restricted to invoking `func` once. Repeat calls
  39704. * to the function return the value of the first invocation. The `func` is
  39705. * invoked with the `this` binding and arguments of the created function.
  39706. *
  39707. * @static
  39708. * @memberOf _
  39709. * @since 0.1.0
  39710. * @category Function
  39711. * @param {Function} func The function to restrict.
  39712. * @returns {Function} Returns the new restricted function.
  39713. * @example
  39714. *
  39715. * var initialize = _.once(createApplication);
  39716. * initialize();
  39717. * initialize();
  39718. * // => `createApplication` is invoked once
  39719. */function once(func){return before(2,func);}/**
  39720. * Creates a function that invokes `func` with its arguments transformed.
  39721. *
  39722. * @static
  39723. * @since 4.0.0
  39724. * @memberOf _
  39725. * @category Function
  39726. * @param {Function} func The function to wrap.
  39727. * @param {...(Function|Function[])} [transforms=[_.identity]]
  39728. * The argument transforms.
  39729. * @returns {Function} Returns the new function.
  39730. * @example
  39731. *
  39732. * function doubled(n) {
  39733. * return n * 2;
  39734. * }
  39735. *
  39736. * function square(n) {
  39737. * return n * n;
  39738. * }
  39739. *
  39740. * var func = _.overArgs(function(x, y) {
  39741. * return [x, y];
  39742. * }, [square, doubled]);
  39743. *
  39744. * func(9, 3);
  39745. * // => [81, 6]
  39746. *
  39747. * func(10, 5);
  39748. * // => [100, 10]
  39749. */var overArgs=castRest(function(func,transforms){transforms=transforms.length==1&&isArray(transforms[0])?arrayMap(transforms[0],baseUnary(getIteratee())):arrayMap(baseFlatten(transforms,1),baseUnary(getIteratee()));var funcsLength=transforms.length;return baseRest(function(args){var index=-1,length=nativeMin(args.length,funcsLength);while(++index<length){args[index]=transforms[index].call(this,args[index]);}return apply(func,this,args);});});/**
  39750. * Creates a function that invokes `func` with `partials` prepended to the
  39751. * arguments it receives. This method is like `_.bind` except it does **not**
  39752. * alter the `this` binding.
  39753. *
  39754. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  39755. * builds, may be used as a placeholder for partially applied arguments.
  39756. *
  39757. * **Note:** This method doesn't set the "length" property of partially
  39758. * applied functions.
  39759. *
  39760. * @static
  39761. * @memberOf _
  39762. * @since 0.2.0
  39763. * @category Function
  39764. * @param {Function} func The function to partially apply arguments to.
  39765. * @param {...*} [partials] The arguments to be partially applied.
  39766. * @returns {Function} Returns the new partially applied function.
  39767. * @example
  39768. *
  39769. * function greet(greeting, name) {
  39770. * return greeting + ' ' + name;
  39771. * }
  39772. *
  39773. * var sayHelloTo = _.partial(greet, 'hello');
  39774. * sayHelloTo('fred');
  39775. * // => 'hello fred'
  39776. *
  39777. * // Partially applied with placeholders.
  39778. * var greetFred = _.partial(greet, _, 'fred');
  39779. * greetFred('hi');
  39780. * // => 'hi fred'
  39781. */var partial=baseRest(function(func,partials){var holders=replaceHolders(partials,getHolder(partial));return createWrap(func,WRAP_PARTIAL_FLAG,undefined,partials,holders);});/**
  39782. * This method is like `_.partial` except that partially applied arguments
  39783. * are appended to the arguments it receives.
  39784. *
  39785. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  39786. * builds, may be used as a placeholder for partially applied arguments.
  39787. *
  39788. * **Note:** This method doesn't set the "length" property of partially
  39789. * applied functions.
  39790. *
  39791. * @static
  39792. * @memberOf _
  39793. * @since 1.0.0
  39794. * @category Function
  39795. * @param {Function} func The function to partially apply arguments to.
  39796. * @param {...*} [partials] The arguments to be partially applied.
  39797. * @returns {Function} Returns the new partially applied function.
  39798. * @example
  39799. *
  39800. * function greet(greeting, name) {
  39801. * return greeting + ' ' + name;
  39802. * }
  39803. *
  39804. * var greetFred = _.partialRight(greet, 'fred');
  39805. * greetFred('hi');
  39806. * // => 'hi fred'
  39807. *
  39808. * // Partially applied with placeholders.
  39809. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  39810. * sayHelloTo('fred');
  39811. * // => 'hello fred'
  39812. */var partialRight=baseRest(function(func,partials){var holders=replaceHolders(partials,getHolder(partialRight));return createWrap(func,WRAP_PARTIAL_RIGHT_FLAG,undefined,partials,holders);});/**
  39813. * Creates a function that invokes `func` with arguments arranged according
  39814. * to the specified `indexes` where the argument value at the first index is
  39815. * provided as the first argument, the argument value at the second index is
  39816. * provided as the second argument, and so on.
  39817. *
  39818. * @static
  39819. * @memberOf _
  39820. * @since 3.0.0
  39821. * @category Function
  39822. * @param {Function} func The function to rearrange arguments for.
  39823. * @param {...(number|number[])} indexes The arranged argument indexes.
  39824. * @returns {Function} Returns the new function.
  39825. * @example
  39826. *
  39827. * var rearged = _.rearg(function(a, b, c) {
  39828. * return [a, b, c];
  39829. * }, [2, 0, 1]);
  39830. *
  39831. * rearged('b', 'c', 'a')
  39832. * // => ['a', 'b', 'c']
  39833. */var rearg=flatRest(function(func,indexes){return createWrap(func,WRAP_REARG_FLAG,undefined,undefined,undefined,indexes);});/**
  39834. * Creates a function that invokes `func` with the `this` binding of the
  39835. * created function and arguments from `start` and beyond provided as
  39836. * an array.
  39837. *
  39838. * **Note:** This method is based on the
  39839. * [rest parameter](https://mdn.io/rest_parameters).
  39840. *
  39841. * @static
  39842. * @memberOf _
  39843. * @since 4.0.0
  39844. * @category Function
  39845. * @param {Function} func The function to apply a rest parameter to.
  39846. * @param {number} [start=func.length-1] The start position of the rest parameter.
  39847. * @returns {Function} Returns the new function.
  39848. * @example
  39849. *
  39850. * var say = _.rest(function(what, names) {
  39851. * return what + ' ' + _.initial(names).join(', ') +
  39852. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  39853. * });
  39854. *
  39855. * say('hello', 'fred', 'barney', 'pebbles');
  39856. * // => 'hello fred, barney, & pebbles'
  39857. */function rest(func,start){if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}start=start===undefined?start:toInteger(start);return baseRest(func,start);}/**
  39858. * Creates a function that invokes `func` with the `this` binding of the
  39859. * create function and an array of arguments much like
  39860. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  39861. *
  39862. * **Note:** This method is based on the
  39863. * [spread operator](https://mdn.io/spread_operator).
  39864. *
  39865. * @static
  39866. * @memberOf _
  39867. * @since 3.2.0
  39868. * @category Function
  39869. * @param {Function} func The function to spread arguments over.
  39870. * @param {number} [start=0] The start position of the spread.
  39871. * @returns {Function} Returns the new function.
  39872. * @example
  39873. *
  39874. * var say = _.spread(function(who, what) {
  39875. * return who + ' says ' + what;
  39876. * });
  39877. *
  39878. * say(['fred', 'hello']);
  39879. * // => 'fred says hello'
  39880. *
  39881. * var numbers = Promise.all([
  39882. * Promise.resolve(40),
  39883. * Promise.resolve(36)
  39884. * ]);
  39885. *
  39886. * numbers.then(_.spread(function(x, y) {
  39887. * return x + y;
  39888. * }));
  39889. * // => a Promise of 76
  39890. */function spread(func,start){if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}start=start==null?0:nativeMax(toInteger(start),0);return baseRest(function(args){var array=args[start],otherArgs=castSlice(args,0,start);if(array){arrayPush(otherArgs,array);}return apply(func,this,otherArgs);});}/**
  39891. * Creates a throttled function that only invokes `func` at most once per
  39892. * every `wait` milliseconds. The throttled function comes with a `cancel`
  39893. * method to cancel delayed `func` invocations and a `flush` method to
  39894. * immediately invoke them. Provide `options` to indicate whether `func`
  39895. * should be invoked on the leading and/or trailing edge of the `wait`
  39896. * timeout. The `func` is invoked with the last arguments provided to the
  39897. * throttled function. Subsequent calls to the throttled function return the
  39898. * result of the last `func` invocation.
  39899. *
  39900. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  39901. * invoked on the trailing edge of the timeout only if the throttled function
  39902. * is invoked more than once during the `wait` timeout.
  39903. *
  39904. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  39905. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  39906. *
  39907. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  39908. * for details over the differences between `_.throttle` and `_.debounce`.
  39909. *
  39910. * @static
  39911. * @memberOf _
  39912. * @since 0.1.0
  39913. * @category Function
  39914. * @param {Function} func The function to throttle.
  39915. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  39916. * @param {Object} [options={}] The options object.
  39917. * @param {boolean} [options.leading=true]
  39918. * Specify invoking on the leading edge of the timeout.
  39919. * @param {boolean} [options.trailing=true]
  39920. * Specify invoking on the trailing edge of the timeout.
  39921. * @returns {Function} Returns the new throttled function.
  39922. * @example
  39923. *
  39924. * // Avoid excessively updating the position while scrolling.
  39925. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  39926. *
  39927. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  39928. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  39929. * jQuery(element).on('click', throttled);
  39930. *
  39931. * // Cancel the trailing throttled invocation.
  39932. * jQuery(window).on('popstate', throttled.cancel);
  39933. */function throttle(func,wait,options){var leading=true,trailing=true;if(typeof func!='function'){throw new TypeError(FUNC_ERROR_TEXT);}if(isObject(options)){leading='leading'in options?!!options.leading:leading;trailing='trailing'in options?!!options.trailing:trailing;}return debounce(func,wait,{'leading':leading,'maxWait':wait,'trailing':trailing});}/**
  39934. * Creates a function that accepts up to one argument, ignoring any
  39935. * additional arguments.
  39936. *
  39937. * @static
  39938. * @memberOf _
  39939. * @since 4.0.0
  39940. * @category Function
  39941. * @param {Function} func The function to cap arguments for.
  39942. * @returns {Function} Returns the new capped function.
  39943. * @example
  39944. *
  39945. * _.map(['6', '8', '10'], _.unary(parseInt));
  39946. * // => [6, 8, 10]
  39947. */function unary(func){return ary(func,1);}/**
  39948. * Creates a function that provides `value` to `wrapper` as its first
  39949. * argument. Any additional arguments provided to the function are appended
  39950. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  39951. * binding of the created function.
  39952. *
  39953. * @static
  39954. * @memberOf _
  39955. * @since 0.1.0
  39956. * @category Function
  39957. * @param {*} value The value to wrap.
  39958. * @param {Function} [wrapper=identity] The wrapper function.
  39959. * @returns {Function} Returns the new function.
  39960. * @example
  39961. *
  39962. * var p = _.wrap(_.escape, function(func, text) {
  39963. * return '<p>' + func(text) + '</p>';
  39964. * });
  39965. *
  39966. * p('fred, barney, & pebbles');
  39967. * // => '<p>fred, barney, &amp; pebbles</p>'
  39968. */function wrap(value,wrapper){return partial(castFunction(wrapper),value);}/*------------------------------------------------------------------------*//**
  39969. * Casts `value` as an array if it's not one.
  39970. *
  39971. * @static
  39972. * @memberOf _
  39973. * @since 4.4.0
  39974. * @category Lang
  39975. * @param {*} value The value to inspect.
  39976. * @returns {Array} Returns the cast array.
  39977. * @example
  39978. *
  39979. * _.castArray(1);
  39980. * // => [1]
  39981. *
  39982. * _.castArray({ 'a': 1 });
  39983. * // => [{ 'a': 1 }]
  39984. *
  39985. * _.castArray('abc');
  39986. * // => ['abc']
  39987. *
  39988. * _.castArray(null);
  39989. * // => [null]
  39990. *
  39991. * _.castArray(undefined);
  39992. * // => [undefined]
  39993. *
  39994. * _.castArray();
  39995. * // => []
  39996. *
  39997. * var array = [1, 2, 3];
  39998. * console.log(_.castArray(array) === array);
  39999. * // => true
  40000. */function castArray(){if(!arguments.length){return[];}var value=arguments[0];return isArray(value)?value:[value];}/**
  40001. * Creates a shallow clone of `value`.
  40002. *
  40003. * **Note:** This method is loosely based on the
  40004. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  40005. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  40006. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  40007. * arrays. The own enumerable properties of `arguments` objects are cloned
  40008. * as plain objects. An empty object is returned for uncloneable values such
  40009. * as error objects, functions, DOM nodes, and WeakMaps.
  40010. *
  40011. * @static
  40012. * @memberOf _
  40013. * @since 0.1.0
  40014. * @category Lang
  40015. * @param {*} value The value to clone.
  40016. * @returns {*} Returns the cloned value.
  40017. * @see _.cloneDeep
  40018. * @example
  40019. *
  40020. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  40021. *
  40022. * var shallow = _.clone(objects);
  40023. * console.log(shallow[0] === objects[0]);
  40024. * // => true
  40025. */function clone(value){return baseClone(value,CLONE_SYMBOLS_FLAG);}/**
  40026. * This method is like `_.clone` except that it accepts `customizer` which
  40027. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  40028. * cloning is handled by the method instead. The `customizer` is invoked with
  40029. * up to four arguments; (value [, index|key, object, stack]).
  40030. *
  40031. * @static
  40032. * @memberOf _
  40033. * @since 4.0.0
  40034. * @category Lang
  40035. * @param {*} value The value to clone.
  40036. * @param {Function} [customizer] The function to customize cloning.
  40037. * @returns {*} Returns the cloned value.
  40038. * @see _.cloneDeepWith
  40039. * @example
  40040. *
  40041. * function customizer(value) {
  40042. * if (_.isElement(value)) {
  40043. * return value.cloneNode(false);
  40044. * }
  40045. * }
  40046. *
  40047. * var el = _.cloneWith(document.body, customizer);
  40048. *
  40049. * console.log(el === document.body);
  40050. * // => false
  40051. * console.log(el.nodeName);
  40052. * // => 'BODY'
  40053. * console.log(el.childNodes.length);
  40054. * // => 0
  40055. */function cloneWith(value,customizer){customizer=typeof customizer=='function'?customizer:undefined;return baseClone(value,CLONE_SYMBOLS_FLAG,customizer);}/**
  40056. * This method is like `_.clone` except that it recursively clones `value`.
  40057. *
  40058. * @static
  40059. * @memberOf _
  40060. * @since 1.0.0
  40061. * @category Lang
  40062. * @param {*} value The value to recursively clone.
  40063. * @returns {*} Returns the deep cloned value.
  40064. * @see _.clone
  40065. * @example
  40066. *
  40067. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  40068. *
  40069. * var deep = _.cloneDeep(objects);
  40070. * console.log(deep[0] === objects[0]);
  40071. * // => false
  40072. */function cloneDeep(value){return baseClone(value,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG);}/**
  40073. * This method is like `_.cloneWith` except that it recursively clones `value`.
  40074. *
  40075. * @static
  40076. * @memberOf _
  40077. * @since 4.0.0
  40078. * @category Lang
  40079. * @param {*} value The value to recursively clone.
  40080. * @param {Function} [customizer] The function to customize cloning.
  40081. * @returns {*} Returns the deep cloned value.
  40082. * @see _.cloneWith
  40083. * @example
  40084. *
  40085. * function customizer(value) {
  40086. * if (_.isElement(value)) {
  40087. * return value.cloneNode(true);
  40088. * }
  40089. * }
  40090. *
  40091. * var el = _.cloneDeepWith(document.body, customizer);
  40092. *
  40093. * console.log(el === document.body);
  40094. * // => false
  40095. * console.log(el.nodeName);
  40096. * // => 'BODY'
  40097. * console.log(el.childNodes.length);
  40098. * // => 20
  40099. */function cloneDeepWith(value,customizer){customizer=typeof customizer=='function'?customizer:undefined;return baseClone(value,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG,customizer);}/**
  40100. * Checks if `object` conforms to `source` by invoking the predicate
  40101. * properties of `source` with the corresponding property values of `object`.
  40102. *
  40103. * **Note:** This method is equivalent to `_.conforms` when `source` is
  40104. * partially applied.
  40105. *
  40106. * @static
  40107. * @memberOf _
  40108. * @since 4.14.0
  40109. * @category Lang
  40110. * @param {Object} object The object to inspect.
  40111. * @param {Object} source The object of property predicates to conform to.
  40112. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  40113. * @example
  40114. *
  40115. * var object = { 'a': 1, 'b': 2 };
  40116. *
  40117. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  40118. * // => true
  40119. *
  40120. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  40121. * // => false
  40122. */function conformsTo(object,source){return source==null||baseConformsTo(object,source,keys(source));}/**
  40123. * Performs a
  40124. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  40125. * comparison between two values to determine if they are equivalent.
  40126. *
  40127. * @static
  40128. * @memberOf _
  40129. * @since 4.0.0
  40130. * @category Lang
  40131. * @param {*} value The value to compare.
  40132. * @param {*} other The other value to compare.
  40133. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  40134. * @example
  40135. *
  40136. * var object = { 'a': 1 };
  40137. * var other = { 'a': 1 };
  40138. *
  40139. * _.eq(object, object);
  40140. * // => true
  40141. *
  40142. * _.eq(object, other);
  40143. * // => false
  40144. *
  40145. * _.eq('a', 'a');
  40146. * // => true
  40147. *
  40148. * _.eq('a', Object('a'));
  40149. * // => false
  40150. *
  40151. * _.eq(NaN, NaN);
  40152. * // => true
  40153. */function eq(value,other){return value===other||value!==value&&other!==other;}/**
  40154. * Checks if `value` is greater than `other`.
  40155. *
  40156. * @static
  40157. * @memberOf _
  40158. * @since 3.9.0
  40159. * @category Lang
  40160. * @param {*} value The value to compare.
  40161. * @param {*} other The other value to compare.
  40162. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  40163. * else `false`.
  40164. * @see _.lt
  40165. * @example
  40166. *
  40167. * _.gt(3, 1);
  40168. * // => true
  40169. *
  40170. * _.gt(3, 3);
  40171. * // => false
  40172. *
  40173. * _.gt(1, 3);
  40174. * // => false
  40175. */var gt=createRelationalOperation(baseGt);/**
  40176. * Checks if `value` is greater than or equal to `other`.
  40177. *
  40178. * @static
  40179. * @memberOf _
  40180. * @since 3.9.0
  40181. * @category Lang
  40182. * @param {*} value The value to compare.
  40183. * @param {*} other The other value to compare.
  40184. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  40185. * `other`, else `false`.
  40186. * @see _.lte
  40187. * @example
  40188. *
  40189. * _.gte(3, 1);
  40190. * // => true
  40191. *
  40192. * _.gte(3, 3);
  40193. * // => true
  40194. *
  40195. * _.gte(1, 3);
  40196. * // => false
  40197. */var gte=createRelationalOperation(function(value,other){return value>=other;});/**
  40198. * Checks if `value` is likely an `arguments` object.
  40199. *
  40200. * @static
  40201. * @memberOf _
  40202. * @since 0.1.0
  40203. * @category Lang
  40204. * @param {*} value The value to check.
  40205. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  40206. * else `false`.
  40207. * @example
  40208. *
  40209. * _.isArguments(function() { return arguments; }());
  40210. * // => true
  40211. *
  40212. * _.isArguments([1, 2, 3]);
  40213. * // => false
  40214. */var isArguments=baseIsArguments(function(){return arguments;}())?baseIsArguments:function(value){return isObjectLike(value)&&hasOwnProperty.call(value,'callee')&&!propertyIsEnumerable.call(value,'callee');};/**
  40215. * Checks if `value` is classified as an `Array` object.
  40216. *
  40217. * @static
  40218. * @memberOf _
  40219. * @since 0.1.0
  40220. * @category Lang
  40221. * @param {*} value The value to check.
  40222. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  40223. * @example
  40224. *
  40225. * _.isArray([1, 2, 3]);
  40226. * // => true
  40227. *
  40228. * _.isArray(document.body.children);
  40229. * // => false
  40230. *
  40231. * _.isArray('abc');
  40232. * // => false
  40233. *
  40234. * _.isArray(_.noop);
  40235. * // => false
  40236. */var isArray=Array.isArray;/**
  40237. * Checks if `value` is classified as an `ArrayBuffer` object.
  40238. *
  40239. * @static
  40240. * @memberOf _
  40241. * @since 4.3.0
  40242. * @category Lang
  40243. * @param {*} value The value to check.
  40244. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  40245. * @example
  40246. *
  40247. * _.isArrayBuffer(new ArrayBuffer(2));
  40248. * // => true
  40249. *
  40250. * _.isArrayBuffer(new Array(2));
  40251. * // => false
  40252. */var isArrayBuffer=nodeIsArrayBuffer?baseUnary(nodeIsArrayBuffer):baseIsArrayBuffer;/**
  40253. * Checks if `value` is array-like. A value is considered array-like if it's
  40254. * not a function and has a `value.length` that's an integer greater than or
  40255. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  40256. *
  40257. * @static
  40258. * @memberOf _
  40259. * @since 4.0.0
  40260. * @category Lang
  40261. * @param {*} value The value to check.
  40262. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  40263. * @example
  40264. *
  40265. * _.isArrayLike([1, 2, 3]);
  40266. * // => true
  40267. *
  40268. * _.isArrayLike(document.body.children);
  40269. * // => true
  40270. *
  40271. * _.isArrayLike('abc');
  40272. * // => true
  40273. *
  40274. * _.isArrayLike(_.noop);
  40275. * // => false
  40276. */function isArrayLike(value){return value!=null&&isLength(value.length)&&!isFunction(value);}/**
  40277. * This method is like `_.isArrayLike` except that it also checks if `value`
  40278. * is an object.
  40279. *
  40280. * @static
  40281. * @memberOf _
  40282. * @since 4.0.0
  40283. * @category Lang
  40284. * @param {*} value The value to check.
  40285. * @returns {boolean} Returns `true` if `value` is an array-like object,
  40286. * else `false`.
  40287. * @example
  40288. *
  40289. * _.isArrayLikeObject([1, 2, 3]);
  40290. * // => true
  40291. *
  40292. * _.isArrayLikeObject(document.body.children);
  40293. * // => true
  40294. *
  40295. * _.isArrayLikeObject('abc');
  40296. * // => false
  40297. *
  40298. * _.isArrayLikeObject(_.noop);
  40299. * // => false
  40300. */function isArrayLikeObject(value){return isObjectLike(value)&&isArrayLike(value);}/**
  40301. * Checks if `value` is classified as a boolean primitive or object.
  40302. *
  40303. * @static
  40304. * @memberOf _
  40305. * @since 0.1.0
  40306. * @category Lang
  40307. * @param {*} value The value to check.
  40308. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  40309. * @example
  40310. *
  40311. * _.isBoolean(false);
  40312. * // => true
  40313. *
  40314. * _.isBoolean(null);
  40315. * // => false
  40316. */function isBoolean(value){return value===true||value===false||isObjectLike(value)&&baseGetTag(value)==boolTag;}/**
  40317. * Checks if `value` is a buffer.
  40318. *
  40319. * @static
  40320. * @memberOf _
  40321. * @since 4.3.0
  40322. * @category Lang
  40323. * @param {*} value The value to check.
  40324. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  40325. * @example
  40326. *
  40327. * _.isBuffer(new Buffer(2));
  40328. * // => true
  40329. *
  40330. * _.isBuffer(new Uint8Array(2));
  40331. * // => false
  40332. */var isBuffer=nativeIsBuffer||stubFalse;/**
  40333. * Checks if `value` is classified as a `Date` object.
  40334. *
  40335. * @static
  40336. * @memberOf _
  40337. * @since 0.1.0
  40338. * @category Lang
  40339. * @param {*} value The value to check.
  40340. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  40341. * @example
  40342. *
  40343. * _.isDate(new Date);
  40344. * // => true
  40345. *
  40346. * _.isDate('Mon April 23 2012');
  40347. * // => false
  40348. */var isDate=nodeIsDate?baseUnary(nodeIsDate):baseIsDate;/**
  40349. * Checks if `value` is likely a DOM element.
  40350. *
  40351. * @static
  40352. * @memberOf _
  40353. * @since 0.1.0
  40354. * @category Lang
  40355. * @param {*} value The value to check.
  40356. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  40357. * @example
  40358. *
  40359. * _.isElement(document.body);
  40360. * // => true
  40361. *
  40362. * _.isElement('<body>');
  40363. * // => false
  40364. */function isElement(value){return isObjectLike(value)&&value.nodeType===1&&!isPlainObject(value);}/**
  40365. * Checks if `value` is an empty object, collection, map, or set.
  40366. *
  40367. * Objects are considered empty if they have no own enumerable string keyed
  40368. * properties.
  40369. *
  40370. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  40371. * jQuery-like collections are considered empty if they have a `length` of `0`.
  40372. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  40373. *
  40374. * @static
  40375. * @memberOf _
  40376. * @since 0.1.0
  40377. * @category Lang
  40378. * @param {*} value The value to check.
  40379. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  40380. * @example
  40381. *
  40382. * _.isEmpty(null);
  40383. * // => true
  40384. *
  40385. * _.isEmpty(true);
  40386. * // => true
  40387. *
  40388. * _.isEmpty(1);
  40389. * // => true
  40390. *
  40391. * _.isEmpty([1, 2, 3]);
  40392. * // => false
  40393. *
  40394. * _.isEmpty({ 'a': 1 });
  40395. * // => false
  40396. */function isEmpty(value){if(value==null){return true;}if(isArrayLike(value)&&(isArray(value)||typeof value=='string'||typeof value.splice=='function'||isBuffer(value)||isTypedArray(value)||isArguments(value))){return!value.length;}var tag=getTag(value);if(tag==mapTag||tag==setTag){return!value.size;}if(isPrototype(value)){return!baseKeys(value).length;}for(var key in value){if(hasOwnProperty.call(value,key)){return false;}}return true;}/**
  40397. * Performs a deep comparison between two values to determine if they are
  40398. * equivalent.
  40399. *
  40400. * **Note:** This method supports comparing arrays, array buffers, booleans,
  40401. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  40402. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  40403. * by their own, not inherited, enumerable properties. Functions and DOM
  40404. * nodes are compared by strict equality, i.e. `===`.
  40405. *
  40406. * @static
  40407. * @memberOf _
  40408. * @since 0.1.0
  40409. * @category Lang
  40410. * @param {*} value The value to compare.
  40411. * @param {*} other The other value to compare.
  40412. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  40413. * @example
  40414. *
  40415. * var object = { 'a': 1 };
  40416. * var other = { 'a': 1 };
  40417. *
  40418. * _.isEqual(object, other);
  40419. * // => true
  40420. *
  40421. * object === other;
  40422. * // => false
  40423. */function isEqual(value,other){return baseIsEqual(value,other);}/**
  40424. * This method is like `_.isEqual` except that it accepts `customizer` which
  40425. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  40426. * are handled by the method instead. The `customizer` is invoked with up to
  40427. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  40428. *
  40429. * @static
  40430. * @memberOf _
  40431. * @since 4.0.0
  40432. * @category Lang
  40433. * @param {*} value The value to compare.
  40434. * @param {*} other The other value to compare.
  40435. * @param {Function} [customizer] The function to customize comparisons.
  40436. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  40437. * @example
  40438. *
  40439. * function isGreeting(value) {
  40440. * return /^h(?:i|ello)$/.test(value);
  40441. * }
  40442. *
  40443. * function customizer(objValue, othValue) {
  40444. * if (isGreeting(objValue) && isGreeting(othValue)) {
  40445. * return true;
  40446. * }
  40447. * }
  40448. *
  40449. * var array = ['hello', 'goodbye'];
  40450. * var other = ['hi', 'goodbye'];
  40451. *
  40452. * _.isEqualWith(array, other, customizer);
  40453. * // => true
  40454. */function isEqualWith(value,other,customizer){customizer=typeof customizer=='function'?customizer:undefined;var result=customizer?customizer(value,other):undefined;return result===undefined?baseIsEqual(value,other,undefined,customizer):!!result;}/**
  40455. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  40456. * `SyntaxError`, `TypeError`, or `URIError` object.
  40457. *
  40458. * @static
  40459. * @memberOf _
  40460. * @since 3.0.0
  40461. * @category Lang
  40462. * @param {*} value The value to check.
  40463. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  40464. * @example
  40465. *
  40466. * _.isError(new Error);
  40467. * // => true
  40468. *
  40469. * _.isError(Error);
  40470. * // => false
  40471. */function isError(value){if(!isObjectLike(value)){return false;}var tag=baseGetTag(value);return tag==errorTag||tag==domExcTag||typeof value.message=='string'&&typeof value.name=='string'&&!isPlainObject(value);}/**
  40472. * Checks if `value` is a finite primitive number.
  40473. *
  40474. * **Note:** This method is based on
  40475. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  40476. *
  40477. * @static
  40478. * @memberOf _
  40479. * @since 0.1.0
  40480. * @category Lang
  40481. * @param {*} value The value to check.
  40482. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  40483. * @example
  40484. *
  40485. * _.isFinite(3);
  40486. * // => true
  40487. *
  40488. * _.isFinite(Number.MIN_VALUE);
  40489. * // => true
  40490. *
  40491. * _.isFinite(Infinity);
  40492. * // => false
  40493. *
  40494. * _.isFinite('3');
  40495. * // => false
  40496. */function isFinite(value){return typeof value=='number'&&nativeIsFinite(value);}/**
  40497. * Checks if `value` is classified as a `Function` object.
  40498. *
  40499. * @static
  40500. * @memberOf _
  40501. * @since 0.1.0
  40502. * @category Lang
  40503. * @param {*} value The value to check.
  40504. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  40505. * @example
  40506. *
  40507. * _.isFunction(_);
  40508. * // => true
  40509. *
  40510. * _.isFunction(/abc/);
  40511. * // => false
  40512. */function isFunction(value){if(!isObject(value)){return false;}// The use of `Object#toString` avoids issues with the `typeof` operator
  40513. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  40514. var tag=baseGetTag(value);return tag==funcTag||tag==genTag||tag==asyncTag||tag==proxyTag;}/**
  40515. * Checks if `value` is an integer.
  40516. *
  40517. * **Note:** This method is based on
  40518. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  40519. *
  40520. * @static
  40521. * @memberOf _
  40522. * @since 4.0.0
  40523. * @category Lang
  40524. * @param {*} value The value to check.
  40525. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  40526. * @example
  40527. *
  40528. * _.isInteger(3);
  40529. * // => true
  40530. *
  40531. * _.isInteger(Number.MIN_VALUE);
  40532. * // => false
  40533. *
  40534. * _.isInteger(Infinity);
  40535. * // => false
  40536. *
  40537. * _.isInteger('3');
  40538. * // => false
  40539. */function isInteger(value){return typeof value=='number'&&value==toInteger(value);}/**
  40540. * Checks if `value` is a valid array-like length.
  40541. *
  40542. * **Note:** This method is loosely based on
  40543. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  40544. *
  40545. * @static
  40546. * @memberOf _
  40547. * @since 4.0.0
  40548. * @category Lang
  40549. * @param {*} value The value to check.
  40550. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  40551. * @example
  40552. *
  40553. * _.isLength(3);
  40554. * // => true
  40555. *
  40556. * _.isLength(Number.MIN_VALUE);
  40557. * // => false
  40558. *
  40559. * _.isLength(Infinity);
  40560. * // => false
  40561. *
  40562. * _.isLength('3');
  40563. * // => false
  40564. */function isLength(value){return typeof value=='number'&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER;}/**
  40565. * Checks if `value` is the
  40566. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  40567. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  40568. *
  40569. * @static
  40570. * @memberOf _
  40571. * @since 0.1.0
  40572. * @category Lang
  40573. * @param {*} value The value to check.
  40574. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  40575. * @example
  40576. *
  40577. * _.isObject({});
  40578. * // => true
  40579. *
  40580. * _.isObject([1, 2, 3]);
  40581. * // => true
  40582. *
  40583. * _.isObject(_.noop);
  40584. * // => true
  40585. *
  40586. * _.isObject(null);
  40587. * // => false
  40588. */function isObject(value){var type=typeof value==='undefined'?'undefined':_typeof(value);return value!=null&&(type=='object'||type=='function');}/**
  40589. * Checks if `value` is object-like. A value is object-like if it's not `null`
  40590. * and has a `typeof` result of "object".
  40591. *
  40592. * @static
  40593. * @memberOf _
  40594. * @since 4.0.0
  40595. * @category Lang
  40596. * @param {*} value The value to check.
  40597. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  40598. * @example
  40599. *
  40600. * _.isObjectLike({});
  40601. * // => true
  40602. *
  40603. * _.isObjectLike([1, 2, 3]);
  40604. * // => true
  40605. *
  40606. * _.isObjectLike(_.noop);
  40607. * // => false
  40608. *
  40609. * _.isObjectLike(null);
  40610. * // => false
  40611. */function isObjectLike(value){return value!=null&&(typeof value==='undefined'?'undefined':_typeof(value))=='object';}/**
  40612. * Checks if `value` is classified as a `Map` object.
  40613. *
  40614. * @static
  40615. * @memberOf _
  40616. * @since 4.3.0
  40617. * @category Lang
  40618. * @param {*} value The value to check.
  40619. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  40620. * @example
  40621. *
  40622. * _.isMap(new Map);
  40623. * // => true
  40624. *
  40625. * _.isMap(new WeakMap);
  40626. * // => false
  40627. */var isMap=nodeIsMap?baseUnary(nodeIsMap):baseIsMap;/**
  40628. * Performs a partial deep comparison between `object` and `source` to
  40629. * determine if `object` contains equivalent property values.
  40630. *
  40631. * **Note:** This method is equivalent to `_.matches` when `source` is
  40632. * partially applied.
  40633. *
  40634. * Partial comparisons will match empty array and empty object `source`
  40635. * values against any array or object value, respectively. See `_.isEqual`
  40636. * for a list of supported value comparisons.
  40637. *
  40638. * @static
  40639. * @memberOf _
  40640. * @since 3.0.0
  40641. * @category Lang
  40642. * @param {Object} object The object to inspect.
  40643. * @param {Object} source The object of property values to match.
  40644. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  40645. * @example
  40646. *
  40647. * var object = { 'a': 1, 'b': 2 };
  40648. *
  40649. * _.isMatch(object, { 'b': 2 });
  40650. * // => true
  40651. *
  40652. * _.isMatch(object, { 'b': 1 });
  40653. * // => false
  40654. */function isMatch(object,source){return object===source||baseIsMatch(object,source,getMatchData(source));}/**
  40655. * This method is like `_.isMatch` except that it accepts `customizer` which
  40656. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  40657. * are handled by the method instead. The `customizer` is invoked with five
  40658. * arguments: (objValue, srcValue, index|key, object, source).
  40659. *
  40660. * @static
  40661. * @memberOf _
  40662. * @since 4.0.0
  40663. * @category Lang
  40664. * @param {Object} object The object to inspect.
  40665. * @param {Object} source The object of property values to match.
  40666. * @param {Function} [customizer] The function to customize comparisons.
  40667. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  40668. * @example
  40669. *
  40670. * function isGreeting(value) {
  40671. * return /^h(?:i|ello)$/.test(value);
  40672. * }
  40673. *
  40674. * function customizer(objValue, srcValue) {
  40675. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  40676. * return true;
  40677. * }
  40678. * }
  40679. *
  40680. * var object = { 'greeting': 'hello' };
  40681. * var source = { 'greeting': 'hi' };
  40682. *
  40683. * _.isMatchWith(object, source, customizer);
  40684. * // => true
  40685. */function isMatchWith(object,source,customizer){customizer=typeof customizer=='function'?customizer:undefined;return baseIsMatch(object,source,getMatchData(source),customizer);}/**
  40686. * Checks if `value` is `NaN`.
  40687. *
  40688. * **Note:** This method is based on
  40689. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  40690. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  40691. * `undefined` and other non-number values.
  40692. *
  40693. * @static
  40694. * @memberOf _
  40695. * @since 0.1.0
  40696. * @category Lang
  40697. * @param {*} value The value to check.
  40698. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  40699. * @example
  40700. *
  40701. * _.isNaN(NaN);
  40702. * // => true
  40703. *
  40704. * _.isNaN(new Number(NaN));
  40705. * // => true
  40706. *
  40707. * isNaN(undefined);
  40708. * // => true
  40709. *
  40710. * _.isNaN(undefined);
  40711. * // => false
  40712. */function isNaN(value){// An `NaN` primitive is the only value that is not equal to itself.
  40713. // Perform the `toStringTag` check first to avoid errors with some
  40714. // ActiveX objects in IE.
  40715. return isNumber(value)&&value!=+value;}/**
  40716. * Checks if `value` is a pristine native function.
  40717. *
  40718. * **Note:** This method can't reliably detect native functions in the presence
  40719. * of the core-js package because core-js circumvents this kind of detection.
  40720. * Despite multiple requests, the core-js maintainer has made it clear: any
  40721. * attempt to fix the detection will be obstructed. As a result, we're left
  40722. * with little choice but to throw an error. Unfortunately, this also affects
  40723. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  40724. * which rely on core-js.
  40725. *
  40726. * @static
  40727. * @memberOf _
  40728. * @since 3.0.0
  40729. * @category Lang
  40730. * @param {*} value The value to check.
  40731. * @returns {boolean} Returns `true` if `value` is a native function,
  40732. * else `false`.
  40733. * @example
  40734. *
  40735. * _.isNative(Array.prototype.push);
  40736. * // => true
  40737. *
  40738. * _.isNative(_);
  40739. * // => false
  40740. */function isNative(value){if(isMaskable(value)){throw new Error(CORE_ERROR_TEXT);}return baseIsNative(value);}/**
  40741. * Checks if `value` is `null`.
  40742. *
  40743. * @static
  40744. * @memberOf _
  40745. * @since 0.1.0
  40746. * @category Lang
  40747. * @param {*} value The value to check.
  40748. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  40749. * @example
  40750. *
  40751. * _.isNull(null);
  40752. * // => true
  40753. *
  40754. * _.isNull(void 0);
  40755. * // => false
  40756. */function isNull(value){return value===null;}/**
  40757. * Checks if `value` is `null` or `undefined`.
  40758. *
  40759. * @static
  40760. * @memberOf _
  40761. * @since 4.0.0
  40762. * @category Lang
  40763. * @param {*} value The value to check.
  40764. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  40765. * @example
  40766. *
  40767. * _.isNil(null);
  40768. * // => true
  40769. *
  40770. * _.isNil(void 0);
  40771. * // => true
  40772. *
  40773. * _.isNil(NaN);
  40774. * // => false
  40775. */function isNil(value){return value==null;}/**
  40776. * Checks if `value` is classified as a `Number` primitive or object.
  40777. *
  40778. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  40779. * classified as numbers, use the `_.isFinite` method.
  40780. *
  40781. * @static
  40782. * @memberOf _
  40783. * @since 0.1.0
  40784. * @category Lang
  40785. * @param {*} value The value to check.
  40786. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  40787. * @example
  40788. *
  40789. * _.isNumber(3);
  40790. * // => true
  40791. *
  40792. * _.isNumber(Number.MIN_VALUE);
  40793. * // => true
  40794. *
  40795. * _.isNumber(Infinity);
  40796. * // => true
  40797. *
  40798. * _.isNumber('3');
  40799. * // => false
  40800. */function isNumber(value){return typeof value=='number'||isObjectLike(value)&&baseGetTag(value)==numberTag;}/**
  40801. * Checks if `value` is a plain object, that is, an object created by the
  40802. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  40803. *
  40804. * @static
  40805. * @memberOf _
  40806. * @since 0.8.0
  40807. * @category Lang
  40808. * @param {*} value The value to check.
  40809. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  40810. * @example
  40811. *
  40812. * function Foo() {
  40813. * this.a = 1;
  40814. * }
  40815. *
  40816. * _.isPlainObject(new Foo);
  40817. * // => false
  40818. *
  40819. * _.isPlainObject([1, 2, 3]);
  40820. * // => false
  40821. *
  40822. * _.isPlainObject({ 'x': 0, 'y': 0 });
  40823. * // => true
  40824. *
  40825. * _.isPlainObject(Object.create(null));
  40826. * // => true
  40827. */function isPlainObject(value){if(!isObjectLike(value)||baseGetTag(value)!=objectTag){return false;}var proto=getPrototype(value);if(proto===null){return true;}var Ctor=hasOwnProperty.call(proto,'constructor')&&proto.constructor;return typeof Ctor=='function'&&Ctor instanceof Ctor&&funcToString.call(Ctor)==objectCtorString;}/**
  40828. * Checks if `value` is classified as a `RegExp` object.
  40829. *
  40830. * @static
  40831. * @memberOf _
  40832. * @since 0.1.0
  40833. * @category Lang
  40834. * @param {*} value The value to check.
  40835. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  40836. * @example
  40837. *
  40838. * _.isRegExp(/abc/);
  40839. * // => true
  40840. *
  40841. * _.isRegExp('/abc/');
  40842. * // => false
  40843. */var isRegExp=nodeIsRegExp?baseUnary(nodeIsRegExp):baseIsRegExp;/**
  40844. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  40845. * double precision number which isn't the result of a rounded unsafe integer.
  40846. *
  40847. * **Note:** This method is based on
  40848. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  40849. *
  40850. * @static
  40851. * @memberOf _
  40852. * @since 4.0.0
  40853. * @category Lang
  40854. * @param {*} value The value to check.
  40855. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  40856. * @example
  40857. *
  40858. * _.isSafeInteger(3);
  40859. * // => true
  40860. *
  40861. * _.isSafeInteger(Number.MIN_VALUE);
  40862. * // => false
  40863. *
  40864. * _.isSafeInteger(Infinity);
  40865. * // => false
  40866. *
  40867. * _.isSafeInteger('3');
  40868. * // => false
  40869. */function isSafeInteger(value){return isInteger(value)&&value>=-MAX_SAFE_INTEGER&&value<=MAX_SAFE_INTEGER;}/**
  40870. * Checks if `value` is classified as a `Set` object.
  40871. *
  40872. * @static
  40873. * @memberOf _
  40874. * @since 4.3.0
  40875. * @category Lang
  40876. * @param {*} value The value to check.
  40877. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  40878. * @example
  40879. *
  40880. * _.isSet(new Set);
  40881. * // => true
  40882. *
  40883. * _.isSet(new WeakSet);
  40884. * // => false
  40885. */var isSet=nodeIsSet?baseUnary(nodeIsSet):baseIsSet;/**
  40886. * Checks if `value` is classified as a `String` primitive or object.
  40887. *
  40888. * @static
  40889. * @since 0.1.0
  40890. * @memberOf _
  40891. * @category Lang
  40892. * @param {*} value The value to check.
  40893. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  40894. * @example
  40895. *
  40896. * _.isString('abc');
  40897. * // => true
  40898. *
  40899. * _.isString(1);
  40900. * // => false
  40901. */function isString(value){return typeof value=='string'||!isArray(value)&&isObjectLike(value)&&baseGetTag(value)==stringTag;}/**
  40902. * Checks if `value` is classified as a `Symbol` primitive or object.
  40903. *
  40904. * @static
  40905. * @memberOf _
  40906. * @since 4.0.0
  40907. * @category Lang
  40908. * @param {*} value The value to check.
  40909. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  40910. * @example
  40911. *
  40912. * _.isSymbol(Symbol.iterator);
  40913. * // => true
  40914. *
  40915. * _.isSymbol('abc');
  40916. * // => false
  40917. */function isSymbol(value){return(typeof value==='undefined'?'undefined':_typeof(value))=='symbol'||isObjectLike(value)&&baseGetTag(value)==symbolTag;}/**
  40918. * Checks if `value` is classified as a typed array.
  40919. *
  40920. * @static
  40921. * @memberOf _
  40922. * @since 3.0.0
  40923. * @category Lang
  40924. * @param {*} value The value to check.
  40925. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  40926. * @example
  40927. *
  40928. * _.isTypedArray(new Uint8Array);
  40929. * // => true
  40930. *
  40931. * _.isTypedArray([]);
  40932. * // => false
  40933. */var isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;/**
  40934. * Checks if `value` is `undefined`.
  40935. *
  40936. * @static
  40937. * @since 0.1.0
  40938. * @memberOf _
  40939. * @category Lang
  40940. * @param {*} value The value to check.
  40941. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  40942. * @example
  40943. *
  40944. * _.isUndefined(void 0);
  40945. * // => true
  40946. *
  40947. * _.isUndefined(null);
  40948. * // => false
  40949. */function isUndefined(value){return value===undefined;}/**
  40950. * Checks if `value` is classified as a `WeakMap` object.
  40951. *
  40952. * @static
  40953. * @memberOf _
  40954. * @since 4.3.0
  40955. * @category Lang
  40956. * @param {*} value The value to check.
  40957. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  40958. * @example
  40959. *
  40960. * _.isWeakMap(new WeakMap);
  40961. * // => true
  40962. *
  40963. * _.isWeakMap(new Map);
  40964. * // => false
  40965. */function isWeakMap(value){return isObjectLike(value)&&getTag(value)==weakMapTag;}/**
  40966. * Checks if `value` is classified as a `WeakSet` object.
  40967. *
  40968. * @static
  40969. * @memberOf _
  40970. * @since 4.3.0
  40971. * @category Lang
  40972. * @param {*} value The value to check.
  40973. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  40974. * @example
  40975. *
  40976. * _.isWeakSet(new WeakSet);
  40977. * // => true
  40978. *
  40979. * _.isWeakSet(new Set);
  40980. * // => false
  40981. */function isWeakSet(value){return isObjectLike(value)&&baseGetTag(value)==weakSetTag;}/**
  40982. * Checks if `value` is less than `other`.
  40983. *
  40984. * @static
  40985. * @memberOf _
  40986. * @since 3.9.0
  40987. * @category Lang
  40988. * @param {*} value The value to compare.
  40989. * @param {*} other The other value to compare.
  40990. * @returns {boolean} Returns `true` if `value` is less than `other`,
  40991. * else `false`.
  40992. * @see _.gt
  40993. * @example
  40994. *
  40995. * _.lt(1, 3);
  40996. * // => true
  40997. *
  40998. * _.lt(3, 3);
  40999. * // => false
  41000. *
  41001. * _.lt(3, 1);
  41002. * // => false
  41003. */var lt=createRelationalOperation(baseLt);/**
  41004. * Checks if `value` is less than or equal to `other`.
  41005. *
  41006. * @static
  41007. * @memberOf _
  41008. * @since 3.9.0
  41009. * @category Lang
  41010. * @param {*} value The value to compare.
  41011. * @param {*} other The other value to compare.
  41012. * @returns {boolean} Returns `true` if `value` is less than or equal to
  41013. * `other`, else `false`.
  41014. * @see _.gte
  41015. * @example
  41016. *
  41017. * _.lte(1, 3);
  41018. * // => true
  41019. *
  41020. * _.lte(3, 3);
  41021. * // => true
  41022. *
  41023. * _.lte(3, 1);
  41024. * // => false
  41025. */var lte=createRelationalOperation(function(value,other){return value<=other;});/**
  41026. * Converts `value` to an array.
  41027. *
  41028. * @static
  41029. * @since 0.1.0
  41030. * @memberOf _
  41031. * @category Lang
  41032. * @param {*} value The value to convert.
  41033. * @returns {Array} Returns the converted array.
  41034. * @example
  41035. *
  41036. * _.toArray({ 'a': 1, 'b': 2 });
  41037. * // => [1, 2]
  41038. *
  41039. * _.toArray('abc');
  41040. * // => ['a', 'b', 'c']
  41041. *
  41042. * _.toArray(1);
  41043. * // => []
  41044. *
  41045. * _.toArray(null);
  41046. * // => []
  41047. */function toArray(value){if(!value){return[];}if(isArrayLike(value)){return isString(value)?stringToArray(value):copyArray(value);}if(symIterator&&value[symIterator]){return iteratorToArray(value[symIterator]());}var tag=getTag(value),func=tag==mapTag?mapToArray:tag==setTag?setToArray:values;return func(value);}/**
  41048. * Converts `value` to a finite number.
  41049. *
  41050. * @static
  41051. * @memberOf _
  41052. * @since 4.12.0
  41053. * @category Lang
  41054. * @param {*} value The value to convert.
  41055. * @returns {number} Returns the converted number.
  41056. * @example
  41057. *
  41058. * _.toFinite(3.2);
  41059. * // => 3.2
  41060. *
  41061. * _.toFinite(Number.MIN_VALUE);
  41062. * // => 5e-324
  41063. *
  41064. * _.toFinite(Infinity);
  41065. * // => 1.7976931348623157e+308
  41066. *
  41067. * _.toFinite('3.2');
  41068. * // => 3.2
  41069. */function toFinite(value){if(!value){return value===0?value:0;}value=toNumber(value);if(value===INFINITY||value===-INFINITY){var sign=value<0?-1:1;return sign*MAX_INTEGER;}return value===value?value:0;}/**
  41070. * Converts `value` to an integer.
  41071. *
  41072. * **Note:** This method is loosely based on
  41073. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  41074. *
  41075. * @static
  41076. * @memberOf _
  41077. * @since 4.0.0
  41078. * @category Lang
  41079. * @param {*} value The value to convert.
  41080. * @returns {number} Returns the converted integer.
  41081. * @example
  41082. *
  41083. * _.toInteger(3.2);
  41084. * // => 3
  41085. *
  41086. * _.toInteger(Number.MIN_VALUE);
  41087. * // => 0
  41088. *
  41089. * _.toInteger(Infinity);
  41090. * // => 1.7976931348623157e+308
  41091. *
  41092. * _.toInteger('3.2');
  41093. * // => 3
  41094. */function toInteger(value){var result=toFinite(value),remainder=result%1;return result===result?remainder?result-remainder:result:0;}/**
  41095. * Converts `value` to an integer suitable for use as the length of an
  41096. * array-like object.
  41097. *
  41098. * **Note:** This method is based on
  41099. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  41100. *
  41101. * @static
  41102. * @memberOf _
  41103. * @since 4.0.0
  41104. * @category Lang
  41105. * @param {*} value The value to convert.
  41106. * @returns {number} Returns the converted integer.
  41107. * @example
  41108. *
  41109. * _.toLength(3.2);
  41110. * // => 3
  41111. *
  41112. * _.toLength(Number.MIN_VALUE);
  41113. * // => 0
  41114. *
  41115. * _.toLength(Infinity);
  41116. * // => 4294967295
  41117. *
  41118. * _.toLength('3.2');
  41119. * // => 3
  41120. */function toLength(value){return value?baseClamp(toInteger(value),0,MAX_ARRAY_LENGTH):0;}/**
  41121. * Converts `value` to a number.
  41122. *
  41123. * @static
  41124. * @memberOf _
  41125. * @since 4.0.0
  41126. * @category Lang
  41127. * @param {*} value The value to process.
  41128. * @returns {number} Returns the number.
  41129. * @example
  41130. *
  41131. * _.toNumber(3.2);
  41132. * // => 3.2
  41133. *
  41134. * _.toNumber(Number.MIN_VALUE);
  41135. * // => 5e-324
  41136. *
  41137. * _.toNumber(Infinity);
  41138. * // => Infinity
  41139. *
  41140. * _.toNumber('3.2');
  41141. * // => 3.2
  41142. */function toNumber(value){if(typeof value=='number'){return value;}if(isSymbol(value)){return NAN;}if(isObject(value)){var other=typeof value.valueOf=='function'?value.valueOf():value;value=isObject(other)?other+'':other;}if(typeof value!='string'){return value===0?value:+value;}value=value.replace(reTrim,'');var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NAN:+value;}/**
  41143. * Converts `value` to a plain object flattening inherited enumerable string
  41144. * keyed properties of `value` to own properties of the plain object.
  41145. *
  41146. * @static
  41147. * @memberOf _
  41148. * @since 3.0.0
  41149. * @category Lang
  41150. * @param {*} value The value to convert.
  41151. * @returns {Object} Returns the converted plain object.
  41152. * @example
  41153. *
  41154. * function Foo() {
  41155. * this.b = 2;
  41156. * }
  41157. *
  41158. * Foo.prototype.c = 3;
  41159. *
  41160. * _.assign({ 'a': 1 }, new Foo);
  41161. * // => { 'a': 1, 'b': 2 }
  41162. *
  41163. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  41164. * // => { 'a': 1, 'b': 2, 'c': 3 }
  41165. */function toPlainObject(value){return copyObject(value,keysIn(value));}/**
  41166. * Converts `value` to a safe integer. A safe integer can be compared and
  41167. * represented correctly.
  41168. *
  41169. * @static
  41170. * @memberOf _
  41171. * @since 4.0.0
  41172. * @category Lang
  41173. * @param {*} value The value to convert.
  41174. * @returns {number} Returns the converted integer.
  41175. * @example
  41176. *
  41177. * _.toSafeInteger(3.2);
  41178. * // => 3
  41179. *
  41180. * _.toSafeInteger(Number.MIN_VALUE);
  41181. * // => 0
  41182. *
  41183. * _.toSafeInteger(Infinity);
  41184. * // => 9007199254740991
  41185. *
  41186. * _.toSafeInteger('3.2');
  41187. * // => 3
  41188. */function toSafeInteger(value){return value?baseClamp(toInteger(value),-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER):value===0?value:0;}/**
  41189. * Converts `value` to a string. An empty string is returned for `null`
  41190. * and `undefined` values. The sign of `-0` is preserved.
  41191. *
  41192. * @static
  41193. * @memberOf _
  41194. * @since 4.0.0
  41195. * @category Lang
  41196. * @param {*} value The value to convert.
  41197. * @returns {string} Returns the converted string.
  41198. * @example
  41199. *
  41200. * _.toString(null);
  41201. * // => ''
  41202. *
  41203. * _.toString(-0);
  41204. * // => '-0'
  41205. *
  41206. * _.toString([1, 2, 3]);
  41207. * // => '1,2,3'
  41208. */function toString(value){return value==null?'':baseToString(value);}/*------------------------------------------------------------------------*//**
  41209. * Assigns own enumerable string keyed properties of source objects to the
  41210. * destination object. Source objects are applied from left to right.
  41211. * Subsequent sources overwrite property assignments of previous sources.
  41212. *
  41213. * **Note:** This method mutates `object` and is loosely based on
  41214. * [`Object.assign`](https://mdn.io/Object/assign).
  41215. *
  41216. * @static
  41217. * @memberOf _
  41218. * @since 0.10.0
  41219. * @category Object
  41220. * @param {Object} object The destination object.
  41221. * @param {...Object} [sources] The source objects.
  41222. * @returns {Object} Returns `object`.
  41223. * @see _.assignIn
  41224. * @example
  41225. *
  41226. * function Foo() {
  41227. * this.a = 1;
  41228. * }
  41229. *
  41230. * function Bar() {
  41231. * this.c = 3;
  41232. * }
  41233. *
  41234. * Foo.prototype.b = 2;
  41235. * Bar.prototype.d = 4;
  41236. *
  41237. * _.assign({ 'a': 0 }, new Foo, new Bar);
  41238. * // => { 'a': 1, 'c': 3 }
  41239. */var assign=createAssigner(function(object,source){if(isPrototype(source)||isArrayLike(source)){copyObject(source,keys(source),object);return;}for(var key in source){if(hasOwnProperty.call(source,key)){assignValue(object,key,source[key]);}}});/**
  41240. * This method is like `_.assign` except that it iterates over own and
  41241. * inherited source properties.
  41242. *
  41243. * **Note:** This method mutates `object`.
  41244. *
  41245. * @static
  41246. * @memberOf _
  41247. * @since 4.0.0
  41248. * @alias extend
  41249. * @category Object
  41250. * @param {Object} object The destination object.
  41251. * @param {...Object} [sources] The source objects.
  41252. * @returns {Object} Returns `object`.
  41253. * @see _.assign
  41254. * @example
  41255. *
  41256. * function Foo() {
  41257. * this.a = 1;
  41258. * }
  41259. *
  41260. * function Bar() {
  41261. * this.c = 3;
  41262. * }
  41263. *
  41264. * Foo.prototype.b = 2;
  41265. * Bar.prototype.d = 4;
  41266. *
  41267. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  41268. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  41269. */var assignIn=createAssigner(function(object,source){copyObject(source,keysIn(source),object);});/**
  41270. * This method is like `_.assignIn` except that it accepts `customizer`
  41271. * which is invoked to produce the assigned values. If `customizer` returns
  41272. * `undefined`, assignment is handled by the method instead. The `customizer`
  41273. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  41274. *
  41275. * **Note:** This method mutates `object`.
  41276. *
  41277. * @static
  41278. * @memberOf _
  41279. * @since 4.0.0
  41280. * @alias extendWith
  41281. * @category Object
  41282. * @param {Object} object The destination object.
  41283. * @param {...Object} sources The source objects.
  41284. * @param {Function} [customizer] The function to customize assigned values.
  41285. * @returns {Object} Returns `object`.
  41286. * @see _.assignWith
  41287. * @example
  41288. *
  41289. * function customizer(objValue, srcValue) {
  41290. * return _.isUndefined(objValue) ? srcValue : objValue;
  41291. * }
  41292. *
  41293. * var defaults = _.partialRight(_.assignInWith, customizer);
  41294. *
  41295. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  41296. * // => { 'a': 1, 'b': 2 }
  41297. */var assignInWith=createAssigner(function(object,source,srcIndex,customizer){copyObject(source,keysIn(source),object,customizer);});/**
  41298. * This method is like `_.assign` except that it accepts `customizer`
  41299. * which is invoked to produce the assigned values. If `customizer` returns
  41300. * `undefined`, assignment is handled by the method instead. The `customizer`
  41301. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  41302. *
  41303. * **Note:** This method mutates `object`.
  41304. *
  41305. * @static
  41306. * @memberOf _
  41307. * @since 4.0.0
  41308. * @category Object
  41309. * @param {Object} object The destination object.
  41310. * @param {...Object} sources The source objects.
  41311. * @param {Function} [customizer] The function to customize assigned values.
  41312. * @returns {Object} Returns `object`.
  41313. * @see _.assignInWith
  41314. * @example
  41315. *
  41316. * function customizer(objValue, srcValue) {
  41317. * return _.isUndefined(objValue) ? srcValue : objValue;
  41318. * }
  41319. *
  41320. * var defaults = _.partialRight(_.assignWith, customizer);
  41321. *
  41322. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  41323. * // => { 'a': 1, 'b': 2 }
  41324. */var assignWith=createAssigner(function(object,source,srcIndex,customizer){copyObject(source,keys(source),object,customizer);});/**
  41325. * Creates an array of values corresponding to `paths` of `object`.
  41326. *
  41327. * @static
  41328. * @memberOf _
  41329. * @since 1.0.0
  41330. * @category Object
  41331. * @param {Object} object The object to iterate over.
  41332. * @param {...(string|string[])} [paths] The property paths to pick.
  41333. * @returns {Array} Returns the picked values.
  41334. * @example
  41335. *
  41336. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  41337. *
  41338. * _.at(object, ['a[0].b.c', 'a[1]']);
  41339. * // => [3, 4]
  41340. */var at=flatRest(baseAt);/**
  41341. * Creates an object that inherits from the `prototype` object. If a
  41342. * `properties` object is given, its own enumerable string keyed properties
  41343. * are assigned to the created object.
  41344. *
  41345. * @static
  41346. * @memberOf _
  41347. * @since 2.3.0
  41348. * @category Object
  41349. * @param {Object} prototype The object to inherit from.
  41350. * @param {Object} [properties] The properties to assign to the object.
  41351. * @returns {Object} Returns the new object.
  41352. * @example
  41353. *
  41354. * function Shape() {
  41355. * this.x = 0;
  41356. * this.y = 0;
  41357. * }
  41358. *
  41359. * function Circle() {
  41360. * Shape.call(this);
  41361. * }
  41362. *
  41363. * Circle.prototype = _.create(Shape.prototype, {
  41364. * 'constructor': Circle
  41365. * });
  41366. *
  41367. * var circle = new Circle;
  41368. * circle instanceof Circle;
  41369. * // => true
  41370. *
  41371. * circle instanceof Shape;
  41372. * // => true
  41373. */function create(prototype,properties){var result=baseCreate(prototype);return properties==null?result:baseAssign(result,properties);}/**
  41374. * Assigns own and inherited enumerable string keyed properties of source
  41375. * objects to the destination object for all destination properties that
  41376. * resolve to `undefined`. Source objects are applied from left to right.
  41377. * Once a property is set, additional values of the same property are ignored.
  41378. *
  41379. * **Note:** This method mutates `object`.
  41380. *
  41381. * @static
  41382. * @since 0.1.0
  41383. * @memberOf _
  41384. * @category Object
  41385. * @param {Object} object The destination object.
  41386. * @param {...Object} [sources] The source objects.
  41387. * @returns {Object} Returns `object`.
  41388. * @see _.defaultsDeep
  41389. * @example
  41390. *
  41391. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  41392. * // => { 'a': 1, 'b': 2 }
  41393. */var defaults=baseRest(function(object,sources){object=Object(object);var index=-1;var length=sources.length;var guard=length>2?sources[2]:undefined;if(guard&&isIterateeCall(sources[0],sources[1],guard)){length=1;}while(++index<length){var source=sources[index];var props=keysIn(source);var propsIndex=-1;var propsLength=props.length;while(++propsIndex<propsLength){var key=props[propsIndex];var value=object[key];if(value===undefined||eq(value,objectProto[key])&&!hasOwnProperty.call(object,key)){object[key]=source[key];}}}return object;});/**
  41394. * This method is like `_.defaults` except that it recursively assigns
  41395. * default properties.
  41396. *
  41397. * **Note:** This method mutates `object`.
  41398. *
  41399. * @static
  41400. * @memberOf _
  41401. * @since 3.10.0
  41402. * @category Object
  41403. * @param {Object} object The destination object.
  41404. * @param {...Object} [sources] The source objects.
  41405. * @returns {Object} Returns `object`.
  41406. * @see _.defaults
  41407. * @example
  41408. *
  41409. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  41410. * // => { 'a': { 'b': 2, 'c': 3 } }
  41411. */var defaultsDeep=baseRest(function(args){args.push(undefined,customDefaultsMerge);return apply(mergeWith,undefined,args);});/**
  41412. * This method is like `_.find` except that it returns the key of the first
  41413. * element `predicate` returns truthy for instead of the element itself.
  41414. *
  41415. * @static
  41416. * @memberOf _
  41417. * @since 1.1.0
  41418. * @category Object
  41419. * @param {Object} object The object to inspect.
  41420. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41421. * @returns {string|undefined} Returns the key of the matched element,
  41422. * else `undefined`.
  41423. * @example
  41424. *
  41425. * var users = {
  41426. * 'barney': { 'age': 36, 'active': true },
  41427. * 'fred': { 'age': 40, 'active': false },
  41428. * 'pebbles': { 'age': 1, 'active': true }
  41429. * };
  41430. *
  41431. * _.findKey(users, function(o) { return o.age < 40; });
  41432. * // => 'barney' (iteration order is not guaranteed)
  41433. *
  41434. * // The `_.matches` iteratee shorthand.
  41435. * _.findKey(users, { 'age': 1, 'active': true });
  41436. * // => 'pebbles'
  41437. *
  41438. * // The `_.matchesProperty` iteratee shorthand.
  41439. * _.findKey(users, ['active', false]);
  41440. * // => 'fred'
  41441. *
  41442. * // The `_.property` iteratee shorthand.
  41443. * _.findKey(users, 'active');
  41444. * // => 'barney'
  41445. */function findKey(object,predicate){return baseFindKey(object,getIteratee(predicate,3),baseForOwn);}/**
  41446. * This method is like `_.findKey` except that it iterates over elements of
  41447. * a collection in the opposite order.
  41448. *
  41449. * @static
  41450. * @memberOf _
  41451. * @since 2.0.0
  41452. * @category Object
  41453. * @param {Object} object The object to inspect.
  41454. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41455. * @returns {string|undefined} Returns the key of the matched element,
  41456. * else `undefined`.
  41457. * @example
  41458. *
  41459. * var users = {
  41460. * 'barney': { 'age': 36, 'active': true },
  41461. * 'fred': { 'age': 40, 'active': false },
  41462. * 'pebbles': { 'age': 1, 'active': true }
  41463. * };
  41464. *
  41465. * _.findLastKey(users, function(o) { return o.age < 40; });
  41466. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  41467. *
  41468. * // The `_.matches` iteratee shorthand.
  41469. * _.findLastKey(users, { 'age': 36, 'active': true });
  41470. * // => 'barney'
  41471. *
  41472. * // The `_.matchesProperty` iteratee shorthand.
  41473. * _.findLastKey(users, ['active', false]);
  41474. * // => 'fred'
  41475. *
  41476. * // The `_.property` iteratee shorthand.
  41477. * _.findLastKey(users, 'active');
  41478. * // => 'pebbles'
  41479. */function findLastKey(object,predicate){return baseFindKey(object,getIteratee(predicate,3),baseForOwnRight);}/**
  41480. * Iterates over own and inherited enumerable string keyed properties of an
  41481. * object and invokes `iteratee` for each property. The iteratee is invoked
  41482. * with three arguments: (value, key, object). Iteratee functions may exit
  41483. * iteration early by explicitly returning `false`.
  41484. *
  41485. * @static
  41486. * @memberOf _
  41487. * @since 0.3.0
  41488. * @category Object
  41489. * @param {Object} object The object to iterate over.
  41490. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41491. * @returns {Object} Returns `object`.
  41492. * @see _.forInRight
  41493. * @example
  41494. *
  41495. * function Foo() {
  41496. * this.a = 1;
  41497. * this.b = 2;
  41498. * }
  41499. *
  41500. * Foo.prototype.c = 3;
  41501. *
  41502. * _.forIn(new Foo, function(value, key) {
  41503. * console.log(key);
  41504. * });
  41505. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  41506. */function forIn(object,iteratee){return object==null?object:baseFor(object,getIteratee(iteratee,3),keysIn);}/**
  41507. * This method is like `_.forIn` except that it iterates over properties of
  41508. * `object` in the opposite order.
  41509. *
  41510. * @static
  41511. * @memberOf _
  41512. * @since 2.0.0
  41513. * @category Object
  41514. * @param {Object} object The object to iterate over.
  41515. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41516. * @returns {Object} Returns `object`.
  41517. * @see _.forIn
  41518. * @example
  41519. *
  41520. * function Foo() {
  41521. * this.a = 1;
  41522. * this.b = 2;
  41523. * }
  41524. *
  41525. * Foo.prototype.c = 3;
  41526. *
  41527. * _.forInRight(new Foo, function(value, key) {
  41528. * console.log(key);
  41529. * });
  41530. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  41531. */function forInRight(object,iteratee){return object==null?object:baseForRight(object,getIteratee(iteratee,3),keysIn);}/**
  41532. * Iterates over own enumerable string keyed properties of an object and
  41533. * invokes `iteratee` for each property. The iteratee is invoked with three
  41534. * arguments: (value, key, object). Iteratee functions may exit iteration
  41535. * early by explicitly returning `false`.
  41536. *
  41537. * @static
  41538. * @memberOf _
  41539. * @since 0.3.0
  41540. * @category Object
  41541. * @param {Object} object The object to iterate over.
  41542. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41543. * @returns {Object} Returns `object`.
  41544. * @see _.forOwnRight
  41545. * @example
  41546. *
  41547. * function Foo() {
  41548. * this.a = 1;
  41549. * this.b = 2;
  41550. * }
  41551. *
  41552. * Foo.prototype.c = 3;
  41553. *
  41554. * _.forOwn(new Foo, function(value, key) {
  41555. * console.log(key);
  41556. * });
  41557. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  41558. */function forOwn(object,iteratee){return object&&baseForOwn(object,getIteratee(iteratee,3));}/**
  41559. * This method is like `_.forOwn` except that it iterates over properties of
  41560. * `object` in the opposite order.
  41561. *
  41562. * @static
  41563. * @memberOf _
  41564. * @since 2.0.0
  41565. * @category Object
  41566. * @param {Object} object The object to iterate over.
  41567. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41568. * @returns {Object} Returns `object`.
  41569. * @see _.forOwn
  41570. * @example
  41571. *
  41572. * function Foo() {
  41573. * this.a = 1;
  41574. * this.b = 2;
  41575. * }
  41576. *
  41577. * Foo.prototype.c = 3;
  41578. *
  41579. * _.forOwnRight(new Foo, function(value, key) {
  41580. * console.log(key);
  41581. * });
  41582. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  41583. */function forOwnRight(object,iteratee){return object&&baseForOwnRight(object,getIteratee(iteratee,3));}/**
  41584. * Creates an array of function property names from own enumerable properties
  41585. * of `object`.
  41586. *
  41587. * @static
  41588. * @since 0.1.0
  41589. * @memberOf _
  41590. * @category Object
  41591. * @param {Object} object The object to inspect.
  41592. * @returns {Array} Returns the function names.
  41593. * @see _.functionsIn
  41594. * @example
  41595. *
  41596. * function Foo() {
  41597. * this.a = _.constant('a');
  41598. * this.b = _.constant('b');
  41599. * }
  41600. *
  41601. * Foo.prototype.c = _.constant('c');
  41602. *
  41603. * _.functions(new Foo);
  41604. * // => ['a', 'b']
  41605. */function functions(object){return object==null?[]:baseFunctions(object,keys(object));}/**
  41606. * Creates an array of function property names from own and inherited
  41607. * enumerable properties of `object`.
  41608. *
  41609. * @static
  41610. * @memberOf _
  41611. * @since 4.0.0
  41612. * @category Object
  41613. * @param {Object} object The object to inspect.
  41614. * @returns {Array} Returns the function names.
  41615. * @see _.functions
  41616. * @example
  41617. *
  41618. * function Foo() {
  41619. * this.a = _.constant('a');
  41620. * this.b = _.constant('b');
  41621. * }
  41622. *
  41623. * Foo.prototype.c = _.constant('c');
  41624. *
  41625. * _.functionsIn(new Foo);
  41626. * // => ['a', 'b', 'c']
  41627. */function functionsIn(object){return object==null?[]:baseFunctions(object,keysIn(object));}/**
  41628. * Gets the value at `path` of `object`. If the resolved value is
  41629. * `undefined`, the `defaultValue` is returned in its place.
  41630. *
  41631. * @static
  41632. * @memberOf _
  41633. * @since 3.7.0
  41634. * @category Object
  41635. * @param {Object} object The object to query.
  41636. * @param {Array|string} path The path of the property to get.
  41637. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  41638. * @returns {*} Returns the resolved value.
  41639. * @example
  41640. *
  41641. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  41642. *
  41643. * _.get(object, 'a[0].b.c');
  41644. * // => 3
  41645. *
  41646. * _.get(object, ['a', '0', 'b', 'c']);
  41647. * // => 3
  41648. *
  41649. * _.get(object, 'a.b.c', 'default');
  41650. * // => 'default'
  41651. */function get(object,path,defaultValue){var result=object==null?undefined:baseGet(object,path);return result===undefined?defaultValue:result;}/**
  41652. * Checks if `path` is a direct property of `object`.
  41653. *
  41654. * @static
  41655. * @since 0.1.0
  41656. * @memberOf _
  41657. * @category Object
  41658. * @param {Object} object The object to query.
  41659. * @param {Array|string} path The path to check.
  41660. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  41661. * @example
  41662. *
  41663. * var object = { 'a': { 'b': 2 } };
  41664. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  41665. *
  41666. * _.has(object, 'a');
  41667. * // => true
  41668. *
  41669. * _.has(object, 'a.b');
  41670. * // => true
  41671. *
  41672. * _.has(object, ['a', 'b']);
  41673. * // => true
  41674. *
  41675. * _.has(other, 'a');
  41676. * // => false
  41677. */function has(object,path){return object!=null&&hasPath(object,path,baseHas);}/**
  41678. * Checks if `path` is a direct or inherited property of `object`.
  41679. *
  41680. * @static
  41681. * @memberOf _
  41682. * @since 4.0.0
  41683. * @category Object
  41684. * @param {Object} object The object to query.
  41685. * @param {Array|string} path The path to check.
  41686. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  41687. * @example
  41688. *
  41689. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  41690. *
  41691. * _.hasIn(object, 'a');
  41692. * // => true
  41693. *
  41694. * _.hasIn(object, 'a.b');
  41695. * // => true
  41696. *
  41697. * _.hasIn(object, ['a', 'b']);
  41698. * // => true
  41699. *
  41700. * _.hasIn(object, 'b');
  41701. * // => false
  41702. */function hasIn(object,path){return object!=null&&hasPath(object,path,baseHasIn);}/**
  41703. * Creates an object composed of the inverted keys and values of `object`.
  41704. * If `object` contains duplicate values, subsequent values overwrite
  41705. * property assignments of previous values.
  41706. *
  41707. * @static
  41708. * @memberOf _
  41709. * @since 0.7.0
  41710. * @category Object
  41711. * @param {Object} object The object to invert.
  41712. * @returns {Object} Returns the new inverted object.
  41713. * @example
  41714. *
  41715. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  41716. *
  41717. * _.invert(object);
  41718. * // => { '1': 'c', '2': 'b' }
  41719. */var invert=createInverter(function(result,value,key){if(value!=null&&typeof value.toString!='function'){value=nativeObjectToString.call(value);}result[value]=key;},constant(identity));/**
  41720. * This method is like `_.invert` except that the inverted object is generated
  41721. * from the results of running each element of `object` thru `iteratee`. The
  41722. * corresponding inverted value of each inverted key is an array of keys
  41723. * responsible for generating the inverted value. The iteratee is invoked
  41724. * with one argument: (value).
  41725. *
  41726. * @static
  41727. * @memberOf _
  41728. * @since 4.1.0
  41729. * @category Object
  41730. * @param {Object} object The object to invert.
  41731. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  41732. * @returns {Object} Returns the new inverted object.
  41733. * @example
  41734. *
  41735. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  41736. *
  41737. * _.invertBy(object);
  41738. * // => { '1': ['a', 'c'], '2': ['b'] }
  41739. *
  41740. * _.invertBy(object, function(value) {
  41741. * return 'group' + value;
  41742. * });
  41743. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  41744. */var invertBy=createInverter(function(result,value,key){if(value!=null&&typeof value.toString!='function'){value=nativeObjectToString.call(value);}if(hasOwnProperty.call(result,value)){result[value].push(key);}else{result[value]=[key];}},getIteratee);/**
  41745. * Invokes the method at `path` of `object`.
  41746. *
  41747. * @static
  41748. * @memberOf _
  41749. * @since 4.0.0
  41750. * @category Object
  41751. * @param {Object} object The object to query.
  41752. * @param {Array|string} path The path of the method to invoke.
  41753. * @param {...*} [args] The arguments to invoke the method with.
  41754. * @returns {*} Returns the result of the invoked method.
  41755. * @example
  41756. *
  41757. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  41758. *
  41759. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  41760. * // => [2, 3]
  41761. */var invoke=baseRest(baseInvoke);/**
  41762. * Creates an array of the own enumerable property names of `object`.
  41763. *
  41764. * **Note:** Non-object values are coerced to objects. See the
  41765. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  41766. * for more details.
  41767. *
  41768. * @static
  41769. * @since 0.1.0
  41770. * @memberOf _
  41771. * @category Object
  41772. * @param {Object} object The object to query.
  41773. * @returns {Array} Returns the array of property names.
  41774. * @example
  41775. *
  41776. * function Foo() {
  41777. * this.a = 1;
  41778. * this.b = 2;
  41779. * }
  41780. *
  41781. * Foo.prototype.c = 3;
  41782. *
  41783. * _.keys(new Foo);
  41784. * // => ['a', 'b'] (iteration order is not guaranteed)
  41785. *
  41786. * _.keys('hi');
  41787. * // => ['0', '1']
  41788. */function keys(object){return isArrayLike(object)?arrayLikeKeys(object):baseKeys(object);}/**
  41789. * Creates an array of the own and inherited enumerable property names of `object`.
  41790. *
  41791. * **Note:** Non-object values are coerced to objects.
  41792. *
  41793. * @static
  41794. * @memberOf _
  41795. * @since 3.0.0
  41796. * @category Object
  41797. * @param {Object} object The object to query.
  41798. * @returns {Array} Returns the array of property names.
  41799. * @example
  41800. *
  41801. * function Foo() {
  41802. * this.a = 1;
  41803. * this.b = 2;
  41804. * }
  41805. *
  41806. * Foo.prototype.c = 3;
  41807. *
  41808. * _.keysIn(new Foo);
  41809. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  41810. */function keysIn(object){return isArrayLike(object)?arrayLikeKeys(object,true):baseKeysIn(object);}/**
  41811. * The opposite of `_.mapValues`; this method creates an object with the
  41812. * same values as `object` and keys generated by running each own enumerable
  41813. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  41814. * with three arguments: (value, key, object).
  41815. *
  41816. * @static
  41817. * @memberOf _
  41818. * @since 3.8.0
  41819. * @category Object
  41820. * @param {Object} object The object to iterate over.
  41821. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41822. * @returns {Object} Returns the new mapped object.
  41823. * @see _.mapValues
  41824. * @example
  41825. *
  41826. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  41827. * return key + value;
  41828. * });
  41829. * // => { 'a1': 1, 'b2': 2 }
  41830. */function mapKeys(object,iteratee){var result={};iteratee=getIteratee(iteratee,3);baseForOwn(object,function(value,key,object){baseAssignValue(result,iteratee(value,key,object),value);});return result;}/**
  41831. * Creates an object with the same keys as `object` and values generated
  41832. * by running each own enumerable string keyed property of `object` thru
  41833. * `iteratee`. The iteratee is invoked with three arguments:
  41834. * (value, key, object).
  41835. *
  41836. * @static
  41837. * @memberOf _
  41838. * @since 2.4.0
  41839. * @category Object
  41840. * @param {Object} object The object to iterate over.
  41841. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41842. * @returns {Object} Returns the new mapped object.
  41843. * @see _.mapKeys
  41844. * @example
  41845. *
  41846. * var users = {
  41847. * 'fred': { 'user': 'fred', 'age': 40 },
  41848. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  41849. * };
  41850. *
  41851. * _.mapValues(users, function(o) { return o.age; });
  41852. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  41853. *
  41854. * // The `_.property` iteratee shorthand.
  41855. * _.mapValues(users, 'age');
  41856. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  41857. */function mapValues(object,iteratee){var result={};iteratee=getIteratee(iteratee,3);baseForOwn(object,function(value,key,object){baseAssignValue(result,key,iteratee(value,key,object));});return result;}/**
  41858. * This method is like `_.assign` except that it recursively merges own and
  41859. * inherited enumerable string keyed properties of source objects into the
  41860. * destination object. Source properties that resolve to `undefined` are
  41861. * skipped if a destination value exists. Array and plain object properties
  41862. * are merged recursively. Other objects and value types are overridden by
  41863. * assignment. Source objects are applied from left to right. Subsequent
  41864. * sources overwrite property assignments of previous sources.
  41865. *
  41866. * **Note:** This method mutates `object`.
  41867. *
  41868. * @static
  41869. * @memberOf _
  41870. * @since 0.5.0
  41871. * @category Object
  41872. * @param {Object} object The destination object.
  41873. * @param {...Object} [sources] The source objects.
  41874. * @returns {Object} Returns `object`.
  41875. * @example
  41876. *
  41877. * var object = {
  41878. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  41879. * };
  41880. *
  41881. * var other = {
  41882. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  41883. * };
  41884. *
  41885. * _.merge(object, other);
  41886. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  41887. */var merge=createAssigner(function(object,source,srcIndex){baseMerge(object,source,srcIndex);});/**
  41888. * This method is like `_.merge` except that it accepts `customizer` which
  41889. * is invoked to produce the merged values of the destination and source
  41890. * properties. If `customizer` returns `undefined`, merging is handled by the
  41891. * method instead. The `customizer` is invoked with six arguments:
  41892. * (objValue, srcValue, key, object, source, stack).
  41893. *
  41894. * **Note:** This method mutates `object`.
  41895. *
  41896. * @static
  41897. * @memberOf _
  41898. * @since 4.0.0
  41899. * @category Object
  41900. * @param {Object} object The destination object.
  41901. * @param {...Object} sources The source objects.
  41902. * @param {Function} customizer The function to customize assigned values.
  41903. * @returns {Object} Returns `object`.
  41904. * @example
  41905. *
  41906. * function customizer(objValue, srcValue) {
  41907. * if (_.isArray(objValue)) {
  41908. * return objValue.concat(srcValue);
  41909. * }
  41910. * }
  41911. *
  41912. * var object = { 'a': [1], 'b': [2] };
  41913. * var other = { 'a': [3], 'b': [4] };
  41914. *
  41915. * _.mergeWith(object, other, customizer);
  41916. * // => { 'a': [1, 3], 'b': [2, 4] }
  41917. */var mergeWith=createAssigner(function(object,source,srcIndex,customizer){baseMerge(object,source,srcIndex,customizer);});/**
  41918. * The opposite of `_.pick`; this method creates an object composed of the
  41919. * own and inherited enumerable property paths of `object` that are not omitted.
  41920. *
  41921. * **Note:** This method is considerably slower than `_.pick`.
  41922. *
  41923. * @static
  41924. * @since 0.1.0
  41925. * @memberOf _
  41926. * @category Object
  41927. * @param {Object} object The source object.
  41928. * @param {...(string|string[])} [paths] The property paths to omit.
  41929. * @returns {Object} Returns the new object.
  41930. * @example
  41931. *
  41932. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  41933. *
  41934. * _.omit(object, ['a', 'c']);
  41935. * // => { 'b': '2' }
  41936. */var omit=flatRest(function(object,paths){var result={};if(object==null){return result;}var isDeep=false;paths=arrayMap(paths,function(path){path=castPath(path,object);isDeep||(isDeep=path.length>1);return path;});copyObject(object,getAllKeysIn(object),result);if(isDeep){result=baseClone(result,CLONE_DEEP_FLAG|CLONE_FLAT_FLAG|CLONE_SYMBOLS_FLAG,customOmitClone);}var length=paths.length;while(length--){baseUnset(result,paths[length]);}return result;});/**
  41937. * The opposite of `_.pickBy`; this method creates an object composed of
  41938. * the own and inherited enumerable string keyed properties of `object` that
  41939. * `predicate` doesn't return truthy for. The predicate is invoked with two
  41940. * arguments: (value, key).
  41941. *
  41942. * @static
  41943. * @memberOf _
  41944. * @since 4.0.0
  41945. * @category Object
  41946. * @param {Object} object The source object.
  41947. * @param {Function} [predicate=_.identity] The function invoked per property.
  41948. * @returns {Object} Returns the new object.
  41949. * @example
  41950. *
  41951. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  41952. *
  41953. * _.omitBy(object, _.isNumber);
  41954. * // => { 'b': '2' }
  41955. */function omitBy(object,predicate){return pickBy(object,negate(getIteratee(predicate)));}/**
  41956. * Creates an object composed of the picked `object` properties.
  41957. *
  41958. * @static
  41959. * @since 0.1.0
  41960. * @memberOf _
  41961. * @category Object
  41962. * @param {Object} object The source object.
  41963. * @param {...(string|string[])} [paths] The property paths to pick.
  41964. * @returns {Object} Returns the new object.
  41965. * @example
  41966. *
  41967. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  41968. *
  41969. * _.pick(object, ['a', 'c']);
  41970. * // => { 'a': 1, 'c': 3 }
  41971. */var pick=flatRest(function(object,paths){return object==null?{}:basePick(object,paths);});/**
  41972. * Creates an object composed of the `object` properties `predicate` returns
  41973. * truthy for. The predicate is invoked with two arguments: (value, key).
  41974. *
  41975. * @static
  41976. * @memberOf _
  41977. * @since 4.0.0
  41978. * @category Object
  41979. * @param {Object} object The source object.
  41980. * @param {Function} [predicate=_.identity] The function invoked per property.
  41981. * @returns {Object} Returns the new object.
  41982. * @example
  41983. *
  41984. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  41985. *
  41986. * _.pickBy(object, _.isNumber);
  41987. * // => { 'a': 1, 'c': 3 }
  41988. */function pickBy(object,predicate){if(object==null){return{};}var props=arrayMap(getAllKeysIn(object),function(prop){return[prop];});predicate=getIteratee(predicate);return basePickBy(object,props,function(value,path){return predicate(value,path[0]);});}/**
  41989. * This method is like `_.get` except that if the resolved value is a
  41990. * function it's invoked with the `this` binding of its parent object and
  41991. * its result is returned.
  41992. *
  41993. * @static
  41994. * @since 0.1.0
  41995. * @memberOf _
  41996. * @category Object
  41997. * @param {Object} object The object to query.
  41998. * @param {Array|string} path The path of the property to resolve.
  41999. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  42000. * @returns {*} Returns the resolved value.
  42001. * @example
  42002. *
  42003. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  42004. *
  42005. * _.result(object, 'a[0].b.c1');
  42006. * // => 3
  42007. *
  42008. * _.result(object, 'a[0].b.c2');
  42009. * // => 4
  42010. *
  42011. * _.result(object, 'a[0].b.c3', 'default');
  42012. * // => 'default'
  42013. *
  42014. * _.result(object, 'a[0].b.c3', _.constant('default'));
  42015. * // => 'default'
  42016. */function result(object,path,defaultValue){path=castPath(path,object);var index=-1,length=path.length;// Ensure the loop is entered when path is empty.
  42017. if(!length){length=1;object=undefined;}while(++index<length){var value=object==null?undefined:object[toKey(path[index])];if(value===undefined){index=length;value=defaultValue;}object=isFunction(value)?value.call(object):value;}return object;}/**
  42018. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  42019. * it's created. Arrays are created for missing index properties while objects
  42020. * are created for all other missing properties. Use `_.setWith` to customize
  42021. * `path` creation.
  42022. *
  42023. * **Note:** This method mutates `object`.
  42024. *
  42025. * @static
  42026. * @memberOf _
  42027. * @since 3.7.0
  42028. * @category Object
  42029. * @param {Object} object The object to modify.
  42030. * @param {Array|string} path The path of the property to set.
  42031. * @param {*} value The value to set.
  42032. * @returns {Object} Returns `object`.
  42033. * @example
  42034. *
  42035. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  42036. *
  42037. * _.set(object, 'a[0].b.c', 4);
  42038. * console.log(object.a[0].b.c);
  42039. * // => 4
  42040. *
  42041. * _.set(object, ['x', '0', 'y', 'z'], 5);
  42042. * console.log(object.x[0].y.z);
  42043. * // => 5
  42044. */function set(object,path,value){return object==null?object:baseSet(object,path,value);}/**
  42045. * This method is like `_.set` except that it accepts `customizer` which is
  42046. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  42047. * path creation is handled by the method instead. The `customizer` is invoked
  42048. * with three arguments: (nsValue, key, nsObject).
  42049. *
  42050. * **Note:** This method mutates `object`.
  42051. *
  42052. * @static
  42053. * @memberOf _
  42054. * @since 4.0.0
  42055. * @category Object
  42056. * @param {Object} object The object to modify.
  42057. * @param {Array|string} path The path of the property to set.
  42058. * @param {*} value The value to set.
  42059. * @param {Function} [customizer] The function to customize assigned values.
  42060. * @returns {Object} Returns `object`.
  42061. * @example
  42062. *
  42063. * var object = {};
  42064. *
  42065. * _.setWith(object, '[0][1]', 'a', Object);
  42066. * // => { '0': { '1': 'a' } }
  42067. */function setWith(object,path,value,customizer){customizer=typeof customizer=='function'?customizer:undefined;return object==null?object:baseSet(object,path,value,customizer);}/**
  42068. * Creates an array of own enumerable string keyed-value pairs for `object`
  42069. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  42070. * entries are returned.
  42071. *
  42072. * @static
  42073. * @memberOf _
  42074. * @since 4.0.0
  42075. * @alias entries
  42076. * @category Object
  42077. * @param {Object} object The object to query.
  42078. * @returns {Array} Returns the key-value pairs.
  42079. * @example
  42080. *
  42081. * function Foo() {
  42082. * this.a = 1;
  42083. * this.b = 2;
  42084. * }
  42085. *
  42086. * Foo.prototype.c = 3;
  42087. *
  42088. * _.toPairs(new Foo);
  42089. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  42090. */var toPairs=createToPairs(keys);/**
  42091. * Creates an array of own and inherited enumerable string keyed-value pairs
  42092. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  42093. * or set, its entries are returned.
  42094. *
  42095. * @static
  42096. * @memberOf _
  42097. * @since 4.0.0
  42098. * @alias entriesIn
  42099. * @category Object
  42100. * @param {Object} object The object to query.
  42101. * @returns {Array} Returns the key-value pairs.
  42102. * @example
  42103. *
  42104. * function Foo() {
  42105. * this.a = 1;
  42106. * this.b = 2;
  42107. * }
  42108. *
  42109. * Foo.prototype.c = 3;
  42110. *
  42111. * _.toPairsIn(new Foo);
  42112. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  42113. */var toPairsIn=createToPairs(keysIn);/**
  42114. * An alternative to `_.reduce`; this method transforms `object` to a new
  42115. * `accumulator` object which is the result of running each of its own
  42116. * enumerable string keyed properties thru `iteratee`, with each invocation
  42117. * potentially mutating the `accumulator` object. If `accumulator` is not
  42118. * provided, a new object with the same `[[Prototype]]` will be used. The
  42119. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  42120. * Iteratee functions may exit iteration early by explicitly returning `false`.
  42121. *
  42122. * @static
  42123. * @memberOf _
  42124. * @since 1.3.0
  42125. * @category Object
  42126. * @param {Object} object The object to iterate over.
  42127. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  42128. * @param {*} [accumulator] The custom accumulator value.
  42129. * @returns {*} Returns the accumulated value.
  42130. * @example
  42131. *
  42132. * _.transform([2, 3, 4], function(result, n) {
  42133. * result.push(n *= n);
  42134. * return n % 2 == 0;
  42135. * }, []);
  42136. * // => [4, 9]
  42137. *
  42138. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  42139. * (result[value] || (result[value] = [])).push(key);
  42140. * }, {});
  42141. * // => { '1': ['a', 'c'], '2': ['b'] }
  42142. */function transform(object,iteratee,accumulator){var isArr=isArray(object),isArrLike=isArr||isBuffer(object)||isTypedArray(object);iteratee=getIteratee(iteratee,4);if(accumulator==null){var Ctor=object&&object.constructor;if(isArrLike){accumulator=isArr?new Ctor():[];}else if(isObject(object)){accumulator=isFunction(Ctor)?baseCreate(getPrototype(object)):{};}else{accumulator={};}}(isArrLike?arrayEach:baseForOwn)(object,function(value,index,object){return iteratee(accumulator,value,index,object);});return accumulator;}/**
  42143. * Removes the property at `path` of `object`.
  42144. *
  42145. * **Note:** This method mutates `object`.
  42146. *
  42147. * @static
  42148. * @memberOf _
  42149. * @since 4.0.0
  42150. * @category Object
  42151. * @param {Object} object The object to modify.
  42152. * @param {Array|string} path The path of the property to unset.
  42153. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  42154. * @example
  42155. *
  42156. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  42157. * _.unset(object, 'a[0].b.c');
  42158. * // => true
  42159. *
  42160. * console.log(object);
  42161. * // => { 'a': [{ 'b': {} }] };
  42162. *
  42163. * _.unset(object, ['a', '0', 'b', 'c']);
  42164. * // => true
  42165. *
  42166. * console.log(object);
  42167. * // => { 'a': [{ 'b': {} }] };
  42168. */function unset(object,path){return object==null?true:baseUnset(object,path);}/**
  42169. * This method is like `_.set` except that accepts `updater` to produce the
  42170. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  42171. * is invoked with one argument: (value).
  42172. *
  42173. * **Note:** This method mutates `object`.
  42174. *
  42175. * @static
  42176. * @memberOf _
  42177. * @since 4.6.0
  42178. * @category Object
  42179. * @param {Object} object The object to modify.
  42180. * @param {Array|string} path The path of the property to set.
  42181. * @param {Function} updater The function to produce the updated value.
  42182. * @returns {Object} Returns `object`.
  42183. * @example
  42184. *
  42185. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  42186. *
  42187. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  42188. * console.log(object.a[0].b.c);
  42189. * // => 9
  42190. *
  42191. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  42192. * console.log(object.x[0].y.z);
  42193. * // => 0
  42194. */function update(object,path,updater){return object==null?object:baseUpdate(object,path,castFunction(updater));}/**
  42195. * This method is like `_.update` except that it accepts `customizer` which is
  42196. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  42197. * path creation is handled by the method instead. The `customizer` is invoked
  42198. * with three arguments: (nsValue, key, nsObject).
  42199. *
  42200. * **Note:** This method mutates `object`.
  42201. *
  42202. * @static
  42203. * @memberOf _
  42204. * @since 4.6.0
  42205. * @category Object
  42206. * @param {Object} object The object to modify.
  42207. * @param {Array|string} path The path of the property to set.
  42208. * @param {Function} updater The function to produce the updated value.
  42209. * @param {Function} [customizer] The function to customize assigned values.
  42210. * @returns {Object} Returns `object`.
  42211. * @example
  42212. *
  42213. * var object = {};
  42214. *
  42215. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  42216. * // => { '0': { '1': 'a' } }
  42217. */function updateWith(object,path,updater,customizer){customizer=typeof customizer=='function'?customizer:undefined;return object==null?object:baseUpdate(object,path,castFunction(updater),customizer);}/**
  42218. * Creates an array of the own enumerable string keyed property values of `object`.
  42219. *
  42220. * **Note:** Non-object values are coerced to objects.
  42221. *
  42222. * @static
  42223. * @since 0.1.0
  42224. * @memberOf _
  42225. * @category Object
  42226. * @param {Object} object The object to query.
  42227. * @returns {Array} Returns the array of property values.
  42228. * @example
  42229. *
  42230. * function Foo() {
  42231. * this.a = 1;
  42232. * this.b = 2;
  42233. * }
  42234. *
  42235. * Foo.prototype.c = 3;
  42236. *
  42237. * _.values(new Foo);
  42238. * // => [1, 2] (iteration order is not guaranteed)
  42239. *
  42240. * _.values('hi');
  42241. * // => ['h', 'i']
  42242. */function values(object){return object==null?[]:baseValues(object,keys(object));}/**
  42243. * Creates an array of the own and inherited enumerable string keyed property
  42244. * values of `object`.
  42245. *
  42246. * **Note:** Non-object values are coerced to objects.
  42247. *
  42248. * @static
  42249. * @memberOf _
  42250. * @since 3.0.0
  42251. * @category Object
  42252. * @param {Object} object The object to query.
  42253. * @returns {Array} Returns the array of property values.
  42254. * @example
  42255. *
  42256. * function Foo() {
  42257. * this.a = 1;
  42258. * this.b = 2;
  42259. * }
  42260. *
  42261. * Foo.prototype.c = 3;
  42262. *
  42263. * _.valuesIn(new Foo);
  42264. * // => [1, 2, 3] (iteration order is not guaranteed)
  42265. */function valuesIn(object){return object==null?[]:baseValues(object,keysIn(object));}/*------------------------------------------------------------------------*//**
  42266. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  42267. *
  42268. * @static
  42269. * @memberOf _
  42270. * @since 4.0.0
  42271. * @category Number
  42272. * @param {number} number The number to clamp.
  42273. * @param {number} [lower] The lower bound.
  42274. * @param {number} upper The upper bound.
  42275. * @returns {number} Returns the clamped number.
  42276. * @example
  42277. *
  42278. * _.clamp(-10, -5, 5);
  42279. * // => -5
  42280. *
  42281. * _.clamp(10, -5, 5);
  42282. * // => 5
  42283. */function clamp(number,lower,upper){if(upper===undefined){upper=lower;lower=undefined;}if(upper!==undefined){upper=toNumber(upper);upper=upper===upper?upper:0;}if(lower!==undefined){lower=toNumber(lower);lower=lower===lower?lower:0;}return baseClamp(toNumber(number),lower,upper);}/**
  42284. * Checks if `n` is between `start` and up to, but not including, `end`. If
  42285. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  42286. * If `start` is greater than `end` the params are swapped to support
  42287. * negative ranges.
  42288. *
  42289. * @static
  42290. * @memberOf _
  42291. * @since 3.3.0
  42292. * @category Number
  42293. * @param {number} number The number to check.
  42294. * @param {number} [start=0] The start of the range.
  42295. * @param {number} end The end of the range.
  42296. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  42297. * @see _.range, _.rangeRight
  42298. * @example
  42299. *
  42300. * _.inRange(3, 2, 4);
  42301. * // => true
  42302. *
  42303. * _.inRange(4, 8);
  42304. * // => true
  42305. *
  42306. * _.inRange(4, 2);
  42307. * // => false
  42308. *
  42309. * _.inRange(2, 2);
  42310. * // => false
  42311. *
  42312. * _.inRange(1.2, 2);
  42313. * // => true
  42314. *
  42315. * _.inRange(5.2, 4);
  42316. * // => false
  42317. *
  42318. * _.inRange(-3, -2, -6);
  42319. * // => true
  42320. */function inRange(number,start,end){start=toFinite(start);if(end===undefined){end=start;start=0;}else{end=toFinite(end);}number=toNumber(number);return baseInRange(number,start,end);}/**
  42321. * Produces a random number between the inclusive `lower` and `upper` bounds.
  42322. * If only one argument is provided a number between `0` and the given number
  42323. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  42324. * floats, a floating-point number is returned instead of an integer.
  42325. *
  42326. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  42327. * floating-point values which can produce unexpected results.
  42328. *
  42329. * @static
  42330. * @memberOf _
  42331. * @since 0.7.0
  42332. * @category Number
  42333. * @param {number} [lower=0] The lower bound.
  42334. * @param {number} [upper=1] The upper bound.
  42335. * @param {boolean} [floating] Specify returning a floating-point number.
  42336. * @returns {number} Returns the random number.
  42337. * @example
  42338. *
  42339. * _.random(0, 5);
  42340. * // => an integer between 0 and 5
  42341. *
  42342. * _.random(5);
  42343. * // => also an integer between 0 and 5
  42344. *
  42345. * _.random(5, true);
  42346. * // => a floating-point number between 0 and 5
  42347. *
  42348. * _.random(1.2, 5.2);
  42349. * // => a floating-point number between 1.2 and 5.2
  42350. */function random(lower,upper,floating){if(floating&&typeof floating!='boolean'&&isIterateeCall(lower,upper,floating)){upper=floating=undefined;}if(floating===undefined){if(typeof upper=='boolean'){floating=upper;upper=undefined;}else if(typeof lower=='boolean'){floating=lower;lower=undefined;}}if(lower===undefined&&upper===undefined){lower=0;upper=1;}else{lower=toFinite(lower);if(upper===undefined){upper=lower;lower=0;}else{upper=toFinite(upper);}}if(lower>upper){var temp=lower;lower=upper;upper=temp;}if(floating||lower%1||upper%1){var rand=nativeRandom();return nativeMin(lower+rand*(upper-lower+freeParseFloat('1e-'+((rand+'').length-1))),upper);}return baseRandom(lower,upper);}/*------------------------------------------------------------------------*//**
  42351. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  42352. *
  42353. * @static
  42354. * @memberOf _
  42355. * @since 3.0.0
  42356. * @category String
  42357. * @param {string} [string=''] The string to convert.
  42358. * @returns {string} Returns the camel cased string.
  42359. * @example
  42360. *
  42361. * _.camelCase('Foo Bar');
  42362. * // => 'fooBar'
  42363. *
  42364. * _.camelCase('--foo-bar--');
  42365. * // => 'fooBar'
  42366. *
  42367. * _.camelCase('__FOO_BAR__');
  42368. * // => 'fooBar'
  42369. */var camelCase=createCompounder(function(result,word,index){word=word.toLowerCase();return result+(index?capitalize(word):word);});/**
  42370. * Converts the first character of `string` to upper case and the remaining
  42371. * to lower case.
  42372. *
  42373. * @static
  42374. * @memberOf _
  42375. * @since 3.0.0
  42376. * @category String
  42377. * @param {string} [string=''] The string to capitalize.
  42378. * @returns {string} Returns the capitalized string.
  42379. * @example
  42380. *
  42381. * _.capitalize('FRED');
  42382. * // => 'Fred'
  42383. */function capitalize(string){return upperFirst(toString(string).toLowerCase());}/**
  42384. * Deburrs `string` by converting
  42385. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  42386. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  42387. * letters to basic Latin letters and removing
  42388. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  42389. *
  42390. * @static
  42391. * @memberOf _
  42392. * @since 3.0.0
  42393. * @category String
  42394. * @param {string} [string=''] The string to deburr.
  42395. * @returns {string} Returns the deburred string.
  42396. * @example
  42397. *
  42398. * _.deburr('déjà vu');
  42399. * // => 'deja vu'
  42400. */function deburr(string){string=toString(string);return string&&string.replace(reLatin,deburrLetter).replace(reComboMark,'');}/**
  42401. * Checks if `string` ends with the given target string.
  42402. *
  42403. * @static
  42404. * @memberOf _
  42405. * @since 3.0.0
  42406. * @category String
  42407. * @param {string} [string=''] The string to inspect.
  42408. * @param {string} [target] The string to search for.
  42409. * @param {number} [position=string.length] The position to search up to.
  42410. * @returns {boolean} Returns `true` if `string` ends with `target`,
  42411. * else `false`.
  42412. * @example
  42413. *
  42414. * _.endsWith('abc', 'c');
  42415. * // => true
  42416. *
  42417. * _.endsWith('abc', 'b');
  42418. * // => false
  42419. *
  42420. * _.endsWith('abc', 'b', 2);
  42421. * // => true
  42422. */function endsWith(string,target,position){string=toString(string);target=baseToString(target);var length=string.length;position=position===undefined?length:baseClamp(toInteger(position),0,length);var end=position;position-=target.length;return position>=0&&string.slice(position,end)==target;}/**
  42423. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  42424. * corresponding HTML entities.
  42425. *
  42426. * **Note:** No other characters are escaped. To escape additional
  42427. * characters use a third-party library like [_he_](https://mths.be/he).
  42428. *
  42429. * Though the ">" character is escaped for symmetry, characters like
  42430. * ">" and "/" don't need escaping in HTML and have no special meaning
  42431. * unless they're part of a tag or unquoted attribute value. See
  42432. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  42433. * (under "semi-related fun fact") for more details.
  42434. *
  42435. * When working with HTML you should always
  42436. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  42437. * XSS vectors.
  42438. *
  42439. * @static
  42440. * @since 0.1.0
  42441. * @memberOf _
  42442. * @category String
  42443. * @param {string} [string=''] The string to escape.
  42444. * @returns {string} Returns the escaped string.
  42445. * @example
  42446. *
  42447. * _.escape('fred, barney, & pebbles');
  42448. * // => 'fred, barney, &amp; pebbles'
  42449. */function escape(string){string=toString(string);return string&&reHasUnescapedHtml.test(string)?string.replace(reUnescapedHtml,escapeHtmlChar):string;}/**
  42450. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  42451. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  42452. *
  42453. * @static
  42454. * @memberOf _
  42455. * @since 3.0.0
  42456. * @category String
  42457. * @param {string} [string=''] The string to escape.
  42458. * @returns {string} Returns the escaped string.
  42459. * @example
  42460. *
  42461. * _.escapeRegExp('[lodash](https://lodash.com/)');
  42462. * // => '\[lodash\]\(https://lodash\.com/\)'
  42463. */function escapeRegExp(string){string=toString(string);return string&&reHasRegExpChar.test(string)?string.replace(reRegExpChar,'\\$&'):string;}/**
  42464. * Converts `string` to
  42465. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  42466. *
  42467. * @static
  42468. * @memberOf _
  42469. * @since 3.0.0
  42470. * @category String
  42471. * @param {string} [string=''] The string to convert.
  42472. * @returns {string} Returns the kebab cased string.
  42473. * @example
  42474. *
  42475. * _.kebabCase('Foo Bar');
  42476. * // => 'foo-bar'
  42477. *
  42478. * _.kebabCase('fooBar');
  42479. * // => 'foo-bar'
  42480. *
  42481. * _.kebabCase('__FOO_BAR__');
  42482. * // => 'foo-bar'
  42483. */var kebabCase=createCompounder(function(result,word,index){return result+(index?'-':'')+word.toLowerCase();});/**
  42484. * Converts `string`, as space separated words, to lower case.
  42485. *
  42486. * @static
  42487. * @memberOf _
  42488. * @since 4.0.0
  42489. * @category String
  42490. * @param {string} [string=''] The string to convert.
  42491. * @returns {string} Returns the lower cased string.
  42492. * @example
  42493. *
  42494. * _.lowerCase('--Foo-Bar--');
  42495. * // => 'foo bar'
  42496. *
  42497. * _.lowerCase('fooBar');
  42498. * // => 'foo bar'
  42499. *
  42500. * _.lowerCase('__FOO_BAR__');
  42501. * // => 'foo bar'
  42502. */var lowerCase=createCompounder(function(result,word,index){return result+(index?' ':'')+word.toLowerCase();});/**
  42503. * Converts the first character of `string` to lower case.
  42504. *
  42505. * @static
  42506. * @memberOf _
  42507. * @since 4.0.0
  42508. * @category String
  42509. * @param {string} [string=''] The string to convert.
  42510. * @returns {string} Returns the converted string.
  42511. * @example
  42512. *
  42513. * _.lowerFirst('Fred');
  42514. * // => 'fred'
  42515. *
  42516. * _.lowerFirst('FRED');
  42517. * // => 'fRED'
  42518. */var lowerFirst=createCaseFirst('toLowerCase');/**
  42519. * Pads `string` on the left and right sides if it's shorter than `length`.
  42520. * Padding characters are truncated if they can't be evenly divided by `length`.
  42521. *
  42522. * @static
  42523. * @memberOf _
  42524. * @since 3.0.0
  42525. * @category String
  42526. * @param {string} [string=''] The string to pad.
  42527. * @param {number} [length=0] The padding length.
  42528. * @param {string} [chars=' '] The string used as padding.
  42529. * @returns {string} Returns the padded string.
  42530. * @example
  42531. *
  42532. * _.pad('abc', 8);
  42533. * // => ' abc '
  42534. *
  42535. * _.pad('abc', 8, '_-');
  42536. * // => '_-abc_-_'
  42537. *
  42538. * _.pad('abc', 3);
  42539. * // => 'abc'
  42540. */function pad(string,length,chars){string=toString(string);length=toInteger(length);var strLength=length?stringSize(string):0;if(!length||strLength>=length){return string;}var mid=(length-strLength)/2;return createPadding(nativeFloor(mid),chars)+string+createPadding(nativeCeil(mid),chars);}/**
  42541. * Pads `string` on the right side if it's shorter than `length`. Padding
  42542. * characters are truncated if they exceed `length`.
  42543. *
  42544. * @static
  42545. * @memberOf _
  42546. * @since 4.0.0
  42547. * @category String
  42548. * @param {string} [string=''] The string to pad.
  42549. * @param {number} [length=0] The padding length.
  42550. * @param {string} [chars=' '] The string used as padding.
  42551. * @returns {string} Returns the padded string.
  42552. * @example
  42553. *
  42554. * _.padEnd('abc', 6);
  42555. * // => 'abc '
  42556. *
  42557. * _.padEnd('abc', 6, '_-');
  42558. * // => 'abc_-_'
  42559. *
  42560. * _.padEnd('abc', 3);
  42561. * // => 'abc'
  42562. */function padEnd(string,length,chars){string=toString(string);length=toInteger(length);var strLength=length?stringSize(string):0;return length&&strLength<length?string+createPadding(length-strLength,chars):string;}/**
  42563. * Pads `string` on the left side if it's shorter than `length`. Padding
  42564. * characters are truncated if they exceed `length`.
  42565. *
  42566. * @static
  42567. * @memberOf _
  42568. * @since 4.0.0
  42569. * @category String
  42570. * @param {string} [string=''] The string to pad.
  42571. * @param {number} [length=0] The padding length.
  42572. * @param {string} [chars=' '] The string used as padding.
  42573. * @returns {string} Returns the padded string.
  42574. * @example
  42575. *
  42576. * _.padStart('abc', 6);
  42577. * // => ' abc'
  42578. *
  42579. * _.padStart('abc', 6, '_-');
  42580. * // => '_-_abc'
  42581. *
  42582. * _.padStart('abc', 3);
  42583. * // => 'abc'
  42584. */function padStart(string,length,chars){string=toString(string);length=toInteger(length);var strLength=length?stringSize(string):0;return length&&strLength<length?createPadding(length-strLength,chars)+string:string;}/**
  42585. * Converts `string` to an integer of the specified radix. If `radix` is
  42586. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  42587. * hexadecimal, in which case a `radix` of `16` is used.
  42588. *
  42589. * **Note:** This method aligns with the
  42590. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  42591. *
  42592. * @static
  42593. * @memberOf _
  42594. * @since 1.1.0
  42595. * @category String
  42596. * @param {string} string The string to convert.
  42597. * @param {number} [radix=10] The radix to interpret `value` by.
  42598. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42599. * @returns {number} Returns the converted integer.
  42600. * @example
  42601. *
  42602. * _.parseInt('08');
  42603. * // => 8
  42604. *
  42605. * _.map(['6', '08', '10'], _.parseInt);
  42606. * // => [6, 8, 10]
  42607. */function parseInt(string,radix,guard){if(guard||radix==null){radix=0;}else if(radix){radix=+radix;}return nativeParseInt(toString(string).replace(reTrimStart,''),radix||0);}/**
  42608. * Repeats the given string `n` times.
  42609. *
  42610. * @static
  42611. * @memberOf _
  42612. * @since 3.0.0
  42613. * @category String
  42614. * @param {string} [string=''] The string to repeat.
  42615. * @param {number} [n=1] The number of times to repeat the string.
  42616. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42617. * @returns {string} Returns the repeated string.
  42618. * @example
  42619. *
  42620. * _.repeat('*', 3);
  42621. * // => '***'
  42622. *
  42623. * _.repeat('abc', 2);
  42624. * // => 'abcabc'
  42625. *
  42626. * _.repeat('abc', 0);
  42627. * // => ''
  42628. */function repeat(string,n,guard){if(guard?isIterateeCall(string,n,guard):n===undefined){n=1;}else{n=toInteger(n);}return baseRepeat(toString(string),n);}/**
  42629. * Replaces matches for `pattern` in `string` with `replacement`.
  42630. *
  42631. * **Note:** This method is based on
  42632. * [`String#replace`](https://mdn.io/String/replace).
  42633. *
  42634. * @static
  42635. * @memberOf _
  42636. * @since 4.0.0
  42637. * @category String
  42638. * @param {string} [string=''] The string to modify.
  42639. * @param {RegExp|string} pattern The pattern to replace.
  42640. * @param {Function|string} replacement The match replacement.
  42641. * @returns {string} Returns the modified string.
  42642. * @example
  42643. *
  42644. * _.replace('Hi Fred', 'Fred', 'Barney');
  42645. * // => 'Hi Barney'
  42646. */function replace(){var args=arguments,string=toString(args[0]);return args.length<3?string:string.replace(args[1],args[2]);}/**
  42647. * Converts `string` to
  42648. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  42649. *
  42650. * @static
  42651. * @memberOf _
  42652. * @since 3.0.0
  42653. * @category String
  42654. * @param {string} [string=''] The string to convert.
  42655. * @returns {string} Returns the snake cased string.
  42656. * @example
  42657. *
  42658. * _.snakeCase('Foo Bar');
  42659. * // => 'foo_bar'
  42660. *
  42661. * _.snakeCase('fooBar');
  42662. * // => 'foo_bar'
  42663. *
  42664. * _.snakeCase('--FOO-BAR--');
  42665. * // => 'foo_bar'
  42666. */var snakeCase=createCompounder(function(result,word,index){return result+(index?'_':'')+word.toLowerCase();});/**
  42667. * Splits `string` by `separator`.
  42668. *
  42669. * **Note:** This method is based on
  42670. * [`String#split`](https://mdn.io/String/split).
  42671. *
  42672. * @static
  42673. * @memberOf _
  42674. * @since 4.0.0
  42675. * @category String
  42676. * @param {string} [string=''] The string to split.
  42677. * @param {RegExp|string} separator The separator pattern to split by.
  42678. * @param {number} [limit] The length to truncate results to.
  42679. * @returns {Array} Returns the string segments.
  42680. * @example
  42681. *
  42682. * _.split('a-b-c', '-', 2);
  42683. * // => ['a', 'b']
  42684. */function split(string,separator,limit){if(limit&&typeof limit!='number'&&isIterateeCall(string,separator,limit)){separator=limit=undefined;}limit=limit===undefined?MAX_ARRAY_LENGTH:limit>>>0;if(!limit){return[];}string=toString(string);if(string&&(typeof separator=='string'||separator!=null&&!isRegExp(separator))){separator=baseToString(separator);if(!separator&&hasUnicode(string)){return castSlice(stringToArray(string),0,limit);}}return string.split(separator,limit);}/**
  42685. * Converts `string` to
  42686. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  42687. *
  42688. * @static
  42689. * @memberOf _
  42690. * @since 3.1.0
  42691. * @category String
  42692. * @param {string} [string=''] The string to convert.
  42693. * @returns {string} Returns the start cased string.
  42694. * @example
  42695. *
  42696. * _.startCase('--foo-bar--');
  42697. * // => 'Foo Bar'
  42698. *
  42699. * _.startCase('fooBar');
  42700. * // => 'Foo Bar'
  42701. *
  42702. * _.startCase('__FOO_BAR__');
  42703. * // => 'FOO BAR'
  42704. */var startCase=createCompounder(function(result,word,index){return result+(index?' ':'')+upperFirst(word);});/**
  42705. * Checks if `string` starts with the given target string.
  42706. *
  42707. * @static
  42708. * @memberOf _
  42709. * @since 3.0.0
  42710. * @category String
  42711. * @param {string} [string=''] The string to inspect.
  42712. * @param {string} [target] The string to search for.
  42713. * @param {number} [position=0] The position to search from.
  42714. * @returns {boolean} Returns `true` if `string` starts with `target`,
  42715. * else `false`.
  42716. * @example
  42717. *
  42718. * _.startsWith('abc', 'a');
  42719. * // => true
  42720. *
  42721. * _.startsWith('abc', 'b');
  42722. * // => false
  42723. *
  42724. * _.startsWith('abc', 'b', 1);
  42725. * // => true
  42726. */function startsWith(string,target,position){string=toString(string);position=position==null?0:baseClamp(toInteger(position),0,string.length);target=baseToString(target);return string.slice(position,position+target.length)==target;}/**
  42727. * Creates a compiled template function that can interpolate data properties
  42728. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  42729. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  42730. * properties may be accessed as free variables in the template. If a setting
  42731. * object is given, it takes precedence over `_.templateSettings` values.
  42732. *
  42733. * **Note:** In the development build `_.template` utilizes
  42734. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  42735. * for easier debugging.
  42736. *
  42737. * For more information on precompiling templates see
  42738. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  42739. *
  42740. * For more information on Chrome extension sandboxes see
  42741. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  42742. *
  42743. * @static
  42744. * @since 0.1.0
  42745. * @memberOf _
  42746. * @category String
  42747. * @param {string} [string=''] The template string.
  42748. * @param {Object} [options={}] The options object.
  42749. * @param {RegExp} [options.escape=_.templateSettings.escape]
  42750. * The HTML "escape" delimiter.
  42751. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  42752. * The "evaluate" delimiter.
  42753. * @param {Object} [options.imports=_.templateSettings.imports]
  42754. * An object to import into the template as free variables.
  42755. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  42756. * The "interpolate" delimiter.
  42757. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  42758. * The sourceURL of the compiled template.
  42759. * @param {string} [options.variable='obj']
  42760. * The data object variable name.
  42761. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42762. * @returns {Function} Returns the compiled template function.
  42763. * @example
  42764. *
  42765. * // Use the "interpolate" delimiter to create a compiled template.
  42766. * var compiled = _.template('hello <%= user %>!');
  42767. * compiled({ 'user': 'fred' });
  42768. * // => 'hello fred!'
  42769. *
  42770. * // Use the HTML "escape" delimiter to escape data property values.
  42771. * var compiled = _.template('<b><%- value %></b>');
  42772. * compiled({ 'value': '<script>' });
  42773. * // => '<b>&lt;script&gt;</b>'
  42774. *
  42775. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  42776. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  42777. * compiled({ 'users': ['fred', 'barney'] });
  42778. * // => '<li>fred</li><li>barney</li>'
  42779. *
  42780. * // Use the internal `print` function in "evaluate" delimiters.
  42781. * var compiled = _.template('<% print("hello " + user); %>!');
  42782. * compiled({ 'user': 'barney' });
  42783. * // => 'hello barney!'
  42784. *
  42785. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  42786. * // Disable support by replacing the "interpolate" delimiter.
  42787. * var compiled = _.template('hello ${ user }!');
  42788. * compiled({ 'user': 'pebbles' });
  42789. * // => 'hello pebbles!'
  42790. *
  42791. * // Use backslashes to treat delimiters as plain text.
  42792. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  42793. * compiled({ 'value': 'ignored' });
  42794. * // => '<%- value %>'
  42795. *
  42796. * // Use the `imports` option to import `jQuery` as `jq`.
  42797. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  42798. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  42799. * compiled({ 'users': ['fred', 'barney'] });
  42800. * // => '<li>fred</li><li>barney</li>'
  42801. *
  42802. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  42803. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  42804. * compiled(data);
  42805. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  42806. *
  42807. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  42808. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  42809. * compiled.source;
  42810. * // => function(data) {
  42811. * // var __t, __p = '';
  42812. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  42813. * // return __p;
  42814. * // }
  42815. *
  42816. * // Use custom template delimiters.
  42817. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  42818. * var compiled = _.template('hello {{ user }}!');
  42819. * compiled({ 'user': 'mustache' });
  42820. * // => 'hello mustache!'
  42821. *
  42822. * // Use the `source` property to inline compiled templates for meaningful
  42823. * // line numbers in error messages and stack traces.
  42824. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  42825. * var JST = {\
  42826. * "main": ' + _.template(mainText).source + '\
  42827. * };\
  42828. * ');
  42829. */function template(string,options,guard){// Based on John Resig's `tmpl` implementation
  42830. // (http://ejohn.org/blog/javascript-micro-templating/)
  42831. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  42832. var settings=lodash.templateSettings;if(guard&&isIterateeCall(string,options,guard)){options=undefined;}string=toString(string);options=assignInWith({},options,settings,customDefaultsAssignIn);var imports=assignInWith({},options.imports,settings.imports,customDefaultsAssignIn),importsKeys=keys(imports),importsValues=baseValues(imports,importsKeys);var isEscaping,isEvaluating,index=0,interpolate=options.interpolate||reNoMatch,source="__p += '";// Compile the regexp to match each delimiter.
  42833. var reDelimiters=RegExp((options.escape||reNoMatch).source+'|'+interpolate.source+'|'+(interpolate===reInterpolate?reEsTemplate:reNoMatch).source+'|'+(options.evaluate||reNoMatch).source+'|$','g');// Use a sourceURL for easier debugging.
  42834. var sourceURL='//# sourceURL='+('sourceURL'in options?options.sourceURL:'lodash.templateSources['+ ++templateCounter+']')+'\n';string.replace(reDelimiters,function(match,escapeValue,interpolateValue,esTemplateValue,evaluateValue,offset){interpolateValue||(interpolateValue=esTemplateValue);// Escape characters that can't be included in string literals.
  42835. source+=string.slice(index,offset).replace(reUnescapedString,escapeStringChar);// Replace delimiters with snippets.
  42836. if(escapeValue){isEscaping=true;source+="' +\n__e("+escapeValue+") +\n'";}if(evaluateValue){isEvaluating=true;source+="';\n"+evaluateValue+";\n__p += '";}if(interpolateValue){source+="' +\n((__t = ("+interpolateValue+")) == null ? '' : __t) +\n'";}index=offset+match.length;// The JS engine embedded in Adobe products needs `match` returned in
  42837. // order to produce the correct `offset` value.
  42838. return match;});source+="';\n";// If `variable` is not specified wrap a with-statement around the generated
  42839. // code to add the data object to the top of the scope chain.
  42840. var variable=options.variable;if(!variable){source='with (obj) {\n'+source+'\n}\n';}// Cleanup code by stripping empty strings.
  42841. source=(isEvaluating?source.replace(reEmptyStringLeading,''):source).replace(reEmptyStringMiddle,'$1').replace(reEmptyStringTrailing,'$1;');// Frame code as the function body.
  42842. source='function('+(variable||'obj')+') {\n'+(variable?'':'obj || (obj = {});\n')+"var __t, __p = ''"+(isEscaping?', __e = _.escape':'')+(isEvaluating?', __j = Array.prototype.join;\n'+"function print() { __p += __j.call(arguments, '') }\n":';\n')+source+'return __p\n}';var result=attempt(function(){return Function(importsKeys,sourceURL+'return '+source).apply(undefined,importsValues);});// Provide the compiled function's source by its `toString` method or
  42843. // the `source` property as a convenience for inlining compiled templates.
  42844. result.source=source;if(isError(result)){throw result;}return result;}/**
  42845. * Converts `string`, as a whole, to lower case just like
  42846. * [String#toLowerCase](https://mdn.io/toLowerCase).
  42847. *
  42848. * @static
  42849. * @memberOf _
  42850. * @since 4.0.0
  42851. * @category String
  42852. * @param {string} [string=''] The string to convert.
  42853. * @returns {string} Returns the lower cased string.
  42854. * @example
  42855. *
  42856. * _.toLower('--Foo-Bar--');
  42857. * // => '--foo-bar--'
  42858. *
  42859. * _.toLower('fooBar');
  42860. * // => 'foobar'
  42861. *
  42862. * _.toLower('__FOO_BAR__');
  42863. * // => '__foo_bar__'
  42864. */function toLower(value){return toString(value).toLowerCase();}/**
  42865. * Converts `string`, as a whole, to upper case just like
  42866. * [String#toUpperCase](https://mdn.io/toUpperCase).
  42867. *
  42868. * @static
  42869. * @memberOf _
  42870. * @since 4.0.0
  42871. * @category String
  42872. * @param {string} [string=''] The string to convert.
  42873. * @returns {string} Returns the upper cased string.
  42874. * @example
  42875. *
  42876. * _.toUpper('--foo-bar--');
  42877. * // => '--FOO-BAR--'
  42878. *
  42879. * _.toUpper('fooBar');
  42880. * // => 'FOOBAR'
  42881. *
  42882. * _.toUpper('__foo_bar__');
  42883. * // => '__FOO_BAR__'
  42884. */function toUpper(value){return toString(value).toUpperCase();}/**
  42885. * Removes leading and trailing whitespace or specified characters from `string`.
  42886. *
  42887. * @static
  42888. * @memberOf _
  42889. * @since 3.0.0
  42890. * @category String
  42891. * @param {string} [string=''] The string to trim.
  42892. * @param {string} [chars=whitespace] The characters to trim.
  42893. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42894. * @returns {string} Returns the trimmed string.
  42895. * @example
  42896. *
  42897. * _.trim(' abc ');
  42898. * // => 'abc'
  42899. *
  42900. * _.trim('-_-abc-_-', '_-');
  42901. * // => 'abc'
  42902. *
  42903. * _.map([' foo ', ' bar '], _.trim);
  42904. * // => ['foo', 'bar']
  42905. */function trim(string,chars,guard){string=toString(string);if(string&&(guard||chars===undefined)){return string.replace(reTrim,'');}if(!string||!(chars=baseToString(chars))){return string;}var strSymbols=stringToArray(string),chrSymbols=stringToArray(chars),start=charsStartIndex(strSymbols,chrSymbols),end=charsEndIndex(strSymbols,chrSymbols)+1;return castSlice(strSymbols,start,end).join('');}/**
  42906. * Removes trailing whitespace or specified characters from `string`.
  42907. *
  42908. * @static
  42909. * @memberOf _
  42910. * @since 4.0.0
  42911. * @category String
  42912. * @param {string} [string=''] The string to trim.
  42913. * @param {string} [chars=whitespace] The characters to trim.
  42914. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42915. * @returns {string} Returns the trimmed string.
  42916. * @example
  42917. *
  42918. * _.trimEnd(' abc ');
  42919. * // => ' abc'
  42920. *
  42921. * _.trimEnd('-_-abc-_-', '_-');
  42922. * // => '-_-abc'
  42923. */function trimEnd(string,chars,guard){string=toString(string);if(string&&(guard||chars===undefined)){return string.replace(reTrimEnd,'');}if(!string||!(chars=baseToString(chars))){return string;}var strSymbols=stringToArray(string),end=charsEndIndex(strSymbols,stringToArray(chars))+1;return castSlice(strSymbols,0,end).join('');}/**
  42924. * Removes leading whitespace or specified characters from `string`.
  42925. *
  42926. * @static
  42927. * @memberOf _
  42928. * @since 4.0.0
  42929. * @category String
  42930. * @param {string} [string=''] The string to trim.
  42931. * @param {string} [chars=whitespace] The characters to trim.
  42932. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42933. * @returns {string} Returns the trimmed string.
  42934. * @example
  42935. *
  42936. * _.trimStart(' abc ');
  42937. * // => 'abc '
  42938. *
  42939. * _.trimStart('-_-abc-_-', '_-');
  42940. * // => 'abc-_-'
  42941. */function trimStart(string,chars,guard){string=toString(string);if(string&&(guard||chars===undefined)){return string.replace(reTrimStart,'');}if(!string||!(chars=baseToString(chars))){return string;}var strSymbols=stringToArray(string),start=charsStartIndex(strSymbols,stringToArray(chars));return castSlice(strSymbols,start).join('');}/**
  42942. * Truncates `string` if it's longer than the given maximum string length.
  42943. * The last characters of the truncated string are replaced with the omission
  42944. * string which defaults to "...".
  42945. *
  42946. * @static
  42947. * @memberOf _
  42948. * @since 4.0.0
  42949. * @category String
  42950. * @param {string} [string=''] The string to truncate.
  42951. * @param {Object} [options={}] The options object.
  42952. * @param {number} [options.length=30] The maximum string length.
  42953. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  42954. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  42955. * @returns {string} Returns the truncated string.
  42956. * @example
  42957. *
  42958. * _.truncate('hi-diddly-ho there, neighborino');
  42959. * // => 'hi-diddly-ho there, neighbo...'
  42960. *
  42961. * _.truncate('hi-diddly-ho there, neighborino', {
  42962. * 'length': 24,
  42963. * 'separator': ' '
  42964. * });
  42965. * // => 'hi-diddly-ho there,...'
  42966. *
  42967. * _.truncate('hi-diddly-ho there, neighborino', {
  42968. * 'length': 24,
  42969. * 'separator': /,? +/
  42970. * });
  42971. * // => 'hi-diddly-ho there...'
  42972. *
  42973. * _.truncate('hi-diddly-ho there, neighborino', {
  42974. * 'omission': ' [...]'
  42975. * });
  42976. * // => 'hi-diddly-ho there, neig [...]'
  42977. */function truncate(string,options){var length=DEFAULT_TRUNC_LENGTH,omission=DEFAULT_TRUNC_OMISSION;if(isObject(options)){var separator='separator'in options?options.separator:separator;length='length'in options?toInteger(options.length):length;omission='omission'in options?baseToString(options.omission):omission;}string=toString(string);var strLength=string.length;if(hasUnicode(string)){var strSymbols=stringToArray(string);strLength=strSymbols.length;}if(length>=strLength){return string;}var end=length-stringSize(omission);if(end<1){return omission;}var result=strSymbols?castSlice(strSymbols,0,end).join(''):string.slice(0,end);if(separator===undefined){return result+omission;}if(strSymbols){end+=result.length-end;}if(isRegExp(separator)){if(string.slice(end).search(separator)){var match,substring=result;if(!separator.global){separator=RegExp(separator.source,toString(reFlags.exec(separator))+'g');}separator.lastIndex=0;while(match=separator.exec(substring)){var newEnd=match.index;}result=result.slice(0,newEnd===undefined?end:newEnd);}}else if(string.indexOf(baseToString(separator),end)!=end){var index=result.lastIndexOf(separator);if(index>-1){result=result.slice(0,index);}}return result+omission;}/**
  42978. * The inverse of `_.escape`; this method converts the HTML entities
  42979. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  42980. * their corresponding characters.
  42981. *
  42982. * **Note:** No other HTML entities are unescaped. To unescape additional
  42983. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  42984. *
  42985. * @static
  42986. * @memberOf _
  42987. * @since 0.6.0
  42988. * @category String
  42989. * @param {string} [string=''] The string to unescape.
  42990. * @returns {string} Returns the unescaped string.
  42991. * @example
  42992. *
  42993. * _.unescape('fred, barney, &amp; pebbles');
  42994. * // => 'fred, barney, & pebbles'
  42995. */function unescape(string){string=toString(string);return string&&reHasEscapedHtml.test(string)?string.replace(reEscapedHtml,unescapeHtmlChar):string;}/**
  42996. * Converts `string`, as space separated words, to upper case.
  42997. *
  42998. * @static
  42999. * @memberOf _
  43000. * @since 4.0.0
  43001. * @category String
  43002. * @param {string} [string=''] The string to convert.
  43003. * @returns {string} Returns the upper cased string.
  43004. * @example
  43005. *
  43006. * _.upperCase('--foo-bar');
  43007. * // => 'FOO BAR'
  43008. *
  43009. * _.upperCase('fooBar');
  43010. * // => 'FOO BAR'
  43011. *
  43012. * _.upperCase('__foo_bar__');
  43013. * // => 'FOO BAR'
  43014. */var upperCase=createCompounder(function(result,word,index){return result+(index?' ':'')+word.toUpperCase();});/**
  43015. * Converts the first character of `string` to upper case.
  43016. *
  43017. * @static
  43018. * @memberOf _
  43019. * @since 4.0.0
  43020. * @category String
  43021. * @param {string} [string=''] The string to convert.
  43022. * @returns {string} Returns the converted string.
  43023. * @example
  43024. *
  43025. * _.upperFirst('fred');
  43026. * // => 'Fred'
  43027. *
  43028. * _.upperFirst('FRED');
  43029. * // => 'FRED'
  43030. */var upperFirst=createCaseFirst('toUpperCase');/**
  43031. * Splits `string` into an array of its words.
  43032. *
  43033. * @static
  43034. * @memberOf _
  43035. * @since 3.0.0
  43036. * @category String
  43037. * @param {string} [string=''] The string to inspect.
  43038. * @param {RegExp|string} [pattern] The pattern to match words.
  43039. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  43040. * @returns {Array} Returns the words of `string`.
  43041. * @example
  43042. *
  43043. * _.words('fred, barney, & pebbles');
  43044. * // => ['fred', 'barney', 'pebbles']
  43045. *
  43046. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  43047. * // => ['fred', 'barney', '&', 'pebbles']
  43048. */function words(string,pattern,guard){string=toString(string);pattern=guard?undefined:pattern;if(pattern===undefined){return hasUnicodeWord(string)?unicodeWords(string):asciiWords(string);}return string.match(pattern)||[];}/*------------------------------------------------------------------------*//**
  43049. * Attempts to invoke `func`, returning either the result or the caught error
  43050. * object. Any additional arguments are provided to `func` when it's invoked.
  43051. *
  43052. * @static
  43053. * @memberOf _
  43054. * @since 3.0.0
  43055. * @category Util
  43056. * @param {Function} func The function to attempt.
  43057. * @param {...*} [args] The arguments to invoke `func` with.
  43058. * @returns {*} Returns the `func` result or error object.
  43059. * @example
  43060. *
  43061. * // Avoid throwing errors for invalid selectors.
  43062. * var elements = _.attempt(function(selector) {
  43063. * return document.querySelectorAll(selector);
  43064. * }, '>_>');
  43065. *
  43066. * if (_.isError(elements)) {
  43067. * elements = [];
  43068. * }
  43069. */var attempt=baseRest(function(func,args){try{return apply(func,undefined,args);}catch(e){return isError(e)?e:new Error(e);}});/**
  43070. * Binds methods of an object to the object itself, overwriting the existing
  43071. * method.
  43072. *
  43073. * **Note:** This method doesn't set the "length" property of bound functions.
  43074. *
  43075. * @static
  43076. * @since 0.1.0
  43077. * @memberOf _
  43078. * @category Util
  43079. * @param {Object} object The object to bind and assign the bound methods to.
  43080. * @param {...(string|string[])} methodNames The object method names to bind.
  43081. * @returns {Object} Returns `object`.
  43082. * @example
  43083. *
  43084. * var view = {
  43085. * 'label': 'docs',
  43086. * 'click': function() {
  43087. * console.log('clicked ' + this.label);
  43088. * }
  43089. * };
  43090. *
  43091. * _.bindAll(view, ['click']);
  43092. * jQuery(element).on('click', view.click);
  43093. * // => Logs 'clicked docs' when clicked.
  43094. */var bindAll=flatRest(function(object,methodNames){arrayEach(methodNames,function(key){key=toKey(key);baseAssignValue(object,key,bind(object[key],object));});return object;});/**
  43095. * Creates a function that iterates over `pairs` and invokes the corresponding
  43096. * function of the first predicate to return truthy. The predicate-function
  43097. * pairs are invoked with the `this` binding and arguments of the created
  43098. * function.
  43099. *
  43100. * @static
  43101. * @memberOf _
  43102. * @since 4.0.0
  43103. * @category Util
  43104. * @param {Array} pairs The predicate-function pairs.
  43105. * @returns {Function} Returns the new composite function.
  43106. * @example
  43107. *
  43108. * var func = _.cond([
  43109. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  43110. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  43111. * [_.stubTrue, _.constant('no match')]
  43112. * ]);
  43113. *
  43114. * func({ 'a': 1, 'b': 2 });
  43115. * // => 'matches A'
  43116. *
  43117. * func({ 'a': 0, 'b': 1 });
  43118. * // => 'matches B'
  43119. *
  43120. * func({ 'a': '1', 'b': '2' });
  43121. * // => 'no match'
  43122. */function cond(pairs){var length=pairs==null?0:pairs.length,toIteratee=getIteratee();pairs=!length?[]:arrayMap(pairs,function(pair){if(typeof pair[1]!='function'){throw new TypeError(FUNC_ERROR_TEXT);}return[toIteratee(pair[0]),pair[1]];});return baseRest(function(args){var index=-1;while(++index<length){var pair=pairs[index];if(apply(pair[0],this,args)){return apply(pair[1],this,args);}}});}/**
  43123. * Creates a function that invokes the predicate properties of `source` with
  43124. * the corresponding property values of a given object, returning `true` if
  43125. * all predicates return truthy, else `false`.
  43126. *
  43127. * **Note:** The created function is equivalent to `_.conformsTo` with
  43128. * `source` partially applied.
  43129. *
  43130. * @static
  43131. * @memberOf _
  43132. * @since 4.0.0
  43133. * @category Util
  43134. * @param {Object} source The object of property predicates to conform to.
  43135. * @returns {Function} Returns the new spec function.
  43136. * @example
  43137. *
  43138. * var objects = [
  43139. * { 'a': 2, 'b': 1 },
  43140. * { 'a': 1, 'b': 2 }
  43141. * ];
  43142. *
  43143. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  43144. * // => [{ 'a': 1, 'b': 2 }]
  43145. */function conforms(source){return baseConforms(baseClone(source,CLONE_DEEP_FLAG));}/**
  43146. * Creates a function that returns `value`.
  43147. *
  43148. * @static
  43149. * @memberOf _
  43150. * @since 2.4.0
  43151. * @category Util
  43152. * @param {*} value The value to return from the new function.
  43153. * @returns {Function} Returns the new constant function.
  43154. * @example
  43155. *
  43156. * var objects = _.times(2, _.constant({ 'a': 1 }));
  43157. *
  43158. * console.log(objects);
  43159. * // => [{ 'a': 1 }, { 'a': 1 }]
  43160. *
  43161. * console.log(objects[0] === objects[1]);
  43162. * // => true
  43163. */function constant(value){return function(){return value;};}/**
  43164. * Checks `value` to determine whether a default value should be returned in
  43165. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  43166. * or `undefined`.
  43167. *
  43168. * @static
  43169. * @memberOf _
  43170. * @since 4.14.0
  43171. * @category Util
  43172. * @param {*} value The value to check.
  43173. * @param {*} defaultValue The default value.
  43174. * @returns {*} Returns the resolved value.
  43175. * @example
  43176. *
  43177. * _.defaultTo(1, 10);
  43178. * // => 1
  43179. *
  43180. * _.defaultTo(undefined, 10);
  43181. * // => 10
  43182. */function defaultTo(value,defaultValue){return value==null||value!==value?defaultValue:value;}/**
  43183. * Creates a function that returns the result of invoking the given functions
  43184. * with the `this` binding of the created function, where each successive
  43185. * invocation is supplied the return value of the previous.
  43186. *
  43187. * @static
  43188. * @memberOf _
  43189. * @since 3.0.0
  43190. * @category Util
  43191. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  43192. * @returns {Function} Returns the new composite function.
  43193. * @see _.flowRight
  43194. * @example
  43195. *
  43196. * function square(n) {
  43197. * return n * n;
  43198. * }
  43199. *
  43200. * var addSquare = _.flow([_.add, square]);
  43201. * addSquare(1, 2);
  43202. * // => 9
  43203. */var flow=createFlow();/**
  43204. * This method is like `_.flow` except that it creates a function that
  43205. * invokes the given functions from right to left.
  43206. *
  43207. * @static
  43208. * @since 3.0.0
  43209. * @memberOf _
  43210. * @category Util
  43211. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  43212. * @returns {Function} Returns the new composite function.
  43213. * @see _.flow
  43214. * @example
  43215. *
  43216. * function square(n) {
  43217. * return n * n;
  43218. * }
  43219. *
  43220. * var addSquare = _.flowRight([square, _.add]);
  43221. * addSquare(1, 2);
  43222. * // => 9
  43223. */var flowRight=createFlow(true);/**
  43224. * This method returns the first argument it receives.
  43225. *
  43226. * @static
  43227. * @since 0.1.0
  43228. * @memberOf _
  43229. * @category Util
  43230. * @param {*} value Any value.
  43231. * @returns {*} Returns `value`.
  43232. * @example
  43233. *
  43234. * var object = { 'a': 1 };
  43235. *
  43236. * console.log(_.identity(object) === object);
  43237. * // => true
  43238. */function identity(value){return value;}/**
  43239. * Creates a function that invokes `func` with the arguments of the created
  43240. * function. If `func` is a property name, the created function returns the
  43241. * property value for a given element. If `func` is an array or object, the
  43242. * created function returns `true` for elements that contain the equivalent
  43243. * source properties, otherwise it returns `false`.
  43244. *
  43245. * @static
  43246. * @since 4.0.0
  43247. * @memberOf _
  43248. * @category Util
  43249. * @param {*} [func=_.identity] The value to convert to a callback.
  43250. * @returns {Function} Returns the callback.
  43251. * @example
  43252. *
  43253. * var users = [
  43254. * { 'user': 'barney', 'age': 36, 'active': true },
  43255. * { 'user': 'fred', 'age': 40, 'active': false }
  43256. * ];
  43257. *
  43258. * // The `_.matches` iteratee shorthand.
  43259. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  43260. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  43261. *
  43262. * // The `_.matchesProperty` iteratee shorthand.
  43263. * _.filter(users, _.iteratee(['user', 'fred']));
  43264. * // => [{ 'user': 'fred', 'age': 40 }]
  43265. *
  43266. * // The `_.property` iteratee shorthand.
  43267. * _.map(users, _.iteratee('user'));
  43268. * // => ['barney', 'fred']
  43269. *
  43270. * // Create custom iteratee shorthands.
  43271. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  43272. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  43273. * return func.test(string);
  43274. * };
  43275. * });
  43276. *
  43277. * _.filter(['abc', 'def'], /ef/);
  43278. * // => ['def']
  43279. */function iteratee(func){return baseIteratee(typeof func=='function'?func:baseClone(func,CLONE_DEEP_FLAG));}/**
  43280. * Creates a function that performs a partial deep comparison between a given
  43281. * object and `source`, returning `true` if the given object has equivalent
  43282. * property values, else `false`.
  43283. *
  43284. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  43285. * partially applied.
  43286. *
  43287. * Partial comparisons will match empty array and empty object `source`
  43288. * values against any array or object value, respectively. See `_.isEqual`
  43289. * for a list of supported value comparisons.
  43290. *
  43291. * @static
  43292. * @memberOf _
  43293. * @since 3.0.0
  43294. * @category Util
  43295. * @param {Object} source The object of property values to match.
  43296. * @returns {Function} Returns the new spec function.
  43297. * @example
  43298. *
  43299. * var objects = [
  43300. * { 'a': 1, 'b': 2, 'c': 3 },
  43301. * { 'a': 4, 'b': 5, 'c': 6 }
  43302. * ];
  43303. *
  43304. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  43305. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  43306. */function matches(source){return baseMatches(baseClone(source,CLONE_DEEP_FLAG));}/**
  43307. * Creates a function that performs a partial deep comparison between the
  43308. * value at `path` of a given object to `srcValue`, returning `true` if the
  43309. * object value is equivalent, else `false`.
  43310. *
  43311. * **Note:** Partial comparisons will match empty array and empty object
  43312. * `srcValue` values against any array or object value, respectively. See
  43313. * `_.isEqual` for a list of supported value comparisons.
  43314. *
  43315. * @static
  43316. * @memberOf _
  43317. * @since 3.2.0
  43318. * @category Util
  43319. * @param {Array|string} path The path of the property to get.
  43320. * @param {*} srcValue The value to match.
  43321. * @returns {Function} Returns the new spec function.
  43322. * @example
  43323. *
  43324. * var objects = [
  43325. * { 'a': 1, 'b': 2, 'c': 3 },
  43326. * { 'a': 4, 'b': 5, 'c': 6 }
  43327. * ];
  43328. *
  43329. * _.find(objects, _.matchesProperty('a', 4));
  43330. * // => { 'a': 4, 'b': 5, 'c': 6 }
  43331. */function matchesProperty(path,srcValue){return baseMatchesProperty(path,baseClone(srcValue,CLONE_DEEP_FLAG));}/**
  43332. * Creates a function that invokes the method at `path` of a given object.
  43333. * Any additional arguments are provided to the invoked method.
  43334. *
  43335. * @static
  43336. * @memberOf _
  43337. * @since 3.7.0
  43338. * @category Util
  43339. * @param {Array|string} path The path of the method to invoke.
  43340. * @param {...*} [args] The arguments to invoke the method with.
  43341. * @returns {Function} Returns the new invoker function.
  43342. * @example
  43343. *
  43344. * var objects = [
  43345. * { 'a': { 'b': _.constant(2) } },
  43346. * { 'a': { 'b': _.constant(1) } }
  43347. * ];
  43348. *
  43349. * _.map(objects, _.method('a.b'));
  43350. * // => [2, 1]
  43351. *
  43352. * _.map(objects, _.method(['a', 'b']));
  43353. * // => [2, 1]
  43354. */var method=baseRest(function(path,args){return function(object){return baseInvoke(object,path,args);};});/**
  43355. * The opposite of `_.method`; this method creates a function that invokes
  43356. * the method at a given path of `object`. Any additional arguments are
  43357. * provided to the invoked method.
  43358. *
  43359. * @static
  43360. * @memberOf _
  43361. * @since 3.7.0
  43362. * @category Util
  43363. * @param {Object} object The object to query.
  43364. * @param {...*} [args] The arguments to invoke the method with.
  43365. * @returns {Function} Returns the new invoker function.
  43366. * @example
  43367. *
  43368. * var array = _.times(3, _.constant),
  43369. * object = { 'a': array, 'b': array, 'c': array };
  43370. *
  43371. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  43372. * // => [2, 0]
  43373. *
  43374. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  43375. * // => [2, 0]
  43376. */var methodOf=baseRest(function(object,args){return function(path){return baseInvoke(object,path,args);};});/**
  43377. * Adds all own enumerable string keyed function properties of a source
  43378. * object to the destination object. If `object` is a function, then methods
  43379. * are added to its prototype as well.
  43380. *
  43381. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  43382. * avoid conflicts caused by modifying the original.
  43383. *
  43384. * @static
  43385. * @since 0.1.0
  43386. * @memberOf _
  43387. * @category Util
  43388. * @param {Function|Object} [object=lodash] The destination object.
  43389. * @param {Object} source The object of functions to add.
  43390. * @param {Object} [options={}] The options object.
  43391. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  43392. * @returns {Function|Object} Returns `object`.
  43393. * @example
  43394. *
  43395. * function vowels(string) {
  43396. * return _.filter(string, function(v) {
  43397. * return /[aeiou]/i.test(v);
  43398. * });
  43399. * }
  43400. *
  43401. * _.mixin({ 'vowels': vowels });
  43402. * _.vowels('fred');
  43403. * // => ['e']
  43404. *
  43405. * _('fred').vowels().value();
  43406. * // => ['e']
  43407. *
  43408. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  43409. * _('fred').vowels();
  43410. * // => ['e']
  43411. */function mixin(object,source,options){var props=keys(source),methodNames=baseFunctions(source,props);if(options==null&&!(isObject(source)&&(methodNames.length||!props.length))){options=source;source=object;object=this;methodNames=baseFunctions(source,keys(source));}var chain=!(isObject(options)&&'chain'in options)||!!options.chain,isFunc=isFunction(object);arrayEach(methodNames,function(methodName){var func=source[methodName];object[methodName]=func;if(isFunc){object.prototype[methodName]=function(){var chainAll=this.__chain__;if(chain||chainAll){var result=object(this.__wrapped__),actions=result.__actions__=copyArray(this.__actions__);actions.push({'func':func,'args':arguments,'thisArg':object});result.__chain__=chainAll;return result;}return func.apply(object,arrayPush([this.value()],arguments));};}});return object;}/**
  43412. * Reverts the `_` variable to its previous value and returns a reference to
  43413. * the `lodash` function.
  43414. *
  43415. * @static
  43416. * @since 0.1.0
  43417. * @memberOf _
  43418. * @category Util
  43419. * @returns {Function} Returns the `lodash` function.
  43420. * @example
  43421. *
  43422. * var lodash = _.noConflict();
  43423. */function noConflict(){if(root._===this){root._=oldDash;}return this;}/**
  43424. * This method returns `undefined`.
  43425. *
  43426. * @static
  43427. * @memberOf _
  43428. * @since 2.3.0
  43429. * @category Util
  43430. * @example
  43431. *
  43432. * _.times(2, _.noop);
  43433. * // => [undefined, undefined]
  43434. */function noop(){}// No operation performed.
  43435. /**
  43436. * Creates a function that gets the argument at index `n`. If `n` is negative,
  43437. * the nth argument from the end is returned.
  43438. *
  43439. * @static
  43440. * @memberOf _
  43441. * @since 4.0.0
  43442. * @category Util
  43443. * @param {number} [n=0] The index of the argument to return.
  43444. * @returns {Function} Returns the new pass-thru function.
  43445. * @example
  43446. *
  43447. * var func = _.nthArg(1);
  43448. * func('a', 'b', 'c', 'd');
  43449. * // => 'b'
  43450. *
  43451. * var func = _.nthArg(-2);
  43452. * func('a', 'b', 'c', 'd');
  43453. * // => 'c'
  43454. */function nthArg(n){n=toInteger(n);return baseRest(function(args){return baseNth(args,n);});}/**
  43455. * Creates a function that invokes `iteratees` with the arguments it receives
  43456. * and returns their results.
  43457. *
  43458. * @static
  43459. * @memberOf _
  43460. * @since 4.0.0
  43461. * @category Util
  43462. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  43463. * The iteratees to invoke.
  43464. * @returns {Function} Returns the new function.
  43465. * @example
  43466. *
  43467. * var func = _.over([Math.max, Math.min]);
  43468. *
  43469. * func(1, 2, 3, 4);
  43470. * // => [4, 1]
  43471. */var over=createOver(arrayMap);/**
  43472. * Creates a function that checks if **all** of the `predicates` return
  43473. * truthy when invoked with the arguments it receives.
  43474. *
  43475. * @static
  43476. * @memberOf _
  43477. * @since 4.0.0
  43478. * @category Util
  43479. * @param {...(Function|Function[])} [predicates=[_.identity]]
  43480. * The predicates to check.
  43481. * @returns {Function} Returns the new function.
  43482. * @example
  43483. *
  43484. * var func = _.overEvery([Boolean, isFinite]);
  43485. *
  43486. * func('1');
  43487. * // => true
  43488. *
  43489. * func(null);
  43490. * // => false
  43491. *
  43492. * func(NaN);
  43493. * // => false
  43494. */var overEvery=createOver(arrayEvery);/**
  43495. * Creates a function that checks if **any** of the `predicates` return
  43496. * truthy when invoked with the arguments it receives.
  43497. *
  43498. * @static
  43499. * @memberOf _
  43500. * @since 4.0.0
  43501. * @category Util
  43502. * @param {...(Function|Function[])} [predicates=[_.identity]]
  43503. * The predicates to check.
  43504. * @returns {Function} Returns the new function.
  43505. * @example
  43506. *
  43507. * var func = _.overSome([Boolean, isFinite]);
  43508. *
  43509. * func('1');
  43510. * // => true
  43511. *
  43512. * func(null);
  43513. * // => true
  43514. *
  43515. * func(NaN);
  43516. * // => false
  43517. */var overSome=createOver(arraySome);/**
  43518. * Creates a function that returns the value at `path` of a given object.
  43519. *
  43520. * @static
  43521. * @memberOf _
  43522. * @since 2.4.0
  43523. * @category Util
  43524. * @param {Array|string} path The path of the property to get.
  43525. * @returns {Function} Returns the new accessor function.
  43526. * @example
  43527. *
  43528. * var objects = [
  43529. * { 'a': { 'b': 2 } },
  43530. * { 'a': { 'b': 1 } }
  43531. * ];
  43532. *
  43533. * _.map(objects, _.property('a.b'));
  43534. * // => [2, 1]
  43535. *
  43536. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  43537. * // => [1, 2]
  43538. */function property(path){return isKey(path)?baseProperty(toKey(path)):basePropertyDeep(path);}/**
  43539. * The opposite of `_.property`; this method creates a function that returns
  43540. * the value at a given path of `object`.
  43541. *
  43542. * @static
  43543. * @memberOf _
  43544. * @since 3.0.0
  43545. * @category Util
  43546. * @param {Object} object The object to query.
  43547. * @returns {Function} Returns the new accessor function.
  43548. * @example
  43549. *
  43550. * var array = [0, 1, 2],
  43551. * object = { 'a': array, 'b': array, 'c': array };
  43552. *
  43553. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  43554. * // => [2, 0]
  43555. *
  43556. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  43557. * // => [2, 0]
  43558. */function propertyOf(object){return function(path){return object==null?undefined:baseGet(object,path);};}/**
  43559. * Creates an array of numbers (positive and/or negative) progressing from
  43560. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  43561. * `start` is specified without an `end` or `step`. If `end` is not specified,
  43562. * it's set to `start` with `start` then set to `0`.
  43563. *
  43564. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  43565. * floating-point values which can produce unexpected results.
  43566. *
  43567. * @static
  43568. * @since 0.1.0
  43569. * @memberOf _
  43570. * @category Util
  43571. * @param {number} [start=0] The start of the range.
  43572. * @param {number} end The end of the range.
  43573. * @param {number} [step=1] The value to increment or decrement by.
  43574. * @returns {Array} Returns the range of numbers.
  43575. * @see _.inRange, _.rangeRight
  43576. * @example
  43577. *
  43578. * _.range(4);
  43579. * // => [0, 1, 2, 3]
  43580. *
  43581. * _.range(-4);
  43582. * // => [0, -1, -2, -3]
  43583. *
  43584. * _.range(1, 5);
  43585. * // => [1, 2, 3, 4]
  43586. *
  43587. * _.range(0, 20, 5);
  43588. * // => [0, 5, 10, 15]
  43589. *
  43590. * _.range(0, -4, -1);
  43591. * // => [0, -1, -2, -3]
  43592. *
  43593. * _.range(1, 4, 0);
  43594. * // => [1, 1, 1]
  43595. *
  43596. * _.range(0);
  43597. * // => []
  43598. */var range=createRange();/**
  43599. * This method is like `_.range` except that it populates values in
  43600. * descending order.
  43601. *
  43602. * @static
  43603. * @memberOf _
  43604. * @since 4.0.0
  43605. * @category Util
  43606. * @param {number} [start=0] The start of the range.
  43607. * @param {number} end The end of the range.
  43608. * @param {number} [step=1] The value to increment or decrement by.
  43609. * @returns {Array} Returns the range of numbers.
  43610. * @see _.inRange, _.range
  43611. * @example
  43612. *
  43613. * _.rangeRight(4);
  43614. * // => [3, 2, 1, 0]
  43615. *
  43616. * _.rangeRight(-4);
  43617. * // => [-3, -2, -1, 0]
  43618. *
  43619. * _.rangeRight(1, 5);
  43620. * // => [4, 3, 2, 1]
  43621. *
  43622. * _.rangeRight(0, 20, 5);
  43623. * // => [15, 10, 5, 0]
  43624. *
  43625. * _.rangeRight(0, -4, -1);
  43626. * // => [-3, -2, -1, 0]
  43627. *
  43628. * _.rangeRight(1, 4, 0);
  43629. * // => [1, 1, 1]
  43630. *
  43631. * _.rangeRight(0);
  43632. * // => []
  43633. */var rangeRight=createRange(true);/**
  43634. * This method returns a new empty array.
  43635. *
  43636. * @static
  43637. * @memberOf _
  43638. * @since 4.13.0
  43639. * @category Util
  43640. * @returns {Array} Returns the new empty array.
  43641. * @example
  43642. *
  43643. * var arrays = _.times(2, _.stubArray);
  43644. *
  43645. * console.log(arrays);
  43646. * // => [[], []]
  43647. *
  43648. * console.log(arrays[0] === arrays[1]);
  43649. * // => false
  43650. */function stubArray(){return[];}/**
  43651. * This method returns `false`.
  43652. *
  43653. * @static
  43654. * @memberOf _
  43655. * @since 4.13.0
  43656. * @category Util
  43657. * @returns {boolean} Returns `false`.
  43658. * @example
  43659. *
  43660. * _.times(2, _.stubFalse);
  43661. * // => [false, false]
  43662. */function stubFalse(){return false;}/**
  43663. * This method returns a new empty object.
  43664. *
  43665. * @static
  43666. * @memberOf _
  43667. * @since 4.13.0
  43668. * @category Util
  43669. * @returns {Object} Returns the new empty object.
  43670. * @example
  43671. *
  43672. * var objects = _.times(2, _.stubObject);
  43673. *
  43674. * console.log(objects);
  43675. * // => [{}, {}]
  43676. *
  43677. * console.log(objects[0] === objects[1]);
  43678. * // => false
  43679. */function stubObject(){return{};}/**
  43680. * This method returns an empty string.
  43681. *
  43682. * @static
  43683. * @memberOf _
  43684. * @since 4.13.0
  43685. * @category Util
  43686. * @returns {string} Returns the empty string.
  43687. * @example
  43688. *
  43689. * _.times(2, _.stubString);
  43690. * // => ['', '']
  43691. */function stubString(){return'';}/**
  43692. * This method returns `true`.
  43693. *
  43694. * @static
  43695. * @memberOf _
  43696. * @since 4.13.0
  43697. * @category Util
  43698. * @returns {boolean} Returns `true`.
  43699. * @example
  43700. *
  43701. * _.times(2, _.stubTrue);
  43702. * // => [true, true]
  43703. */function stubTrue(){return true;}/**
  43704. * Invokes the iteratee `n` times, returning an array of the results of
  43705. * each invocation. The iteratee is invoked with one argument; (index).
  43706. *
  43707. * @static
  43708. * @since 0.1.0
  43709. * @memberOf _
  43710. * @category Util
  43711. * @param {number} n The number of times to invoke `iteratee`.
  43712. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  43713. * @returns {Array} Returns the array of results.
  43714. * @example
  43715. *
  43716. * _.times(3, String);
  43717. * // => ['0', '1', '2']
  43718. *
  43719. * _.times(4, _.constant(0));
  43720. * // => [0, 0, 0, 0]
  43721. */function times(n,iteratee){n=toInteger(n);if(n<1||n>MAX_SAFE_INTEGER){return[];}var index=MAX_ARRAY_LENGTH,length=nativeMin(n,MAX_ARRAY_LENGTH);iteratee=getIteratee(iteratee);n-=MAX_ARRAY_LENGTH;var result=baseTimes(length,iteratee);while(++index<n){iteratee(index);}return result;}/**
  43722. * Converts `value` to a property path array.
  43723. *
  43724. * @static
  43725. * @memberOf _
  43726. * @since 4.0.0
  43727. * @category Util
  43728. * @param {*} value The value to convert.
  43729. * @returns {Array} Returns the new property path array.
  43730. * @example
  43731. *
  43732. * _.toPath('a.b.c');
  43733. * // => ['a', 'b', 'c']
  43734. *
  43735. * _.toPath('a[0].b.c');
  43736. * // => ['a', '0', 'b', 'c']
  43737. */function toPath(value){if(isArray(value)){return arrayMap(value,toKey);}return isSymbol(value)?[value]:copyArray(stringToPath(toString(value)));}/**
  43738. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  43739. *
  43740. * @static
  43741. * @since 0.1.0
  43742. * @memberOf _
  43743. * @category Util
  43744. * @param {string} [prefix=''] The value to prefix the ID with.
  43745. * @returns {string} Returns the unique ID.
  43746. * @example
  43747. *
  43748. * _.uniqueId('contact_');
  43749. * // => 'contact_104'
  43750. *
  43751. * _.uniqueId();
  43752. * // => '105'
  43753. */function uniqueId(prefix){var id=++idCounter;return toString(prefix)+id;}/*------------------------------------------------------------------------*//**
  43754. * Adds two numbers.
  43755. *
  43756. * @static
  43757. * @memberOf _
  43758. * @since 3.4.0
  43759. * @category Math
  43760. * @param {number} augend The first number in an addition.
  43761. * @param {number} addend The second number in an addition.
  43762. * @returns {number} Returns the total.
  43763. * @example
  43764. *
  43765. * _.add(6, 4);
  43766. * // => 10
  43767. */var add=createMathOperation(function(augend,addend){return augend+addend;},0);/**
  43768. * Computes `number` rounded up to `precision`.
  43769. *
  43770. * @static
  43771. * @memberOf _
  43772. * @since 3.10.0
  43773. * @category Math
  43774. * @param {number} number The number to round up.
  43775. * @param {number} [precision=0] The precision to round up to.
  43776. * @returns {number} Returns the rounded up number.
  43777. * @example
  43778. *
  43779. * _.ceil(4.006);
  43780. * // => 5
  43781. *
  43782. * _.ceil(6.004, 2);
  43783. * // => 6.01
  43784. *
  43785. * _.ceil(6040, -2);
  43786. * // => 6100
  43787. */var ceil=createRound('ceil');/**
  43788. * Divide two numbers.
  43789. *
  43790. * @static
  43791. * @memberOf _
  43792. * @since 4.7.0
  43793. * @category Math
  43794. * @param {number} dividend The first number in a division.
  43795. * @param {number} divisor The second number in a division.
  43796. * @returns {number} Returns the quotient.
  43797. * @example
  43798. *
  43799. * _.divide(6, 4);
  43800. * // => 1.5
  43801. */var divide=createMathOperation(function(dividend,divisor){return dividend/divisor;},1);/**
  43802. * Computes `number` rounded down to `precision`.
  43803. *
  43804. * @static
  43805. * @memberOf _
  43806. * @since 3.10.0
  43807. * @category Math
  43808. * @param {number} number The number to round down.
  43809. * @param {number} [precision=0] The precision to round down to.
  43810. * @returns {number} Returns the rounded down number.
  43811. * @example
  43812. *
  43813. * _.floor(4.006);
  43814. * // => 4
  43815. *
  43816. * _.floor(0.046, 2);
  43817. * // => 0.04
  43818. *
  43819. * _.floor(4060, -2);
  43820. * // => 4000
  43821. */var floor=createRound('floor');/**
  43822. * Computes the maximum value of `array`. If `array` is empty or falsey,
  43823. * `undefined` is returned.
  43824. *
  43825. * @static
  43826. * @since 0.1.0
  43827. * @memberOf _
  43828. * @category Math
  43829. * @param {Array} array The array to iterate over.
  43830. * @returns {*} Returns the maximum value.
  43831. * @example
  43832. *
  43833. * _.max([4, 2, 8, 6]);
  43834. * // => 8
  43835. *
  43836. * _.max([]);
  43837. * // => undefined
  43838. */function max(array){return array&&array.length?baseExtremum(array,identity,baseGt):undefined;}/**
  43839. * This method is like `_.max` except that it accepts `iteratee` which is
  43840. * invoked for each element in `array` to generate the criterion by which
  43841. * the value is ranked. The iteratee is invoked with one argument: (value).
  43842. *
  43843. * @static
  43844. * @memberOf _
  43845. * @since 4.0.0
  43846. * @category Math
  43847. * @param {Array} array The array to iterate over.
  43848. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  43849. * @returns {*} Returns the maximum value.
  43850. * @example
  43851. *
  43852. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  43853. *
  43854. * _.maxBy(objects, function(o) { return o.n; });
  43855. * // => { 'n': 2 }
  43856. *
  43857. * // The `_.property` iteratee shorthand.
  43858. * _.maxBy(objects, 'n');
  43859. * // => { 'n': 2 }
  43860. */function maxBy(array,iteratee){return array&&array.length?baseExtremum(array,getIteratee(iteratee,2),baseGt):undefined;}/**
  43861. * Computes the mean of the values in `array`.
  43862. *
  43863. * @static
  43864. * @memberOf _
  43865. * @since 4.0.0
  43866. * @category Math
  43867. * @param {Array} array The array to iterate over.
  43868. * @returns {number} Returns the mean.
  43869. * @example
  43870. *
  43871. * _.mean([4, 2, 8, 6]);
  43872. * // => 5
  43873. */function mean(array){return baseMean(array,identity);}/**
  43874. * This method is like `_.mean` except that it accepts `iteratee` which is
  43875. * invoked for each element in `array` to generate the value to be averaged.
  43876. * The iteratee is invoked with one argument: (value).
  43877. *
  43878. * @static
  43879. * @memberOf _
  43880. * @since 4.7.0
  43881. * @category Math
  43882. * @param {Array} array The array to iterate over.
  43883. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  43884. * @returns {number} Returns the mean.
  43885. * @example
  43886. *
  43887. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  43888. *
  43889. * _.meanBy(objects, function(o) { return o.n; });
  43890. * // => 5
  43891. *
  43892. * // The `_.property` iteratee shorthand.
  43893. * _.meanBy(objects, 'n');
  43894. * // => 5
  43895. */function meanBy(array,iteratee){return baseMean(array,getIteratee(iteratee,2));}/**
  43896. * Computes the minimum value of `array`. If `array` is empty or falsey,
  43897. * `undefined` is returned.
  43898. *
  43899. * @static
  43900. * @since 0.1.0
  43901. * @memberOf _
  43902. * @category Math
  43903. * @param {Array} array The array to iterate over.
  43904. * @returns {*} Returns the minimum value.
  43905. * @example
  43906. *
  43907. * _.min([4, 2, 8, 6]);
  43908. * // => 2
  43909. *
  43910. * _.min([]);
  43911. * // => undefined
  43912. */function min(array){return array&&array.length?baseExtremum(array,identity,baseLt):undefined;}/**
  43913. * This method is like `_.min` except that it accepts `iteratee` which is
  43914. * invoked for each element in `array` to generate the criterion by which
  43915. * the value is ranked. The iteratee is invoked with one argument: (value).
  43916. *
  43917. * @static
  43918. * @memberOf _
  43919. * @since 4.0.0
  43920. * @category Math
  43921. * @param {Array} array The array to iterate over.
  43922. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  43923. * @returns {*} Returns the minimum value.
  43924. * @example
  43925. *
  43926. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  43927. *
  43928. * _.minBy(objects, function(o) { return o.n; });
  43929. * // => { 'n': 1 }
  43930. *
  43931. * // The `_.property` iteratee shorthand.
  43932. * _.minBy(objects, 'n');
  43933. * // => { 'n': 1 }
  43934. */function minBy(array,iteratee){return array&&array.length?baseExtremum(array,getIteratee(iteratee,2),baseLt):undefined;}/**
  43935. * Multiply two numbers.
  43936. *
  43937. * @static
  43938. * @memberOf _
  43939. * @since 4.7.0
  43940. * @category Math
  43941. * @param {number} multiplier The first number in a multiplication.
  43942. * @param {number} multiplicand The second number in a multiplication.
  43943. * @returns {number} Returns the product.
  43944. * @example
  43945. *
  43946. * _.multiply(6, 4);
  43947. * // => 24
  43948. */var multiply=createMathOperation(function(multiplier,multiplicand){return multiplier*multiplicand;},1);/**
  43949. * Computes `number` rounded to `precision`.
  43950. *
  43951. * @static
  43952. * @memberOf _
  43953. * @since 3.10.0
  43954. * @category Math
  43955. * @param {number} number The number to round.
  43956. * @param {number} [precision=0] The precision to round to.
  43957. * @returns {number} Returns the rounded number.
  43958. * @example
  43959. *
  43960. * _.round(4.006);
  43961. * // => 4
  43962. *
  43963. * _.round(4.006, 2);
  43964. * // => 4.01
  43965. *
  43966. * _.round(4060, -2);
  43967. * // => 4100
  43968. */var round=createRound('round');/**
  43969. * Subtract two numbers.
  43970. *
  43971. * @static
  43972. * @memberOf _
  43973. * @since 4.0.0
  43974. * @category Math
  43975. * @param {number} minuend The first number in a subtraction.
  43976. * @param {number} subtrahend The second number in a subtraction.
  43977. * @returns {number} Returns the difference.
  43978. * @example
  43979. *
  43980. * _.subtract(6, 4);
  43981. * // => 2
  43982. */var subtract=createMathOperation(function(minuend,subtrahend){return minuend-subtrahend;},0);/**
  43983. * Computes the sum of the values in `array`.
  43984. *
  43985. * @static
  43986. * @memberOf _
  43987. * @since 3.4.0
  43988. * @category Math
  43989. * @param {Array} array The array to iterate over.
  43990. * @returns {number} Returns the sum.
  43991. * @example
  43992. *
  43993. * _.sum([4, 2, 8, 6]);
  43994. * // => 20
  43995. */function sum(array){return array&&array.length?baseSum(array,identity):0;}/**
  43996. * This method is like `_.sum` except that it accepts `iteratee` which is
  43997. * invoked for each element in `array` to generate the value to be summed.
  43998. * The iteratee is invoked with one argument: (value).
  43999. *
  44000. * @static
  44001. * @memberOf _
  44002. * @since 4.0.0
  44003. * @category Math
  44004. * @param {Array} array The array to iterate over.
  44005. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  44006. * @returns {number} Returns the sum.
  44007. * @example
  44008. *
  44009. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  44010. *
  44011. * _.sumBy(objects, function(o) { return o.n; });
  44012. * // => 20
  44013. *
  44014. * // The `_.property` iteratee shorthand.
  44015. * _.sumBy(objects, 'n');
  44016. * // => 20
  44017. */function sumBy(array,iteratee){return array&&array.length?baseSum(array,getIteratee(iteratee,2)):0;}/*------------------------------------------------------------------------*/// Add methods that return wrapped values in chain sequences.
  44018. lodash.after=after;lodash.ary=ary;lodash.assign=assign;lodash.assignIn=assignIn;lodash.assignInWith=assignInWith;lodash.assignWith=assignWith;lodash.at=at;lodash.before=before;lodash.bind=bind;lodash.bindAll=bindAll;lodash.bindKey=bindKey;lodash.castArray=castArray;lodash.chain=chain;lodash.chunk=chunk;lodash.compact=compact;lodash.concat=concat;lodash.cond=cond;lodash.conforms=conforms;lodash.constant=constant;lodash.countBy=countBy;lodash.create=create;lodash.curry=curry;lodash.curryRight=curryRight;lodash.debounce=debounce;lodash.defaults=defaults;lodash.defaultsDeep=defaultsDeep;lodash.defer=defer;lodash.delay=delay;lodash.difference=difference;lodash.differenceBy=differenceBy;lodash.differenceWith=differenceWith;lodash.drop=drop;lodash.dropRight=dropRight;lodash.dropRightWhile=dropRightWhile;lodash.dropWhile=dropWhile;lodash.fill=fill;lodash.filter=filter;lodash.flatMap=flatMap;lodash.flatMapDeep=flatMapDeep;lodash.flatMapDepth=flatMapDepth;lodash.flatten=flatten;lodash.flattenDeep=flattenDeep;lodash.flattenDepth=flattenDepth;lodash.flip=flip;lodash.flow=flow;lodash.flowRight=flowRight;lodash.fromPairs=fromPairs;lodash.functions=functions;lodash.functionsIn=functionsIn;lodash.groupBy=groupBy;lodash.initial=initial;lodash.intersection=intersection;lodash.intersectionBy=intersectionBy;lodash.intersectionWith=intersectionWith;lodash.invert=invert;lodash.invertBy=invertBy;lodash.invokeMap=invokeMap;lodash.iteratee=iteratee;lodash.keyBy=keyBy;lodash.keys=keys;lodash.keysIn=keysIn;lodash.map=map;lodash.mapKeys=mapKeys;lodash.mapValues=mapValues;lodash.matches=matches;lodash.matchesProperty=matchesProperty;lodash.memoize=memoize;lodash.merge=merge;lodash.mergeWith=mergeWith;lodash.method=method;lodash.methodOf=methodOf;lodash.mixin=mixin;lodash.negate=negate;lodash.nthArg=nthArg;lodash.omit=omit;lodash.omitBy=omitBy;lodash.once=once;lodash.orderBy=orderBy;lodash.over=over;lodash.overArgs=overArgs;lodash.overEvery=overEvery;lodash.overSome=overSome;lodash.partial=partial;lodash.partialRight=partialRight;lodash.partition=partition;lodash.pick=pick;lodash.pickBy=pickBy;lodash.property=property;lodash.propertyOf=propertyOf;lodash.pull=pull;lodash.pullAll=pullAll;lodash.pullAllBy=pullAllBy;lodash.pullAllWith=pullAllWith;lodash.pullAt=pullAt;lodash.range=range;lodash.rangeRight=rangeRight;lodash.rearg=rearg;lodash.reject=reject;lodash.remove=remove;lodash.rest=rest;lodash.reverse=reverse;lodash.sampleSize=sampleSize;lodash.set=set;lodash.setWith=setWith;lodash.shuffle=shuffle;lodash.slice=slice;lodash.sortBy=sortBy;lodash.sortedUniq=sortedUniq;lodash.sortedUniqBy=sortedUniqBy;lodash.split=split;lodash.spread=spread;lodash.tail=tail;lodash.take=take;lodash.takeRight=takeRight;lodash.takeRightWhile=takeRightWhile;lodash.takeWhile=takeWhile;lodash.tap=tap;lodash.throttle=throttle;lodash.thru=thru;lodash.toArray=toArray;lodash.toPairs=toPairs;lodash.toPairsIn=toPairsIn;lodash.toPath=toPath;lodash.toPlainObject=toPlainObject;lodash.transform=transform;lodash.unary=unary;lodash.union=union;lodash.unionBy=unionBy;lodash.unionWith=unionWith;lodash.uniq=uniq;lodash.uniqBy=uniqBy;lodash.uniqWith=uniqWith;lodash.unset=unset;lodash.unzip=unzip;lodash.unzipWith=unzipWith;lodash.update=update;lodash.updateWith=updateWith;lodash.values=values;lodash.valuesIn=valuesIn;lodash.without=without;lodash.words=words;lodash.wrap=wrap;lodash.xor=xor;lodash.xorBy=xorBy;lodash.xorWith=xorWith;lodash.zip=zip;lodash.zipObject=zipObject;lodash.zipObjectDeep=zipObjectDeep;lodash.zipWith=zipWith;// Add aliases.
  44019. lodash.entries=toPairs;lodash.entriesIn=toPairsIn;lodash.extend=assignIn;lodash.extendWith=assignInWith;// Add methods to `lodash.prototype`.
  44020. mixin(lodash,lodash);/*------------------------------------------------------------------------*/// Add methods that return unwrapped values in chain sequences.
  44021. lodash.add=add;lodash.attempt=attempt;lodash.camelCase=camelCase;lodash.capitalize=capitalize;lodash.ceil=ceil;lodash.clamp=clamp;lodash.clone=clone;lodash.cloneDeep=cloneDeep;lodash.cloneDeepWith=cloneDeepWith;lodash.cloneWith=cloneWith;lodash.conformsTo=conformsTo;lodash.deburr=deburr;lodash.defaultTo=defaultTo;lodash.divide=divide;lodash.endsWith=endsWith;lodash.eq=eq;lodash.escape=escape;lodash.escapeRegExp=escapeRegExp;lodash.every=every;lodash.find=find;lodash.findIndex=findIndex;lodash.findKey=findKey;lodash.findLast=findLast;lodash.findLastIndex=findLastIndex;lodash.findLastKey=findLastKey;lodash.floor=floor;lodash.forEach=forEach;lodash.forEachRight=forEachRight;lodash.forIn=forIn;lodash.forInRight=forInRight;lodash.forOwn=forOwn;lodash.forOwnRight=forOwnRight;lodash.get=get;lodash.gt=gt;lodash.gte=gte;lodash.has=has;lodash.hasIn=hasIn;lodash.head=head;lodash.identity=identity;lodash.includes=includes;lodash.indexOf=indexOf;lodash.inRange=inRange;lodash.invoke=invoke;lodash.isArguments=isArguments;lodash.isArray=isArray;lodash.isArrayBuffer=isArrayBuffer;lodash.isArrayLike=isArrayLike;lodash.isArrayLikeObject=isArrayLikeObject;lodash.isBoolean=isBoolean;lodash.isBuffer=isBuffer;lodash.isDate=isDate;lodash.isElement=isElement;lodash.isEmpty=isEmpty;lodash.isEqual=isEqual;lodash.isEqualWith=isEqualWith;lodash.isError=isError;lodash.isFinite=isFinite;lodash.isFunction=isFunction;lodash.isInteger=isInteger;lodash.isLength=isLength;lodash.isMap=isMap;lodash.isMatch=isMatch;lodash.isMatchWith=isMatchWith;lodash.isNaN=isNaN;lodash.isNative=isNative;lodash.isNil=isNil;lodash.isNull=isNull;lodash.isNumber=isNumber;lodash.isObject=isObject;lodash.isObjectLike=isObjectLike;lodash.isPlainObject=isPlainObject;lodash.isRegExp=isRegExp;lodash.isSafeInteger=isSafeInteger;lodash.isSet=isSet;lodash.isString=isString;lodash.isSymbol=isSymbol;lodash.isTypedArray=isTypedArray;lodash.isUndefined=isUndefined;lodash.isWeakMap=isWeakMap;lodash.isWeakSet=isWeakSet;lodash.join=join;lodash.kebabCase=kebabCase;lodash.last=last;lodash.lastIndexOf=lastIndexOf;lodash.lowerCase=lowerCase;lodash.lowerFirst=lowerFirst;lodash.lt=lt;lodash.lte=lte;lodash.max=max;lodash.maxBy=maxBy;lodash.mean=mean;lodash.meanBy=meanBy;lodash.min=min;lodash.minBy=minBy;lodash.stubArray=stubArray;lodash.stubFalse=stubFalse;lodash.stubObject=stubObject;lodash.stubString=stubString;lodash.stubTrue=stubTrue;lodash.multiply=multiply;lodash.nth=nth;lodash.noConflict=noConflict;lodash.noop=noop;lodash.now=now;lodash.pad=pad;lodash.padEnd=padEnd;lodash.padStart=padStart;lodash.parseInt=parseInt;lodash.random=random;lodash.reduce=reduce;lodash.reduceRight=reduceRight;lodash.repeat=repeat;lodash.replace=replace;lodash.result=result;lodash.round=round;lodash.runInContext=runInContext;lodash.sample=sample;lodash.size=size;lodash.snakeCase=snakeCase;lodash.some=some;lodash.sortedIndex=sortedIndex;lodash.sortedIndexBy=sortedIndexBy;lodash.sortedIndexOf=sortedIndexOf;lodash.sortedLastIndex=sortedLastIndex;lodash.sortedLastIndexBy=sortedLastIndexBy;lodash.sortedLastIndexOf=sortedLastIndexOf;lodash.startCase=startCase;lodash.startsWith=startsWith;lodash.subtract=subtract;lodash.sum=sum;lodash.sumBy=sumBy;lodash.template=template;lodash.times=times;lodash.toFinite=toFinite;lodash.toInteger=toInteger;lodash.toLength=toLength;lodash.toLower=toLower;lodash.toNumber=toNumber;lodash.toSafeInteger=toSafeInteger;lodash.toString=toString;lodash.toUpper=toUpper;lodash.trim=trim;lodash.trimEnd=trimEnd;lodash.trimStart=trimStart;lodash.truncate=truncate;lodash.unescape=unescape;lodash.uniqueId=uniqueId;lodash.upperCase=upperCase;lodash.upperFirst=upperFirst;// Add aliases.
  44022. lodash.each=forEach;lodash.eachRight=forEachRight;lodash.first=head;mixin(lodash,function(){var source={};baseForOwn(lodash,function(func,methodName){if(!hasOwnProperty.call(lodash.prototype,methodName)){source[methodName]=func;}});return source;}(),{'chain':false});/*------------------------------------------------------------------------*//**
  44023. * The semantic version number.
  44024. *
  44025. * @static
  44026. * @memberOf _
  44027. * @type {string}
  44028. */lodash.VERSION=VERSION;// Assign default placeholders.
  44029. arrayEach(['bind','bindKey','curry','curryRight','partial','partialRight'],function(methodName){lodash[methodName].placeholder=lodash;});// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  44030. arrayEach(['drop','take'],function(methodName,index){LazyWrapper.prototype[methodName]=function(n){n=n===undefined?1:nativeMax(toInteger(n),0);var result=this.__filtered__&&!index?new LazyWrapper(this):this.clone();if(result.__filtered__){result.__takeCount__=nativeMin(n,result.__takeCount__);}else{result.__views__.push({'size':nativeMin(n,MAX_ARRAY_LENGTH),'type':methodName+(result.__dir__<0?'Right':'')});}return result;};LazyWrapper.prototype[methodName+'Right']=function(n){return this.reverse()[methodName](n).reverse();};});// Add `LazyWrapper` methods that accept an `iteratee` value.
  44031. arrayEach(['filter','map','takeWhile'],function(methodName,index){var type=index+1,isFilter=type==LAZY_FILTER_FLAG||type==LAZY_WHILE_FLAG;LazyWrapper.prototype[methodName]=function(iteratee){var result=this.clone();result.__iteratees__.push({'iteratee':getIteratee(iteratee,3),'type':type});result.__filtered__=result.__filtered__||isFilter;return result;};});// Add `LazyWrapper` methods for `_.head` and `_.last`.
  44032. arrayEach(['head','last'],function(methodName,index){var takeName='take'+(index?'Right':'');LazyWrapper.prototype[methodName]=function(){return this[takeName](1).value()[0];};});// Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  44033. arrayEach(['initial','tail'],function(methodName,index){var dropName='drop'+(index?'':'Right');LazyWrapper.prototype[methodName]=function(){return this.__filtered__?new LazyWrapper(this):this[dropName](1);};});LazyWrapper.prototype.compact=function(){return this.filter(identity);};LazyWrapper.prototype.find=function(predicate){return this.filter(predicate).head();};LazyWrapper.prototype.findLast=function(predicate){return this.reverse().find(predicate);};LazyWrapper.prototype.invokeMap=baseRest(function(path,args){if(typeof path=='function'){return new LazyWrapper(this);}return this.map(function(value){return baseInvoke(value,path,args);});});LazyWrapper.prototype.reject=function(predicate){return this.filter(negate(getIteratee(predicate)));};LazyWrapper.prototype.slice=function(start,end){start=toInteger(start);var result=this;if(result.__filtered__&&(start>0||end<0)){return new LazyWrapper(result);}if(start<0){result=result.takeRight(-start);}else if(start){result=result.drop(start);}if(end!==undefined){end=toInteger(end);result=end<0?result.dropRight(-end):result.take(end-start);}return result;};LazyWrapper.prototype.takeRightWhile=function(predicate){return this.reverse().takeWhile(predicate).reverse();};LazyWrapper.prototype.toArray=function(){return this.take(MAX_ARRAY_LENGTH);};// Add `LazyWrapper` methods to `lodash.prototype`.
  44034. baseForOwn(LazyWrapper.prototype,function(func,methodName){var checkIteratee=/^(?:filter|find|map|reject)|While$/.test(methodName),isTaker=/^(?:head|last)$/.test(methodName),lodashFunc=lodash[isTaker?'take'+(methodName=='last'?'Right':''):methodName],retUnwrapped=isTaker||/^find/.test(methodName);if(!lodashFunc){return;}lodash.prototype[methodName]=function(){var value=this.__wrapped__,args=isTaker?[1]:arguments,isLazy=value instanceof LazyWrapper,iteratee=args[0],useLazy=isLazy||isArray(value);var interceptor=function interceptor(value){var result=lodashFunc.apply(lodash,arrayPush([value],args));return isTaker&&chainAll?result[0]:result;};if(useLazy&&checkIteratee&&typeof iteratee=='function'&&iteratee.length!=1){// Avoid lazy use if the iteratee has a "length" value other than `1`.
  44035. isLazy=useLazy=false;}var chainAll=this.__chain__,isHybrid=!!this.__actions__.length,isUnwrapped=retUnwrapped&&!chainAll,onlyLazy=isLazy&&!isHybrid;if(!retUnwrapped&&useLazy){value=onlyLazy?value:new LazyWrapper(this);var result=func.apply(value,args);result.__actions__.push({'func':thru,'args':[interceptor],'thisArg':undefined});return new LodashWrapper(result,chainAll);}if(isUnwrapped&&onlyLazy){return func.apply(this,args);}result=this.thru(interceptor);return isUnwrapped?isTaker?result.value()[0]:result.value():result;};});// Add `Array` methods to `lodash.prototype`.
  44036. arrayEach(['pop','push','shift','sort','splice','unshift'],function(methodName){var func=arrayProto[methodName],chainName=/^(?:push|sort|unshift)$/.test(methodName)?'tap':'thru',retUnwrapped=/^(?:pop|shift)$/.test(methodName);lodash.prototype[methodName]=function(){var args=arguments;if(retUnwrapped&&!this.__chain__){var value=this.value();return func.apply(isArray(value)?value:[],args);}return this[chainName](function(value){return func.apply(isArray(value)?value:[],args);});};});// Map minified method names to their real names.
  44037. baseForOwn(LazyWrapper.prototype,function(func,methodName){var lodashFunc=lodash[methodName];if(lodashFunc){var key=lodashFunc.name+'',names=realNames[key]||(realNames[key]=[]);names.push({'name':methodName,'func':lodashFunc});}});realNames[createHybrid(undefined,WRAP_BIND_KEY_FLAG).name]=[{'name':'wrapper','func':undefined}];// Add methods to `LazyWrapper`.
  44038. LazyWrapper.prototype.clone=lazyClone;LazyWrapper.prototype.reverse=lazyReverse;LazyWrapper.prototype.value=lazyValue;// Add chain sequence methods to the `lodash` wrapper.
  44039. lodash.prototype.at=wrapperAt;lodash.prototype.chain=wrapperChain;lodash.prototype.commit=wrapperCommit;lodash.prototype.next=wrapperNext;lodash.prototype.plant=wrapperPlant;lodash.prototype.reverse=wrapperReverse;lodash.prototype.toJSON=lodash.prototype.valueOf=lodash.prototype.value=wrapperValue;// Add lazy aliases.
  44040. lodash.prototype.first=lodash.prototype.head;if(symIterator){lodash.prototype[symIterator]=wrapperToIterator;}return lodash;};/*--------------------------------------------------------------------------*/// Export lodash.
  44041. var _=runInContext();// Some AMD build optimizers, like r.js, check for condition patterns like:
  44042. if(typeof define=='function'&&_typeof(define.amd)=='object'&&define.amd){// Expose Lodash on the global object to prevent errors when Lodash is
  44043. // loaded by a script tag in the presence of an AMD loader.
  44044. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  44045. // Use `_.noConflict` to remove Lodash from the global object.
  44046. root._=_;// Define as an anonymous module so, through path mapping, it can be
  44047. // referenced as the "underscore" module.
  44048. define(function(){return _;});}// Check for `exports` after `define` in case a build optimizer adds it.
  44049. else if(freeModule){// Export for Node.js.
  44050. (freeModule.exports=_)._=_;// Export for CommonJS support.
  44051. freeExports._=_;}else{// Export to the global object.
  44052. root._=_;}}).call(undefined);
  44053. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  44054. },{}],93:[function(require,module,exports){
  44055. 'use strict';
  44056. module.exports = minimatch;
  44057. minimatch.Minimatch = Minimatch;
  44058. var path = { sep: '/' };
  44059. try {
  44060. path = require('path');
  44061. } catch (er) {}
  44062. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
  44063. var expand = require('brace-expansion');
  44064. var plTypes = {
  44065. '!': { open: '(?:(?!(?:', close: '))[^/]*?)' },
  44066. '?': { open: '(?:', close: ')?' },
  44067. '+': { open: '(?:', close: ')+' },
  44068. '*': { open: '(?:', close: ')*' },
  44069. '@': { open: '(?:', close: ')' }
  44070. // any single thing other than /
  44071. // don't need to escape / when using new RegExp()
  44072. };var qmark = '[^/]';
  44073. // * => any number of characters
  44074. var star = qmark + '*?';
  44075. // ** when dots are allowed. Anything goes, except .. and .
  44076. // not (^ or / followed by one or two dots followed by $ or /),
  44077. // followed by anything, any number of times.
  44078. var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?';
  44079. // not a ^ or / followed by a dot,
  44080. // followed by anything, any number of times.
  44081. var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?';
  44082. // characters that need to be escaped in RegExp.
  44083. var reSpecials = charSet('().*{}+?[]^$\\!');
  44084. // "abc" -> { a:true, b:true, c:true }
  44085. function charSet(s) {
  44086. return s.split('').reduce(function (set, c) {
  44087. set[c] = true;
  44088. return set;
  44089. }, {});
  44090. }
  44091. // normalizes slashes.
  44092. var slashSplit = /\/+/;
  44093. minimatch.filter = filter;
  44094. function filter(pattern, options) {
  44095. options = options || {};
  44096. return function (p, i, list) {
  44097. return minimatch(p, pattern, options);
  44098. };
  44099. }
  44100. function ext(a, b) {
  44101. a = a || {};
  44102. b = b || {};
  44103. var t = {};
  44104. Object.keys(b).forEach(function (k) {
  44105. t[k] = b[k];
  44106. });
  44107. Object.keys(a).forEach(function (k) {
  44108. t[k] = a[k];
  44109. });
  44110. return t;
  44111. }
  44112. minimatch.defaults = function (def) {
  44113. if (!def || !Object.keys(def).length) return minimatch;
  44114. var orig = minimatch;
  44115. var m = function minimatch(p, pattern, options) {
  44116. return orig.minimatch(p, pattern, ext(def, options));
  44117. };
  44118. m.Minimatch = function Minimatch(pattern, options) {
  44119. return new orig.Minimatch(pattern, ext(def, options));
  44120. };
  44121. return m;
  44122. };
  44123. Minimatch.defaults = function (def) {
  44124. if (!def || !Object.keys(def).length) return Minimatch;
  44125. return minimatch.defaults(def).Minimatch;
  44126. };
  44127. function minimatch(p, pattern, options) {
  44128. if (typeof pattern !== 'string') {
  44129. throw new TypeError('glob pattern string required');
  44130. }
  44131. if (!options) options = {};
  44132. // shortcut: comments match nothing.
  44133. if (!options.nocomment && pattern.charAt(0) === '#') {
  44134. return false;
  44135. }
  44136. // "" only matches ""
  44137. if (pattern.trim() === '') return p === '';
  44138. return new Minimatch(pattern, options).match(p);
  44139. }
  44140. function Minimatch(pattern, options) {
  44141. if (!(this instanceof Minimatch)) {
  44142. return new Minimatch(pattern, options);
  44143. }
  44144. if (typeof pattern !== 'string') {
  44145. throw new TypeError('glob pattern string required');
  44146. }
  44147. if (!options) options = {};
  44148. pattern = pattern.trim();
  44149. // windows support: need to use /, not \
  44150. if (path.sep !== '/') {
  44151. pattern = pattern.split(path.sep).join('/');
  44152. }
  44153. this.options = options;
  44154. this.set = [];
  44155. this.pattern = pattern;
  44156. this.regexp = null;
  44157. this.negate = false;
  44158. this.comment = false;
  44159. this.empty = false;
  44160. // make the set of regexps etc.
  44161. this.make();
  44162. }
  44163. Minimatch.prototype.debug = function () {};
  44164. Minimatch.prototype.make = make;
  44165. function make() {
  44166. // don't do it more than once.
  44167. if (this._made) return;
  44168. var pattern = this.pattern;
  44169. var options = this.options;
  44170. // empty patterns and comments match nothing.
  44171. if (!options.nocomment && pattern.charAt(0) === '#') {
  44172. this.comment = true;
  44173. return;
  44174. }
  44175. if (!pattern) {
  44176. this.empty = true;
  44177. return;
  44178. }
  44179. // step 1: figure out negation, etc.
  44180. this.parseNegate();
  44181. // step 2: expand braces
  44182. var set = this.globSet = this.braceExpand();
  44183. if (options.debug) this.debug = console.error;
  44184. this.debug(this.pattern, set);
  44185. // step 3: now we have a set, so turn each one into a series of path-portion
  44186. // matching patterns.
  44187. // These will be regexps, except in the case of "**", which is
  44188. // set to the GLOBSTAR object for globstar behavior,
  44189. // and will not contain any / characters
  44190. set = this.globParts = set.map(function (s) {
  44191. return s.split(slashSplit);
  44192. });
  44193. this.debug(this.pattern, set);
  44194. // glob --> regexps
  44195. set = set.map(function (s, si, set) {
  44196. return s.map(this.parse, this);
  44197. }, this);
  44198. this.debug(this.pattern, set);
  44199. // filter out everything that didn't compile properly.
  44200. set = set.filter(function (s) {
  44201. return s.indexOf(false) === -1;
  44202. });
  44203. this.debug(this.pattern, set);
  44204. this.set = set;
  44205. }
  44206. Minimatch.prototype.parseNegate = parseNegate;
  44207. function parseNegate() {
  44208. var pattern = this.pattern;
  44209. var negate = false;
  44210. var options = this.options;
  44211. var negateOffset = 0;
  44212. if (options.nonegate) return;
  44213. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
  44214. negate = !negate;
  44215. negateOffset++;
  44216. }
  44217. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  44218. this.negate = negate;
  44219. }
  44220. // Brace expansion:
  44221. // a{b,c}d -> abd acd
  44222. // a{b,}c -> abc ac
  44223. // a{0..3}d -> a0d a1d a2d a3d
  44224. // a{b,c{d,e}f}g -> abg acdfg acefg
  44225. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  44226. //
  44227. // Invalid sets are not expanded.
  44228. // a{2..}b -> a{2..}b
  44229. // a{b}c -> a{b}c
  44230. minimatch.braceExpand = function (pattern, options) {
  44231. return braceExpand(pattern, options);
  44232. };
  44233. Minimatch.prototype.braceExpand = braceExpand;
  44234. function braceExpand(pattern, options) {
  44235. if (!options) {
  44236. if (this instanceof Minimatch) {
  44237. options = this.options;
  44238. } else {
  44239. options = {};
  44240. }
  44241. }
  44242. pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
  44243. if (typeof pattern === 'undefined') {
  44244. throw new TypeError('undefined pattern');
  44245. }
  44246. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  44247. // shortcut. no need to expand.
  44248. return [pattern];
  44249. }
  44250. return expand(pattern);
  44251. }
  44252. // parse a component of the expanded set.
  44253. // At this point, no pattern may contain "/" in it
  44254. // so we're going to return a 2d array, where each entry is the full
  44255. // pattern, split on '/', and then turned into a regular expression.
  44256. // A regexp is made at the end which joins each array with an
  44257. // escaped /, and another full one which joins each regexp with |.
  44258. //
  44259. // Following the lead of Bash 4.1, note that "**" only has special meaning
  44260. // when it is the *only* thing in a path portion. Otherwise, any series
  44261. // of * is equivalent to a single *. Globstar behavior is enabled by
  44262. // default, and can be disabled by setting options.noglobstar.
  44263. Minimatch.prototype.parse = parse;
  44264. var SUBPARSE = {};
  44265. function parse(pattern, isSub) {
  44266. if (pattern.length > 1024 * 64) {
  44267. throw new TypeError('pattern is too long');
  44268. }
  44269. var options = this.options;
  44270. // shortcuts
  44271. if (!options.noglobstar && pattern === '**') return GLOBSTAR;
  44272. if (pattern === '') return '';
  44273. var re = '';
  44274. var hasMagic = !!options.nocase;
  44275. var escaping = false;
  44276. // ? => one single character
  44277. var patternListStack = [];
  44278. var negativeLists = [];
  44279. var stateChar;
  44280. var inClass = false;
  44281. var reClassStart = -1;
  44282. var classStart = -1;
  44283. // . and .. never match anything that doesn't start with .,
  44284. // even when options.dot is set.
  44285. var patternStart = pattern.charAt(0) === '.' ? '' // anything
  44286. // not (start or / followed by . or .. followed by / or end)
  44287. : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
  44288. var self = this;
  44289. function clearStateChar() {
  44290. if (stateChar) {
  44291. // we had some state-tracking character
  44292. // that wasn't consumed by this pass.
  44293. switch (stateChar) {
  44294. case '*':
  44295. re += star;
  44296. hasMagic = true;
  44297. break;
  44298. case '?':
  44299. re += qmark;
  44300. hasMagic = true;
  44301. break;
  44302. default:
  44303. re += '\\' + stateChar;
  44304. break;
  44305. }
  44306. self.debug('clearStateChar %j %j', stateChar, re);
  44307. stateChar = false;
  44308. }
  44309. }
  44310. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  44311. this.debug('%s\t%s %s %j', pattern, i, re, c);
  44312. // skip over any that are escaped.
  44313. if (escaping && reSpecials[c]) {
  44314. re += '\\' + c;
  44315. escaping = false;
  44316. continue;
  44317. }
  44318. switch (c) {
  44319. case '/':
  44320. // completely not allowed, even escaped.
  44321. // Should already be path-split by now.
  44322. return false;
  44323. case '\\':
  44324. clearStateChar();
  44325. escaping = true;
  44326. continue;
  44327. // the various stateChar values
  44328. // for the "extglob" stuff.
  44329. case '?':
  44330. case '*':
  44331. case '+':
  44332. case '@':
  44333. case '!':
  44334. this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
  44335. // all of those are literals inside a class, except that
  44336. // the glob [!a] means [^a] in regexp
  44337. if (inClass) {
  44338. this.debug(' in class');
  44339. if (c === '!' && i === classStart + 1) c = '^';
  44340. re += c;
  44341. continue;
  44342. }
  44343. // if we already have a stateChar, then it means
  44344. // that there was something like ** or +? in there.
  44345. // Handle the stateChar, then proceed with this one.
  44346. self.debug('call clearStateChar %j', stateChar);
  44347. clearStateChar();
  44348. stateChar = c;
  44349. // if extglob is disabled, then +(asdf|foo) isn't a thing.
  44350. // just clear the statechar *now*, rather than even diving into
  44351. // the patternList stuff.
  44352. if (options.noext) clearStateChar();
  44353. continue;
  44354. case '(':
  44355. if (inClass) {
  44356. re += '(';
  44357. continue;
  44358. }
  44359. if (!stateChar) {
  44360. re += '\\(';
  44361. continue;
  44362. }
  44363. patternListStack.push({
  44364. type: stateChar,
  44365. start: i - 1,
  44366. reStart: re.length,
  44367. open: plTypes[stateChar].open,
  44368. close: plTypes[stateChar].close
  44369. });
  44370. // negation is (?:(?!js)[^/]*)
  44371. re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
  44372. this.debug('plType %j %j', stateChar, re);
  44373. stateChar = false;
  44374. continue;
  44375. case ')':
  44376. if (inClass || !patternListStack.length) {
  44377. re += '\\)';
  44378. continue;
  44379. }
  44380. clearStateChar();
  44381. hasMagic = true;
  44382. var pl = patternListStack.pop();
  44383. // negation is (?:(?!js)[^/]*)
  44384. // The others are (?:<pattern>)<type>
  44385. re += pl.close;
  44386. if (pl.type === '!') {
  44387. negativeLists.push(pl);
  44388. }
  44389. pl.reEnd = re.length;
  44390. continue;
  44391. case '|':
  44392. if (inClass || !patternListStack.length || escaping) {
  44393. re += '\\|';
  44394. escaping = false;
  44395. continue;
  44396. }
  44397. clearStateChar();
  44398. re += '|';
  44399. continue;
  44400. // these are mostly the same in regexp and glob
  44401. case '[':
  44402. // swallow any state-tracking char before the [
  44403. clearStateChar();
  44404. if (inClass) {
  44405. re += '\\' + c;
  44406. continue;
  44407. }
  44408. inClass = true;
  44409. classStart = i;
  44410. reClassStart = re.length;
  44411. re += c;
  44412. continue;
  44413. case ']':
  44414. // a right bracket shall lose its special
  44415. // meaning and represent itself in
  44416. // a bracket expression if it occurs
  44417. // first in the list. -- POSIX.2 2.8.3.2
  44418. if (i === classStart + 1 || !inClass) {
  44419. re += '\\' + c;
  44420. escaping = false;
  44421. continue;
  44422. }
  44423. // handle the case where we left a class open.
  44424. // "[z-a]" is valid, equivalent to "\[z-a\]"
  44425. if (inClass) {
  44426. // split where the last [ was, make sure we don't have
  44427. // an invalid re. if so, re-walk the contents of the
  44428. // would-be class to re-translate any characters that
  44429. // were passed through as-is
  44430. // TODO: It would probably be faster to determine this
  44431. // without a try/catch and a new RegExp, but it's tricky
  44432. // to do safely. For now, this is safe and works.
  44433. var cs = pattern.substring(classStart + 1, i);
  44434. try {
  44435. RegExp('[' + cs + ']');
  44436. } catch (er) {
  44437. // not a valid class!
  44438. var sp = this.parse(cs, SUBPARSE);
  44439. re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
  44440. hasMagic = hasMagic || sp[1];
  44441. inClass = false;
  44442. continue;
  44443. }
  44444. }
  44445. // finish up the class.
  44446. hasMagic = true;
  44447. inClass = false;
  44448. re += c;
  44449. continue;
  44450. default:
  44451. // swallow any state char that wasn't consumed
  44452. clearStateChar();
  44453. if (escaping) {
  44454. // no need
  44455. escaping = false;
  44456. } else if (reSpecials[c] && !(c === '^' && inClass)) {
  44457. re += '\\';
  44458. }
  44459. re += c;
  44460. } // switch
  44461. } // for
  44462. // handle the case where we left a class open.
  44463. // "[abc" is valid, equivalent to "\[abc"
  44464. if (inClass) {
  44465. // split where the last [ was, and escape it
  44466. // this is a huge pita. We now have to re-walk
  44467. // the contents of the would-be class to re-translate
  44468. // any characters that were passed through as-is
  44469. cs = pattern.substr(classStart + 1);
  44470. sp = this.parse(cs, SUBPARSE);
  44471. re = re.substr(0, reClassStart) + '\\[' + sp[0];
  44472. hasMagic = hasMagic || sp[1];
  44473. }
  44474. // handle the case where we had a +( thing at the *end*
  44475. // of the pattern.
  44476. // each pattern list stack adds 3 chars, and we need to go through
  44477. // and escape any | chars that were passed through as-is for the regexp.
  44478. // Go through and escape them, taking care not to double-escape any
  44479. // | chars that were already escaped.
  44480. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  44481. var tail = re.slice(pl.reStart + pl.open.length);
  44482. this.debug('setting tail', re, pl);
  44483. // maybe some even number of \, then maybe 1 \, followed by a |
  44484. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
  44485. if (!$2) {
  44486. // the | isn't already escaped, so escape it.
  44487. $2 = '\\';
  44488. }
  44489. // need to escape all those slashes *again*, without escaping the
  44490. // one that we need for escaping the | character. As it works out,
  44491. // escaping an even number of slashes can be done by simply repeating
  44492. // it exactly after itself. That's why this trick works.
  44493. //
  44494. // I am sorry that you have to see this.
  44495. return $1 + $1 + $2 + '|';
  44496. });
  44497. this.debug('tail=%j\n %s', tail, tail, pl, re);
  44498. var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
  44499. hasMagic = true;
  44500. re = re.slice(0, pl.reStart) + t + '\\(' + tail;
  44501. }
  44502. // handle trailing things that only matter at the very end.
  44503. clearStateChar();
  44504. if (escaping) {
  44505. // trailing \\
  44506. re += '\\\\';
  44507. }
  44508. // only need to apply the nodot start if the re starts with
  44509. // something that could conceivably capture a dot
  44510. var addPatternStart = false;
  44511. switch (re.charAt(0)) {
  44512. case '.':
  44513. case '[':
  44514. case '(':
  44515. addPatternStart = true;
  44516. }
  44517. // Hack to work around lack of negative lookbehind in JS
  44518. // A pattern like: *.!(x).!(y|z) needs to ensure that a name
  44519. // like 'a.xyz.yz' doesn't match. So, the first negative
  44520. // lookahead, has to look ALL the way ahead, to the end of
  44521. // the pattern.
  44522. for (var n = negativeLists.length - 1; n > -1; n--) {
  44523. var nl = negativeLists[n];
  44524. var nlBefore = re.slice(0, nl.reStart);
  44525. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
  44526. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
  44527. var nlAfter = re.slice(nl.reEnd);
  44528. nlLast += nlAfter;
  44529. // Handle nested stuff like *(*.js|!(*.json)), where open parens
  44530. // mean that we should *not* include the ) in the bit that is considered
  44531. // "after" the negated section.
  44532. var openParensBefore = nlBefore.split('(').length - 1;
  44533. var cleanAfter = nlAfter;
  44534. for (i = 0; i < openParensBefore; i++) {
  44535. cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
  44536. }
  44537. nlAfter = cleanAfter;
  44538. var dollar = '';
  44539. if (nlAfter === '' && isSub !== SUBPARSE) {
  44540. dollar = '$';
  44541. }
  44542. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
  44543. re = newRe;
  44544. }
  44545. // if the re is not "" at this point, then we need to make sure
  44546. // it doesn't match against an empty path part.
  44547. // Otherwise a/* will match a/, which it should not.
  44548. if (re !== '' && hasMagic) {
  44549. re = '(?=.)' + re;
  44550. }
  44551. if (addPatternStart) {
  44552. re = patternStart + re;
  44553. }
  44554. // parsing just a piece of a larger pattern.
  44555. if (isSub === SUBPARSE) {
  44556. return [re, hasMagic];
  44557. }
  44558. // skip the regexp for non-magical patterns
  44559. // unescape anything in it, though, so that it'll be
  44560. // an exact match against a file etc.
  44561. if (!hasMagic) {
  44562. return globUnescape(pattern);
  44563. }
  44564. var flags = options.nocase ? 'i' : '';
  44565. try {
  44566. var regExp = new RegExp('^' + re + '$', flags);
  44567. } catch (er) {
  44568. // If it was an invalid regular expression, then it can't match
  44569. // anything. This trick looks for a character after the end of
  44570. // the string, which is of course impossible, except in multi-line
  44571. // mode, but it's not a /m regex.
  44572. return new RegExp('$.');
  44573. }
  44574. regExp._glob = pattern;
  44575. regExp._src = re;
  44576. return regExp;
  44577. }
  44578. minimatch.makeRe = function (pattern, options) {
  44579. return new Minimatch(pattern, options || {}).makeRe();
  44580. };
  44581. Minimatch.prototype.makeRe = makeRe;
  44582. function makeRe() {
  44583. if (this.regexp || this.regexp === false) return this.regexp;
  44584. // at this point, this.set is a 2d array of partial
  44585. // pattern strings, or "**".
  44586. //
  44587. // It's better to use .match(). This function shouldn't
  44588. // be used, really, but it's pretty convenient sometimes,
  44589. // when you just want to work with a regex.
  44590. var set = this.set;
  44591. if (!set.length) {
  44592. this.regexp = false;
  44593. return this.regexp;
  44594. }
  44595. var options = this.options;
  44596. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
  44597. var flags = options.nocase ? 'i' : '';
  44598. var re = set.map(function (pattern) {
  44599. return pattern.map(function (p) {
  44600. return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
  44601. }).join('\\\/');
  44602. }).join('|');
  44603. // must match entire pattern
  44604. // ending in a * or ** will make it less strict.
  44605. re = '^(?:' + re + ')$';
  44606. // can match anything, as long as it's not this.
  44607. if (this.negate) re = '^(?!' + re + ').*$';
  44608. try {
  44609. this.regexp = new RegExp(re, flags);
  44610. } catch (ex) {
  44611. this.regexp = false;
  44612. }
  44613. return this.regexp;
  44614. }
  44615. minimatch.match = function (list, pattern, options) {
  44616. options = options || {};
  44617. var mm = new Minimatch(pattern, options);
  44618. list = list.filter(function (f) {
  44619. return mm.match(f);
  44620. });
  44621. if (mm.options.nonull && !list.length) {
  44622. list.push(pattern);
  44623. }
  44624. return list;
  44625. };
  44626. Minimatch.prototype.match = match;
  44627. function match(f, partial) {
  44628. this.debug('match', f, this.pattern);
  44629. // short-circuit in the case of busted things.
  44630. // comments, etc.
  44631. if (this.comment) return false;
  44632. if (this.empty) return f === '';
  44633. if (f === '/' && partial) return true;
  44634. var options = this.options;
  44635. // windows: need to use /, not \
  44636. if (path.sep !== '/') {
  44637. f = f.split(path.sep).join('/');
  44638. }
  44639. // treat the test path as a set of pathparts.
  44640. f = f.split(slashSplit);
  44641. this.debug(this.pattern, 'split', f);
  44642. // just ONE of the pattern sets in this.set needs to match
  44643. // in order for it to be valid. If negating, then just one
  44644. // match means that we have failed.
  44645. // Either way, return on the first hit.
  44646. var set = this.set;
  44647. this.debug(this.pattern, 'set', set);
  44648. // Find the basename of the path by looking for the last non-empty segment
  44649. var filename;
  44650. var i;
  44651. for (i = f.length - 1; i >= 0; i--) {
  44652. filename = f[i];
  44653. if (filename) break;
  44654. }
  44655. for (i = 0; i < set.length; i++) {
  44656. var pattern = set[i];
  44657. var file = f;
  44658. if (options.matchBase && pattern.length === 1) {
  44659. file = [filename];
  44660. }
  44661. var hit = this.matchOne(file, pattern, partial);
  44662. if (hit) {
  44663. if (options.flipNegate) return true;
  44664. return !this.negate;
  44665. }
  44666. }
  44667. // didn't get any hits. this is success if it's a negative
  44668. // pattern, failure otherwise.
  44669. if (options.flipNegate) return false;
  44670. return this.negate;
  44671. }
  44672. // set partial to true to test if, for example,
  44673. // "/a/b" matches the start of "/*/b/*/d"
  44674. // Partial means, if you run out of file before you run
  44675. // out of pattern, then that's fine, as long as all
  44676. // the parts match.
  44677. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  44678. var options = this.options;
  44679. this.debug('matchOne', { 'this': this, file: file, pattern: pattern });
  44680. this.debug('matchOne', file.length, pattern.length);
  44681. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  44682. this.debug('matchOne loop');
  44683. var p = pattern[pi];
  44684. var f = file[fi];
  44685. this.debug(pattern, p, f);
  44686. // should be impossible.
  44687. // some invalid regexp stuff in the set.
  44688. if (p === false) return false;
  44689. if (p === GLOBSTAR) {
  44690. this.debug('GLOBSTAR', [pattern, p, f]);
  44691. // "**"
  44692. // a/**/b/**/c would match the following:
  44693. // a/b/x/y/z/c
  44694. // a/x/y/z/b/c
  44695. // a/b/x/b/x/c
  44696. // a/b/c
  44697. // To do this, take the rest of the pattern after
  44698. // the **, and see if it would match the file remainder.
  44699. // If so, return success.
  44700. // If not, the ** "swallows" a segment, and try again.
  44701. // This is recursively awful.
  44702. //
  44703. // a/**/b/**/c matching a/b/x/y/z/c
  44704. // - a matches a
  44705. // - doublestar
  44706. // - matchOne(b/x/y/z/c, b/**/c)
  44707. // - b matches b
  44708. // - doublestar
  44709. // - matchOne(x/y/z/c, c) -> no
  44710. // - matchOne(y/z/c, c) -> no
  44711. // - matchOne(z/c, c) -> no
  44712. // - matchOne(c, c) yes, hit
  44713. var fr = fi;
  44714. var pr = pi + 1;
  44715. if (pr === pl) {
  44716. this.debug('** at the end');
  44717. // a ** at the end will just swallow the rest.
  44718. // We have found a match.
  44719. // however, it will not swallow /.x, unless
  44720. // options.dot is set.
  44721. // . and .. are *never* matched by **, for explosively
  44722. // exponential reasons.
  44723. for (; fi < fl; fi++) {
  44724. if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
  44725. }
  44726. return true;
  44727. }
  44728. // ok, let's see if we can swallow whatever we can.
  44729. while (fr < fl) {
  44730. var swallowee = file[fr];
  44731. this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
  44732. // XXX remove this slice. Just pass the start index.
  44733. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  44734. this.debug('globstar found match!', fr, fl, swallowee);
  44735. // found a match.
  44736. return true;
  44737. } else {
  44738. // can't swallow "." or ".." ever.
  44739. // can only swallow ".foo" when explicitly asked.
  44740. if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
  44741. this.debug('dot detected!', file, fr, pattern, pr);
  44742. break;
  44743. }
  44744. // ** swallows a segment, and continue.
  44745. this.debug('globstar swallow a segment, and continue');
  44746. fr++;
  44747. }
  44748. }
  44749. // no match was found.
  44750. // However, in partial mode, we can't say this is necessarily over.
  44751. // If there's more *pattern* left, then
  44752. if (partial) {
  44753. // ran out of file
  44754. this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
  44755. if (fr === fl) return true;
  44756. }
  44757. return false;
  44758. }
  44759. // something other than **
  44760. // non-magic patterns just have to match exactly
  44761. // patterns with magic have been turned into regexps.
  44762. var hit;
  44763. if (typeof p === 'string') {
  44764. if (options.nocase) {
  44765. hit = f.toLowerCase() === p.toLowerCase();
  44766. } else {
  44767. hit = f === p;
  44768. }
  44769. this.debug('string match', p, f, hit);
  44770. } else {
  44771. hit = f.match(p);
  44772. this.debug('pattern match', p, f, hit);
  44773. }
  44774. if (!hit) return false;
  44775. }
  44776. // Note: ending in / means that we'll get a final ""
  44777. // at the end of the pattern. This can only match a
  44778. // corresponding "" at the end of the file.
  44779. // If the file ends in /, then it can only match a
  44780. // a pattern that ends in /, unless the pattern just
  44781. // doesn't have any more for it. But, a/b/ should *not*
  44782. // match "a/b/*", even though "" matches against the
  44783. // [^/]*? pattern, except in partial mode, where it might
  44784. // simply not be reached yet.
  44785. // However, a/b/ should still satisfy a/*
  44786. // now either we fell off the end of the pattern, or we're done.
  44787. if (fi === fl && pi === pl) {
  44788. // ran out of pattern and filename at the same time.
  44789. // an exact hit!
  44790. return true;
  44791. } else if (fi === fl) {
  44792. // ran out of file, but still had pattern left.
  44793. // this is ok if we're doing the match as part of
  44794. // a glob fs traversal.
  44795. return partial;
  44796. } else if (pi === pl) {
  44797. // ran out of pattern, still have file left.
  44798. // this is only acceptable if we're on the very last
  44799. // empty segment of a file with a trailing slash.
  44800. // a/* should match a/b/
  44801. var emptyFileEnd = fi === fl - 1 && file[fi] === '';
  44802. return emptyFileEnd;
  44803. }
  44804. // should be unreachable.
  44805. throw new Error('wtf?');
  44806. };
  44807. // replace stuff like \* with *
  44808. function globUnescape(s) {
  44809. return s.replace(/\\(.)/g, '$1');
  44810. }
  44811. function regExpEscape(s) {
  44812. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
  44813. }
  44814. },{"brace-expansion":51,"path":96}],94:[function(require,module,exports){
  44815. 'use strict';
  44816. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  44817. /**
  44818. * Helpers.
  44819. */
  44820. var s = 1000;
  44821. var m = s * 60;
  44822. var h = m * 60;
  44823. var d = h * 24;
  44824. var w = d * 7;
  44825. var y = d * 365.25;
  44826. /**
  44827. * Parse or format the given `val`.
  44828. *
  44829. * Options:
  44830. *
  44831. * - `long` verbose formatting [false]
  44832. *
  44833. * @param {String|Number} val
  44834. * @param {Object} [options]
  44835. * @throws {Error} throw an error if val is not a non-empty string or a number
  44836. * @return {String|Number}
  44837. * @api public
  44838. */
  44839. module.exports = function (val, options) {
  44840. options = options || {};
  44841. var type = typeof val === 'undefined' ? 'undefined' : _typeof(val);
  44842. if (type === 'string' && val.length > 0) {
  44843. return parse(val);
  44844. } else if (type === 'number' && isNaN(val) === false) {
  44845. return options.long ? fmtLong(val) : fmtShort(val);
  44846. }
  44847. throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
  44848. };
  44849. /**
  44850. * Parse the given `str` and return milliseconds.
  44851. *
  44852. * @param {String} str
  44853. * @return {Number}
  44854. * @api private
  44855. */
  44856. function parse(str) {
  44857. str = String(str);
  44858. if (str.length > 100) {
  44859. return;
  44860. }
  44861. var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
  44862. if (!match) {
  44863. return;
  44864. }
  44865. var n = parseFloat(match[1]);
  44866. var type = (match[2] || 'ms').toLowerCase();
  44867. switch (type) {
  44868. case 'years':
  44869. case 'year':
  44870. case 'yrs':
  44871. case 'yr':
  44872. case 'y':
  44873. return n * y;
  44874. case 'weeks':
  44875. case 'week':
  44876. case 'w':
  44877. return n * w;
  44878. case 'days':
  44879. case 'day':
  44880. case 'd':
  44881. return n * d;
  44882. case 'hours':
  44883. case 'hour':
  44884. case 'hrs':
  44885. case 'hr':
  44886. case 'h':
  44887. return n * h;
  44888. case 'minutes':
  44889. case 'minute':
  44890. case 'mins':
  44891. case 'min':
  44892. case 'm':
  44893. return n * m;
  44894. case 'seconds':
  44895. case 'second':
  44896. case 'secs':
  44897. case 'sec':
  44898. case 's':
  44899. return n * s;
  44900. case 'milliseconds':
  44901. case 'millisecond':
  44902. case 'msecs':
  44903. case 'msec':
  44904. case 'ms':
  44905. return n;
  44906. default:
  44907. return undefined;
  44908. }
  44909. }
  44910. /**
  44911. * Short format for `ms`.
  44912. *
  44913. * @param {Number} ms
  44914. * @return {String}
  44915. * @api private
  44916. */
  44917. function fmtShort(ms) {
  44918. var msAbs = Math.abs(ms);
  44919. if (msAbs >= d) {
  44920. return Math.round(ms / d) + 'd';
  44921. }
  44922. if (msAbs >= h) {
  44923. return Math.round(ms / h) + 'h';
  44924. }
  44925. if (msAbs >= m) {
  44926. return Math.round(ms / m) + 'm';
  44927. }
  44928. if (msAbs >= s) {
  44929. return Math.round(ms / s) + 's';
  44930. }
  44931. return ms + 'ms';
  44932. }
  44933. /**
  44934. * Long format for `ms`.
  44935. *
  44936. * @param {Number} ms
  44937. * @return {String}
  44938. * @api private
  44939. */
  44940. function fmtLong(ms) {
  44941. var msAbs = Math.abs(ms);
  44942. if (msAbs >= d) {
  44943. return plural(ms, msAbs, d, 'day');
  44944. }
  44945. if (msAbs >= h) {
  44946. return plural(ms, msAbs, h, 'hour');
  44947. }
  44948. if (msAbs >= m) {
  44949. return plural(ms, msAbs, m, 'minute');
  44950. }
  44951. if (msAbs >= s) {
  44952. return plural(ms, msAbs, s, 'second');
  44953. }
  44954. return ms + ' ms';
  44955. }
  44956. /**
  44957. * Pluralization helper.
  44958. */
  44959. function plural(ms, msAbs, n, name) {
  44960. var isPlural = msAbs >= n * 1.5;
  44961. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  44962. }
  44963. },{}],95:[function(require,module,exports){
  44964. "use strict";
  44965. /*
  44966. * @version 1.4.0
  44967. * @date 2015-10-26
  44968. * @stability 3 - Stable
  44969. * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
  44970. * @license MIT License
  44971. */
  44972. var naturalCompare = function naturalCompare(a, b) {
  44973. var i,
  44974. codeA,
  44975. codeB = 1,
  44976. posA = 0,
  44977. posB = 0,
  44978. alphabet = String.alphabet;
  44979. function getCode(str, pos, code) {
  44980. if (code) {
  44981. for (i = pos; code = getCode(str, i), code < 76 && code > 65;) {
  44982. ++i;
  44983. }return +str.slice(pos - 1, i);
  44984. }
  44985. code = alphabet && alphabet.indexOf(str.charAt(pos));
  44986. return code > -1 ? code + 76 : (code = str.charCodeAt(pos) || 0, code < 45 || code > 127) ? code : code < 46 ? 65 // -
  44987. : code < 48 ? code - 1 : code < 58 ? code + 18 // 0-9
  44988. : code < 65 ? code - 11 : code < 91 ? code + 11 // A-Z
  44989. : code < 97 ? code - 37 : code < 123 ? code + 5 // a-z
  44990. : code - 63;
  44991. }
  44992. if ((a += "") != (b += "")) for (; codeB;) {
  44993. codeA = getCode(a, posA++);
  44994. codeB = getCode(b, posB++);
  44995. if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
  44996. codeA = getCode(a, posA, posA);
  44997. codeB = getCode(b, posB, posA = i);
  44998. posB = i;
  44999. }
  45000. if (codeA != codeB) return codeA < codeB ? -1 : 1;
  45001. }
  45002. return 0;
  45003. };
  45004. try {
  45005. module.exports = naturalCompare;
  45006. } catch (e) {
  45007. String.naturalCompare = naturalCompare;
  45008. }
  45009. },{}],96:[function(require,module,exports){
  45010. (function (process){
  45011. 'use strict';
  45012. // .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
  45013. // backported and transplited with Babel, with backwards-compat fixes
  45014. // Copyright Joyent, Inc. and other Node contributors.
  45015. //
  45016. // Permission is hereby granted, free of charge, to any person obtaining a
  45017. // copy of this software and associated documentation files (the
  45018. // "Software"), to deal in the Software without restriction, including
  45019. // without limitation the rights to use, copy, modify, merge, publish,
  45020. // distribute, sublicense, and/or sell copies of the Software, and to permit
  45021. // persons to whom the Software is furnished to do so, subject to the
  45022. // following conditions:
  45023. //
  45024. // The above copyright notice and this permission notice shall be included
  45025. // in all copies or substantial portions of the Software.
  45026. //
  45027. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  45028. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  45029. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  45030. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  45031. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  45032. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  45033. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  45034. // resolves . and .. elements in a path array with directory names there
  45035. // must be no slashes, empty elements, or device names (c:\) in the array
  45036. // (so also no leading and trailing slashes - it does not distinguish
  45037. // relative and absolute paths)
  45038. function normalizeArray(parts, allowAboveRoot) {
  45039. // if the path tries to go above the root, `up` ends up > 0
  45040. var up = 0;
  45041. for (var i = parts.length - 1; i >= 0; i--) {
  45042. var last = parts[i];
  45043. if (last === '.') {
  45044. parts.splice(i, 1);
  45045. } else if (last === '..') {
  45046. parts.splice(i, 1);
  45047. up++;
  45048. } else if (up) {
  45049. parts.splice(i, 1);
  45050. up--;
  45051. }
  45052. }
  45053. // if the path is allowed to go above the root, restore leading ..s
  45054. if (allowAboveRoot) {
  45055. for (; up--; up) {
  45056. parts.unshift('..');
  45057. }
  45058. }
  45059. return parts;
  45060. }
  45061. // path.resolve([from ...], to)
  45062. // posix version
  45063. exports.resolve = function () {
  45064. var resolvedPath = '',
  45065. resolvedAbsolute = false;
  45066. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  45067. var path = i >= 0 ? arguments[i] : process.cwd();
  45068. // Skip empty and invalid entries
  45069. if (typeof path !== 'string') {
  45070. throw new TypeError('Arguments to path.resolve must be strings');
  45071. } else if (!path) {
  45072. continue;
  45073. }
  45074. resolvedPath = path + '/' + resolvedPath;
  45075. resolvedAbsolute = path.charAt(0) === '/';
  45076. }
  45077. // At this point the path should be resolved to a full absolute path, but
  45078. // handle relative paths to be safe (might happen when process.cwd() fails)
  45079. // Normalize the path
  45080. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function (p) {
  45081. return !!p;
  45082. }), !resolvedAbsolute).join('/');
  45083. return (resolvedAbsolute ? '/' : '') + resolvedPath || '.';
  45084. };
  45085. // path.normalize(path)
  45086. // posix version
  45087. exports.normalize = function (path) {
  45088. var isAbsolute = exports.isAbsolute(path),
  45089. trailingSlash = substr(path, -1) === '/';
  45090. // Normalize the path
  45091. path = normalizeArray(filter(path.split('/'), function (p) {
  45092. return !!p;
  45093. }), !isAbsolute).join('/');
  45094. if (!path && !isAbsolute) {
  45095. path = '.';
  45096. }
  45097. if (path && trailingSlash) {
  45098. path += '/';
  45099. }
  45100. return (isAbsolute ? '/' : '') + path;
  45101. };
  45102. // posix version
  45103. exports.isAbsolute = function (path) {
  45104. return path.charAt(0) === '/';
  45105. };
  45106. // posix version
  45107. exports.join = function () {
  45108. var paths = Array.prototype.slice.call(arguments, 0);
  45109. return exports.normalize(filter(paths, function (p, index) {
  45110. if (typeof p !== 'string') {
  45111. throw new TypeError('Arguments to path.join must be strings');
  45112. }
  45113. return p;
  45114. }).join('/'));
  45115. };
  45116. // path.relative(from, to)
  45117. // posix version
  45118. exports.relative = function (from, to) {
  45119. from = exports.resolve(from).substr(1);
  45120. to = exports.resolve(to).substr(1);
  45121. function trim(arr) {
  45122. var start = 0;
  45123. for (; start < arr.length; start++) {
  45124. if (arr[start] !== '') break;
  45125. }
  45126. var end = arr.length - 1;
  45127. for (; end >= 0; end--) {
  45128. if (arr[end] !== '') break;
  45129. }
  45130. if (start > end) return [];
  45131. return arr.slice(start, end - start + 1);
  45132. }
  45133. var fromParts = trim(from.split('/'));
  45134. var toParts = trim(to.split('/'));
  45135. var length = Math.min(fromParts.length, toParts.length);
  45136. var samePartsLength = length;
  45137. for (var i = 0; i < length; i++) {
  45138. if (fromParts[i] !== toParts[i]) {
  45139. samePartsLength = i;
  45140. break;
  45141. }
  45142. }
  45143. var outputParts = [];
  45144. for (var i = samePartsLength; i < fromParts.length; i++) {
  45145. outputParts.push('..');
  45146. }
  45147. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  45148. return outputParts.join('/');
  45149. };
  45150. exports.sep = '/';
  45151. exports.delimiter = ':';
  45152. exports.dirname = function (path) {
  45153. if (typeof path !== 'string') path = path + '';
  45154. if (path.length === 0) return '.';
  45155. var code = path.charCodeAt(0);
  45156. var hasRoot = code === 47 /*/*/;
  45157. var end = -1;
  45158. var matchedSlash = true;
  45159. for (var i = path.length - 1; i >= 1; --i) {
  45160. code = path.charCodeAt(i);
  45161. if (code === 47 /*/*/) {
  45162. if (!matchedSlash) {
  45163. end = i;
  45164. break;
  45165. }
  45166. } else {
  45167. // We saw the first non-path separator
  45168. matchedSlash = false;
  45169. }
  45170. }
  45171. if (end === -1) return hasRoot ? '/' : '.';
  45172. if (hasRoot && end === 1) {
  45173. // return '//';
  45174. // Backwards-compat fix:
  45175. return '/';
  45176. }
  45177. return path.slice(0, end);
  45178. };
  45179. function basename(path) {
  45180. if (typeof path !== 'string') path = path + '';
  45181. var start = 0;
  45182. var end = -1;
  45183. var matchedSlash = true;
  45184. var i;
  45185. for (i = path.length - 1; i >= 0; --i) {
  45186. if (path.charCodeAt(i) === 47 /*/*/) {
  45187. // If we reached a path separator that was not part of a set of path
  45188. // separators at the end of the string, stop now
  45189. if (!matchedSlash) {
  45190. start = i + 1;
  45191. break;
  45192. }
  45193. } else if (end === -1) {
  45194. // We saw the first non-path separator, mark this as the end of our
  45195. // path component
  45196. matchedSlash = false;
  45197. end = i + 1;
  45198. }
  45199. }
  45200. if (end === -1) return '';
  45201. return path.slice(start, end);
  45202. }
  45203. // Uses a mixed approach for backwards-compatibility, as ext behavior changed
  45204. // in new Node.js versions, so only basename() above is backported here
  45205. exports.basename = function (path, ext) {
  45206. var f = basename(path);
  45207. if (ext && f.substr(-1 * ext.length) === ext) {
  45208. f = f.substr(0, f.length - ext.length);
  45209. }
  45210. return f;
  45211. };
  45212. exports.extname = function (path) {
  45213. if (typeof path !== 'string') path = path + '';
  45214. var startDot = -1;
  45215. var startPart = 0;
  45216. var end = -1;
  45217. var matchedSlash = true;
  45218. // Track the state of characters (if any) we see before our first dot and
  45219. // after any path separator we find
  45220. var preDotState = 0;
  45221. for (var i = path.length - 1; i >= 0; --i) {
  45222. var code = path.charCodeAt(i);
  45223. if (code === 47 /*/*/) {
  45224. // If we reached a path separator that was not part of a set of path
  45225. // separators at the end of the string, stop now
  45226. if (!matchedSlash) {
  45227. startPart = i + 1;
  45228. break;
  45229. }
  45230. continue;
  45231. }
  45232. if (end === -1) {
  45233. // We saw the first non-path separator, mark this as the end of our
  45234. // extension
  45235. matchedSlash = false;
  45236. end = i + 1;
  45237. }
  45238. if (code === 46 /*.*/) {
  45239. // If this is our first dot, mark it as the start of our extension
  45240. if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
  45241. } else if (startDot !== -1) {
  45242. // We saw a non-dot and non-path separator before our dot, so we should
  45243. // have a good chance at having a non-empty extension
  45244. preDotState = -1;
  45245. }
  45246. }
  45247. if (startDot === -1 || end === -1 ||
  45248. // We saw a non-dot character immediately before the dot
  45249. preDotState === 0 ||
  45250. // The (right-most) trimmed path component is exactly '..'
  45251. preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
  45252. return '';
  45253. }
  45254. return path.slice(startDot, end);
  45255. };
  45256. function filter(xs, f) {
  45257. if (xs.filter) return xs.filter(f);
  45258. var res = [];
  45259. for (var i = 0; i < xs.length; i++) {
  45260. if (f(xs[i], i, xs)) res.push(xs[i]);
  45261. }
  45262. return res;
  45263. }
  45264. // String.prototype.substr - negative index don't work in IE8
  45265. var substr = 'ab'.substr(-1) === 'b' ? function (str, start, len) {
  45266. return str.substr(start, len);
  45267. } : function (str, start, len) {
  45268. if (start < 0) start = str.length + start;
  45269. return str.substr(start, len);
  45270. };
  45271. }).call(this,require('_process'))
  45272. },{"_process":103}],97:[function(require,module,exports){
  45273. 'use strict';
  45274. // Generated by LiveScript 1.4.0
  45275. var apply,
  45276. curry,
  45277. flip,
  45278. fix,
  45279. over,
  45280. memoize,
  45281. slice$ = [].slice,
  45282. toString$ = {}.toString;
  45283. apply = curry$(function (f, list) {
  45284. return f.apply(null, list);
  45285. });
  45286. curry = function curry(f) {
  45287. return curry$(f);
  45288. };
  45289. flip = curry$(function (f, x, y) {
  45290. return f(y, x);
  45291. });
  45292. fix = function fix(f) {
  45293. return function (g) {
  45294. return function () {
  45295. return f(g(g)).apply(null, arguments);
  45296. };
  45297. }(function (g) {
  45298. return function () {
  45299. return f(g(g)).apply(null, arguments);
  45300. };
  45301. });
  45302. };
  45303. over = curry$(function (f, g, x, y) {
  45304. return f(g(x), g(y));
  45305. });
  45306. memoize = function memoize(f) {
  45307. var memo;
  45308. memo = {};
  45309. return function () {
  45310. var args, key, arg;
  45311. args = slice$.call(arguments);
  45312. key = function () {
  45313. var i$,
  45314. ref$,
  45315. len$,
  45316. results$ = [];
  45317. for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) {
  45318. arg = ref$[i$];
  45319. results$.push(arg + toString$.call(arg).slice(8, -1));
  45320. }
  45321. return results$;
  45322. }().join('');
  45323. return memo[key] = key in memo ? memo[key] : f.apply(null, args);
  45324. };
  45325. };
  45326. module.exports = {
  45327. curry: curry,
  45328. flip: flip,
  45329. fix: fix,
  45330. apply: apply,
  45331. over: over,
  45332. memoize: memoize
  45333. };
  45334. function curry$(f, bound) {
  45335. var context,
  45336. _curry = function _curry(args) {
  45337. return f.length > 1 ? function () {
  45338. var params = args ? args.concat() : [];
  45339. context = bound ? context || this : this;
  45340. return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
  45341. } : f;
  45342. };
  45343. return _curry();
  45344. }
  45345. },{}],98:[function(require,module,exports){
  45346. 'use strict';
  45347. // Generated by LiveScript 1.4.0
  45348. var each,
  45349. map,
  45350. compact,
  45351. filter,
  45352. reject,
  45353. partition,
  45354. find,
  45355. head,
  45356. first,
  45357. tail,
  45358. last,
  45359. initial,
  45360. empty,
  45361. reverse,
  45362. unique,
  45363. uniqueBy,
  45364. fold,
  45365. foldl,
  45366. fold1,
  45367. foldl1,
  45368. foldr,
  45369. foldr1,
  45370. unfoldr,
  45371. concat,
  45372. concatMap,
  45373. _flatten,
  45374. difference,
  45375. intersection,
  45376. union,
  45377. countBy,
  45378. groupBy,
  45379. andList,
  45380. orList,
  45381. any,
  45382. all,
  45383. sort,
  45384. sortWith,
  45385. sortBy,
  45386. sum,
  45387. product,
  45388. mean,
  45389. average,
  45390. maximum,
  45391. minimum,
  45392. maximumBy,
  45393. minimumBy,
  45394. scan,
  45395. scanl,
  45396. scan1,
  45397. scanl1,
  45398. scanr,
  45399. scanr1,
  45400. slice,
  45401. take,
  45402. drop,
  45403. splitAt,
  45404. takeWhile,
  45405. dropWhile,
  45406. span,
  45407. breakList,
  45408. zip,
  45409. zipWith,
  45410. zipAll,
  45411. zipAllWith,
  45412. at,
  45413. elemIndex,
  45414. elemIndices,
  45415. findIndex,
  45416. findIndices,
  45417. toString$ = {}.toString,
  45418. slice$ = [].slice;
  45419. each = curry$(function (f, xs) {
  45420. var i$, len$, x;
  45421. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45422. x = xs[i$];
  45423. f(x);
  45424. }
  45425. return xs;
  45426. });
  45427. map = curry$(function (f, xs) {
  45428. var i$,
  45429. len$,
  45430. x,
  45431. results$ = [];
  45432. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45433. x = xs[i$];
  45434. results$.push(f(x));
  45435. }
  45436. return results$;
  45437. });
  45438. compact = function compact(xs) {
  45439. var i$,
  45440. len$,
  45441. x,
  45442. results$ = [];
  45443. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45444. x = xs[i$];
  45445. if (x) {
  45446. results$.push(x);
  45447. }
  45448. }
  45449. return results$;
  45450. };
  45451. filter = curry$(function (f, xs) {
  45452. var i$,
  45453. len$,
  45454. x,
  45455. results$ = [];
  45456. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45457. x = xs[i$];
  45458. if (f(x)) {
  45459. results$.push(x);
  45460. }
  45461. }
  45462. return results$;
  45463. });
  45464. reject = curry$(function (f, xs) {
  45465. var i$,
  45466. len$,
  45467. x,
  45468. results$ = [];
  45469. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45470. x = xs[i$];
  45471. if (!f(x)) {
  45472. results$.push(x);
  45473. }
  45474. }
  45475. return results$;
  45476. });
  45477. partition = curry$(function (f, xs) {
  45478. var passed, failed, i$, len$, x;
  45479. passed = [];
  45480. failed = [];
  45481. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45482. x = xs[i$];
  45483. (f(x) ? passed : failed).push(x);
  45484. }
  45485. return [passed, failed];
  45486. });
  45487. find = curry$(function (f, xs) {
  45488. var i$, len$, x;
  45489. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45490. x = xs[i$];
  45491. if (f(x)) {
  45492. return x;
  45493. }
  45494. }
  45495. });
  45496. head = first = function first(xs) {
  45497. return xs[0];
  45498. };
  45499. tail = function tail(xs) {
  45500. if (!xs.length) {
  45501. return;
  45502. }
  45503. return xs.slice(1);
  45504. };
  45505. last = function last(xs) {
  45506. return xs[xs.length - 1];
  45507. };
  45508. initial = function initial(xs) {
  45509. if (!xs.length) {
  45510. return;
  45511. }
  45512. return xs.slice(0, -1);
  45513. };
  45514. empty = function empty(xs) {
  45515. return !xs.length;
  45516. };
  45517. reverse = function reverse(xs) {
  45518. return xs.concat().reverse();
  45519. };
  45520. unique = function unique(xs) {
  45521. var result, i$, len$, x;
  45522. result = [];
  45523. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45524. x = xs[i$];
  45525. if (!in$(x, result)) {
  45526. result.push(x);
  45527. }
  45528. }
  45529. return result;
  45530. };
  45531. uniqueBy = curry$(function (f, xs) {
  45532. var seen,
  45533. i$,
  45534. len$,
  45535. x,
  45536. val,
  45537. results$ = [];
  45538. seen = [];
  45539. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45540. x = xs[i$];
  45541. val = f(x);
  45542. if (in$(val, seen)) {
  45543. continue;
  45544. }
  45545. seen.push(val);
  45546. results$.push(x);
  45547. }
  45548. return results$;
  45549. });
  45550. fold = foldl = curry$(function (f, memo, xs) {
  45551. var i$, len$, x;
  45552. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45553. x = xs[i$];
  45554. memo = f(memo, x);
  45555. }
  45556. return memo;
  45557. });
  45558. fold1 = foldl1 = curry$(function (f, xs) {
  45559. return fold(f, xs[0], xs.slice(1));
  45560. });
  45561. foldr = curry$(function (f, memo, xs) {
  45562. var i$, x;
  45563. for (i$ = xs.length - 1; i$ >= 0; --i$) {
  45564. x = xs[i$];
  45565. memo = f(x, memo);
  45566. }
  45567. return memo;
  45568. });
  45569. foldr1 = curry$(function (f, xs) {
  45570. return foldr(f, xs[xs.length - 1], xs.slice(0, -1));
  45571. });
  45572. unfoldr = curry$(function (f, b) {
  45573. var result, x, that;
  45574. result = [];
  45575. x = b;
  45576. while ((that = f(x)) != null) {
  45577. result.push(that[0]);
  45578. x = that[1];
  45579. }
  45580. return result;
  45581. });
  45582. concat = function concat(xss) {
  45583. return [].concat.apply([], xss);
  45584. };
  45585. concatMap = curry$(function (f, xs) {
  45586. var x;
  45587. return [].concat.apply([], function () {
  45588. var i$,
  45589. ref$,
  45590. len$,
  45591. results$ = [];
  45592. for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
  45593. x = ref$[i$];
  45594. results$.push(f(x));
  45595. }
  45596. return results$;
  45597. }());
  45598. });
  45599. _flatten = function flatten(xs) {
  45600. var x;
  45601. return [].concat.apply([], function () {
  45602. var i$,
  45603. ref$,
  45604. len$,
  45605. results$ = [];
  45606. for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
  45607. x = ref$[i$];
  45608. if (toString$.call(x).slice(8, -1) === 'Array') {
  45609. results$.push(_flatten(x));
  45610. } else {
  45611. results$.push(x);
  45612. }
  45613. }
  45614. return results$;
  45615. }());
  45616. };
  45617. difference = function difference(xs) {
  45618. var yss, results, i$, len$, x, j$, len1$, ys;
  45619. yss = slice$.call(arguments, 1);
  45620. results = [];
  45621. outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45622. x = xs[i$];
  45623. for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
  45624. ys = yss[j$];
  45625. if (in$(x, ys)) {
  45626. continue outer;
  45627. }
  45628. }
  45629. results.push(x);
  45630. }
  45631. return results;
  45632. };
  45633. intersection = function intersection(xs) {
  45634. var yss, results, i$, len$, x, j$, len1$, ys;
  45635. yss = slice$.call(arguments, 1);
  45636. results = [];
  45637. outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45638. x = xs[i$];
  45639. for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
  45640. ys = yss[j$];
  45641. if (!in$(x, ys)) {
  45642. continue outer;
  45643. }
  45644. }
  45645. results.push(x);
  45646. }
  45647. return results;
  45648. };
  45649. union = function union() {
  45650. var xss, results, i$, len$, xs, j$, len1$, x;
  45651. xss = slice$.call(arguments);
  45652. results = [];
  45653. for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
  45654. xs = xss[i$];
  45655. for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) {
  45656. x = xs[j$];
  45657. if (!in$(x, results)) {
  45658. results.push(x);
  45659. }
  45660. }
  45661. }
  45662. return results;
  45663. };
  45664. countBy = curry$(function (f, xs) {
  45665. var results, i$, len$, x, key;
  45666. results = {};
  45667. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45668. x = xs[i$];
  45669. key = f(x);
  45670. if (key in results) {
  45671. results[key] += 1;
  45672. } else {
  45673. results[key] = 1;
  45674. }
  45675. }
  45676. return results;
  45677. });
  45678. groupBy = curry$(function (f, xs) {
  45679. var results, i$, len$, x, key;
  45680. results = {};
  45681. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45682. x = xs[i$];
  45683. key = f(x);
  45684. if (key in results) {
  45685. results[key].push(x);
  45686. } else {
  45687. results[key] = [x];
  45688. }
  45689. }
  45690. return results;
  45691. });
  45692. andList = function andList(xs) {
  45693. var i$, len$, x;
  45694. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45695. x = xs[i$];
  45696. if (!x) {
  45697. return false;
  45698. }
  45699. }
  45700. return true;
  45701. };
  45702. orList = function orList(xs) {
  45703. var i$, len$, x;
  45704. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45705. x = xs[i$];
  45706. if (x) {
  45707. return true;
  45708. }
  45709. }
  45710. return false;
  45711. };
  45712. any = curry$(function (f, xs) {
  45713. var i$, len$, x;
  45714. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45715. x = xs[i$];
  45716. if (f(x)) {
  45717. return true;
  45718. }
  45719. }
  45720. return false;
  45721. });
  45722. all = curry$(function (f, xs) {
  45723. var i$, len$, x;
  45724. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45725. x = xs[i$];
  45726. if (!f(x)) {
  45727. return false;
  45728. }
  45729. }
  45730. return true;
  45731. });
  45732. sort = function sort(xs) {
  45733. return xs.concat().sort(function (x, y) {
  45734. if (x > y) {
  45735. return 1;
  45736. } else if (x < y) {
  45737. return -1;
  45738. } else {
  45739. return 0;
  45740. }
  45741. });
  45742. };
  45743. sortWith = curry$(function (f, xs) {
  45744. return xs.concat().sort(f);
  45745. });
  45746. sortBy = curry$(function (f, xs) {
  45747. return xs.concat().sort(function (x, y) {
  45748. if (f(x) > f(y)) {
  45749. return 1;
  45750. } else if (f(x) < f(y)) {
  45751. return -1;
  45752. } else {
  45753. return 0;
  45754. }
  45755. });
  45756. });
  45757. sum = function sum(xs) {
  45758. var result, i$, len$, x;
  45759. result = 0;
  45760. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45761. x = xs[i$];
  45762. result += x;
  45763. }
  45764. return result;
  45765. };
  45766. product = function product(xs) {
  45767. var result, i$, len$, x;
  45768. result = 1;
  45769. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45770. x = xs[i$];
  45771. result *= x;
  45772. }
  45773. return result;
  45774. };
  45775. mean = average = function average(xs) {
  45776. var sum, i$, len$, x;
  45777. sum = 0;
  45778. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45779. x = xs[i$];
  45780. sum += x;
  45781. }
  45782. return sum / xs.length;
  45783. };
  45784. maximum = function maximum(xs) {
  45785. var max, i$, ref$, len$, x;
  45786. max = xs[0];
  45787. for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
  45788. x = ref$[i$];
  45789. if (x > max) {
  45790. max = x;
  45791. }
  45792. }
  45793. return max;
  45794. };
  45795. minimum = function minimum(xs) {
  45796. var min, i$, ref$, len$, x;
  45797. min = xs[0];
  45798. for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
  45799. x = ref$[i$];
  45800. if (x < min) {
  45801. min = x;
  45802. }
  45803. }
  45804. return min;
  45805. };
  45806. maximumBy = curry$(function (f, xs) {
  45807. var max, i$, ref$, len$, x;
  45808. max = xs[0];
  45809. for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
  45810. x = ref$[i$];
  45811. if (f(x) > f(max)) {
  45812. max = x;
  45813. }
  45814. }
  45815. return max;
  45816. });
  45817. minimumBy = curry$(function (f, xs) {
  45818. var min, i$, ref$, len$, x;
  45819. min = xs[0];
  45820. for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
  45821. x = ref$[i$];
  45822. if (f(x) < f(min)) {
  45823. min = x;
  45824. }
  45825. }
  45826. return min;
  45827. });
  45828. scan = scanl = curry$(function (f, memo, xs) {
  45829. var last, x;
  45830. last = memo;
  45831. return [memo].concat(function () {
  45832. var i$,
  45833. ref$,
  45834. len$,
  45835. results$ = [];
  45836. for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
  45837. x = ref$[i$];
  45838. results$.push(last = f(last, x));
  45839. }
  45840. return results$;
  45841. }());
  45842. });
  45843. scan1 = scanl1 = curry$(function (f, xs) {
  45844. if (!xs.length) {
  45845. return;
  45846. }
  45847. return scan(f, xs[0], xs.slice(1));
  45848. });
  45849. scanr = curry$(function (f, memo, xs) {
  45850. xs = xs.concat().reverse();
  45851. return scan(f, memo, xs).reverse();
  45852. });
  45853. scanr1 = curry$(function (f, xs) {
  45854. if (!xs.length) {
  45855. return;
  45856. }
  45857. xs = xs.concat().reverse();
  45858. return scan(f, xs[0], xs.slice(1)).reverse();
  45859. });
  45860. slice = curry$(function (x, y, xs) {
  45861. return xs.slice(x, y);
  45862. });
  45863. take = curry$(function (n, xs) {
  45864. if (n <= 0) {
  45865. return xs.slice(0, 0);
  45866. } else {
  45867. return xs.slice(0, n);
  45868. }
  45869. });
  45870. drop = curry$(function (n, xs) {
  45871. if (n <= 0) {
  45872. return xs;
  45873. } else {
  45874. return xs.slice(n);
  45875. }
  45876. });
  45877. splitAt = curry$(function (n, xs) {
  45878. return [take(n, xs), drop(n, xs)];
  45879. });
  45880. takeWhile = curry$(function (p, xs) {
  45881. var len, i;
  45882. len = xs.length;
  45883. if (!len) {
  45884. return xs;
  45885. }
  45886. i = 0;
  45887. while (i < len && p(xs[i])) {
  45888. i += 1;
  45889. }
  45890. return xs.slice(0, i);
  45891. });
  45892. dropWhile = curry$(function (p, xs) {
  45893. var len, i;
  45894. len = xs.length;
  45895. if (!len) {
  45896. return xs;
  45897. }
  45898. i = 0;
  45899. while (i < len && p(xs[i])) {
  45900. i += 1;
  45901. }
  45902. return xs.slice(i);
  45903. });
  45904. span = curry$(function (p, xs) {
  45905. return [takeWhile(p, xs), dropWhile(p, xs)];
  45906. });
  45907. breakList = curry$(function (p, xs) {
  45908. return span(compose$(p, not$), xs);
  45909. });
  45910. zip = curry$(function (xs, ys) {
  45911. var result, len, i$, len$, i, x;
  45912. result = [];
  45913. len = ys.length;
  45914. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45915. i = i$;
  45916. x = xs[i$];
  45917. if (i === len) {
  45918. break;
  45919. }
  45920. result.push([x, ys[i]]);
  45921. }
  45922. return result;
  45923. });
  45924. zipWith = curry$(function (f, xs, ys) {
  45925. var result, len, i$, len$, i, x;
  45926. result = [];
  45927. len = ys.length;
  45928. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  45929. i = i$;
  45930. x = xs[i$];
  45931. if (i === len) {
  45932. break;
  45933. }
  45934. result.push(f(x, ys[i]));
  45935. }
  45936. return result;
  45937. });
  45938. zipAll = function zipAll() {
  45939. var xss,
  45940. minLength,
  45941. i$,
  45942. len$,
  45943. xs,
  45944. ref$,
  45945. i,
  45946. lresult$,
  45947. j$,
  45948. results$ = [];
  45949. xss = slice$.call(arguments);
  45950. minLength = undefined;
  45951. for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
  45952. xs = xss[i$];
  45953. minLength <= (ref$ = xs.length) || (minLength = ref$);
  45954. }
  45955. for (i$ = 0; i$ < minLength; ++i$) {
  45956. i = i$;
  45957. lresult$ = [];
  45958. for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) {
  45959. xs = xss[j$];
  45960. lresult$.push(xs[i]);
  45961. }
  45962. results$.push(lresult$);
  45963. }
  45964. return results$;
  45965. };
  45966. zipAllWith = function zipAllWith(f) {
  45967. var xss,
  45968. minLength,
  45969. i$,
  45970. len$,
  45971. xs,
  45972. ref$,
  45973. i,
  45974. results$ = [];
  45975. xss = slice$.call(arguments, 1);
  45976. minLength = undefined;
  45977. for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
  45978. xs = xss[i$];
  45979. minLength <= (ref$ = xs.length) || (minLength = ref$);
  45980. }
  45981. for (i$ = 0; i$ < minLength; ++i$) {
  45982. i = i$;
  45983. results$.push(f.apply(null, fn$()));
  45984. }
  45985. return results$;
  45986. function fn$() {
  45987. var i$,
  45988. ref$,
  45989. len$,
  45990. results$ = [];
  45991. for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) {
  45992. xs = ref$[i$];
  45993. results$.push(xs[i]);
  45994. }
  45995. return results$;
  45996. }
  45997. };
  45998. at = curry$(function (n, xs) {
  45999. if (n < 0) {
  46000. return xs[xs.length + n];
  46001. } else {
  46002. return xs[n];
  46003. }
  46004. });
  46005. elemIndex = curry$(function (el, xs) {
  46006. var i$, len$, i, x;
  46007. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  46008. i = i$;
  46009. x = xs[i$];
  46010. if (x === el) {
  46011. return i;
  46012. }
  46013. }
  46014. });
  46015. elemIndices = curry$(function (el, xs) {
  46016. var i$,
  46017. len$,
  46018. i,
  46019. x,
  46020. results$ = [];
  46021. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  46022. i = i$;
  46023. x = xs[i$];
  46024. if (x === el) {
  46025. results$.push(i);
  46026. }
  46027. }
  46028. return results$;
  46029. });
  46030. findIndex = curry$(function (f, xs) {
  46031. var i$, len$, i, x;
  46032. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  46033. i = i$;
  46034. x = xs[i$];
  46035. if (f(x)) {
  46036. return i;
  46037. }
  46038. }
  46039. });
  46040. findIndices = curry$(function (f, xs) {
  46041. var i$,
  46042. len$,
  46043. i,
  46044. x,
  46045. results$ = [];
  46046. for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
  46047. i = i$;
  46048. x = xs[i$];
  46049. if (f(x)) {
  46050. results$.push(i);
  46051. }
  46052. }
  46053. return results$;
  46054. });
  46055. module.exports = {
  46056. each: each,
  46057. map: map,
  46058. filter: filter,
  46059. compact: compact,
  46060. reject: reject,
  46061. partition: partition,
  46062. find: find,
  46063. head: head,
  46064. first: first,
  46065. tail: tail,
  46066. last: last,
  46067. initial: initial,
  46068. empty: empty,
  46069. reverse: reverse,
  46070. difference: difference,
  46071. intersection: intersection,
  46072. union: union,
  46073. countBy: countBy,
  46074. groupBy: groupBy,
  46075. fold: fold,
  46076. fold1: fold1,
  46077. foldl: foldl,
  46078. foldl1: foldl1,
  46079. foldr: foldr,
  46080. foldr1: foldr1,
  46081. unfoldr: unfoldr,
  46082. andList: andList,
  46083. orList: orList,
  46084. any: any,
  46085. all: all,
  46086. unique: unique,
  46087. uniqueBy: uniqueBy,
  46088. sort: sort,
  46089. sortWith: sortWith,
  46090. sortBy: sortBy,
  46091. sum: sum,
  46092. product: product,
  46093. mean: mean,
  46094. average: average,
  46095. concat: concat,
  46096. concatMap: concatMap,
  46097. flatten: _flatten,
  46098. maximum: maximum,
  46099. minimum: minimum,
  46100. maximumBy: maximumBy,
  46101. minimumBy: minimumBy,
  46102. scan: scan,
  46103. scan1: scan1,
  46104. scanl: scanl,
  46105. scanl1: scanl1,
  46106. scanr: scanr,
  46107. scanr1: scanr1,
  46108. slice: slice,
  46109. take: take,
  46110. drop: drop,
  46111. splitAt: splitAt,
  46112. takeWhile: takeWhile,
  46113. dropWhile: dropWhile,
  46114. span: span,
  46115. breakList: breakList,
  46116. zip: zip,
  46117. zipWith: zipWith,
  46118. zipAll: zipAll,
  46119. zipAllWith: zipAllWith,
  46120. at: at,
  46121. elemIndex: elemIndex,
  46122. elemIndices: elemIndices,
  46123. findIndex: findIndex,
  46124. findIndices: findIndices
  46125. };
  46126. function curry$(f, bound) {
  46127. var context,
  46128. _curry = function _curry(args) {
  46129. return f.length > 1 ? function () {
  46130. var params = args ? args.concat() : [];
  46131. context = bound ? context || this : this;
  46132. return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
  46133. } : f;
  46134. };
  46135. return _curry();
  46136. }
  46137. function in$(x, xs) {
  46138. var i = -1,
  46139. l = xs.length >>> 0;
  46140. while (++i < l) {
  46141. if (x === xs[i]) return true;
  46142. }return false;
  46143. }
  46144. function compose$() {
  46145. var functions = arguments;
  46146. return function () {
  46147. var i, result;
  46148. result = functions[0].apply(this, arguments);
  46149. for (i = 1; i < functions.length; ++i) {
  46150. result = functions[i](result);
  46151. }
  46152. return result;
  46153. };
  46154. }
  46155. function not$(x) {
  46156. return !x;
  46157. }
  46158. },{}],99:[function(require,module,exports){
  46159. "use strict";
  46160. // Generated by LiveScript 1.4.0
  46161. var max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm;
  46162. max = curry$(function (x$, y$) {
  46163. return x$ > y$ ? x$ : y$;
  46164. });
  46165. min = curry$(function (x$, y$) {
  46166. return x$ < y$ ? x$ : y$;
  46167. });
  46168. negate = function negate(x) {
  46169. return -x;
  46170. };
  46171. abs = Math.abs;
  46172. signum = function signum(x) {
  46173. if (x < 0) {
  46174. return -1;
  46175. } else if (x > 0) {
  46176. return 1;
  46177. } else {
  46178. return 0;
  46179. }
  46180. };
  46181. quot = curry$(function (x, y) {
  46182. return ~~(x / y);
  46183. });
  46184. rem = curry$(function (x$, y$) {
  46185. return x$ % y$;
  46186. });
  46187. div = curry$(function (x, y) {
  46188. return Math.floor(x / y);
  46189. });
  46190. mod = curry$(function (x$, y$) {
  46191. var ref$;
  46192. return (x$ % (ref$ = y$) + ref$) % ref$;
  46193. });
  46194. recip = function recip(it) {
  46195. return 1 / it;
  46196. };
  46197. pi = Math.PI;
  46198. tau = pi * 2;
  46199. exp = Math.exp;
  46200. sqrt = Math.sqrt;
  46201. ln = Math.log;
  46202. pow = curry$(function (x$, y$) {
  46203. return Math.pow(x$, y$);
  46204. });
  46205. sin = Math.sin;
  46206. tan = Math.tan;
  46207. cos = Math.cos;
  46208. asin = Math.asin;
  46209. acos = Math.acos;
  46210. atan = Math.atan;
  46211. atan2 = curry$(function (x, y) {
  46212. return Math.atan2(x, y);
  46213. });
  46214. truncate = function truncate(x) {
  46215. return ~~x;
  46216. };
  46217. round = Math.round;
  46218. ceiling = Math.ceil;
  46219. floor = Math.floor;
  46220. isItNaN = function isItNaN(x) {
  46221. return x !== x;
  46222. };
  46223. even = function even(x) {
  46224. return x % 2 === 0;
  46225. };
  46226. odd = function odd(x) {
  46227. return x % 2 !== 0;
  46228. };
  46229. gcd = curry$(function (x, y) {
  46230. var z;
  46231. x = Math.abs(x);
  46232. y = Math.abs(y);
  46233. while (y !== 0) {
  46234. z = x % y;
  46235. x = y;
  46236. y = z;
  46237. }
  46238. return x;
  46239. });
  46240. lcm = curry$(function (x, y) {
  46241. return Math.abs(Math.floor(x / gcd(x, y) * y));
  46242. });
  46243. module.exports = {
  46244. max: max,
  46245. min: min,
  46246. negate: negate,
  46247. abs: abs,
  46248. signum: signum,
  46249. quot: quot,
  46250. rem: rem,
  46251. div: div,
  46252. mod: mod,
  46253. recip: recip,
  46254. pi: pi,
  46255. tau: tau,
  46256. exp: exp,
  46257. sqrt: sqrt,
  46258. ln: ln,
  46259. pow: pow,
  46260. sin: sin,
  46261. tan: tan,
  46262. cos: cos,
  46263. acos: acos,
  46264. asin: asin,
  46265. atan: atan,
  46266. atan2: atan2,
  46267. truncate: truncate,
  46268. round: round,
  46269. ceiling: ceiling,
  46270. floor: floor,
  46271. isItNaN: isItNaN,
  46272. even: even,
  46273. odd: odd,
  46274. gcd: gcd,
  46275. lcm: lcm
  46276. };
  46277. function curry$(f, bound) {
  46278. var context,
  46279. _curry = function _curry(args) {
  46280. return f.length > 1 ? function () {
  46281. var params = args ? args.concat() : [];
  46282. context = bound ? context || this : this;
  46283. return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
  46284. } : f;
  46285. };
  46286. return _curry();
  46287. }
  46288. },{}],100:[function(require,module,exports){
  46289. "use strict";
  46290. // Generated by LiveScript 1.4.0
  46291. var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find;
  46292. values = function values(object) {
  46293. var i$,
  46294. x,
  46295. results$ = [];
  46296. for (i$ in object) {
  46297. x = object[i$];
  46298. results$.push(x);
  46299. }
  46300. return results$;
  46301. };
  46302. keys = function keys(object) {
  46303. var x,
  46304. results$ = [];
  46305. for (x in object) {
  46306. results$.push(x);
  46307. }
  46308. return results$;
  46309. };
  46310. pairsToObj = function pairsToObj(object) {
  46311. var i$,
  46312. len$,
  46313. x,
  46314. resultObj$ = {};
  46315. for (i$ = 0, len$ = object.length; i$ < len$; ++i$) {
  46316. x = object[i$];
  46317. resultObj$[x[0]] = x[1];
  46318. }
  46319. return resultObj$;
  46320. };
  46321. objToPairs = function objToPairs(object) {
  46322. var key,
  46323. value,
  46324. results$ = [];
  46325. for (key in object) {
  46326. value = object[key];
  46327. results$.push([key, value]);
  46328. }
  46329. return results$;
  46330. };
  46331. listsToObj = curry$(function (keys, values) {
  46332. var i$,
  46333. len$,
  46334. i,
  46335. key,
  46336. resultObj$ = {};
  46337. for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) {
  46338. i = i$;
  46339. key = keys[i$];
  46340. resultObj$[key] = values[i];
  46341. }
  46342. return resultObj$;
  46343. });
  46344. objToLists = function objToLists(object) {
  46345. var keys, values, key, value;
  46346. keys = [];
  46347. values = [];
  46348. for (key in object) {
  46349. value = object[key];
  46350. keys.push(key);
  46351. values.push(value);
  46352. }
  46353. return [keys, values];
  46354. };
  46355. empty = function empty(object) {
  46356. var x;
  46357. for (x in object) {
  46358. return false;
  46359. }
  46360. return true;
  46361. };
  46362. each = curry$(function (f, object) {
  46363. var i$, x;
  46364. for (i$ in object) {
  46365. x = object[i$];
  46366. f(x);
  46367. }
  46368. return object;
  46369. });
  46370. map = curry$(function (f, object) {
  46371. var k,
  46372. x,
  46373. resultObj$ = {};
  46374. for (k in object) {
  46375. x = object[k];
  46376. resultObj$[k] = f(x);
  46377. }
  46378. return resultObj$;
  46379. });
  46380. compact = function compact(object) {
  46381. var k,
  46382. x,
  46383. resultObj$ = {};
  46384. for (k in object) {
  46385. x = object[k];
  46386. if (x) {
  46387. resultObj$[k] = x;
  46388. }
  46389. }
  46390. return resultObj$;
  46391. };
  46392. filter = curry$(function (f, object) {
  46393. var k,
  46394. x,
  46395. resultObj$ = {};
  46396. for (k in object) {
  46397. x = object[k];
  46398. if (f(x)) {
  46399. resultObj$[k] = x;
  46400. }
  46401. }
  46402. return resultObj$;
  46403. });
  46404. reject = curry$(function (f, object) {
  46405. var k,
  46406. x,
  46407. resultObj$ = {};
  46408. for (k in object) {
  46409. x = object[k];
  46410. if (!f(x)) {
  46411. resultObj$[k] = x;
  46412. }
  46413. }
  46414. return resultObj$;
  46415. });
  46416. partition = curry$(function (f, object) {
  46417. var passed, failed, k, x;
  46418. passed = {};
  46419. failed = {};
  46420. for (k in object) {
  46421. x = object[k];
  46422. (f(x) ? passed : failed)[k] = x;
  46423. }
  46424. return [passed, failed];
  46425. });
  46426. find = curry$(function (f, object) {
  46427. var i$, x;
  46428. for (i$ in object) {
  46429. x = object[i$];
  46430. if (f(x)) {
  46431. return x;
  46432. }
  46433. }
  46434. });
  46435. module.exports = {
  46436. values: values,
  46437. keys: keys,
  46438. pairsToObj: pairsToObj,
  46439. objToPairs: objToPairs,
  46440. listsToObj: listsToObj,
  46441. objToLists: objToLists,
  46442. empty: empty,
  46443. each: each,
  46444. map: map,
  46445. filter: filter,
  46446. compact: compact,
  46447. reject: reject,
  46448. partition: partition,
  46449. find: find
  46450. };
  46451. function curry$(f, bound) {
  46452. var context,
  46453. _curry = function _curry(args) {
  46454. return f.length > 1 ? function () {
  46455. var params = args ? args.concat() : [];
  46456. context = bound ? context || this : this;
  46457. return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
  46458. } : f;
  46459. };
  46460. return _curry();
  46461. }
  46462. },{}],101:[function(require,module,exports){
  46463. 'use strict';
  46464. // Generated by LiveScript 1.4.0
  46465. var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize;
  46466. split = curry$(function (sep, str) {
  46467. return str.split(sep);
  46468. });
  46469. join = curry$(function (sep, xs) {
  46470. return xs.join(sep);
  46471. });
  46472. lines = function lines(str) {
  46473. if (!str.length) {
  46474. return [];
  46475. }
  46476. return str.split('\n');
  46477. };
  46478. unlines = function unlines(it) {
  46479. return it.join('\n');
  46480. };
  46481. words = function words(str) {
  46482. if (!str.length) {
  46483. return [];
  46484. }
  46485. return str.split(/[ ]+/);
  46486. };
  46487. unwords = function unwords(it) {
  46488. return it.join(' ');
  46489. };
  46490. chars = function chars(it) {
  46491. return it.split('');
  46492. };
  46493. unchars = function unchars(it) {
  46494. return it.join('');
  46495. };
  46496. reverse = function reverse(str) {
  46497. return str.split('').reverse().join('');
  46498. };
  46499. repeat = curry$(function (n, str) {
  46500. var result, i$;
  46501. result = '';
  46502. for (i$ = 0; i$ < n; ++i$) {
  46503. result += str;
  46504. }
  46505. return result;
  46506. });
  46507. capitalize = function capitalize(str) {
  46508. return str.charAt(0).toUpperCase() + str.slice(1);
  46509. };
  46510. camelize = function camelize(it) {
  46511. return it.replace(/[-_]+(.)?/g, function (arg$, c) {
  46512. return (c != null ? c : '').toUpperCase();
  46513. });
  46514. };
  46515. dasherize = function dasherize(str) {
  46516. return str.replace(/([^-A-Z])([A-Z]+)/g, function (arg$, lower, upper) {
  46517. return lower + "-" + (upper.length > 1 ? upper : upper.toLowerCase());
  46518. }).replace(/^([A-Z]+)/, function (arg$, upper) {
  46519. if (upper.length > 1) {
  46520. return upper + "-";
  46521. } else {
  46522. return upper.toLowerCase();
  46523. }
  46524. });
  46525. };
  46526. module.exports = {
  46527. split: split,
  46528. join: join,
  46529. lines: lines,
  46530. unlines: unlines,
  46531. words: words,
  46532. unwords: unwords,
  46533. chars: chars,
  46534. unchars: unchars,
  46535. reverse: reverse,
  46536. repeat: repeat,
  46537. capitalize: capitalize,
  46538. camelize: camelize,
  46539. dasherize: dasherize
  46540. };
  46541. function curry$(f, bound) {
  46542. var context,
  46543. _curry = function _curry(args) {
  46544. return f.length > 1 ? function () {
  46545. var params = args ? args.concat() : [];
  46546. context = bound ? context || this : this;
  46547. return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
  46548. } : f;
  46549. };
  46550. return _curry();
  46551. }
  46552. },{}],102:[function(require,module,exports){
  46553. 'use strict';
  46554. // Generated by LiveScript 1.4.0
  46555. var Func,
  46556. List,
  46557. Obj,
  46558. Str,
  46559. Num,
  46560. id,
  46561. isType,
  46562. replicate,
  46563. prelude,
  46564. toString$ = {}.toString;
  46565. Func = require('./Func.js');
  46566. List = require('./List.js');
  46567. Obj = require('./Obj.js');
  46568. Str = require('./Str.js');
  46569. Num = require('./Num.js');
  46570. id = function id(x) {
  46571. return x;
  46572. };
  46573. isType = curry$(function (type, x) {
  46574. return toString$.call(x).slice(8, -1) === type;
  46575. });
  46576. replicate = curry$(function (n, x) {
  46577. var i$,
  46578. results$ = [];
  46579. for (i$ = 0; i$ < n; ++i$) {
  46580. results$.push(x);
  46581. }
  46582. return results$;
  46583. });
  46584. Str.empty = List.empty;
  46585. Str.slice = List.slice;
  46586. Str.take = List.take;
  46587. Str.drop = List.drop;
  46588. Str.splitAt = List.splitAt;
  46589. Str.takeWhile = List.takeWhile;
  46590. Str.dropWhile = List.dropWhile;
  46591. Str.span = List.span;
  46592. Str.breakStr = List.breakList;
  46593. prelude = {
  46594. Func: Func,
  46595. List: List,
  46596. Obj: Obj,
  46597. Str: Str,
  46598. Num: Num,
  46599. id: id,
  46600. isType: isType,
  46601. replicate: replicate
  46602. };
  46603. prelude.each = List.each;
  46604. prelude.map = List.map;
  46605. prelude.filter = List.filter;
  46606. prelude.compact = List.compact;
  46607. prelude.reject = List.reject;
  46608. prelude.partition = List.partition;
  46609. prelude.find = List.find;
  46610. prelude.head = List.head;
  46611. prelude.first = List.first;
  46612. prelude.tail = List.tail;
  46613. prelude.last = List.last;
  46614. prelude.initial = List.initial;
  46615. prelude.empty = List.empty;
  46616. prelude.reverse = List.reverse;
  46617. prelude.difference = List.difference;
  46618. prelude.intersection = List.intersection;
  46619. prelude.union = List.union;
  46620. prelude.countBy = List.countBy;
  46621. prelude.groupBy = List.groupBy;
  46622. prelude.fold = List.fold;
  46623. prelude.foldl = List.foldl;
  46624. prelude.fold1 = List.fold1;
  46625. prelude.foldl1 = List.foldl1;
  46626. prelude.foldr = List.foldr;
  46627. prelude.foldr1 = List.foldr1;
  46628. prelude.unfoldr = List.unfoldr;
  46629. prelude.andList = List.andList;
  46630. prelude.orList = List.orList;
  46631. prelude.any = List.any;
  46632. prelude.all = List.all;
  46633. prelude.unique = List.unique;
  46634. prelude.uniqueBy = List.uniqueBy;
  46635. prelude.sort = List.sort;
  46636. prelude.sortWith = List.sortWith;
  46637. prelude.sortBy = List.sortBy;
  46638. prelude.sum = List.sum;
  46639. prelude.product = List.product;
  46640. prelude.mean = List.mean;
  46641. prelude.average = List.average;
  46642. prelude.concat = List.concat;
  46643. prelude.concatMap = List.concatMap;
  46644. prelude.flatten = List.flatten;
  46645. prelude.maximum = List.maximum;
  46646. prelude.minimum = List.minimum;
  46647. prelude.maximumBy = List.maximumBy;
  46648. prelude.minimumBy = List.minimumBy;
  46649. prelude.scan = List.scan;
  46650. prelude.scanl = List.scanl;
  46651. prelude.scan1 = List.scan1;
  46652. prelude.scanl1 = List.scanl1;
  46653. prelude.scanr = List.scanr;
  46654. prelude.scanr1 = List.scanr1;
  46655. prelude.slice = List.slice;
  46656. prelude.take = List.take;
  46657. prelude.drop = List.drop;
  46658. prelude.splitAt = List.splitAt;
  46659. prelude.takeWhile = List.takeWhile;
  46660. prelude.dropWhile = List.dropWhile;
  46661. prelude.span = List.span;
  46662. prelude.breakList = List.breakList;
  46663. prelude.zip = List.zip;
  46664. prelude.zipWith = List.zipWith;
  46665. prelude.zipAll = List.zipAll;
  46666. prelude.zipAllWith = List.zipAllWith;
  46667. prelude.at = List.at;
  46668. prelude.elemIndex = List.elemIndex;
  46669. prelude.elemIndices = List.elemIndices;
  46670. prelude.findIndex = List.findIndex;
  46671. prelude.findIndices = List.findIndices;
  46672. prelude.apply = Func.apply;
  46673. prelude.curry = Func.curry;
  46674. prelude.flip = Func.flip;
  46675. prelude.fix = Func.fix;
  46676. prelude.over = Func.over;
  46677. prelude.split = Str.split;
  46678. prelude.join = Str.join;
  46679. prelude.lines = Str.lines;
  46680. prelude.unlines = Str.unlines;
  46681. prelude.words = Str.words;
  46682. prelude.unwords = Str.unwords;
  46683. prelude.chars = Str.chars;
  46684. prelude.unchars = Str.unchars;
  46685. prelude.repeat = Str.repeat;
  46686. prelude.capitalize = Str.capitalize;
  46687. prelude.camelize = Str.camelize;
  46688. prelude.dasherize = Str.dasherize;
  46689. prelude.values = Obj.values;
  46690. prelude.keys = Obj.keys;
  46691. prelude.pairsToObj = Obj.pairsToObj;
  46692. prelude.objToPairs = Obj.objToPairs;
  46693. prelude.listsToObj = Obj.listsToObj;
  46694. prelude.objToLists = Obj.objToLists;
  46695. prelude.max = Num.max;
  46696. prelude.min = Num.min;
  46697. prelude.negate = Num.negate;
  46698. prelude.abs = Num.abs;
  46699. prelude.signum = Num.signum;
  46700. prelude.quot = Num.quot;
  46701. prelude.rem = Num.rem;
  46702. prelude.div = Num.div;
  46703. prelude.mod = Num.mod;
  46704. prelude.recip = Num.recip;
  46705. prelude.pi = Num.pi;
  46706. prelude.tau = Num.tau;
  46707. prelude.exp = Num.exp;
  46708. prelude.sqrt = Num.sqrt;
  46709. prelude.ln = Num.ln;
  46710. prelude.pow = Num.pow;
  46711. prelude.sin = Num.sin;
  46712. prelude.tan = Num.tan;
  46713. prelude.cos = Num.cos;
  46714. prelude.acos = Num.acos;
  46715. prelude.asin = Num.asin;
  46716. prelude.atan = Num.atan;
  46717. prelude.atan2 = Num.atan2;
  46718. prelude.truncate = Num.truncate;
  46719. prelude.round = Num.round;
  46720. prelude.ceiling = Num.ceiling;
  46721. prelude.floor = Num.floor;
  46722. prelude.isItNaN = Num.isItNaN;
  46723. prelude.even = Num.even;
  46724. prelude.odd = Num.odd;
  46725. prelude.gcd = Num.gcd;
  46726. prelude.lcm = Num.lcm;
  46727. prelude.VERSION = '1.1.2';
  46728. module.exports = prelude;
  46729. function curry$(f, bound) {
  46730. var context,
  46731. _curry = function _curry(args) {
  46732. return f.length > 1 ? function () {
  46733. var params = args ? args.concat() : [];
  46734. context = bound ? context || this : this;
  46735. return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
  46736. } : f;
  46737. };
  46738. return _curry();
  46739. }
  46740. },{"./Func.js":97,"./List.js":98,"./Num.js":99,"./Obj.js":100,"./Str.js":101}],103:[function(require,module,exports){
  46741. 'use strict';
  46742. // shim for using process in browser
  46743. var process = module.exports = {};
  46744. // cached from whatever global is present so that test runners that stub it
  46745. // don't break things. But we need to wrap it in a try catch in case it is
  46746. // wrapped in strict mode code which doesn't define any globals. It's inside a
  46747. // function because try/catches deoptimize in certain engines.
  46748. var cachedSetTimeout;
  46749. var cachedClearTimeout;
  46750. function defaultSetTimout() {
  46751. throw new Error('setTimeout has not been defined');
  46752. }
  46753. function defaultClearTimeout() {
  46754. throw new Error('clearTimeout has not been defined');
  46755. }
  46756. (function () {
  46757. try {
  46758. if (typeof setTimeout === 'function') {
  46759. cachedSetTimeout = setTimeout;
  46760. } else {
  46761. cachedSetTimeout = defaultSetTimout;
  46762. }
  46763. } catch (e) {
  46764. cachedSetTimeout = defaultSetTimout;
  46765. }
  46766. try {
  46767. if (typeof clearTimeout === 'function') {
  46768. cachedClearTimeout = clearTimeout;
  46769. } else {
  46770. cachedClearTimeout = defaultClearTimeout;
  46771. }
  46772. } catch (e) {
  46773. cachedClearTimeout = defaultClearTimeout;
  46774. }
  46775. })();
  46776. function runTimeout(fun) {
  46777. if (cachedSetTimeout === setTimeout) {
  46778. //normal enviroments in sane situations
  46779. return setTimeout(fun, 0);
  46780. }
  46781. // if setTimeout wasn't available but was latter defined
  46782. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  46783. cachedSetTimeout = setTimeout;
  46784. return setTimeout(fun, 0);
  46785. }
  46786. try {
  46787. // when when somebody has screwed with setTimeout but no I.E. maddness
  46788. return cachedSetTimeout(fun, 0);
  46789. } catch (e) {
  46790. try {
  46791. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  46792. return cachedSetTimeout.call(null, fun, 0);
  46793. } catch (e) {
  46794. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  46795. return cachedSetTimeout.call(this, fun, 0);
  46796. }
  46797. }
  46798. }
  46799. function runClearTimeout(marker) {
  46800. if (cachedClearTimeout === clearTimeout) {
  46801. //normal enviroments in sane situations
  46802. return clearTimeout(marker);
  46803. }
  46804. // if clearTimeout wasn't available but was latter defined
  46805. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  46806. cachedClearTimeout = clearTimeout;
  46807. return clearTimeout(marker);
  46808. }
  46809. try {
  46810. // when when somebody has screwed with setTimeout but no I.E. maddness
  46811. return cachedClearTimeout(marker);
  46812. } catch (e) {
  46813. try {
  46814. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  46815. return cachedClearTimeout.call(null, marker);
  46816. } catch (e) {
  46817. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  46818. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  46819. return cachedClearTimeout.call(this, marker);
  46820. }
  46821. }
  46822. }
  46823. var queue = [];
  46824. var draining = false;
  46825. var currentQueue;
  46826. var queueIndex = -1;
  46827. function cleanUpNextTick() {
  46828. if (!draining || !currentQueue) {
  46829. return;
  46830. }
  46831. draining = false;
  46832. if (currentQueue.length) {
  46833. queue = currentQueue.concat(queue);
  46834. } else {
  46835. queueIndex = -1;
  46836. }
  46837. if (queue.length) {
  46838. drainQueue();
  46839. }
  46840. }
  46841. function drainQueue() {
  46842. if (draining) {
  46843. return;
  46844. }
  46845. var timeout = runTimeout(cleanUpNextTick);
  46846. draining = true;
  46847. var len = queue.length;
  46848. while (len) {
  46849. currentQueue = queue;
  46850. queue = [];
  46851. while (++queueIndex < len) {
  46852. if (currentQueue) {
  46853. currentQueue[queueIndex].run();
  46854. }
  46855. }
  46856. queueIndex = -1;
  46857. len = queue.length;
  46858. }
  46859. currentQueue = null;
  46860. draining = false;
  46861. runClearTimeout(timeout);
  46862. }
  46863. process.nextTick = function (fun) {
  46864. var args = new Array(arguments.length - 1);
  46865. if (arguments.length > 1) {
  46866. for (var i = 1; i < arguments.length; i++) {
  46867. args[i - 1] = arguments[i];
  46868. }
  46869. }
  46870. queue.push(new Item(fun, args));
  46871. if (queue.length === 1 && !draining) {
  46872. runTimeout(drainQueue);
  46873. }
  46874. };
  46875. // v8 likes predictible objects
  46876. function Item(fun, array) {
  46877. this.fun = fun;
  46878. this.array = array;
  46879. }
  46880. Item.prototype.run = function () {
  46881. this.fun.apply(null, this.array);
  46882. };
  46883. process.title = 'browser';
  46884. process.browser = true;
  46885. process.env = {};
  46886. process.argv = [];
  46887. process.version = ''; // empty string to avoid regexp issues
  46888. process.versions = {};
  46889. function noop() {}
  46890. process.on = noop;
  46891. process.addListener = noop;
  46892. process.once = noop;
  46893. process.off = noop;
  46894. process.removeListener = noop;
  46895. process.removeAllListeners = noop;
  46896. process.emit = noop;
  46897. process.prependListener = noop;
  46898. process.prependOnceListener = noop;
  46899. process.listeners = function (name) {
  46900. return [];
  46901. };
  46902. process.binding = function (name) {
  46903. throw new Error('process.binding is not supported');
  46904. };
  46905. process.cwd = function () {
  46906. return '/';
  46907. };
  46908. process.chdir = function (dir) {
  46909. throw new Error('process.chdir is not supported');
  46910. };
  46911. process.umask = function () {
  46912. return 0;
  46913. };
  46914. },{}],104:[function(require,module,exports){
  46915. /*! @author Toru Nagashima <https://github.com/mysticatea> */
  46916. 'use strict';
  46917. 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; }; }();
  46918. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  46919. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  46920. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  46921. Object.defineProperty(exports, '__esModule', { value: true });
  46922. var ast = /*#__PURE__*/Object.freeze({});
  46923. function isIdStart(cp) {
  46924. if (cp < 0x41) return false;
  46925. if (cp < 0x5b) return true;
  46926. if (cp < 0x61) return false;
  46927. if (cp < 0x7b) return true;
  46928. return isLargeIdStart(cp);
  46929. }
  46930. function isIdContinue(cp) {
  46931. if (cp < 0x30) return false;
  46932. if (cp < 0x3a) return true;
  46933. if (cp < 0x41) return false;
  46934. if (cp < 0x5b) return true;
  46935. if (cp === 0x5f) return true;
  46936. if (cp < 0x61) return false;
  46937. if (cp < 0x7b) return true;
  46938. return isLargeIdStart(cp) || isLargeIdContinue(cp);
  46939. }
  46940. function isLargeIdStart(cp) {
  46941. if (cp < 0x30a1) {
  46942. if (cp < 0xec0) {
  46943. if (cp < 0xa35) {
  46944. if (cp < 0x6e5) {
  46945. if (cp < 0x37a) {
  46946. if (cp < 0x294) {
  46947. if (cp < 0xf8) {
  46948. if (cp === 0xaa) return true;
  46949. if (cp === 0xb5) return true;
  46950. if (cp === 0xba) return true;
  46951. if (cp < 0xc0) return false;
  46952. if (cp < 0xd7) return true;
  46953. if (cp < 0xd8) return false;
  46954. if (cp < 0xf7) return true;
  46955. return false;
  46956. }
  46957. if (cp < 0x1bb) return true;
  46958. if (cp === 0x1bb) return true;
  46959. if (cp < 0x1bc) return false;
  46960. if (cp < 0x1c0) return true;
  46961. if (cp < 0x1c0) return false;
  46962. if (cp < 0x1c4) return true;
  46963. if (cp < 0x1c4) return false;
  46964. if (cp < 0x294) return true;
  46965. return false;
  46966. }
  46967. if (cp < 0x2ec) {
  46968. if (cp === 0x294) return true;
  46969. if (cp < 0x295) return false;
  46970. if (cp < 0x2b0) return true;
  46971. if (cp < 0x2b0) return false;
  46972. if (cp < 0x2c2) return true;
  46973. if (cp < 0x2c6) return false;
  46974. if (cp < 0x2d2) return true;
  46975. if (cp < 0x2e0) return false;
  46976. if (cp < 0x2e5) return true;
  46977. return false;
  46978. }
  46979. if (cp === 0x2ec) return true;
  46980. if (cp === 0x2ee) return true;
  46981. if (cp < 0x370) return false;
  46982. if (cp < 0x374) return true;
  46983. if (cp === 0x374) return true;
  46984. if (cp < 0x376) return false;
  46985. if (cp < 0x378) return true;
  46986. return false;
  46987. }
  46988. if (cp < 0x531) {
  46989. if (cp < 0x38c) {
  46990. if (cp === 0x37a) return true;
  46991. if (cp < 0x37b) return false;
  46992. if (cp < 0x37e) return true;
  46993. if (cp === 0x37f) return true;
  46994. if (cp === 0x386) return true;
  46995. if (cp < 0x388) return false;
  46996. if (cp < 0x38b) return true;
  46997. return false;
  46998. }
  46999. if (cp === 0x38c) return true;
  47000. if (cp < 0x38e) return false;
  47001. if (cp < 0x3a2) return true;
  47002. if (cp < 0x3a3) return false;
  47003. if (cp < 0x3f6) return true;
  47004. if (cp < 0x3f7) return false;
  47005. if (cp < 0x482) return true;
  47006. if (cp < 0x48a) return false;
  47007. if (cp < 0x530) return true;
  47008. return false;
  47009. }
  47010. if (cp < 0x620) {
  47011. if (cp < 0x531) return false;
  47012. if (cp < 0x557) return true;
  47013. if (cp === 0x559) return true;
  47014. if (cp < 0x560) return false;
  47015. if (cp < 0x589) return true;
  47016. if (cp < 0x5d0) return false;
  47017. if (cp < 0x5eb) return true;
  47018. if (cp < 0x5ef) return false;
  47019. if (cp < 0x5f3) return true;
  47020. return false;
  47021. }
  47022. if (cp < 0x640) return true;
  47023. if (cp === 0x640) return true;
  47024. if (cp < 0x641) return false;
  47025. if (cp < 0x64b) return true;
  47026. if (cp < 0x66e) return false;
  47027. if (cp < 0x670) return true;
  47028. if (cp < 0x671) return false;
  47029. if (cp < 0x6d4) return true;
  47030. if (cp === 0x6d5) return true;
  47031. return false;
  47032. }
  47033. if (cp < 0x950) {
  47034. if (cp < 0x7fa) {
  47035. if (cp < 0x712) {
  47036. if (cp < 0x6e5) return false;
  47037. if (cp < 0x6e7) return true;
  47038. if (cp < 0x6ee) return false;
  47039. if (cp < 0x6f0) return true;
  47040. if (cp < 0x6fa) return false;
  47041. if (cp < 0x6fd) return true;
  47042. if (cp === 0x6ff) return true;
  47043. if (cp === 0x710) return true;
  47044. return false;
  47045. }
  47046. if (cp < 0x730) return true;
  47047. if (cp < 0x74d) return false;
  47048. if (cp < 0x7a6) return true;
  47049. if (cp === 0x7b1) return true;
  47050. if (cp < 0x7ca) return false;
  47051. if (cp < 0x7eb) return true;
  47052. if (cp < 0x7f4) return false;
  47053. if (cp < 0x7f6) return true;
  47054. return false;
  47055. }
  47056. if (cp < 0x840) {
  47057. if (cp === 0x7fa) return true;
  47058. if (cp < 0x800) return false;
  47059. if (cp < 0x816) return true;
  47060. if (cp === 0x81a) return true;
  47061. if (cp === 0x824) return true;
  47062. if (cp === 0x828) return true;
  47063. return false;
  47064. }
  47065. if (cp < 0x859) return true;
  47066. if (cp < 0x860) return false;
  47067. if (cp < 0x86b) return true;
  47068. if (cp < 0x8a0) return false;
  47069. if (cp < 0x8b5) return true;
  47070. if (cp < 0x8b6) return false;
  47071. if (cp < 0x8be) return true;
  47072. if (cp < 0x904) return false;
  47073. if (cp < 0x93a) return true;
  47074. if (cp === 0x93d) return true;
  47075. return false;
  47076. }
  47077. if (cp < 0x9bd) {
  47078. if (cp < 0x98f) {
  47079. if (cp === 0x950) return true;
  47080. if (cp < 0x958) return false;
  47081. if (cp < 0x962) return true;
  47082. if (cp === 0x971) return true;
  47083. if (cp < 0x972) return false;
  47084. if (cp < 0x981) return true;
  47085. if (cp < 0x985) return false;
  47086. if (cp < 0x98d) return true;
  47087. return false;
  47088. }
  47089. if (cp < 0x991) return true;
  47090. if (cp < 0x993) return false;
  47091. if (cp < 0x9a9) return true;
  47092. if (cp < 0x9aa) return false;
  47093. if (cp < 0x9b1) return true;
  47094. if (cp === 0x9b2) return true;
  47095. if (cp < 0x9b6) return false;
  47096. if (cp < 0x9ba) return true;
  47097. return false;
  47098. }
  47099. if (cp < 0x9fc) {
  47100. if (cp === 0x9bd) return true;
  47101. if (cp === 0x9ce) return true;
  47102. if (cp < 0x9dc) return false;
  47103. if (cp < 0x9de) return true;
  47104. if (cp < 0x9df) return false;
  47105. if (cp < 0x9e2) return true;
  47106. if (cp < 0x9f0) return false;
  47107. if (cp < 0x9f2) return true;
  47108. return false;
  47109. }
  47110. if (cp === 0x9fc) return true;
  47111. if (cp < 0xa05) return false;
  47112. if (cp < 0xa0b) return true;
  47113. if (cp < 0xa0f) return false;
  47114. if (cp < 0xa11) return true;
  47115. if (cp < 0xa13) return false;
  47116. if (cp < 0xa29) return true;
  47117. if (cp < 0xa2a) return false;
  47118. if (cp < 0xa31) return true;
  47119. if (cp < 0xa32) return false;
  47120. if (cp < 0xa34) return true;
  47121. return false;
  47122. }
  47123. if (cp < 0xc60) {
  47124. if (cp < 0xb3d) {
  47125. if (cp < 0xab5) {
  47126. if (cp < 0xa85) {
  47127. if (cp < 0xa35) return false;
  47128. if (cp < 0xa37) return true;
  47129. if (cp < 0xa38) return false;
  47130. if (cp < 0xa3a) return true;
  47131. if (cp < 0xa59) return false;
  47132. if (cp < 0xa5d) return true;
  47133. if (cp === 0xa5e) return true;
  47134. if (cp < 0xa72) return false;
  47135. if (cp < 0xa75) return true;
  47136. return false;
  47137. }
  47138. if (cp < 0xa8e) return true;
  47139. if (cp < 0xa8f) return false;
  47140. if (cp < 0xa92) return true;
  47141. if (cp < 0xa93) return false;
  47142. if (cp < 0xaa9) return true;
  47143. if (cp < 0xaaa) return false;
  47144. if (cp < 0xab1) return true;
  47145. if (cp < 0xab2) return false;
  47146. if (cp < 0xab4) return true;
  47147. return false;
  47148. }
  47149. if (cp < 0xb05) {
  47150. if (cp < 0xab5) return false;
  47151. if (cp < 0xaba) return true;
  47152. if (cp === 0xabd) return true;
  47153. if (cp === 0xad0) return true;
  47154. if (cp < 0xae0) return false;
  47155. if (cp < 0xae2) return true;
  47156. if (cp === 0xaf9) return true;
  47157. return false;
  47158. }
  47159. if (cp < 0xb0d) return true;
  47160. if (cp < 0xb0f) return false;
  47161. if (cp < 0xb11) return true;
  47162. if (cp < 0xb13) return false;
  47163. if (cp < 0xb29) return true;
  47164. if (cp < 0xb2a) return false;
  47165. if (cp < 0xb31) return true;
  47166. if (cp < 0xb32) return false;
  47167. if (cp < 0xb34) return true;
  47168. if (cp < 0xb35) return false;
  47169. if (cp < 0xb3a) return true;
  47170. return false;
  47171. }
  47172. if (cp < 0xb9e) {
  47173. if (cp < 0xb85) {
  47174. if (cp === 0xb3d) return true;
  47175. if (cp < 0xb5c) return false;
  47176. if (cp < 0xb5e) return true;
  47177. if (cp < 0xb5f) return false;
  47178. if (cp < 0xb62) return true;
  47179. if (cp === 0xb71) return true;
  47180. if (cp === 0xb83) return true;
  47181. return false;
  47182. }
  47183. if (cp < 0xb8b) return true;
  47184. if (cp < 0xb8e) return false;
  47185. if (cp < 0xb91) return true;
  47186. if (cp < 0xb92) return false;
  47187. if (cp < 0xb96) return true;
  47188. if (cp < 0xb99) return false;
  47189. if (cp < 0xb9b) return true;
  47190. if (cp === 0xb9c) return true;
  47191. return false;
  47192. }
  47193. if (cp < 0xc05) {
  47194. if (cp < 0xb9e) return false;
  47195. if (cp < 0xba0) return true;
  47196. if (cp < 0xba3) return false;
  47197. if (cp < 0xba5) return true;
  47198. if (cp < 0xba8) return false;
  47199. if (cp < 0xbab) return true;
  47200. if (cp < 0xbae) return false;
  47201. if (cp < 0xbba) return true;
  47202. if (cp === 0xbd0) return true;
  47203. return false;
  47204. }
  47205. if (cp < 0xc0d) return true;
  47206. if (cp < 0xc0e) return false;
  47207. if (cp < 0xc11) return true;
  47208. if (cp < 0xc12) return false;
  47209. if (cp < 0xc29) return true;
  47210. if (cp < 0xc2a) return false;
  47211. if (cp < 0xc3a) return true;
  47212. if (cp === 0xc3d) return true;
  47213. if (cp < 0xc58) return false;
  47214. if (cp < 0xc5b) return true;
  47215. return false;
  47216. }
  47217. if (cp < 0xdb3) {
  47218. if (cp < 0xcf1) {
  47219. if (cp < 0xcaa) {
  47220. if (cp < 0xc60) return false;
  47221. if (cp < 0xc62) return true;
  47222. if (cp === 0xc80) return true;
  47223. if (cp < 0xc85) return false;
  47224. if (cp < 0xc8d) return true;
  47225. if (cp < 0xc8e) return false;
  47226. if (cp < 0xc91) return true;
  47227. if (cp < 0xc92) return false;
  47228. if (cp < 0xca9) return true;
  47229. return false;
  47230. }
  47231. if (cp < 0xcb4) return true;
  47232. if (cp < 0xcb5) return false;
  47233. if (cp < 0xcba) return true;
  47234. if (cp === 0xcbd) return true;
  47235. if (cp === 0xcde) return true;
  47236. if (cp < 0xce0) return false;
  47237. if (cp < 0xce2) return true;
  47238. return false;
  47239. }
  47240. if (cp < 0xd4e) {
  47241. if (cp < 0xcf1) return false;
  47242. if (cp < 0xcf3) return true;
  47243. if (cp < 0xd05) return false;
  47244. if (cp < 0xd0d) return true;
  47245. if (cp < 0xd0e) return false;
  47246. if (cp < 0xd11) return true;
  47247. if (cp < 0xd12) return false;
  47248. if (cp < 0xd3b) return true;
  47249. if (cp === 0xd3d) return true;
  47250. return false;
  47251. }
  47252. if (cp === 0xd4e) return true;
  47253. if (cp < 0xd54) return false;
  47254. if (cp < 0xd57) return true;
  47255. if (cp < 0xd5f) return false;
  47256. if (cp < 0xd62) return true;
  47257. if (cp < 0xd7a) return false;
  47258. if (cp < 0xd80) return true;
  47259. if (cp < 0xd85) return false;
  47260. if (cp < 0xd97) return true;
  47261. if (cp < 0xd9a) return false;
  47262. if (cp < 0xdb2) return true;
  47263. return false;
  47264. }
  47265. if (cp < 0xe8a) {
  47266. if (cp < 0xe40) {
  47267. if (cp < 0xdb3) return false;
  47268. if (cp < 0xdbc) return true;
  47269. if (cp === 0xdbd) return true;
  47270. if (cp < 0xdc0) return false;
  47271. if (cp < 0xdc7) return true;
  47272. if (cp < 0xe01) return false;
  47273. if (cp < 0xe31) return true;
  47274. if (cp < 0xe32) return false;
  47275. if (cp < 0xe34) return true;
  47276. return false;
  47277. }
  47278. if (cp < 0xe46) return true;
  47279. if (cp === 0xe46) return true;
  47280. if (cp < 0xe81) return false;
  47281. if (cp < 0xe83) return true;
  47282. if (cp === 0xe84) return true;
  47283. if (cp < 0xe87) return false;
  47284. if (cp < 0xe89) return true;
  47285. return false;
  47286. }
  47287. if (cp < 0xea5) {
  47288. if (cp === 0xe8a) return true;
  47289. if (cp === 0xe8d) return true;
  47290. if (cp < 0xe94) return false;
  47291. if (cp < 0xe98) return true;
  47292. if (cp < 0xe99) return false;
  47293. if (cp < 0xea0) return true;
  47294. if (cp < 0xea1) return false;
  47295. if (cp < 0xea4) return true;
  47296. return false;
  47297. }
  47298. if (cp === 0xea5) return true;
  47299. if (cp === 0xea7) return true;
  47300. if (cp < 0xeaa) return false;
  47301. if (cp < 0xeac) return true;
  47302. if (cp < 0xead) return false;
  47303. if (cp < 0xeb1) return true;
  47304. if (cp < 0xeb2) return false;
  47305. if (cp < 0xeb4) return true;
  47306. if (cp === 0xebd) return true;
  47307. return false;
  47308. }
  47309. if (cp < 0x1ce9) {
  47310. if (cp < 0x166f) {
  47311. if (cp < 0x10fd) {
  47312. if (cp < 0x105a) {
  47313. if (cp < 0xf49) {
  47314. if (cp < 0xec0) return false;
  47315. if (cp < 0xec5) return true;
  47316. if (cp === 0xec6) return true;
  47317. if (cp < 0xedc) return false;
  47318. if (cp < 0xee0) return true;
  47319. if (cp === 0xf00) return true;
  47320. if (cp < 0xf40) return false;
  47321. if (cp < 0xf48) return true;
  47322. return false;
  47323. }
  47324. if (cp < 0xf6d) return true;
  47325. if (cp < 0xf88) return false;
  47326. if (cp < 0xf8d) return true;
  47327. if (cp < 0x1000) return false;
  47328. if (cp < 0x102b) return true;
  47329. if (cp === 0x103f) return true;
  47330. if (cp < 0x1050) return false;
  47331. if (cp < 0x1056) return true;
  47332. return false;
  47333. }
  47334. if (cp < 0x108e) {
  47335. if (cp < 0x105a) return false;
  47336. if (cp < 0x105e) return true;
  47337. if (cp === 0x1061) return true;
  47338. if (cp < 0x1065) return false;
  47339. if (cp < 0x1067) return true;
  47340. if (cp < 0x106e) return false;
  47341. if (cp < 0x1071) return true;
  47342. if (cp < 0x1075) return false;
  47343. if (cp < 0x1082) return true;
  47344. return false;
  47345. }
  47346. if (cp === 0x108e) return true;
  47347. if (cp < 0x10a0) return false;
  47348. if (cp < 0x10c6) return true;
  47349. if (cp === 0x10c7) return true;
  47350. if (cp === 0x10cd) return true;
  47351. if (cp < 0x10d0) return false;
  47352. if (cp < 0x10fb) return true;
  47353. if (cp === 0x10fc) return true;
  47354. return false;
  47355. }
  47356. if (cp < 0x12b8) {
  47357. if (cp < 0x125a) {
  47358. if (cp < 0x10fd) return false;
  47359. if (cp < 0x1100) return true;
  47360. if (cp < 0x1100) return false;
  47361. if (cp < 0x1249) return true;
  47362. if (cp < 0x124a) return false;
  47363. if (cp < 0x124e) return true;
  47364. if (cp < 0x1250) return false;
  47365. if (cp < 0x1257) return true;
  47366. if (cp === 0x1258) return true;
  47367. return false;
  47368. }
  47369. if (cp < 0x125e) return true;
  47370. if (cp < 0x1260) return false;
  47371. if (cp < 0x1289) return true;
  47372. if (cp < 0x128a) return false;
  47373. if (cp < 0x128e) return true;
  47374. if (cp < 0x1290) return false;
  47375. if (cp < 0x12b1) return true;
  47376. if (cp < 0x12b2) return false;
  47377. if (cp < 0x12b6) return true;
  47378. return false;
  47379. }
  47380. if (cp < 0x1312) {
  47381. if (cp < 0x12b8) return false;
  47382. if (cp < 0x12bf) return true;
  47383. if (cp === 0x12c0) return true;
  47384. if (cp < 0x12c2) return false;
  47385. if (cp < 0x12c6) return true;
  47386. if (cp < 0x12c8) return false;
  47387. if (cp < 0x12d7) return true;
  47388. if (cp < 0x12d8) return false;
  47389. if (cp < 0x1311) return true;
  47390. return false;
  47391. }
  47392. if (cp < 0x1316) return true;
  47393. if (cp < 0x1318) return false;
  47394. if (cp < 0x135b) return true;
  47395. if (cp < 0x1380) return false;
  47396. if (cp < 0x1390) return true;
  47397. if (cp < 0x13a0) return false;
  47398. if (cp < 0x13f6) return true;
  47399. if (cp < 0x13f8) return false;
  47400. if (cp < 0x13fe) return true;
  47401. if (cp < 0x1401) return false;
  47402. if (cp < 0x166d) return true;
  47403. return false;
  47404. }
  47405. if (cp < 0x18b0) {
  47406. if (cp < 0x176e) {
  47407. if (cp < 0x1700) {
  47408. if (cp < 0x166f) return false;
  47409. if (cp < 0x1680) return true;
  47410. if (cp < 0x1681) return false;
  47411. if (cp < 0x169b) return true;
  47412. if (cp < 0x16a0) return false;
  47413. if (cp < 0x16eb) return true;
  47414. if (cp < 0x16ee) return false;
  47415. if (cp < 0x16f1) return true;
  47416. if (cp < 0x16f1) return false;
  47417. if (cp < 0x16f9) return true;
  47418. return false;
  47419. }
  47420. if (cp < 0x170d) return true;
  47421. if (cp < 0x170e) return false;
  47422. if (cp < 0x1712) return true;
  47423. if (cp < 0x1720) return false;
  47424. if (cp < 0x1732) return true;
  47425. if (cp < 0x1740) return false;
  47426. if (cp < 0x1752) return true;
  47427. if (cp < 0x1760) return false;
  47428. if (cp < 0x176d) return true;
  47429. return false;
  47430. }
  47431. if (cp < 0x1843) {
  47432. if (cp < 0x176e) return false;
  47433. if (cp < 0x1771) return true;
  47434. if (cp < 0x1780) return false;
  47435. if (cp < 0x17b4) return true;
  47436. if (cp === 0x17d7) return true;
  47437. if (cp === 0x17dc) return true;
  47438. if (cp < 0x1820) return false;
  47439. if (cp < 0x1843) return true;
  47440. return false;
  47441. }
  47442. if (cp === 0x1843) return true;
  47443. if (cp < 0x1844) return false;
  47444. if (cp < 0x1879) return true;
  47445. if (cp < 0x1880) return false;
  47446. if (cp < 0x1885) return true;
  47447. if (cp < 0x1885) return false;
  47448. if (cp < 0x1887) return true;
  47449. if (cp < 0x1887) return false;
  47450. if (cp < 0x18a9) return true;
  47451. if (cp === 0x18aa) return true;
  47452. return false;
  47453. }
  47454. if (cp < 0x1b45) {
  47455. if (cp < 0x19b0) {
  47456. if (cp < 0x18b0) return false;
  47457. if (cp < 0x18f6) return true;
  47458. if (cp < 0x1900) return false;
  47459. if (cp < 0x191f) return true;
  47460. if (cp < 0x1950) return false;
  47461. if (cp < 0x196e) return true;
  47462. if (cp < 0x1970) return false;
  47463. if (cp < 0x1975) return true;
  47464. if (cp < 0x1980) return false;
  47465. if (cp < 0x19ac) return true;
  47466. return false;
  47467. }
  47468. if (cp < 0x19ca) return true;
  47469. if (cp < 0x1a00) return false;
  47470. if (cp < 0x1a17) return true;
  47471. if (cp < 0x1a20) return false;
  47472. if (cp < 0x1a55) return true;
  47473. if (cp === 0x1aa7) return true;
  47474. if (cp < 0x1b05) return false;
  47475. if (cp < 0x1b34) return true;
  47476. return false;
  47477. }
  47478. if (cp < 0x1c4d) {
  47479. if (cp < 0x1b45) return false;
  47480. if (cp < 0x1b4c) return true;
  47481. if (cp < 0x1b83) return false;
  47482. if (cp < 0x1ba1) return true;
  47483. if (cp < 0x1bae) return false;
  47484. if (cp < 0x1bb0) return true;
  47485. if (cp < 0x1bba) return false;
  47486. if (cp < 0x1be6) return true;
  47487. if (cp < 0x1c00) return false;
  47488. if (cp < 0x1c24) return true;
  47489. return false;
  47490. }
  47491. if (cp < 0x1c50) return true;
  47492. if (cp < 0x1c5a) return false;
  47493. if (cp < 0x1c78) return true;
  47494. if (cp < 0x1c78) return false;
  47495. if (cp < 0x1c7e) return true;
  47496. if (cp < 0x1c80) return false;
  47497. if (cp < 0x1c89) return true;
  47498. if (cp < 0x1c90) return false;
  47499. if (cp < 0x1cbb) return true;
  47500. if (cp < 0x1cbd) return false;
  47501. if (cp < 0x1cc0) return true;
  47502. return false;
  47503. }
  47504. if (cp < 0x212f) {
  47505. if (cp < 0x1fc2) {
  47506. if (cp < 0x1f18) {
  47507. if (cp < 0x1d6b) {
  47508. if (cp < 0x1ce9) return false;
  47509. if (cp < 0x1ced) return true;
  47510. if (cp < 0x1cee) return false;
  47511. if (cp < 0x1cf2) return true;
  47512. if (cp < 0x1cf5) return false;
  47513. if (cp < 0x1cf7) return true;
  47514. if (cp < 0x1d00) return false;
  47515. if (cp < 0x1d2c) return true;
  47516. if (cp < 0x1d2c) return false;
  47517. if (cp < 0x1d6b) return true;
  47518. return false;
  47519. }
  47520. if (cp < 0x1d78) return true;
  47521. if (cp === 0x1d78) return true;
  47522. if (cp < 0x1d79) return false;
  47523. if (cp < 0x1d9b) return true;
  47524. if (cp < 0x1d9b) return false;
  47525. if (cp < 0x1dc0) return true;
  47526. if (cp < 0x1e00) return false;
  47527. if (cp < 0x1f16) return true;
  47528. return false;
  47529. }
  47530. if (cp < 0x1f5b) {
  47531. if (cp < 0x1f18) return false;
  47532. if (cp < 0x1f1e) return true;
  47533. if (cp < 0x1f20) return false;
  47534. if (cp < 0x1f46) return true;
  47535. if (cp < 0x1f48) return false;
  47536. if (cp < 0x1f4e) return true;
  47537. if (cp < 0x1f50) return false;
  47538. if (cp < 0x1f58) return true;
  47539. if (cp === 0x1f59) return true;
  47540. return false;
  47541. }
  47542. if (cp === 0x1f5b) return true;
  47543. if (cp === 0x1f5d) return true;
  47544. if (cp < 0x1f5f) return false;
  47545. if (cp < 0x1f7e) return true;
  47546. if (cp < 0x1f80) return false;
  47547. if (cp < 0x1fb5) return true;
  47548. if (cp < 0x1fb6) return false;
  47549. if (cp < 0x1fbd) return true;
  47550. if (cp === 0x1fbe) return true;
  47551. return false;
  47552. }
  47553. if (cp < 0x2102) {
  47554. if (cp < 0x1ff2) {
  47555. if (cp < 0x1fc2) return false;
  47556. if (cp < 0x1fc5) return true;
  47557. if (cp < 0x1fc6) return false;
  47558. if (cp < 0x1fcd) return true;
  47559. if (cp < 0x1fd0) return false;
  47560. if (cp < 0x1fd4) return true;
  47561. if (cp < 0x1fd6) return false;
  47562. if (cp < 0x1fdc) return true;
  47563. if (cp < 0x1fe0) return false;
  47564. if (cp < 0x1fed) return true;
  47565. return false;
  47566. }
  47567. if (cp < 0x1ff5) return true;
  47568. if (cp < 0x1ff6) return false;
  47569. if (cp < 0x1ffd) return true;
  47570. if (cp === 0x2071) return true;
  47571. if (cp === 0x207f) return true;
  47572. if (cp < 0x2090) return false;
  47573. if (cp < 0x209d) return true;
  47574. return false;
  47575. }
  47576. if (cp < 0x2119) {
  47577. if (cp === 0x2102) return true;
  47578. if (cp === 0x2107) return true;
  47579. if (cp < 0x210a) return false;
  47580. if (cp < 0x2114) return true;
  47581. if (cp === 0x2115) return true;
  47582. if (cp === 0x2118) return true;
  47583. return false;
  47584. }
  47585. if (cp < 0x211e) return true;
  47586. if (cp === 0x2124) return true;
  47587. if (cp === 0x2126) return true;
  47588. if (cp === 0x2128) return true;
  47589. if (cp < 0x212a) return false;
  47590. if (cp < 0x212e) return true;
  47591. if (cp === 0x212e) return true;
  47592. return false;
  47593. }
  47594. if (cp < 0x2d80) {
  47595. if (cp < 0x2c30) {
  47596. if (cp < 0x214e) {
  47597. if (cp < 0x212f) return false;
  47598. if (cp < 0x2135) return true;
  47599. if (cp < 0x2135) return false;
  47600. if (cp < 0x2139) return true;
  47601. if (cp === 0x2139) return true;
  47602. if (cp < 0x213c) return false;
  47603. if (cp < 0x2140) return true;
  47604. if (cp < 0x2145) return false;
  47605. if (cp < 0x214a) return true;
  47606. return false;
  47607. }
  47608. if (cp === 0x214e) return true;
  47609. if (cp < 0x2160) return false;
  47610. if (cp < 0x2183) return true;
  47611. if (cp < 0x2183) return false;
  47612. if (cp < 0x2185) return true;
  47613. if (cp < 0x2185) return false;
  47614. if (cp < 0x2189) return true;
  47615. if (cp < 0x2c00) return false;
  47616. if (cp < 0x2c2f) return true;
  47617. return false;
  47618. }
  47619. if (cp < 0x2cf2) {
  47620. if (cp < 0x2c30) return false;
  47621. if (cp < 0x2c5f) return true;
  47622. if (cp < 0x2c60) return false;
  47623. if (cp < 0x2c7c) return true;
  47624. if (cp < 0x2c7c) return false;
  47625. if (cp < 0x2c7e) return true;
  47626. if (cp < 0x2c7e) return false;
  47627. if (cp < 0x2ce5) return true;
  47628. if (cp < 0x2ceb) return false;
  47629. if (cp < 0x2cef) return true;
  47630. return false;
  47631. }
  47632. if (cp < 0x2cf4) return true;
  47633. if (cp < 0x2d00) return false;
  47634. if (cp < 0x2d26) return true;
  47635. if (cp === 0x2d27) return true;
  47636. if (cp === 0x2d2d) return true;
  47637. if (cp < 0x2d30) return false;
  47638. if (cp < 0x2d68) return true;
  47639. if (cp === 0x2d6f) return true;
  47640. return false;
  47641. }
  47642. if (cp < 0x3006) {
  47643. if (cp < 0x2dc0) {
  47644. if (cp < 0x2d80) return false;
  47645. if (cp < 0x2d97) return true;
  47646. if (cp < 0x2da0) return false;
  47647. if (cp < 0x2da7) return true;
  47648. if (cp < 0x2da8) return false;
  47649. if (cp < 0x2daf) return true;
  47650. if (cp < 0x2db0) return false;
  47651. if (cp < 0x2db7) return true;
  47652. if (cp < 0x2db8) return false;
  47653. if (cp < 0x2dbf) return true;
  47654. return false;
  47655. }
  47656. if (cp < 0x2dc7) return true;
  47657. if (cp < 0x2dc8) return false;
  47658. if (cp < 0x2dcf) return true;
  47659. if (cp < 0x2dd0) return false;
  47660. if (cp < 0x2dd7) return true;
  47661. if (cp < 0x2dd8) return false;
  47662. if (cp < 0x2ddf) return true;
  47663. if (cp === 0x3005) return true;
  47664. return false;
  47665. }
  47666. if (cp < 0x303b) {
  47667. if (cp === 0x3006) return true;
  47668. if (cp === 0x3007) return true;
  47669. if (cp < 0x3021) return false;
  47670. if (cp < 0x302a) return true;
  47671. if (cp < 0x3031) return false;
  47672. if (cp < 0x3036) return true;
  47673. if (cp < 0x3038) return false;
  47674. if (cp < 0x303b) return true;
  47675. return false;
  47676. }
  47677. if (cp === 0x303b) return true;
  47678. if (cp === 0x303c) return true;
  47679. if (cp < 0x3041) return false;
  47680. if (cp < 0x3097) return true;
  47681. if (cp < 0x309b) return false;
  47682. if (cp < 0x309d) return true;
  47683. if (cp < 0x309d) return false;
  47684. if (cp < 0x309f) return true;
  47685. if (cp === 0x309f) return true;
  47686. return false;
  47687. }
  47688. if (cp < 0x10b60) {
  47689. if (cp < 0xd7b0) {
  47690. if (cp < 0xa882) {
  47691. if (cp < 0xa67f) {
  47692. if (cp < 0xa015) {
  47693. if (cp < 0x31a0) {
  47694. if (cp < 0x30a1) return false;
  47695. if (cp < 0x30fb) return true;
  47696. if (cp < 0x30fc) return false;
  47697. if (cp < 0x30ff) return true;
  47698. if (cp === 0x30ff) return true;
  47699. if (cp < 0x3105) return false;
  47700. if (cp < 0x3130) return true;
  47701. if (cp < 0x3131) return false;
  47702. if (cp < 0x318f) return true;
  47703. return false;
  47704. }
  47705. if (cp < 0x31bb) return true;
  47706. if (cp < 0x31f0) return false;
  47707. if (cp < 0x3200) return true;
  47708. if (cp < 0x3400) return false;
  47709. if (cp < 0x4db6) return true;
  47710. if (cp < 0x4e00) return false;
  47711. if (cp < 0x9ff0) return true;
  47712. if (cp < 0xa000) return false;
  47713. if (cp < 0xa015) return true;
  47714. return false;
  47715. }
  47716. if (cp < 0xa60c) {
  47717. if (cp === 0xa015) return true;
  47718. if (cp < 0xa016) return false;
  47719. if (cp < 0xa48d) return true;
  47720. if (cp < 0xa4d0) return false;
  47721. if (cp < 0xa4f8) return true;
  47722. if (cp < 0xa4f8) return false;
  47723. if (cp < 0xa4fe) return true;
  47724. if (cp < 0xa500) return false;
  47725. if (cp < 0xa60c) return true;
  47726. return false;
  47727. }
  47728. if (cp === 0xa60c) return true;
  47729. if (cp < 0xa610) return false;
  47730. if (cp < 0xa620) return true;
  47731. if (cp < 0xa62a) return false;
  47732. if (cp < 0xa62c) return true;
  47733. if (cp < 0xa640) return false;
  47734. if (cp < 0xa66e) return true;
  47735. if (cp === 0xa66e) return true;
  47736. return false;
  47737. }
  47738. if (cp < 0xa78b) {
  47739. if (cp < 0xa717) {
  47740. if (cp === 0xa67f) return true;
  47741. if (cp < 0xa680) return false;
  47742. if (cp < 0xa69c) return true;
  47743. if (cp < 0xa69c) return false;
  47744. if (cp < 0xa69e) return true;
  47745. if (cp < 0xa6a0) return false;
  47746. if (cp < 0xa6e6) return true;
  47747. if (cp < 0xa6e6) return false;
  47748. if (cp < 0xa6f0) return true;
  47749. return false;
  47750. }
  47751. if (cp < 0xa720) return true;
  47752. if (cp < 0xa722) return false;
  47753. if (cp < 0xa770) return true;
  47754. if (cp === 0xa770) return true;
  47755. if (cp < 0xa771) return false;
  47756. if (cp < 0xa788) return true;
  47757. if (cp === 0xa788) return true;
  47758. return false;
  47759. }
  47760. if (cp < 0xa7fa) {
  47761. if (cp < 0xa78b) return false;
  47762. if (cp < 0xa78f) return true;
  47763. if (cp === 0xa78f) return true;
  47764. if (cp < 0xa790) return false;
  47765. if (cp < 0xa7ba) return true;
  47766. if (cp === 0xa7f7) return true;
  47767. if (cp < 0xa7f8) return false;
  47768. if (cp < 0xa7fa) return true;
  47769. return false;
  47770. }
  47771. if (cp === 0xa7fa) return true;
  47772. if (cp < 0xa7fb) return false;
  47773. if (cp < 0xa802) return true;
  47774. if (cp < 0xa803) return false;
  47775. if (cp < 0xa806) return true;
  47776. if (cp < 0xa807) return false;
  47777. if (cp < 0xa80b) return true;
  47778. if (cp < 0xa80c) return false;
  47779. if (cp < 0xa823) return true;
  47780. if (cp < 0xa840) return false;
  47781. if (cp < 0xa874) return true;
  47782. return false;
  47783. }
  47784. if (cp < 0xaab1) {
  47785. if (cp < 0xa9e6) {
  47786. if (cp < 0xa930) {
  47787. if (cp < 0xa882) return false;
  47788. if (cp < 0xa8b4) return true;
  47789. if (cp < 0xa8f2) return false;
  47790. if (cp < 0xa8f8) return true;
  47791. if (cp === 0xa8fb) return true;
  47792. if (cp < 0xa8fd) return false;
  47793. if (cp < 0xa8ff) return true;
  47794. if (cp < 0xa90a) return false;
  47795. if (cp < 0xa926) return true;
  47796. return false;
  47797. }
  47798. if (cp < 0xa947) return true;
  47799. if (cp < 0xa960) return false;
  47800. if (cp < 0xa97d) return true;
  47801. if (cp < 0xa984) return false;
  47802. if (cp < 0xa9b3) return true;
  47803. if (cp === 0xa9cf) return true;
  47804. if (cp < 0xa9e0) return false;
  47805. if (cp < 0xa9e5) return true;
  47806. return false;
  47807. }
  47808. if (cp < 0xaa44) {
  47809. if (cp === 0xa9e6) return true;
  47810. if (cp < 0xa9e7) return false;
  47811. if (cp < 0xa9f0) return true;
  47812. if (cp < 0xa9fa) return false;
  47813. if (cp < 0xa9ff) return true;
  47814. if (cp < 0xaa00) return false;
  47815. if (cp < 0xaa29) return true;
  47816. if (cp < 0xaa40) return false;
  47817. if (cp < 0xaa43) return true;
  47818. return false;
  47819. }
  47820. if (cp < 0xaa4c) return true;
  47821. if (cp < 0xaa60) return false;
  47822. if (cp < 0xaa70) return true;
  47823. if (cp === 0xaa70) return true;
  47824. if (cp < 0xaa71) return false;
  47825. if (cp < 0xaa77) return true;
  47826. if (cp === 0xaa7a) return true;
  47827. if (cp < 0xaa7e) return false;
  47828. if (cp < 0xaab0) return true;
  47829. return false;
  47830. }
  47831. if (cp < 0xab01) {
  47832. if (cp < 0xaadb) {
  47833. if (cp === 0xaab1) return true;
  47834. if (cp < 0xaab5) return false;
  47835. if (cp < 0xaab7) return true;
  47836. if (cp < 0xaab9) return false;
  47837. if (cp < 0xaabe) return true;
  47838. if (cp === 0xaac0) return true;
  47839. if (cp === 0xaac2) return true;
  47840. return false;
  47841. }
  47842. if (cp < 0xaadd) return true;
  47843. if (cp === 0xaadd) return true;
  47844. if (cp < 0xaae0) return false;
  47845. if (cp < 0xaaeb) return true;
  47846. if (cp === 0xaaf2) return true;
  47847. if (cp < 0xaaf3) return false;
  47848. if (cp < 0xaaf5) return true;
  47849. return false;
  47850. }
  47851. if (cp < 0xab30) {
  47852. if (cp < 0xab01) return false;
  47853. if (cp < 0xab07) return true;
  47854. if (cp < 0xab09) return false;
  47855. if (cp < 0xab0f) return true;
  47856. if (cp < 0xab11) return false;
  47857. if (cp < 0xab17) return true;
  47858. if (cp < 0xab20) return false;
  47859. if (cp < 0xab27) return true;
  47860. if (cp < 0xab28) return false;
  47861. if (cp < 0xab2f) return true;
  47862. return false;
  47863. }
  47864. if (cp < 0xab5b) return true;
  47865. if (cp < 0xab5c) return false;
  47866. if (cp < 0xab60) return true;
  47867. if (cp < 0xab60) return false;
  47868. if (cp < 0xab66) return true;
  47869. if (cp < 0xab70) return false;
  47870. if (cp < 0xabc0) return true;
  47871. if (cp < 0xabc0) return false;
  47872. if (cp < 0xabe3) return true;
  47873. if (cp < 0xac00) return false;
  47874. if (cp < 0xd7a4) return true;
  47875. return false;
  47876. }
  47877. if (cp < 0x1032d) {
  47878. if (cp < 0xff41) {
  47879. if (cp < 0xfb3e) {
  47880. if (cp < 0xfb13) {
  47881. if (cp < 0xd7b0) return false;
  47882. if (cp < 0xd7c7) return true;
  47883. if (cp < 0xd7cb) return false;
  47884. if (cp < 0xd7fc) return true;
  47885. if (cp < 0xf900) return false;
  47886. if (cp < 0xfa6e) return true;
  47887. if (cp < 0xfa70) return false;
  47888. if (cp < 0xfada) return true;
  47889. if (cp < 0xfb00) return false;
  47890. if (cp < 0xfb07) return true;
  47891. return false;
  47892. }
  47893. if (cp < 0xfb18) return true;
  47894. if (cp === 0xfb1d) return true;
  47895. if (cp < 0xfb1f) return false;
  47896. if (cp < 0xfb29) return true;
  47897. if (cp < 0xfb2a) return false;
  47898. if (cp < 0xfb37) return true;
  47899. if (cp < 0xfb38) return false;
  47900. if (cp < 0xfb3d) return true;
  47901. return false;
  47902. }
  47903. if (cp < 0xfd50) {
  47904. if (cp === 0xfb3e) return true;
  47905. if (cp < 0xfb40) return false;
  47906. if (cp < 0xfb42) return true;
  47907. if (cp < 0xfb43) return false;
  47908. if (cp < 0xfb45) return true;
  47909. if (cp < 0xfb46) return false;
  47910. if (cp < 0xfbb2) return true;
  47911. if (cp < 0xfbd3) return false;
  47912. if (cp < 0xfd3e) return true;
  47913. return false;
  47914. }
  47915. if (cp < 0xfd90) return true;
  47916. if (cp < 0xfd92) return false;
  47917. if (cp < 0xfdc8) return true;
  47918. if (cp < 0xfdf0) return false;
  47919. if (cp < 0xfdfc) return true;
  47920. if (cp < 0xfe70) return false;
  47921. if (cp < 0xfe75) return true;
  47922. if (cp < 0xfe76) return false;
  47923. if (cp < 0xfefd) return true;
  47924. if (cp < 0xff21) return false;
  47925. if (cp < 0xff3b) return true;
  47926. return false;
  47927. }
  47928. if (cp < 0x10000) {
  47929. if (cp < 0xffa0) {
  47930. if (cp < 0xff41) return false;
  47931. if (cp < 0xff5b) return true;
  47932. if (cp < 0xff66) return false;
  47933. if (cp < 0xff70) return true;
  47934. if (cp === 0xff70) return true;
  47935. if (cp < 0xff71) return false;
  47936. if (cp < 0xff9e) return true;
  47937. if (cp < 0xff9e) return false;
  47938. if (cp < 0xffa0) return true;
  47939. return false;
  47940. }
  47941. if (cp < 0xffbf) return true;
  47942. if (cp < 0xffc2) return false;
  47943. if (cp < 0xffc8) return true;
  47944. if (cp < 0xffca) return false;
  47945. if (cp < 0xffd0) return true;
  47946. if (cp < 0xffd2) return false;
  47947. if (cp < 0xffd8) return true;
  47948. if (cp < 0xffda) return false;
  47949. if (cp < 0xffdd) return true;
  47950. return false;
  47951. }
  47952. if (cp < 0x10050) {
  47953. if (cp < 0x10000) return false;
  47954. if (cp < 0x1000c) return true;
  47955. if (cp < 0x1000d) return false;
  47956. if (cp < 0x10027) return true;
  47957. if (cp < 0x10028) return false;
  47958. if (cp < 0x1003b) return true;
  47959. if (cp < 0x1003c) return false;
  47960. if (cp < 0x1003e) return true;
  47961. if (cp < 0x1003f) return false;
  47962. if (cp < 0x1004e) return true;
  47963. return false;
  47964. }
  47965. if (cp < 0x1005e) return true;
  47966. if (cp < 0x10080) return false;
  47967. if (cp < 0x100fb) return true;
  47968. if (cp < 0x10140) return false;
  47969. if (cp < 0x10175) return true;
  47970. if (cp < 0x10280) return false;
  47971. if (cp < 0x1029d) return true;
  47972. if (cp < 0x102a0) return false;
  47973. if (cp < 0x102d1) return true;
  47974. if (cp < 0x10300) return false;
  47975. if (cp < 0x10320) return true;
  47976. return false;
  47977. }
  47978. if (cp < 0x10837) {
  47979. if (cp < 0x10450) {
  47980. if (cp < 0x10380) {
  47981. if (cp < 0x1032d) return false;
  47982. if (cp < 0x10341) return true;
  47983. if (cp === 0x10341) return true;
  47984. if (cp < 0x10342) return false;
  47985. if (cp < 0x1034a) return true;
  47986. if (cp === 0x1034a) return true;
  47987. if (cp < 0x10350) return false;
  47988. if (cp < 0x10376) return true;
  47989. return false;
  47990. }
  47991. if (cp < 0x1039e) return true;
  47992. if (cp < 0x103a0) return false;
  47993. if (cp < 0x103c4) return true;
  47994. if (cp < 0x103c8) return false;
  47995. if (cp < 0x103d0) return true;
  47996. if (cp < 0x103d1) return false;
  47997. if (cp < 0x103d6) return true;
  47998. if (cp < 0x10400) return false;
  47999. if (cp < 0x10450) return true;
  48000. return false;
  48001. }
  48002. if (cp < 0x10600) {
  48003. if (cp < 0x10450) return false;
  48004. if (cp < 0x1049e) return true;
  48005. if (cp < 0x104b0) return false;
  48006. if (cp < 0x104d4) return true;
  48007. if (cp < 0x104d8) return false;
  48008. if (cp < 0x104fc) return true;
  48009. if (cp < 0x10500) return false;
  48010. if (cp < 0x10528) return true;
  48011. if (cp < 0x10530) return false;
  48012. if (cp < 0x10564) return true;
  48013. return false;
  48014. }
  48015. if (cp < 0x10737) return true;
  48016. if (cp < 0x10740) return false;
  48017. if (cp < 0x10756) return true;
  48018. if (cp < 0x10760) return false;
  48019. if (cp < 0x10768) return true;
  48020. if (cp < 0x10800) return false;
  48021. if (cp < 0x10806) return true;
  48022. if (cp === 0x10808) return true;
  48023. if (cp < 0x1080a) return false;
  48024. if (cp < 0x10836) return true;
  48025. return false;
  48026. }
  48027. if (cp < 0x109be) {
  48028. if (cp < 0x108e0) {
  48029. if (cp < 0x10837) return false;
  48030. if (cp < 0x10839) return true;
  48031. if (cp === 0x1083c) return true;
  48032. if (cp < 0x1083f) return false;
  48033. if (cp < 0x10856) return true;
  48034. if (cp < 0x10860) return false;
  48035. if (cp < 0x10877) return true;
  48036. if (cp < 0x10880) return false;
  48037. if (cp < 0x1089f) return true;
  48038. return false;
  48039. }
  48040. if (cp < 0x108f3) return true;
  48041. if (cp < 0x108f4) return false;
  48042. if (cp < 0x108f6) return true;
  48043. if (cp < 0x10900) return false;
  48044. if (cp < 0x10916) return true;
  48045. if (cp < 0x10920) return false;
  48046. if (cp < 0x1093a) return true;
  48047. if (cp < 0x10980) return false;
  48048. if (cp < 0x109b8) return true;
  48049. return false;
  48050. }
  48051. if (cp < 0x10a60) {
  48052. if (cp < 0x109be) return false;
  48053. if (cp < 0x109c0) return true;
  48054. if (cp === 0x10a00) return true;
  48055. if (cp < 0x10a10) return false;
  48056. if (cp < 0x10a14) return true;
  48057. if (cp < 0x10a15) return false;
  48058. if (cp < 0x10a18) return true;
  48059. if (cp < 0x10a19) return false;
  48060. if (cp < 0x10a36) return true;
  48061. return false;
  48062. }
  48063. if (cp < 0x10a7d) return true;
  48064. if (cp < 0x10a80) return false;
  48065. if (cp < 0x10a9d) return true;
  48066. if (cp < 0x10ac0) return false;
  48067. if (cp < 0x10ac8) return true;
  48068. if (cp < 0x10ac9) return false;
  48069. if (cp < 0x10ae5) return true;
  48070. if (cp < 0x10b00) return false;
  48071. if (cp < 0x10b36) return true;
  48072. if (cp < 0x10b40) return false;
  48073. if (cp < 0x10b56) return true;
  48074. return false;
  48075. }
  48076. if (cp < 0x16e40) {
  48077. if (cp < 0x11580) {
  48078. if (cp < 0x11213) {
  48079. if (cp < 0x11083) {
  48080. if (cp < 0x10d00) {
  48081. if (cp < 0x10b60) return false;
  48082. if (cp < 0x10b73) return true;
  48083. if (cp < 0x10b80) return false;
  48084. if (cp < 0x10b92) return true;
  48085. if (cp < 0x10c00) return false;
  48086. if (cp < 0x10c49) return true;
  48087. if (cp < 0x10c80) return false;
  48088. if (cp < 0x10cb3) return true;
  48089. if (cp < 0x10cc0) return false;
  48090. if (cp < 0x10cf3) return true;
  48091. return false;
  48092. }
  48093. if (cp < 0x10d24) return true;
  48094. if (cp < 0x10f00) return false;
  48095. if (cp < 0x10f1d) return true;
  48096. if (cp === 0x10f27) return true;
  48097. if (cp < 0x10f30) return false;
  48098. if (cp < 0x10f46) return true;
  48099. if (cp < 0x11003) return false;
  48100. if (cp < 0x11038) return true;
  48101. return false;
  48102. }
  48103. if (cp < 0x11176) {
  48104. if (cp < 0x11083) return false;
  48105. if (cp < 0x110b0) return true;
  48106. if (cp < 0x110d0) return false;
  48107. if (cp < 0x110e9) return true;
  48108. if (cp < 0x11103) return false;
  48109. if (cp < 0x11127) return true;
  48110. if (cp === 0x11144) return true;
  48111. if (cp < 0x11150) return false;
  48112. if (cp < 0x11173) return true;
  48113. return false;
  48114. }
  48115. if (cp === 0x11176) return true;
  48116. if (cp < 0x11183) return false;
  48117. if (cp < 0x111b3) return true;
  48118. if (cp < 0x111c1) return false;
  48119. if (cp < 0x111c5) return true;
  48120. if (cp === 0x111da) return true;
  48121. if (cp === 0x111dc) return true;
  48122. if (cp < 0x11200) return false;
  48123. if (cp < 0x11212) return true;
  48124. return false;
  48125. }
  48126. if (cp < 0x1132a) {
  48127. if (cp < 0x1129f) {
  48128. if (cp < 0x11213) return false;
  48129. if (cp < 0x1122c) return true;
  48130. if (cp < 0x11280) return false;
  48131. if (cp < 0x11287) return true;
  48132. if (cp === 0x11288) return true;
  48133. if (cp < 0x1128a) return false;
  48134. if (cp < 0x1128e) return true;
  48135. if (cp < 0x1128f) return false;
  48136. if (cp < 0x1129e) return true;
  48137. return false;
  48138. }
  48139. if (cp < 0x112a9) return true;
  48140. if (cp < 0x112b0) return false;
  48141. if (cp < 0x112df) return true;
  48142. if (cp < 0x11305) return false;
  48143. if (cp < 0x1130d) return true;
  48144. if (cp < 0x1130f) return false;
  48145. if (cp < 0x11311) return true;
  48146. if (cp < 0x11313) return false;
  48147. if (cp < 0x11329) return true;
  48148. return false;
  48149. }
  48150. if (cp < 0x1135d) {
  48151. if (cp < 0x1132a) return false;
  48152. if (cp < 0x11331) return true;
  48153. if (cp < 0x11332) return false;
  48154. if (cp < 0x11334) return true;
  48155. if (cp < 0x11335) return false;
  48156. if (cp < 0x1133a) return true;
  48157. if (cp === 0x1133d) return true;
  48158. if (cp === 0x11350) return true;
  48159. return false;
  48160. }
  48161. if (cp < 0x11362) return true;
  48162. if (cp < 0x11400) return false;
  48163. if (cp < 0x11435) return true;
  48164. if (cp < 0x11447) return false;
  48165. if (cp < 0x1144b) return true;
  48166. if (cp < 0x11480) return false;
  48167. if (cp < 0x114b0) return true;
  48168. if (cp < 0x114c4) return false;
  48169. if (cp < 0x114c6) return true;
  48170. if (cp === 0x114c7) return true;
  48171. return false;
  48172. }
  48173. if (cp < 0x11d00) {
  48174. if (cp < 0x11a0b) {
  48175. if (cp < 0x11700) {
  48176. if (cp < 0x11580) return false;
  48177. if (cp < 0x115af) return true;
  48178. if (cp < 0x115d8) return false;
  48179. if (cp < 0x115dc) return true;
  48180. if (cp < 0x11600) return false;
  48181. if (cp < 0x11630) return true;
  48182. if (cp === 0x11644) return true;
  48183. if (cp < 0x11680) return false;
  48184. if (cp < 0x116ab) return true;
  48185. return false;
  48186. }
  48187. if (cp < 0x1171b) return true;
  48188. if (cp < 0x11800) return false;
  48189. if (cp < 0x1182c) return true;
  48190. if (cp < 0x118a0) return false;
  48191. if (cp < 0x118e0) return true;
  48192. if (cp === 0x118ff) return true;
  48193. if (cp === 0x11a00) return true;
  48194. return false;
  48195. }
  48196. if (cp < 0x11a9d) {
  48197. if (cp < 0x11a0b) return false;
  48198. if (cp < 0x11a33) return true;
  48199. if (cp === 0x11a3a) return true;
  48200. if (cp === 0x11a50) return true;
  48201. if (cp < 0x11a5c) return false;
  48202. if (cp < 0x11a84) return true;
  48203. if (cp < 0x11a86) return false;
  48204. if (cp < 0x11a8a) return true;
  48205. return false;
  48206. }
  48207. if (cp === 0x11a9d) return true;
  48208. if (cp < 0x11ac0) return false;
  48209. if (cp < 0x11af9) return true;
  48210. if (cp < 0x11c00) return false;
  48211. if (cp < 0x11c09) return true;
  48212. if (cp < 0x11c0a) return false;
  48213. if (cp < 0x11c2f) return true;
  48214. if (cp === 0x11c40) return true;
  48215. if (cp < 0x11c72) return false;
  48216. if (cp < 0x11c90) return true;
  48217. return false;
  48218. }
  48219. if (cp < 0x12400) {
  48220. if (cp < 0x11d67) {
  48221. if (cp < 0x11d00) return false;
  48222. if (cp < 0x11d07) return true;
  48223. if (cp < 0x11d08) return false;
  48224. if (cp < 0x11d0a) return true;
  48225. if (cp < 0x11d0b) return false;
  48226. if (cp < 0x11d31) return true;
  48227. if (cp === 0x11d46) return true;
  48228. if (cp < 0x11d60) return false;
  48229. if (cp < 0x11d66) return true;
  48230. return false;
  48231. }
  48232. if (cp < 0x11d69) return true;
  48233. if (cp < 0x11d6a) return false;
  48234. if (cp < 0x11d8a) return true;
  48235. if (cp === 0x11d98) return true;
  48236. if (cp < 0x11ee0) return false;
  48237. if (cp < 0x11ef3) return true;
  48238. if (cp < 0x12000) return false;
  48239. if (cp < 0x1239a) return true;
  48240. return false;
  48241. }
  48242. if (cp < 0x16a40) {
  48243. if (cp < 0x12400) return false;
  48244. if (cp < 0x1246f) return true;
  48245. if (cp < 0x12480) return false;
  48246. if (cp < 0x12544) return true;
  48247. if (cp < 0x13000) return false;
  48248. if (cp < 0x1342f) return true;
  48249. if (cp < 0x14400) return false;
  48250. if (cp < 0x14647) return true;
  48251. if (cp < 0x16800) return false;
  48252. if (cp < 0x16a39) return true;
  48253. return false;
  48254. }
  48255. if (cp < 0x16a5f) return true;
  48256. if (cp < 0x16ad0) return false;
  48257. if (cp < 0x16aee) return true;
  48258. if (cp < 0x16b00) return false;
  48259. if (cp < 0x16b30) return true;
  48260. if (cp < 0x16b40) return false;
  48261. if (cp < 0x16b44) return true;
  48262. if (cp < 0x16b63) return false;
  48263. if (cp < 0x16b78) return true;
  48264. if (cp < 0x16b7d) return false;
  48265. if (cp < 0x16b90) return true;
  48266. return false;
  48267. }
  48268. if (cp < 0x1d7c4) {
  48269. if (cp < 0x1d4bd) {
  48270. if (cp < 0x1bc70) {
  48271. if (cp < 0x17000) {
  48272. if (cp < 0x16e40) return false;
  48273. if (cp < 0x16e80) return true;
  48274. if (cp < 0x16f00) return false;
  48275. if (cp < 0x16f45) return true;
  48276. if (cp === 0x16f50) return true;
  48277. if (cp < 0x16f93) return false;
  48278. if (cp < 0x16fa0) return true;
  48279. if (cp < 0x16fe0) return false;
  48280. if (cp < 0x16fe2) return true;
  48281. return false;
  48282. }
  48283. if (cp < 0x187f2) return true;
  48284. if (cp < 0x18800) return false;
  48285. if (cp < 0x18af3) return true;
  48286. if (cp < 0x1b000) return false;
  48287. if (cp < 0x1b11f) return true;
  48288. if (cp < 0x1b170) return false;
  48289. if (cp < 0x1b2fc) return true;
  48290. if (cp < 0x1bc00) return false;
  48291. if (cp < 0x1bc6b) return true;
  48292. return false;
  48293. }
  48294. if (cp < 0x1d49e) {
  48295. if (cp < 0x1bc70) return false;
  48296. if (cp < 0x1bc7d) return true;
  48297. if (cp < 0x1bc80) return false;
  48298. if (cp < 0x1bc89) return true;
  48299. if (cp < 0x1bc90) return false;
  48300. if (cp < 0x1bc9a) return true;
  48301. if (cp < 0x1d400) return false;
  48302. if (cp < 0x1d455) return true;
  48303. if (cp < 0x1d456) return false;
  48304. if (cp < 0x1d49d) return true;
  48305. return false;
  48306. }
  48307. if (cp < 0x1d4a0) return true;
  48308. if (cp === 0x1d4a2) return true;
  48309. if (cp < 0x1d4a5) return false;
  48310. if (cp < 0x1d4a7) return true;
  48311. if (cp < 0x1d4a9) return false;
  48312. if (cp < 0x1d4ad) return true;
  48313. if (cp < 0x1d4ae) return false;
  48314. if (cp < 0x1d4ba) return true;
  48315. if (cp === 0x1d4bb) return true;
  48316. return false;
  48317. }
  48318. if (cp < 0x1d552) {
  48319. if (cp < 0x1d51e) {
  48320. if (cp < 0x1d4bd) return false;
  48321. if (cp < 0x1d4c4) return true;
  48322. if (cp < 0x1d4c5) return false;
  48323. if (cp < 0x1d506) return true;
  48324. if (cp < 0x1d507) return false;
  48325. if (cp < 0x1d50b) return true;
  48326. if (cp < 0x1d50d) return false;
  48327. if (cp < 0x1d515) return true;
  48328. if (cp < 0x1d516) return false;
  48329. if (cp < 0x1d51d) return true;
  48330. return false;
  48331. }
  48332. if (cp < 0x1d53a) return true;
  48333. if (cp < 0x1d53b) return false;
  48334. if (cp < 0x1d53f) return true;
  48335. if (cp < 0x1d540) return false;
  48336. if (cp < 0x1d545) return true;
  48337. if (cp === 0x1d546) return true;
  48338. if (cp < 0x1d54a) return false;
  48339. if (cp < 0x1d551) return true;
  48340. return false;
  48341. }
  48342. if (cp < 0x1d716) {
  48343. if (cp < 0x1d552) return false;
  48344. if (cp < 0x1d6a6) return true;
  48345. if (cp < 0x1d6a8) return false;
  48346. if (cp < 0x1d6c1) return true;
  48347. if (cp < 0x1d6c2) return false;
  48348. if (cp < 0x1d6db) return true;
  48349. if (cp < 0x1d6dc) return false;
  48350. if (cp < 0x1d6fb) return true;
  48351. if (cp < 0x1d6fc) return false;
  48352. if (cp < 0x1d715) return true;
  48353. return false;
  48354. }
  48355. if (cp < 0x1d735) return true;
  48356. if (cp < 0x1d736) return false;
  48357. if (cp < 0x1d74f) return true;
  48358. if (cp < 0x1d750) return false;
  48359. if (cp < 0x1d76f) return true;
  48360. if (cp < 0x1d770) return false;
  48361. if (cp < 0x1d789) return true;
  48362. if (cp < 0x1d78a) return false;
  48363. if (cp < 0x1d7a9) return true;
  48364. if (cp < 0x1d7aa) return false;
  48365. if (cp < 0x1d7c3) return true;
  48366. return false;
  48367. }
  48368. if (cp < 0x1ee5b) {
  48369. if (cp < 0x1ee39) {
  48370. if (cp < 0x1ee21) {
  48371. if (cp < 0x1d7c4) return false;
  48372. if (cp < 0x1d7cc) return true;
  48373. if (cp < 0x1e800) return false;
  48374. if (cp < 0x1e8c5) return true;
  48375. if (cp < 0x1e900) return false;
  48376. if (cp < 0x1e944) return true;
  48377. if (cp < 0x1ee00) return false;
  48378. if (cp < 0x1ee04) return true;
  48379. if (cp < 0x1ee05) return false;
  48380. if (cp < 0x1ee20) return true;
  48381. return false;
  48382. }
  48383. if (cp < 0x1ee23) return true;
  48384. if (cp === 0x1ee24) return true;
  48385. if (cp === 0x1ee27) return true;
  48386. if (cp < 0x1ee29) return false;
  48387. if (cp < 0x1ee33) return true;
  48388. if (cp < 0x1ee34) return false;
  48389. if (cp < 0x1ee38) return true;
  48390. return false;
  48391. }
  48392. if (cp < 0x1ee4b) {
  48393. if (cp === 0x1ee39) return true;
  48394. if (cp === 0x1ee3b) return true;
  48395. if (cp === 0x1ee42) return true;
  48396. if (cp === 0x1ee47) return true;
  48397. if (cp === 0x1ee49) return true;
  48398. return false;
  48399. }
  48400. if (cp === 0x1ee4b) return true;
  48401. if (cp < 0x1ee4d) return false;
  48402. if (cp < 0x1ee50) return true;
  48403. if (cp < 0x1ee51) return false;
  48404. if (cp < 0x1ee53) return true;
  48405. if (cp === 0x1ee54) return true;
  48406. if (cp === 0x1ee57) return true;
  48407. if (cp === 0x1ee59) return true;
  48408. return false;
  48409. }
  48410. if (cp < 0x1ee80) {
  48411. if (cp < 0x1ee67) {
  48412. if (cp === 0x1ee5b) return true;
  48413. if (cp === 0x1ee5d) return true;
  48414. if (cp === 0x1ee5f) return true;
  48415. if (cp < 0x1ee61) return false;
  48416. if (cp < 0x1ee63) return true;
  48417. if (cp === 0x1ee64) return true;
  48418. return false;
  48419. }
  48420. if (cp < 0x1ee6b) return true;
  48421. if (cp < 0x1ee6c) return false;
  48422. if (cp < 0x1ee73) return true;
  48423. if (cp < 0x1ee74) return false;
  48424. if (cp < 0x1ee78) return true;
  48425. if (cp < 0x1ee79) return false;
  48426. if (cp < 0x1ee7d) return true;
  48427. if (cp === 0x1ee7e) return true;
  48428. return false;
  48429. }
  48430. if (cp < 0x20000) {
  48431. if (cp < 0x1ee80) return false;
  48432. if (cp < 0x1ee8a) return true;
  48433. if (cp < 0x1ee8b) return false;
  48434. if (cp < 0x1ee9c) return true;
  48435. if (cp < 0x1eea1) return false;
  48436. if (cp < 0x1eea4) return true;
  48437. if (cp < 0x1eea5) return false;
  48438. if (cp < 0x1eeaa) return true;
  48439. if (cp < 0x1eeab) return false;
  48440. if (cp < 0x1eebc) return true;
  48441. return false;
  48442. }
  48443. if (cp < 0x2a6d7) return true;
  48444. if (cp < 0x2a700) return false;
  48445. if (cp < 0x2b735) return true;
  48446. if (cp < 0x2b740) return false;
  48447. if (cp < 0x2b81e) return true;
  48448. if (cp < 0x2b820) return false;
  48449. if (cp < 0x2cea2) return true;
  48450. if (cp < 0x2ceb0) return false;
  48451. if (cp < 0x2ebe1) return true;
  48452. if (cp < 0x2f800) return false;
  48453. if (cp < 0x2fa1e) return true;
  48454. return false;
  48455. }
  48456. function isLargeIdContinue(cp) {
  48457. if (cp < 0x1cd0) {
  48458. if (cp < 0xd82) {
  48459. if (cp < 0xa83) {
  48460. if (cp < 0x93b) {
  48461. if (cp < 0x6ea) {
  48462. if (cp < 0x5c7) {
  48463. if (cp === 0xb7) return true;
  48464. if (cp < 0x300) return false;
  48465. if (cp < 0x370) return true;
  48466. if (cp === 0x387) return true;
  48467. if (cp < 0x483) return false;
  48468. if (cp < 0x488) return true;
  48469. if (cp < 0x591) return false;
  48470. if (cp < 0x5be) return true;
  48471. if (cp === 0x5bf) return true;
  48472. if (cp < 0x5c1) return false;
  48473. if (cp < 0x5c3) return true;
  48474. if (cp < 0x5c4) return false;
  48475. if (cp < 0x5c6) return true;
  48476. return false;
  48477. }
  48478. if (cp === 0x5c7) return true;
  48479. if (cp < 0x610) return false;
  48480. if (cp < 0x61b) return true;
  48481. if (cp < 0x64b) return false;
  48482. if (cp < 0x660) return true;
  48483. if (cp < 0x660) return false;
  48484. if (cp < 0x66a) return true;
  48485. if (cp === 0x670) return true;
  48486. if (cp < 0x6d6) return false;
  48487. if (cp < 0x6dd) return true;
  48488. if (cp < 0x6df) return false;
  48489. if (cp < 0x6e5) return true;
  48490. if (cp < 0x6e7) return false;
  48491. if (cp < 0x6e9) return true;
  48492. return false;
  48493. }
  48494. if (cp < 0x816) {
  48495. if (cp < 0x6ea) return false;
  48496. if (cp < 0x6ee) return true;
  48497. if (cp < 0x6f0) return false;
  48498. if (cp < 0x6fa) return true;
  48499. if (cp === 0x711) return true;
  48500. if (cp < 0x730) return false;
  48501. if (cp < 0x74b) return true;
  48502. if (cp < 0x7a6) return false;
  48503. if (cp < 0x7b1) return true;
  48504. if (cp < 0x7c0) return false;
  48505. if (cp < 0x7ca) return true;
  48506. if (cp < 0x7eb) return false;
  48507. if (cp < 0x7f4) return true;
  48508. if (cp === 0x7fd) return true;
  48509. return false;
  48510. }
  48511. if (cp < 0x81a) return true;
  48512. if (cp < 0x81b) return false;
  48513. if (cp < 0x824) return true;
  48514. if (cp < 0x825) return false;
  48515. if (cp < 0x828) return true;
  48516. if (cp < 0x829) return false;
  48517. if (cp < 0x82e) return true;
  48518. if (cp < 0x859) return false;
  48519. if (cp < 0x85c) return true;
  48520. if (cp < 0x8d3) return false;
  48521. if (cp < 0x8e2) return true;
  48522. if (cp < 0x8e3) return false;
  48523. if (cp < 0x903) return true;
  48524. if (cp === 0x903) return true;
  48525. if (cp === 0x93a) return true;
  48526. return false;
  48527. }
  48528. if (cp < 0x9cd) {
  48529. if (cp < 0x962) {
  48530. if (cp === 0x93b) return true;
  48531. if (cp === 0x93c) return true;
  48532. if (cp < 0x93e) return false;
  48533. if (cp < 0x941) return true;
  48534. if (cp < 0x941) return false;
  48535. if (cp < 0x949) return true;
  48536. if (cp < 0x949) return false;
  48537. if (cp < 0x94d) return true;
  48538. if (cp === 0x94d) return true;
  48539. if (cp < 0x94e) return false;
  48540. if (cp < 0x950) return true;
  48541. if (cp < 0x951) return false;
  48542. if (cp < 0x958) return true;
  48543. return false;
  48544. }
  48545. if (cp < 0x964) return true;
  48546. if (cp < 0x966) return false;
  48547. if (cp < 0x970) return true;
  48548. if (cp === 0x981) return true;
  48549. if (cp < 0x982) return false;
  48550. if (cp < 0x984) return true;
  48551. if (cp === 0x9bc) return true;
  48552. if (cp < 0x9be) return false;
  48553. if (cp < 0x9c1) return true;
  48554. if (cp < 0x9c1) return false;
  48555. if (cp < 0x9c5) return true;
  48556. if (cp < 0x9c7) return false;
  48557. if (cp < 0x9c9) return true;
  48558. if (cp < 0x9cb) return false;
  48559. if (cp < 0x9cd) return true;
  48560. return false;
  48561. }
  48562. if (cp < 0xa3e) {
  48563. if (cp === 0x9cd) return true;
  48564. if (cp === 0x9d7) return true;
  48565. if (cp < 0x9e2) return false;
  48566. if (cp < 0x9e4) return true;
  48567. if (cp < 0x9e6) return false;
  48568. if (cp < 0x9f0) return true;
  48569. if (cp === 0x9fe) return true;
  48570. if (cp < 0xa01) return false;
  48571. if (cp < 0xa03) return true;
  48572. if (cp === 0xa03) return true;
  48573. if (cp === 0xa3c) return true;
  48574. return false;
  48575. }
  48576. if (cp < 0xa41) return true;
  48577. if (cp < 0xa41) return false;
  48578. if (cp < 0xa43) return true;
  48579. if (cp < 0xa47) return false;
  48580. if (cp < 0xa49) return true;
  48581. if (cp < 0xa4b) return false;
  48582. if (cp < 0xa4e) return true;
  48583. if (cp === 0xa51) return true;
  48584. if (cp < 0xa66) return false;
  48585. if (cp < 0xa70) return true;
  48586. if (cp < 0xa70) return false;
  48587. if (cp < 0xa72) return true;
  48588. if (cp === 0xa75) return true;
  48589. if (cp < 0xa81) return false;
  48590. if (cp < 0xa83) return true;
  48591. return false;
  48592. }
  48593. if (cp < 0xc00) {
  48594. if (cp < 0xb41) {
  48595. if (cp < 0xae2) {
  48596. if (cp === 0xa83) return true;
  48597. if (cp === 0xabc) return true;
  48598. if (cp < 0xabe) return false;
  48599. if (cp < 0xac1) return true;
  48600. if (cp < 0xac1) return false;
  48601. if (cp < 0xac6) return true;
  48602. if (cp < 0xac7) return false;
  48603. if (cp < 0xac9) return true;
  48604. if (cp === 0xac9) return true;
  48605. if (cp < 0xacb) return false;
  48606. if (cp < 0xacd) return true;
  48607. if (cp === 0xacd) return true;
  48608. return false;
  48609. }
  48610. if (cp < 0xae4) return true;
  48611. if (cp < 0xae6) return false;
  48612. if (cp < 0xaf0) return true;
  48613. if (cp < 0xafa) return false;
  48614. if (cp < 0xb00) return true;
  48615. if (cp === 0xb01) return true;
  48616. if (cp < 0xb02) return false;
  48617. if (cp < 0xb04) return true;
  48618. if (cp === 0xb3c) return true;
  48619. if (cp === 0xb3e) return true;
  48620. if (cp === 0xb3f) return true;
  48621. if (cp === 0xb40) return true;
  48622. return false;
  48623. }
  48624. if (cp < 0xb82) {
  48625. if (cp < 0xb41) return false;
  48626. if (cp < 0xb45) return true;
  48627. if (cp < 0xb47) return false;
  48628. if (cp < 0xb49) return true;
  48629. if (cp < 0xb4b) return false;
  48630. if (cp < 0xb4d) return true;
  48631. if (cp === 0xb4d) return true;
  48632. if (cp === 0xb56) return true;
  48633. if (cp === 0xb57) return true;
  48634. if (cp < 0xb62) return false;
  48635. if (cp < 0xb64) return true;
  48636. if (cp < 0xb66) return false;
  48637. if (cp < 0xb70) return true;
  48638. return false;
  48639. }
  48640. if (cp === 0xb82) return true;
  48641. if (cp < 0xbbe) return false;
  48642. if (cp < 0xbc0) return true;
  48643. if (cp === 0xbc0) return true;
  48644. if (cp < 0xbc1) return false;
  48645. if (cp < 0xbc3) return true;
  48646. if (cp < 0xbc6) return false;
  48647. if (cp < 0xbc9) return true;
  48648. if (cp < 0xbca) return false;
  48649. if (cp < 0xbcd) return true;
  48650. if (cp === 0xbcd) return true;
  48651. if (cp === 0xbd7) return true;
  48652. if (cp < 0xbe6) return false;
  48653. if (cp < 0xbf0) return true;
  48654. return false;
  48655. }
  48656. if (cp < 0xcc7) {
  48657. if (cp < 0xc62) {
  48658. if (cp === 0xc00) return true;
  48659. if (cp < 0xc01) return false;
  48660. if (cp < 0xc04) return true;
  48661. if (cp === 0xc04) return true;
  48662. if (cp < 0xc3e) return false;
  48663. if (cp < 0xc41) return true;
  48664. if (cp < 0xc41) return false;
  48665. if (cp < 0xc45) return true;
  48666. if (cp < 0xc46) return false;
  48667. if (cp < 0xc49) return true;
  48668. if (cp < 0xc4a) return false;
  48669. if (cp < 0xc4e) return true;
  48670. if (cp < 0xc55) return false;
  48671. if (cp < 0xc57) return true;
  48672. return false;
  48673. }
  48674. if (cp < 0xc64) return true;
  48675. if (cp < 0xc66) return false;
  48676. if (cp < 0xc70) return true;
  48677. if (cp === 0xc81) return true;
  48678. if (cp < 0xc82) return false;
  48679. if (cp < 0xc84) return true;
  48680. if (cp === 0xcbc) return true;
  48681. if (cp === 0xcbe) return true;
  48682. if (cp === 0xcbf) return true;
  48683. if (cp < 0xcc0) return false;
  48684. if (cp < 0xcc5) return true;
  48685. if (cp === 0xcc6) return true;
  48686. return false;
  48687. }
  48688. if (cp < 0xd3b) {
  48689. if (cp < 0xcc7) return false;
  48690. if (cp < 0xcc9) return true;
  48691. if (cp < 0xcca) return false;
  48692. if (cp < 0xccc) return true;
  48693. if (cp < 0xccc) return false;
  48694. if (cp < 0xcce) return true;
  48695. if (cp < 0xcd5) return false;
  48696. if (cp < 0xcd7) return true;
  48697. if (cp < 0xce2) return false;
  48698. if (cp < 0xce4) return true;
  48699. if (cp < 0xce6) return false;
  48700. if (cp < 0xcf0) return true;
  48701. if (cp < 0xd00) return false;
  48702. if (cp < 0xd02) return true;
  48703. if (cp < 0xd02) return false;
  48704. if (cp < 0xd04) return true;
  48705. return false;
  48706. }
  48707. if (cp < 0xd3d) return true;
  48708. if (cp < 0xd3e) return false;
  48709. if (cp < 0xd41) return true;
  48710. if (cp < 0xd41) return false;
  48711. if (cp < 0xd45) return true;
  48712. if (cp < 0xd46) return false;
  48713. if (cp < 0xd49) return true;
  48714. if (cp < 0xd4a) return false;
  48715. if (cp < 0xd4d) return true;
  48716. if (cp === 0xd4d) return true;
  48717. if (cp === 0xd57) return true;
  48718. if (cp < 0xd62) return false;
  48719. if (cp < 0xd64) return true;
  48720. if (cp < 0xd66) return false;
  48721. if (cp < 0xd70) return true;
  48722. return false;
  48723. }
  48724. if (cp < 0x17e0) {
  48725. if (cp < 0x1038) {
  48726. if (cp < 0xf18) {
  48727. if (cp < 0xe31) {
  48728. if (cp < 0xd82) return false;
  48729. if (cp < 0xd84) return true;
  48730. if (cp === 0xdca) return true;
  48731. if (cp < 0xdcf) return false;
  48732. if (cp < 0xdd2) return true;
  48733. if (cp < 0xdd2) return false;
  48734. if (cp < 0xdd5) return true;
  48735. if (cp === 0xdd6) return true;
  48736. if (cp < 0xdd8) return false;
  48737. if (cp < 0xde0) return true;
  48738. if (cp < 0xde6) return false;
  48739. if (cp < 0xdf0) return true;
  48740. if (cp < 0xdf2) return false;
  48741. if (cp < 0xdf4) return true;
  48742. return false;
  48743. }
  48744. if (cp === 0xe31) return true;
  48745. if (cp < 0xe34) return false;
  48746. if (cp < 0xe3b) return true;
  48747. if (cp < 0xe47) return false;
  48748. if (cp < 0xe4f) return true;
  48749. if (cp < 0xe50) return false;
  48750. if (cp < 0xe5a) return true;
  48751. if (cp === 0xeb1) return true;
  48752. if (cp < 0xeb4) return false;
  48753. if (cp < 0xeba) return true;
  48754. if (cp < 0xebb) return false;
  48755. if (cp < 0xebd) return true;
  48756. if (cp < 0xec8) return false;
  48757. if (cp < 0xece) return true;
  48758. if (cp < 0xed0) return false;
  48759. if (cp < 0xeda) return true;
  48760. return false;
  48761. }
  48762. if (cp < 0xf80) {
  48763. if (cp < 0xf18) return false;
  48764. if (cp < 0xf1a) return true;
  48765. if (cp < 0xf20) return false;
  48766. if (cp < 0xf2a) return true;
  48767. if (cp === 0xf35) return true;
  48768. if (cp === 0xf37) return true;
  48769. if (cp === 0xf39) return true;
  48770. if (cp < 0xf3e) return false;
  48771. if (cp < 0xf40) return true;
  48772. if (cp < 0xf71) return false;
  48773. if (cp < 0xf7f) return true;
  48774. if (cp === 0xf7f) return true;
  48775. return false;
  48776. }
  48777. if (cp < 0xf85) return true;
  48778. if (cp < 0xf86) return false;
  48779. if (cp < 0xf88) return true;
  48780. if (cp < 0xf8d) return false;
  48781. if (cp < 0xf98) return true;
  48782. if (cp < 0xf99) return false;
  48783. if (cp < 0xfbd) return true;
  48784. if (cp === 0xfc6) return true;
  48785. if (cp < 0x102b) return false;
  48786. if (cp < 0x102d) return true;
  48787. if (cp < 0x102d) return false;
  48788. if (cp < 0x1031) return true;
  48789. if (cp === 0x1031) return true;
  48790. if (cp < 0x1032) return false;
  48791. if (cp < 0x1038) return true;
  48792. return false;
  48793. }
  48794. if (cp < 0x1090) {
  48795. if (cp < 0x1062) {
  48796. if (cp === 0x1038) return true;
  48797. if (cp < 0x1039) return false;
  48798. if (cp < 0x103b) return true;
  48799. if (cp < 0x103b) return false;
  48800. if (cp < 0x103d) return true;
  48801. if (cp < 0x103d) return false;
  48802. if (cp < 0x103f) return true;
  48803. if (cp < 0x1040) return false;
  48804. if (cp < 0x104a) return true;
  48805. if (cp < 0x1056) return false;
  48806. if (cp < 0x1058) return true;
  48807. if (cp < 0x1058) return false;
  48808. if (cp < 0x105a) return true;
  48809. if (cp < 0x105e) return false;
  48810. if (cp < 0x1061) return true;
  48811. return false;
  48812. }
  48813. if (cp < 0x1065) return true;
  48814. if (cp < 0x1067) return false;
  48815. if (cp < 0x106e) return true;
  48816. if (cp < 0x1071) return false;
  48817. if (cp < 0x1075) return true;
  48818. if (cp === 0x1082) return true;
  48819. if (cp < 0x1083) return false;
  48820. if (cp < 0x1085) return true;
  48821. if (cp < 0x1085) return false;
  48822. if (cp < 0x1087) return true;
  48823. if (cp < 0x1087) return false;
  48824. if (cp < 0x108d) return true;
  48825. if (cp === 0x108d) return true;
  48826. if (cp === 0x108f) return true;
  48827. return false;
  48828. }
  48829. if (cp < 0x1772) {
  48830. if (cp < 0x1090) return false;
  48831. if (cp < 0x109a) return true;
  48832. if (cp < 0x109a) return false;
  48833. if (cp < 0x109d) return true;
  48834. if (cp === 0x109d) return true;
  48835. if (cp < 0x135d) return false;
  48836. if (cp < 0x1360) return true;
  48837. if (cp < 0x1369) return false;
  48838. if (cp < 0x1372) return true;
  48839. if (cp < 0x1712) return false;
  48840. if (cp < 0x1715) return true;
  48841. if (cp < 0x1732) return false;
  48842. if (cp < 0x1735) return true;
  48843. if (cp < 0x1752) return false;
  48844. if (cp < 0x1754) return true;
  48845. return false;
  48846. }
  48847. if (cp < 0x1774) return true;
  48848. if (cp < 0x17b4) return false;
  48849. if (cp < 0x17b6) return true;
  48850. if (cp === 0x17b6) return true;
  48851. if (cp < 0x17b7) return false;
  48852. if (cp < 0x17be) return true;
  48853. if (cp < 0x17be) return false;
  48854. if (cp < 0x17c6) return true;
  48855. if (cp === 0x17c6) return true;
  48856. if (cp < 0x17c7) return false;
  48857. if (cp < 0x17c9) return true;
  48858. if (cp < 0x17c9) return false;
  48859. if (cp < 0x17d4) return true;
  48860. if (cp === 0x17dd) return true;
  48861. return false;
  48862. }
  48863. if (cp < 0x1b04) {
  48864. if (cp < 0x1a1b) {
  48865. if (cp < 0x1930) {
  48866. if (cp < 0x17e0) return false;
  48867. if (cp < 0x17ea) return true;
  48868. if (cp < 0x180b) return false;
  48869. if (cp < 0x180e) return true;
  48870. if (cp < 0x1810) return false;
  48871. if (cp < 0x181a) return true;
  48872. if (cp === 0x18a9) return true;
  48873. if (cp < 0x1920) return false;
  48874. if (cp < 0x1923) return true;
  48875. if (cp < 0x1923) return false;
  48876. if (cp < 0x1927) return true;
  48877. if (cp < 0x1927) return false;
  48878. if (cp < 0x1929) return true;
  48879. if (cp < 0x1929) return false;
  48880. if (cp < 0x192c) return true;
  48881. return false;
  48882. }
  48883. if (cp < 0x1932) return true;
  48884. if (cp === 0x1932) return true;
  48885. if (cp < 0x1933) return false;
  48886. if (cp < 0x1939) return true;
  48887. if (cp < 0x1939) return false;
  48888. if (cp < 0x193c) return true;
  48889. if (cp < 0x1946) return false;
  48890. if (cp < 0x1950) return true;
  48891. if (cp < 0x19d0) return false;
  48892. if (cp < 0x19da) return true;
  48893. if (cp === 0x19da) return true;
  48894. if (cp < 0x1a17) return false;
  48895. if (cp < 0x1a19) return true;
  48896. if (cp < 0x1a19) return false;
  48897. if (cp < 0x1a1b) return true;
  48898. return false;
  48899. }
  48900. if (cp < 0x1a63) {
  48901. if (cp === 0x1a1b) return true;
  48902. if (cp === 0x1a55) return true;
  48903. if (cp === 0x1a56) return true;
  48904. if (cp === 0x1a57) return true;
  48905. if (cp < 0x1a58) return false;
  48906. if (cp < 0x1a5f) return true;
  48907. if (cp === 0x1a60) return true;
  48908. if (cp === 0x1a61) return true;
  48909. if (cp === 0x1a62) return true;
  48910. return false;
  48911. }
  48912. if (cp < 0x1a65) return true;
  48913. if (cp < 0x1a65) return false;
  48914. if (cp < 0x1a6d) return true;
  48915. if (cp < 0x1a6d) return false;
  48916. if (cp < 0x1a73) return true;
  48917. if (cp < 0x1a73) return false;
  48918. if (cp < 0x1a7d) return true;
  48919. if (cp === 0x1a7f) return true;
  48920. if (cp < 0x1a80) return false;
  48921. if (cp < 0x1a8a) return true;
  48922. if (cp < 0x1a90) return false;
  48923. if (cp < 0x1a9a) return true;
  48924. if (cp < 0x1ab0) return false;
  48925. if (cp < 0x1abe) return true;
  48926. if (cp < 0x1b00) return false;
  48927. if (cp < 0x1b04) return true;
  48928. return false;
  48929. }
  48930. if (cp < 0x1baa) {
  48931. if (cp < 0x1b43) {
  48932. if (cp === 0x1b04) return true;
  48933. if (cp === 0x1b34) return true;
  48934. if (cp === 0x1b35) return true;
  48935. if (cp < 0x1b36) return false;
  48936. if (cp < 0x1b3b) return true;
  48937. if (cp === 0x1b3b) return true;
  48938. if (cp === 0x1b3c) return true;
  48939. if (cp < 0x1b3d) return false;
  48940. if (cp < 0x1b42) return true;
  48941. if (cp === 0x1b42) return true;
  48942. return false;
  48943. }
  48944. if (cp < 0x1b45) return true;
  48945. if (cp < 0x1b50) return false;
  48946. if (cp < 0x1b5a) return true;
  48947. if (cp < 0x1b6b) return false;
  48948. if (cp < 0x1b74) return true;
  48949. if (cp < 0x1b80) return false;
  48950. if (cp < 0x1b82) return true;
  48951. if (cp === 0x1b82) return true;
  48952. if (cp === 0x1ba1) return true;
  48953. if (cp < 0x1ba2) return false;
  48954. if (cp < 0x1ba6) return true;
  48955. if (cp < 0x1ba6) return false;
  48956. if (cp < 0x1ba8) return true;
  48957. if (cp < 0x1ba8) return false;
  48958. if (cp < 0x1baa) return true;
  48959. return false;
  48960. }
  48961. if (cp < 0x1bee) {
  48962. if (cp === 0x1baa) return true;
  48963. if (cp < 0x1bab) return false;
  48964. if (cp < 0x1bae) return true;
  48965. if (cp < 0x1bb0) return false;
  48966. if (cp < 0x1bba) return true;
  48967. if (cp === 0x1be6) return true;
  48968. if (cp === 0x1be7) return true;
  48969. if (cp < 0x1be8) return false;
  48970. if (cp < 0x1bea) return true;
  48971. if (cp < 0x1bea) return false;
  48972. if (cp < 0x1bed) return true;
  48973. if (cp === 0x1bed) return true;
  48974. return false;
  48975. }
  48976. if (cp === 0x1bee) return true;
  48977. if (cp < 0x1bef) return false;
  48978. if (cp < 0x1bf2) return true;
  48979. if (cp < 0x1bf2) return false;
  48980. if (cp < 0x1bf4) return true;
  48981. if (cp < 0x1c24) return false;
  48982. if (cp < 0x1c2c) return true;
  48983. if (cp < 0x1c2c) return false;
  48984. if (cp < 0x1c34) return true;
  48985. if (cp < 0x1c34) return false;
  48986. if (cp < 0x1c36) return true;
  48987. if (cp < 0x1c36) return false;
  48988. if (cp < 0x1c38) return true;
  48989. if (cp < 0x1c40) return false;
  48990. if (cp < 0x1c4a) return true;
  48991. if (cp < 0x1c50) return false;
  48992. if (cp < 0x1c5a) return true;
  48993. return false;
  48994. }
  48995. if (cp < 0x1123e) {
  48996. if (cp < 0xaab7) {
  48997. if (cp < 0xa8b4) {
  48998. if (cp < 0x2d7f) {
  48999. if (cp < 0x1cf8) {
  49000. if (cp < 0x1cd0) return false;
  49001. if (cp < 0x1cd3) return true;
  49002. if (cp < 0x1cd4) return false;
  49003. if (cp < 0x1ce1) return true;
  49004. if (cp === 0x1ce1) return true;
  49005. if (cp < 0x1ce2) return false;
  49006. if (cp < 0x1ce9) return true;
  49007. if (cp === 0x1ced) return true;
  49008. if (cp < 0x1cf2) return false;
  49009. if (cp < 0x1cf4) return true;
  49010. if (cp === 0x1cf4) return true;
  49011. if (cp === 0x1cf7) return true;
  49012. return false;
  49013. }
  49014. if (cp < 0x1cfa) return true;
  49015. if (cp < 0x1dc0) return false;
  49016. if (cp < 0x1dfa) return true;
  49017. if (cp < 0x1dfb) return false;
  49018. if (cp < 0x1e00) return true;
  49019. if (cp < 0x203f) return false;
  49020. if (cp < 0x2041) return true;
  49021. if (cp === 0x2054) return true;
  49022. if (cp < 0x20d0) return false;
  49023. if (cp < 0x20dd) return true;
  49024. if (cp === 0x20e1) return true;
  49025. if (cp < 0x20e5) return false;
  49026. if (cp < 0x20f1) return true;
  49027. if (cp < 0x2cef) return false;
  49028. if (cp < 0x2cf2) return true;
  49029. return false;
  49030. }
  49031. if (cp < 0xa69e) {
  49032. if (cp === 0x2d7f) return true;
  49033. if (cp < 0x2de0) return false;
  49034. if (cp < 0x2e00) return true;
  49035. if (cp < 0x302a) return false;
  49036. if (cp < 0x302e) return true;
  49037. if (cp < 0x302e) return false;
  49038. if (cp < 0x3030) return true;
  49039. if (cp < 0x3099) return false;
  49040. if (cp < 0x309b) return true;
  49041. if (cp < 0xa620) return false;
  49042. if (cp < 0xa62a) return true;
  49043. if (cp === 0xa66f) return true;
  49044. if (cp < 0xa674) return false;
  49045. if (cp < 0xa67e) return true;
  49046. return false;
  49047. }
  49048. if (cp < 0xa6a0) return true;
  49049. if (cp < 0xa6f0) return false;
  49050. if (cp < 0xa6f2) return true;
  49051. if (cp === 0xa802) return true;
  49052. if (cp === 0xa806) return true;
  49053. if (cp === 0xa80b) return true;
  49054. if (cp < 0xa823) return false;
  49055. if (cp < 0xa825) return true;
  49056. if (cp < 0xa825) return false;
  49057. if (cp < 0xa827) return true;
  49058. if (cp === 0xa827) return true;
  49059. if (cp < 0xa880) return false;
  49060. if (cp < 0xa882) return true;
  49061. return false;
  49062. }
  49063. if (cp < 0xa9d0) {
  49064. if (cp < 0xa952) {
  49065. if (cp < 0xa8b4) return false;
  49066. if (cp < 0xa8c4) return true;
  49067. if (cp < 0xa8c4) return false;
  49068. if (cp < 0xa8c6) return true;
  49069. if (cp < 0xa8d0) return false;
  49070. if (cp < 0xa8da) return true;
  49071. if (cp < 0xa8e0) return false;
  49072. if (cp < 0xa8f2) return true;
  49073. if (cp === 0xa8ff) return true;
  49074. if (cp < 0xa900) return false;
  49075. if (cp < 0xa90a) return true;
  49076. if (cp < 0xa926) return false;
  49077. if (cp < 0xa92e) return true;
  49078. if (cp < 0xa947) return false;
  49079. if (cp < 0xa952) return true;
  49080. return false;
  49081. }
  49082. if (cp < 0xa954) return true;
  49083. if (cp < 0xa980) return false;
  49084. if (cp < 0xa983) return true;
  49085. if (cp === 0xa983) return true;
  49086. if (cp === 0xa9b3) return true;
  49087. if (cp < 0xa9b4) return false;
  49088. if (cp < 0xa9b6) return true;
  49089. if (cp < 0xa9b6) return false;
  49090. if (cp < 0xa9ba) return true;
  49091. if (cp < 0xa9ba) return false;
  49092. if (cp < 0xa9bc) return true;
  49093. if (cp === 0xa9bc) return true;
  49094. if (cp < 0xa9bd) return false;
  49095. if (cp < 0xa9c1) return true;
  49096. return false;
  49097. }
  49098. if (cp < 0xaa43) {
  49099. if (cp < 0xa9d0) return false;
  49100. if (cp < 0xa9da) return true;
  49101. if (cp === 0xa9e5) return true;
  49102. if (cp < 0xa9f0) return false;
  49103. if (cp < 0xa9fa) return true;
  49104. if (cp < 0xaa29) return false;
  49105. if (cp < 0xaa2f) return true;
  49106. if (cp < 0xaa2f) return false;
  49107. if (cp < 0xaa31) return true;
  49108. if (cp < 0xaa31) return false;
  49109. if (cp < 0xaa33) return true;
  49110. if (cp < 0xaa33) return false;
  49111. if (cp < 0xaa35) return true;
  49112. if (cp < 0xaa35) return false;
  49113. if (cp < 0xaa37) return true;
  49114. return false;
  49115. }
  49116. if (cp === 0xaa43) return true;
  49117. if (cp === 0xaa4c) return true;
  49118. if (cp === 0xaa4d) return true;
  49119. if (cp < 0xaa50) return false;
  49120. if (cp < 0xaa5a) return true;
  49121. if (cp === 0xaa7b) return true;
  49122. if (cp === 0xaa7c) return true;
  49123. if (cp === 0xaa7d) return true;
  49124. if (cp === 0xaab0) return true;
  49125. if (cp < 0xaab2) return false;
  49126. if (cp < 0xaab5) return true;
  49127. return false;
  49128. }
  49129. if (cp < 0x10d30) {
  49130. if (cp < 0xfe00) {
  49131. if (cp < 0xabe3) {
  49132. if (cp < 0xaab7) return false;
  49133. if (cp < 0xaab9) return true;
  49134. if (cp < 0xaabe) return false;
  49135. if (cp < 0xaac0) return true;
  49136. if (cp === 0xaac1) return true;
  49137. if (cp === 0xaaeb) return true;
  49138. if (cp < 0xaaec) return false;
  49139. if (cp < 0xaaee) return true;
  49140. if (cp < 0xaaee) return false;
  49141. if (cp < 0xaaf0) return true;
  49142. if (cp === 0xaaf5) return true;
  49143. if (cp === 0xaaf6) return true;
  49144. return false;
  49145. }
  49146. if (cp < 0xabe5) return true;
  49147. if (cp === 0xabe5) return true;
  49148. if (cp < 0xabe6) return false;
  49149. if (cp < 0xabe8) return true;
  49150. if (cp === 0xabe8) return true;
  49151. if (cp < 0xabe9) return false;
  49152. if (cp < 0xabeb) return true;
  49153. if (cp === 0xabec) return true;
  49154. if (cp === 0xabed) return true;
  49155. if (cp < 0xabf0) return false;
  49156. if (cp < 0xabfa) return true;
  49157. if (cp === 0xfb1e) return true;
  49158. return false;
  49159. }
  49160. if (cp < 0x10376) {
  49161. if (cp < 0xfe00) return false;
  49162. if (cp < 0xfe10) return true;
  49163. if (cp < 0xfe20) return false;
  49164. if (cp < 0xfe30) return true;
  49165. if (cp < 0xfe33) return false;
  49166. if (cp < 0xfe35) return true;
  49167. if (cp < 0xfe4d) return false;
  49168. if (cp < 0xfe50) return true;
  49169. if (cp < 0xff10) return false;
  49170. if (cp < 0xff1a) return true;
  49171. if (cp === 0xff3f) return true;
  49172. if (cp === 0x101fd) return true;
  49173. if (cp === 0x102e0) return true;
  49174. return false;
  49175. }
  49176. if (cp < 0x1037b) return true;
  49177. if (cp < 0x104a0) return false;
  49178. if (cp < 0x104aa) return true;
  49179. if (cp < 0x10a01) return false;
  49180. if (cp < 0x10a04) return true;
  49181. if (cp < 0x10a05) return false;
  49182. if (cp < 0x10a07) return true;
  49183. if (cp < 0x10a0c) return false;
  49184. if (cp < 0x10a10) return true;
  49185. if (cp < 0x10a38) return false;
  49186. if (cp < 0x10a3b) return true;
  49187. if (cp === 0x10a3f) return true;
  49188. if (cp < 0x10ae5) return false;
  49189. if (cp < 0x10ae7) return true;
  49190. if (cp < 0x10d24) return false;
  49191. if (cp < 0x10d28) return true;
  49192. return false;
  49193. }
  49194. if (cp < 0x1112d) {
  49195. if (cp < 0x11082) {
  49196. if (cp < 0x10d30) return false;
  49197. if (cp < 0x10d3a) return true;
  49198. if (cp < 0x10f46) return false;
  49199. if (cp < 0x10f51) return true;
  49200. if (cp === 0x11000) return true;
  49201. if (cp === 0x11001) return true;
  49202. if (cp === 0x11002) return true;
  49203. if (cp < 0x11038) return false;
  49204. if (cp < 0x11047) return true;
  49205. if (cp < 0x11066) return false;
  49206. if (cp < 0x11070) return true;
  49207. if (cp < 0x1107f) return false;
  49208. if (cp < 0x11082) return true;
  49209. return false;
  49210. }
  49211. if (cp === 0x11082) return true;
  49212. if (cp < 0x110b0) return false;
  49213. if (cp < 0x110b3) return true;
  49214. if (cp < 0x110b3) return false;
  49215. if (cp < 0x110b7) return true;
  49216. if (cp < 0x110b7) return false;
  49217. if (cp < 0x110b9) return true;
  49218. if (cp < 0x110b9) return false;
  49219. if (cp < 0x110bb) return true;
  49220. if (cp < 0x110f0) return false;
  49221. if (cp < 0x110fa) return true;
  49222. if (cp < 0x11100) return false;
  49223. if (cp < 0x11103) return true;
  49224. if (cp < 0x11127) return false;
  49225. if (cp < 0x1112c) return true;
  49226. if (cp === 0x1112c) return true;
  49227. return false;
  49228. }
  49229. if (cp < 0x111bf) {
  49230. if (cp < 0x1112d) return false;
  49231. if (cp < 0x11135) return true;
  49232. if (cp < 0x11136) return false;
  49233. if (cp < 0x11140) return true;
  49234. if (cp < 0x11145) return false;
  49235. if (cp < 0x11147) return true;
  49236. if (cp === 0x11173) return true;
  49237. if (cp < 0x11180) return false;
  49238. if (cp < 0x11182) return true;
  49239. if (cp === 0x11182) return true;
  49240. if (cp < 0x111b3) return false;
  49241. if (cp < 0x111b6) return true;
  49242. if (cp < 0x111b6) return false;
  49243. if (cp < 0x111bf) return true;
  49244. return false;
  49245. }
  49246. if (cp < 0x111c1) return true;
  49247. if (cp < 0x111c9) return false;
  49248. if (cp < 0x111cd) return true;
  49249. if (cp < 0x111d0) return false;
  49250. if (cp < 0x111da) return true;
  49251. if (cp < 0x1122c) return false;
  49252. if (cp < 0x1122f) return true;
  49253. if (cp < 0x1122f) return false;
  49254. if (cp < 0x11232) return true;
  49255. if (cp < 0x11232) return false;
  49256. if (cp < 0x11234) return true;
  49257. if (cp === 0x11234) return true;
  49258. if (cp === 0x11235) return true;
  49259. if (cp < 0x11236) return false;
  49260. if (cp < 0x11238) return true;
  49261. return false;
  49262. }
  49263. if (cp < 0x11a33) {
  49264. if (cp < 0x115af) {
  49265. if (cp < 0x11435) {
  49266. if (cp < 0x1133e) {
  49267. if (cp === 0x1123e) return true;
  49268. if (cp === 0x112df) return true;
  49269. if (cp < 0x112e0) return false;
  49270. if (cp < 0x112e3) return true;
  49271. if (cp < 0x112e3) return false;
  49272. if (cp < 0x112eb) return true;
  49273. if (cp < 0x112f0) return false;
  49274. if (cp < 0x112fa) return true;
  49275. if (cp < 0x11300) return false;
  49276. if (cp < 0x11302) return true;
  49277. if (cp < 0x11302) return false;
  49278. if (cp < 0x11304) return true;
  49279. if (cp < 0x1133b) return false;
  49280. if (cp < 0x1133d) return true;
  49281. return false;
  49282. }
  49283. if (cp < 0x11340) return true;
  49284. if (cp === 0x11340) return true;
  49285. if (cp < 0x11341) return false;
  49286. if (cp < 0x11345) return true;
  49287. if (cp < 0x11347) return false;
  49288. if (cp < 0x11349) return true;
  49289. if (cp < 0x1134b) return false;
  49290. if (cp < 0x1134e) return true;
  49291. if (cp === 0x11357) return true;
  49292. if (cp < 0x11362) return false;
  49293. if (cp < 0x11364) return true;
  49294. if (cp < 0x11366) return false;
  49295. if (cp < 0x1136d) return true;
  49296. if (cp < 0x11370) return false;
  49297. if (cp < 0x11375) return true;
  49298. return false;
  49299. }
  49300. if (cp < 0x114b0) {
  49301. if (cp < 0x11435) return false;
  49302. if (cp < 0x11438) return true;
  49303. if (cp < 0x11438) return false;
  49304. if (cp < 0x11440) return true;
  49305. if (cp < 0x11440) return false;
  49306. if (cp < 0x11442) return true;
  49307. if (cp < 0x11442) return false;
  49308. if (cp < 0x11445) return true;
  49309. if (cp === 0x11445) return true;
  49310. if (cp === 0x11446) return true;
  49311. if (cp < 0x11450) return false;
  49312. if (cp < 0x1145a) return true;
  49313. if (cp === 0x1145e) return true;
  49314. return false;
  49315. }
  49316. if (cp < 0x114b3) return true;
  49317. if (cp < 0x114b3) return false;
  49318. if (cp < 0x114b9) return true;
  49319. if (cp === 0x114b9) return true;
  49320. if (cp === 0x114ba) return true;
  49321. if (cp < 0x114bb) return false;
  49322. if (cp < 0x114bf) return true;
  49323. if (cp < 0x114bf) return false;
  49324. if (cp < 0x114c1) return true;
  49325. if (cp === 0x114c1) return true;
  49326. if (cp < 0x114c2) return false;
  49327. if (cp < 0x114c4) return true;
  49328. if (cp < 0x114d0) return false;
  49329. if (cp < 0x114da) return true;
  49330. return false;
  49331. }
  49332. if (cp < 0x116ae) {
  49333. if (cp < 0x11633) {
  49334. if (cp < 0x115af) return false;
  49335. if (cp < 0x115b2) return true;
  49336. if (cp < 0x115b2) return false;
  49337. if (cp < 0x115b6) return true;
  49338. if (cp < 0x115b8) return false;
  49339. if (cp < 0x115bc) return true;
  49340. if (cp < 0x115bc) return false;
  49341. if (cp < 0x115be) return true;
  49342. if (cp === 0x115be) return true;
  49343. if (cp < 0x115bf) return false;
  49344. if (cp < 0x115c1) return true;
  49345. if (cp < 0x115dc) return false;
  49346. if (cp < 0x115de) return true;
  49347. if (cp < 0x11630) return false;
  49348. if (cp < 0x11633) return true;
  49349. return false;
  49350. }
  49351. if (cp < 0x1163b) return true;
  49352. if (cp < 0x1163b) return false;
  49353. if (cp < 0x1163d) return true;
  49354. if (cp === 0x1163d) return true;
  49355. if (cp === 0x1163e) return true;
  49356. if (cp < 0x1163f) return false;
  49357. if (cp < 0x11641) return true;
  49358. if (cp < 0x11650) return false;
  49359. if (cp < 0x1165a) return true;
  49360. if (cp === 0x116ab) return true;
  49361. if (cp === 0x116ac) return true;
  49362. if (cp === 0x116ad) return true;
  49363. return false;
  49364. }
  49365. if (cp < 0x11726) {
  49366. if (cp < 0x116ae) return false;
  49367. if (cp < 0x116b0) return true;
  49368. if (cp < 0x116b0) return false;
  49369. if (cp < 0x116b6) return true;
  49370. if (cp === 0x116b6) return true;
  49371. if (cp === 0x116b7) return true;
  49372. if (cp < 0x116c0) return false;
  49373. if (cp < 0x116ca) return true;
  49374. if (cp < 0x1171d) return false;
  49375. if (cp < 0x11720) return true;
  49376. if (cp < 0x11720) return false;
  49377. if (cp < 0x11722) return true;
  49378. if (cp < 0x11722) return false;
  49379. if (cp < 0x11726) return true;
  49380. return false;
  49381. }
  49382. if (cp === 0x11726) return true;
  49383. if (cp < 0x11727) return false;
  49384. if (cp < 0x1172c) return true;
  49385. if (cp < 0x11730) return false;
  49386. if (cp < 0x1173a) return true;
  49387. if (cp < 0x1182c) return false;
  49388. if (cp < 0x1182f) return true;
  49389. if (cp < 0x1182f) return false;
  49390. if (cp < 0x11838) return true;
  49391. if (cp === 0x11838) return true;
  49392. if (cp < 0x11839) return false;
  49393. if (cp < 0x1183b) return true;
  49394. if (cp < 0x118e0) return false;
  49395. if (cp < 0x118ea) return true;
  49396. if (cp < 0x11a01) return false;
  49397. if (cp < 0x11a0b) return true;
  49398. return false;
  49399. }
  49400. if (cp < 0x11d97) {
  49401. if (cp < 0x11ca9) {
  49402. if (cp < 0x11a97) {
  49403. if (cp < 0x11a33) return false;
  49404. if (cp < 0x11a39) return true;
  49405. if (cp === 0x11a39) return true;
  49406. if (cp < 0x11a3b) return false;
  49407. if (cp < 0x11a3f) return true;
  49408. if (cp === 0x11a47) return true;
  49409. if (cp < 0x11a51) return false;
  49410. if (cp < 0x11a57) return true;
  49411. if (cp < 0x11a57) return false;
  49412. if (cp < 0x11a59) return true;
  49413. if (cp < 0x11a59) return false;
  49414. if (cp < 0x11a5c) return true;
  49415. if (cp < 0x11a8a) return false;
  49416. if (cp < 0x11a97) return true;
  49417. return false;
  49418. }
  49419. if (cp === 0x11a97) return true;
  49420. if (cp < 0x11a98) return false;
  49421. if (cp < 0x11a9a) return true;
  49422. if (cp === 0x11c2f) return true;
  49423. if (cp < 0x11c30) return false;
  49424. if (cp < 0x11c37) return true;
  49425. if (cp < 0x11c38) return false;
  49426. if (cp < 0x11c3e) return true;
  49427. if (cp === 0x11c3e) return true;
  49428. if (cp === 0x11c3f) return true;
  49429. if (cp < 0x11c50) return false;
  49430. if (cp < 0x11c5a) return true;
  49431. if (cp < 0x11c92) return false;
  49432. if (cp < 0x11ca8) return true;
  49433. return false;
  49434. }
  49435. if (cp < 0x11d3c) {
  49436. if (cp === 0x11ca9) return true;
  49437. if (cp < 0x11caa) return false;
  49438. if (cp < 0x11cb1) return true;
  49439. if (cp === 0x11cb1) return true;
  49440. if (cp < 0x11cb2) return false;
  49441. if (cp < 0x11cb4) return true;
  49442. if (cp === 0x11cb4) return true;
  49443. if (cp < 0x11cb5) return false;
  49444. if (cp < 0x11cb7) return true;
  49445. if (cp < 0x11d31) return false;
  49446. if (cp < 0x11d37) return true;
  49447. if (cp === 0x11d3a) return true;
  49448. return false;
  49449. }
  49450. if (cp < 0x11d3e) return true;
  49451. if (cp < 0x11d3f) return false;
  49452. if (cp < 0x11d46) return true;
  49453. if (cp === 0x11d47) return true;
  49454. if (cp < 0x11d50) return false;
  49455. if (cp < 0x11d5a) return true;
  49456. if (cp < 0x11d8a) return false;
  49457. if (cp < 0x11d8f) return true;
  49458. if (cp < 0x11d90) return false;
  49459. if (cp < 0x11d92) return true;
  49460. if (cp < 0x11d93) return false;
  49461. if (cp < 0x11d95) return true;
  49462. if (cp === 0x11d95) return true;
  49463. if (cp === 0x11d96) return true;
  49464. return false;
  49465. }
  49466. if (cp < 0x1d242) {
  49467. if (cp < 0x16f51) {
  49468. if (cp === 0x11d97) return true;
  49469. if (cp < 0x11da0) return false;
  49470. if (cp < 0x11daa) return true;
  49471. if (cp < 0x11ef3) return false;
  49472. if (cp < 0x11ef5) return true;
  49473. if (cp < 0x11ef5) return false;
  49474. if (cp < 0x11ef7) return true;
  49475. if (cp < 0x16a60) return false;
  49476. if (cp < 0x16a6a) return true;
  49477. if (cp < 0x16af0) return false;
  49478. if (cp < 0x16af5) return true;
  49479. if (cp < 0x16b30) return false;
  49480. if (cp < 0x16b37) return true;
  49481. if (cp < 0x16b50) return false;
  49482. if (cp < 0x16b5a) return true;
  49483. return false;
  49484. }
  49485. if (cp < 0x16f7f) return true;
  49486. if (cp < 0x16f8f) return false;
  49487. if (cp < 0x16f93) return true;
  49488. if (cp < 0x1bc9d) return false;
  49489. if (cp < 0x1bc9f) return true;
  49490. if (cp < 0x1d165) return false;
  49491. if (cp < 0x1d167) return true;
  49492. if (cp < 0x1d167) return false;
  49493. if (cp < 0x1d16a) return true;
  49494. if (cp < 0x1d16d) return false;
  49495. if (cp < 0x1d173) return true;
  49496. if (cp < 0x1d17b) return false;
  49497. if (cp < 0x1d183) return true;
  49498. if (cp < 0x1d185) return false;
  49499. if (cp < 0x1d18c) return true;
  49500. if (cp < 0x1d1aa) return false;
  49501. if (cp < 0x1d1ae) return true;
  49502. return false;
  49503. }
  49504. if (cp < 0x1e000) {
  49505. if (cp < 0x1d242) return false;
  49506. if (cp < 0x1d245) return true;
  49507. if (cp < 0x1d7ce) return false;
  49508. if (cp < 0x1d800) return true;
  49509. if (cp < 0x1da00) return false;
  49510. if (cp < 0x1da37) return true;
  49511. if (cp < 0x1da3b) return false;
  49512. if (cp < 0x1da6d) return true;
  49513. if (cp === 0x1da75) return true;
  49514. if (cp === 0x1da84) return true;
  49515. if (cp < 0x1da9b) return false;
  49516. if (cp < 0x1daa0) return true;
  49517. if (cp < 0x1daa1) return false;
  49518. if (cp < 0x1dab0) return true;
  49519. return false;
  49520. }
  49521. if (cp < 0x1e007) return true;
  49522. if (cp < 0x1e008) return false;
  49523. if (cp < 0x1e019) return true;
  49524. if (cp < 0x1e01b) return false;
  49525. if (cp < 0x1e022) return true;
  49526. if (cp < 0x1e023) return false;
  49527. if (cp < 0x1e025) return true;
  49528. if (cp < 0x1e026) return false;
  49529. if (cp < 0x1e02b) return true;
  49530. if (cp < 0x1e8d0) return false;
  49531. if (cp < 0x1e8d7) return true;
  49532. if (cp < 0x1e944) return false;
  49533. if (cp < 0x1e94b) return true;
  49534. if (cp < 0x1e950) return false;
  49535. if (cp < 0x1e95a) return true;
  49536. if (cp < 0xe0100) return false;
  49537. if (cp < 0xe01f0) return true;
  49538. return false;
  49539. }
  49540. var PropertyData = {
  49541. $LONE: new Set(["ASCII", "ASCII_Hex_Digit", "AHex", "Alphabetic", "Alpha", "Any", "Assigned", "Bidi_Control", "Bidi_C", "Bidi_Mirrored", "Bidi_M", "Case_Ignorable", "CI", "Cased", "Changes_When_Casefolded", "CWCF", "Changes_When_Casemapped", "CWCM", "Changes_When_Lowercased", "CWL", "Changes_When_NFKC_Casefolded", "CWKCF", "Changes_When_Titlecased", "CWT", "Changes_When_Uppercased", "CWU", "Dash", "Default_Ignorable_Code_Point", "DI", "Deprecated", "Dep", "Diacritic", "Dia", "Emoji", "Emoji_Component", "Emoji_Modifier", "Emoji_Modifier_Base", "Emoji_Presentation", "Extender", "Ext", "Grapheme_Base", "Gr_Base", "Grapheme_Extend", "Gr_Ext", "Hex_Digit", "Hex", "IDS_Binary_Operator", "IDSB", "IDS_Trinary_Operator", "IDST", "ID_Continue", "IDC", "ID_Start", "IDS", "Ideographic", "Ideo", "Join_Control", "Join_C", "Logical_Order_Exception", "LOE", "Lowercase", "Lower", "Math", "Noncharacter_Code_Point", "NChar", "Pattern_Syntax", "Pat_Syn", "Pattern_White_Space", "Pat_WS", "Quotation_Mark", "QMark", "Radical", "Regional_Indicator", "RI", "Sentence_Terminal", "STerm", "Soft_Dotted", "SD", "Terminal_Punctuation", "Term", "Unified_Ideograph", "UIdeo", "Uppercase", "Upper", "Variation_Selector", "VS", "White_Space", "space", "XID_Continue", "XIDC", "XID_Start", "XIDS"]),
  49542. General_Category: new Set(["Cased_Letter", "LC", "Close_Punctuation", "Pe", "Connector_Punctuation", "Pc", "Control", "Cc", "cntrl", "Currency_Symbol", "Sc", "Dash_Punctuation", "Pd", "Decimal_Number", "Nd", "digit", "Enclosing_Mark", "Me", "Final_Punctuation", "Pf", "Format", "Cf", "Initial_Punctuation", "Pi", "Letter", "L", "Letter_Number", "Nl", "Line_Separator", "Zl", "Lowercase_Letter", "Ll", "Mark", "M", "Combining_Mark", "Math_Symbol", "Sm", "Modifier_Letter", "Lm", "Modifier_Symbol", "Sk", "Nonspacing_Mark", "Mn", "Number", "N", "Open_Punctuation", "Ps", "Other", "C", "Other_Letter", "Lo", "Other_Number", "No", "Other_Punctuation", "Po", "Other_Symbol", "So", "Paragraph_Separator", "Zp", "Private_Use", "Co", "Punctuation", "P", "punct", "Separator", "Z", "Space_Separator", "Zs", "Spacing_Mark", "Mc", "Surrogate", "Cs", "Symbol", "S", "Titlecase_Letter", "Lt", "Unassigned", "Cn", "Uppercase_Letter", "Lu"]),
  49543. Script: new Set(["Adlam", "Adlm", "Ahom", "Anatolian_Hieroglyphs", "Hluw", "Arabic", "Arab", "Armenian", "Armn", "Avestan", "Avst", "Balinese", "Bali", "Bamum", "Bamu", "Bassa_Vah", "Bass", "Batak", "Batk", "Bengali", "Beng", "Bhaiksuki", "Bhks", "Bopomofo", "Bopo", "Brahmi", "Brah", "Braille", "Brai", "Buginese", "Bugi", "Buhid", "Buhd", "Canadian_Aboriginal", "Cans", "Carian", "Cari", "Caucasian_Albanian", "Aghb", "Chakma", "Cakm", "Cham", "Cherokee", "Cher", "Common", "Zyyy", "Coptic", "Copt", "Qaac", "Cuneiform", "Xsux", "Cypriot", "Cprt", "Cyrillic", "Cyrl", "Deseret", "Dsrt", "Devanagari", "Deva", "Duployan", "Dupl", "Egyptian_Hieroglyphs", "Egyp", "Elbasan", "Elba", "Ethiopic", "Ethi", "Georgian", "Geor", "Glagolitic", "Glag", "Gothic", "Goth", "Grantha", "Gran", "Greek", "Grek", "Gujarati", "Gujr", "Gurmukhi", "Guru", "Han", "Hani", "Hangul", "Hang", "Hanunoo", "Hano", "Hatran", "Hatr", "Hebrew", "Hebr", "Hiragana", "Hira", "Imperial_Aramaic", "Armi", "Inherited", "Zinh", "Qaai", "Inscriptional_Pahlavi", "Phli", "Inscriptional_Parthian", "Prti", "Javanese", "Java", "Kaithi", "Kthi", "Kannada", "Knda", "Katakana", "Kana", "Kayah_Li", "Kali", "Kharoshthi", "Khar", "Khmer", "Khmr", "Khojki", "Khoj", "Khudawadi", "Sind", "Lao", "Laoo", "Latin", "Latn", "Lepcha", "Lepc", "Limbu", "Limb", "Linear_A", "Lina", "Linear_B", "Linb", "Lisu", "Lycian", "Lyci", "Lydian", "Lydi", "Mahajani", "Mahj", "Malayalam", "Mlym", "Mandaic", "Mand", "Manichaean", "Mani", "Marchen", "Marc", "Masaram_Gondi", "Gonm", "Meetei_Mayek", "Mtei", "Mende_Kikakui", "Mend", "Meroitic_Cursive", "Merc", "Meroitic_Hieroglyphs", "Mero", "Miao", "Plrd", "Modi", "Mongolian", "Mong", "Mro", "Mroo", "Multani", "Mult", "Myanmar", "Mymr", "Nabataean", "Nbat", "New_Tai_Lue", "Talu", "Newa", "Nko", "Nkoo", "Nushu", "Nshu", "Ogham", "Ogam", "Ol_Chiki", "Olck", "Old_Hungarian", "Hung", "Old_Italic", "Ital", "Old_North_Arabian", "Narb", "Old_Permic", "Perm", "Old_Persian", "Xpeo", "Old_South_Arabian", "Sarb", "Old_Turkic", "Orkh", "Oriya", "Orya", "Osage", "Osge", "Osmanya", "Osma", "Pahawh_Hmong", "Hmng", "Palmyrene", "Palm", "Pau_Cin_Hau", "Pauc", "Phags_Pa", "Phag", "Phoenician", "Phnx", "Psalter_Pahlavi", "Phlp", "Rejang", "Rjng", "Runic", "Runr", "Samaritan", "Samr", "Saurashtra", "Saur", "Sharada", "Shrd", "Shavian", "Shaw", "Siddham", "Sidd", "SignWriting", "Sgnw", "Sinhala", "Sinh", "Sora_Sompeng", "Sora", "Soyombo", "Soyo", "Sundanese", "Sund", "Syloti_Nagri", "Sylo", "Syriac", "Syrc", "Tagalog", "Tglg", "Tagbanwa", "Tagb", "Tai_Le", "Tale", "Tai_Tham", "Lana", "Tai_Viet", "Tavt", "Takri", "Takr", "Tamil", "Taml", "Tangut", "Tang", "Telugu", "Telu", "Thaana", "Thaa", "Thai", "Tibetan", "Tibt", "Tifinagh", "Tfng", "Tirhuta", "Tirh", "Ugaritic", "Ugar", "Vai", "Vaii", "Warang_Citi", "Wara", "Yi", "Yiii", "Zanabazar_Square", "Zanb"])
  49544. };
  49545. PropertyData.gc = PropertyData.General_Category;
  49546. PropertyData.sc = PropertyData.Script_Extensions = PropertyData.scx = PropertyData.Script;
  49547. var Backspace = 0x08;
  49548. var CharacterTabulation = 0x09;
  49549. var LineFeed = 0x0a;
  49550. var LineTabulation = 0x0b;
  49551. var FormFeed = 0x0c;
  49552. var CarriageReturn = 0x0d;
  49553. var ExclamationMark = 0x21;
  49554. var DollarSign = 0x24;
  49555. var LeftParenthesis = 0x28;
  49556. var RightParenthesis = 0x29;
  49557. var Asterisk = 0x2a;
  49558. var PlusSign = 0x2b;
  49559. var Comma = 0x2c;
  49560. var HyphenMinus = 0x2d;
  49561. var FullStop = 0x2e;
  49562. var Solidus = 0x2f;
  49563. var DigitZero = 0x30;
  49564. var DigitOne = 0x31;
  49565. var DigitSeven = 0x37;
  49566. var DigitNine = 0x39;
  49567. var Colon = 0x3a;
  49568. var LessThanSign = 0x3c;
  49569. var EqualsSign = 0x3d;
  49570. var GreaterThanSign = 0x3e;
  49571. var QuestionMark = 0x3f;
  49572. var LatinCapitalLetterA = 0x41;
  49573. var LatinCapitalLetterB = 0x42;
  49574. var LatinCapitalLetterD = 0x44;
  49575. var LatinCapitalLetterF = 0x46;
  49576. var LatinCapitalLetterP = 0x50;
  49577. var LatinCapitalLetterS = 0x53;
  49578. var LatinCapitalLetterW = 0x57;
  49579. var LatinCapitalLetterZ = 0x5a;
  49580. var LowLine = 0x5f;
  49581. var LatinSmallLetterA = 0x61;
  49582. var LatinSmallLetterB = 0x62;
  49583. var LatinSmallLetterC = 0x63;
  49584. var LatinSmallLetterD = 0x64;
  49585. var LatinSmallLetterF = 0x66;
  49586. var LatinSmallLetterG = 0x67;
  49587. var LatinSmallLetterI = 0x69;
  49588. var LatinSmallLetterK = 0x6b;
  49589. var LatinSmallLetterM = 0x6d;
  49590. var LatinSmallLetterN = 0x6e;
  49591. var LatinSmallLetterP = 0x70;
  49592. var LatinSmallLetterR = 0x72;
  49593. var LatinSmallLetterS = 0x73;
  49594. var LatinSmallLetterT = 0x74;
  49595. var LatinSmallLetterU = 0x75;
  49596. var LatinSmallLetterV = 0x76;
  49597. var LatinSmallLetterW = 0x77;
  49598. var LatinSmallLetterX = 0x78;
  49599. var LatinSmallLetterY = 0x79;
  49600. var LatinSmallLetterZ = 0x7a;
  49601. var LeftSquareBracket = 0x5b;
  49602. var ReverseSolidus = 0x5c;
  49603. var RightSquareBracket = 0x5d;
  49604. var CircumflexAccent = 0x5e;
  49605. var LeftCurlyBracket = 0x7b;
  49606. var VerticalLine = 0x7c;
  49607. var RightCurlyBracket = 0x7d;
  49608. var ZeroWidthNonJoiner = 0x200c;
  49609. var ZeroWidthJoiner = 0x200d;
  49610. var LineSeparator = 0x2028;
  49611. var ParagraphSeparator = 0x2029;
  49612. var MinCodePoint = 0x00;
  49613. var MaxCodePoint = 0x10ffff;
  49614. function isLatinLetter(code) {
  49615. return code >= LatinCapitalLetterA && code <= LatinCapitalLetterZ || code >= LatinSmallLetterA && code <= LatinSmallLetterZ;
  49616. }
  49617. function isDecimalDigit(code) {
  49618. return code >= DigitZero && code <= DigitNine;
  49619. }
  49620. function isOctalDigit(code) {
  49621. return code >= DigitZero && code <= DigitSeven;
  49622. }
  49623. function isHexDigit(code) {
  49624. return code >= DigitZero && code <= DigitNine || code >= LatinCapitalLetterA && code <= LatinCapitalLetterF || code >= LatinSmallLetterA && code <= LatinSmallLetterF;
  49625. }
  49626. function isLineTerminator(code) {
  49627. return code === LineFeed || code === CarriageReturn || code === LineSeparator || code === ParagraphSeparator;
  49628. }
  49629. function isValidUnicode(code) {
  49630. return code >= MinCodePoint && code <= MaxCodePoint;
  49631. }
  49632. function digitToInt(code) {
  49633. if (code >= LatinSmallLetterA && code <= LatinSmallLetterF) {
  49634. return code - LatinSmallLetterA + 10;
  49635. }
  49636. if (code >= LatinCapitalLetterA && code <= LatinCapitalLetterF) {
  49637. return code - LatinCapitalLetterA + 10;
  49638. }
  49639. return code - DigitZero;
  49640. }
  49641. var legacyImpl = {
  49642. at: function at(s, end, i) {
  49643. return i < end ? s.charCodeAt(i) : -1;
  49644. },
  49645. width: function width(c) {
  49646. return 1;
  49647. }
  49648. };
  49649. var unicodeImpl = {
  49650. at: function at(s, end, i) {
  49651. return i < end ? s.codePointAt(i) : -1;
  49652. },
  49653. width: function width(c) {
  49654. return c > 0xffff ? 2 : 1;
  49655. }
  49656. };
  49657. var Reader = function () {
  49658. function Reader() {
  49659. _classCallCheck(this, Reader);
  49660. this._impl = legacyImpl;
  49661. this._s = "";
  49662. this._i = 0;
  49663. this._end = 0;
  49664. this._cp1 = -1;
  49665. this._w1 = 1;
  49666. this._cp2 = -1;
  49667. this._w2 = 1;
  49668. this._cp3 = -1;
  49669. this._w3 = 1;
  49670. this._cp4 = -1;
  49671. }
  49672. _createClass(Reader, [{
  49673. key: 'reset',
  49674. value: function reset(source, start, end, uFlag) {
  49675. this._impl = uFlag ? unicodeImpl : legacyImpl;
  49676. this._s = source;
  49677. this._end = end;
  49678. this.rewind(start);
  49679. }
  49680. }, {
  49681. key: 'rewind',
  49682. value: function rewind(index) {
  49683. var impl = this._impl;
  49684. this._i = index;
  49685. this._cp1 = impl.at(this._s, this._end, index);
  49686. this._w1 = impl.width(this._cp1);
  49687. this._cp2 = impl.at(this._s, this._end, index + this._w1);
  49688. this._w2 = impl.width(this._cp2);
  49689. this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2);
  49690. this._w3 = impl.width(this._cp3);
  49691. this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3);
  49692. }
  49693. }, {
  49694. key: 'advance',
  49695. value: function advance() {
  49696. if (this._cp1 !== -1) {
  49697. var impl = this._impl;
  49698. this._i += this._w1;
  49699. this._cp1 = this._cp2;
  49700. this._w1 = this._w2;
  49701. this._cp2 = this._cp3;
  49702. this._w2 = impl.width(this._cp2);
  49703. this._cp3 = this._cp4;
  49704. this._w3 = impl.width(this._cp3);
  49705. this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3);
  49706. }
  49707. }
  49708. }, {
  49709. key: 'eat',
  49710. value: function eat(cp) {
  49711. if (this._cp1 === cp) {
  49712. this.advance();
  49713. return true;
  49714. }
  49715. return false;
  49716. }
  49717. }, {
  49718. key: 'eat2',
  49719. value: function eat2(cp1, cp2) {
  49720. if (this._cp1 === cp1 && this._cp2 === cp2) {
  49721. this.advance();
  49722. this.advance();
  49723. return true;
  49724. }
  49725. return false;
  49726. }
  49727. }, {
  49728. key: 'eat3',
  49729. value: function eat3(cp1, cp2, cp3) {
  49730. if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) {
  49731. this.advance();
  49732. this.advance();
  49733. this.advance();
  49734. return true;
  49735. }
  49736. return false;
  49737. }
  49738. }, {
  49739. key: 'source',
  49740. get: function get() {
  49741. return this._s;
  49742. }
  49743. }, {
  49744. key: 'index',
  49745. get: function get() {
  49746. return this._i;
  49747. }
  49748. }, {
  49749. key: 'currentCodePoint',
  49750. get: function get() {
  49751. return this._cp1;
  49752. }
  49753. }, {
  49754. key: 'nextCodePoint',
  49755. get: function get() {
  49756. return this._cp2;
  49757. }
  49758. }, {
  49759. key: 'nextCodePoint2',
  49760. get: function get() {
  49761. return this._cp3;
  49762. }
  49763. }, {
  49764. key: 'nextCodePoint3',
  49765. get: function get() {
  49766. return this._cp4;
  49767. }
  49768. }]);
  49769. return Reader;
  49770. }();
  49771. var RegExpSyntaxError = function (_SyntaxError) {
  49772. _inherits(RegExpSyntaxError, _SyntaxError);
  49773. function RegExpSyntaxError(source, uFlag, index, message) {
  49774. _classCallCheck(this, RegExpSyntaxError);
  49775. if (source) {
  49776. if (source[0] !== "/") {
  49777. source = '/' + source + '/' + (uFlag ? "u" : "");
  49778. }
  49779. source = ': ' + source;
  49780. }
  49781. var _this = _possibleConstructorReturn(this, (RegExpSyntaxError.__proto__ || Object.getPrototypeOf(RegExpSyntaxError)).call(this, 'Invalid regular expression' + source + ': ' + message));
  49782. _this.index = index;
  49783. return _this;
  49784. }
  49785. return RegExpSyntaxError;
  49786. }(SyntaxError);
  49787. function isSyntaxCharacter(cp) {
  49788. return cp === CircumflexAccent || cp === DollarSign || cp === ReverseSolidus || cp === FullStop || cp === Asterisk || cp === PlusSign || cp === QuestionMark || cp === LeftParenthesis || cp === RightParenthesis || cp === LeftSquareBracket || cp === RightSquareBracket || cp === LeftCurlyBracket || cp === RightCurlyBracket || cp === VerticalLine;
  49789. }
  49790. function isRegExpIdentifierStart(cp) {
  49791. return isIdStart(cp) || cp === DollarSign || cp === LowLine;
  49792. }
  49793. function isRegExpIdentifierPart(cp) {
  49794. return isIdContinue(cp) || cp === DollarSign || cp === LowLine || cp === ZeroWidthNonJoiner || cp === ZeroWidthJoiner;
  49795. }
  49796. function isUnicodePropertyNameCharacter(cp) {
  49797. return isLatinLetter(cp) || cp === LowLine;
  49798. }
  49799. function isUnicodePropertyValueCharacter(cp) {
  49800. return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp);
  49801. }
  49802. function isValidUnicodeProperty(name, value) {
  49803. return PropertyData.hasOwnProperty(name) && PropertyData[name].has(value);
  49804. }
  49805. function isValidUnicodePropertyName(name) {
  49806. return PropertyData.$LONE.has(name);
  49807. }
  49808. var RegExpValidator = function () {
  49809. function RegExpValidator(options) {
  49810. _classCallCheck(this, RegExpValidator);
  49811. this._reader = new Reader();
  49812. this._uFlag = false;
  49813. this._nFlag = false;
  49814. this._lastIntValue = 0;
  49815. this._lastMinValue = 0;
  49816. this._lastMaxValue = 0;
  49817. this._lastStrValue = "";
  49818. this._lastKeyValue = "";
  49819. this._lastValValue = "";
  49820. this._lastAssertionIsQuantifiable = false;
  49821. this._numCapturingParens = 0;
  49822. this._groupNames = new Set();
  49823. this._backreferenceNames = new Set();
  49824. this._options = options || {};
  49825. }
  49826. _createClass(RegExpValidator, [{
  49827. key: 'validateLiteral',
  49828. value: function validateLiteral(source) {
  49829. var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  49830. var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
  49831. this._uFlag = this._nFlag = false;
  49832. this.reset(source, start, end);
  49833. this.onLiteralEnter(start);
  49834. if (this.eat(Solidus) && this.eatRegExpBody() && this.eat(Solidus)) {
  49835. var flagStart = this.index;
  49836. var uFlag = source.indexOf("u", flagStart) !== -1;
  49837. this.validateFlags(source, flagStart, end);
  49838. this.validatePattern(source, start + 1, flagStart - 1, uFlag);
  49839. } else if (start >= end) {
  49840. this.raise("Empty");
  49841. } else {
  49842. var c = String.fromCodePoint(this.currentCodePoint);
  49843. this.raise('Unexpected character \'' + c + '\'');
  49844. }
  49845. this.onLiteralLeave(start, end);
  49846. }
  49847. }, {
  49848. key: 'validateFlags',
  49849. value: function validateFlags(source) {
  49850. var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  49851. var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
  49852. var existingFlags = new Set();
  49853. var global = false;
  49854. var ignoreCase = false;
  49855. var multiline = false;
  49856. var sticky = false;
  49857. var unicode = false;
  49858. var dotAll = false;
  49859. for (var i = start; i < end; ++i) {
  49860. var flag = source.charCodeAt(i);
  49861. if (existingFlags.has(flag)) {
  49862. this.raise('Duplicated flag \'' + source[i] + '\'');
  49863. }
  49864. existingFlags.add(flag);
  49865. if (flag === LatinSmallLetterG) {
  49866. global = true;
  49867. } else if (flag === LatinSmallLetterI) {
  49868. ignoreCase = true;
  49869. } else if (flag === LatinSmallLetterM) {
  49870. multiline = true;
  49871. } else if (flag === LatinSmallLetterU && this.ecmaVersion >= 2015) {
  49872. unicode = true;
  49873. } else if (flag === LatinSmallLetterY && this.ecmaVersion >= 2015) {
  49874. sticky = true;
  49875. } else if (flag === LatinSmallLetterS && this.ecmaVersion >= 2018) {
  49876. dotAll = true;
  49877. } else {
  49878. this.raise('Invalid flag \'' + source[i] + '\'');
  49879. }
  49880. }
  49881. this.onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll);
  49882. }
  49883. }, {
  49884. key: 'validatePattern',
  49885. value: function validatePattern(source) {
  49886. var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  49887. var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
  49888. var uFlag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  49889. this._uFlag = uFlag && this.ecmaVersion >= 2015;
  49890. this._nFlag = uFlag && this.ecmaVersion >= 2018;
  49891. this.reset(source, start, end);
  49892. this.pattern();
  49893. if (!this._nFlag && this.ecmaVersion >= 2018 && this._groupNames.size > 0) {
  49894. this._nFlag = true;
  49895. this.rewind(start);
  49896. this.pattern();
  49897. }
  49898. }
  49899. }, {
  49900. key: 'onLiteralEnter',
  49901. value: function onLiteralEnter(start) {
  49902. if (this._options.onLiteralEnter) {
  49903. this._options.onLiteralEnter(start);
  49904. }
  49905. }
  49906. }, {
  49907. key: 'onLiteralLeave',
  49908. value: function onLiteralLeave(start, end) {
  49909. if (this._options.onLiteralLeave) {
  49910. this._options.onLiteralLeave(start, end);
  49911. }
  49912. }
  49913. }, {
  49914. key: 'onFlags',
  49915. value: function onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll) {
  49916. if (this._options.onFlags) {
  49917. this._options.onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll);
  49918. }
  49919. }
  49920. }, {
  49921. key: 'onPatternEnter',
  49922. value: function onPatternEnter(start) {
  49923. if (this._options.onPatternEnter) {
  49924. this._options.onPatternEnter(start);
  49925. }
  49926. }
  49927. }, {
  49928. key: 'onPatternLeave',
  49929. value: function onPatternLeave(start, end) {
  49930. if (this._options.onPatternLeave) {
  49931. this._options.onPatternLeave(start, end);
  49932. }
  49933. }
  49934. }, {
  49935. key: 'onDisjunctionEnter',
  49936. value: function onDisjunctionEnter(start) {
  49937. if (this._options.onDisjunctionEnter) {
  49938. this._options.onDisjunctionEnter(start);
  49939. }
  49940. }
  49941. }, {
  49942. key: 'onDisjunctionLeave',
  49943. value: function onDisjunctionLeave(start, end) {
  49944. if (this._options.onDisjunctionLeave) {
  49945. this._options.onDisjunctionLeave(start, end);
  49946. }
  49947. }
  49948. }, {
  49949. key: 'onAlternativeEnter',
  49950. value: function onAlternativeEnter(start, index) {
  49951. if (this._options.onAlternativeEnter) {
  49952. this._options.onAlternativeEnter(start, index);
  49953. }
  49954. }
  49955. }, {
  49956. key: 'onAlternativeLeave',
  49957. value: function onAlternativeLeave(start, end, index) {
  49958. if (this._options.onAlternativeLeave) {
  49959. this._options.onAlternativeLeave(start, end, index);
  49960. }
  49961. }
  49962. }, {
  49963. key: 'onGroupEnter',
  49964. value: function onGroupEnter(start) {
  49965. if (this._options.onGroupEnter) {
  49966. this._options.onGroupEnter(start);
  49967. }
  49968. }
  49969. }, {
  49970. key: 'onGroupLeave',
  49971. value: function onGroupLeave(start, end) {
  49972. if (this._options.onGroupLeave) {
  49973. this._options.onGroupLeave(start, end);
  49974. }
  49975. }
  49976. }, {
  49977. key: 'onCapturingGroupEnter',
  49978. value: function onCapturingGroupEnter(start, name) {
  49979. if (this._options.onCapturingGroupEnter) {
  49980. this._options.onCapturingGroupEnter(start, name);
  49981. }
  49982. }
  49983. }, {
  49984. key: 'onCapturingGroupLeave',
  49985. value: function onCapturingGroupLeave(start, end, name) {
  49986. if (this._options.onCapturingGroupLeave) {
  49987. this._options.onCapturingGroupLeave(start, end, name);
  49988. }
  49989. }
  49990. }, {
  49991. key: 'onQuantifier',
  49992. value: function onQuantifier(start, end, min, max, greedy) {
  49993. if (this._options.onQuantifier) {
  49994. this._options.onQuantifier(start, end, min, max, greedy);
  49995. }
  49996. }
  49997. }, {
  49998. key: 'onLookaroundAssertionEnter',
  49999. value: function onLookaroundAssertionEnter(start, kind, negate) {
  50000. if (this._options.onLookaroundAssertionEnter) {
  50001. this._options.onLookaroundAssertionEnter(start, kind, negate);
  50002. }
  50003. }
  50004. }, {
  50005. key: 'onLookaroundAssertionLeave',
  50006. value: function onLookaroundAssertionLeave(start, end, kind, negate) {
  50007. if (this._options.onLookaroundAssertionLeave) {
  50008. this._options.onLookaroundAssertionLeave(start, end, kind, negate);
  50009. }
  50010. }
  50011. }, {
  50012. key: 'onEdgeAssertion',
  50013. value: function onEdgeAssertion(start, end, kind) {
  50014. if (this._options.onEdgeAssertion) {
  50015. this._options.onEdgeAssertion(start, end, kind);
  50016. }
  50017. }
  50018. }, {
  50019. key: 'onWordBoundaryAssertion',
  50020. value: function onWordBoundaryAssertion(start, end, kind, negate) {
  50021. if (this._options.onWordBoundaryAssertion) {
  50022. this._options.onWordBoundaryAssertion(start, end, kind, negate);
  50023. }
  50024. }
  50025. }, {
  50026. key: 'onAnyCharacterSet',
  50027. value: function onAnyCharacterSet(start, end, kind) {
  50028. if (this._options.onAnyCharacterSet) {
  50029. this._options.onAnyCharacterSet(start, end, kind);
  50030. }
  50031. }
  50032. }, {
  50033. key: 'onEscapeCharacterSet',
  50034. value: function onEscapeCharacterSet(start, end, kind, negate) {
  50035. if (this._options.onEscapeCharacterSet) {
  50036. this._options.onEscapeCharacterSet(start, end, kind, negate);
  50037. }
  50038. }
  50039. }, {
  50040. key: 'onUnicodePropertyCharacterSet',
  50041. value: function onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
  50042. if (this._options.onUnicodePropertyCharacterSet) {
  50043. this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate);
  50044. }
  50045. }
  50046. }, {
  50047. key: 'onCharacter',
  50048. value: function onCharacter(start, end, value) {
  50049. if (this._options.onCharacter) {
  50050. this._options.onCharacter(start, end, value);
  50051. }
  50052. }
  50053. }, {
  50054. key: 'onBackreference',
  50055. value: function onBackreference(start, end, ref) {
  50056. if (this._options.onBackreference) {
  50057. this._options.onBackreference(start, end, ref);
  50058. }
  50059. }
  50060. }, {
  50061. key: 'onCharacterClassEnter',
  50062. value: function onCharacterClassEnter(start, negate) {
  50063. if (this._options.onCharacterClassEnter) {
  50064. this._options.onCharacterClassEnter(start, negate);
  50065. }
  50066. }
  50067. }, {
  50068. key: 'onCharacterClassLeave',
  50069. value: function onCharacterClassLeave(start, end, negate) {
  50070. if (this._options.onCharacterClassLeave) {
  50071. this._options.onCharacterClassLeave(start, end, negate);
  50072. }
  50073. }
  50074. }, {
  50075. key: 'onCharacterClassRange',
  50076. value: function onCharacterClassRange(start, end, min, max) {
  50077. if (this._options.onCharacterClassRange) {
  50078. this._options.onCharacterClassRange(start, end, min, max);
  50079. }
  50080. }
  50081. }, {
  50082. key: 'reset',
  50083. value: function reset(source, start, end) {
  50084. this._reader.reset(source, start, end, this._uFlag);
  50085. }
  50086. }, {
  50087. key: 'rewind',
  50088. value: function rewind(index) {
  50089. this._reader.rewind(index);
  50090. }
  50091. }, {
  50092. key: 'advance',
  50093. value: function advance() {
  50094. this._reader.advance();
  50095. }
  50096. }, {
  50097. key: 'eat',
  50098. value: function eat(cp) {
  50099. return this._reader.eat(cp);
  50100. }
  50101. }, {
  50102. key: 'eat2',
  50103. value: function eat2(cp1, cp2) {
  50104. return this._reader.eat2(cp1, cp2);
  50105. }
  50106. }, {
  50107. key: 'eat3',
  50108. value: function eat3(cp1, cp2, cp3) {
  50109. return this._reader.eat3(cp1, cp2, cp3);
  50110. }
  50111. }, {
  50112. key: 'raise',
  50113. value: function raise(message) {
  50114. throw new RegExpSyntaxError(this.source, this._uFlag, this.index, message);
  50115. }
  50116. }, {
  50117. key: 'eatRegExpBody',
  50118. value: function eatRegExpBody() {
  50119. var start = this.index;
  50120. var inClass = false;
  50121. var escaped = false;
  50122. for (;;) {
  50123. var cp = this.currentCodePoint;
  50124. if (cp === -1 || isLineTerminator(cp)) {
  50125. var kind = inClass ? "character class" : "regular expression";
  50126. this.raise('Unterminated ' + kind);
  50127. }
  50128. if (escaped) {
  50129. escaped = false;
  50130. } else if (cp === ReverseSolidus) {
  50131. escaped = true;
  50132. } else if (cp === LeftSquareBracket) {
  50133. inClass = true;
  50134. } else if (cp === RightSquareBracket) {
  50135. inClass = false;
  50136. } else if (cp === Solidus && !inClass || cp === Asterisk && this.index === start) {
  50137. break;
  50138. }
  50139. this.advance();
  50140. }
  50141. return this.index !== start;
  50142. }
  50143. }, {
  50144. key: 'pattern',
  50145. value: function pattern() {
  50146. var start = this.index;
  50147. this._numCapturingParens = this.countCapturingParens();
  50148. this._groupNames.clear();
  50149. this._backreferenceNames.clear();
  50150. this.onPatternEnter(start);
  50151. this.disjunction();
  50152. var cp = this.currentCodePoint;
  50153. if (this.currentCodePoint !== -1) {
  50154. if (cp === RightParenthesis) {
  50155. this.raise("Unmatched ')'");
  50156. }
  50157. if (cp === ReverseSolidus) {
  50158. this.raise("\\ at end of pattern");
  50159. }
  50160. if (cp === RightSquareBracket || cp === RightCurlyBracket) {
  50161. this.raise("Lone quantifier brackets");
  50162. }
  50163. var c = String.fromCodePoint(cp);
  50164. this.raise('Unexpected character \'' + c + '\'');
  50165. }
  50166. var _iteratorNormalCompletion = true;
  50167. var _didIteratorError = false;
  50168. var _iteratorError = undefined;
  50169. try {
  50170. for (var _iterator = this._backreferenceNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  50171. var name = _step.value;
  50172. if (!this._groupNames.has(name)) {
  50173. this.raise("Invalid named capture referenced");
  50174. }
  50175. }
  50176. } catch (err) {
  50177. _didIteratorError = true;
  50178. _iteratorError = err;
  50179. } finally {
  50180. try {
  50181. if (!_iteratorNormalCompletion && _iterator.return) {
  50182. _iterator.return();
  50183. }
  50184. } finally {
  50185. if (_didIteratorError) {
  50186. throw _iteratorError;
  50187. }
  50188. }
  50189. }
  50190. this.onPatternLeave(start, this.index);
  50191. }
  50192. }, {
  50193. key: 'countCapturingParens',
  50194. value: function countCapturingParens() {
  50195. var start = this.index;
  50196. var inClass = false;
  50197. var escaped = false;
  50198. var count = 0;
  50199. var cp = 0;
  50200. while ((cp = this.currentCodePoint) !== -1) {
  50201. if (escaped) {
  50202. escaped = false;
  50203. } else if (cp === ReverseSolidus) {
  50204. escaped = true;
  50205. } else if (cp === LeftSquareBracket) {
  50206. inClass = true;
  50207. } else if (cp === RightSquareBracket) {
  50208. inClass = false;
  50209. } else if (cp === LeftParenthesis && !inClass && (this.nextCodePoint !== QuestionMark || this.nextCodePoint2 === LessThanSign && this.nextCodePoint3 !== EqualsSign && this.nextCodePoint3 !== ExclamationMark)) {
  50210. count += 1;
  50211. }
  50212. this.advance();
  50213. }
  50214. this.rewind(start);
  50215. return count;
  50216. }
  50217. }, {
  50218. key: 'disjunction',
  50219. value: function disjunction() {
  50220. var start = this.index;
  50221. var i = 0;
  50222. this.onDisjunctionEnter(start);
  50223. this.alternative(i++);
  50224. while (this.eat(VerticalLine)) {
  50225. this.alternative(i++);
  50226. }
  50227. if (this.eatQuantifier(true)) {
  50228. this.raise("Nothing to repeat");
  50229. }
  50230. if (this.eat(LeftCurlyBracket)) {
  50231. this.raise("Lone quantifier brackets");
  50232. }
  50233. this.onDisjunctionLeave(start, this.index);
  50234. }
  50235. }, {
  50236. key: 'alternative',
  50237. value: function alternative(i) {
  50238. var start = this.index;
  50239. this.onAlternativeEnter(start, i);
  50240. while (this.currentCodePoint !== -1 && this.eatTerm()) {}
  50241. this.onAlternativeLeave(start, this.index, i);
  50242. }
  50243. }, {
  50244. key: 'eatTerm',
  50245. value: function eatTerm() {
  50246. if (this.eatAssertion()) {
  50247. if (this._lastAssertionIsQuantifiable) {
  50248. this.eatQuantifier();
  50249. }
  50250. return true;
  50251. }
  50252. if (this.strict ? this.eatAtom() : this.eatExtendedAtom()) {
  50253. this.eatQuantifier();
  50254. return true;
  50255. }
  50256. return false;
  50257. }
  50258. }, {
  50259. key: 'eatAssertion',
  50260. value: function eatAssertion() {
  50261. var start = this.index;
  50262. this._lastAssertionIsQuantifiable = false;
  50263. if (this.eat(CircumflexAccent)) {
  50264. this.onEdgeAssertion(start, this.index, "start");
  50265. return true;
  50266. }
  50267. if (this.eat(DollarSign)) {
  50268. this.onEdgeAssertion(start, this.index, "end");
  50269. return true;
  50270. }
  50271. if (this.eat2(ReverseSolidus, LatinCapitalLetterB)) {
  50272. this.onWordBoundaryAssertion(start, this.index, "word", true);
  50273. return true;
  50274. }
  50275. if (this.eat2(ReverseSolidus, LatinSmallLetterB)) {
  50276. this.onWordBoundaryAssertion(start, this.index, "word", false);
  50277. return true;
  50278. }
  50279. if (this.eat2(LeftParenthesis, QuestionMark)) {
  50280. var lookbehind = this.ecmaVersion >= 2018 && this.eat(LessThanSign);
  50281. var negate = false;
  50282. if (this.eat(EqualsSign) || (negate = this.eat(ExclamationMark))) {
  50283. var kind = lookbehind ? "lookbehind" : "lookahead";
  50284. this.onLookaroundAssertionEnter(start, kind, negate);
  50285. this.disjunction();
  50286. if (!this.eat(RightParenthesis)) {
  50287. this.raise("Unterminated group");
  50288. }
  50289. this._lastAssertionIsQuantifiable = !lookbehind && !this.strict;
  50290. this.onLookaroundAssertionLeave(start, this.index, kind, negate);
  50291. return true;
  50292. }
  50293. this.rewind(start);
  50294. }
  50295. return false;
  50296. }
  50297. }, {
  50298. key: 'eatQuantifier',
  50299. value: function eatQuantifier() {
  50300. var noError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  50301. var start = this.index;
  50302. var min = 0;
  50303. var max = 0;
  50304. var greedy = false;
  50305. if (this.eat(Asterisk)) {
  50306. min = 0;
  50307. max = Number.POSITIVE_INFINITY;
  50308. } else if (this.eat(PlusSign)) {
  50309. min = 1;
  50310. max = Number.POSITIVE_INFINITY;
  50311. } else if (this.eat(QuestionMark)) {
  50312. min = 0;
  50313. max = 1;
  50314. } else if (this.eatBracedQuantifier(noError)) {
  50315. min = this._lastMinValue;
  50316. max = this._lastMaxValue;
  50317. } else {
  50318. return false;
  50319. }
  50320. greedy = !this.eat(QuestionMark);
  50321. if (!noError) {
  50322. this.onQuantifier(start, this.index, min, max, greedy);
  50323. }
  50324. return true;
  50325. }
  50326. }, {
  50327. key: 'eatBracedQuantifier',
  50328. value: function eatBracedQuantifier(noError) {
  50329. var start = this.index;
  50330. if (this.eat(LeftCurlyBracket)) {
  50331. this._lastMinValue = 0;
  50332. this._lastMaxValue = Number.POSITIVE_INFINITY;
  50333. if (this.eatDecimalDigits()) {
  50334. this._lastMinValue = this._lastMaxValue = this._lastIntValue;
  50335. if (this.eat(Comma)) {
  50336. this._lastMaxValue = this.eatDecimalDigits() ? this._lastIntValue : Number.POSITIVE_INFINITY;
  50337. }
  50338. if (this.eat(RightCurlyBracket)) {
  50339. if (!noError && this._lastMaxValue < this._lastMinValue) {
  50340. this.raise("numbers out of order in {} quantifier");
  50341. }
  50342. return true;
  50343. }
  50344. }
  50345. if (!noError && this.strict) {
  50346. this.raise("Incomplete quantifier");
  50347. }
  50348. this.rewind(start);
  50349. }
  50350. return false;
  50351. }
  50352. }, {
  50353. key: 'eatAtom',
  50354. value: function eatAtom() {
  50355. return this.eatPatternCharacter() || this.eatDot() || this.eatReverseSolidusAtomEscape() || this.eatCharacterClass() || this.eatUncapturingGroup() || this.eatCapturingGroup();
  50356. }
  50357. }, {
  50358. key: 'eatDot',
  50359. value: function eatDot() {
  50360. if (this.eat(FullStop)) {
  50361. this.onAnyCharacterSet(this.index - 1, this.index, "any");
  50362. return true;
  50363. }
  50364. return false;
  50365. }
  50366. }, {
  50367. key: 'eatReverseSolidusAtomEscape',
  50368. value: function eatReverseSolidusAtomEscape() {
  50369. var start = this.index;
  50370. if (this.eat(ReverseSolidus)) {
  50371. if (this.eatAtomEscape()) {
  50372. return true;
  50373. }
  50374. this.rewind(start);
  50375. }
  50376. return false;
  50377. }
  50378. }, {
  50379. key: 'eatUncapturingGroup',
  50380. value: function eatUncapturingGroup() {
  50381. var start = this.index;
  50382. if (this.eat3(LeftParenthesis, QuestionMark, Colon)) {
  50383. this.onGroupEnter(start);
  50384. this.disjunction();
  50385. if (!this.eat(RightParenthesis)) {
  50386. this.raise("Unterminated group");
  50387. }
  50388. this.onGroupLeave(start, this.index);
  50389. return true;
  50390. }
  50391. return false;
  50392. }
  50393. }, {
  50394. key: 'eatCapturingGroup',
  50395. value: function eatCapturingGroup() {
  50396. var start = this.index;
  50397. if (this.eat(LeftParenthesis)) {
  50398. this._lastStrValue = "";
  50399. if (this.ecmaVersion >= 2018) {
  50400. this.groupSpecifier();
  50401. } else if (this.currentCodePoint === QuestionMark) {
  50402. this.raise("Invalid group");
  50403. }
  50404. var name = this._lastStrValue || null;
  50405. this.onCapturingGroupEnter(start, name);
  50406. this.disjunction();
  50407. if (!this.eat(RightParenthesis)) {
  50408. this.raise("Unterminated group");
  50409. }
  50410. this.onCapturingGroupLeave(start, this.index, name);
  50411. return true;
  50412. }
  50413. return false;
  50414. }
  50415. }, {
  50416. key: 'eatExtendedAtom',
  50417. value: function eatExtendedAtom() {
  50418. return this.eatDot() || this.eatReverseSolidusAtomEscape() || this.eatReverseSolidusFollowedByC() || this.eatCharacterClass() || this.eatUncapturingGroup() || this.eatCapturingGroup() || this.eatInvalidBracedQuantifier() || this.eatExtendedPatternCharacter();
  50419. }
  50420. }, {
  50421. key: 'eatReverseSolidusFollowedByC',
  50422. value: function eatReverseSolidusFollowedByC() {
  50423. if (this.currentCodePoint === ReverseSolidus && this.nextCodePoint === LatinSmallLetterC) {
  50424. this._lastIntValue = this.currentCodePoint;
  50425. this.advance();
  50426. this.onCharacter(this.index - 1, this.index, ReverseSolidus);
  50427. return true;
  50428. }
  50429. return false;
  50430. }
  50431. }, {
  50432. key: 'eatInvalidBracedQuantifier',
  50433. value: function eatInvalidBracedQuantifier() {
  50434. if (this.eatBracedQuantifier(true)) {
  50435. this.raise("Nothing to repeat");
  50436. }
  50437. return false;
  50438. }
  50439. }, {
  50440. key: 'eatSyntaxCharacter',
  50441. value: function eatSyntaxCharacter() {
  50442. if (isSyntaxCharacter(this.currentCodePoint)) {
  50443. this._lastIntValue = this.currentCodePoint;
  50444. this.advance();
  50445. return true;
  50446. }
  50447. return false;
  50448. }
  50449. }, {
  50450. key: 'eatPatternCharacter',
  50451. value: function eatPatternCharacter() {
  50452. var start = this.index;
  50453. var cp = this.currentCodePoint;
  50454. if (cp !== -1 && !isSyntaxCharacter(cp)) {
  50455. this.advance();
  50456. this.onCharacter(start, this.index, cp);
  50457. return true;
  50458. }
  50459. return false;
  50460. }
  50461. }, {
  50462. key: 'eatExtendedPatternCharacter',
  50463. value: function eatExtendedPatternCharacter() {
  50464. var start = this.index;
  50465. var cp = this.currentCodePoint;
  50466. if (cp !== -1 && cp !== CircumflexAccent && cp !== DollarSign && cp !== ReverseSolidus && cp !== FullStop && cp !== Asterisk && cp !== PlusSign && cp !== QuestionMark && cp !== LeftParenthesis && cp !== RightParenthesis && cp !== LeftSquareBracket && cp !== VerticalLine) {
  50467. this.advance();
  50468. this.onCharacter(start, this.index, cp);
  50469. return true;
  50470. }
  50471. return false;
  50472. }
  50473. }, {
  50474. key: 'groupSpecifier',
  50475. value: function groupSpecifier() {
  50476. this._lastStrValue = "";
  50477. if (this.eat(QuestionMark)) {
  50478. if (this.eatGroupName()) {
  50479. if (!this._groupNames.has(this._lastStrValue)) {
  50480. this._groupNames.add(this._lastStrValue);
  50481. return;
  50482. }
  50483. this.raise("Duplicate capture group name");
  50484. }
  50485. this.raise("Invalid group");
  50486. }
  50487. }
  50488. }, {
  50489. key: 'eatGroupName',
  50490. value: function eatGroupName() {
  50491. this._lastStrValue = "";
  50492. if (this.eat(LessThanSign)) {
  50493. if (this.eatRegExpIdentifierName() && this.eat(GreaterThanSign)) {
  50494. return true;
  50495. }
  50496. this.raise("Invalid capture group name");
  50497. }
  50498. return false;
  50499. }
  50500. }, {
  50501. key: 'eatRegExpIdentifierName',
  50502. value: function eatRegExpIdentifierName() {
  50503. this._lastStrValue = "";
  50504. if (this.eatRegExpIdentifierStart()) {
  50505. this._lastStrValue += String.fromCodePoint(this._lastIntValue);
  50506. while (this.eatRegExpIdentifierPart()) {
  50507. this._lastStrValue += String.fromCodePoint(this._lastIntValue);
  50508. }
  50509. return true;
  50510. }
  50511. return false;
  50512. }
  50513. }, {
  50514. key: 'eatRegExpIdentifierStart',
  50515. value: function eatRegExpIdentifierStart() {
  50516. var start = this.index;
  50517. var cp = this.currentCodePoint;
  50518. this.advance();
  50519. if (cp === ReverseSolidus && this.eatRegExpUnicodeEscapeSequence()) {
  50520. cp = this._lastIntValue;
  50521. }
  50522. if (isRegExpIdentifierStart(cp)) {
  50523. this._lastIntValue = cp;
  50524. return true;
  50525. }
  50526. if (this.index !== start) {
  50527. this.rewind(start);
  50528. }
  50529. return false;
  50530. }
  50531. }, {
  50532. key: 'eatRegExpIdentifierPart',
  50533. value: function eatRegExpIdentifierPart() {
  50534. var start = this.index;
  50535. var cp = this.currentCodePoint;
  50536. this.advance();
  50537. if (cp === ReverseSolidus && this.eatRegExpUnicodeEscapeSequence()) {
  50538. cp = this._lastIntValue;
  50539. }
  50540. if (isRegExpIdentifierPart(cp)) {
  50541. this._lastIntValue = cp;
  50542. return true;
  50543. }
  50544. if (this.index !== start) {
  50545. this.rewind(start);
  50546. }
  50547. return false;
  50548. }
  50549. }, {
  50550. key: 'eatAtomEscape',
  50551. value: function eatAtomEscape() {
  50552. if (this.eatBackreference() || this.eatCharacterClassEscape() || this.eatCharacterEscape() || this._nFlag && this.eatKGroupName()) {
  50553. return true;
  50554. }
  50555. if (this.strict || this._uFlag) {
  50556. this.raise("Invalid escape");
  50557. }
  50558. return false;
  50559. }
  50560. }, {
  50561. key: 'eatBackreference',
  50562. value: function eatBackreference() {
  50563. var start = this.index;
  50564. if (this.eatDecimalEscape()) {
  50565. var n = this._lastIntValue;
  50566. if (n <= this._numCapturingParens) {
  50567. this.onBackreference(start - 1, this.index, n);
  50568. return true;
  50569. }
  50570. if (this.strict) {
  50571. this.raise("Invalid escape");
  50572. }
  50573. this.rewind(start);
  50574. }
  50575. return false;
  50576. }
  50577. }, {
  50578. key: 'eatKGroupName',
  50579. value: function eatKGroupName() {
  50580. var start = this.index;
  50581. if (this.eat(LatinSmallLetterK)) {
  50582. if (this.eatGroupName()) {
  50583. var groupName = this._lastStrValue;
  50584. this._backreferenceNames.add(groupName);
  50585. this.onBackreference(start - 1, this.index, groupName);
  50586. return true;
  50587. }
  50588. this.raise("Invalid named reference");
  50589. }
  50590. return false;
  50591. }
  50592. }, {
  50593. key: 'eatCharacterEscape',
  50594. value: function eatCharacterEscape() {
  50595. var start = this.index;
  50596. if (this.eatControlEscape() || this.eatCControlLetter() || this.eatZero() || this.eatHexEscapeSequence() || this.eatRegExpUnicodeEscapeSequence() || !this.strict && this.eatLegacyOctalEscapeSequence() || this.eatIdentityEscape()) {
  50597. this.onCharacter(start - 1, this.index, this._lastIntValue);
  50598. return true;
  50599. }
  50600. return false;
  50601. }
  50602. }, {
  50603. key: 'eatCControlLetter',
  50604. value: function eatCControlLetter() {
  50605. var start = this.index;
  50606. if (this.eat(LatinSmallLetterC)) {
  50607. if (this.eatControlLetter()) {
  50608. return true;
  50609. }
  50610. this.rewind(start);
  50611. }
  50612. return false;
  50613. }
  50614. }, {
  50615. key: 'eatZero',
  50616. value: function eatZero() {
  50617. if (this.currentCodePoint === DigitZero && !isDecimalDigit(this.nextCodePoint)) {
  50618. this._lastIntValue = 0;
  50619. this.advance();
  50620. return true;
  50621. }
  50622. return false;
  50623. }
  50624. }, {
  50625. key: 'eatControlEscape',
  50626. value: function eatControlEscape() {
  50627. if (this.eat(LatinSmallLetterT)) {
  50628. this._lastIntValue = CharacterTabulation;
  50629. return true;
  50630. }
  50631. if (this.eat(LatinSmallLetterN)) {
  50632. this._lastIntValue = LineFeed;
  50633. return true;
  50634. }
  50635. if (this.eat(LatinSmallLetterV)) {
  50636. this._lastIntValue = LineTabulation;
  50637. return true;
  50638. }
  50639. if (this.eat(LatinSmallLetterF)) {
  50640. this._lastIntValue = FormFeed;
  50641. return true;
  50642. }
  50643. if (this.eat(LatinSmallLetterR)) {
  50644. this._lastIntValue = CarriageReturn;
  50645. return true;
  50646. }
  50647. return false;
  50648. }
  50649. }, {
  50650. key: 'eatControlLetter',
  50651. value: function eatControlLetter() {
  50652. var cp = this.currentCodePoint;
  50653. if (isLatinLetter(cp)) {
  50654. this.advance();
  50655. this._lastIntValue = cp % 0x20;
  50656. return true;
  50657. }
  50658. return false;
  50659. }
  50660. }, {
  50661. key: 'eatRegExpUnicodeEscapeSequence',
  50662. value: function eatRegExpUnicodeEscapeSequence() {
  50663. var start = this.index;
  50664. if (this.eat(LatinSmallLetterU)) {
  50665. if (this.eatFixedHexDigits(4)) {
  50666. var lead = this._lastIntValue;
  50667. if (this._uFlag && lead >= 0xd800 && lead <= 0xdbff) {
  50668. var leadSurrogateEnd = this.index;
  50669. if (this.eat(ReverseSolidus) && this.eat(LatinSmallLetterU) && this.eatFixedHexDigits(4)) {
  50670. var trail = this._lastIntValue;
  50671. if (trail >= 0xdc00 && trail <= 0xdfff) {
  50672. this._lastIntValue = (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000;
  50673. return true;
  50674. }
  50675. }
  50676. this.rewind(leadSurrogateEnd);
  50677. this._lastIntValue = lead;
  50678. }
  50679. return true;
  50680. }
  50681. if (this._uFlag && this.eat(LeftCurlyBracket) && this.eatHexDigits() && this.eat(RightCurlyBracket) && isValidUnicode(this._lastIntValue)) {
  50682. return true;
  50683. }
  50684. if (this.strict || this._uFlag) {
  50685. this.raise("Invalid unicode escape");
  50686. }
  50687. this.rewind(start);
  50688. }
  50689. return false;
  50690. }
  50691. }, {
  50692. key: 'eatIdentityEscape',
  50693. value: function eatIdentityEscape() {
  50694. if (this._uFlag) {
  50695. if (this.eatSyntaxCharacter()) {
  50696. return true;
  50697. }
  50698. if (this.eat(Solidus)) {
  50699. this._lastIntValue = Solidus;
  50700. return true;
  50701. }
  50702. return false;
  50703. }
  50704. if (this.isValidIdentityEscape(this.currentCodePoint)) {
  50705. this._lastIntValue = this.currentCodePoint;
  50706. this.advance();
  50707. return true;
  50708. }
  50709. return false;
  50710. }
  50711. }, {
  50712. key: 'isValidIdentityEscape',
  50713. value: function isValidIdentityEscape(cp) {
  50714. if (cp === -1) {
  50715. return false;
  50716. }
  50717. if (this.strict) {
  50718. return !isIdContinue(cp);
  50719. }
  50720. return cp !== LatinSmallLetterC && (!this._nFlag || cp !== LatinSmallLetterK);
  50721. }
  50722. }, {
  50723. key: 'eatDecimalEscape',
  50724. value: function eatDecimalEscape() {
  50725. this._lastIntValue = 0;
  50726. var cp = this.currentCodePoint;
  50727. if (cp >= DigitOne && cp <= DigitNine) {
  50728. do {
  50729. this._lastIntValue = 10 * this._lastIntValue + (cp - DigitZero);
  50730. this.advance();
  50731. } while ((cp = this.currentCodePoint) >= DigitZero && cp <= DigitNine);
  50732. return true;
  50733. }
  50734. return false;
  50735. }
  50736. }, {
  50737. key: 'eatCharacterClassEscape',
  50738. value: function eatCharacterClassEscape() {
  50739. var start = this.index;
  50740. if (this.eat(LatinSmallLetterD)) {
  50741. this._lastIntValue = -1;
  50742. this.onEscapeCharacterSet(start - 1, this.index, "digit", false);
  50743. return true;
  50744. }
  50745. if (this.eat(LatinCapitalLetterD)) {
  50746. this._lastIntValue = -1;
  50747. this.onEscapeCharacterSet(start - 1, this.index, "digit", true);
  50748. return true;
  50749. }
  50750. if (this.eat(LatinSmallLetterS)) {
  50751. this._lastIntValue = -1;
  50752. this.onEscapeCharacterSet(start - 1, this.index, "space", false);
  50753. return true;
  50754. }
  50755. if (this.eat(LatinCapitalLetterS)) {
  50756. this._lastIntValue = -1;
  50757. this.onEscapeCharacterSet(start - 1, this.index, "space", true);
  50758. return true;
  50759. }
  50760. if (this.eat(LatinSmallLetterW)) {
  50761. this._lastIntValue = -1;
  50762. this.onEscapeCharacterSet(start - 1, this.index, "word", false);
  50763. return true;
  50764. }
  50765. if (this.eat(LatinCapitalLetterW)) {
  50766. this._lastIntValue = -1;
  50767. this.onEscapeCharacterSet(start - 1, this.index, "word", true);
  50768. return true;
  50769. }
  50770. var negate = false;
  50771. if (this._uFlag && this.ecmaVersion >= 2018 && (this.eat(LatinSmallLetterP) || (negate = this.eat(LatinCapitalLetterP)))) {
  50772. this._lastIntValue = -1;
  50773. if (this.eat(LeftCurlyBracket) && this.eatUnicodePropertyValueExpression() && this.eat(RightCurlyBracket)) {
  50774. this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", this._lastKeyValue, this._lastValValue || null, negate);
  50775. return true;
  50776. }
  50777. this.raise("Invalid property name");
  50778. }
  50779. return false;
  50780. }
  50781. }, {
  50782. key: 'eatUnicodePropertyValueExpression',
  50783. value: function eatUnicodePropertyValueExpression() {
  50784. var start = this.index;
  50785. if (this.eatUnicodePropertyName() && this.eat(EqualsSign)) {
  50786. this._lastKeyValue = this._lastStrValue;
  50787. if (this.eatUnicodePropertyValue()) {
  50788. this._lastValValue = this._lastStrValue;
  50789. if (isValidUnicodeProperty(this._lastKeyValue, this._lastValValue)) {
  50790. return true;
  50791. }
  50792. this.raise("Invalid property name");
  50793. }
  50794. }
  50795. this.rewind(start);
  50796. if (this.eatLoneUnicodePropertyNameOrValue()) {
  50797. var nameOrValue = this._lastStrValue;
  50798. if (isValidUnicodeProperty("General_Category", nameOrValue)) {
  50799. this._lastKeyValue = "General_Category";
  50800. this._lastValValue = nameOrValue;
  50801. return true;
  50802. }
  50803. if (isValidUnicodePropertyName(nameOrValue)) {
  50804. this._lastKeyValue = nameOrValue;
  50805. this._lastValValue = "";
  50806. return true;
  50807. }
  50808. this.raise("Invalid property name");
  50809. }
  50810. return false;
  50811. }
  50812. }, {
  50813. key: 'eatUnicodePropertyName',
  50814. value: function eatUnicodePropertyName() {
  50815. this._lastStrValue = "";
  50816. while (isUnicodePropertyNameCharacter(this.currentCodePoint)) {
  50817. this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
  50818. this.advance();
  50819. }
  50820. return this._lastStrValue !== "";
  50821. }
  50822. }, {
  50823. key: 'eatUnicodePropertyValue',
  50824. value: function eatUnicodePropertyValue() {
  50825. this._lastStrValue = "";
  50826. while (isUnicodePropertyValueCharacter(this.currentCodePoint)) {
  50827. this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
  50828. this.advance();
  50829. }
  50830. return this._lastStrValue !== "";
  50831. }
  50832. }, {
  50833. key: 'eatLoneUnicodePropertyNameOrValue',
  50834. value: function eatLoneUnicodePropertyNameOrValue() {
  50835. return this.eatUnicodePropertyValue();
  50836. }
  50837. }, {
  50838. key: 'eatCharacterClass',
  50839. value: function eatCharacterClass() {
  50840. var start = this.index;
  50841. if (this.eat(LeftSquareBracket)) {
  50842. var negate = this.eat(CircumflexAccent);
  50843. this.onCharacterClassEnter(start, negate);
  50844. this.classRanges();
  50845. if (!this.eat(RightSquareBracket)) {
  50846. this.raise("Unterminated character class");
  50847. }
  50848. this.onCharacterClassLeave(start, this.index, negate);
  50849. return true;
  50850. }
  50851. return false;
  50852. }
  50853. }, {
  50854. key: 'classRanges',
  50855. value: function classRanges() {
  50856. var start = this.index;
  50857. while (this.eatClassAtom()) {
  50858. var left = this._lastIntValue;
  50859. var hyphenStart = this.index;
  50860. if (this.eat(HyphenMinus)) {
  50861. this.onCharacter(hyphenStart, this.index, HyphenMinus);
  50862. if (this.eatClassAtom()) {
  50863. var right = this._lastIntValue;
  50864. if (left === -1 || right === -1) {
  50865. if (this.strict) {
  50866. this.raise("Invalid character class");
  50867. }
  50868. } else if (left > right) {
  50869. this.raise("Range out of order in character class");
  50870. } else {
  50871. this.onCharacterClassRange(start, this.index, left, right);
  50872. }
  50873. }
  50874. }
  50875. start = this.index;
  50876. }
  50877. }
  50878. }, {
  50879. key: 'eatClassAtom',
  50880. value: function eatClassAtom() {
  50881. var start = this.index;
  50882. if (this.eat(ReverseSolidus)) {
  50883. if (this.eatClassEscape()) {
  50884. return true;
  50885. }
  50886. if (this._uFlag) {
  50887. this.raise("Invalid escape");
  50888. }
  50889. this.rewind(start);
  50890. }
  50891. var cp = this.currentCodePoint;
  50892. if (cp !== -1 && cp !== RightSquareBracket) {
  50893. this.advance();
  50894. this._lastIntValue = cp;
  50895. this.onCharacter(start, this.index, cp);
  50896. return true;
  50897. }
  50898. return false;
  50899. }
  50900. }, {
  50901. key: 'eatClassEscape',
  50902. value: function eatClassEscape() {
  50903. var start = this.index;
  50904. if (this.eat(LatinSmallLetterB)) {
  50905. this._lastIntValue = Backspace;
  50906. this.onCharacter(start - 1, this.index, Backspace);
  50907. return true;
  50908. }
  50909. if (this._uFlag && this.eat(HyphenMinus)) {
  50910. this._lastIntValue = HyphenMinus;
  50911. this.onCharacter(start - 1, this.index, HyphenMinus);
  50912. return true;
  50913. }
  50914. if (!this._uFlag && this.eat(LatinSmallLetterC)) {
  50915. if (this.eatClassControlLetter()) {
  50916. this.onCharacter(start - 1, this.index, this._lastIntValue);
  50917. return true;
  50918. }
  50919. this.rewind(start);
  50920. }
  50921. return this.eatCharacterClassEscape() || this.eatCharacterEscape();
  50922. }
  50923. }, {
  50924. key: 'eatClassControlLetter',
  50925. value: function eatClassControlLetter() {
  50926. var cp = this.currentCodePoint;
  50927. if (isDecimalDigit(cp) || cp === LowLine) {
  50928. this.advance();
  50929. this._lastIntValue = cp % 0x20;
  50930. return true;
  50931. }
  50932. return false;
  50933. }
  50934. }, {
  50935. key: 'eatHexEscapeSequence',
  50936. value: function eatHexEscapeSequence() {
  50937. var start = this.index;
  50938. if (this.eat(LatinSmallLetterX)) {
  50939. if (this.eatFixedHexDigits(2)) {
  50940. return true;
  50941. }
  50942. if (this._uFlag) {
  50943. this.raise("Invalid escape");
  50944. }
  50945. this.rewind(start);
  50946. }
  50947. return false;
  50948. }
  50949. }, {
  50950. key: 'eatDecimalDigits',
  50951. value: function eatDecimalDigits() {
  50952. var start = this.index;
  50953. this._lastIntValue = 0;
  50954. while (isDecimalDigit(this.currentCodePoint)) {
  50955. this._lastIntValue = 10 * this._lastIntValue + digitToInt(this.currentCodePoint);
  50956. this.advance();
  50957. }
  50958. return this.index !== start;
  50959. }
  50960. }, {
  50961. key: 'eatHexDigits',
  50962. value: function eatHexDigits() {
  50963. var start = this.index;
  50964. this._lastIntValue = 0;
  50965. while (isHexDigit(this.currentCodePoint)) {
  50966. this._lastIntValue = 16 * this._lastIntValue + digitToInt(this.currentCodePoint);
  50967. this.advance();
  50968. }
  50969. return this.index !== start;
  50970. }
  50971. }, {
  50972. key: 'eatLegacyOctalEscapeSequence',
  50973. value: function eatLegacyOctalEscapeSequence() {
  50974. if (this.eatOctalDigit()) {
  50975. var n1 = this._lastIntValue;
  50976. if (this.eatOctalDigit()) {
  50977. var n2 = this._lastIntValue;
  50978. if (n1 <= 3 && this.eatOctalDigit()) {
  50979. this._lastIntValue = n1 * 64 + n2 * 8 + this._lastIntValue;
  50980. } else {
  50981. this._lastIntValue = n1 * 8 + n2;
  50982. }
  50983. } else {
  50984. this._lastIntValue = n1;
  50985. }
  50986. return true;
  50987. }
  50988. return false;
  50989. }
  50990. }, {
  50991. key: 'eatOctalDigit',
  50992. value: function eatOctalDigit() {
  50993. var cp = this.currentCodePoint;
  50994. if (isOctalDigit(cp)) {
  50995. this.advance();
  50996. this._lastIntValue = cp - DigitZero;
  50997. return true;
  50998. }
  50999. this._lastIntValue = 0;
  51000. return false;
  51001. }
  51002. }, {
  51003. key: 'eatFixedHexDigits',
  51004. value: function eatFixedHexDigits(length) {
  51005. var start = this.index;
  51006. this._lastIntValue = 0;
  51007. for (var i = 0; i < length; ++i) {
  51008. var cp = this.currentCodePoint;
  51009. if (!isHexDigit(cp)) {
  51010. this.rewind(start);
  51011. return false;
  51012. }
  51013. this._lastIntValue = 16 * this._lastIntValue + digitToInt(cp);
  51014. this.advance();
  51015. }
  51016. return true;
  51017. }
  51018. }, {
  51019. key: 'strict',
  51020. get: function get() {
  51021. return Boolean(this._options.strict || this._uFlag);
  51022. }
  51023. }, {
  51024. key: 'ecmaVersion',
  51025. get: function get() {
  51026. return this._options.ecmaVersion || 2018;
  51027. }
  51028. }, {
  51029. key: 'source',
  51030. get: function get() {
  51031. return this._reader.source;
  51032. }
  51033. }, {
  51034. key: 'index',
  51035. get: function get() {
  51036. return this._reader.index;
  51037. }
  51038. }, {
  51039. key: 'currentCodePoint',
  51040. get: function get() {
  51041. return this._reader.currentCodePoint;
  51042. }
  51043. }, {
  51044. key: 'nextCodePoint',
  51045. get: function get() {
  51046. return this._reader.nextCodePoint;
  51047. }
  51048. }, {
  51049. key: 'nextCodePoint2',
  51050. get: function get() {
  51051. return this._reader.nextCodePoint2;
  51052. }
  51053. }, {
  51054. key: 'nextCodePoint3',
  51055. get: function get() {
  51056. return this._reader.nextCodePoint3;
  51057. }
  51058. }]);
  51059. return RegExpValidator;
  51060. }();
  51061. var DummyPattern = {};
  51062. var DummyFlags = {};
  51063. var DummyCapturingGroup = {};
  51064. var RegExpParserState = function () {
  51065. function RegExpParserState(options) {
  51066. _classCallCheck(this, RegExpParserState);
  51067. this._node = DummyPattern;
  51068. this._flags = DummyFlags;
  51069. this._backreferences = [];
  51070. this._capturingGroups = [];
  51071. this.source = "";
  51072. this.strict = Boolean(options && options.strict);
  51073. this.ecmaVersion = options && options.ecmaVersion || 2018;
  51074. }
  51075. _createClass(RegExpParserState, [{
  51076. key: 'onFlags',
  51077. value: function onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll) {
  51078. this._flags = {
  51079. type: "Flags",
  51080. parent: null,
  51081. start: start,
  51082. end: end,
  51083. raw: this.source.slice(start, end),
  51084. global: global,
  51085. ignoreCase: ignoreCase,
  51086. multiline: multiline,
  51087. unicode: unicode,
  51088. sticky: sticky,
  51089. dotAll: dotAll
  51090. };
  51091. }
  51092. }, {
  51093. key: 'onPatternEnter',
  51094. value: function onPatternEnter(start) {
  51095. this._node = {
  51096. type: "Pattern",
  51097. parent: null,
  51098. start: start,
  51099. end: start,
  51100. raw: "",
  51101. alternatives: []
  51102. };
  51103. this._backreferences.length = 0;
  51104. this._capturingGroups.length = 0;
  51105. }
  51106. }, {
  51107. key: 'onPatternLeave',
  51108. value: function onPatternLeave(start, end) {
  51109. var _this2 = this;
  51110. this._node.end = end;
  51111. this._node.raw = this.source.slice(start, end);
  51112. var _iteratorNormalCompletion2 = true;
  51113. var _didIteratorError2 = false;
  51114. var _iteratorError2 = undefined;
  51115. try {
  51116. var _loop = function _loop() {
  51117. var reference = _step2.value;
  51118. var ref = reference.ref;
  51119. var group = typeof ref === "number" ? _this2._capturingGroups[ref - 1] : _this2._capturingGroups.find(function (g) {
  51120. return g.name === ref;
  51121. });
  51122. reference.resolved = group;
  51123. group.references.push(reference);
  51124. };
  51125. for (var _iterator2 = this._backreferences[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  51126. _loop();
  51127. }
  51128. } catch (err) {
  51129. _didIteratorError2 = true;
  51130. _iteratorError2 = err;
  51131. } finally {
  51132. try {
  51133. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  51134. _iterator2.return();
  51135. }
  51136. } finally {
  51137. if (_didIteratorError2) {
  51138. throw _iteratorError2;
  51139. }
  51140. }
  51141. }
  51142. }
  51143. }, {
  51144. key: 'onAlternativeEnter',
  51145. value: function onAlternativeEnter(start) {
  51146. var parent = this._node;
  51147. if (parent.type !== "Assertion" && parent.type !== "CapturingGroup" && parent.type !== "Group" && parent.type !== "Pattern") {
  51148. throw new Error("UnknownError");
  51149. }
  51150. this._node = {
  51151. type: "Alternative",
  51152. parent: parent,
  51153. start: start,
  51154. end: start,
  51155. raw: "",
  51156. elements: []
  51157. };
  51158. parent.alternatives.push(this._node);
  51159. }
  51160. }, {
  51161. key: 'onAlternativeLeave',
  51162. value: function onAlternativeLeave(start, end) {
  51163. var node = this._node;
  51164. if (node.type !== "Alternative") {
  51165. throw new Error("UnknownError");
  51166. }
  51167. node.end = end;
  51168. node.raw = this.source.slice(start, end);
  51169. this._node = node.parent;
  51170. }
  51171. }, {
  51172. key: 'onGroupEnter',
  51173. value: function onGroupEnter(start) {
  51174. var parent = this._node;
  51175. if (parent.type !== "Alternative") {
  51176. throw new Error("UnknownError");
  51177. }
  51178. this._node = {
  51179. type: "Group",
  51180. parent: parent,
  51181. start: start,
  51182. end: start,
  51183. raw: "",
  51184. alternatives: []
  51185. };
  51186. parent.elements.push(this._node);
  51187. }
  51188. }, {
  51189. key: 'onGroupLeave',
  51190. value: function onGroupLeave(start, end) {
  51191. var node = this._node;
  51192. if (node.type !== "Group" || node.parent.type !== "Alternative") {
  51193. throw new Error("UnknownError");
  51194. }
  51195. node.end = end;
  51196. node.raw = this.source.slice(start, end);
  51197. this._node = node.parent;
  51198. }
  51199. }, {
  51200. key: 'onCapturingGroupEnter',
  51201. value: function onCapturingGroupEnter(start, name) {
  51202. var parent = this._node;
  51203. if (parent.type !== "Alternative") {
  51204. throw new Error("UnknownError");
  51205. }
  51206. this._node = {
  51207. type: "CapturingGroup",
  51208. parent: parent,
  51209. start: start,
  51210. end: start,
  51211. raw: "",
  51212. name: name,
  51213. alternatives: [],
  51214. references: []
  51215. };
  51216. parent.elements.push(this._node);
  51217. this._capturingGroups.push(this._node);
  51218. }
  51219. }, {
  51220. key: 'onCapturingGroupLeave',
  51221. value: function onCapturingGroupLeave(start, end) {
  51222. var node = this._node;
  51223. if (node.type !== "CapturingGroup" || node.parent.type !== "Alternative") {
  51224. throw new Error("UnknownError");
  51225. }
  51226. node.end = end;
  51227. node.raw = this.source.slice(start, end);
  51228. this._node = node.parent;
  51229. }
  51230. }, {
  51231. key: 'onQuantifier',
  51232. value: function onQuantifier(start, end, min, max, greedy) {
  51233. var parent = this._node;
  51234. if (parent.type !== "Alternative") {
  51235. throw new Error("UnknownError");
  51236. }
  51237. var element = parent.elements.pop();
  51238. if (element == null || element.type === "Quantifier" || element.type === "Assertion" && element.kind !== "lookahead") {
  51239. throw new Error("UnknownError");
  51240. }
  51241. var node = {
  51242. type: "Quantifier",
  51243. parent: parent,
  51244. start: element.start,
  51245. end: end,
  51246. raw: this.source.slice(element.start, end),
  51247. min: min,
  51248. max: max,
  51249. greedy: greedy,
  51250. element: element
  51251. };
  51252. parent.elements.push(node);
  51253. element.parent = node;
  51254. }
  51255. }, {
  51256. key: 'onLookaroundAssertionEnter',
  51257. value: function onLookaroundAssertionEnter(start, kind, negate) {
  51258. var parent = this._node;
  51259. if (parent.type !== "Alternative") {
  51260. throw new Error("UnknownError");
  51261. }
  51262. this._node = {
  51263. type: "Assertion",
  51264. parent: parent,
  51265. start: start,
  51266. end: start,
  51267. raw: "",
  51268. kind: kind,
  51269. negate: negate,
  51270. alternatives: []
  51271. };
  51272. parent.elements.push(this._node);
  51273. }
  51274. }, {
  51275. key: 'onLookaroundAssertionLeave',
  51276. value: function onLookaroundAssertionLeave(start, end) {
  51277. var node = this._node;
  51278. if (node.type !== "Assertion" || node.parent.type !== "Alternative") {
  51279. throw new Error("UnknownError");
  51280. }
  51281. node.end = end;
  51282. node.raw = this.source.slice(start, end);
  51283. this._node = node.parent;
  51284. }
  51285. }, {
  51286. key: 'onEdgeAssertion',
  51287. value: function onEdgeAssertion(start, end, kind) {
  51288. var parent = this._node;
  51289. if (parent.type !== "Alternative") {
  51290. throw new Error("UnknownError");
  51291. }
  51292. parent.elements.push({
  51293. type: "Assertion",
  51294. parent: parent,
  51295. start: start,
  51296. end: end,
  51297. raw: this.source.slice(start, end),
  51298. kind: kind
  51299. });
  51300. }
  51301. }, {
  51302. key: 'onWordBoundaryAssertion',
  51303. value: function onWordBoundaryAssertion(start, end, kind, negate) {
  51304. var parent = this._node;
  51305. if (parent.type !== "Alternative") {
  51306. throw new Error("UnknownError");
  51307. }
  51308. parent.elements.push({
  51309. type: "Assertion",
  51310. parent: parent,
  51311. start: start,
  51312. end: end,
  51313. raw: this.source.slice(start, end),
  51314. kind: kind,
  51315. negate: negate
  51316. });
  51317. }
  51318. }, {
  51319. key: 'onAnyCharacterSet',
  51320. value: function onAnyCharacterSet(start, end, kind) {
  51321. var parent = this._node;
  51322. if (parent.type !== "Alternative") {
  51323. throw new Error("UnknownError");
  51324. }
  51325. parent.elements.push({
  51326. type: "CharacterSet",
  51327. parent: parent,
  51328. start: start,
  51329. end: end,
  51330. raw: this.source.slice(start, end),
  51331. kind: kind
  51332. });
  51333. }
  51334. }, {
  51335. key: 'onEscapeCharacterSet',
  51336. value: function onEscapeCharacterSet(start, end, kind, negate) {
  51337. var parent = this._node;
  51338. if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
  51339. throw new Error("UnknownError");
  51340. }
  51341. parent.elements.push({
  51342. type: "CharacterSet",
  51343. parent: parent,
  51344. start: start,
  51345. end: end,
  51346. raw: this.source.slice(start, end),
  51347. kind: kind,
  51348. negate: negate
  51349. });
  51350. }
  51351. }, {
  51352. key: 'onUnicodePropertyCharacterSet',
  51353. value: function onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
  51354. var parent = this._node;
  51355. if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
  51356. throw new Error("UnknownError");
  51357. }
  51358. parent.elements.push({
  51359. type: "CharacterSet",
  51360. parent: parent,
  51361. start: start,
  51362. end: end,
  51363. raw: this.source.slice(start, end),
  51364. kind: kind,
  51365. key: key,
  51366. value: value,
  51367. negate: negate
  51368. });
  51369. }
  51370. }, {
  51371. key: 'onCharacter',
  51372. value: function onCharacter(start, end, value) {
  51373. var parent = this._node;
  51374. if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
  51375. throw new Error("UnknownError");
  51376. }
  51377. parent.elements.push({
  51378. type: "Character",
  51379. parent: parent,
  51380. start: start,
  51381. end: end,
  51382. raw: this.source.slice(start, end),
  51383. value: value
  51384. });
  51385. }
  51386. }, {
  51387. key: 'onBackreference',
  51388. value: function onBackreference(start, end, ref) {
  51389. var parent = this._node;
  51390. if (parent.type !== "Alternative") {
  51391. throw new Error("UnknownError");
  51392. }
  51393. var node = {
  51394. type: "Backreference",
  51395. parent: parent,
  51396. start: start,
  51397. end: end,
  51398. raw: this.source.slice(start, end),
  51399. ref: ref,
  51400. resolved: DummyCapturingGroup
  51401. };
  51402. parent.elements.push(node);
  51403. this._backreferences.push(node);
  51404. }
  51405. }, {
  51406. key: 'onCharacterClassEnter',
  51407. value: function onCharacterClassEnter(start, negate) {
  51408. var parent = this._node;
  51409. if (parent.type !== "Alternative") {
  51410. throw new Error("UnknownError");
  51411. }
  51412. this._node = {
  51413. type: "CharacterClass",
  51414. parent: parent,
  51415. start: start,
  51416. end: start,
  51417. raw: "",
  51418. negate: negate,
  51419. elements: []
  51420. };
  51421. parent.elements.push(this._node);
  51422. }
  51423. }, {
  51424. key: 'onCharacterClassLeave',
  51425. value: function onCharacterClassLeave(start, end) {
  51426. var node = this._node;
  51427. if (node.type !== "CharacterClass" || node.parent.type !== "Alternative") {
  51428. throw new Error("UnknownError");
  51429. }
  51430. node.end = end;
  51431. node.raw = this.source.slice(start, end);
  51432. this._node = node.parent;
  51433. }
  51434. }, {
  51435. key: 'onCharacterClassRange',
  51436. value: function onCharacterClassRange(start, end) {
  51437. var parent = this._node;
  51438. if (parent.type !== "CharacterClass") {
  51439. throw new Error("UnknownError");
  51440. }
  51441. var elements = parent.elements;
  51442. var max = elements.pop();
  51443. var hyphen = elements.pop();
  51444. var min = elements.pop();
  51445. if (!min || !max || !hyphen || min.type !== "Character" || max.type !== "Character" || hyphen.type !== "Character" || hyphen.value !== HyphenMinus) {
  51446. throw new Error("UnknownError");
  51447. }
  51448. var node = {
  51449. type: "CharacterClassRange",
  51450. parent: parent,
  51451. start: start,
  51452. end: end,
  51453. raw: this.source.slice(start, end),
  51454. min: min,
  51455. max: max
  51456. };
  51457. min.parent = node;
  51458. max.parent = node;
  51459. elements.push(node);
  51460. }
  51461. }, {
  51462. key: 'pattern',
  51463. get: function get() {
  51464. if (this._node.type !== "Pattern") {
  51465. throw new Error("UnknownError");
  51466. }
  51467. return this._node;
  51468. }
  51469. }, {
  51470. key: 'flags',
  51471. get: function get() {
  51472. if (this._flags.type !== "Flags") {
  51473. throw new Error("UnknownError");
  51474. }
  51475. return this._flags;
  51476. }
  51477. }]);
  51478. return RegExpParserState;
  51479. }();
  51480. var RegExpParser = function () {
  51481. function RegExpParser(options) {
  51482. _classCallCheck(this, RegExpParser);
  51483. this._state = new RegExpParserState(options);
  51484. this._validator = new RegExpValidator(this._state);
  51485. }
  51486. _createClass(RegExpParser, [{
  51487. key: 'parseLiteral',
  51488. value: function parseLiteral(source) {
  51489. var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  51490. var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
  51491. this._state.source = source;
  51492. this._validator.validateLiteral(source, start, end);
  51493. var pattern = this._state.pattern;
  51494. var flags = this._state.flags;
  51495. var literal = {
  51496. type: "RegExpLiteral",
  51497. parent: null,
  51498. start: start,
  51499. end: end,
  51500. raw: source,
  51501. pattern: pattern,
  51502. flags: flags
  51503. };
  51504. pattern.parent = literal;
  51505. flags.parent = literal;
  51506. return literal;
  51507. }
  51508. }, {
  51509. key: 'parseFlags',
  51510. value: function parseFlags(source) {
  51511. var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  51512. var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
  51513. this._state.source = source;
  51514. this._validator.validateFlags(source, start, end);
  51515. return this._state.flags;
  51516. }
  51517. }, {
  51518. key: 'parsePattern',
  51519. value: function parsePattern(source) {
  51520. var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  51521. var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
  51522. var uFlag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  51523. this._state.source = source;
  51524. this._validator.validatePattern(source, start, end, uFlag);
  51525. return this._state.pattern;
  51526. }
  51527. }]);
  51528. return RegExpParser;
  51529. }();
  51530. var RegExpVisitor = function () {
  51531. function RegExpVisitor(handlers) {
  51532. _classCallCheck(this, RegExpVisitor);
  51533. this._handlers = handlers;
  51534. }
  51535. _createClass(RegExpVisitor, [{
  51536. key: 'visit',
  51537. value: function visit(node) {
  51538. switch (node.type) {
  51539. case "Alternative":
  51540. this.visitAlternative(node);
  51541. break;
  51542. case "Assertion":
  51543. this.visitAssertion(node);
  51544. break;
  51545. case "Backreference":
  51546. this.visitBackreference(node);
  51547. break;
  51548. case "CapturingGroup":
  51549. this.visitCapturingGroup(node);
  51550. break;
  51551. case "Character":
  51552. this.visitCharacter(node);
  51553. break;
  51554. case "CharacterClass":
  51555. this.visitCharacterClass(node);
  51556. break;
  51557. case "CharacterClassRange":
  51558. this.visitCharacterClassRange(node);
  51559. break;
  51560. case "CharacterSet":
  51561. this.visitCharacterSet(node);
  51562. break;
  51563. case "Flags":
  51564. this.visitFlags(node);
  51565. break;
  51566. case "Group":
  51567. this.visitGroup(node);
  51568. break;
  51569. case "Pattern":
  51570. this.visitPattern(node);
  51571. break;
  51572. case "Quantifier":
  51573. this.visitQuantifier(node);
  51574. break;
  51575. case "RegExpLiteral":
  51576. this.visitRegExpLiteral(node);
  51577. break;
  51578. default:
  51579. throw new Error('Unknown type: ' + node.type);
  51580. }
  51581. }
  51582. }, {
  51583. key: 'visitAlternative',
  51584. value: function visitAlternative(node) {
  51585. if (this._handlers.onAlternativeEnter) {
  51586. this._handlers.onAlternativeEnter(node);
  51587. }
  51588. node.elements.forEach(this.visit, this);
  51589. if (this._handlers.onAlternativeLeave) {
  51590. this._handlers.onAlternativeLeave(node);
  51591. }
  51592. }
  51593. }, {
  51594. key: 'visitAssertion',
  51595. value: function visitAssertion(node) {
  51596. if (this._handlers.onAssertionEnter) {
  51597. this._handlers.onAssertionEnter(node);
  51598. }
  51599. if (node.kind === "lookahead" || node.kind === "lookbehind") {
  51600. node.alternatives.forEach(this.visit, this);
  51601. }
  51602. if (this._handlers.onAssertionLeave) {
  51603. this._handlers.onAssertionLeave(node);
  51604. }
  51605. }
  51606. }, {
  51607. key: 'visitBackreference',
  51608. value: function visitBackreference(node) {
  51609. if (this._handlers.onBackreferenceEnter) {
  51610. this._handlers.onBackreferenceEnter(node);
  51611. }
  51612. if (this._handlers.onBackreferenceLeave) {
  51613. this._handlers.onBackreferenceLeave(node);
  51614. }
  51615. }
  51616. }, {
  51617. key: 'visitCapturingGroup',
  51618. value: function visitCapturingGroup(node) {
  51619. if (this._handlers.onCapturingGroupEnter) {
  51620. this._handlers.onCapturingGroupEnter(node);
  51621. }
  51622. node.alternatives.forEach(this.visit, this);
  51623. if (this._handlers.onCapturingGroupLeave) {
  51624. this._handlers.onCapturingGroupLeave(node);
  51625. }
  51626. }
  51627. }, {
  51628. key: 'visitCharacter',
  51629. value: function visitCharacter(node) {
  51630. if (this._handlers.onCharacterEnter) {
  51631. this._handlers.onCharacterEnter(node);
  51632. }
  51633. if (this._handlers.onCharacterLeave) {
  51634. this._handlers.onCharacterLeave(node);
  51635. }
  51636. }
  51637. }, {
  51638. key: 'visitCharacterClass',
  51639. value: function visitCharacterClass(node) {
  51640. if (this._handlers.onCharacterClassEnter) {
  51641. this._handlers.onCharacterClassEnter(node);
  51642. }
  51643. node.elements.forEach(this.visit, this);
  51644. if (this._handlers.onCharacterClassLeave) {
  51645. this._handlers.onCharacterClassLeave(node);
  51646. }
  51647. }
  51648. }, {
  51649. key: 'visitCharacterClassRange',
  51650. value: function visitCharacterClassRange(node) {
  51651. if (this._handlers.onCharacterClassRangeEnter) {
  51652. this._handlers.onCharacterClassRangeEnter(node);
  51653. }
  51654. this.visitCharacter(node.min);
  51655. this.visitCharacter(node.max);
  51656. if (this._handlers.onCharacterClassRangeLeave) {
  51657. this._handlers.onCharacterClassRangeLeave(node);
  51658. }
  51659. }
  51660. }, {
  51661. key: 'visitCharacterSet',
  51662. value: function visitCharacterSet(node) {
  51663. if (this._handlers.onCharacterSetEnter) {
  51664. this._handlers.onCharacterSetEnter(node);
  51665. }
  51666. if (this._handlers.onCharacterSetLeave) {
  51667. this._handlers.onCharacterSetLeave(node);
  51668. }
  51669. }
  51670. }, {
  51671. key: 'visitFlags',
  51672. value: function visitFlags(node) {
  51673. if (this._handlers.onFlagsEnter) {
  51674. this._handlers.onFlagsEnter(node);
  51675. }
  51676. if (this._handlers.onFlagsLeave) {
  51677. this._handlers.onFlagsLeave(node);
  51678. }
  51679. }
  51680. }, {
  51681. key: 'visitGroup',
  51682. value: function visitGroup(node) {
  51683. if (this._handlers.onGroupEnter) {
  51684. this._handlers.onGroupEnter(node);
  51685. }
  51686. node.alternatives.forEach(this.visit, this);
  51687. if (this._handlers.onGroupLeave) {
  51688. this._handlers.onGroupLeave(node);
  51689. }
  51690. }
  51691. }, {
  51692. key: 'visitPattern',
  51693. value: function visitPattern(node) {
  51694. if (this._handlers.onPatternEnter) {
  51695. this._handlers.onPatternEnter(node);
  51696. }
  51697. node.alternatives.forEach(this.visit, this);
  51698. if (this._handlers.onPatternLeave) {
  51699. this._handlers.onPatternLeave(node);
  51700. }
  51701. }
  51702. }, {
  51703. key: 'visitQuantifier',
  51704. value: function visitQuantifier(node) {
  51705. if (this._handlers.onQuantifierEnter) {
  51706. this._handlers.onQuantifierEnter(node);
  51707. }
  51708. this.visit(node.element);
  51709. if (this._handlers.onQuantifierLeave) {
  51710. this._handlers.onQuantifierLeave(node);
  51711. }
  51712. }
  51713. }, {
  51714. key: 'visitRegExpLiteral',
  51715. value: function visitRegExpLiteral(node) {
  51716. if (this._handlers.onRegExpLiteralEnter) {
  51717. this._handlers.onRegExpLiteralEnter(node);
  51718. }
  51719. this.visitPattern(node.pattern);
  51720. this.visitFlags(node.flags);
  51721. if (this._handlers.onRegExpLiteralLeave) {
  51722. this._handlers.onRegExpLiteralLeave(node);
  51723. }
  51724. }
  51725. }]);
  51726. return RegExpVisitor;
  51727. }();
  51728. function parseRegExpLiteral(source, options) {
  51729. return new RegExpParser(options).parseLiteral(String(source));
  51730. }
  51731. function validateRegExpLiteral(source, options) {
  51732. return new RegExpValidator(options).validateLiteral(source);
  51733. }
  51734. function visitRegExpAST(node, handlers) {
  51735. new RegExpVisitor(handlers).visit(node);
  51736. }
  51737. exports.AST = ast;
  51738. exports.RegExpParser = RegExpParser;
  51739. exports.RegExpValidator = RegExpValidator;
  51740. exports.parseRegExpLiteral = parseRegExpLiteral;
  51741. exports.validateRegExpLiteral = validateRegExpLiteral;
  51742. exports.visitRegExpAST = visitRegExpAST;
  51743. },{}],105:[function(require,module,exports){
  51744. 'use strict';
  51745. // Generated by LiveScript 1.4.0
  51746. (function () {
  51747. var ref$,
  51748. any,
  51749. all,
  51750. isItNaN,
  51751. types,
  51752. defaultType,
  51753. customTypes,
  51754. toString$ = {}.toString;
  51755. ref$ = require('prelude-ls'), any = ref$.any, all = ref$.all, isItNaN = ref$.isItNaN;
  51756. types = {
  51757. Number: {
  51758. typeOf: 'Number',
  51759. validate: function validate(it) {
  51760. return !isItNaN(it);
  51761. }
  51762. },
  51763. NaN: {
  51764. typeOf: 'Number',
  51765. validate: isItNaN
  51766. },
  51767. Int: {
  51768. typeOf: 'Number',
  51769. validate: function validate(it) {
  51770. return !isItNaN(it) && it % 1 === 0;
  51771. }
  51772. },
  51773. Float: {
  51774. typeOf: 'Number',
  51775. validate: function validate(it) {
  51776. return !isItNaN(it);
  51777. }
  51778. },
  51779. Date: {
  51780. typeOf: 'Date',
  51781. validate: function validate(it) {
  51782. return !isItNaN(it.getTime());
  51783. }
  51784. }
  51785. };
  51786. defaultType = {
  51787. array: 'Array',
  51788. tuple: 'Array'
  51789. };
  51790. function checkArray(input, type) {
  51791. return all(function (it) {
  51792. return checkMultiple(it, type.of);
  51793. }, input);
  51794. }
  51795. function checkTuple(input, type) {
  51796. var i, i$, ref$, len$, types;
  51797. i = 0;
  51798. for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
  51799. types = ref$[i$];
  51800. if (!checkMultiple(input[i], types)) {
  51801. return false;
  51802. }
  51803. i++;
  51804. }
  51805. return input.length <= i;
  51806. }
  51807. function checkFields(input, type) {
  51808. var inputKeys, numInputKeys, k, numOfKeys, key, ref$, types;
  51809. inputKeys = {};
  51810. numInputKeys = 0;
  51811. for (k in input) {
  51812. inputKeys[k] = true;
  51813. numInputKeys++;
  51814. }
  51815. numOfKeys = 0;
  51816. for (key in ref$ = type.of) {
  51817. types = ref$[key];
  51818. if (!checkMultiple(input[key], types)) {
  51819. return false;
  51820. }
  51821. if (inputKeys[key]) {
  51822. numOfKeys++;
  51823. }
  51824. }
  51825. return type.subset || numInputKeys === numOfKeys;
  51826. }
  51827. function checkStructure(input, type) {
  51828. if (!(input instanceof Object)) {
  51829. return false;
  51830. }
  51831. switch (type.structure) {
  51832. case 'fields':
  51833. return checkFields(input, type);
  51834. case 'array':
  51835. return checkArray(input, type);
  51836. case 'tuple':
  51837. return checkTuple(input, type);
  51838. }
  51839. }
  51840. function check(input, typeObj) {
  51841. var type, structure, setting, that;
  51842. type = typeObj.type, structure = typeObj.structure;
  51843. if (type) {
  51844. if (type === '*') {
  51845. return true;
  51846. }
  51847. setting = customTypes[type] || types[type];
  51848. if (setting) {
  51849. return setting.typeOf === toString$.call(input).slice(8, -1) && setting.validate(input);
  51850. } else {
  51851. return type === toString$.call(input).slice(8, -1) && (!structure || checkStructure(input, typeObj));
  51852. }
  51853. } else if (structure) {
  51854. if (that = defaultType[structure]) {
  51855. if (that !== toString$.call(input).slice(8, -1)) {
  51856. return false;
  51857. }
  51858. }
  51859. return checkStructure(input, typeObj);
  51860. } else {
  51861. throw new Error("No type defined. Input: " + input + ".");
  51862. }
  51863. }
  51864. function checkMultiple(input, types) {
  51865. if (toString$.call(types).slice(8, -1) !== 'Array') {
  51866. throw new Error("Types must be in an array. Input: " + input + ".");
  51867. }
  51868. return any(function (it) {
  51869. return check(input, it);
  51870. }, types);
  51871. }
  51872. module.exports = function (parsedType, input, options) {
  51873. options == null && (options = {});
  51874. customTypes = options.customTypes || {};
  51875. return checkMultiple(input, parsedType);
  51876. };
  51877. }).call(undefined);
  51878. },{"prelude-ls":102}],106:[function(require,module,exports){
  51879. 'use strict';
  51880. // Generated by LiveScript 1.4.0
  51881. (function () {
  51882. var VERSION, parseType, parsedTypeCheck, typeCheck;
  51883. VERSION = '0.3.2';
  51884. parseType = require('./parse-type');
  51885. parsedTypeCheck = require('./check');
  51886. typeCheck = function typeCheck(type, input, options) {
  51887. return parsedTypeCheck(parseType(type), input, options);
  51888. };
  51889. module.exports = {
  51890. VERSION: VERSION,
  51891. typeCheck: typeCheck,
  51892. parsedTypeCheck: parsedTypeCheck,
  51893. parseType: parseType
  51894. };
  51895. }).call(undefined);
  51896. },{"./check":105,"./parse-type":107}],107:[function(require,module,exports){
  51897. "use strict";
  51898. // Generated by LiveScript 1.4.0
  51899. (function () {
  51900. var identifierRegex, tokenRegex;
  51901. identifierRegex = /[\$\w]+/;
  51902. function peek(tokens) {
  51903. var token;
  51904. token = tokens[0];
  51905. if (token == null) {
  51906. throw new Error('Unexpected end of input.');
  51907. }
  51908. return token;
  51909. }
  51910. function consumeIdent(tokens) {
  51911. var token;
  51912. token = peek(tokens);
  51913. if (!identifierRegex.test(token)) {
  51914. throw new Error("Expected text, got '" + token + "' instead.");
  51915. }
  51916. return tokens.shift();
  51917. }
  51918. function consumeOp(tokens, op) {
  51919. var token;
  51920. token = peek(tokens);
  51921. if (token !== op) {
  51922. throw new Error("Expected '" + op + "', got '" + token + "' instead.");
  51923. }
  51924. return tokens.shift();
  51925. }
  51926. function maybeConsumeOp(tokens, op) {
  51927. var token;
  51928. token = tokens[0];
  51929. if (token === op) {
  51930. return tokens.shift();
  51931. } else {
  51932. return null;
  51933. }
  51934. }
  51935. function consumeArray(tokens) {
  51936. var types;
  51937. consumeOp(tokens, '[');
  51938. if (peek(tokens) === ']') {
  51939. throw new Error("Must specify type of Array - eg. [Type], got [] instead.");
  51940. }
  51941. types = consumeTypes(tokens);
  51942. consumeOp(tokens, ']');
  51943. return {
  51944. structure: 'array',
  51945. of: types
  51946. };
  51947. }
  51948. function consumeTuple(tokens) {
  51949. var components;
  51950. components = [];
  51951. consumeOp(tokens, '(');
  51952. if (peek(tokens) === ')') {
  51953. throw new Error("Tuple must be of at least length 1 - eg. (Type), got () instead.");
  51954. }
  51955. for (;;) {
  51956. components.push(consumeTypes(tokens));
  51957. maybeConsumeOp(tokens, ',');
  51958. if (')' === peek(tokens)) {
  51959. break;
  51960. }
  51961. }
  51962. consumeOp(tokens, ')');
  51963. return {
  51964. structure: 'tuple',
  51965. of: components
  51966. };
  51967. }
  51968. function consumeFields(tokens) {
  51969. var fields, subset, ref$, key, types;
  51970. fields = {};
  51971. consumeOp(tokens, '{');
  51972. subset = false;
  51973. for (;;) {
  51974. if (maybeConsumeOp(tokens, '...')) {
  51975. subset = true;
  51976. break;
  51977. }
  51978. ref$ = consumeField(tokens), key = ref$[0], types = ref$[1];
  51979. fields[key] = types;
  51980. maybeConsumeOp(tokens, ',');
  51981. if ('}' === peek(tokens)) {
  51982. break;
  51983. }
  51984. }
  51985. consumeOp(tokens, '}');
  51986. return {
  51987. structure: 'fields',
  51988. of: fields,
  51989. subset: subset
  51990. };
  51991. }
  51992. function consumeField(tokens) {
  51993. var key, types;
  51994. key = consumeIdent(tokens);
  51995. consumeOp(tokens, ':');
  51996. types = consumeTypes(tokens);
  51997. return [key, types];
  51998. }
  51999. function maybeConsumeStructure(tokens) {
  52000. switch (tokens[0]) {
  52001. case '[':
  52002. return consumeArray(tokens);
  52003. case '(':
  52004. return consumeTuple(tokens);
  52005. case '{':
  52006. return consumeFields(tokens);
  52007. }
  52008. }
  52009. function consumeType(tokens) {
  52010. var token, wildcard, type, structure;
  52011. token = peek(tokens);
  52012. wildcard = token === '*';
  52013. if (wildcard || identifierRegex.test(token)) {
  52014. type = wildcard ? consumeOp(tokens, '*') : consumeIdent(tokens);
  52015. structure = maybeConsumeStructure(tokens);
  52016. if (structure) {
  52017. return structure.type = type, structure;
  52018. } else {
  52019. return {
  52020. type: type
  52021. };
  52022. }
  52023. } else {
  52024. structure = maybeConsumeStructure(tokens);
  52025. if (!structure) {
  52026. throw new Error("Unexpected character: " + token);
  52027. }
  52028. return structure;
  52029. }
  52030. }
  52031. function consumeTypes(tokens) {
  52032. var lookahead, types, typesSoFar, typeObj, type;
  52033. if ('::' === peek(tokens)) {
  52034. throw new Error("No comment before comment separator '::' found.");
  52035. }
  52036. lookahead = tokens[1];
  52037. if (lookahead != null && lookahead === '::') {
  52038. tokens.shift();
  52039. tokens.shift();
  52040. }
  52041. types = [];
  52042. typesSoFar = {};
  52043. if ('Maybe' === peek(tokens)) {
  52044. tokens.shift();
  52045. types = [{
  52046. type: 'Undefined'
  52047. }, {
  52048. type: 'Null'
  52049. }];
  52050. typesSoFar = {
  52051. Undefined: true,
  52052. Null: true
  52053. };
  52054. }
  52055. for (;;) {
  52056. typeObj = consumeType(tokens), type = typeObj.type;
  52057. if (!typesSoFar[type]) {
  52058. types.push(typeObj);
  52059. }
  52060. typesSoFar[type] = true;
  52061. if (!maybeConsumeOp(tokens, '|')) {
  52062. break;
  52063. }
  52064. }
  52065. return types;
  52066. }
  52067. tokenRegex = RegExp('\\.\\.\\.|::|->|' + identifierRegex.source + '|\\S', 'g');
  52068. module.exports = function (input) {
  52069. var tokens, e;
  52070. if (!input.length) {
  52071. throw new Error('No type specified.');
  52072. }
  52073. tokens = input.match(tokenRegex) || [];
  52074. if (in$('->', tokens)) {
  52075. throw new Error("Function types are not supported.\ To validate that something is a function, you may use 'Function'.");
  52076. }
  52077. try {
  52078. return consumeTypes(tokens);
  52079. } catch (e$) {
  52080. e = e$;
  52081. throw new Error(e.message + " - Remaining tokens: " + JSON.stringify(tokens) + " - Initial input: '" + input + "'");
  52082. }
  52083. };
  52084. function in$(x, xs) {
  52085. var i = -1,
  52086. l = xs.length >>> 0;
  52087. while (++i < l) {
  52088. if (x === xs[i]) return true;
  52089. }return false;
  52090. }
  52091. }).call(undefined);
  52092. },{}],108:[function(require,module,exports){
  52093. 'use strict';
  52094. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  52095. /** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
  52096. (function (global, factory) {
  52097. (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory(global.URI = global.URI || {});
  52098. })(undefined, function (exports) {
  52099. 'use strict';
  52100. function merge() {
  52101. for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
  52102. sets[_key] = arguments[_key];
  52103. }
  52104. if (sets.length > 1) {
  52105. sets[0] = sets[0].slice(0, -1);
  52106. var xl = sets.length - 1;
  52107. for (var x = 1; x < xl; ++x) {
  52108. sets[x] = sets[x].slice(1, -1);
  52109. }
  52110. sets[xl] = sets[xl].slice(1);
  52111. return sets.join('');
  52112. } else {
  52113. return sets[0];
  52114. }
  52115. }
  52116. function subexp(str) {
  52117. return "(?:" + str + ")";
  52118. }
  52119. function typeOf(o) {
  52120. return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
  52121. }
  52122. function toUpperCase(str) {
  52123. return str.toUpperCase();
  52124. }
  52125. function toArray(obj) {
  52126. return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
  52127. }
  52128. function assign(target, source) {
  52129. var obj = target;
  52130. if (source) {
  52131. for (var key in source) {
  52132. obj[key] = source[key];
  52133. }
  52134. }
  52135. return obj;
  52136. }
  52137. function buildExps(isIRI) {
  52138. var ALPHA$$ = "[A-Za-z]",
  52139. CR$ = "[\\x0D]",
  52140. DIGIT$$ = "[0-9]",
  52141. DQUOTE$$ = "[\\x22]",
  52142. HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
  52143. //case-insensitive
  52144. LF$$ = "[\\x0A]",
  52145. SP$$ = "[\\x20]",
  52146. PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
  52147. //expanded
  52148. GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
  52149. SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
  52150. RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
  52151. UCSCHAR$$ = isIRI ? '[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]' : "[]",
  52152. //subset, excludes bidi control characters
  52153. IPRIVATE$$ = isIRI ? '[\\uE000-\\uF8FF]' : "[]",
  52154. //subset
  52155. UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$),
  52156. SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
  52157. USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
  52158. DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
  52159. DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
  52160. //relaxed parsing rules
  52161. IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
  52162. H16$ = subexp(HEXDIG$$ + "{1,4}"),
  52163. LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
  52164. IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
  52165. // 6( h16 ":" ) ls32
  52166. IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
  52167. // "::" 5( h16 ":" ) ls32
  52168. IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
  52169. //[ h16 ] "::" 4( h16 ":" ) ls32
  52170. IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
  52171. //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
  52172. IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
  52173. //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
  52174. IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
  52175. //[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
  52176. IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
  52177. //[ *4( h16 ":" ) h16 ] "::" ls32
  52178. IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
  52179. //[ *5( h16 ":" ) h16 ] "::" h16
  52180. IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
  52181. //[ *6( h16 ":" ) h16 ] "::"
  52182. IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
  52183. ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
  52184. //RFC 6874
  52185. IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
  52186. //RFC 6874
  52187. IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
  52188. //RFC 6874, with relaxed parsing rules
  52189. IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
  52190. IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
  52191. //RFC 6874
  52192. REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
  52193. HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),
  52194. PORT$ = subexp(DIGIT$$ + "*"),
  52195. AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
  52196. PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
  52197. SEGMENT$ = subexp(PCHAR$ + "*"),
  52198. SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
  52199. SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
  52200. PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
  52201. PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"),
  52202. //simplified
  52203. PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$),
  52204. //simplified
  52205. PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$),
  52206. //simplified
  52207. PATH_EMPTY$ = "(?!" + PCHAR$ + ")",
  52208. PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
  52209. QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"),
  52210. FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
  52211. HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
  52212. URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
  52213. RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
  52214. RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
  52215. URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$),
  52216. ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
  52217. GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
  52218. RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
  52219. ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$",
  52220. SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
  52221. AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
  52222. return {
  52223. NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
  52224. NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  52225. NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  52226. NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  52227. NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  52228. NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
  52229. NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
  52230. ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
  52231. UNRESERVED: new RegExp(UNRESERVED$$, "g"),
  52232. OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
  52233. PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
  52234. IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
  52235. IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
  52236. };
  52237. }
  52238. var URI_PROTOCOL = buildExps(false);
  52239. var IRI_PROTOCOL = buildExps(true);
  52240. var slicedToArray = function () {
  52241. function sliceIterator(arr, i) {
  52242. var _arr = [];
  52243. var _n = true;
  52244. var _d = false;
  52245. var _e = undefined;
  52246. try {
  52247. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  52248. _arr.push(_s.value);
  52249. if (i && _arr.length === i) break;
  52250. }
  52251. } catch (err) {
  52252. _d = true;
  52253. _e = err;
  52254. } finally {
  52255. try {
  52256. if (!_n && _i["return"]) _i["return"]();
  52257. } finally {
  52258. if (_d) throw _e;
  52259. }
  52260. }
  52261. return _arr;
  52262. }
  52263. return function (arr, i) {
  52264. if (Array.isArray(arr)) {
  52265. return arr;
  52266. } else if (Symbol.iterator in Object(arr)) {
  52267. return sliceIterator(arr, i);
  52268. } else {
  52269. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  52270. }
  52271. };
  52272. }();
  52273. var toConsumableArray = function toConsumableArray(arr) {
  52274. if (Array.isArray(arr)) {
  52275. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  52276. arr2[i] = arr[i];
  52277. }return arr2;
  52278. } else {
  52279. return Array.from(arr);
  52280. }
  52281. };
  52282. /** Highest positive signed 32-bit float value */
  52283. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  52284. /** Bootstring parameters */
  52285. var base = 36;
  52286. var tMin = 1;
  52287. var tMax = 26;
  52288. var skew = 38;
  52289. var damp = 700;
  52290. var initialBias = 72;
  52291. var initialN = 128; // 0x80
  52292. var delimiter = '-'; // '\x2D'
  52293. /** Regular expressions */
  52294. var regexPunycode = /^xn--/;
  52295. var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
  52296. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  52297. /** Error messages */
  52298. var errors = {
  52299. 'overflow': 'Overflow: input needs wider integers to process',
  52300. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  52301. 'invalid-input': 'Invalid input'
  52302. };
  52303. /** Convenience shortcuts */
  52304. var baseMinusTMin = base - tMin;
  52305. var floor = Math.floor;
  52306. var stringFromCharCode = String.fromCharCode;
  52307. /*--------------------------------------------------------------------------*/
  52308. /**
  52309. * A generic error utility function.
  52310. * @private
  52311. * @param {String} type The error type.
  52312. * @returns {Error} Throws a `RangeError` with the applicable error message.
  52313. */
  52314. function error$1(type) {
  52315. throw new RangeError(errors[type]);
  52316. }
  52317. /**
  52318. * A generic `Array#map` utility function.
  52319. * @private
  52320. * @param {Array} array The array to iterate over.
  52321. * @param {Function} callback The function that gets called for every array
  52322. * item.
  52323. * @returns {Array} A new array of values returned by the callback function.
  52324. */
  52325. function map(array, fn) {
  52326. var result = [];
  52327. var length = array.length;
  52328. while (length--) {
  52329. result[length] = fn(array[length]);
  52330. }
  52331. return result;
  52332. }
  52333. /**
  52334. * A simple `Array#map`-like wrapper to work with domain name strings or email
  52335. * addresses.
  52336. * @private
  52337. * @param {String} domain The domain name or email address.
  52338. * @param {Function} callback The function that gets called for every
  52339. * character.
  52340. * @returns {Array} A new string of characters returned by the callback
  52341. * function.
  52342. */
  52343. function mapDomain(string, fn) {
  52344. var parts = string.split('@');
  52345. var result = '';
  52346. if (parts.length > 1) {
  52347. // In email addresses, only the domain name should be punycoded. Leave
  52348. // the local part (i.e. everything up to `@`) intact.
  52349. result = parts[0] + '@';
  52350. string = parts[1];
  52351. }
  52352. // Avoid `split(regex)` for IE8 compatibility. See #17.
  52353. string = string.replace(regexSeparators, '\x2E');
  52354. var labels = string.split('.');
  52355. var encoded = map(labels, fn).join('.');
  52356. return result + encoded;
  52357. }
  52358. /**
  52359. * Creates an array containing the numeric code points of each Unicode
  52360. * character in the string. While JavaScript uses UCS-2 internally,
  52361. * this function will convert a pair of surrogate halves (each of which
  52362. * UCS-2 exposes as separate characters) into a single code point,
  52363. * matching UTF-16.
  52364. * @see `punycode.ucs2.encode`
  52365. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  52366. * @memberOf punycode.ucs2
  52367. * @name decode
  52368. * @param {String} string The Unicode input string (UCS-2).
  52369. * @returns {Array} The new array of code points.
  52370. */
  52371. function ucs2decode(string) {
  52372. var output = [];
  52373. var counter = 0;
  52374. var length = string.length;
  52375. while (counter < length) {
  52376. var value = string.charCodeAt(counter++);
  52377. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  52378. // It's a high surrogate, and there is a next character.
  52379. var extra = string.charCodeAt(counter++);
  52380. if ((extra & 0xFC00) == 0xDC00) {
  52381. // Low surrogate.
  52382. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  52383. } else {
  52384. // It's an unmatched surrogate; only append this code unit, in case the
  52385. // next code unit is the high surrogate of a surrogate pair.
  52386. output.push(value);
  52387. counter--;
  52388. }
  52389. } else {
  52390. output.push(value);
  52391. }
  52392. }
  52393. return output;
  52394. }
  52395. /**
  52396. * Creates a string based on an array of numeric code points.
  52397. * @see `punycode.ucs2.decode`
  52398. * @memberOf punycode.ucs2
  52399. * @name encode
  52400. * @param {Array} codePoints The array of numeric code points.
  52401. * @returns {String} The new Unicode string (UCS-2).
  52402. */
  52403. var ucs2encode = function ucs2encode(array) {
  52404. return String.fromCodePoint.apply(String, toConsumableArray(array));
  52405. };
  52406. /**
  52407. * Converts a basic code point into a digit/integer.
  52408. * @see `digitToBasic()`
  52409. * @private
  52410. * @param {Number} codePoint The basic numeric code point value.
  52411. * @returns {Number} The numeric value of a basic code point (for use in
  52412. * representing integers) in the range `0` to `base - 1`, or `base` if
  52413. * the code point does not represent a value.
  52414. */
  52415. var basicToDigit = function basicToDigit(codePoint) {
  52416. if (codePoint - 0x30 < 0x0A) {
  52417. return codePoint - 0x16;
  52418. }
  52419. if (codePoint - 0x41 < 0x1A) {
  52420. return codePoint - 0x41;
  52421. }
  52422. if (codePoint - 0x61 < 0x1A) {
  52423. return codePoint - 0x61;
  52424. }
  52425. return base;
  52426. };
  52427. /**
  52428. * Converts a digit/integer into a basic code point.
  52429. * @see `basicToDigit()`
  52430. * @private
  52431. * @param {Number} digit The numeric value of a basic code point.
  52432. * @returns {Number} The basic code point whose value (when used for
  52433. * representing integers) is `digit`, which needs to be in the range
  52434. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  52435. * used; else, the lowercase form is used. The behavior is undefined
  52436. * if `flag` is non-zero and `digit` has no uppercase form.
  52437. */
  52438. var digitToBasic = function digitToBasic(digit, flag) {
  52439. // 0..25 map to ASCII a..z or A..Z
  52440. // 26..35 map to ASCII 0..9
  52441. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  52442. };
  52443. /**
  52444. * Bias adaptation function as per section 3.4 of RFC 3492.
  52445. * https://tools.ietf.org/html/rfc3492#section-3.4
  52446. * @private
  52447. */
  52448. var adapt = function adapt(delta, numPoints, firstTime) {
  52449. var k = 0;
  52450. delta = firstTime ? floor(delta / damp) : delta >> 1;
  52451. delta += floor(delta / numPoints);
  52452. for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
  52453. delta = floor(delta / baseMinusTMin);
  52454. }
  52455. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  52456. };
  52457. /**
  52458. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  52459. * symbols.
  52460. * @memberOf punycode
  52461. * @param {String} input The Punycode string of ASCII-only symbols.
  52462. * @returns {String} The resulting string of Unicode symbols.
  52463. */
  52464. var decode = function decode(input) {
  52465. // Don't use UCS-2.
  52466. var output = [];
  52467. var inputLength = input.length;
  52468. var i = 0;
  52469. var n = initialN;
  52470. var bias = initialBias;
  52471. // Handle the basic code points: let `basic` be the number of input code
  52472. // points before the last delimiter, or `0` if there is none, then copy
  52473. // the first basic code points to the output.
  52474. var basic = input.lastIndexOf(delimiter);
  52475. if (basic < 0) {
  52476. basic = 0;
  52477. }
  52478. for (var j = 0; j < basic; ++j) {
  52479. // if it's not a basic code point
  52480. if (input.charCodeAt(j) >= 0x80) {
  52481. error$1('not-basic');
  52482. }
  52483. output.push(input.charCodeAt(j));
  52484. }
  52485. // Main decoding loop: start just after the last delimiter if any basic code
  52486. // points were copied; start at the beginning otherwise.
  52487. for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
  52488. // `index` is the index of the next character to be consumed.
  52489. // Decode a generalized variable-length integer into `delta`,
  52490. // which gets added to `i`. The overflow checking is easier
  52491. // if we increase `i` as we go, then subtract off its starting
  52492. // value at the end to obtain `delta`.
  52493. var oldi = i;
  52494. for (var w = 1, k = base;; /* no condition */k += base) {
  52495. if (index >= inputLength) {
  52496. error$1('invalid-input');
  52497. }
  52498. var digit = basicToDigit(input.charCodeAt(index++));
  52499. if (digit >= base || digit > floor((maxInt - i) / w)) {
  52500. error$1('overflow');
  52501. }
  52502. i += digit * w;
  52503. var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  52504. if (digit < t) {
  52505. break;
  52506. }
  52507. var baseMinusT = base - t;
  52508. if (w > floor(maxInt / baseMinusT)) {
  52509. error$1('overflow');
  52510. }
  52511. w *= baseMinusT;
  52512. }
  52513. var out = output.length + 1;
  52514. bias = adapt(i - oldi, out, oldi == 0);
  52515. // `i` was supposed to wrap around from `out` to `0`,
  52516. // incrementing `n` each time, so we'll fix that now:
  52517. if (floor(i / out) > maxInt - n) {
  52518. error$1('overflow');
  52519. }
  52520. n += floor(i / out);
  52521. i %= out;
  52522. // Insert `n` at position `i` of the output.
  52523. output.splice(i++, 0, n);
  52524. }
  52525. return String.fromCodePoint.apply(String, output);
  52526. };
  52527. /**
  52528. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  52529. * Punycode string of ASCII-only symbols.
  52530. * @memberOf punycode
  52531. * @param {String} input The string of Unicode symbols.
  52532. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  52533. */
  52534. var encode = function encode(input) {
  52535. var output = [];
  52536. // Convert the input in UCS-2 to an array of Unicode code points.
  52537. input = ucs2decode(input);
  52538. // Cache the length.
  52539. var inputLength = input.length;
  52540. // Initialize the state.
  52541. var n = initialN;
  52542. var delta = 0;
  52543. var bias = initialBias;
  52544. // Handle the basic code points.
  52545. var _iteratorNormalCompletion = true;
  52546. var _didIteratorError = false;
  52547. var _iteratorError = undefined;
  52548. try {
  52549. for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  52550. var _currentValue2 = _step.value;
  52551. if (_currentValue2 < 0x80) {
  52552. output.push(stringFromCharCode(_currentValue2));
  52553. }
  52554. }
  52555. } catch (err) {
  52556. _didIteratorError = true;
  52557. _iteratorError = err;
  52558. } finally {
  52559. try {
  52560. if (!_iteratorNormalCompletion && _iterator.return) {
  52561. _iterator.return();
  52562. }
  52563. } finally {
  52564. if (_didIteratorError) {
  52565. throw _iteratorError;
  52566. }
  52567. }
  52568. }
  52569. var basicLength = output.length;
  52570. var handledCPCount = basicLength;
  52571. // `handledCPCount` is the number of code points that have been handled;
  52572. // `basicLength` is the number of basic code points.
  52573. // Finish the basic string with a delimiter unless it's empty.
  52574. if (basicLength) {
  52575. output.push(delimiter);
  52576. }
  52577. // Main encoding loop:
  52578. while (handledCPCount < inputLength) {
  52579. // All non-basic code points < n have been handled already. Find the next
  52580. // larger one:
  52581. var m = maxInt;
  52582. var _iteratorNormalCompletion2 = true;
  52583. var _didIteratorError2 = false;
  52584. var _iteratorError2 = undefined;
  52585. try {
  52586. for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  52587. var currentValue = _step2.value;
  52588. if (currentValue >= n && currentValue < m) {
  52589. m = currentValue;
  52590. }
  52591. }
  52592. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  52593. // but guard against overflow.
  52594. } catch (err) {
  52595. _didIteratorError2 = true;
  52596. _iteratorError2 = err;
  52597. } finally {
  52598. try {
  52599. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  52600. _iterator2.return();
  52601. }
  52602. } finally {
  52603. if (_didIteratorError2) {
  52604. throw _iteratorError2;
  52605. }
  52606. }
  52607. }
  52608. var handledCPCountPlusOne = handledCPCount + 1;
  52609. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  52610. error$1('overflow');
  52611. }
  52612. delta += (m - n) * handledCPCountPlusOne;
  52613. n = m;
  52614. var _iteratorNormalCompletion3 = true;
  52615. var _didIteratorError3 = false;
  52616. var _iteratorError3 = undefined;
  52617. try {
  52618. for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  52619. var _currentValue = _step3.value;
  52620. if (_currentValue < n && ++delta > maxInt) {
  52621. error$1('overflow');
  52622. }
  52623. if (_currentValue == n) {
  52624. // Represent delta as a generalized variable-length integer.
  52625. var q = delta;
  52626. for (var k = base;; /* no condition */k += base) {
  52627. var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  52628. if (q < t) {
  52629. break;
  52630. }
  52631. var qMinusT = q - t;
  52632. var baseMinusT = base - t;
  52633. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
  52634. q = floor(qMinusT / baseMinusT);
  52635. }
  52636. output.push(stringFromCharCode(digitToBasic(q, 0)));
  52637. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  52638. delta = 0;
  52639. ++handledCPCount;
  52640. }
  52641. }
  52642. } catch (err) {
  52643. _didIteratorError3 = true;
  52644. _iteratorError3 = err;
  52645. } finally {
  52646. try {
  52647. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  52648. _iterator3.return();
  52649. }
  52650. } finally {
  52651. if (_didIteratorError3) {
  52652. throw _iteratorError3;
  52653. }
  52654. }
  52655. }
  52656. ++delta;
  52657. ++n;
  52658. }
  52659. return output.join('');
  52660. };
  52661. /**
  52662. * Converts a Punycode string representing a domain name or an email address
  52663. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  52664. * it doesn't matter if you call it on a string that has already been
  52665. * converted to Unicode.
  52666. * @memberOf punycode
  52667. * @param {String} input The Punycoded domain name or email address to
  52668. * convert to Unicode.
  52669. * @returns {String} The Unicode representation of the given Punycode
  52670. * string.
  52671. */
  52672. var toUnicode = function toUnicode(input) {
  52673. return mapDomain(input, function (string) {
  52674. return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
  52675. });
  52676. };
  52677. /**
  52678. * Converts a Unicode string representing a domain name or an email address to
  52679. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  52680. * i.e. it doesn't matter if you call it with a domain that's already in
  52681. * ASCII.
  52682. * @memberOf punycode
  52683. * @param {String} input The domain name or email address to convert, as a
  52684. * Unicode string.
  52685. * @returns {String} The Punycode representation of the given domain name or
  52686. * email address.
  52687. */
  52688. var toASCII = function toASCII(input) {
  52689. return mapDomain(input, function (string) {
  52690. return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
  52691. });
  52692. };
  52693. /*--------------------------------------------------------------------------*/
  52694. /** Define the public API */
  52695. var punycode = {
  52696. /**
  52697. * A string representing the current Punycode.js version number.
  52698. * @memberOf punycode
  52699. * @type String
  52700. */
  52701. 'version': '2.1.0',
  52702. /**
  52703. * An object of methods to convert from JavaScript's internal character
  52704. * representation (UCS-2) to Unicode code points, and back.
  52705. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  52706. * @memberOf punycode
  52707. * @type Object
  52708. */
  52709. 'ucs2': {
  52710. 'decode': ucs2decode,
  52711. 'encode': ucs2encode
  52712. },
  52713. 'decode': decode,
  52714. 'encode': encode,
  52715. 'toASCII': toASCII,
  52716. 'toUnicode': toUnicode
  52717. };
  52718. /**
  52719. * URI.js
  52720. *
  52721. * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
  52722. * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
  52723. * @see http://github.com/garycourt/uri-js
  52724. */
  52725. /**
  52726. * Copyright 2011 Gary Court. All rights reserved.
  52727. *
  52728. * Redistribution and use in source and binary forms, with or without modification, are
  52729. * permitted provided that the following conditions are met:
  52730. *
  52731. * 1. Redistributions of source code must retain the above copyright notice, this list of
  52732. * conditions and the following disclaimer.
  52733. *
  52734. * 2. Redistributions in binary form must reproduce the above copyright notice, this list
  52735. * of conditions and the following disclaimer in the documentation and/or other materials
  52736. * provided with the distribution.
  52737. *
  52738. * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
  52739. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  52740. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
  52741. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  52742. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  52743. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  52744. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  52745. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  52746. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  52747. *
  52748. * The views and conclusions contained in the software and documentation are those of the
  52749. * authors and should not be interpreted as representing official policies, either expressed
  52750. * or implied, of Gary Court.
  52751. */
  52752. var SCHEMES = {};
  52753. function pctEncChar(chr) {
  52754. var c = chr.charCodeAt(0);
  52755. var e = void 0;
  52756. if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
  52757. return e;
  52758. }
  52759. function pctDecChars(str) {
  52760. var newStr = "";
  52761. var i = 0;
  52762. var il = str.length;
  52763. while (i < il) {
  52764. var c = parseInt(str.substr(i + 1, 2), 16);
  52765. if (c < 128) {
  52766. newStr += String.fromCharCode(c);
  52767. i += 3;
  52768. } else if (c >= 194 && c < 224) {
  52769. if (il - i >= 6) {
  52770. var c2 = parseInt(str.substr(i + 4, 2), 16);
  52771. newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
  52772. } else {
  52773. newStr += str.substr(i, 6);
  52774. }
  52775. i += 6;
  52776. } else if (c >= 224) {
  52777. if (il - i >= 9) {
  52778. var _c = parseInt(str.substr(i + 4, 2), 16);
  52779. var c3 = parseInt(str.substr(i + 7, 2), 16);
  52780. newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
  52781. } else {
  52782. newStr += str.substr(i, 9);
  52783. }
  52784. i += 9;
  52785. } else {
  52786. newStr += str.substr(i, 3);
  52787. i += 3;
  52788. }
  52789. }
  52790. return newStr;
  52791. }
  52792. function _normalizeComponentEncoding(components, protocol) {
  52793. function decodeUnreserved(str) {
  52794. var decStr = pctDecChars(str);
  52795. return !decStr.match(protocol.UNRESERVED) ? str : decStr;
  52796. }
  52797. if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
  52798. if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  52799. if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  52800. if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  52801. if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  52802. if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
  52803. return components;
  52804. }
  52805. function _stripLeadingZeros(str) {
  52806. return str.replace(/^0*(.*)/, "$1") || "0";
  52807. }
  52808. function _normalizeIPv4(host, protocol) {
  52809. var matches = host.match(protocol.IPV4ADDRESS) || [];
  52810. var _matches = slicedToArray(matches, 2),
  52811. address = _matches[1];
  52812. if (address) {
  52813. return address.split(".").map(_stripLeadingZeros).join(".");
  52814. } else {
  52815. return host;
  52816. }
  52817. }
  52818. function _normalizeIPv6(host, protocol) {
  52819. var matches = host.match(protocol.IPV6ADDRESS) || [];
  52820. var _matches2 = slicedToArray(matches, 3),
  52821. address = _matches2[1],
  52822. zone = _matches2[2];
  52823. if (address) {
  52824. var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
  52825. _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
  52826. last = _address$toLowerCase$2[0],
  52827. first = _address$toLowerCase$2[1];
  52828. var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
  52829. var lastFields = last.split(":").map(_stripLeadingZeros);
  52830. var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
  52831. var fieldCount = isLastFieldIPv4Address ? 7 : 8;
  52832. var lastFieldsStart = lastFields.length - fieldCount;
  52833. var fields = Array(fieldCount);
  52834. for (var x = 0; x < fieldCount; ++x) {
  52835. fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
  52836. }
  52837. if (isLastFieldIPv4Address) {
  52838. fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
  52839. }
  52840. var allZeroFields = fields.reduce(function (acc, field, index) {
  52841. if (!field || field === "0") {
  52842. var lastLongest = acc[acc.length - 1];
  52843. if (lastLongest && lastLongest.index + lastLongest.length === index) {
  52844. lastLongest.length++;
  52845. } else {
  52846. acc.push({ index: index, length: 1 });
  52847. }
  52848. }
  52849. return acc;
  52850. }, []);
  52851. var longestZeroFields = allZeroFields.sort(function (a, b) {
  52852. return b.length - a.length;
  52853. })[0];
  52854. var newHost = void 0;
  52855. if (longestZeroFields && longestZeroFields.length > 1) {
  52856. var newFirst = fields.slice(0, longestZeroFields.index);
  52857. var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
  52858. newHost = newFirst.join(":") + "::" + newLast.join(":");
  52859. } else {
  52860. newHost = fields.join(":");
  52861. }
  52862. if (zone) {
  52863. newHost += "%" + zone;
  52864. }
  52865. return newHost;
  52866. } else {
  52867. return host;
  52868. }
  52869. }
  52870. var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
  52871. var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
  52872. function parse(uriString) {
  52873. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  52874. var components = {};
  52875. var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
  52876. if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
  52877. var matches = uriString.match(URI_PARSE);
  52878. if (matches) {
  52879. if (NO_MATCH_IS_UNDEFINED) {
  52880. //store each component
  52881. components.scheme = matches[1];
  52882. components.userinfo = matches[3];
  52883. components.host = matches[4];
  52884. components.port = parseInt(matches[5], 10);
  52885. components.path = matches[6] || "";
  52886. components.query = matches[7];
  52887. components.fragment = matches[8];
  52888. //fix port number
  52889. if (isNaN(components.port)) {
  52890. components.port = matches[5];
  52891. }
  52892. } else {
  52893. //IE FIX for improper RegExp matching
  52894. //store each component
  52895. components.scheme = matches[1] || undefined;
  52896. components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
  52897. components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
  52898. components.port = parseInt(matches[5], 10);
  52899. components.path = matches[6] || "";
  52900. components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
  52901. components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined;
  52902. //fix port number
  52903. if (isNaN(components.port)) {
  52904. components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
  52905. }
  52906. }
  52907. if (components.host) {
  52908. //normalize IP hosts
  52909. components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
  52910. }
  52911. //determine reference type
  52912. if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
  52913. components.reference = "same-document";
  52914. } else if (components.scheme === undefined) {
  52915. components.reference = "relative";
  52916. } else if (components.fragment === undefined) {
  52917. components.reference = "absolute";
  52918. } else {
  52919. components.reference = "uri";
  52920. }
  52921. //check for reference errors
  52922. if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
  52923. components.error = components.error || "URI is not a " + options.reference + " reference.";
  52924. }
  52925. //find scheme handler
  52926. var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
  52927. //check if scheme can't handle IRIs
  52928. if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
  52929. //if host component is a domain name
  52930. if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
  52931. //convert Unicode IDN -> ASCII IDN
  52932. try {
  52933. components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
  52934. } catch (e) {
  52935. components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
  52936. }
  52937. }
  52938. //convert IRI -> URI
  52939. _normalizeComponentEncoding(components, URI_PROTOCOL);
  52940. } else {
  52941. //normalize encodings
  52942. _normalizeComponentEncoding(components, protocol);
  52943. }
  52944. //perform scheme specific parsing
  52945. if (schemeHandler && schemeHandler.parse) {
  52946. schemeHandler.parse(components, options);
  52947. }
  52948. } else {
  52949. components.error = components.error || "URI can not be parsed.";
  52950. }
  52951. return components;
  52952. }
  52953. function _recomposeAuthority(components, options) {
  52954. var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
  52955. var uriTokens = [];
  52956. if (components.userinfo !== undefined) {
  52957. uriTokens.push(components.userinfo);
  52958. uriTokens.push("@");
  52959. }
  52960. if (components.host !== undefined) {
  52961. //normalize IP hosts, add brackets and escape zone separator for IPv6
  52962. uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
  52963. return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
  52964. }));
  52965. }
  52966. if (typeof components.port === "number") {
  52967. uriTokens.push(":");
  52968. uriTokens.push(components.port.toString(10));
  52969. }
  52970. return uriTokens.length ? uriTokens.join("") : undefined;
  52971. }
  52972. var RDS1 = /^\.\.?\//;
  52973. var RDS2 = /^\/\.(\/|$)/;
  52974. var RDS3 = /^\/\.\.(\/|$)/;
  52975. var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
  52976. function removeDotSegments(input) {
  52977. var output = [];
  52978. while (input.length) {
  52979. if (input.match(RDS1)) {
  52980. input = input.replace(RDS1, "");
  52981. } else if (input.match(RDS2)) {
  52982. input = input.replace(RDS2, "/");
  52983. } else if (input.match(RDS3)) {
  52984. input = input.replace(RDS3, "/");
  52985. output.pop();
  52986. } else if (input === "." || input === "..") {
  52987. input = "";
  52988. } else {
  52989. var im = input.match(RDS5);
  52990. if (im) {
  52991. var s = im[0];
  52992. input = input.slice(s.length);
  52993. output.push(s);
  52994. } else {
  52995. throw new Error("Unexpected dot segment condition");
  52996. }
  52997. }
  52998. }
  52999. return output.join("");
  53000. }
  53001. function serialize(components) {
  53002. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  53003. var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
  53004. var uriTokens = [];
  53005. //find scheme handler
  53006. var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
  53007. //perform scheme specific serialization
  53008. if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
  53009. if (components.host) {
  53010. //if host component is an IPv6 address
  53011. if (protocol.IPV6ADDRESS.test(components.host)) {}
  53012. //TODO: normalize IPv6 address as per RFC 5952
  53013. //if host component is a domain name
  53014. else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
  53015. //convert IDN via punycode
  53016. try {
  53017. components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
  53018. } catch (e) {
  53019. components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
  53020. }
  53021. }
  53022. }
  53023. //normalize encoding
  53024. _normalizeComponentEncoding(components, protocol);
  53025. if (options.reference !== "suffix" && components.scheme) {
  53026. uriTokens.push(components.scheme);
  53027. uriTokens.push(":");
  53028. }
  53029. var authority = _recomposeAuthority(components, options);
  53030. if (authority !== undefined) {
  53031. if (options.reference !== "suffix") {
  53032. uriTokens.push("//");
  53033. }
  53034. uriTokens.push(authority);
  53035. if (components.path && components.path.charAt(0) !== "/") {
  53036. uriTokens.push("/");
  53037. }
  53038. }
  53039. if (components.path !== undefined) {
  53040. var s = components.path;
  53041. if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
  53042. s = removeDotSegments(s);
  53043. }
  53044. if (authority === undefined) {
  53045. s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
  53046. }
  53047. uriTokens.push(s);
  53048. }
  53049. if (components.query !== undefined) {
  53050. uriTokens.push("?");
  53051. uriTokens.push(components.query);
  53052. }
  53053. if (components.fragment !== undefined) {
  53054. uriTokens.push("#");
  53055. uriTokens.push(components.fragment);
  53056. }
  53057. return uriTokens.join(""); //merge tokens into a string
  53058. }
  53059. function resolveComponents(base, relative) {
  53060. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  53061. var skipNormalization = arguments[3];
  53062. var target = {};
  53063. if (!skipNormalization) {
  53064. base = parse(serialize(base, options), options); //normalize base components
  53065. relative = parse(serialize(relative, options), options); //normalize relative components
  53066. }
  53067. options = options || {};
  53068. if (!options.tolerant && relative.scheme) {
  53069. target.scheme = relative.scheme;
  53070. //target.authority = relative.authority;
  53071. target.userinfo = relative.userinfo;
  53072. target.host = relative.host;
  53073. target.port = relative.port;
  53074. target.path = removeDotSegments(relative.path || "");
  53075. target.query = relative.query;
  53076. } else {
  53077. if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
  53078. //target.authority = relative.authority;
  53079. target.userinfo = relative.userinfo;
  53080. target.host = relative.host;
  53081. target.port = relative.port;
  53082. target.path = removeDotSegments(relative.path || "");
  53083. target.query = relative.query;
  53084. } else {
  53085. if (!relative.path) {
  53086. target.path = base.path;
  53087. if (relative.query !== undefined) {
  53088. target.query = relative.query;
  53089. } else {
  53090. target.query = base.query;
  53091. }
  53092. } else {
  53093. if (relative.path.charAt(0) === "/") {
  53094. target.path = removeDotSegments(relative.path);
  53095. } else {
  53096. if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
  53097. target.path = "/" + relative.path;
  53098. } else if (!base.path) {
  53099. target.path = relative.path;
  53100. } else {
  53101. target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
  53102. }
  53103. target.path = removeDotSegments(target.path);
  53104. }
  53105. target.query = relative.query;
  53106. }
  53107. //target.authority = base.authority;
  53108. target.userinfo = base.userinfo;
  53109. target.host = base.host;
  53110. target.port = base.port;
  53111. }
  53112. target.scheme = base.scheme;
  53113. }
  53114. target.fragment = relative.fragment;
  53115. return target;
  53116. }
  53117. function resolve(baseURI, relativeURI, options) {
  53118. var schemelessOptions = assign({ scheme: 'null' }, options);
  53119. return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
  53120. }
  53121. function normalize(uri, options) {
  53122. if (typeof uri === "string") {
  53123. uri = serialize(parse(uri, options), options);
  53124. } else if (typeOf(uri) === "object") {
  53125. uri = parse(serialize(uri, options), options);
  53126. }
  53127. return uri;
  53128. }
  53129. function equal(uriA, uriB, options) {
  53130. if (typeof uriA === "string") {
  53131. uriA = serialize(parse(uriA, options), options);
  53132. } else if (typeOf(uriA) === "object") {
  53133. uriA = serialize(uriA, options);
  53134. }
  53135. if (typeof uriB === "string") {
  53136. uriB = serialize(parse(uriB, options), options);
  53137. } else if (typeOf(uriB) === "object") {
  53138. uriB = serialize(uriB, options);
  53139. }
  53140. return uriA === uriB;
  53141. }
  53142. function escapeComponent(str, options) {
  53143. return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
  53144. }
  53145. function unescapeComponent(str, options) {
  53146. return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
  53147. }
  53148. var handler = {
  53149. scheme: "http",
  53150. domainHost: true,
  53151. parse: function parse(components, options) {
  53152. //report missing host
  53153. if (!components.host) {
  53154. components.error = components.error || "HTTP URIs must have a host.";
  53155. }
  53156. return components;
  53157. },
  53158. serialize: function serialize(components, options) {
  53159. //normalize the default port
  53160. if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") {
  53161. components.port = undefined;
  53162. }
  53163. //normalize the empty path
  53164. if (!components.path) {
  53165. components.path = "/";
  53166. }
  53167. //NOTE: We do not parse query strings for HTTP URIs
  53168. //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
  53169. //and not the HTTP spec.
  53170. return components;
  53171. }
  53172. };
  53173. var handler$1 = {
  53174. scheme: "https",
  53175. domainHost: handler.domainHost,
  53176. parse: handler.parse,
  53177. serialize: handler.serialize
  53178. };
  53179. var O = {};
  53180. var isIRI = true;
  53181. //RFC 3986
  53182. var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? '\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF' : "") + "]";
  53183. var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
  53184. var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
  53185. //RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
  53186. //const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
  53187. //const WSP$$ = "[\\x20\\x09]";
  53188. //const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127)
  53189. //const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext
  53190. //const VCHAR$$ = "[\\x21-\\x7E]";
  53191. //const WSP$$ = "[\\x20\\x09]";
  53192. //const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext
  53193. //const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
  53194. //const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
  53195. //const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
  53196. var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
  53197. var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
  53198. var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
  53199. var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
  53200. var UNRESERVED = new RegExp(UNRESERVED$$, "g");
  53201. var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
  53202. var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
  53203. var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
  53204. var NOT_HFVALUE = NOT_HFNAME;
  53205. function decodeUnreserved(str) {
  53206. var decStr = pctDecChars(str);
  53207. return !decStr.match(UNRESERVED) ? str : decStr;
  53208. }
  53209. var handler$2 = {
  53210. scheme: "mailto",
  53211. parse: function parse$$1(components, options) {
  53212. var mailtoComponents = components;
  53213. var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
  53214. mailtoComponents.path = undefined;
  53215. if (mailtoComponents.query) {
  53216. var unknownHeaders = false;
  53217. var headers = {};
  53218. var hfields = mailtoComponents.query.split("&");
  53219. for (var x = 0, xl = hfields.length; x < xl; ++x) {
  53220. var hfield = hfields[x].split("=");
  53221. switch (hfield[0]) {
  53222. case "to":
  53223. var toAddrs = hfield[1].split(",");
  53224. for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
  53225. to.push(toAddrs[_x]);
  53226. }
  53227. break;
  53228. case "subject":
  53229. mailtoComponents.subject = unescapeComponent(hfield[1], options);
  53230. break;
  53231. case "body":
  53232. mailtoComponents.body = unescapeComponent(hfield[1], options);
  53233. break;
  53234. default:
  53235. unknownHeaders = true;
  53236. headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
  53237. break;
  53238. }
  53239. }
  53240. if (unknownHeaders) mailtoComponents.headers = headers;
  53241. }
  53242. mailtoComponents.query = undefined;
  53243. for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
  53244. var addr = to[_x2].split("@");
  53245. addr[0] = unescapeComponent(addr[0]);
  53246. if (!options.unicodeSupport) {
  53247. //convert Unicode IDN -> ASCII IDN
  53248. try {
  53249. addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
  53250. } catch (e) {
  53251. mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
  53252. }
  53253. } else {
  53254. addr[1] = unescapeComponent(addr[1], options).toLowerCase();
  53255. }
  53256. to[_x2] = addr.join("@");
  53257. }
  53258. return mailtoComponents;
  53259. },
  53260. serialize: function serialize$$1(mailtoComponents, options) {
  53261. var components = mailtoComponents;
  53262. var to = toArray(mailtoComponents.to);
  53263. if (to) {
  53264. for (var x = 0, xl = to.length; x < xl; ++x) {
  53265. var toAddr = String(to[x]);
  53266. var atIdx = toAddr.lastIndexOf("@");
  53267. var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
  53268. var domain = toAddr.slice(atIdx + 1);
  53269. //convert IDN via punycode
  53270. try {
  53271. domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
  53272. } catch (e) {
  53273. components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
  53274. }
  53275. to[x] = localPart + "@" + domain;
  53276. }
  53277. components.path = to.join(",");
  53278. }
  53279. var headers = mailtoComponents.headers = mailtoComponents.headers || {};
  53280. if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
  53281. if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
  53282. var fields = [];
  53283. for (var name in headers) {
  53284. if (headers[name] !== O[name]) {
  53285. fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
  53286. }
  53287. }
  53288. if (fields.length) {
  53289. components.query = fields.join("&");
  53290. }
  53291. return components;
  53292. }
  53293. };
  53294. var URN_PARSE = /^([^\:]+)\:(.*)/;
  53295. //RFC 2141
  53296. var handler$3 = {
  53297. scheme: "urn",
  53298. parse: function parse$$1(components, options) {
  53299. var matches = components.path && components.path.match(URN_PARSE);
  53300. var urnComponents = components;
  53301. if (matches) {
  53302. var scheme = options.scheme || urnComponents.scheme || "urn";
  53303. var nid = matches[1].toLowerCase();
  53304. var nss = matches[2];
  53305. var urnScheme = scheme + ":" + (options.nid || nid);
  53306. var schemeHandler = SCHEMES[urnScheme];
  53307. urnComponents.nid = nid;
  53308. urnComponents.nss = nss;
  53309. urnComponents.path = undefined;
  53310. if (schemeHandler) {
  53311. urnComponents = schemeHandler.parse(urnComponents, options);
  53312. }
  53313. } else {
  53314. urnComponents.error = urnComponents.error || "URN can not be parsed.";
  53315. }
  53316. return urnComponents;
  53317. },
  53318. serialize: function serialize$$1(urnComponents, options) {
  53319. var scheme = options.scheme || urnComponents.scheme || "urn";
  53320. var nid = urnComponents.nid;
  53321. var urnScheme = scheme + ":" + (options.nid || nid);
  53322. var schemeHandler = SCHEMES[urnScheme];
  53323. if (schemeHandler) {
  53324. urnComponents = schemeHandler.serialize(urnComponents, options);
  53325. }
  53326. var uriComponents = urnComponents;
  53327. var nss = urnComponents.nss;
  53328. uriComponents.path = (nid || options.nid) + ":" + nss;
  53329. return uriComponents;
  53330. }
  53331. };
  53332. var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
  53333. //RFC 4122
  53334. var handler$4 = {
  53335. scheme: "urn:uuid",
  53336. parse: function parse(urnComponents, options) {
  53337. var uuidComponents = urnComponents;
  53338. uuidComponents.uuid = uuidComponents.nss;
  53339. uuidComponents.nss = undefined;
  53340. if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
  53341. uuidComponents.error = uuidComponents.error || "UUID is not valid.";
  53342. }
  53343. return uuidComponents;
  53344. },
  53345. serialize: function serialize(uuidComponents, options) {
  53346. var urnComponents = uuidComponents;
  53347. //normalize UUID
  53348. urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
  53349. return urnComponents;
  53350. }
  53351. };
  53352. SCHEMES[handler.scheme] = handler;
  53353. SCHEMES[handler$1.scheme] = handler$1;
  53354. SCHEMES[handler$2.scheme] = handler$2;
  53355. SCHEMES[handler$3.scheme] = handler$3;
  53356. SCHEMES[handler$4.scheme] = handler$4;
  53357. exports.SCHEMES = SCHEMES;
  53358. exports.pctEncChar = pctEncChar;
  53359. exports.pctDecChars = pctDecChars;
  53360. exports.parse = parse;
  53361. exports.removeDotSegments = removeDotSegments;
  53362. exports.serialize = serialize;
  53363. exports.resolveComponents = resolveComponents;
  53364. exports.resolve = resolve;
  53365. exports.normalize = normalize;
  53366. exports.equal = equal;
  53367. exports.escapeComponent = escapeComponent;
  53368. exports.unescapeComponent = unescapeComponent;
  53369. Object.defineProperty(exports, '__esModule', { value: true });
  53370. });
  53371. },{}],109:[function(require,module,exports){
  53372. arguments[4][48][0].apply(exports,arguments)
  53373. },{"dup":48}],110:[function(require,module,exports){
  53374. arguments[4][49][0].apply(exports,arguments)
  53375. },{"./support/isBuffer":109,"_process":103,"dup":49,"inherits":87}],111:[function(require,module,exports){
  53376. module.exports={
  53377. "name": "eslint",
  53378. "version": "5.11.1",
  53379. "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
  53380. "description": "An AST-based pattern checker for JavaScript.",
  53381. "bin": {
  53382. "eslint": "./bin/eslint.js"
  53383. },
  53384. "main": "./lib/api.js",
  53385. "scripts": {
  53386. "test": "node Makefile.js test",
  53387. "lint": "node Makefile.js lint",
  53388. "fuzz": "node Makefile.js fuzz",
  53389. "generate-release": "node Makefile.js generateRelease",
  53390. "generate-alpharelease": "node Makefile.js generatePrerelease -- alpha",
  53391. "generate-betarelease": "node Makefile.js generatePrerelease -- beta",
  53392. "generate-rcrelease": "node Makefile.js generatePrerelease -- rc",
  53393. "publish-release": "node Makefile.js publishRelease",
  53394. "docs": "node Makefile.js docs",
  53395. "gensite": "node Makefile.js gensite",
  53396. "browserify": "node Makefile.js browserify",
  53397. "perf": "node Makefile.js perf",
  53398. "profile": "beefy tests/bench/bench.js --open -- -t brfs -t ./tests/bench/xform-rules.js -r espree",
  53399. "coveralls": "cat ./coverage/lcov.info | coveralls"
  53400. },
  53401. "files": [
  53402. "LICENSE",
  53403. "README.md",
  53404. "bin",
  53405. "conf",
  53406. "lib",
  53407. "messages"
  53408. ],
  53409. "repository": "eslint/eslint",
  53410. "homepage": "https://eslint.org",
  53411. "bugs": "https://github.com/eslint/eslint/issues/",
  53412. "dependencies": {
  53413. "@babel/code-frame": "^7.0.0",
  53414. "ajv": "^6.5.3",
  53415. "chalk": "^2.1.0",
  53416. "cross-spawn": "^6.0.5",
  53417. "debug": "^4.0.1",
  53418. "doctrine": "^2.1.0",
  53419. "eslint-scope": "^4.0.0",
  53420. "eslint-utils": "^1.3.1",
  53421. "eslint-visitor-keys": "^1.0.0",
  53422. "espree": "^5.0.0",
  53423. "esquery": "^1.0.1",
  53424. "esutils": "^2.0.2",
  53425. "file-entry-cache": "^2.0.0",
  53426. "functional-red-black-tree": "^1.0.1",
  53427. "glob": "^7.1.2",
  53428. "globals": "^11.7.0",
  53429. "ignore": "^4.0.6",
  53430. "imurmurhash": "^0.1.4",
  53431. "inquirer": "^6.1.0",
  53432. "js-yaml": "^3.12.0",
  53433. "json-stable-stringify-without-jsonify": "^1.0.1",
  53434. "levn": "^0.3.0",
  53435. "lodash": "^4.17.5",
  53436. "minimatch": "^3.0.4",
  53437. "mkdirp": "^0.5.1",
  53438. "natural-compare": "^1.4.0",
  53439. "optionator": "^0.8.2",
  53440. "path-is-inside": "^1.0.2",
  53441. "pluralize": "^7.0.0",
  53442. "progress": "^2.0.0",
  53443. "regexpp": "^2.0.1",
  53444. "require-uncached": "^1.0.3",
  53445. "semver": "^5.5.1",
  53446. "strip-ansi": "^4.0.0",
  53447. "strip-json-comments": "^2.0.1",
  53448. "table": "^5.0.2",
  53449. "text-table": "^0.2.0"
  53450. },
  53451. "devDependencies": {
  53452. "babel-core": "^6.26.3",
  53453. "babel-polyfill": "^6.26.0",
  53454. "babel-preset-es2015": "^6.24.1",
  53455. "babelify": "^8.0.0",
  53456. "beefy": "^2.1.8",
  53457. "brfs": "^2.0.0",
  53458. "browserify": "^16.2.2",
  53459. "chai": "^4.0.1",
  53460. "cheerio": "^0.22.0",
  53461. "coveralls": "^3.0.1",
  53462. "dateformat": "^3.0.3",
  53463. "ejs": "^2.6.1",
  53464. "eslint-plugin-eslint-plugin": "^1.4.1",
  53465. "eslint-plugin-node": "^8.0.0",
  53466. "eslint-plugin-rulesdir": "^0.1.0",
  53467. "eslint-release": "^1.2.0",
  53468. "eslint-rule-composer": "^0.3.0",
  53469. "eslump": "^1.6.2",
  53470. "esprima": "^4.0.1",
  53471. "istanbul": "^0.4.5",
  53472. "jsdoc": "^3.5.5",
  53473. "karma": "^3.0.0",
  53474. "karma-babel-preprocessor": "^7.0.0",
  53475. "karma-mocha": "^1.3.0",
  53476. "karma-mocha-reporter": "^2.2.3",
  53477. "karma-phantomjs-launcher": "^1.0.4",
  53478. "leche": "^2.2.3",
  53479. "load-perf": "^0.2.0",
  53480. "markdownlint": "^0.11.0",
  53481. "mocha": "^5.0.5",
  53482. "mock-fs": "^4.6.0",
  53483. "npm-license": "^0.3.3",
  53484. "phantomjs-prebuilt": "^2.1.16",
  53485. "proxyquire": "^2.0.1",
  53486. "shelljs": "^0.8.2",
  53487. "sinon": "^3.3.0",
  53488. "temp": "^0.8.3",
  53489. "through": "^2.3.8"
  53490. },
  53491. "keywords": [
  53492. "ast",
  53493. "lint",
  53494. "javascript",
  53495. "ecmascript",
  53496. "espree"
  53497. ],
  53498. "license": "MIT",
  53499. "engines": {
  53500. "node": "^6.14.0 || ^8.10.0 || >=9.10.0"
  53501. }
  53502. }
  53503. },{}],112:[function(require,module,exports){
  53504. /**
  53505. * @fileoverview A class of the code path analyzer.
  53506. * @author Toru Nagashima
  53507. */
  53508. "use strict";
  53509. //------------------------------------------------------------------------------
  53510. // Requirements
  53511. //------------------------------------------------------------------------------
  53512. 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; }; }();
  53513. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  53514. var assert = require("assert"),
  53515. CodePath = require("./code-path"),
  53516. CodePathSegment = require("./code-path-segment"),
  53517. IdGenerator = require("./id-generator"),
  53518. debug = require("./debug-helpers"),
  53519. astUtils = require("../util/ast-utils");
  53520. //------------------------------------------------------------------------------
  53521. // Helpers
  53522. //------------------------------------------------------------------------------
  53523. /**
  53524. * Checks whether or not a given node is a `case` node (not `default` node).
  53525. *
  53526. * @param {ASTNode} node - A `SwitchCase` node to check.
  53527. * @returns {boolean} `true` if the node is a `case` node (not `default` node).
  53528. */
  53529. function isCaseNode(node) {
  53530. return Boolean(node.test);
  53531. }
  53532. /**
  53533. * Checks whether the given logical operator is taken into account for the code
  53534. * path analysis.
  53535. *
  53536. * @param {string} operator - The operator found in the LogicalExpression node
  53537. * @returns {boolean} `true` if the operator is "&&" or "||"
  53538. */
  53539. function isHandledLogicalOperator(operator) {
  53540. return operator === "&&" || operator === "||";
  53541. }
  53542. /**
  53543. * Checks whether or not a given logical expression node goes different path
  53544. * between the `true` case and the `false` case.
  53545. *
  53546. * @param {ASTNode} node - A node to check.
  53547. * @returns {boolean} `true` if the node is a test of a choice statement.
  53548. */
  53549. function isForkingByTrueOrFalse(node) {
  53550. var parent = node.parent;
  53551. switch (parent.type) {
  53552. case "ConditionalExpression":
  53553. case "IfStatement":
  53554. case "WhileStatement":
  53555. case "DoWhileStatement":
  53556. case "ForStatement":
  53557. return parent.test === node;
  53558. case "LogicalExpression":
  53559. return isHandledLogicalOperator(parent.operator);
  53560. default:
  53561. return false;
  53562. }
  53563. }
  53564. /**
  53565. * Gets the boolean value of a given literal node.
  53566. *
  53567. * This is used to detect infinity loops (e.g. `while (true) {}`).
  53568. * Statements preceded by an infinity loop are unreachable if the loop didn't
  53569. * have any `break` statement.
  53570. *
  53571. * @param {ASTNode} node - A node to get.
  53572. * @returns {boolean|undefined} a boolean value if the node is a Literal node,
  53573. * otherwise `undefined`.
  53574. */
  53575. function getBooleanValueIfSimpleConstant(node) {
  53576. if (node.type === "Literal") {
  53577. return Boolean(node.value);
  53578. }
  53579. return void 0;
  53580. }
  53581. /**
  53582. * Checks that a given identifier node is a reference or not.
  53583. *
  53584. * This is used to detect the first throwable node in a `try` block.
  53585. *
  53586. * @param {ASTNode} node - An Identifier node to check.
  53587. * @returns {boolean} `true` if the node is a reference.
  53588. */
  53589. function isIdentifierReference(node) {
  53590. var parent = node.parent;
  53591. switch (parent.type) {
  53592. case "LabeledStatement":
  53593. case "BreakStatement":
  53594. case "ContinueStatement":
  53595. case "ArrayPattern":
  53596. case "RestElement":
  53597. case "ImportSpecifier":
  53598. case "ImportDefaultSpecifier":
  53599. case "ImportNamespaceSpecifier":
  53600. case "CatchClause":
  53601. return false;
  53602. case "FunctionDeclaration":
  53603. case "FunctionExpression":
  53604. case "ArrowFunctionExpression":
  53605. case "ClassDeclaration":
  53606. case "ClassExpression":
  53607. case "VariableDeclarator":
  53608. return parent.id !== node;
  53609. case "Property":
  53610. case "MethodDefinition":
  53611. return parent.key !== node || parent.computed || parent.shorthand;
  53612. case "AssignmentPattern":
  53613. return parent.key !== node;
  53614. default:
  53615. return true;
  53616. }
  53617. }
  53618. /**
  53619. * Updates the current segment with the head segment.
  53620. * This is similar to local branches and tracking branches of git.
  53621. *
  53622. * To separate the current and the head is in order to not make useless segments.
  53623. *
  53624. * In this process, both "onCodePathSegmentStart" and "onCodePathSegmentEnd"
  53625. * events are fired.
  53626. *
  53627. * @param {CodePathAnalyzer} analyzer - The instance.
  53628. * @param {ASTNode} node - The current AST node.
  53629. * @returns {void}
  53630. */
  53631. function forwardCurrentToHead(analyzer, node) {
  53632. var codePath = analyzer.codePath;
  53633. var state = CodePath.getState(codePath);
  53634. var currentSegments = state.currentSegments;
  53635. var headSegments = state.headSegments;
  53636. var end = Math.max(currentSegments.length, headSegments.length);
  53637. var i = void 0,
  53638. currentSegment = void 0,
  53639. headSegment = void 0;
  53640. // Fires leaving events.
  53641. for (i = 0; i < end; ++i) {
  53642. currentSegment = currentSegments[i];
  53643. headSegment = headSegments[i];
  53644. if (currentSegment !== headSegment && currentSegment) {
  53645. debug.dump("onCodePathSegmentEnd " + currentSegment.id);
  53646. if (currentSegment.reachable) {
  53647. analyzer.emitter.emit("onCodePathSegmentEnd", currentSegment, node);
  53648. }
  53649. }
  53650. }
  53651. // Update state.
  53652. state.currentSegments = headSegments;
  53653. // Fires entering events.
  53654. for (i = 0; i < end; ++i) {
  53655. currentSegment = currentSegments[i];
  53656. headSegment = headSegments[i];
  53657. if (currentSegment !== headSegment && headSegment) {
  53658. debug.dump("onCodePathSegmentStart " + headSegment.id);
  53659. CodePathSegment.markUsed(headSegment);
  53660. if (headSegment.reachable) {
  53661. analyzer.emitter.emit("onCodePathSegmentStart", headSegment, node);
  53662. }
  53663. }
  53664. }
  53665. }
  53666. /**
  53667. * Updates the current segment with empty.
  53668. * This is called at the last of functions or the program.
  53669. *
  53670. * @param {CodePathAnalyzer} analyzer - The instance.
  53671. * @param {ASTNode} node - The current AST node.
  53672. * @returns {void}
  53673. */
  53674. function leaveFromCurrentSegment(analyzer, node) {
  53675. var state = CodePath.getState(analyzer.codePath);
  53676. var currentSegments = state.currentSegments;
  53677. for (var i = 0; i < currentSegments.length; ++i) {
  53678. var currentSegment = currentSegments[i];
  53679. debug.dump("onCodePathSegmentEnd " + currentSegment.id);
  53680. if (currentSegment.reachable) {
  53681. analyzer.emitter.emit("onCodePathSegmentEnd", currentSegment, node);
  53682. }
  53683. }
  53684. state.currentSegments = [];
  53685. }
  53686. /**
  53687. * Updates the code path due to the position of a given node in the parent node
  53688. * thereof.
  53689. *
  53690. * For example, if the node is `parent.consequent`, this creates a fork from the
  53691. * current path.
  53692. *
  53693. * @param {CodePathAnalyzer} analyzer - The instance.
  53694. * @param {ASTNode} node - The current AST node.
  53695. * @returns {void}
  53696. */
  53697. function preprocess(analyzer, node) {
  53698. var codePath = analyzer.codePath;
  53699. var state = CodePath.getState(codePath);
  53700. var parent = node.parent;
  53701. switch (parent.type) {
  53702. case "LogicalExpression":
  53703. if (parent.right === node && isHandledLogicalOperator(parent.operator)) {
  53704. state.makeLogicalRight();
  53705. }
  53706. break;
  53707. case "ConditionalExpression":
  53708. case "IfStatement":
  53709. /*
  53710. * Fork if this node is at `consequent`/`alternate`.
  53711. * `popForkContext()` exists at `IfStatement:exit` and
  53712. * `ConditionalExpression:exit`.
  53713. */
  53714. if (parent.consequent === node) {
  53715. state.makeIfConsequent();
  53716. } else if (parent.alternate === node) {
  53717. state.makeIfAlternate();
  53718. }
  53719. break;
  53720. case "SwitchCase":
  53721. if (parent.consequent[0] === node) {
  53722. state.makeSwitchCaseBody(false, !parent.test);
  53723. }
  53724. break;
  53725. case "TryStatement":
  53726. if (parent.handler === node) {
  53727. state.makeCatchBlock();
  53728. } else if (parent.finalizer === node) {
  53729. state.makeFinallyBlock();
  53730. }
  53731. break;
  53732. case "WhileStatement":
  53733. if (parent.test === node) {
  53734. state.makeWhileTest(getBooleanValueIfSimpleConstant(node));
  53735. } else {
  53736. assert(parent.body === node);
  53737. state.makeWhileBody();
  53738. }
  53739. break;
  53740. case "DoWhileStatement":
  53741. if (parent.body === node) {
  53742. state.makeDoWhileBody();
  53743. } else {
  53744. assert(parent.test === node);
  53745. state.makeDoWhileTest(getBooleanValueIfSimpleConstant(node));
  53746. }
  53747. break;
  53748. case "ForStatement":
  53749. if (parent.test === node) {
  53750. state.makeForTest(getBooleanValueIfSimpleConstant(node));
  53751. } else if (parent.update === node) {
  53752. state.makeForUpdate();
  53753. } else if (parent.body === node) {
  53754. state.makeForBody();
  53755. }
  53756. break;
  53757. case "ForInStatement":
  53758. case "ForOfStatement":
  53759. if (parent.left === node) {
  53760. state.makeForInOfLeft();
  53761. } else if (parent.right === node) {
  53762. state.makeForInOfRight();
  53763. } else {
  53764. assert(parent.body === node);
  53765. state.makeForInOfBody();
  53766. }
  53767. break;
  53768. case "AssignmentPattern":
  53769. /*
  53770. * Fork if this node is at `right`.
  53771. * `left` is executed always, so it uses the current path.
  53772. * `popForkContext()` exists at `AssignmentPattern:exit`.
  53773. */
  53774. if (parent.right === node) {
  53775. state.pushForkContext();
  53776. state.forkBypassPath();
  53777. state.forkPath();
  53778. }
  53779. break;
  53780. default:
  53781. break;
  53782. }
  53783. }
  53784. /**
  53785. * Updates the code path due to the type of a given node in entering.
  53786. *
  53787. * @param {CodePathAnalyzer} analyzer - The instance.
  53788. * @param {ASTNode} node - The current AST node.
  53789. * @returns {void}
  53790. */
  53791. function processCodePathToEnter(analyzer, node) {
  53792. var codePath = analyzer.codePath;
  53793. var state = codePath && CodePath.getState(codePath);
  53794. var parent = node.parent;
  53795. switch (node.type) {
  53796. case "Program":
  53797. case "FunctionDeclaration":
  53798. case "FunctionExpression":
  53799. case "ArrowFunctionExpression":
  53800. if (codePath) {
  53801. // Emits onCodePathSegmentStart events if updated.
  53802. forwardCurrentToHead(analyzer, node);
  53803. debug.dumpState(node, state, false);
  53804. }
  53805. // Create the code path of this scope.
  53806. codePath = analyzer.codePath = new CodePath(analyzer.idGenerator.next(), codePath, analyzer.onLooped);
  53807. state = CodePath.getState(codePath);
  53808. // Emits onCodePathStart events.
  53809. debug.dump("onCodePathStart " + codePath.id);
  53810. analyzer.emitter.emit("onCodePathStart", codePath, node);
  53811. break;
  53812. case "LogicalExpression":
  53813. if (isHandledLogicalOperator(node.operator)) {
  53814. state.pushChoiceContext(node.operator, isForkingByTrueOrFalse(node));
  53815. }
  53816. break;
  53817. case "ConditionalExpression":
  53818. case "IfStatement":
  53819. state.pushChoiceContext("test", false);
  53820. break;
  53821. case "SwitchStatement":
  53822. state.pushSwitchContext(node.cases.some(isCaseNode), astUtils.getLabel(node));
  53823. break;
  53824. case "TryStatement":
  53825. state.pushTryContext(Boolean(node.finalizer));
  53826. break;
  53827. case "SwitchCase":
  53828. /*
  53829. * Fork if this node is after the 2st node in `cases`.
  53830. * It's similar to `else` blocks.
  53831. * The next `test` node is processed in this path.
  53832. */
  53833. if (parent.discriminant !== node && parent.cases[0] !== node) {
  53834. state.forkPath();
  53835. }
  53836. break;
  53837. case "WhileStatement":
  53838. case "DoWhileStatement":
  53839. case "ForStatement":
  53840. case "ForInStatement":
  53841. case "ForOfStatement":
  53842. state.pushLoopContext(node.type, astUtils.getLabel(node));
  53843. break;
  53844. case "LabeledStatement":
  53845. if (!astUtils.isBreakableStatement(node.body)) {
  53846. state.pushBreakContext(false, node.label.name);
  53847. }
  53848. break;
  53849. default:
  53850. break;
  53851. }
  53852. // Emits onCodePathSegmentStart events if updated.
  53853. forwardCurrentToHead(analyzer, node);
  53854. debug.dumpState(node, state, false);
  53855. }
  53856. /**
  53857. * Updates the code path due to the type of a given node in leaving.
  53858. *
  53859. * @param {CodePathAnalyzer} analyzer - The instance.
  53860. * @param {ASTNode} node - The current AST node.
  53861. * @returns {void}
  53862. */
  53863. function processCodePathToExit(analyzer, node) {
  53864. var codePath = analyzer.codePath;
  53865. var state = CodePath.getState(codePath);
  53866. var dontForward = false;
  53867. switch (node.type) {
  53868. case "IfStatement":
  53869. case "ConditionalExpression":
  53870. state.popChoiceContext();
  53871. break;
  53872. case "LogicalExpression":
  53873. if (isHandledLogicalOperator(node.operator)) {
  53874. state.popChoiceContext();
  53875. }
  53876. break;
  53877. case "SwitchStatement":
  53878. state.popSwitchContext();
  53879. break;
  53880. case "SwitchCase":
  53881. /*
  53882. * This is the same as the process at the 1st `consequent` node in
  53883. * `preprocess` function.
  53884. * Must do if this `consequent` is empty.
  53885. */
  53886. if (node.consequent.length === 0) {
  53887. state.makeSwitchCaseBody(true, !node.test);
  53888. }
  53889. if (state.forkContext.reachable) {
  53890. dontForward = true;
  53891. }
  53892. break;
  53893. case "TryStatement":
  53894. state.popTryContext();
  53895. break;
  53896. case "BreakStatement":
  53897. forwardCurrentToHead(analyzer, node);
  53898. state.makeBreak(node.label && node.label.name);
  53899. dontForward = true;
  53900. break;
  53901. case "ContinueStatement":
  53902. forwardCurrentToHead(analyzer, node);
  53903. state.makeContinue(node.label && node.label.name);
  53904. dontForward = true;
  53905. break;
  53906. case "ReturnStatement":
  53907. forwardCurrentToHead(analyzer, node);
  53908. state.makeReturn();
  53909. dontForward = true;
  53910. break;
  53911. case "ThrowStatement":
  53912. forwardCurrentToHead(analyzer, node);
  53913. state.makeThrow();
  53914. dontForward = true;
  53915. break;
  53916. case "Identifier":
  53917. if (isIdentifierReference(node)) {
  53918. state.makeFirstThrowablePathInTryBlock();
  53919. dontForward = true;
  53920. }
  53921. break;
  53922. case "CallExpression":
  53923. case "MemberExpression":
  53924. case "NewExpression":
  53925. state.makeFirstThrowablePathInTryBlock();
  53926. break;
  53927. case "WhileStatement":
  53928. case "DoWhileStatement":
  53929. case "ForStatement":
  53930. case "ForInStatement":
  53931. case "ForOfStatement":
  53932. state.popLoopContext();
  53933. break;
  53934. case "AssignmentPattern":
  53935. state.popForkContext();
  53936. break;
  53937. case "LabeledStatement":
  53938. if (!astUtils.isBreakableStatement(node.body)) {
  53939. state.popBreakContext();
  53940. }
  53941. break;
  53942. default:
  53943. break;
  53944. }
  53945. // Emits onCodePathSegmentStart events if updated.
  53946. if (!dontForward) {
  53947. forwardCurrentToHead(analyzer, node);
  53948. }
  53949. debug.dumpState(node, state, true);
  53950. }
  53951. /**
  53952. * Updates the code path to finalize the current code path.
  53953. *
  53954. * @param {CodePathAnalyzer} analyzer - The instance.
  53955. * @param {ASTNode} node - The current AST node.
  53956. * @returns {void}
  53957. */
  53958. function postprocess(analyzer, node) {
  53959. switch (node.type) {
  53960. case "Program":
  53961. case "FunctionDeclaration":
  53962. case "FunctionExpression":
  53963. case "ArrowFunctionExpression":
  53964. {
  53965. var codePath = analyzer.codePath;
  53966. // Mark the current path as the final node.
  53967. CodePath.getState(codePath).makeFinal();
  53968. // Emits onCodePathSegmentEnd event of the current segments.
  53969. leaveFromCurrentSegment(analyzer, node);
  53970. // Emits onCodePathEnd event of this code path.
  53971. debug.dump("onCodePathEnd " + codePath.id);
  53972. analyzer.emitter.emit("onCodePathEnd", codePath, node);
  53973. debug.dumpDot(codePath);
  53974. codePath = analyzer.codePath = analyzer.codePath.upper;
  53975. if (codePath) {
  53976. debug.dumpState(node, CodePath.getState(codePath), true);
  53977. }
  53978. break;
  53979. }
  53980. default:
  53981. break;
  53982. }
  53983. }
  53984. //------------------------------------------------------------------------------
  53985. // Public Interface
  53986. //------------------------------------------------------------------------------
  53987. /**
  53988. * The class to analyze code paths.
  53989. * This class implements the EventGenerator interface.
  53990. */
  53991. var CodePathAnalyzer = function () {
  53992. /**
  53993. * @param {EventGenerator} eventGenerator - An event generator to wrap.
  53994. */
  53995. function CodePathAnalyzer(eventGenerator) {
  53996. _classCallCheck(this, CodePathAnalyzer);
  53997. this.original = eventGenerator;
  53998. this.emitter = eventGenerator.emitter;
  53999. this.codePath = null;
  54000. this.idGenerator = new IdGenerator("s");
  54001. this.currentNode = null;
  54002. this.onLooped = this.onLooped.bind(this);
  54003. }
  54004. /**
  54005. * Does the process to enter a given AST node.
  54006. * This updates state of analysis and calls `enterNode` of the wrapped.
  54007. *
  54008. * @param {ASTNode} node - A node which is entering.
  54009. * @returns {void}
  54010. */
  54011. _createClass(CodePathAnalyzer, [{
  54012. key: "enterNode",
  54013. value: function enterNode(node) {
  54014. this.currentNode = node;
  54015. // Updates the code path due to node's position in its parent node.
  54016. if (node.parent) {
  54017. preprocess(this, node);
  54018. }
  54019. /*
  54020. * Updates the code path.
  54021. * And emits onCodePathStart/onCodePathSegmentStart events.
  54022. */
  54023. processCodePathToEnter(this, node);
  54024. // Emits node events.
  54025. this.original.enterNode(node);
  54026. this.currentNode = null;
  54027. }
  54028. /**
  54029. * Does the process to leave a given AST node.
  54030. * This updates state of analysis and calls `leaveNode` of the wrapped.
  54031. *
  54032. * @param {ASTNode} node - A node which is leaving.
  54033. * @returns {void}
  54034. */
  54035. }, {
  54036. key: "leaveNode",
  54037. value: function leaveNode(node) {
  54038. this.currentNode = node;
  54039. /*
  54040. * Updates the code path.
  54041. * And emits onCodePathStart/onCodePathSegmentStart events.
  54042. */
  54043. processCodePathToExit(this, node);
  54044. // Emits node events.
  54045. this.original.leaveNode(node);
  54046. // Emits the last onCodePathStart/onCodePathSegmentStart events.
  54047. postprocess(this, node);
  54048. this.currentNode = null;
  54049. }
  54050. /**
  54051. * This is called on a code path looped.
  54052. * Then this raises a looped event.
  54053. *
  54054. * @param {CodePathSegment} fromSegment - A segment of prev.
  54055. * @param {CodePathSegment} toSegment - A segment of next.
  54056. * @returns {void}
  54057. */
  54058. }, {
  54059. key: "onLooped",
  54060. value: function onLooped(fromSegment, toSegment) {
  54061. if (fromSegment.reachable && toSegment.reachable) {
  54062. debug.dump("onCodePathSegmentLoop " + fromSegment.id + " -> " + toSegment.id);
  54063. this.emitter.emit("onCodePathSegmentLoop", fromSegment, toSegment, this.currentNode);
  54064. }
  54065. }
  54066. }]);
  54067. return CodePathAnalyzer;
  54068. }();
  54069. module.exports = CodePathAnalyzer;
  54070. },{"../util/ast-utils":405,"./code-path":115,"./code-path-segment":113,"./debug-helpers":116,"./id-generator":118,"assert":46}],113:[function(require,module,exports){
  54071. /**
  54072. * @fileoverview A class of the code path segment.
  54073. * @author Toru Nagashima
  54074. */
  54075. "use strict";
  54076. //------------------------------------------------------------------------------
  54077. // Requirements
  54078. //------------------------------------------------------------------------------
  54079. 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; }; }();
  54080. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  54081. var debug = require("./debug-helpers");
  54082. //------------------------------------------------------------------------------
  54083. // Helpers
  54084. //------------------------------------------------------------------------------
  54085. /**
  54086. * Checks whether or not a given segment is reachable.
  54087. *
  54088. * @param {CodePathSegment} segment - A segment to check.
  54089. * @returns {boolean} `true` if the segment is reachable.
  54090. */
  54091. function isReachable(segment) {
  54092. return segment.reachable;
  54093. }
  54094. //------------------------------------------------------------------------------
  54095. // Public Interface
  54096. //------------------------------------------------------------------------------
  54097. /**
  54098. * A code path segment.
  54099. */
  54100. var CodePathSegment = function () {
  54101. /**
  54102. * @param {string} id - An identifier.
  54103. * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
  54104. * This array includes unreachable segments.
  54105. * @param {boolean} reachable - A flag which shows this is reachable.
  54106. */
  54107. function CodePathSegment(id, allPrevSegments, reachable) {
  54108. _classCallCheck(this, CodePathSegment);
  54109. /**
  54110. * The identifier of this code path.
  54111. * Rules use it to store additional information of each rule.
  54112. * @type {string}
  54113. */
  54114. this.id = id;
  54115. /**
  54116. * An array of the next segments.
  54117. * @type {CodePathSegment[]}
  54118. */
  54119. this.nextSegments = [];
  54120. /**
  54121. * An array of the previous segments.
  54122. * @type {CodePathSegment[]}
  54123. */
  54124. this.prevSegments = allPrevSegments.filter(isReachable);
  54125. /**
  54126. * An array of the next segments.
  54127. * This array includes unreachable segments.
  54128. * @type {CodePathSegment[]}
  54129. */
  54130. this.allNextSegments = [];
  54131. /**
  54132. * An array of the previous segments.
  54133. * This array includes unreachable segments.
  54134. * @type {CodePathSegment[]}
  54135. */
  54136. this.allPrevSegments = allPrevSegments;
  54137. /**
  54138. * A flag which shows this is reachable.
  54139. * @type {boolean}
  54140. */
  54141. this.reachable = reachable;
  54142. // Internal data.
  54143. Object.defineProperty(this, "internal", {
  54144. value: {
  54145. used: false,
  54146. loopedPrevSegments: []
  54147. }
  54148. });
  54149. /* istanbul ignore if */
  54150. if (debug.enabled) {
  54151. this.internal.nodes = [];
  54152. this.internal.exitNodes = [];
  54153. }
  54154. }
  54155. /**
  54156. * Checks a given previous segment is coming from the end of a loop.
  54157. *
  54158. * @param {CodePathSegment} segment - A previous segment to check.
  54159. * @returns {boolean} `true` if the segment is coming from the end of a loop.
  54160. */
  54161. _createClass(CodePathSegment, [{
  54162. key: "isLoopedPrevSegment",
  54163. value: function isLoopedPrevSegment(segment) {
  54164. return this.internal.loopedPrevSegments.indexOf(segment) !== -1;
  54165. }
  54166. /**
  54167. * Creates the root segment.
  54168. *
  54169. * @param {string} id - An identifier.
  54170. * @returns {CodePathSegment} The created segment.
  54171. */
  54172. }], [{
  54173. key: "newRoot",
  54174. value: function newRoot(id) {
  54175. return new CodePathSegment(id, [], true);
  54176. }
  54177. /**
  54178. * Creates a segment that follows given segments.
  54179. *
  54180. * @param {string} id - An identifier.
  54181. * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
  54182. * @returns {CodePathSegment} The created segment.
  54183. */
  54184. }, {
  54185. key: "newNext",
  54186. value: function newNext(id, allPrevSegments) {
  54187. return new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), allPrevSegments.some(isReachable));
  54188. }
  54189. /**
  54190. * Creates an unreachable segment that follows given segments.
  54191. *
  54192. * @param {string} id - An identifier.
  54193. * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
  54194. * @returns {CodePathSegment} The created segment.
  54195. */
  54196. }, {
  54197. key: "newUnreachable",
  54198. value: function newUnreachable(id, allPrevSegments) {
  54199. var segment = new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), false);
  54200. /*
  54201. * In `if (a) return a; foo();` case, the unreachable segment preceded by
  54202. * the return statement is not used but must not be remove.
  54203. */
  54204. CodePathSegment.markUsed(segment);
  54205. return segment;
  54206. }
  54207. /**
  54208. * Creates a segment that follows given segments.
  54209. * This factory method does not connect with `allPrevSegments`.
  54210. * But this inherits `reachable` flag.
  54211. *
  54212. * @param {string} id - An identifier.
  54213. * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
  54214. * @returns {CodePathSegment} The created segment.
  54215. */
  54216. }, {
  54217. key: "newDisconnected",
  54218. value: function newDisconnected(id, allPrevSegments) {
  54219. return new CodePathSegment(id, [], allPrevSegments.some(isReachable));
  54220. }
  54221. /**
  54222. * Makes a given segment being used.
  54223. *
  54224. * And this function registers the segment into the previous segments as a next.
  54225. *
  54226. * @param {CodePathSegment} segment - A segment to mark.
  54227. * @returns {void}
  54228. */
  54229. }, {
  54230. key: "markUsed",
  54231. value: function markUsed(segment) {
  54232. if (segment.internal.used) {
  54233. return;
  54234. }
  54235. segment.internal.used = true;
  54236. var i = void 0;
  54237. if (segment.reachable) {
  54238. for (i = 0; i < segment.allPrevSegments.length; ++i) {
  54239. var prevSegment = segment.allPrevSegments[i];
  54240. prevSegment.allNextSegments.push(segment);
  54241. prevSegment.nextSegments.push(segment);
  54242. }
  54243. } else {
  54244. for (i = 0; i < segment.allPrevSegments.length; ++i) {
  54245. segment.allPrevSegments[i].allNextSegments.push(segment);
  54246. }
  54247. }
  54248. }
  54249. /**
  54250. * Marks a previous segment as looped.
  54251. *
  54252. * @param {CodePathSegment} segment - A segment.
  54253. * @param {CodePathSegment} prevSegment - A previous segment to mark.
  54254. * @returns {void}
  54255. */
  54256. }, {
  54257. key: "markPrevSegmentAsLooped",
  54258. value: function markPrevSegmentAsLooped(segment, prevSegment) {
  54259. segment.internal.loopedPrevSegments.push(prevSegment);
  54260. }
  54261. /**
  54262. * Replaces unused segments with the previous segments of each unused segment.
  54263. *
  54264. * @param {CodePathSegment[]} segments - An array of segments to replace.
  54265. * @returns {CodePathSegment[]} The replaced array.
  54266. */
  54267. }, {
  54268. key: "flattenUnusedSegments",
  54269. value: function flattenUnusedSegments(segments) {
  54270. var done = Object.create(null);
  54271. var retv = [];
  54272. for (var i = 0; i < segments.length; ++i) {
  54273. var segment = segments[i];
  54274. // Ignores duplicated.
  54275. if (done[segment.id]) {
  54276. continue;
  54277. }
  54278. // Use previous segments if unused.
  54279. if (!segment.internal.used) {
  54280. for (var j = 0; j < segment.allPrevSegments.length; ++j) {
  54281. var prevSegment = segment.allPrevSegments[j];
  54282. if (!done[prevSegment.id]) {
  54283. done[prevSegment.id] = true;
  54284. retv.push(prevSegment);
  54285. }
  54286. }
  54287. } else {
  54288. done[segment.id] = true;
  54289. retv.push(segment);
  54290. }
  54291. }
  54292. return retv;
  54293. }
  54294. }]);
  54295. return CodePathSegment;
  54296. }();
  54297. module.exports = CodePathSegment;
  54298. },{"./debug-helpers":116}],114:[function(require,module,exports){
  54299. /**
  54300. * @fileoverview A class to manage state of generating a code path.
  54301. * @author Toru Nagashima
  54302. */
  54303. "use strict";
  54304. //------------------------------------------------------------------------------
  54305. // Requirements
  54306. //------------------------------------------------------------------------------
  54307. 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; }; }();
  54308. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  54309. var CodePathSegment = require("./code-path-segment"),
  54310. ForkContext = require("./fork-context");
  54311. //------------------------------------------------------------------------------
  54312. // Helpers
  54313. //------------------------------------------------------------------------------
  54314. /**
  54315. * Adds given segments into the `dest` array.
  54316. * If the `others` array does not includes the given segments, adds to the `all`
  54317. * array as well.
  54318. *
  54319. * This adds only reachable and used segments.
  54320. *
  54321. * @param {CodePathSegment[]} dest - A destination array (`returnedSegments` or `thrownSegments`).
  54322. * @param {CodePathSegment[]} others - Another destination array (`returnedSegments` or `thrownSegments`).
  54323. * @param {CodePathSegment[]} all - The unified destination array (`finalSegments`).
  54324. * @param {CodePathSegment[]} segments - Segments to add.
  54325. * @returns {void}
  54326. */
  54327. function addToReturnedOrThrown(dest, others, all, segments) {
  54328. for (var i = 0; i < segments.length; ++i) {
  54329. var segment = segments[i];
  54330. dest.push(segment);
  54331. if (others.indexOf(segment) === -1) {
  54332. all.push(segment);
  54333. }
  54334. }
  54335. }
  54336. /**
  54337. * Gets a loop-context for a `continue` statement.
  54338. *
  54339. * @param {CodePathState} state - A state to get.
  54340. * @param {string} label - The label of a `continue` statement.
  54341. * @returns {LoopContext} A loop-context for a `continue` statement.
  54342. */
  54343. function getContinueContext(state, label) {
  54344. if (!label) {
  54345. return state.loopContext;
  54346. }
  54347. var context = state.loopContext;
  54348. while (context) {
  54349. if (context.label === label) {
  54350. return context;
  54351. }
  54352. context = context.upper;
  54353. }
  54354. /* istanbul ignore next: foolproof (syntax error) */
  54355. return null;
  54356. }
  54357. /**
  54358. * Gets a context for a `break` statement.
  54359. *
  54360. * @param {CodePathState} state - A state to get.
  54361. * @param {string} label - The label of a `break` statement.
  54362. * @returns {LoopContext|SwitchContext} A context for a `break` statement.
  54363. */
  54364. function getBreakContext(state, label) {
  54365. var context = state.breakContext;
  54366. while (context) {
  54367. if (label ? context.label === label : context.breakable) {
  54368. return context;
  54369. }
  54370. context = context.upper;
  54371. }
  54372. /* istanbul ignore next: foolproof (syntax error) */
  54373. return null;
  54374. }
  54375. /**
  54376. * Gets a context for a `return` statement.
  54377. *
  54378. * @param {CodePathState} state - A state to get.
  54379. * @returns {TryContext|CodePathState} A context for a `return` statement.
  54380. */
  54381. function getReturnContext(state) {
  54382. var context = state.tryContext;
  54383. while (context) {
  54384. if (context.hasFinalizer && context.position !== "finally") {
  54385. return context;
  54386. }
  54387. context = context.upper;
  54388. }
  54389. return state;
  54390. }
  54391. /**
  54392. * Gets a context for a `throw` statement.
  54393. *
  54394. * @param {CodePathState} state - A state to get.
  54395. * @returns {TryContext|CodePathState} A context for a `throw` statement.
  54396. */
  54397. function getThrowContext(state) {
  54398. var context = state.tryContext;
  54399. while (context) {
  54400. if (context.position === "try" || context.hasFinalizer && context.position === "catch") {
  54401. return context;
  54402. }
  54403. context = context.upper;
  54404. }
  54405. return state;
  54406. }
  54407. /**
  54408. * Removes a given element from a given array.
  54409. *
  54410. * @param {any[]} xs - An array to remove the specific element.
  54411. * @param {any} x - An element to be removed.
  54412. * @returns {void}
  54413. */
  54414. function remove(xs, x) {
  54415. xs.splice(xs.indexOf(x), 1);
  54416. }
  54417. /**
  54418. * Disconnect given segments.
  54419. *
  54420. * This is used in a process for switch statements.
  54421. * If there is the "default" chunk before other cases, the order is different
  54422. * between node's and running's.
  54423. *
  54424. * @param {CodePathSegment[]} prevSegments - Forward segments to disconnect.
  54425. * @param {CodePathSegment[]} nextSegments - Backward segments to disconnect.
  54426. * @returns {void}
  54427. */
  54428. function removeConnection(prevSegments, nextSegments) {
  54429. for (var i = 0; i < prevSegments.length; ++i) {
  54430. var prevSegment = prevSegments[i];
  54431. var nextSegment = nextSegments[i];
  54432. remove(prevSegment.nextSegments, nextSegment);
  54433. remove(prevSegment.allNextSegments, nextSegment);
  54434. remove(nextSegment.prevSegments, prevSegment);
  54435. remove(nextSegment.allPrevSegments, prevSegment);
  54436. }
  54437. }
  54438. /**
  54439. * Creates looping path.
  54440. *
  54441. * @param {CodePathState} state - The instance.
  54442. * @param {CodePathSegment[]} unflattenedFromSegments - Segments which are source.
  54443. * @param {CodePathSegment[]} unflattenedToSegments - Segments which are destination.
  54444. * @returns {void}
  54445. */
  54446. function makeLooped(state, unflattenedFromSegments, unflattenedToSegments) {
  54447. var fromSegments = CodePathSegment.flattenUnusedSegments(unflattenedFromSegments);
  54448. var toSegments = CodePathSegment.flattenUnusedSegments(unflattenedToSegments);
  54449. var end = Math.min(fromSegments.length, toSegments.length);
  54450. for (var i = 0; i < end; ++i) {
  54451. var fromSegment = fromSegments[i];
  54452. var toSegment = toSegments[i];
  54453. if (toSegment.reachable) {
  54454. fromSegment.nextSegments.push(toSegment);
  54455. }
  54456. if (fromSegment.reachable) {
  54457. toSegment.prevSegments.push(fromSegment);
  54458. }
  54459. fromSegment.allNextSegments.push(toSegment);
  54460. toSegment.allPrevSegments.push(fromSegment);
  54461. if (toSegment.allPrevSegments.length >= 2) {
  54462. CodePathSegment.markPrevSegmentAsLooped(toSegment, fromSegment);
  54463. }
  54464. state.notifyLooped(fromSegment, toSegment);
  54465. }
  54466. }
  54467. /**
  54468. * Finalizes segments of `test` chunk of a ForStatement.
  54469. *
  54470. * - Adds `false` paths to paths which are leaving from the loop.
  54471. * - Sets `true` paths to paths which go to the body.
  54472. *
  54473. * @param {LoopContext} context - A loop context to modify.
  54474. * @param {ChoiceContext} choiceContext - A choice context of this loop.
  54475. * @param {CodePathSegment[]} head - The current head paths.
  54476. * @returns {void}
  54477. */
  54478. function finalizeTestSegmentsOfFor(context, choiceContext, head) {
  54479. if (!choiceContext.processed) {
  54480. choiceContext.trueForkContext.add(head);
  54481. choiceContext.falseForkContext.add(head);
  54482. }
  54483. if (context.test !== true) {
  54484. context.brokenForkContext.addAll(choiceContext.falseForkContext);
  54485. }
  54486. context.endOfTestSegments = choiceContext.trueForkContext.makeNext(0, -1);
  54487. }
  54488. //------------------------------------------------------------------------------
  54489. // Public Interface
  54490. //------------------------------------------------------------------------------
  54491. /**
  54492. * A class which manages state to analyze code paths.
  54493. */
  54494. var CodePathState = function () {
  54495. /**
  54496. * @param {IdGenerator} idGenerator - An id generator to generate id for code
  54497. * path segments.
  54498. * @param {Function} onLooped - A callback function to notify looping.
  54499. */
  54500. function CodePathState(idGenerator, onLooped) {
  54501. _classCallCheck(this, CodePathState);
  54502. this.idGenerator = idGenerator;
  54503. this.notifyLooped = onLooped;
  54504. this.forkContext = ForkContext.newRoot(idGenerator);
  54505. this.choiceContext = null;
  54506. this.switchContext = null;
  54507. this.tryContext = null;
  54508. this.loopContext = null;
  54509. this.breakContext = null;
  54510. this.currentSegments = [];
  54511. this.initialSegment = this.forkContext.head[0];
  54512. // returnedSegments and thrownSegments push elements into finalSegments also.
  54513. var final = this.finalSegments = [];
  54514. var returned = this.returnedForkContext = [];
  54515. var thrown = this.thrownForkContext = [];
  54516. returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final);
  54517. thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final);
  54518. }
  54519. /**
  54520. * The head segments.
  54521. * @type {CodePathSegment[]}
  54522. */
  54523. _createClass(CodePathState, [{
  54524. key: "pushForkContext",
  54525. /**
  54526. * Creates and stacks new forking context.
  54527. *
  54528. * @param {boolean} forkLeavingPath - A flag which shows being in a
  54529. * "finally" block.
  54530. * @returns {ForkContext} The created context.
  54531. */
  54532. value: function pushForkContext(forkLeavingPath) {
  54533. this.forkContext = ForkContext.newEmpty(this.forkContext, forkLeavingPath);
  54534. return this.forkContext;
  54535. }
  54536. /**
  54537. * Pops and merges the last forking context.
  54538. * @returns {ForkContext} The last context.
  54539. */
  54540. }, {
  54541. key: "popForkContext",
  54542. value: function popForkContext() {
  54543. var lastContext = this.forkContext;
  54544. this.forkContext = lastContext.upper;
  54545. this.forkContext.replaceHead(lastContext.makeNext(0, -1));
  54546. return lastContext;
  54547. }
  54548. /**
  54549. * Creates a new path.
  54550. * @returns {void}
  54551. */
  54552. }, {
  54553. key: "forkPath",
  54554. value: function forkPath() {
  54555. this.forkContext.add(this.parentForkContext.makeNext(-1, -1));
  54556. }
  54557. /**
  54558. * Creates a bypass path.
  54559. * This is used for such as IfStatement which does not have "else" chunk.
  54560. *
  54561. * @returns {void}
  54562. */
  54563. }, {
  54564. key: "forkBypassPath",
  54565. value: function forkBypassPath() {
  54566. this.forkContext.add(this.parentForkContext.head);
  54567. }
  54568. //--------------------------------------------------------------------------
  54569. // ConditionalExpression, LogicalExpression, IfStatement
  54570. //--------------------------------------------------------------------------
  54571. /**
  54572. * Creates a context for ConditionalExpression, LogicalExpression,
  54573. * IfStatement, WhileStatement, DoWhileStatement, or ForStatement.
  54574. *
  54575. * LogicalExpressions have cases that it goes different paths between the
  54576. * `true` case and the `false` case.
  54577. *
  54578. * For Example:
  54579. *
  54580. * if (a || b) {
  54581. * foo();
  54582. * } else {
  54583. * bar();
  54584. * }
  54585. *
  54586. * In this case, `b` is evaluated always in the code path of the `else`
  54587. * block, but it's not so in the code path of the `if` block.
  54588. * So there are 3 paths.
  54589. *
  54590. * a -> foo();
  54591. * a -> b -> foo();
  54592. * a -> b -> bar();
  54593. *
  54594. * @param {string} kind - A kind string.
  54595. * If the new context is LogicalExpression's, this is `"&&"` or `"||"`.
  54596. * If it's IfStatement's or ConditionalExpression's, this is `"test"`.
  54597. * Otherwise, this is `"loop"`.
  54598. * @param {boolean} isForkingAsResult - A flag that shows that goes different
  54599. * paths between `true` and `false`.
  54600. * @returns {void}
  54601. */
  54602. }, {
  54603. key: "pushChoiceContext",
  54604. value: function pushChoiceContext(kind, isForkingAsResult) {
  54605. this.choiceContext = {
  54606. upper: this.choiceContext,
  54607. kind: kind,
  54608. isForkingAsResult: isForkingAsResult,
  54609. trueForkContext: ForkContext.newEmpty(this.forkContext),
  54610. falseForkContext: ForkContext.newEmpty(this.forkContext),
  54611. processed: false
  54612. };
  54613. }
  54614. /**
  54615. * Pops the last choice context and finalizes it.
  54616. *
  54617. * @returns {ChoiceContext} The popped context.
  54618. */
  54619. }, {
  54620. key: "popChoiceContext",
  54621. value: function popChoiceContext() {
  54622. var context = this.choiceContext;
  54623. this.choiceContext = context.upper;
  54624. var forkContext = this.forkContext;
  54625. var headSegments = forkContext.head;
  54626. switch (context.kind) {
  54627. case "&&":
  54628. case "||":
  54629. /*
  54630. * If any result were not transferred from child contexts,
  54631. * this sets the head segments to both cases.
  54632. * The head segments are the path of the right-hand operand.
  54633. */
  54634. if (!context.processed) {
  54635. context.trueForkContext.add(headSegments);
  54636. context.falseForkContext.add(headSegments);
  54637. }
  54638. /*
  54639. * Transfers results to upper context if this context is in
  54640. * test chunk.
  54641. */
  54642. if (context.isForkingAsResult) {
  54643. var parentContext = this.choiceContext;
  54644. parentContext.trueForkContext.addAll(context.trueForkContext);
  54645. parentContext.falseForkContext.addAll(context.falseForkContext);
  54646. parentContext.processed = true;
  54647. return context;
  54648. }
  54649. break;
  54650. case "test":
  54651. if (!context.processed) {
  54652. /*
  54653. * The head segments are the path of the `if` block here.
  54654. * Updates the `true` path with the end of the `if` block.
  54655. */
  54656. context.trueForkContext.clear();
  54657. context.trueForkContext.add(headSegments);
  54658. } else {
  54659. /*
  54660. * The head segments are the path of the `else` block here.
  54661. * Updates the `false` path with the end of the `else`
  54662. * block.
  54663. */
  54664. context.falseForkContext.clear();
  54665. context.falseForkContext.add(headSegments);
  54666. }
  54667. break;
  54668. case "loop":
  54669. /*
  54670. * Loops are addressed in popLoopContext().
  54671. * This is called from popLoopContext().
  54672. */
  54673. return context;
  54674. /* istanbul ignore next */
  54675. default:
  54676. throw new Error("unreachable");
  54677. }
  54678. // Merges all paths.
  54679. var prevForkContext = context.trueForkContext;
  54680. prevForkContext.addAll(context.falseForkContext);
  54681. forkContext.replaceHead(prevForkContext.makeNext(0, -1));
  54682. return context;
  54683. }
  54684. /**
  54685. * Makes a code path segment of the right-hand operand of a logical
  54686. * expression.
  54687. *
  54688. * @returns {void}
  54689. */
  54690. }, {
  54691. key: "makeLogicalRight",
  54692. value: function makeLogicalRight() {
  54693. var context = this.choiceContext;
  54694. var forkContext = this.forkContext;
  54695. if (context.processed) {
  54696. /*
  54697. * This got segments already from the child choice context.
  54698. * Creates the next path from own true/false fork context.
  54699. */
  54700. var prevForkContext = context.kind === "&&" ? context.trueForkContext
  54701. /* kind === "||" */ : context.falseForkContext;
  54702. forkContext.replaceHead(prevForkContext.makeNext(0, -1));
  54703. prevForkContext.clear();
  54704. context.processed = false;
  54705. } else {
  54706. /*
  54707. * This did not get segments from the child choice context.
  54708. * So addresses the head segments.
  54709. * The head segments are the path of the left-hand operand.
  54710. */
  54711. if (context.kind === "&&") {
  54712. // The path does short-circuit if false.
  54713. context.falseForkContext.add(forkContext.head);
  54714. } else {
  54715. // The path does short-circuit if true.
  54716. context.trueForkContext.add(forkContext.head);
  54717. }
  54718. forkContext.replaceHead(forkContext.makeNext(-1, -1));
  54719. }
  54720. }
  54721. /**
  54722. * Makes a code path segment of the `if` block.
  54723. *
  54724. * @returns {void}
  54725. */
  54726. }, {
  54727. key: "makeIfConsequent",
  54728. value: function makeIfConsequent() {
  54729. var context = this.choiceContext;
  54730. var forkContext = this.forkContext;
  54731. /*
  54732. * If any result were not transferred from child contexts,
  54733. * this sets the head segments to both cases.
  54734. * The head segments are the path of the test expression.
  54735. */
  54736. if (!context.processed) {
  54737. context.trueForkContext.add(forkContext.head);
  54738. context.falseForkContext.add(forkContext.head);
  54739. }
  54740. context.processed = false;
  54741. // Creates new path from the `true` case.
  54742. forkContext.replaceHead(context.trueForkContext.makeNext(0, -1));
  54743. }
  54744. /**
  54745. * Makes a code path segment of the `else` block.
  54746. *
  54747. * @returns {void}
  54748. */
  54749. }, {
  54750. key: "makeIfAlternate",
  54751. value: function makeIfAlternate() {
  54752. var context = this.choiceContext;
  54753. var forkContext = this.forkContext;
  54754. /*
  54755. * The head segments are the path of the `if` block.
  54756. * Updates the `true` path with the end of the `if` block.
  54757. */
  54758. context.trueForkContext.clear();
  54759. context.trueForkContext.add(forkContext.head);
  54760. context.processed = true;
  54761. // Creates new path from the `false` case.
  54762. forkContext.replaceHead(context.falseForkContext.makeNext(0, -1));
  54763. }
  54764. //--------------------------------------------------------------------------
  54765. // SwitchStatement
  54766. //--------------------------------------------------------------------------
  54767. /**
  54768. * Creates a context object of SwitchStatement and stacks it.
  54769. *
  54770. * @param {boolean} hasCase - `true` if the switch statement has one or more
  54771. * case parts.
  54772. * @param {string|null} label - The label text.
  54773. * @returns {void}
  54774. */
  54775. }, {
  54776. key: "pushSwitchContext",
  54777. value: function pushSwitchContext(hasCase, label) {
  54778. this.switchContext = {
  54779. upper: this.switchContext,
  54780. hasCase: hasCase,
  54781. defaultSegments: null,
  54782. defaultBodySegments: null,
  54783. foundDefault: false,
  54784. lastIsDefault: false,
  54785. countForks: 0
  54786. };
  54787. this.pushBreakContext(true, label);
  54788. }
  54789. /**
  54790. * Pops the last context of SwitchStatement and finalizes it.
  54791. *
  54792. * - Disposes all forking stack for `case` and `default`.
  54793. * - Creates the next code path segment from `context.brokenForkContext`.
  54794. * - If the last `SwitchCase` node is not a `default` part, creates a path
  54795. * to the `default` body.
  54796. *
  54797. * @returns {void}
  54798. */
  54799. }, {
  54800. key: "popSwitchContext",
  54801. value: function popSwitchContext() {
  54802. var context = this.switchContext;
  54803. this.switchContext = context.upper;
  54804. var forkContext = this.forkContext;
  54805. var brokenForkContext = this.popBreakContext().brokenForkContext;
  54806. if (context.countForks === 0) {
  54807. /*
  54808. * When there is only one `default` chunk and there is one or more
  54809. * `break` statements, even if forks are nothing, it needs to merge
  54810. * those.
  54811. */
  54812. if (!brokenForkContext.empty) {
  54813. brokenForkContext.add(forkContext.makeNext(-1, -1));
  54814. forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
  54815. }
  54816. return;
  54817. }
  54818. var lastSegments = forkContext.head;
  54819. this.forkBypassPath();
  54820. var lastCaseSegments = forkContext.head;
  54821. /*
  54822. * `brokenForkContext` is used to make the next segment.
  54823. * It must add the last segment into `brokenForkContext`.
  54824. */
  54825. brokenForkContext.add(lastSegments);
  54826. /*
  54827. * A path which is failed in all case test should be connected to path
  54828. * of `default` chunk.
  54829. */
  54830. if (!context.lastIsDefault) {
  54831. if (context.defaultBodySegments) {
  54832. /*
  54833. * Remove a link from `default` label to its chunk.
  54834. * It's false route.
  54835. */
  54836. removeConnection(context.defaultSegments, context.defaultBodySegments);
  54837. makeLooped(this, lastCaseSegments, context.defaultBodySegments);
  54838. } else {
  54839. /*
  54840. * It handles the last case body as broken if `default` chunk
  54841. * does not exist.
  54842. */
  54843. brokenForkContext.add(lastCaseSegments);
  54844. }
  54845. }
  54846. // Pops the segment context stack until the entry segment.
  54847. for (var i = 0; i < context.countForks; ++i) {
  54848. this.forkContext = this.forkContext.upper;
  54849. }
  54850. /*
  54851. * Creates a path from all brokenForkContext paths.
  54852. * This is a path after switch statement.
  54853. */
  54854. this.forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
  54855. }
  54856. /**
  54857. * Makes a code path segment for a `SwitchCase` node.
  54858. *
  54859. * @param {boolean} isEmpty - `true` if the body is empty.
  54860. * @param {boolean} isDefault - `true` if the body is the default case.
  54861. * @returns {void}
  54862. */
  54863. }, {
  54864. key: "makeSwitchCaseBody",
  54865. value: function makeSwitchCaseBody(isEmpty, isDefault) {
  54866. var context = this.switchContext;
  54867. if (!context.hasCase) {
  54868. return;
  54869. }
  54870. /*
  54871. * Merge forks.
  54872. * The parent fork context has two segments.
  54873. * Those are from the current case and the body of the previous case.
  54874. */
  54875. var parentForkContext = this.forkContext;
  54876. var forkContext = this.pushForkContext();
  54877. forkContext.add(parentForkContext.makeNext(0, -1));
  54878. /*
  54879. * Save `default` chunk info.
  54880. * If the `default` label is not at the last, we must make a path from
  54881. * the last `case` to the `default` chunk.
  54882. */
  54883. if (isDefault) {
  54884. context.defaultSegments = parentForkContext.head;
  54885. if (isEmpty) {
  54886. context.foundDefault = true;
  54887. } else {
  54888. context.defaultBodySegments = forkContext.head;
  54889. }
  54890. } else {
  54891. if (!isEmpty && context.foundDefault) {
  54892. context.foundDefault = false;
  54893. context.defaultBodySegments = forkContext.head;
  54894. }
  54895. }
  54896. context.lastIsDefault = isDefault;
  54897. context.countForks += 1;
  54898. }
  54899. //--------------------------------------------------------------------------
  54900. // TryStatement
  54901. //--------------------------------------------------------------------------
  54902. /**
  54903. * Creates a context object of TryStatement and stacks it.
  54904. *
  54905. * @param {boolean} hasFinalizer - `true` if the try statement has a
  54906. * `finally` block.
  54907. * @returns {void}
  54908. */
  54909. }, {
  54910. key: "pushTryContext",
  54911. value: function pushTryContext(hasFinalizer) {
  54912. this.tryContext = {
  54913. upper: this.tryContext,
  54914. position: "try",
  54915. hasFinalizer: hasFinalizer,
  54916. returnedForkContext: hasFinalizer ? ForkContext.newEmpty(this.forkContext) : null,
  54917. thrownForkContext: ForkContext.newEmpty(this.forkContext),
  54918. lastOfTryIsReachable: false,
  54919. lastOfCatchIsReachable: false
  54920. };
  54921. }
  54922. /**
  54923. * Pops the last context of TryStatement and finalizes it.
  54924. *
  54925. * @returns {void}
  54926. */
  54927. }, {
  54928. key: "popTryContext",
  54929. value: function popTryContext() {
  54930. var context = this.tryContext;
  54931. this.tryContext = context.upper;
  54932. if (context.position === "catch") {
  54933. // Merges two paths from the `try` block and `catch` block merely.
  54934. this.popForkContext();
  54935. return;
  54936. }
  54937. /*
  54938. * The following process is executed only when there is the `finally`
  54939. * block.
  54940. */
  54941. var returned = context.returnedForkContext;
  54942. var thrown = context.thrownForkContext;
  54943. if (returned.empty && thrown.empty) {
  54944. return;
  54945. }
  54946. // Separate head to normal paths and leaving paths.
  54947. var headSegments = this.forkContext.head;
  54948. this.forkContext = this.forkContext.upper;
  54949. var normalSegments = headSegments.slice(0, headSegments.length / 2 | 0);
  54950. var leavingSegments = headSegments.slice(headSegments.length / 2 | 0);
  54951. // Forwards the leaving path to upper contexts.
  54952. if (!returned.empty) {
  54953. getReturnContext(this).returnedForkContext.add(leavingSegments);
  54954. }
  54955. if (!thrown.empty) {
  54956. getThrowContext(this).thrownForkContext.add(leavingSegments);
  54957. }
  54958. // Sets the normal path as the next.
  54959. this.forkContext.replaceHead(normalSegments);
  54960. /*
  54961. * If both paths of the `try` block and the `catch` block are
  54962. * unreachable, the next path becomes unreachable as well.
  54963. */
  54964. if (!context.lastOfTryIsReachable && !context.lastOfCatchIsReachable) {
  54965. this.forkContext.makeUnreachable();
  54966. }
  54967. }
  54968. /**
  54969. * Makes a code path segment for a `catch` block.
  54970. *
  54971. * @returns {void}
  54972. */
  54973. }, {
  54974. key: "makeCatchBlock",
  54975. value: function makeCatchBlock() {
  54976. var context = this.tryContext;
  54977. var forkContext = this.forkContext;
  54978. var thrown = context.thrownForkContext;
  54979. // Update state.
  54980. context.position = "catch";
  54981. context.thrownForkContext = ForkContext.newEmpty(forkContext);
  54982. context.lastOfTryIsReachable = forkContext.reachable;
  54983. // Merge thrown paths.
  54984. thrown.add(forkContext.head);
  54985. var thrownSegments = thrown.makeNext(0, -1);
  54986. // Fork to a bypass and the merged thrown path.
  54987. this.pushForkContext();
  54988. this.forkBypassPath();
  54989. this.forkContext.add(thrownSegments);
  54990. }
  54991. /**
  54992. * Makes a code path segment for a `finally` block.
  54993. *
  54994. * In the `finally` block, parallel paths are created. The parallel paths
  54995. * are used as leaving-paths. The leaving-paths are paths from `return`
  54996. * statements and `throw` statements in a `try` block or a `catch` block.
  54997. *
  54998. * @returns {void}
  54999. */
  55000. }, {
  55001. key: "makeFinallyBlock",
  55002. value: function makeFinallyBlock() {
  55003. var context = this.tryContext;
  55004. var forkContext = this.forkContext;
  55005. var returned = context.returnedForkContext;
  55006. var thrown = context.thrownForkContext;
  55007. var headOfLeavingSegments = forkContext.head;
  55008. // Update state.
  55009. if (context.position === "catch") {
  55010. // Merges two paths from the `try` block and `catch` block.
  55011. this.popForkContext();
  55012. forkContext = this.forkContext;
  55013. context.lastOfCatchIsReachable = forkContext.reachable;
  55014. } else {
  55015. context.lastOfTryIsReachable = forkContext.reachable;
  55016. }
  55017. context.position = "finally";
  55018. if (returned.empty && thrown.empty) {
  55019. // This path does not leave.
  55020. return;
  55021. }
  55022. /*
  55023. * Create a parallel segment from merging returned and thrown.
  55024. * This segment will leave at the end of this finally block.
  55025. */
  55026. var segments = forkContext.makeNext(-1, -1);
  55027. for (var i = 0; i < forkContext.count; ++i) {
  55028. var prevSegsOfLeavingSegment = [headOfLeavingSegments[i]];
  55029. for (var j = 0; j < returned.segmentsList.length; ++j) {
  55030. prevSegsOfLeavingSegment.push(returned.segmentsList[j][i]);
  55031. }
  55032. for (var _j = 0; _j < thrown.segmentsList.length; ++_j) {
  55033. prevSegsOfLeavingSegment.push(thrown.segmentsList[_j][i]);
  55034. }
  55035. segments.push(CodePathSegment.newNext(this.idGenerator.next(), prevSegsOfLeavingSegment));
  55036. }
  55037. this.pushForkContext(true);
  55038. this.forkContext.add(segments);
  55039. }
  55040. /**
  55041. * Makes a code path segment from the first throwable node to the `catch`
  55042. * block or the `finally` block.
  55043. *
  55044. * @returns {void}
  55045. */
  55046. }, {
  55047. key: "makeFirstThrowablePathInTryBlock",
  55048. value: function makeFirstThrowablePathInTryBlock() {
  55049. var forkContext = this.forkContext;
  55050. if (!forkContext.reachable) {
  55051. return;
  55052. }
  55053. var context = getThrowContext(this);
  55054. if (context === this || context.position !== "try" || !context.thrownForkContext.empty) {
  55055. return;
  55056. }
  55057. context.thrownForkContext.add(forkContext.head);
  55058. forkContext.replaceHead(forkContext.makeNext(-1, -1));
  55059. }
  55060. //--------------------------------------------------------------------------
  55061. // Loop Statements
  55062. //--------------------------------------------------------------------------
  55063. /**
  55064. * Creates a context object of a loop statement and stacks it.
  55065. *
  55066. * @param {string} type - The type of the node which was triggered. One of
  55067. * `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`,
  55068. * and `ForStatement`.
  55069. * @param {string|null} label - A label of the node which was triggered.
  55070. * @returns {void}
  55071. */
  55072. }, {
  55073. key: "pushLoopContext",
  55074. value: function pushLoopContext(type, label) {
  55075. var forkContext = this.forkContext;
  55076. var breakContext = this.pushBreakContext(true, label);
  55077. switch (type) {
  55078. case "WhileStatement":
  55079. this.pushChoiceContext("loop", false);
  55080. this.loopContext = {
  55081. upper: this.loopContext,
  55082. type: type,
  55083. label: label,
  55084. test: void 0,
  55085. continueDestSegments: null,
  55086. brokenForkContext: breakContext.brokenForkContext
  55087. };
  55088. break;
  55089. case "DoWhileStatement":
  55090. this.pushChoiceContext("loop", false);
  55091. this.loopContext = {
  55092. upper: this.loopContext,
  55093. type: type,
  55094. label: label,
  55095. test: void 0,
  55096. entrySegments: null,
  55097. continueForkContext: ForkContext.newEmpty(forkContext),
  55098. brokenForkContext: breakContext.brokenForkContext
  55099. };
  55100. break;
  55101. case "ForStatement":
  55102. this.pushChoiceContext("loop", false);
  55103. this.loopContext = {
  55104. upper: this.loopContext,
  55105. type: type,
  55106. label: label,
  55107. test: void 0,
  55108. endOfInitSegments: null,
  55109. testSegments: null,
  55110. endOfTestSegments: null,
  55111. updateSegments: null,
  55112. endOfUpdateSegments: null,
  55113. continueDestSegments: null,
  55114. brokenForkContext: breakContext.brokenForkContext
  55115. };
  55116. break;
  55117. case "ForInStatement":
  55118. case "ForOfStatement":
  55119. this.loopContext = {
  55120. upper: this.loopContext,
  55121. type: type,
  55122. label: label,
  55123. prevSegments: null,
  55124. leftSegments: null,
  55125. endOfLeftSegments: null,
  55126. continueDestSegments: null,
  55127. brokenForkContext: breakContext.brokenForkContext
  55128. };
  55129. break;
  55130. /* istanbul ignore next */
  55131. default:
  55132. throw new Error("unknown type: \"" + type + "\"");
  55133. }
  55134. }
  55135. /**
  55136. * Pops the last context of a loop statement and finalizes it.
  55137. *
  55138. * @returns {void}
  55139. */
  55140. }, {
  55141. key: "popLoopContext",
  55142. value: function popLoopContext() {
  55143. var context = this.loopContext;
  55144. this.loopContext = context.upper;
  55145. var forkContext = this.forkContext;
  55146. var brokenForkContext = this.popBreakContext().brokenForkContext;
  55147. // Creates a looped path.
  55148. switch (context.type) {
  55149. case "WhileStatement":
  55150. case "ForStatement":
  55151. this.popChoiceContext();
  55152. makeLooped(this, forkContext.head, context.continueDestSegments);
  55153. break;
  55154. case "DoWhileStatement":
  55155. {
  55156. var choiceContext = this.popChoiceContext();
  55157. if (!choiceContext.processed) {
  55158. choiceContext.trueForkContext.add(forkContext.head);
  55159. choiceContext.falseForkContext.add(forkContext.head);
  55160. }
  55161. if (context.test !== true) {
  55162. brokenForkContext.addAll(choiceContext.falseForkContext);
  55163. }
  55164. // `true` paths go to looping.
  55165. var segmentsList = choiceContext.trueForkContext.segmentsList;
  55166. for (var i = 0; i < segmentsList.length; ++i) {
  55167. makeLooped(this, segmentsList[i], context.entrySegments);
  55168. }
  55169. break;
  55170. }
  55171. case "ForInStatement":
  55172. case "ForOfStatement":
  55173. brokenForkContext.add(forkContext.head);
  55174. makeLooped(this, forkContext.head, context.leftSegments);
  55175. break;
  55176. /* istanbul ignore next */
  55177. default:
  55178. throw new Error("unreachable");
  55179. }
  55180. // Go next.
  55181. if (brokenForkContext.empty) {
  55182. forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
  55183. } else {
  55184. forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
  55185. }
  55186. }
  55187. /**
  55188. * Makes a code path segment for the test part of a WhileStatement.
  55189. *
  55190. * @param {boolean|undefined} test - The test value (only when constant).
  55191. * @returns {void}
  55192. */
  55193. }, {
  55194. key: "makeWhileTest",
  55195. value: function makeWhileTest(test) {
  55196. var context = this.loopContext;
  55197. var forkContext = this.forkContext;
  55198. var testSegments = forkContext.makeNext(0, -1);
  55199. // Update state.
  55200. context.test = test;
  55201. context.continueDestSegments = testSegments;
  55202. forkContext.replaceHead(testSegments);
  55203. }
  55204. /**
  55205. * Makes a code path segment for the body part of a WhileStatement.
  55206. *
  55207. * @returns {void}
  55208. */
  55209. }, {
  55210. key: "makeWhileBody",
  55211. value: function makeWhileBody() {
  55212. var context = this.loopContext;
  55213. var choiceContext = this.choiceContext;
  55214. var forkContext = this.forkContext;
  55215. if (!choiceContext.processed) {
  55216. choiceContext.trueForkContext.add(forkContext.head);
  55217. choiceContext.falseForkContext.add(forkContext.head);
  55218. }
  55219. // Update state.
  55220. if (context.test !== true) {
  55221. context.brokenForkContext.addAll(choiceContext.falseForkContext);
  55222. }
  55223. forkContext.replaceHead(choiceContext.trueForkContext.makeNext(0, -1));
  55224. }
  55225. /**
  55226. * Makes a code path segment for the body part of a DoWhileStatement.
  55227. *
  55228. * @returns {void}
  55229. */
  55230. }, {
  55231. key: "makeDoWhileBody",
  55232. value: function makeDoWhileBody() {
  55233. var context = this.loopContext;
  55234. var forkContext = this.forkContext;
  55235. var bodySegments = forkContext.makeNext(-1, -1);
  55236. // Update state.
  55237. context.entrySegments = bodySegments;
  55238. forkContext.replaceHead(bodySegments);
  55239. }
  55240. /**
  55241. * Makes a code path segment for the test part of a DoWhileStatement.
  55242. *
  55243. * @param {boolean|undefined} test - The test value (only when constant).
  55244. * @returns {void}
  55245. */
  55246. }, {
  55247. key: "makeDoWhileTest",
  55248. value: function makeDoWhileTest(test) {
  55249. var context = this.loopContext;
  55250. var forkContext = this.forkContext;
  55251. context.test = test;
  55252. // Creates paths of `continue` statements.
  55253. if (!context.continueForkContext.empty) {
  55254. context.continueForkContext.add(forkContext.head);
  55255. var testSegments = context.continueForkContext.makeNext(0, -1);
  55256. forkContext.replaceHead(testSegments);
  55257. }
  55258. }
  55259. /**
  55260. * Makes a code path segment for the test part of a ForStatement.
  55261. *
  55262. * @param {boolean|undefined} test - The test value (only when constant).
  55263. * @returns {void}
  55264. */
  55265. }, {
  55266. key: "makeForTest",
  55267. value: function makeForTest(test) {
  55268. var context = this.loopContext;
  55269. var forkContext = this.forkContext;
  55270. var endOfInitSegments = forkContext.head;
  55271. var testSegments = forkContext.makeNext(-1, -1);
  55272. // Update state.
  55273. context.test = test;
  55274. context.endOfInitSegments = endOfInitSegments;
  55275. context.continueDestSegments = context.testSegments = testSegments;
  55276. forkContext.replaceHead(testSegments);
  55277. }
  55278. /**
  55279. * Makes a code path segment for the update part of a ForStatement.
  55280. *
  55281. * @returns {void}
  55282. */
  55283. }, {
  55284. key: "makeForUpdate",
  55285. value: function makeForUpdate() {
  55286. var context = this.loopContext;
  55287. var choiceContext = this.choiceContext;
  55288. var forkContext = this.forkContext;
  55289. // Make the next paths of the test.
  55290. if (context.testSegments) {
  55291. finalizeTestSegmentsOfFor(context, choiceContext, forkContext.head);
  55292. } else {
  55293. context.endOfInitSegments = forkContext.head;
  55294. }
  55295. // Update state.
  55296. var updateSegments = forkContext.makeDisconnected(-1, -1);
  55297. context.continueDestSegments = context.updateSegments = updateSegments;
  55298. forkContext.replaceHead(updateSegments);
  55299. }
  55300. /**
  55301. * Makes a code path segment for the body part of a ForStatement.
  55302. *
  55303. * @returns {void}
  55304. */
  55305. }, {
  55306. key: "makeForBody",
  55307. value: function makeForBody() {
  55308. var context = this.loopContext;
  55309. var choiceContext = this.choiceContext;
  55310. var forkContext = this.forkContext;
  55311. // Update state.
  55312. if (context.updateSegments) {
  55313. context.endOfUpdateSegments = forkContext.head;
  55314. // `update` -> `test`
  55315. if (context.testSegments) {
  55316. makeLooped(this, context.endOfUpdateSegments, context.testSegments);
  55317. }
  55318. } else if (context.testSegments) {
  55319. finalizeTestSegmentsOfFor(context, choiceContext, forkContext.head);
  55320. } else {
  55321. context.endOfInitSegments = forkContext.head;
  55322. }
  55323. var bodySegments = context.endOfTestSegments;
  55324. if (!bodySegments) {
  55325. /*
  55326. * If there is not the `test` part, the `body` path comes from the
  55327. * `init` part and the `update` part.
  55328. */
  55329. var prevForkContext = ForkContext.newEmpty(forkContext);
  55330. prevForkContext.add(context.endOfInitSegments);
  55331. if (context.endOfUpdateSegments) {
  55332. prevForkContext.add(context.endOfUpdateSegments);
  55333. }
  55334. bodySegments = prevForkContext.makeNext(0, -1);
  55335. }
  55336. context.continueDestSegments = context.continueDestSegments || bodySegments;
  55337. forkContext.replaceHead(bodySegments);
  55338. }
  55339. /**
  55340. * Makes a code path segment for the left part of a ForInStatement and a
  55341. * ForOfStatement.
  55342. *
  55343. * @returns {void}
  55344. */
  55345. }, {
  55346. key: "makeForInOfLeft",
  55347. value: function makeForInOfLeft() {
  55348. var context = this.loopContext;
  55349. var forkContext = this.forkContext;
  55350. var leftSegments = forkContext.makeDisconnected(-1, -1);
  55351. // Update state.
  55352. context.prevSegments = forkContext.head;
  55353. context.leftSegments = context.continueDestSegments = leftSegments;
  55354. forkContext.replaceHead(leftSegments);
  55355. }
  55356. /**
  55357. * Makes a code path segment for the right part of a ForInStatement and a
  55358. * ForOfStatement.
  55359. *
  55360. * @returns {void}
  55361. */
  55362. }, {
  55363. key: "makeForInOfRight",
  55364. value: function makeForInOfRight() {
  55365. var context = this.loopContext;
  55366. var forkContext = this.forkContext;
  55367. var temp = ForkContext.newEmpty(forkContext);
  55368. temp.add(context.prevSegments);
  55369. var rightSegments = temp.makeNext(-1, -1);
  55370. // Update state.
  55371. context.endOfLeftSegments = forkContext.head;
  55372. forkContext.replaceHead(rightSegments);
  55373. }
  55374. /**
  55375. * Makes a code path segment for the body part of a ForInStatement and a
  55376. * ForOfStatement.
  55377. *
  55378. * @returns {void}
  55379. */
  55380. }, {
  55381. key: "makeForInOfBody",
  55382. value: function makeForInOfBody() {
  55383. var context = this.loopContext;
  55384. var forkContext = this.forkContext;
  55385. var temp = ForkContext.newEmpty(forkContext);
  55386. temp.add(context.endOfLeftSegments);
  55387. var bodySegments = temp.makeNext(-1, -1);
  55388. // Make a path: `right` -> `left`.
  55389. makeLooped(this, forkContext.head, context.leftSegments);
  55390. // Update state.
  55391. context.brokenForkContext.add(forkContext.head);
  55392. forkContext.replaceHead(bodySegments);
  55393. }
  55394. //--------------------------------------------------------------------------
  55395. // Control Statements
  55396. //--------------------------------------------------------------------------
  55397. /**
  55398. * Creates new context for BreakStatement.
  55399. *
  55400. * @param {boolean} breakable - The flag to indicate it can break by
  55401. * an unlabeled BreakStatement.
  55402. * @param {string|null} label - The label of this context.
  55403. * @returns {Object} The new context.
  55404. */
  55405. }, {
  55406. key: "pushBreakContext",
  55407. value: function pushBreakContext(breakable, label) {
  55408. this.breakContext = {
  55409. upper: this.breakContext,
  55410. breakable: breakable,
  55411. label: label,
  55412. brokenForkContext: ForkContext.newEmpty(this.forkContext)
  55413. };
  55414. return this.breakContext;
  55415. }
  55416. /**
  55417. * Removes the top item of the break context stack.
  55418. *
  55419. * @returns {Object} The removed context.
  55420. */
  55421. }, {
  55422. key: "popBreakContext",
  55423. value: function popBreakContext() {
  55424. var context = this.breakContext;
  55425. var forkContext = this.forkContext;
  55426. this.breakContext = context.upper;
  55427. // Process this context here for other than switches and loops.
  55428. if (!context.breakable) {
  55429. var brokenForkContext = context.brokenForkContext;
  55430. if (!brokenForkContext.empty) {
  55431. brokenForkContext.add(forkContext.head);
  55432. forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
  55433. }
  55434. }
  55435. return context;
  55436. }
  55437. /**
  55438. * Makes a path for a `break` statement.
  55439. *
  55440. * It registers the head segment to a context of `break`.
  55441. * It makes new unreachable segment, then it set the head with the segment.
  55442. *
  55443. * @param {string} label - A label of the break statement.
  55444. * @returns {void}
  55445. */
  55446. }, {
  55447. key: "makeBreak",
  55448. value: function makeBreak(label) {
  55449. var forkContext = this.forkContext;
  55450. if (!forkContext.reachable) {
  55451. return;
  55452. }
  55453. var context = getBreakContext(this, label);
  55454. /* istanbul ignore else: foolproof (syntax error) */
  55455. if (context) {
  55456. context.brokenForkContext.add(forkContext.head);
  55457. }
  55458. forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
  55459. }
  55460. /**
  55461. * Makes a path for a `continue` statement.
  55462. *
  55463. * It makes a looping path.
  55464. * It makes new unreachable segment, then it set the head with the segment.
  55465. *
  55466. * @param {string} label - A label of the continue statement.
  55467. * @returns {void}
  55468. */
  55469. }, {
  55470. key: "makeContinue",
  55471. value: function makeContinue(label) {
  55472. var forkContext = this.forkContext;
  55473. if (!forkContext.reachable) {
  55474. return;
  55475. }
  55476. var context = getContinueContext(this, label);
  55477. /* istanbul ignore else: foolproof (syntax error) */
  55478. if (context) {
  55479. if (context.continueDestSegments) {
  55480. makeLooped(this, forkContext.head, context.continueDestSegments);
  55481. // If the context is a for-in/of loop, this effects a break also.
  55482. if (context.type === "ForInStatement" || context.type === "ForOfStatement") {
  55483. context.brokenForkContext.add(forkContext.head);
  55484. }
  55485. } else {
  55486. context.continueForkContext.add(forkContext.head);
  55487. }
  55488. }
  55489. forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
  55490. }
  55491. /**
  55492. * Makes a path for a `return` statement.
  55493. *
  55494. * It registers the head segment to a context of `return`.
  55495. * It makes new unreachable segment, then it set the head with the segment.
  55496. *
  55497. * @returns {void}
  55498. */
  55499. }, {
  55500. key: "makeReturn",
  55501. value: function makeReturn() {
  55502. var forkContext = this.forkContext;
  55503. if (forkContext.reachable) {
  55504. getReturnContext(this).returnedForkContext.add(forkContext.head);
  55505. forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
  55506. }
  55507. }
  55508. /**
  55509. * Makes a path for a `throw` statement.
  55510. *
  55511. * It registers the head segment to a context of `throw`.
  55512. * It makes new unreachable segment, then it set the head with the segment.
  55513. *
  55514. * @returns {void}
  55515. */
  55516. }, {
  55517. key: "makeThrow",
  55518. value: function makeThrow() {
  55519. var forkContext = this.forkContext;
  55520. if (forkContext.reachable) {
  55521. getThrowContext(this).thrownForkContext.add(forkContext.head);
  55522. forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
  55523. }
  55524. }
  55525. /**
  55526. * Makes the final path.
  55527. * @returns {void}
  55528. */
  55529. }, {
  55530. key: "makeFinal",
  55531. value: function makeFinal() {
  55532. var segments = this.currentSegments;
  55533. if (segments.length > 0 && segments[0].reachable) {
  55534. this.returnedForkContext.add(segments);
  55535. }
  55536. }
  55537. }, {
  55538. key: "headSegments",
  55539. get: function get() {
  55540. return this.forkContext.head;
  55541. }
  55542. /**
  55543. * The parent forking context.
  55544. * This is used for the root of new forks.
  55545. * @type {ForkContext}
  55546. */
  55547. }, {
  55548. key: "parentForkContext",
  55549. get: function get() {
  55550. var current = this.forkContext;
  55551. return current && current.upper;
  55552. }
  55553. }]);
  55554. return CodePathState;
  55555. }();
  55556. module.exports = CodePathState;
  55557. },{"./code-path-segment":113,"./fork-context":117}],115:[function(require,module,exports){
  55558. /**
  55559. * @fileoverview A class of the code path.
  55560. * @author Toru Nagashima
  55561. */
  55562. "use strict";
  55563. //------------------------------------------------------------------------------
  55564. // Requirements
  55565. //------------------------------------------------------------------------------
  55566. 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; }; }();
  55567. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  55568. var CodePathState = require("./code-path-state");
  55569. var IdGenerator = require("./id-generator");
  55570. //------------------------------------------------------------------------------
  55571. // Public Interface
  55572. //------------------------------------------------------------------------------
  55573. /**
  55574. * A code path.
  55575. */
  55576. var CodePath = function () {
  55577. /**
  55578. * @param {string} id - An identifier.
  55579. * @param {CodePath|null} upper - The code path of the upper function scope.
  55580. * @param {Function} onLooped - A callback function to notify looping.
  55581. */
  55582. function CodePath(id, upper, onLooped) {
  55583. _classCallCheck(this, CodePath);
  55584. /**
  55585. * The identifier of this code path.
  55586. * Rules use it to store additional information of each rule.
  55587. * @type {string}
  55588. */
  55589. this.id = id;
  55590. /**
  55591. * The code path of the upper function scope.
  55592. * @type {CodePath|null}
  55593. */
  55594. this.upper = upper;
  55595. /**
  55596. * The code paths of nested function scopes.
  55597. * @type {CodePath[]}
  55598. */
  55599. this.childCodePaths = [];
  55600. // Initializes internal state.
  55601. Object.defineProperty(this, "internal", { value: new CodePathState(new IdGenerator(id + "_"), onLooped) });
  55602. // Adds this into `childCodePaths` of `upper`.
  55603. if (upper) {
  55604. upper.childCodePaths.push(this);
  55605. }
  55606. }
  55607. /**
  55608. * Gets the state of a given code path.
  55609. *
  55610. * @param {CodePath} codePath - A code path to get.
  55611. * @returns {CodePathState} The state of the code path.
  55612. */
  55613. _createClass(CodePath, [{
  55614. key: "traverseSegments",
  55615. /**
  55616. * Traverses all segments in this code path.
  55617. *
  55618. * codePath.traverseSegments(function(segment, controller) {
  55619. * // do something.
  55620. * });
  55621. *
  55622. * This method enumerates segments in order from the head.
  55623. *
  55624. * The `controller` object has two methods.
  55625. *
  55626. * - `controller.skip()` - Skip the following segments in this branch.
  55627. * - `controller.break()` - Skip all following segments.
  55628. *
  55629. * @param {Object} [options] - Omittable.
  55630. * @param {CodePathSegment} [options.first] - The first segment to traverse.
  55631. * @param {CodePathSegment} [options.last] - The last segment to traverse.
  55632. * @param {Function} callback - A callback function.
  55633. * @returns {void}
  55634. */
  55635. value: function traverseSegments(options, callback) {
  55636. var resolvedOptions = void 0;
  55637. var resolvedCallback = void 0;
  55638. if (typeof options === "function") {
  55639. resolvedCallback = options;
  55640. resolvedOptions = {};
  55641. } else {
  55642. resolvedOptions = options || {};
  55643. resolvedCallback = callback;
  55644. }
  55645. var startSegment = resolvedOptions.first || this.internal.initialSegment;
  55646. var lastSegment = resolvedOptions.last;
  55647. var item = null;
  55648. var index = 0;
  55649. var end = 0;
  55650. var segment = null;
  55651. var visited = Object.create(null);
  55652. var stack = [[startSegment, 0]];
  55653. var skippedSegment = null;
  55654. var broken = false;
  55655. var controller = {
  55656. skip: function skip() {
  55657. if (stack.length <= 1) {
  55658. broken = true;
  55659. } else {
  55660. skippedSegment = stack[stack.length - 2][0];
  55661. }
  55662. },
  55663. break: function _break() {
  55664. broken = true;
  55665. }
  55666. };
  55667. /**
  55668. * Checks a given previous segment has been visited.
  55669. * @param {CodePathSegment} prevSegment - A previous segment to check.
  55670. * @returns {boolean} `true` if the segment has been visited.
  55671. */
  55672. function isVisited(prevSegment) {
  55673. return visited[prevSegment.id] || segment.isLoopedPrevSegment(prevSegment);
  55674. }
  55675. while (stack.length > 0) {
  55676. item = stack[stack.length - 1];
  55677. segment = item[0];
  55678. index = item[1];
  55679. if (index === 0) {
  55680. // Skip if this segment has been visited already.
  55681. if (visited[segment.id]) {
  55682. stack.pop();
  55683. continue;
  55684. }
  55685. // Skip if all previous segments have not been visited.
  55686. if (segment !== startSegment && segment.prevSegments.length > 0 && !segment.prevSegments.every(isVisited)) {
  55687. stack.pop();
  55688. continue;
  55689. }
  55690. // Reset the flag of skipping if all branches have been skipped.
  55691. if (skippedSegment && segment.prevSegments.indexOf(skippedSegment) !== -1) {
  55692. skippedSegment = null;
  55693. }
  55694. visited[segment.id] = true;
  55695. // Call the callback when the first time.
  55696. if (!skippedSegment) {
  55697. resolvedCallback.call(this, segment, controller);
  55698. if (segment === lastSegment) {
  55699. controller.skip();
  55700. }
  55701. if (broken) {
  55702. break;
  55703. }
  55704. }
  55705. }
  55706. // Update the stack.
  55707. end = segment.nextSegments.length - 1;
  55708. if (index < end) {
  55709. item[1] += 1;
  55710. stack.push([segment.nextSegments[index], 0]);
  55711. } else if (index === end) {
  55712. item[0] = segment.nextSegments[index];
  55713. item[1] = 0;
  55714. } else {
  55715. stack.pop();
  55716. }
  55717. }
  55718. }
  55719. }, {
  55720. key: "initialSegment",
  55721. /**
  55722. * The initial code path segment.
  55723. * @type {CodePathSegment}
  55724. */
  55725. get: function get() {
  55726. return this.internal.initialSegment;
  55727. }
  55728. /**
  55729. * Final code path segments.
  55730. * This array is a mix of `returnedSegments` and `thrownSegments`.
  55731. * @type {CodePathSegment[]}
  55732. */
  55733. }, {
  55734. key: "finalSegments",
  55735. get: function get() {
  55736. return this.internal.finalSegments;
  55737. }
  55738. /**
  55739. * Final code path segments which is with `return` statements.
  55740. * This array contains the last path segment if it's reachable.
  55741. * Since the reachable last path returns `undefined`.
  55742. * @type {CodePathSegment[]}
  55743. */
  55744. }, {
  55745. key: "returnedSegments",
  55746. get: function get() {
  55747. return this.internal.returnedForkContext;
  55748. }
  55749. /**
  55750. * Final code path segments which is with `throw` statements.
  55751. * @type {CodePathSegment[]}
  55752. */
  55753. }, {
  55754. key: "thrownSegments",
  55755. get: function get() {
  55756. return this.internal.thrownForkContext;
  55757. }
  55758. /**
  55759. * Current code path segments.
  55760. * @type {CodePathSegment[]}
  55761. */
  55762. }, {
  55763. key: "currentSegments",
  55764. get: function get() {
  55765. return this.internal.currentSegments;
  55766. }
  55767. }], [{
  55768. key: "getState",
  55769. value: function getState(codePath) {
  55770. return codePath.internal;
  55771. }
  55772. }]);
  55773. return CodePath;
  55774. }();
  55775. module.exports = CodePath;
  55776. },{"./code-path-state":114,"./id-generator":118}],116:[function(require,module,exports){
  55777. /**
  55778. * @fileoverview Helpers to debug for code path analysis.
  55779. * @author Toru Nagashima
  55780. */
  55781. "use strict";
  55782. //------------------------------------------------------------------------------
  55783. // Requirements
  55784. //------------------------------------------------------------------------------
  55785. var debug = require("debug")("eslint:code-path");
  55786. //------------------------------------------------------------------------------
  55787. // Helpers
  55788. //------------------------------------------------------------------------------
  55789. /**
  55790. * Gets id of a given segment.
  55791. * @param {CodePathSegment} segment - A segment to get.
  55792. * @returns {string} Id of the segment.
  55793. */
  55794. /* istanbul ignore next */
  55795. function getId(segment) {
  55796. // eslint-disable-line require-jsdoc
  55797. return segment.id + (segment.reachable ? "" : "!");
  55798. }
  55799. //------------------------------------------------------------------------------
  55800. // Public Interface
  55801. //------------------------------------------------------------------------------
  55802. module.exports = {
  55803. /**
  55804. * A flag that debug dumping is enabled or not.
  55805. * @type {boolean}
  55806. */
  55807. enabled: debug.enabled,
  55808. /**
  55809. * Dumps given objects.
  55810. *
  55811. * @param {...any} args - objects to dump.
  55812. * @returns {void}
  55813. */
  55814. dump: debug,
  55815. /**
  55816. * Dumps the current analyzing state.
  55817. *
  55818. * @param {ASTNode} node - A node to dump.
  55819. * @param {CodePathState} state - A state to dump.
  55820. * @param {boolean} leaving - A flag whether or not it's leaving
  55821. * @returns {void}
  55822. */
  55823. dumpState: !debug.enabled ? debug : /* istanbul ignore next */function (node, state, leaving) {
  55824. for (var i = 0; i < state.currentSegments.length; ++i) {
  55825. var segInternal = state.currentSegments[i].internal;
  55826. if (leaving) {
  55827. segInternal.exitNodes.push(node);
  55828. } else {
  55829. segInternal.nodes.push(node);
  55830. }
  55831. }
  55832. debug([state.currentSegments.map(getId).join(",") + ")", "" + node.type + (leaving ? ":exit" : "")].join(" "));
  55833. },
  55834. /**
  55835. * Dumps a DOT code of a given code path.
  55836. * The DOT code can be visialized with Graphvis.
  55837. *
  55838. * @param {CodePath} codePath - A code path to dump.
  55839. * @returns {void}
  55840. * @see http://www.graphviz.org
  55841. * @see http://www.webgraphviz.com
  55842. */
  55843. dumpDot: !debug.enabled ? debug : /* istanbul ignore next */function (codePath) {
  55844. var text = "\n" + "digraph {\n" + "node[shape=box,style=\"rounded,filled\",fillcolor=white];\n" + "initial[label=\"\",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
  55845. if (codePath.returnedSegments.length > 0) {
  55846. text += "final[label=\"\",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
  55847. }
  55848. if (codePath.thrownSegments.length > 0) {
  55849. text += "thrown[label=\"✘\",shape=circle,width=0.3,height=0.3,fixedsize];\n";
  55850. }
  55851. var traceMap = Object.create(null);
  55852. var arrows = this.makeDotArrows(codePath, traceMap);
  55853. for (var id in traceMap) {
  55854. // eslint-disable-line guard-for-in
  55855. var segment = traceMap[id];
  55856. text += id + "[";
  55857. if (segment.reachable) {
  55858. text += "label=\"";
  55859. } else {
  55860. text += "style=\"rounded,dashed,filled\",fillcolor=\"#FF9800\",label=\"<<unreachable>>\\n";
  55861. }
  55862. if (segment.internal.nodes.length > 0 || segment.internal.exitNodes.length > 0) {
  55863. text += [].concat(segment.internal.nodes.map(function (node) {
  55864. switch (node.type) {
  55865. case "Identifier":
  55866. return node.type + " (" + node.name + ")";
  55867. case "Literal":
  55868. return node.type + " (" + node.value + ")";
  55869. default:
  55870. return node.type;
  55871. }
  55872. }), segment.internal.exitNodes.map(function (node) {
  55873. switch (node.type) {
  55874. case "Identifier":
  55875. return node.type + ":exit (" + node.name + ")";
  55876. case "Literal":
  55877. return node.type + ":exit (" + node.value + ")";
  55878. default:
  55879. return node.type + ":exit";
  55880. }
  55881. })).join("\\n");
  55882. } else {
  55883. text += "????";
  55884. }
  55885. text += "\"];\n";
  55886. }
  55887. text += arrows + "\n";
  55888. text += "}";
  55889. debug("DOT", text);
  55890. },
  55891. /**
  55892. * Makes a DOT code of a given code path.
  55893. * The DOT code can be visialized with Graphvis.
  55894. *
  55895. * @param {CodePath} codePath - A code path to make DOT.
  55896. * @param {Object} traceMap - Optional. A map to check whether or not segments had been done.
  55897. * @returns {string} A DOT code of the code path.
  55898. */
  55899. makeDotArrows: function makeDotArrows(codePath, traceMap) {
  55900. var stack = [[codePath.initialSegment, 0]];
  55901. var done = traceMap || Object.create(null);
  55902. var lastId = codePath.initialSegment.id;
  55903. var text = "initial->" + codePath.initialSegment.id;
  55904. while (stack.length > 0) {
  55905. var item = stack.pop();
  55906. var segment = item[0];
  55907. var index = item[1];
  55908. if (done[segment.id] && index === 0) {
  55909. continue;
  55910. }
  55911. done[segment.id] = segment;
  55912. var nextSegment = segment.allNextSegments[index];
  55913. if (!nextSegment) {
  55914. continue;
  55915. }
  55916. if (lastId === segment.id) {
  55917. text += "->" + nextSegment.id;
  55918. } else {
  55919. text += ";\n" + segment.id + "->" + nextSegment.id;
  55920. }
  55921. lastId = nextSegment.id;
  55922. stack.unshift([segment, 1 + index]);
  55923. stack.push([nextSegment, 0]);
  55924. }
  55925. codePath.returnedSegments.forEach(function (finalSegment) {
  55926. if (lastId === finalSegment.id) {
  55927. text += "->final";
  55928. } else {
  55929. text += ";\n" + finalSegment.id + "->final";
  55930. }
  55931. lastId = null;
  55932. });
  55933. codePath.thrownSegments.forEach(function (finalSegment) {
  55934. if (lastId === finalSegment.id) {
  55935. text += "->thrown";
  55936. } else {
  55937. text += ";\n" + finalSegment.id + "->thrown";
  55938. }
  55939. lastId = null;
  55940. });
  55941. return text + ";";
  55942. }
  55943. };
  55944. },{"debug":53}],117:[function(require,module,exports){
  55945. /**
  55946. * @fileoverview A class to operate forking.
  55947. *
  55948. * This is state of forking.
  55949. * This has a fork list and manages it.
  55950. *
  55951. * @author Toru Nagashima
  55952. */
  55953. "use strict";
  55954. //------------------------------------------------------------------------------
  55955. // Requirements
  55956. //------------------------------------------------------------------------------
  55957. 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; }; }();
  55958. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  55959. var assert = require("assert"),
  55960. CodePathSegment = require("./code-path-segment");
  55961. //------------------------------------------------------------------------------
  55962. // Helpers
  55963. //------------------------------------------------------------------------------
  55964. /**
  55965. * Gets whether or not a given segment is reachable.
  55966. *
  55967. * @param {CodePathSegment} segment - A segment to get.
  55968. * @returns {boolean} `true` if the segment is reachable.
  55969. */
  55970. function isReachable(segment) {
  55971. return segment.reachable;
  55972. }
  55973. /**
  55974. * Creates new segments from the specific range of `context.segmentsList`.
  55975. *
  55976. * When `context.segmentsList` is `[[a, b], [c, d], [e, f]]`, `begin` is `0`, and
  55977. * `end` is `-1`, this creates `[g, h]`. This `g` is from `a`, `c`, and `e`.
  55978. * This `h` is from `b`, `d`, and `f`.
  55979. *
  55980. * @param {ForkContext} context - An instance.
  55981. * @param {number} begin - The first index of the previous segments.
  55982. * @param {number} end - The last index of the previous segments.
  55983. * @param {Function} create - A factory function of new segments.
  55984. * @returns {CodePathSegment[]} New segments.
  55985. */
  55986. function makeSegments(context, begin, end, create) {
  55987. var list = context.segmentsList;
  55988. var normalizedBegin = begin >= 0 ? begin : list.length + begin;
  55989. var normalizedEnd = end >= 0 ? end : list.length + end;
  55990. var segments = [];
  55991. for (var i = 0; i < context.count; ++i) {
  55992. var allPrevSegments = [];
  55993. for (var j = normalizedBegin; j <= normalizedEnd; ++j) {
  55994. allPrevSegments.push(list[j][i]);
  55995. }
  55996. segments.push(create(context.idGenerator.next(), allPrevSegments));
  55997. }
  55998. return segments;
  55999. }
  56000. /**
  56001. * `segments` becomes doubly in a `finally` block. Then if a code path exits by a
  56002. * control statement (such as `break`, `continue`) from the `finally` block, the
  56003. * destination's segments may be half of the source segments. In that case, this
  56004. * merges segments.
  56005. *
  56006. * @param {ForkContext} context - An instance.
  56007. * @param {CodePathSegment[]} segments - Segments to merge.
  56008. * @returns {CodePathSegment[]} The merged segments.
  56009. */
  56010. function mergeExtraSegments(context, segments) {
  56011. var currentSegments = segments;
  56012. while (currentSegments.length > context.count) {
  56013. var merged = [];
  56014. for (var i = 0, length = currentSegments.length / 2 | 0; i < length; ++i) {
  56015. merged.push(CodePathSegment.newNext(context.idGenerator.next(), [currentSegments[i], currentSegments[i + length]]));
  56016. }
  56017. currentSegments = merged;
  56018. }
  56019. return currentSegments;
  56020. }
  56021. //------------------------------------------------------------------------------
  56022. // Public Interface
  56023. //------------------------------------------------------------------------------
  56024. /**
  56025. * A class to manage forking.
  56026. */
  56027. var ForkContext = function () {
  56028. /**
  56029. * @param {IdGenerator} idGenerator - An identifier generator for segments.
  56030. * @param {ForkContext|null} upper - An upper fork context.
  56031. * @param {number} count - A number of parallel segments.
  56032. */
  56033. function ForkContext(idGenerator, upper, count) {
  56034. _classCallCheck(this, ForkContext);
  56035. this.idGenerator = idGenerator;
  56036. this.upper = upper;
  56037. this.count = count;
  56038. this.segmentsList = [];
  56039. }
  56040. /**
  56041. * The head segments.
  56042. * @type {CodePathSegment[]}
  56043. */
  56044. _createClass(ForkContext, [{
  56045. key: "makeNext",
  56046. /**
  56047. * Creates new segments from this context.
  56048. *
  56049. * @param {number} begin - The first index of previous segments.
  56050. * @param {number} end - The last index of previous segments.
  56051. * @returns {CodePathSegment[]} New segments.
  56052. */
  56053. value: function makeNext(begin, end) {
  56054. return makeSegments(this, begin, end, CodePathSegment.newNext);
  56055. }
  56056. /**
  56057. * Creates new segments from this context.
  56058. * The new segments is always unreachable.
  56059. *
  56060. * @param {number} begin - The first index of previous segments.
  56061. * @param {number} end - The last index of previous segments.
  56062. * @returns {CodePathSegment[]} New segments.
  56063. */
  56064. }, {
  56065. key: "makeUnreachable",
  56066. value: function makeUnreachable(begin, end) {
  56067. return makeSegments(this, begin, end, CodePathSegment.newUnreachable);
  56068. }
  56069. /**
  56070. * Creates new segments from this context.
  56071. * The new segments don't have connections for previous segments.
  56072. * But these inherit the reachable flag from this context.
  56073. *
  56074. * @param {number} begin - The first index of previous segments.
  56075. * @param {number} end - The last index of previous segments.
  56076. * @returns {CodePathSegment[]} New segments.
  56077. */
  56078. }, {
  56079. key: "makeDisconnected",
  56080. value: function makeDisconnected(begin, end) {
  56081. return makeSegments(this, begin, end, CodePathSegment.newDisconnected);
  56082. }
  56083. /**
  56084. * Adds segments into this context.
  56085. * The added segments become the head.
  56086. *
  56087. * @param {CodePathSegment[]} segments - Segments to add.
  56088. * @returns {void}
  56089. */
  56090. }, {
  56091. key: "add",
  56092. value: function add(segments) {
  56093. assert(segments.length >= this.count, segments.length + " >= " + this.count);
  56094. this.segmentsList.push(mergeExtraSegments(this, segments));
  56095. }
  56096. /**
  56097. * Replaces the head segments with given segments.
  56098. * The current head segments are removed.
  56099. *
  56100. * @param {CodePathSegment[]} segments - Segments to add.
  56101. * @returns {void}
  56102. */
  56103. }, {
  56104. key: "replaceHead",
  56105. value: function replaceHead(segments) {
  56106. assert(segments.length >= this.count, segments.length + " >= " + this.count);
  56107. this.segmentsList.splice(-1, 1, mergeExtraSegments(this, segments));
  56108. }
  56109. /**
  56110. * Adds all segments of a given fork context into this context.
  56111. *
  56112. * @param {ForkContext} context - A fork context to add.
  56113. * @returns {void}
  56114. */
  56115. }, {
  56116. key: "addAll",
  56117. value: function addAll(context) {
  56118. assert(context.count === this.count);
  56119. var source = context.segmentsList;
  56120. for (var i = 0; i < source.length; ++i) {
  56121. this.segmentsList.push(source[i]);
  56122. }
  56123. }
  56124. /**
  56125. * Clears all secments in this context.
  56126. *
  56127. * @returns {void}
  56128. */
  56129. }, {
  56130. key: "clear",
  56131. value: function clear() {
  56132. this.segmentsList = [];
  56133. }
  56134. /**
  56135. * Creates the root fork context.
  56136. *
  56137. * @param {IdGenerator} idGenerator - An identifier generator for segments.
  56138. * @returns {ForkContext} New fork context.
  56139. */
  56140. }, {
  56141. key: "head",
  56142. get: function get() {
  56143. var list = this.segmentsList;
  56144. return list.length === 0 ? [] : list[list.length - 1];
  56145. }
  56146. /**
  56147. * A flag which shows empty.
  56148. * @type {boolean}
  56149. */
  56150. }, {
  56151. key: "empty",
  56152. get: function get() {
  56153. return this.segmentsList.length === 0;
  56154. }
  56155. /**
  56156. * A flag which shows reachable.
  56157. * @type {boolean}
  56158. */
  56159. }, {
  56160. key: "reachable",
  56161. get: function get() {
  56162. var segments = this.head;
  56163. return segments.length > 0 && segments.some(isReachable);
  56164. }
  56165. }], [{
  56166. key: "newRoot",
  56167. value: function newRoot(idGenerator) {
  56168. var context = new ForkContext(idGenerator, null, 1);
  56169. context.add([CodePathSegment.newRoot(idGenerator.next())]);
  56170. return context;
  56171. }
  56172. /**
  56173. * Creates an empty fork context preceded by a given context.
  56174. *
  56175. * @param {ForkContext} parentContext - The parent fork context.
  56176. * @param {boolean} forkLeavingPath - A flag which shows inside of `finally` block.
  56177. * @returns {ForkContext} New fork context.
  56178. */
  56179. }, {
  56180. key: "newEmpty",
  56181. value: function newEmpty(parentContext, forkLeavingPath) {
  56182. return new ForkContext(parentContext.idGenerator, parentContext, (forkLeavingPath ? 2 : 1) * parentContext.count);
  56183. }
  56184. }]);
  56185. return ForkContext;
  56186. }();
  56187. module.exports = ForkContext;
  56188. },{"./code-path-segment":113,"assert":46}],118:[function(require,module,exports){
  56189. /**
  56190. * @fileoverview A class of identifiers generator for code path segments.
  56191. *
  56192. * Each rule uses the identifier of code path segments to store additional
  56193. * information of the code path.
  56194. *
  56195. * @author Toru Nagashima
  56196. */
  56197. "use strict";
  56198. //------------------------------------------------------------------------------
  56199. // Public Interface
  56200. //------------------------------------------------------------------------------
  56201. /**
  56202. * A generator for unique ids.
  56203. */
  56204. 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; }; }();
  56205. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  56206. var IdGenerator = function () {
  56207. /**
  56208. * @param {string} prefix - Optional. A prefix of generated ids.
  56209. */
  56210. function IdGenerator(prefix) {
  56211. _classCallCheck(this, IdGenerator);
  56212. this.prefix = String(prefix);
  56213. this.n = 0;
  56214. }
  56215. /**
  56216. * Generates id.
  56217. *
  56218. * @returns {string} A generated id.
  56219. */
  56220. _createClass(IdGenerator, [{
  56221. key: "next",
  56222. value: function next() {
  56223. this.n = 1 + this.n | 0;
  56224. /* istanbul ignore if */
  56225. if (this.n < 0) {
  56226. this.n = 1;
  56227. }
  56228. return this.prefix + this.n;
  56229. }
  56230. }]);
  56231. return IdGenerator;
  56232. }();
  56233. module.exports = IdGenerator;
  56234. },{}],119:[function(require,module,exports){
  56235. /**
  56236. * @fileoverview Config file operations. This file must be usable in the browser,
  56237. * so no Node-specific code can be here.
  56238. * @author Nicholas C. Zakas
  56239. */
  56240. "use strict";
  56241. //------------------------------------------------------------------------------
  56242. // Requirements
  56243. //------------------------------------------------------------------------------
  56244. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  56245. var minimatch = require("minimatch"),
  56246. path = require("path");
  56247. var debug = require("debug")("eslint:config-ops");
  56248. //------------------------------------------------------------------------------
  56249. // Private
  56250. //------------------------------------------------------------------------------
  56251. var RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
  56252. RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce(function (map, value, index) {
  56253. map[value] = index;
  56254. return map;
  56255. }, {}),
  56256. VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];
  56257. //------------------------------------------------------------------------------
  56258. // Public Interface
  56259. //------------------------------------------------------------------------------
  56260. module.exports = {
  56261. /**
  56262. * Creates an empty configuration object suitable for merging as a base.
  56263. * @returns {Object} A configuration object.
  56264. */
  56265. createEmptyConfig: function createEmptyConfig() {
  56266. return {
  56267. globals: {},
  56268. env: {},
  56269. rules: {},
  56270. parserOptions: {}
  56271. };
  56272. },
  56273. /**
  56274. * Creates an environment config based on the specified environments.
  56275. * @param {Object<string,boolean>} env The environment settings.
  56276. * @param {Environments} envContext The environment context.
  56277. * @returns {Object} A configuration object with the appropriate rules and globals
  56278. * set.
  56279. */
  56280. createEnvironmentConfig: function createEnvironmentConfig(env, envContext) {
  56281. var envConfig = this.createEmptyConfig();
  56282. if (env) {
  56283. envConfig.env = env;
  56284. Object.keys(env).filter(function (name) {
  56285. return env[name];
  56286. }).forEach(function (name) {
  56287. var environment = envContext.get(name);
  56288. if (environment) {
  56289. debug("Creating config for environment " + name);
  56290. if (environment.globals) {
  56291. Object.assign(envConfig.globals, environment.globals);
  56292. }
  56293. if (environment.parserOptions) {
  56294. Object.assign(envConfig.parserOptions, environment.parserOptions);
  56295. }
  56296. }
  56297. });
  56298. }
  56299. return envConfig;
  56300. },
  56301. /**
  56302. * Given a config with environment settings, applies the globals and
  56303. * ecmaFeatures to the configuration and returns the result.
  56304. * @param {Object} config The configuration information.
  56305. * @param {Environments} envContent env context.
  56306. * @returns {Object} The updated configuration information.
  56307. */
  56308. applyEnvironments: function applyEnvironments(config, envContent) {
  56309. if (config.env && _typeof(config.env) === "object") {
  56310. debug("Apply environment settings to config");
  56311. return this.merge(this.createEnvironmentConfig(config.env, envContent), config);
  56312. }
  56313. return config;
  56314. },
  56315. /**
  56316. * Merges two config objects. This will not only add missing keys, but will also modify values to match.
  56317. * @param {Object} target config object
  56318. * @param {Object} src config object. Overrides in this config object will take priority over base.
  56319. * @param {boolean} [combine] Whether to combine arrays or not
  56320. * @param {boolean} [isRule] Whether its a rule
  56321. * @returns {Object} merged config object.
  56322. */
  56323. merge: function deepmerge(target, src, combine, isRule) {
  56324. /*
  56325. * The MIT License (MIT)
  56326. *
  56327. * Copyright (c) 2012 Nicholas Fisher
  56328. *
  56329. * Permission is hereby granted, free of charge, to any person obtaining a copy
  56330. * of this software and associated documentation files (the "Software"), to deal
  56331. * in the Software without restriction, including without limitation the rights
  56332. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56333. * copies of the Software, and to permit persons to whom the Software is
  56334. * furnished to do so, subject to the following conditions:
  56335. *
  56336. * The above copyright notice and this permission notice shall be included in
  56337. * all copies or substantial portions of the Software.
  56338. *
  56339. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56340. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56341. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56342. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56343. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56344. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56345. * THE SOFTWARE.
  56346. */
  56347. /*
  56348. * This code is taken from deepmerge repo
  56349. * (https://github.com/KyleAMathews/deepmerge)
  56350. * and modified to meet our needs.
  56351. */
  56352. var array = Array.isArray(src) || Array.isArray(target);
  56353. var dst = array && [] || {};
  56354. if (array) {
  56355. var resolvedTarget = target || [];
  56356. // src could be a string, so check for array
  56357. if (isRule && Array.isArray(src) && src.length > 1) {
  56358. dst = dst.concat(src);
  56359. } else {
  56360. dst = dst.concat(resolvedTarget);
  56361. }
  56362. var resolvedSrc = (typeof src === "undefined" ? "undefined" : _typeof(src)) === "object" ? src : [src];
  56363. Object.keys(resolvedSrc).forEach(function (_, i) {
  56364. var e = resolvedSrc[i];
  56365. if (typeof dst[i] === "undefined") {
  56366. dst[i] = e;
  56367. } else if ((typeof e === "undefined" ? "undefined" : _typeof(e)) === "object") {
  56368. if (isRule) {
  56369. dst[i] = e;
  56370. } else {
  56371. dst[i] = deepmerge(resolvedTarget[i], e, combine, isRule);
  56372. }
  56373. } else {
  56374. if (!combine) {
  56375. dst[i] = e;
  56376. } else {
  56377. if (dst.indexOf(e) === -1) {
  56378. dst.push(e);
  56379. }
  56380. }
  56381. }
  56382. });
  56383. } else {
  56384. if (target && (typeof target === "undefined" ? "undefined" : _typeof(target)) === "object") {
  56385. Object.keys(target).forEach(function (key) {
  56386. dst[key] = target[key];
  56387. });
  56388. }
  56389. Object.keys(src).forEach(function (key) {
  56390. if (key === "overrides") {
  56391. dst[key] = (target[key] || []).concat(src[key] || []);
  56392. } else if (Array.isArray(src[key]) || Array.isArray(target[key])) {
  56393. dst[key] = deepmerge(target[key], src[key], key === "plugins" || key === "extends", isRule);
  56394. } else if (_typeof(src[key]) !== "object" || !src[key] || key === "exported" || key === "astGlobals") {
  56395. dst[key] = src[key];
  56396. } else {
  56397. dst[key] = deepmerge(target[key] || {}, src[key], combine, key === "rules");
  56398. }
  56399. });
  56400. }
  56401. return dst;
  56402. },
  56403. /**
  56404. * Normalizes the severity value of a rule's configuration to a number
  56405. * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally
  56406. * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0),
  56407. * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array
  56408. * whose first element is one of the above values. Strings are matched case-insensitively.
  56409. * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0.
  56410. */
  56411. getRuleSeverity: function getRuleSeverity(ruleConfig) {
  56412. var severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
  56413. if (severityValue === 0 || severityValue === 1 || severityValue === 2) {
  56414. return severityValue;
  56415. }
  56416. if (typeof severityValue === "string") {
  56417. return RULE_SEVERITY[severityValue.toLowerCase()] || 0;
  56418. }
  56419. return 0;
  56420. },
  56421. /**
  56422. * Converts old-style severity settings (0, 1, 2) into new-style
  56423. * severity settings (off, warn, error) for all rules. Assumption is that severity
  56424. * values have already been validated as correct.
  56425. * @param {Object} config The config object to normalize.
  56426. * @returns {void}
  56427. */
  56428. normalizeToStrings: function normalizeToStrings(config) {
  56429. if (config.rules) {
  56430. Object.keys(config.rules).forEach(function (ruleId) {
  56431. var ruleConfig = config.rules[ruleId];
  56432. if (typeof ruleConfig === "number") {
  56433. config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0];
  56434. } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") {
  56435. ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0];
  56436. }
  56437. });
  56438. }
  56439. },
  56440. /**
  56441. * Determines if the severity for the given rule configuration represents an error.
  56442. * @param {int|string|Array} ruleConfig The configuration for an individual rule.
  56443. * @returns {boolean} True if the rule represents an error, false if not.
  56444. */
  56445. isErrorSeverity: function isErrorSeverity(ruleConfig) {
  56446. return module.exports.getRuleSeverity(ruleConfig) === 2;
  56447. },
  56448. /**
  56449. * Checks whether a given config has valid severity or not.
  56450. * @param {number|string|Array} ruleConfig - The configuration for an individual rule.
  56451. * @returns {boolean} `true` if the configuration has valid severity.
  56452. */
  56453. isValidSeverity: function isValidSeverity(ruleConfig) {
  56454. var severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
  56455. if (typeof severity === "string") {
  56456. severity = severity.toLowerCase();
  56457. }
  56458. return VALID_SEVERITIES.indexOf(severity) !== -1;
  56459. },
  56460. /**
  56461. * Checks whether every rule of a given config has valid severity or not.
  56462. * @param {Object} config - The configuration for rules.
  56463. * @returns {boolean} `true` if the configuration has valid severity.
  56464. */
  56465. isEverySeverityValid: function isEverySeverityValid(config) {
  56466. var _this = this;
  56467. return Object.keys(config).every(function (ruleId) {
  56468. return _this.isValidSeverity(config[ruleId]);
  56469. });
  56470. },
  56471. /**
  56472. * Merges all configurations in a given config vector. A vector is an array of objects, each containing a config
  56473. * file path and a list of subconfig indices that match the current file path. All config data is assumed to be
  56474. * cached.
  56475. * @param {Array<Object>} vector list of config files and their subconfig indices that match the current file path
  56476. * @param {Object} configCache the config cache
  56477. * @returns {Object} config object
  56478. */
  56479. getConfigFromVector: function getConfigFromVector(vector, configCache) {
  56480. var cachedConfig = configCache.getMergedVectorConfig(vector);
  56481. if (cachedConfig) {
  56482. return cachedConfig;
  56483. }
  56484. debug("Using config from partial cache");
  56485. var subvector = Array.from(vector);
  56486. var nearestCacheIndex = subvector.length - 1,
  56487. partialCachedConfig = void 0;
  56488. while (nearestCacheIndex >= 0) {
  56489. partialCachedConfig = configCache.getMergedVectorConfig(subvector);
  56490. if (partialCachedConfig) {
  56491. break;
  56492. }
  56493. subvector.pop();
  56494. nearestCacheIndex--;
  56495. }
  56496. if (!partialCachedConfig) {
  56497. partialCachedConfig = {};
  56498. }
  56499. var finalConfig = partialCachedConfig;
  56500. // Start from entry immediately following nearest cached config (first uncached entry)
  56501. for (var i = nearestCacheIndex + 1; i < vector.length; i++) {
  56502. finalConfig = this.mergeVectorEntry(finalConfig, vector[i], configCache);
  56503. configCache.setMergedVectorConfig(vector.slice(0, i + 1), finalConfig);
  56504. }
  56505. return finalConfig;
  56506. },
  56507. /**
  56508. * Merges the config options from a single vector entry into the supplied config.
  56509. * @param {Object} config the base config to merge the vector entry's options into
  56510. * @param {Object} vectorEntry a single entry from a vector, consisting of a config file path and an array of
  56511. * matching override indices
  56512. * @param {Object} configCache the config cache
  56513. * @returns {Object} merged config object
  56514. */
  56515. mergeVectorEntry: function mergeVectorEntry(config, vectorEntry, configCache) {
  56516. var _this2 = this;
  56517. var vectorEntryConfig = Object.assign({}, configCache.getConfig(vectorEntry.filePath));
  56518. var mergedConfig = Object.assign({}, config),
  56519. overrides = void 0;
  56520. if (vectorEntryConfig.overrides) {
  56521. overrides = vectorEntryConfig.overrides.filter(function (override, overrideIndex) {
  56522. return vectorEntry.matchingOverrides.indexOf(overrideIndex) !== -1;
  56523. });
  56524. } else {
  56525. overrides = [];
  56526. }
  56527. mergedConfig = this.merge(mergedConfig, vectorEntryConfig);
  56528. delete mergedConfig.overrides;
  56529. mergedConfig = overrides.reduce(function (lastConfig, override) {
  56530. return _this2.merge(lastConfig, override);
  56531. }, mergedConfig);
  56532. if (mergedConfig.filePath) {
  56533. delete mergedConfig.filePath;
  56534. delete mergedConfig.baseDirectory;
  56535. } else if (mergedConfig.files) {
  56536. delete mergedConfig.files;
  56537. }
  56538. return mergedConfig;
  56539. },
  56540. /**
  56541. * Checks that the specified file path matches all of the supplied glob patterns.
  56542. * @param {string} filePath The file path to test patterns against
  56543. * @param {string|string[]} patterns One or more glob patterns, of which at least one should match the file path
  56544. * @param {string|string[]} [excludedPatterns] One or more glob patterns, of which none should match the file path
  56545. * @returns {boolean} True if all the supplied patterns match the file path, false otherwise
  56546. */
  56547. pathMatchesGlobs: function pathMatchesGlobs(filePath, patterns, excludedPatterns) {
  56548. var patternList = [].concat(patterns);
  56549. var excludedPatternList = [].concat(excludedPatterns || []);
  56550. patternList.concat(excludedPatternList).forEach(function (pattern) {
  56551. if (path.isAbsolute(pattern) || pattern.includes("..")) {
  56552. throw new Error("Invalid override pattern (expected relative path not containing '..'): " + pattern);
  56553. }
  56554. });
  56555. var opts = { matchBase: true };
  56556. return patternList.some(function (pattern) {
  56557. return minimatch(filePath, pattern, opts);
  56558. }) && !excludedPatternList.some(function (excludedPattern) {
  56559. return minimatch(filePath, excludedPattern, opts);
  56560. });
  56561. }
  56562. };
  56563. },{"debug":53,"minimatch":93,"path":96}],120:[function(require,module,exports){
  56564. (function (process){
  56565. /**
  56566. * @fileoverview Validates configs.
  56567. * @author Brandon Mills
  56568. */
  56569. "use strict";
  56570. //------------------------------------------------------------------------------
  56571. // Requirements
  56572. //------------------------------------------------------------------------------
  56573. var path = require("path"),
  56574. ajv = require("../util/ajv"),
  56575. lodash = require("lodash"),
  56576. configSchema = require("../../conf/config-schema.js"),
  56577. util = require("util");
  56578. var ruleValidators = new WeakMap();
  56579. //------------------------------------------------------------------------------
  56580. // Private
  56581. //------------------------------------------------------------------------------
  56582. var validateSchema = void 0;
  56583. // Defitions for deprecation warnings.
  56584. var deprecationWarningMessages = {
  56585. ESLINT_LEGACY_ECMAFEATURES: "The 'ecmaFeatures' config file property is deprecated, and has no effect.",
  56586. ESLINT_LEGACY_OBJECT_REST_SPREAD: "The 'parserOptions.ecmaFeatures.experimentalObjectRestSpread' option is deprecated. Use 'parserOptions.ecmaVersion' instead."
  56587. };
  56588. var severityMap = {
  56589. error: 2,
  56590. warn: 1,
  56591. off: 0
  56592. };
  56593. /**
  56594. * Gets a complete options schema for a rule.
  56595. * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
  56596. * @returns {Object} JSON Schema for the rule's options.
  56597. */
  56598. function getRuleOptionsSchema(rule) {
  56599. var schema = rule.schema || rule.meta && rule.meta.schema;
  56600. // Given a tuple of schemas, insert warning level at the beginning
  56601. if (Array.isArray(schema)) {
  56602. if (schema.length) {
  56603. return {
  56604. type: "array",
  56605. items: schema,
  56606. minItems: 0,
  56607. maxItems: schema.length
  56608. };
  56609. }
  56610. return {
  56611. type: "array",
  56612. minItems: 0,
  56613. maxItems: 0
  56614. };
  56615. }
  56616. // Given a full schema, leave it alone
  56617. return schema || null;
  56618. }
  56619. /**
  56620. * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
  56621. * @param {options} options The given options for the rule.
  56622. * @returns {number|string} The rule's severity value
  56623. */
  56624. function validateRuleSeverity(options) {
  56625. var severity = Array.isArray(options) ? options[0] : options;
  56626. var normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
  56627. if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
  56628. return normSeverity;
  56629. }
  56630. throw new Error("\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '" + util.inspect(severity).replace(/'/g, "\"").replace(/\n/g, "") + "').\n");
  56631. }
  56632. /**
  56633. * Validates the non-severity options passed to a rule, based on its schema.
  56634. * @param {{create: Function}} rule The rule to validate
  56635. * @param {Array} localOptions The options for the rule, excluding severity
  56636. * @returns {void}
  56637. */
  56638. function validateRuleSchema(rule, localOptions) {
  56639. if (!ruleValidators.has(rule)) {
  56640. var schema = getRuleOptionsSchema(rule);
  56641. if (schema) {
  56642. ruleValidators.set(rule, ajv.compile(schema));
  56643. }
  56644. }
  56645. var validateRule = ruleValidators.get(rule);
  56646. if (validateRule) {
  56647. validateRule(localOptions);
  56648. if (validateRule.errors) {
  56649. throw new Error(validateRule.errors.map(function (error) {
  56650. return "\tValue " + JSON.stringify(error.data) + " " + error.message + ".\n";
  56651. }).join(""));
  56652. }
  56653. }
  56654. }
  56655. /**
  56656. * Validates a rule's options against its schema.
  56657. * @param {{create: Function}|null} rule The rule that the config is being validated for
  56658. * @param {string} ruleId The rule's unique name.
  56659. * @param {Array|number} options The given options for the rule.
  56660. * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
  56661. * no source is prepended to the message.
  56662. * @returns {void}
  56663. */
  56664. function validateRuleOptions(rule, ruleId, options, source) {
  56665. if (!rule) {
  56666. return;
  56667. }
  56668. try {
  56669. var severity = validateRuleSeverity(options);
  56670. if (severity !== 0) {
  56671. validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
  56672. }
  56673. } catch (err) {
  56674. var enhancedMessage = "Configuration for rule \"" + ruleId + "\" is invalid:\n" + err.message;
  56675. if (typeof source === "string") {
  56676. throw new Error(source + ":\n\t" + enhancedMessage);
  56677. } else {
  56678. throw new Error(enhancedMessage);
  56679. }
  56680. }
  56681. }
  56682. /**
  56683. * Validates an environment object
  56684. * @param {Object} environment The environment config object to validate.
  56685. * @param {string} source The name of the configuration source to report in any errors.
  56686. * @param {Environments} envContext Env context
  56687. * @returns {void}
  56688. */
  56689. function validateEnvironment(environment, source, envContext) {
  56690. // not having an environment is ok
  56691. if (!environment) {
  56692. return;
  56693. }
  56694. Object.keys(environment).forEach(function (env) {
  56695. if (!envContext.get(env)) {
  56696. var message = source + ":\n\tEnvironment key \"" + env + "\" is unknown\n";
  56697. throw new Error(message);
  56698. }
  56699. });
  56700. }
  56701. /**
  56702. * Validates a rules config object
  56703. * @param {Object} rulesConfig The rules config object to validate.
  56704. * @param {string} source The name of the configuration source to report in any errors.
  56705. * @param {function(string): {create: Function}} ruleMapper A mapper function from strings to loaded rules
  56706. * @returns {void}
  56707. */
  56708. function validateRules(rulesConfig, source, ruleMapper) {
  56709. if (!rulesConfig) {
  56710. return;
  56711. }
  56712. Object.keys(rulesConfig).forEach(function (id) {
  56713. validateRuleOptions(ruleMapper(id), id, rulesConfig[id], source);
  56714. });
  56715. }
  56716. /**
  56717. * Formats an array of schema validation errors.
  56718. * @param {Array} errors An array of error messages to format.
  56719. * @returns {string} Formatted error message
  56720. */
  56721. function formatErrors(errors) {
  56722. return errors.map(function (error) {
  56723. if (error.keyword === "additionalProperties") {
  56724. var formattedPropertyPath = error.dataPath.length ? error.dataPath.slice(1) + "." + error.params.additionalProperty : error.params.additionalProperty;
  56725. return "Unexpected top-level property \"" + formattedPropertyPath + "\"";
  56726. }
  56727. if (error.keyword === "type") {
  56728. var formattedField = error.dataPath.slice(1);
  56729. var formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
  56730. var formattedValue = JSON.stringify(error.data);
  56731. return "Property \"" + formattedField + "\" is the wrong type (expected " + formattedExpectedType + " but got `" + formattedValue + "`)";
  56732. }
  56733. var field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
  56734. return "\"" + field + "\" " + error.message + ". Value: " + JSON.stringify(error.data);
  56735. }).map(function (message) {
  56736. return "\t- " + message + ".\n";
  56737. }).join("");
  56738. }
  56739. /**
  56740. * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
  56741. * for each unique file path, but repeated invocations with the same file path have no effect.
  56742. * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
  56743. * @param {string} source The name of the configuration source to report the warning for.
  56744. * @param {string} errorCode The warning message to show.
  56745. * @returns {void}
  56746. */
  56747. var emitDeprecationWarning = lodash.memoize(function (source, errorCode) {
  56748. var rel = path.relative(process.cwd(), source);
  56749. var message = deprecationWarningMessages[errorCode];
  56750. process.emitWarning(message + " (found in \"" + rel + "\")", "DeprecationWarning", errorCode);
  56751. });
  56752. /**
  56753. * Validates the top level properties of the config object.
  56754. * @param {Object} config The config object to validate.
  56755. * @param {string} source The name of the configuration source to report in any errors.
  56756. * @returns {void}
  56757. */
  56758. function validateConfigSchema(config, source) {
  56759. validateSchema = validateSchema || ajv.compile(configSchema);
  56760. if (!validateSchema(config)) {
  56761. throw new Error("ESLint configuration in " + source + " is invalid:\n" + formatErrors(validateSchema.errors));
  56762. }
  56763. if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
  56764. emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
  56765. }
  56766. if ((config.parser || "espree") === "espree" && config.parserOptions && config.parserOptions.ecmaFeatures && config.parserOptions.ecmaFeatures.experimentalObjectRestSpread) {
  56767. emitDeprecationWarning(source, "ESLINT_LEGACY_OBJECT_REST_SPREAD");
  56768. }
  56769. }
  56770. /**
  56771. * Validates an entire config object.
  56772. * @param {Object} config The config object to validate.
  56773. * @param {string} source The name of the configuration source to report in any errors.
  56774. * @param {function(string): {create: Function}} ruleMapper A mapper function from rule IDs to defined rules
  56775. * @param {Environments} envContext The env context
  56776. * @returns {void}
  56777. */
  56778. function validate(config, source, ruleMapper, envContext) {
  56779. validateConfigSchema(config, source);
  56780. validateRules(config.rules, source, ruleMapper);
  56781. validateEnvironment(config.env, source, envContext);
  56782. var _iteratorNormalCompletion = true;
  56783. var _didIteratorError = false;
  56784. var _iteratorError = undefined;
  56785. try {
  56786. for (var _iterator = (config.overrides || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  56787. var override = _step.value;
  56788. validateRules(override.rules, source, ruleMapper);
  56789. validateEnvironment(override.env, source, envContext);
  56790. }
  56791. } catch (err) {
  56792. _didIteratorError = true;
  56793. _iteratorError = err;
  56794. } finally {
  56795. try {
  56796. if (!_iteratorNormalCompletion && _iterator.return) {
  56797. _iterator.return();
  56798. }
  56799. } finally {
  56800. if (_didIteratorError) {
  56801. throw _iteratorError;
  56802. }
  56803. }
  56804. }
  56805. }
  56806. //------------------------------------------------------------------------------
  56807. // Public Interface
  56808. //------------------------------------------------------------------------------
  56809. module.exports = {
  56810. getRuleOptionsSchema: getRuleOptionsSchema,
  56811. validate: validate,
  56812. validateRuleOptions: validateRuleOptions
  56813. };
  56814. }).call(this,require('_process'))
  56815. },{"../../conf/config-schema.js":1,"../util/ajv":403,"_process":103,"lodash":92,"path":96,"util":110}],121:[function(require,module,exports){
  56816. /**
  56817. * @fileoverview Environments manager
  56818. * @author Nicholas C. Zakas
  56819. */
  56820. "use strict";
  56821. //------------------------------------------------------------------------------
  56822. // Requirements
  56823. //------------------------------------------------------------------------------
  56824. 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; }; }();
  56825. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  56826. var envs = require("../../conf/environments");
  56827. //------------------------------------------------------------------------------
  56828. // Public Interface
  56829. //------------------------------------------------------------------------------
  56830. var Environments = function () {
  56831. /**
  56832. * create env context
  56833. */
  56834. function Environments() {
  56835. _classCallCheck(this, Environments);
  56836. this._environments = new Map();
  56837. this.load();
  56838. }
  56839. /**
  56840. * Loads the default environments.
  56841. * @returns {void}
  56842. * @private
  56843. */
  56844. _createClass(Environments, [{
  56845. key: "load",
  56846. value: function load() {
  56847. var _this = this;
  56848. Object.keys(envs).forEach(function (envName) {
  56849. _this._environments.set(envName, envs[envName]);
  56850. });
  56851. }
  56852. /**
  56853. * Gets the environment with the given name.
  56854. * @param {string} name The name of the environment to retrieve.
  56855. * @returns {Object?} The environment object or null if not found.
  56856. */
  56857. }, {
  56858. key: "get",
  56859. value: function get(name) {
  56860. return this._environments.get(name) || null;
  56861. }
  56862. /**
  56863. * Gets all the environment present
  56864. * @returns {Object} The environment object for each env name
  56865. */
  56866. }, {
  56867. key: "getAll",
  56868. value: function getAll() {
  56869. return Array.from(this._environments).reduce(function (coll, env) {
  56870. coll[env[0]] = env[1];
  56871. return coll;
  56872. }, {});
  56873. }
  56874. /**
  56875. * Defines an environment.
  56876. * @param {string} name The name of the environment.
  56877. * @param {Object} env The environment settings.
  56878. * @returns {void}
  56879. */
  56880. }, {
  56881. key: "define",
  56882. value: function define(name, env) {
  56883. this._environments.set(name, env);
  56884. }
  56885. /**
  56886. * Imports all environments from a plugin.
  56887. * @param {Object} plugin The plugin object.
  56888. * @param {string} pluginName The name of the plugin.
  56889. * @returns {void}
  56890. */
  56891. }, {
  56892. key: "importPlugin",
  56893. value: function importPlugin(plugin, pluginName) {
  56894. var _this2 = this;
  56895. if (plugin.environments) {
  56896. Object.keys(plugin.environments).forEach(function (envName) {
  56897. _this2.define(pluginName + "/" + envName, plugin.environments[envName]);
  56898. });
  56899. }
  56900. }
  56901. }]);
  56902. return Environments;
  56903. }();
  56904. module.exports = Environments;
  56905. },{"../../conf/environments":2}],122:[function(require,module,exports){
  56906. /**
  56907. * @fileoverview Main Linter Class
  56908. * @author Gyandeep Singh
  56909. */
  56910. "use strict";
  56911. //------------------------------------------------------------------------------
  56912. // Requirements
  56913. //------------------------------------------------------------------------------
  56914. 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; }; }();
  56915. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  56916. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  56917. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  56918. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  56919. var eslintScope = require("eslint-scope"),
  56920. evk = require("eslint-visitor-keys"),
  56921. lodash = require("lodash"),
  56922. CodePathAnalyzer = require("./code-path-analysis/code-path-analyzer"),
  56923. ConfigOps = require("./config/config-ops"),
  56924. validator = require("./config/config-validator"),
  56925. Environments = require("./config/environments"),
  56926. applyDisableDirectives = require("./util/apply-disable-directives"),
  56927. createEmitter = require("./util/safe-emitter"),
  56928. NodeEventGenerator = require("./util/node-event-generator"),
  56929. SourceCode = require("./util/source-code"),
  56930. Traverser = require("./util/traverser"),
  56931. createReportTranslator = require("./util/report-translator"),
  56932. Rules = require("./rules"),
  56933. timing = require("./util/timing"),
  56934. ConfigCommentParser = require("./util/config-comment-parser"),
  56935. astUtils = require("./util/ast-utils"),
  56936. pkg = require("../package.json"),
  56937. SourceCodeFixer = require("./util/source-code-fixer");
  56938. var debug = require("debug")("eslint:linter");
  56939. var MAX_AUTOFIX_PASSES = 10;
  56940. var DEFAULT_PARSER_NAME = "espree";
  56941. var commentParser = new ConfigCommentParser();
  56942. //------------------------------------------------------------------------------
  56943. // Typedefs
  56944. //------------------------------------------------------------------------------
  56945. /**
  56946. * The result of a parsing operation from parseForESLint()
  56947. * @typedef {Object} CustomParseResult
  56948. * @property {ASTNode} ast The ESTree AST Program node.
  56949. * @property {Object} services An object containing additional services related
  56950. * to the parser.
  56951. * @property {ScopeManager|null} scopeManager The scope manager object of this AST.
  56952. * @property {Object|null} visitorKeys The visitor keys to traverse this AST.
  56953. */
  56954. /**
  56955. * @typedef {Object} DisableDirective
  56956. * @property {("disable"|"enable"|"disable-line"|"disable-next-line")} type
  56957. * @property {number} line
  56958. * @property {number} column
  56959. * @property {(string|null)} ruleId
  56960. */
  56961. //------------------------------------------------------------------------------
  56962. // Helpers
  56963. //------------------------------------------------------------------------------
  56964. /**
  56965. * Ensures that variables representing built-in properties of the Global Object,
  56966. * and any globals declared by special block comments, are present in the global
  56967. * scope.
  56968. * @param {Scope} globalScope The global scope.
  56969. * @param {Object} configGlobals The globals declared in configuration
  56970. * @param {{exportedVariables: Object, enabledGlobals: Object}} commentDirectives Directives from comment configuration
  56971. * @returns {void}
  56972. */
  56973. function addDeclaredGlobals(globalScope, configGlobals, commentDirectives) {
  56974. Object.keys(configGlobals).forEach(function (name) {
  56975. var variable = globalScope.set.get(name);
  56976. if (!variable) {
  56977. variable = new eslintScope.Variable(name, globalScope);
  56978. variable.eslintExplicitGlobal = false;
  56979. globalScope.variables.push(variable);
  56980. globalScope.set.set(name, variable);
  56981. }
  56982. variable.writeable = configGlobals[name];
  56983. });
  56984. Object.keys(commentDirectives.enabledGlobals).forEach(function (name) {
  56985. var variable = globalScope.set.get(name);
  56986. if (!variable) {
  56987. variable = new eslintScope.Variable(name, globalScope);
  56988. variable.eslintExplicitGlobal = true;
  56989. variable.eslintExplicitGlobalComment = commentDirectives.enabledGlobals[name].comment;
  56990. globalScope.variables.push(variable);
  56991. globalScope.set.set(name, variable);
  56992. }
  56993. variable.writeable = commentDirectives.enabledGlobals[name].value;
  56994. });
  56995. // mark all exported variables as such
  56996. Object.keys(commentDirectives.exportedVariables).forEach(function (name) {
  56997. var variable = globalScope.set.get(name);
  56998. if (variable) {
  56999. variable.eslintUsed = true;
  57000. }
  57001. });
  57002. /*
  57003. * "through" contains all references which definitions cannot be found.
  57004. * Since we augment the global scope using configuration, we need to update
  57005. * references and remove the ones that were added by configuration.
  57006. */
  57007. globalScope.through = globalScope.through.filter(function (reference) {
  57008. var name = reference.identifier.name;
  57009. var variable = globalScope.set.get(name);
  57010. if (variable) {
  57011. /*
  57012. * Links the variable and the reference.
  57013. * And this reference is removed from `Scope#through`.
  57014. */
  57015. reference.resolved = variable;
  57016. variable.references.push(reference);
  57017. return false;
  57018. }
  57019. return true;
  57020. });
  57021. }
  57022. /**
  57023. * Creates a collection of disable directives from a comment
  57024. * @param {("disable"|"enable"|"disable-line"|"disable-next-line")} type The type of directive comment
  57025. * @param {{line: number, column: number}} loc The 0-based location of the comment token
  57026. * @param {string} value The value after the directive in the comment
  57027. * comment specified no specific rules, so it applies to all rules (e.g. `eslint-disable`)
  57028. * @returns {DisableDirective[]} Directives from the comment
  57029. */
  57030. function createDisableDirectives(type, loc, value) {
  57031. var ruleIds = Object.keys(commentParser.parseListConfig(value));
  57032. var directiveRules = ruleIds.length ? ruleIds : [null];
  57033. return directiveRules.map(function (ruleId) {
  57034. return { type: type, line: loc.line, column: loc.column + 1, ruleId: ruleId };
  57035. });
  57036. }
  57037. /**
  57038. * Parses comments in file to extract file-specific config of rules, globals
  57039. * and environments and merges them with global config; also code blocks
  57040. * where reporting is disabled or enabled and merges them with reporting config.
  57041. * @param {string} filename The file being checked.
  57042. * @param {ASTNode} ast The top node of the AST.
  57043. * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
  57044. * @returns {{configuredRules: Object, enabledGlobals: Object, exportedVariables: Object, problems: Problem[], disableDirectives: DisableDirective[]}}
  57045. * A collection of the directive comments that were found, along with any problems that occurred when parsing
  57046. */
  57047. function getDirectiveComments(filename, ast, ruleMapper) {
  57048. var configuredRules = {};
  57049. var enabledGlobals = {};
  57050. var exportedVariables = {};
  57051. var problems = [];
  57052. var disableDirectives = [];
  57053. ast.comments.filter(function (token) {
  57054. return token.type !== "Shebang";
  57055. }).forEach(function (comment) {
  57056. var trimmedCommentText = comment.value.trim();
  57057. var match = /^(eslint(-\w+){0,3}|exported|globals?)(\s|$)/.exec(trimmedCommentText);
  57058. if (!match) {
  57059. return;
  57060. }
  57061. var directiveValue = trimmedCommentText.slice(match.index + match[1].length);
  57062. if (/^eslint-disable-(next-)?line$/.test(match[1])) {
  57063. if (comment.loc.start.line === comment.loc.end.line) {
  57064. var directiveType = match[1].slice("eslint-".length);
  57065. disableDirectives.push.apply(disableDirectives, _toConsumableArray(createDisableDirectives(directiveType, comment.loc.start, directiveValue)));
  57066. } else {
  57067. problems.push({
  57068. ruleId: null,
  57069. severity: 2,
  57070. message: match[1] + " comment should not span multiple lines.",
  57071. line: comment.loc.start.line,
  57072. column: comment.loc.start.column + 1,
  57073. endLine: comment.loc.end.line,
  57074. endColumn: comment.loc.end.column + 1,
  57075. nodeType: null
  57076. });
  57077. }
  57078. } else if (comment.type === "Block") {
  57079. switch (match[1]) {
  57080. case "exported":
  57081. Object.assign(exportedVariables, commentParser.parseBooleanConfig(directiveValue, comment));
  57082. break;
  57083. case "globals":
  57084. case "global":
  57085. Object.assign(enabledGlobals, commentParser.parseBooleanConfig(directiveValue, comment));
  57086. break;
  57087. case "eslint-disable":
  57088. disableDirectives.push.apply(disableDirectives, _toConsumableArray(createDisableDirectives("disable", comment.loc.start, directiveValue)));
  57089. break;
  57090. case "eslint-enable":
  57091. disableDirectives.push.apply(disableDirectives, _toConsumableArray(createDisableDirectives("enable", comment.loc.start, directiveValue)));
  57092. break;
  57093. case "eslint":
  57094. {
  57095. var parseResult = commentParser.parseJsonConfig(directiveValue, comment.loc);
  57096. if (parseResult.success) {
  57097. Object.keys(parseResult.config).forEach(function (name) {
  57098. var ruleValue = parseResult.config[name];
  57099. try {
  57100. validator.validateRuleOptions(ruleMapper(name), name, ruleValue);
  57101. } catch (err) {
  57102. problems.push({
  57103. ruleId: name,
  57104. severity: 2,
  57105. message: err.message,
  57106. line: comment.loc.start.line,
  57107. column: comment.loc.start.column + 1,
  57108. endLine: comment.loc.end.line,
  57109. endColumn: comment.loc.end.column + 1,
  57110. nodeType: null
  57111. });
  57112. }
  57113. configuredRules[name] = ruleValue;
  57114. });
  57115. } else {
  57116. problems.push(parseResult.error);
  57117. }
  57118. break;
  57119. }
  57120. // no default
  57121. }
  57122. }
  57123. });
  57124. return {
  57125. configuredRules: configuredRules,
  57126. enabledGlobals: enabledGlobals,
  57127. exportedVariables: exportedVariables,
  57128. problems: problems,
  57129. disableDirectives: disableDirectives
  57130. };
  57131. }
  57132. /**
  57133. * Normalize ECMAScript version from the initial config
  57134. * @param {number} ecmaVersion ECMAScript version from the initial config
  57135. * @param {boolean} isModule Whether the source type is module or not
  57136. * @returns {number} normalized ECMAScript version
  57137. */
  57138. function normalizeEcmaVersion(ecmaVersion, isModule) {
  57139. // Need at least ES6 for modules
  57140. if (isModule && (!ecmaVersion || ecmaVersion < 6)) {
  57141. return 6;
  57142. }
  57143. /*
  57144. * Calculate ECMAScript edition number from official year version starting with
  57145. * ES2015, which corresponds with ES6 (or a difference of 2009).
  57146. */
  57147. if (ecmaVersion >= 2015) {
  57148. return ecmaVersion - 2009;
  57149. }
  57150. return ecmaVersion;
  57151. }
  57152. var eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)\*\//g;
  57153. /**
  57154. * Checks whether or not there is a comment which has "eslint-env *" in a given text.
  57155. * @param {string} text - A source code text to check.
  57156. * @returns {Object|null} A result of parseListConfig() with "eslint-env *" comment.
  57157. */
  57158. function findEslintEnv(text) {
  57159. var match = void 0,
  57160. retv = void 0;
  57161. eslintEnvPattern.lastIndex = 0;
  57162. while (match = eslintEnvPattern.exec(text)) {
  57163. retv = Object.assign(retv || {}, commentParser.parseListConfig(match[1]));
  57164. }
  57165. return retv;
  57166. }
  57167. /**
  57168. * Normalizes the possible options for `linter.verify` and `linter.verifyAndFix` to a
  57169. * consistent shape.
  57170. * @param {(string|{reportUnusedDisableDirectives: boolean, filename: string, allowInlineConfig: boolean})} providedOptions Options
  57171. * @returns {{reportUnusedDisableDirectives: boolean, filename: string, allowInlineConfig: boolean}} Normalized options
  57172. */
  57173. function normalizeVerifyOptions(providedOptions) {
  57174. var isObjectOptions = (typeof providedOptions === "undefined" ? "undefined" : _typeof(providedOptions)) === "object";
  57175. var providedFilename = isObjectOptions ? providedOptions.filename : providedOptions;
  57176. return {
  57177. filename: typeof providedFilename === "string" ? providedFilename : "<input>",
  57178. allowInlineConfig: !isObjectOptions || providedOptions.allowInlineConfig !== false,
  57179. reportUnusedDisableDirectives: isObjectOptions && !!providedOptions.reportUnusedDisableDirectives
  57180. };
  57181. }
  57182. /**
  57183. * Combines the provided parserOptions with the options from environments
  57184. * @param {string} parserName The parser name which uses this options.
  57185. * @param {Object} providedOptions The provided 'parserOptions' key in a config
  57186. * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
  57187. * @returns {Object} Resulting parser options after merge
  57188. */
  57189. function resolveParserOptions(parserName, providedOptions, enabledEnvironments) {
  57190. var parserOptionsFromEnv = enabledEnvironments.filter(function (env) {
  57191. return env.parserOptions;
  57192. }).reduce(function (parserOptions, env) {
  57193. return ConfigOps.merge(parserOptions, env.parserOptions);
  57194. }, {});
  57195. var mergedParserOptions = ConfigOps.merge(parserOptionsFromEnv, providedOptions || {});
  57196. var isModule = mergedParserOptions.sourceType === "module";
  57197. if (isModule) {
  57198. // can't have global return inside of modules
  57199. mergedParserOptions.ecmaFeatures = Object.assign({}, mergedParserOptions.ecmaFeatures, { globalReturn: false });
  57200. }
  57201. mergedParserOptions.ecmaVersion = normalizeEcmaVersion(mergedParserOptions.ecmaVersion, isModule);
  57202. // TODO: For backward compatibility. Will remove on v6.0.0.
  57203. if (parserName === DEFAULT_PARSER_NAME && mergedParserOptions.ecmaFeatures && mergedParserOptions.ecmaFeatures.experimentalObjectRestSpread && (!mergedParserOptions.ecmaVersion || mergedParserOptions.ecmaVersion < 9)) {
  57204. mergedParserOptions.ecmaVersion = 9;
  57205. }
  57206. return mergedParserOptions;
  57207. }
  57208. /**
  57209. * Combines the provided globals object with the globals from environments
  57210. * @param {Object} providedGlobals The 'globals' key in a config
  57211. * @param {Environments[]} enabledEnvironments The environments enabled in configuration and with inline comments
  57212. * @returns {Object} The resolved globals object
  57213. */
  57214. function resolveGlobals(providedGlobals, enabledEnvironments) {
  57215. return Object.assign.apply(Object, [{}].concat(_toConsumableArray(enabledEnvironments.filter(function (env) {
  57216. return env.globals;
  57217. }).map(function (env) {
  57218. return env.globals;
  57219. })), [providedGlobals]));
  57220. }
  57221. /**
  57222. * Strips Unicode BOM from a given text.
  57223. *
  57224. * @param {string} text - A text to strip.
  57225. * @returns {string} The stripped text.
  57226. */
  57227. function stripUnicodeBOM(text) {
  57228. /*
  57229. * Check Unicode BOM.
  57230. * In JavaScript, string data is stored as UTF-16, so BOM is 0xFEFF.
  57231. * http://www.ecma-international.org/ecma-262/6.0/#sec-unicode-format-control-characters
  57232. */
  57233. if (text.charCodeAt(0) === 0xFEFF) {
  57234. return text.slice(1);
  57235. }
  57236. return text;
  57237. }
  57238. /**
  57239. * Get the options for a rule (not including severity), if any
  57240. * @param {Array|number} ruleConfig rule configuration
  57241. * @returns {Array} of rule options, empty Array if none
  57242. */
  57243. function getRuleOptions(ruleConfig) {
  57244. if (Array.isArray(ruleConfig)) {
  57245. return ruleConfig.slice(1);
  57246. }
  57247. return [];
  57248. }
  57249. /**
  57250. * Analyze scope of the given AST.
  57251. * @param {ASTNode} ast The `Program` node to analyze.
  57252. * @param {Object} parserOptions The parser options.
  57253. * @param {Object} visitorKeys The visitor keys.
  57254. * @returns {ScopeManager} The analysis result.
  57255. */
  57256. function analyzeScope(ast, parserOptions, visitorKeys) {
  57257. var ecmaFeatures = parserOptions.ecmaFeatures || {};
  57258. var ecmaVersion = parserOptions.ecmaVersion || 5;
  57259. return eslintScope.analyze(ast, {
  57260. ignoreEval: true,
  57261. nodejsScope: ecmaFeatures.globalReturn,
  57262. impliedStrict: ecmaFeatures.impliedStrict,
  57263. ecmaVersion: ecmaVersion,
  57264. sourceType: parserOptions.sourceType || "script",
  57265. childVisitorKeys: visitorKeys || evk.KEYS,
  57266. fallback: Traverser.getKeys
  57267. });
  57268. }
  57269. /**
  57270. * Parses text into an AST. Moved out here because the try-catch prevents
  57271. * optimization of functions, so it's best to keep the try-catch as isolated
  57272. * as possible
  57273. * @param {string} text The text to parse.
  57274. * @param {Object} providedParserOptions Options to pass to the parser
  57275. * @param {string} parserName The name of the parser
  57276. * @param {Map<string, Object>} parserMap A map from names to loaded parsers
  57277. * @param {string} filePath The path to the file being parsed.
  57278. * @returns {{success: false, error: Problem}|{success: true, sourceCode: SourceCode}}
  57279. * An object containing the AST and parser services if parsing was successful, or the error if parsing failed
  57280. * @private
  57281. */
  57282. function parse(text, providedParserOptions, parserName, parserMap, filePath) {
  57283. var textToParse = stripUnicodeBOM(text).replace(astUtils.SHEBANG_MATCHER, function (match, captured) {
  57284. return "//" + captured;
  57285. });
  57286. var parserOptions = Object.assign({}, providedParserOptions, {
  57287. loc: true,
  57288. range: true,
  57289. raw: true,
  57290. tokens: true,
  57291. comment: true,
  57292. eslintVisitorKeys: true,
  57293. eslintScopeManager: true,
  57294. filePath: filePath
  57295. });
  57296. var parser = void 0;
  57297. try {
  57298. parser = parserMap.get(parserName) || require(parserName);
  57299. } catch (ex) {
  57300. return {
  57301. success: false,
  57302. error: {
  57303. ruleId: null,
  57304. fatal: true,
  57305. severity: 2,
  57306. message: ex.message,
  57307. line: 0,
  57308. column: 0
  57309. }
  57310. };
  57311. }
  57312. /*
  57313. * Check for parsing errors first. If there's a parsing error, nothing
  57314. * else can happen. However, a parsing error does not throw an error
  57315. * from this method - it's just considered a fatal error message, a
  57316. * problem that ESLint identified just like any other.
  57317. */
  57318. try {
  57319. var parseResult = typeof parser.parseForESLint === "function" ? parser.parseForESLint(textToParse, parserOptions) : { ast: parser.parse(textToParse, parserOptions) };
  57320. var ast = parseResult.ast;
  57321. var parserServices = parseResult.services || {};
  57322. var visitorKeys = parseResult.visitorKeys || evk.KEYS;
  57323. var scopeManager = parseResult.scopeManager || analyzeScope(ast, parserOptions, visitorKeys);
  57324. return {
  57325. success: true,
  57326. /*
  57327. * Save all values that `parseForESLint()` returned.
  57328. * If a `SourceCode` object is given as the first parameter instead of source code text,
  57329. * linter skips the parsing process and reuses the source code object.
  57330. * In that case, linter needs all the values that `parseForESLint()` returned.
  57331. */
  57332. sourceCode: new SourceCode({
  57333. text: text,
  57334. ast: ast,
  57335. parserServices: parserServices,
  57336. scopeManager: scopeManager,
  57337. visitorKeys: visitorKeys
  57338. })
  57339. };
  57340. } catch (ex) {
  57341. // If the message includes a leading line number, strip it:
  57342. var message = "Parsing error: " + ex.message.replace(/^line \d+:/i, "").trim();
  57343. return {
  57344. success: false,
  57345. error: {
  57346. ruleId: null,
  57347. fatal: true,
  57348. severity: 2,
  57349. message: message,
  57350. line: ex.lineNumber,
  57351. column: ex.column
  57352. }
  57353. };
  57354. }
  57355. }
  57356. /**
  57357. * Gets the scope for the current node
  57358. * @param {ScopeManager} scopeManager The scope manager for this AST
  57359. * @param {ASTNode} currentNode The node to get the scope of
  57360. * @returns {eslint-scope.Scope} The scope information for this node
  57361. */
  57362. function _getScope(scopeManager, currentNode) {
  57363. // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope.
  57364. var inner = currentNode.type !== "Program";
  57365. for (var node = currentNode; node; node = node.parent) {
  57366. var scope = scopeManager.acquire(node, inner);
  57367. if (scope) {
  57368. if (scope.type === "function-expression-name") {
  57369. return scope.childScopes[0];
  57370. }
  57371. return scope;
  57372. }
  57373. }
  57374. return scopeManager.scopes[0];
  57375. }
  57376. /**
  57377. * Marks a variable as used in the current scope
  57378. * @param {ScopeManager} scopeManager The scope manager for this AST. The scope may be mutated by this function.
  57379. * @param {ASTNode} currentNode The node currently being traversed
  57380. * @param {Object} parserOptions The options used to parse this text
  57381. * @param {string} name The name of the variable that should be marked as used.
  57382. * @returns {boolean} True if the variable was found and marked as used, false if not.
  57383. */
  57384. function _markVariableAsUsed(scopeManager, currentNode, parserOptions, name) {
  57385. var hasGlobalReturn = parserOptions.ecmaFeatures && parserOptions.ecmaFeatures.globalReturn;
  57386. var specialScope = hasGlobalReturn || parserOptions.sourceType === "module";
  57387. var currentScope = _getScope(scopeManager, currentNode);
  57388. // Special Node.js scope means we need to start one level deeper
  57389. var initialScope = currentScope.type === "global" && specialScope ? currentScope.childScopes[0] : currentScope;
  57390. for (var scope = initialScope; scope; scope = scope.upper) {
  57391. var variable = scope.variables.find(function (scopeVar) {
  57392. return scopeVar.name === name;
  57393. });
  57394. if (variable) {
  57395. variable.eslintUsed = true;
  57396. return true;
  57397. }
  57398. }
  57399. return false;
  57400. }
  57401. /**
  57402. * Runs a rule, and gets its listeners
  57403. * @param {Rule} rule A normalized rule with a `create` method
  57404. * @param {Context} ruleContext The context that should be passed to the rule
  57405. * @returns {Object} A map of selector listeners provided by the rule
  57406. */
  57407. function createRuleListeners(rule, ruleContext) {
  57408. try {
  57409. return rule.create(ruleContext);
  57410. } catch (ex) {
  57411. ex.message = "Error while loading rule '" + ruleContext.id + "': " + ex.message;
  57412. throw ex;
  57413. }
  57414. }
  57415. /**
  57416. * Gets all the ancestors of a given node
  57417. * @param {ASTNode} node The node
  57418. * @returns {ASTNode[]} All the ancestor nodes in the AST, not including the provided node, starting
  57419. * from the root node and going inwards to the parent node.
  57420. */
  57421. function _getAncestors(node) {
  57422. var ancestorsStartingAtParent = [];
  57423. for (var ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
  57424. ancestorsStartingAtParent.push(ancestor);
  57425. }
  57426. return ancestorsStartingAtParent.reverse();
  57427. }
  57428. // methods that exist on SourceCode object
  57429. var DEPRECATED_SOURCECODE_PASSTHROUGHS = {
  57430. getSource: "getText",
  57431. getSourceLines: "getLines",
  57432. getAllComments: "getAllComments",
  57433. getNodeByRangeIndex: "getNodeByRangeIndex",
  57434. getComments: "getComments",
  57435. getCommentsBefore: "getCommentsBefore",
  57436. getCommentsAfter: "getCommentsAfter",
  57437. getCommentsInside: "getCommentsInside",
  57438. getJSDocComment: "getJSDocComment",
  57439. getFirstToken: "getFirstToken",
  57440. getFirstTokens: "getFirstTokens",
  57441. getLastToken: "getLastToken",
  57442. getLastTokens: "getLastTokens",
  57443. getTokenAfter: "getTokenAfter",
  57444. getTokenBefore: "getTokenBefore",
  57445. getTokenByRangeStart: "getTokenByRangeStart",
  57446. getTokens: "getTokens",
  57447. getTokensAfter: "getTokensAfter",
  57448. getTokensBefore: "getTokensBefore",
  57449. getTokensBetween: "getTokensBetween"
  57450. };
  57451. var BASE_TRAVERSAL_CONTEXT = Object.freeze(Object.keys(DEPRECATED_SOURCECODE_PASSTHROUGHS).reduce(function (contextInfo, methodName) {
  57452. return Object.assign(contextInfo, _defineProperty({}, methodName, function () {
  57453. var _getSourceCode;
  57454. return (_getSourceCode = this.getSourceCode())[DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]].apply(_getSourceCode, arguments);
  57455. }));
  57456. }, {}));
  57457. /**
  57458. * Runs the given rules on the given SourceCode object
  57459. * @param {SourceCode} sourceCode A SourceCode object for the given text
  57460. * @param {Object} configuredRules The rules configuration
  57461. * @param {function(string): Rule} ruleMapper A mapper function from rule names to rules
  57462. * @param {Object} parserOptions The options that were passed to the parser
  57463. * @param {string} parserName The name of the parser in the config
  57464. * @param {Object} settings The settings that were enabled in the config
  57465. * @param {string} filename The reported filename of the code
  57466. * @returns {Problem[]} An array of reported problems
  57467. */
  57468. function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parserName, settings, filename) {
  57469. var emitter = createEmitter();
  57470. var nodeQueue = [];
  57471. var currentNode = sourceCode.ast;
  57472. Traverser.traverse(sourceCode.ast, {
  57473. enter: function enter(node, parent) {
  57474. node.parent = parent;
  57475. nodeQueue.push({ isEntering: true, node: node });
  57476. },
  57477. leave: function leave(node) {
  57478. nodeQueue.push({ isEntering: false, node: node });
  57479. },
  57480. visitorKeys: sourceCode.visitorKeys
  57481. });
  57482. /*
  57483. * Create a frozen object with the ruleContext properties and methods that are shared by all rules.
  57484. * All rule contexts will inherit from this object. This avoids the performance penalty of copying all the
  57485. * properties once for each rule.
  57486. */
  57487. var sharedTraversalContext = Object.freeze(Object.assign(Object.create(BASE_TRAVERSAL_CONTEXT), {
  57488. getAncestors: function getAncestors() {
  57489. return _getAncestors(currentNode);
  57490. },
  57491. getDeclaredVariables: sourceCode.scopeManager.getDeclaredVariables.bind(sourceCode.scopeManager),
  57492. getFilename: function getFilename() {
  57493. return filename;
  57494. },
  57495. getScope: function getScope() {
  57496. return _getScope(sourceCode.scopeManager, currentNode);
  57497. },
  57498. getSourceCode: function getSourceCode() {
  57499. return sourceCode;
  57500. },
  57501. markVariableAsUsed: function markVariableAsUsed(name) {
  57502. return _markVariableAsUsed(sourceCode.scopeManager, currentNode, parserOptions, name);
  57503. },
  57504. parserOptions: parserOptions,
  57505. parserPath: parserName,
  57506. parserServices: sourceCode.parserServices,
  57507. settings: settings
  57508. }));
  57509. var lintingProblems = [];
  57510. Object.keys(configuredRules).forEach(function (ruleId) {
  57511. var severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]);
  57512. if (severity === 0) {
  57513. return;
  57514. }
  57515. var rule = ruleMapper(ruleId);
  57516. var messageIds = rule.meta && rule.meta.messages;
  57517. var reportTranslator = null;
  57518. var ruleContext = Object.freeze(Object.assign(Object.create(sharedTraversalContext), {
  57519. id: ruleId,
  57520. options: getRuleOptions(configuredRules[ruleId]),
  57521. report: function report() {
  57522. /*
  57523. * Create a report translator lazily.
  57524. * In a vast majority of cases, any given rule reports zero errors on a given
  57525. * piece of code. Creating a translator lazily avoids the performance cost of
  57526. * creating a new translator function for each rule that usually doesn't get
  57527. * called.
  57528. *
  57529. * Using lazy report translators improves end-to-end performance by about 3%
  57530. * with Node 8.4.0.
  57531. */
  57532. if (reportTranslator === null) {
  57533. reportTranslator = createReportTranslator({ ruleId: ruleId, severity: severity, sourceCode: sourceCode, messageIds: messageIds });
  57534. }
  57535. var problem = reportTranslator.apply(undefined, arguments);
  57536. if (problem.fix && rule.meta && !rule.meta.fixable) {
  57537. throw new Error("Fixable rules should export a `meta.fixable` property.");
  57538. }
  57539. lintingProblems.push(problem);
  57540. }
  57541. }));
  57542. var ruleListeners = createRuleListeners(rule, ruleContext);
  57543. // add all the selectors from the rule as listeners
  57544. Object.keys(ruleListeners).forEach(function (selector) {
  57545. emitter.on(selector, timing.enabled ? timing.time(ruleId, ruleListeners[selector]) : ruleListeners[selector]);
  57546. });
  57547. });
  57548. var eventGenerator = new CodePathAnalyzer(new NodeEventGenerator(emitter));
  57549. nodeQueue.forEach(function (traversalInfo) {
  57550. currentNode = traversalInfo.node;
  57551. if (traversalInfo.isEntering) {
  57552. eventGenerator.enterNode(currentNode);
  57553. } else {
  57554. eventGenerator.leaveNode(currentNode);
  57555. }
  57556. });
  57557. return lintingProblems;
  57558. }
  57559. var lastSourceCodes = new WeakMap();
  57560. var loadedParserMaps = new WeakMap();
  57561. //------------------------------------------------------------------------------
  57562. // Public Interface
  57563. //------------------------------------------------------------------------------
  57564. /**
  57565. * Object that is responsible for verifying JavaScript text
  57566. * @name eslint
  57567. */
  57568. module.exports = function () {
  57569. function Linter() {
  57570. _classCallCheck(this, Linter);
  57571. lastSourceCodes.set(this, null);
  57572. loadedParserMaps.set(this, new Map());
  57573. this.version = pkg.version;
  57574. this.rules = new Rules();
  57575. this.environments = new Environments();
  57576. }
  57577. /**
  57578. * Getter for package version.
  57579. * @static
  57580. * @returns {string} The version from package.json.
  57581. */
  57582. _createClass(Linter, [{
  57583. key: "_verifyWithoutProcessors",
  57584. /**
  57585. * Configuration object for the `verify` API. A JS representation of the eslintrc files.
  57586. * @typedef {Object} ESLintConfig
  57587. * @property {Object} rules The rule configuration to verify against.
  57588. * @property {string} [parser] Parser to use when generatig the AST.
  57589. * @property {Object} [parserOptions] Options for the parsed used.
  57590. * @property {Object} [settings] Global settings passed to each rule.
  57591. * @property {Object} [env] The environment to verify in.
  57592. * @property {Object} [globals] Available globals to the code.
  57593. */
  57594. /**
  57595. * Same as linter.verify, except without support for processors.
  57596. * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
  57597. * @param {ESLintConfig} providedConfig An ESLintConfig instance to configure everything.
  57598. * @param {(string|Object)} [filenameOrOptions] The optional filename of the file being checked.
  57599. * If this is not set, the filename will default to '<input>' in the rule context. If
  57600. * an object, then it has "filename", "saveState", and "allowInlineConfig" properties.
  57601. * @param {boolean} [filenameOrOptions.allowInlineConfig=true] Allow/disallow inline comments' ability to change config once it is set. Defaults to true if not supplied.
  57602. * Useful if you want to validate JS without comments overriding rules.
  57603. * @param {boolean} [filenameOrOptions.reportUnusedDisableDirectives=false] Adds reported errors for unused
  57604. * eslint-disable directives
  57605. * @returns {Object[]} The results as an array of messages or an empty array if no messages.
  57606. */
  57607. value: function _verifyWithoutProcessors(textOrSourceCode, providedConfig, filenameOrOptions) {
  57608. var _this = this;
  57609. var config = providedConfig || {};
  57610. var options = normalizeVerifyOptions(filenameOrOptions);
  57611. var text = void 0;
  57612. // evaluate arguments
  57613. if (typeof textOrSourceCode === "string") {
  57614. lastSourceCodes.set(this, null);
  57615. text = textOrSourceCode;
  57616. } else {
  57617. lastSourceCodes.set(this, textOrSourceCode);
  57618. text = textOrSourceCode.text;
  57619. }
  57620. // search and apply "eslint-env *".
  57621. var envInFile = findEslintEnv(text);
  57622. var resolvedEnvConfig = Object.assign({ builtin: true }, config.env, envInFile);
  57623. var enabledEnvs = Object.keys(resolvedEnvConfig).filter(function (envName) {
  57624. return resolvedEnvConfig[envName];
  57625. }).map(function (envName) {
  57626. return _this.environments.get(envName);
  57627. }).filter(function (env) {
  57628. return env;
  57629. });
  57630. var parserName = config.parser || DEFAULT_PARSER_NAME;
  57631. var parserOptions = resolveParserOptions(parserName, config.parserOptions || {}, enabledEnvs);
  57632. var configuredGlobals = resolveGlobals(config.globals || {}, enabledEnvs);
  57633. var settings = config.settings || {};
  57634. if (!lastSourceCodes.get(this)) {
  57635. var parseResult = parse(text, parserOptions, parserName, loadedParserMaps.get(this), options.filename);
  57636. if (!parseResult.success) {
  57637. return [parseResult.error];
  57638. }
  57639. lastSourceCodes.set(this, parseResult.sourceCode);
  57640. } else {
  57641. /*
  57642. * If the given source code object as the first argument does not have scopeManager, analyze the scope.
  57643. * This is for backward compatibility (SourceCode is frozen so it cannot rebind).
  57644. */
  57645. var lastSourceCode = lastSourceCodes.get(this);
  57646. if (!lastSourceCode.scopeManager) {
  57647. lastSourceCodes.set(this, new SourceCode({
  57648. text: lastSourceCode.text,
  57649. ast: lastSourceCode.ast,
  57650. parserServices: lastSourceCode.parserServices,
  57651. visitorKeys: lastSourceCode.visitorKeys,
  57652. scopeManager: analyzeScope(lastSourceCode.ast, parserOptions)
  57653. }));
  57654. }
  57655. }
  57656. var sourceCode = lastSourceCodes.get(this);
  57657. var commentDirectives = options.allowInlineConfig ? getDirectiveComments(options.filename, sourceCode.ast, function (ruleId) {
  57658. return _this.rules.get(ruleId);
  57659. }) : { configuredRules: {}, enabledGlobals: {}, exportedVariables: {}, problems: [], disableDirectives: [] };
  57660. // augment global scope with declared global variables
  57661. addDeclaredGlobals(sourceCode.scopeManager.scopes[0], configuredGlobals, { exportedVariables: commentDirectives.exportedVariables, enabledGlobals: commentDirectives.enabledGlobals });
  57662. var configuredRules = Object.assign({}, config.rules, commentDirectives.configuredRules);
  57663. var lintingProblems = void 0;
  57664. try {
  57665. lintingProblems = runRules(sourceCode, configuredRules, function (ruleId) {
  57666. return _this.rules.get(ruleId);
  57667. }, parserOptions, parserName, settings, options.filename);
  57668. } catch (err) {
  57669. debug("An error occurred while traversing");
  57670. debug("Filename:", options.filename);
  57671. debug("Parser Options:", parserOptions);
  57672. debug("Parser Path:", parserName);
  57673. debug("Settings:", settings);
  57674. throw err;
  57675. }
  57676. return applyDisableDirectives({
  57677. directives: commentDirectives.disableDirectives,
  57678. problems: lintingProblems.concat(commentDirectives.problems).sort(function (problemA, problemB) {
  57679. return problemA.line - problemB.line || problemA.column - problemB.column;
  57680. }),
  57681. reportUnusedDisableDirectives: options.reportUnusedDisableDirectives
  57682. });
  57683. }
  57684. /**
  57685. * Verifies the text against the rules specified by the second argument.
  57686. * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
  57687. * @param {ESLintConfig} config An ESLintConfig instance to configure everything.
  57688. * @param {(string|Object)} [filenameOrOptions] The optional filename of the file being checked.
  57689. * If this is not set, the filename will default to '<input>' in the rule context. If
  57690. * an object, then it has "filename", "saveState", and "allowInlineConfig" properties.
  57691. * @param {boolean} [filenameOrOptions.allowInlineConfig] Allow/disallow inline comments' ability to change config once it is set. Defaults to true if not supplied.
  57692. * Useful if you want to validate JS without comments overriding rules.
  57693. * @param {function(string): string[]} [filenameOrOptions.preprocess] preprocessor for source text. If provided,
  57694. * this should accept a string of source text, and return an array of code blocks to lint.
  57695. * @param {function(Array<Object[]>): Object[]} [filenameOrOptions.postprocess] postprocessor for report messages. If provided,
  57696. * this should accept an array of the message lists for each code block returned from the preprocessor,
  57697. * apply a mapping to the messages as appropriate, and return a one-dimensional array of messages
  57698. * @returns {Object[]} The results as an array of messages or an empty array if no messages.
  57699. */
  57700. }, {
  57701. key: "verify",
  57702. value: function verify(textOrSourceCode, config, filenameOrOptions) {
  57703. var _this2 = this;
  57704. var preprocess = filenameOrOptions && filenameOrOptions.preprocess || function (rawText) {
  57705. return [rawText];
  57706. };
  57707. var postprocess = filenameOrOptions && filenameOrOptions.postprocess || lodash.flatten;
  57708. return postprocess(preprocess(textOrSourceCode).map(function (textBlock) {
  57709. return _this2._verifyWithoutProcessors(textBlock, config, filenameOrOptions);
  57710. }));
  57711. }
  57712. /**
  57713. * Gets the SourceCode object representing the parsed source.
  57714. * @returns {SourceCode} The SourceCode object.
  57715. */
  57716. }, {
  57717. key: "getSourceCode",
  57718. value: function getSourceCode() {
  57719. return lastSourceCodes.get(this);
  57720. }
  57721. /**
  57722. * Defines a new linting rule.
  57723. * @param {string} ruleId A unique rule identifier
  57724. * @param {Function} ruleModule Function from context to object mapping AST node types to event handlers
  57725. * @returns {void}
  57726. */
  57727. }, {
  57728. key: "defineRule",
  57729. value: function defineRule(ruleId, ruleModule) {
  57730. this.rules.define(ruleId, ruleModule);
  57731. }
  57732. /**
  57733. * Defines many new linting rules.
  57734. * @param {Object} rulesToDefine map from unique rule identifier to rule
  57735. * @returns {void}
  57736. */
  57737. }, {
  57738. key: "defineRules",
  57739. value: function defineRules(rulesToDefine) {
  57740. var _this3 = this;
  57741. Object.getOwnPropertyNames(rulesToDefine).forEach(function (ruleId) {
  57742. _this3.defineRule(ruleId, rulesToDefine[ruleId]);
  57743. });
  57744. }
  57745. /**
  57746. * Gets an object with all loaded rules.
  57747. * @returns {Map} All loaded rules
  57748. */
  57749. }, {
  57750. key: "getRules",
  57751. value: function getRules() {
  57752. return this.rules.getAllLoadedRules();
  57753. }
  57754. /**
  57755. * Define a new parser module
  57756. * @param {any} parserId Name of the parser
  57757. * @param {any} parserModule The parser object
  57758. * @returns {void}
  57759. */
  57760. }, {
  57761. key: "defineParser",
  57762. value: function defineParser(parserId, parserModule) {
  57763. loadedParserMaps.get(this).set(parserId, parserModule);
  57764. }
  57765. /**
  57766. * Performs multiple autofix passes over the text until as many fixes as possible
  57767. * have been applied.
  57768. * @param {string} text The source text to apply fixes to.
  57769. * @param {Object} config The ESLint config object to use.
  57770. * @param {Object} options The ESLint options object to use.
  57771. * @param {string} options.filename The filename from which the text was read.
  57772. * @param {boolean} options.allowInlineConfig Flag indicating if inline comments
  57773. * should be allowed.
  57774. * @param {boolean|Function} options.fix Determines whether fixes should be applied
  57775. * @param {Function} options.preprocess preprocessor for source text. If provided, this should
  57776. * accept a string of source text, and return an array of code blocks to lint.
  57777. * @param {Function} options.postprocess postprocessor for report messages. If provided,
  57778. * this should accept an array of the message lists for each code block returned from the preprocessor,
  57779. * apply a mapping to the messages as appropriate, and return a one-dimensional array of messages
  57780. * @returns {Object} The result of the fix operation as returned from the
  57781. * SourceCodeFixer.
  57782. */
  57783. }, {
  57784. key: "verifyAndFix",
  57785. value: function verifyAndFix(text, config, options) {
  57786. var messages = [],
  57787. fixedResult = void 0,
  57788. fixed = false,
  57789. passNumber = 0,
  57790. currentText = text;
  57791. var debugTextDescription = options && options.filename || text.slice(0, 10) + "...";
  57792. var shouldFix = options && typeof options.fix !== "undefined" ? options.fix : true;
  57793. /**
  57794. * This loop continues until one of the following is true:
  57795. *
  57796. * 1. No more fixes have been applied.
  57797. * 2. Ten passes have been made.
  57798. *
  57799. * That means anytime a fix is successfully applied, there will be another pass.
  57800. * Essentially, guaranteeing a minimum of two passes.
  57801. */
  57802. do {
  57803. passNumber++;
  57804. debug("Linting code for " + debugTextDescription + " (pass " + passNumber + ")");
  57805. messages = this.verify(currentText, config, options);
  57806. debug("Generating fixed text for " + debugTextDescription + " (pass " + passNumber + ")");
  57807. fixedResult = SourceCodeFixer.applyFixes(currentText, messages, shouldFix);
  57808. /*
  57809. * stop if there are any syntax errors.
  57810. * 'fixedResult.output' is a empty string.
  57811. */
  57812. if (messages.length === 1 && messages[0].fatal) {
  57813. break;
  57814. }
  57815. // keep track if any fixes were ever applied - important for return value
  57816. fixed = fixed || fixedResult.fixed;
  57817. // update to use the fixed output instead of the original text
  57818. currentText = fixedResult.output;
  57819. } while (fixedResult.fixed && passNumber < MAX_AUTOFIX_PASSES);
  57820. /*
  57821. * If the last result had fixes, we need to lint again to be sure we have
  57822. * the most up-to-date information.
  57823. */
  57824. if (fixedResult.fixed) {
  57825. fixedResult.messages = this.verify(currentText, config, options);
  57826. }
  57827. // ensure the last result properly reflects if fixes were done
  57828. fixedResult.fixed = fixed;
  57829. fixedResult.output = currentText;
  57830. return fixedResult;
  57831. }
  57832. }], [{
  57833. key: "version",
  57834. get: function get() {
  57835. return pkg.version;
  57836. }
  57837. }]);
  57838. return Linter;
  57839. }();
  57840. },{"../package.json":111,"./code-path-analysis/code-path-analyzer":112,"./config/config-ops":119,"./config/config-validator":120,"./config/environments":121,"./rules":124,"./util/apply-disable-directives":404,"./util/ast-utils":405,"./util/config-comment-parser":406,"./util/node-event-generator":410,"./util/report-translator":412,"./util/safe-emitter":414,"./util/source-code":416,"./util/source-code-fixer":415,"./util/timing":417,"./util/traverser":418,"debug":53,"eslint-scope":60,"eslint-visitor-keys":69,"lodash":92}],123:[function(require,module,exports){
  57841. "use strict";
  57842. module.exports = function () {
  57843. var rules = Object.create(null);
  57844. rules["accessor-pairs"] = require("./rules/accessor-pairs");
  57845. rules["array-bracket-newline"] = require("./rules/array-bracket-newline");
  57846. rules["array-bracket-spacing"] = require("./rules/array-bracket-spacing");
  57847. rules["array-callback-return"] = require("./rules/array-callback-return");
  57848. rules["array-element-newline"] = require("./rules/array-element-newline");
  57849. rules["arrow-body-style"] = require("./rules/arrow-body-style");
  57850. rules["arrow-parens"] = require("./rules/arrow-parens");
  57851. rules["arrow-spacing"] = require("./rules/arrow-spacing");
  57852. rules["block-scoped-var"] = require("./rules/block-scoped-var");
  57853. rules["block-spacing"] = require("./rules/block-spacing");
  57854. rules["brace-style"] = require("./rules/brace-style");
  57855. rules["callback-return"] = require("./rules/callback-return");
  57856. rules["camelcase"] = require("./rules/camelcase");
  57857. rules["capitalized-comments"] = require("./rules/capitalized-comments");
  57858. rules["class-methods-use-this"] = require("./rules/class-methods-use-this");
  57859. rules["comma-dangle"] = require("./rules/comma-dangle");
  57860. rules["comma-spacing"] = require("./rules/comma-spacing");
  57861. rules["comma-style"] = require("./rules/comma-style");
  57862. rules["complexity"] = require("./rules/complexity");
  57863. rules["computed-property-spacing"] = require("./rules/computed-property-spacing");
  57864. rules["consistent-return"] = require("./rules/consistent-return");
  57865. rules["consistent-this"] = require("./rules/consistent-this");
  57866. rules["constructor-super"] = require("./rules/constructor-super");
  57867. rules["curly"] = require("./rules/curly");
  57868. rules["default-case"] = require("./rules/default-case");
  57869. rules["dot-location"] = require("./rules/dot-location");
  57870. rules["dot-notation"] = require("./rules/dot-notation");
  57871. rules["eol-last"] = require("./rules/eol-last");
  57872. rules["eqeqeq"] = require("./rules/eqeqeq");
  57873. rules["for-direction"] = require("./rules/for-direction");
  57874. rules["func-call-spacing"] = require("./rules/func-call-spacing");
  57875. rules["func-name-matching"] = require("./rules/func-name-matching");
  57876. rules["func-names"] = require("./rules/func-names");
  57877. rules["func-style"] = require("./rules/func-style");
  57878. rules["function-paren-newline"] = require("./rules/function-paren-newline");
  57879. rules["generator-star-spacing"] = require("./rules/generator-star-spacing");
  57880. rules["getter-return"] = require("./rules/getter-return");
  57881. rules["global-require"] = require("./rules/global-require");
  57882. rules["guard-for-in"] = require("./rules/guard-for-in");
  57883. rules["handle-callback-err"] = require("./rules/handle-callback-err");
  57884. rules["id-blacklist"] = require("./rules/id-blacklist");
  57885. rules["id-length"] = require("./rules/id-length");
  57886. rules["id-match"] = require("./rules/id-match");
  57887. rules["implicit-arrow-linebreak"] = require("./rules/implicit-arrow-linebreak");
  57888. rules["indent-legacy"] = require("./rules/indent-legacy");
  57889. rules["indent"] = require("./rules/indent");
  57890. rules["init-declarations"] = require("./rules/init-declarations");
  57891. rules["jsx-quotes"] = require("./rules/jsx-quotes");
  57892. rules["key-spacing"] = require("./rules/key-spacing");
  57893. rules["keyword-spacing"] = require("./rules/keyword-spacing");
  57894. rules["line-comment-position"] = require("./rules/line-comment-position");
  57895. rules["linebreak-style"] = require("./rules/linebreak-style");
  57896. rules["lines-around-comment"] = require("./rules/lines-around-comment");
  57897. rules["lines-around-directive"] = require("./rules/lines-around-directive");
  57898. rules["lines-between-class-members"] = require("./rules/lines-between-class-members");
  57899. rules["max-classes-per-file"] = require("./rules/max-classes-per-file");
  57900. rules["max-depth"] = require("./rules/max-depth");
  57901. rules["max-len"] = require("./rules/max-len");
  57902. rules["max-lines-per-function"] = require("./rules/max-lines-per-function");
  57903. rules["max-lines"] = require("./rules/max-lines");
  57904. rules["max-nested-callbacks"] = require("./rules/max-nested-callbacks");
  57905. rules["max-params"] = require("./rules/max-params");
  57906. rules["max-statements-per-line"] = require("./rules/max-statements-per-line");
  57907. rules["max-statements"] = require("./rules/max-statements");
  57908. rules["multiline-comment-style"] = require("./rules/multiline-comment-style");
  57909. rules["multiline-ternary"] = require("./rules/multiline-ternary");
  57910. rules["new-cap"] = require("./rules/new-cap");
  57911. rules["new-parens"] = require("./rules/new-parens");
  57912. rules["newline-after-var"] = require("./rules/newline-after-var");
  57913. rules["newline-before-return"] = require("./rules/newline-before-return");
  57914. rules["newline-per-chained-call"] = require("./rules/newline-per-chained-call");
  57915. rules["no-alert"] = require("./rules/no-alert");
  57916. rules["no-array-constructor"] = require("./rules/no-array-constructor");
  57917. rules["no-async-promise-executor"] = require("./rules/no-async-promise-executor");
  57918. rules["no-await-in-loop"] = require("./rules/no-await-in-loop");
  57919. rules["no-bitwise"] = require("./rules/no-bitwise");
  57920. rules["no-buffer-constructor"] = require("./rules/no-buffer-constructor");
  57921. rules["no-caller"] = require("./rules/no-caller");
  57922. rules["no-case-declarations"] = require("./rules/no-case-declarations");
  57923. rules["no-catch-shadow"] = require("./rules/no-catch-shadow");
  57924. rules["no-class-assign"] = require("./rules/no-class-assign");
  57925. rules["no-compare-neg-zero"] = require("./rules/no-compare-neg-zero");
  57926. rules["no-cond-assign"] = require("./rules/no-cond-assign");
  57927. rules["no-confusing-arrow"] = require("./rules/no-confusing-arrow");
  57928. rules["no-console"] = require("./rules/no-console");
  57929. rules["no-const-assign"] = require("./rules/no-const-assign");
  57930. rules["no-constant-condition"] = require("./rules/no-constant-condition");
  57931. rules["no-continue"] = require("./rules/no-continue");
  57932. rules["no-control-regex"] = require("./rules/no-control-regex");
  57933. rules["no-debugger"] = require("./rules/no-debugger");
  57934. rules["no-delete-var"] = require("./rules/no-delete-var");
  57935. rules["no-div-regex"] = require("./rules/no-div-regex");
  57936. rules["no-dupe-args"] = require("./rules/no-dupe-args");
  57937. rules["no-dupe-class-members"] = require("./rules/no-dupe-class-members");
  57938. rules["no-dupe-keys"] = require("./rules/no-dupe-keys");
  57939. rules["no-duplicate-case"] = require("./rules/no-duplicate-case");
  57940. rules["no-duplicate-imports"] = require("./rules/no-duplicate-imports");
  57941. rules["no-else-return"] = require("./rules/no-else-return");
  57942. rules["no-empty-character-class"] = require("./rules/no-empty-character-class");
  57943. rules["no-empty-function"] = require("./rules/no-empty-function");
  57944. rules["no-empty-pattern"] = require("./rules/no-empty-pattern");
  57945. rules["no-empty"] = require("./rules/no-empty");
  57946. rules["no-eq-null"] = require("./rules/no-eq-null");
  57947. rules["no-eval"] = require("./rules/no-eval");
  57948. rules["no-ex-assign"] = require("./rules/no-ex-assign");
  57949. rules["no-extend-native"] = require("./rules/no-extend-native");
  57950. rules["no-extra-bind"] = require("./rules/no-extra-bind");
  57951. rules["no-extra-boolean-cast"] = require("./rules/no-extra-boolean-cast");
  57952. rules["no-extra-label"] = require("./rules/no-extra-label");
  57953. rules["no-extra-parens"] = require("./rules/no-extra-parens");
  57954. rules["no-extra-semi"] = require("./rules/no-extra-semi");
  57955. rules["no-fallthrough"] = require("./rules/no-fallthrough");
  57956. rules["no-floating-decimal"] = require("./rules/no-floating-decimal");
  57957. rules["no-func-assign"] = require("./rules/no-func-assign");
  57958. rules["no-global-assign"] = require("./rules/no-global-assign");
  57959. rules["no-implicit-coercion"] = require("./rules/no-implicit-coercion");
  57960. rules["no-implicit-globals"] = require("./rules/no-implicit-globals");
  57961. rules["no-implied-eval"] = require("./rules/no-implied-eval");
  57962. rules["no-inline-comments"] = require("./rules/no-inline-comments");
  57963. rules["no-inner-declarations"] = require("./rules/no-inner-declarations");
  57964. rules["no-invalid-regexp"] = require("./rules/no-invalid-regexp");
  57965. rules["no-invalid-this"] = require("./rules/no-invalid-this");
  57966. rules["no-irregular-whitespace"] = require("./rules/no-irregular-whitespace");
  57967. rules["no-iterator"] = require("./rules/no-iterator");
  57968. rules["no-label-var"] = require("./rules/no-label-var");
  57969. rules["no-labels"] = require("./rules/no-labels");
  57970. rules["no-lone-blocks"] = require("./rules/no-lone-blocks");
  57971. rules["no-lonely-if"] = require("./rules/no-lonely-if");
  57972. rules["no-loop-func"] = require("./rules/no-loop-func");
  57973. rules["no-magic-numbers"] = require("./rules/no-magic-numbers");
  57974. rules["no-misleading-character-class"] = require("./rules/no-misleading-character-class");
  57975. rules["no-mixed-operators"] = require("./rules/no-mixed-operators");
  57976. rules["no-mixed-requires"] = require("./rules/no-mixed-requires");
  57977. rules["no-mixed-spaces-and-tabs"] = require("./rules/no-mixed-spaces-and-tabs");
  57978. rules["no-multi-assign"] = require("./rules/no-multi-assign");
  57979. rules["no-multi-spaces"] = require("./rules/no-multi-spaces");
  57980. rules["no-multi-str"] = require("./rules/no-multi-str");
  57981. rules["no-multiple-empty-lines"] = require("./rules/no-multiple-empty-lines");
  57982. rules["no-native-reassign"] = require("./rules/no-native-reassign");
  57983. rules["no-negated-condition"] = require("./rules/no-negated-condition");
  57984. rules["no-negated-in-lhs"] = require("./rules/no-negated-in-lhs");
  57985. rules["no-nested-ternary"] = require("./rules/no-nested-ternary");
  57986. rules["no-new-func"] = require("./rules/no-new-func");
  57987. rules["no-new-object"] = require("./rules/no-new-object");
  57988. rules["no-new-require"] = require("./rules/no-new-require");
  57989. rules["no-new-symbol"] = require("./rules/no-new-symbol");
  57990. rules["no-new-wrappers"] = require("./rules/no-new-wrappers");
  57991. rules["no-new"] = require("./rules/no-new");
  57992. rules["no-obj-calls"] = require("./rules/no-obj-calls");
  57993. rules["no-octal-escape"] = require("./rules/no-octal-escape");
  57994. rules["no-octal"] = require("./rules/no-octal");
  57995. rules["no-param-reassign"] = require("./rules/no-param-reassign");
  57996. rules["no-path-concat"] = require("./rules/no-path-concat");
  57997. rules["no-plusplus"] = require("./rules/no-plusplus");
  57998. rules["no-process-env"] = require("./rules/no-process-env");
  57999. rules["no-process-exit"] = require("./rules/no-process-exit");
  58000. rules["no-proto"] = require("./rules/no-proto");
  58001. rules["no-prototype-builtins"] = require("./rules/no-prototype-builtins");
  58002. rules["no-redeclare"] = require("./rules/no-redeclare");
  58003. rules["no-regex-spaces"] = require("./rules/no-regex-spaces");
  58004. rules["no-restricted-globals"] = require("./rules/no-restricted-globals");
  58005. rules["no-restricted-imports"] = require("./rules/no-restricted-imports");
  58006. rules["no-restricted-modules"] = require("./rules/no-restricted-modules");
  58007. rules["no-restricted-properties"] = require("./rules/no-restricted-properties");
  58008. rules["no-restricted-syntax"] = require("./rules/no-restricted-syntax");
  58009. rules["no-return-assign"] = require("./rules/no-return-assign");
  58010. rules["no-return-await"] = require("./rules/no-return-await");
  58011. rules["no-script-url"] = require("./rules/no-script-url");
  58012. rules["no-self-assign"] = require("./rules/no-self-assign");
  58013. rules["no-self-compare"] = require("./rules/no-self-compare");
  58014. rules["no-sequences"] = require("./rules/no-sequences");
  58015. rules["no-shadow-restricted-names"] = require("./rules/no-shadow-restricted-names");
  58016. rules["no-shadow"] = require("./rules/no-shadow");
  58017. rules["no-spaced-func"] = require("./rules/no-spaced-func");
  58018. rules["no-sparse-arrays"] = require("./rules/no-sparse-arrays");
  58019. rules["no-sync"] = require("./rules/no-sync");
  58020. rules["no-tabs"] = require("./rules/no-tabs");
  58021. rules["no-template-curly-in-string"] = require("./rules/no-template-curly-in-string");
  58022. rules["no-ternary"] = require("./rules/no-ternary");
  58023. rules["no-this-before-super"] = require("./rules/no-this-before-super");
  58024. rules["no-throw-literal"] = require("./rules/no-throw-literal");
  58025. rules["no-trailing-spaces"] = require("./rules/no-trailing-spaces");
  58026. rules["no-undef-init"] = require("./rules/no-undef-init");
  58027. rules["no-undef"] = require("./rules/no-undef");
  58028. rules["no-undefined"] = require("./rules/no-undefined");
  58029. rules["no-underscore-dangle"] = require("./rules/no-underscore-dangle");
  58030. rules["no-unexpected-multiline"] = require("./rules/no-unexpected-multiline");
  58031. rules["no-unmodified-loop-condition"] = require("./rules/no-unmodified-loop-condition");
  58032. rules["no-unneeded-ternary"] = require("./rules/no-unneeded-ternary");
  58033. rules["no-unreachable"] = require("./rules/no-unreachable");
  58034. rules["no-unsafe-finally"] = require("./rules/no-unsafe-finally");
  58035. rules["no-unsafe-negation"] = require("./rules/no-unsafe-negation");
  58036. rules["no-unused-expressions"] = require("./rules/no-unused-expressions");
  58037. rules["no-unused-labels"] = require("./rules/no-unused-labels");
  58038. rules["no-unused-vars"] = require("./rules/no-unused-vars");
  58039. rules["no-use-before-define"] = require("./rules/no-use-before-define");
  58040. rules["no-useless-call"] = require("./rules/no-useless-call");
  58041. rules["no-useless-catch"] = require("./rules/no-useless-catch");
  58042. rules["no-useless-computed-key"] = require("./rules/no-useless-computed-key");
  58043. rules["no-useless-concat"] = require("./rules/no-useless-concat");
  58044. rules["no-useless-constructor"] = require("./rules/no-useless-constructor");
  58045. rules["no-useless-escape"] = require("./rules/no-useless-escape");
  58046. rules["no-useless-rename"] = require("./rules/no-useless-rename");
  58047. rules["no-useless-return"] = require("./rules/no-useless-return");
  58048. rules["no-var"] = require("./rules/no-var");
  58049. rules["no-void"] = require("./rules/no-void");
  58050. rules["no-warning-comments"] = require("./rules/no-warning-comments");
  58051. rules["no-whitespace-before-property"] = require("./rules/no-whitespace-before-property");
  58052. rules["no-with"] = require("./rules/no-with");
  58053. rules["nonblock-statement-body-position"] = require("./rules/nonblock-statement-body-position");
  58054. rules["object-curly-newline"] = require("./rules/object-curly-newline");
  58055. rules["object-curly-spacing"] = require("./rules/object-curly-spacing");
  58056. rules["object-property-newline"] = require("./rules/object-property-newline");
  58057. rules["object-shorthand"] = require("./rules/object-shorthand");
  58058. rules["one-var-declaration-per-line"] = require("./rules/one-var-declaration-per-line");
  58059. rules["one-var"] = require("./rules/one-var");
  58060. rules["operator-assignment"] = require("./rules/operator-assignment");
  58061. rules["operator-linebreak"] = require("./rules/operator-linebreak");
  58062. rules["padded-blocks"] = require("./rules/padded-blocks");
  58063. rules["padding-line-between-statements"] = require("./rules/padding-line-between-statements");
  58064. rules["prefer-arrow-callback"] = require("./rules/prefer-arrow-callback");
  58065. rules["prefer-const"] = require("./rules/prefer-const");
  58066. rules["prefer-destructuring"] = require("./rules/prefer-destructuring");
  58067. rules["prefer-numeric-literals"] = require("./rules/prefer-numeric-literals");
  58068. rules["prefer-object-spread"] = require("./rules/prefer-object-spread");
  58069. rules["prefer-promise-reject-errors"] = require("./rules/prefer-promise-reject-errors");
  58070. rules["prefer-reflect"] = require("./rules/prefer-reflect");
  58071. rules["prefer-rest-params"] = require("./rules/prefer-rest-params");
  58072. rules["prefer-spread"] = require("./rules/prefer-spread");
  58073. rules["prefer-template"] = require("./rules/prefer-template");
  58074. rules["quote-props"] = require("./rules/quote-props");
  58075. rules["quotes"] = require("./rules/quotes");
  58076. rules["radix"] = require("./rules/radix");
  58077. rules["require-atomic-updates"] = require("./rules/require-atomic-updates");
  58078. rules["require-await"] = require("./rules/require-await");
  58079. rules["require-jsdoc"] = require("./rules/require-jsdoc");
  58080. rules["require-unicode-regexp"] = require("./rules/require-unicode-regexp");
  58081. rules["require-yield"] = require("./rules/require-yield");
  58082. rules["rest-spread-spacing"] = require("./rules/rest-spread-spacing");
  58083. rules["semi-spacing"] = require("./rules/semi-spacing");
  58084. rules["semi-style"] = require("./rules/semi-style");
  58085. rules["semi"] = require("./rules/semi");
  58086. rules["sort-imports"] = require("./rules/sort-imports");
  58087. rules["sort-keys"] = require("./rules/sort-keys");
  58088. rules["sort-vars"] = require("./rules/sort-vars");
  58089. rules["space-before-blocks"] = require("./rules/space-before-blocks");
  58090. rules["space-before-function-paren"] = require("./rules/space-before-function-paren");
  58091. rules["space-in-parens"] = require("./rules/space-in-parens");
  58092. rules["space-infix-ops"] = require("./rules/space-infix-ops");
  58093. rules["space-unary-ops"] = require("./rules/space-unary-ops");
  58094. rules["spaced-comment"] = require("./rules/spaced-comment");
  58095. rules["strict"] = require("./rules/strict");
  58096. rules["switch-colon-spacing"] = require("./rules/switch-colon-spacing");
  58097. rules["symbol-description"] = require("./rules/symbol-description");
  58098. rules["template-curly-spacing"] = require("./rules/template-curly-spacing");
  58099. rules["template-tag-spacing"] = require("./rules/template-tag-spacing");
  58100. rules["unicode-bom"] = require("./rules/unicode-bom");
  58101. rules["use-isnan"] = require("./rules/use-isnan");
  58102. rules["valid-jsdoc"] = require("./rules/valid-jsdoc");
  58103. rules["valid-typeof"] = require("./rules/valid-typeof");
  58104. rules["vars-on-top"] = require("./rules/vars-on-top");
  58105. rules["wrap-iife"] = require("./rules/wrap-iife");
  58106. rules["wrap-regex"] = require("./rules/wrap-regex");
  58107. rules["yield-star-spacing"] = require("./rules/yield-star-spacing");
  58108. rules["yoda"] = require("./rules/yoda");
  58109. return rules;
  58110. };
  58111. },{"./rules/accessor-pairs":125,"./rules/array-bracket-newline":126,"./rules/array-bracket-spacing":127,"./rules/array-callback-return":128,"./rules/array-element-newline":129,"./rules/arrow-body-style":130,"./rules/arrow-parens":131,"./rules/arrow-spacing":132,"./rules/block-scoped-var":133,"./rules/block-spacing":134,"./rules/brace-style":135,"./rules/callback-return":136,"./rules/camelcase":137,"./rules/capitalized-comments":138,"./rules/class-methods-use-this":139,"./rules/comma-dangle":140,"./rules/comma-spacing":141,"./rules/comma-style":142,"./rules/complexity":143,"./rules/computed-property-spacing":144,"./rules/consistent-return":145,"./rules/consistent-this":146,"./rules/constructor-super":147,"./rules/curly":148,"./rules/default-case":149,"./rules/dot-location":150,"./rules/dot-notation":151,"./rules/eol-last":152,"./rules/eqeqeq":153,"./rules/for-direction":154,"./rules/func-call-spacing":155,"./rules/func-name-matching":156,"./rules/func-names":157,"./rules/func-style":158,"./rules/function-paren-newline":159,"./rules/generator-star-spacing":160,"./rules/getter-return":161,"./rules/global-require":162,"./rules/guard-for-in":163,"./rules/handle-callback-err":164,"./rules/id-blacklist":165,"./rules/id-length":166,"./rules/id-match":167,"./rules/implicit-arrow-linebreak":168,"./rules/indent":170,"./rules/indent-legacy":169,"./rules/init-declarations":171,"./rules/jsx-quotes":172,"./rules/key-spacing":173,"./rules/keyword-spacing":174,"./rules/line-comment-position":175,"./rules/linebreak-style":176,"./rules/lines-around-comment":177,"./rules/lines-around-directive":178,"./rules/lines-between-class-members":179,"./rules/max-classes-per-file":180,"./rules/max-depth":181,"./rules/max-len":182,"./rules/max-lines":184,"./rules/max-lines-per-function":183,"./rules/max-nested-callbacks":185,"./rules/max-params":186,"./rules/max-statements":188,"./rules/max-statements-per-line":187,"./rules/multiline-comment-style":189,"./rules/multiline-ternary":190,"./rules/new-cap":191,"./rules/new-parens":192,"./rules/newline-after-var":193,"./rules/newline-before-return":194,"./rules/newline-per-chained-call":195,"./rules/no-alert":196,"./rules/no-array-constructor":197,"./rules/no-async-promise-executor":198,"./rules/no-await-in-loop":199,"./rules/no-bitwise":200,"./rules/no-buffer-constructor":201,"./rules/no-caller":202,"./rules/no-case-declarations":203,"./rules/no-catch-shadow":204,"./rules/no-class-assign":205,"./rules/no-compare-neg-zero":206,"./rules/no-cond-assign":207,"./rules/no-confusing-arrow":208,"./rules/no-console":209,"./rules/no-const-assign":210,"./rules/no-constant-condition":211,"./rules/no-continue":212,"./rules/no-control-regex":213,"./rules/no-debugger":214,"./rules/no-delete-var":215,"./rules/no-div-regex":216,"./rules/no-dupe-args":217,"./rules/no-dupe-class-members":218,"./rules/no-dupe-keys":219,"./rules/no-duplicate-case":220,"./rules/no-duplicate-imports":221,"./rules/no-else-return":222,"./rules/no-empty":226,"./rules/no-empty-character-class":223,"./rules/no-empty-function":224,"./rules/no-empty-pattern":225,"./rules/no-eq-null":227,"./rules/no-eval":228,"./rules/no-ex-assign":229,"./rules/no-extend-native":230,"./rules/no-extra-bind":231,"./rules/no-extra-boolean-cast":232,"./rules/no-extra-label":233,"./rules/no-extra-parens":234,"./rules/no-extra-semi":235,"./rules/no-fallthrough":236,"./rules/no-floating-decimal":237,"./rules/no-func-assign":238,"./rules/no-global-assign":239,"./rules/no-implicit-coercion":240,"./rules/no-implicit-globals":241,"./rules/no-implied-eval":242,"./rules/no-inline-comments":243,"./rules/no-inner-declarations":244,"./rules/no-invalid-regexp":245,"./rules/no-invalid-this":246,"./rules/no-irregular-whitespace":247,"./rules/no-iterator":248,"./rules/no-label-var":249,"./rules/no-labels":250,"./rules/no-lone-blocks":251,"./rules/no-lonely-if":252,"./rules/no-loop-func":253,"./rules/no-magic-numbers":254,"./rules/no-misleading-character-class":255,"./rules/no-mixed-operators":256,"./rules/no-mixed-requires":257,"./rules/no-mixed-spaces-and-tabs":258,"./rules/no-multi-assign":259,"./rules/no-multi-spaces":260,"./rules/no-multi-str":261,"./rules/no-multiple-empty-lines":262,"./rules/no-native-reassign":263,"./rules/no-negated-condition":264,"./rules/no-negated-in-lhs":265,"./rules/no-nested-ternary":266,"./rules/no-new":272,"./rules/no-new-func":267,"./rules/no-new-object":268,"./rules/no-new-require":269,"./rules/no-new-symbol":270,"./rules/no-new-wrappers":271,"./rules/no-obj-calls":273,"./rules/no-octal":275,"./rules/no-octal-escape":274,"./rules/no-param-reassign":276,"./rules/no-path-concat":277,"./rules/no-plusplus":278,"./rules/no-process-env":279,"./rules/no-process-exit":280,"./rules/no-proto":281,"./rules/no-prototype-builtins":282,"./rules/no-redeclare":283,"./rules/no-regex-spaces":284,"./rules/no-restricted-globals":285,"./rules/no-restricted-imports":286,"./rules/no-restricted-modules":287,"./rules/no-restricted-properties":288,"./rules/no-restricted-syntax":289,"./rules/no-return-assign":290,"./rules/no-return-await":291,"./rules/no-script-url":292,"./rules/no-self-assign":293,"./rules/no-self-compare":294,"./rules/no-sequences":295,"./rules/no-shadow":297,"./rules/no-shadow-restricted-names":296,"./rules/no-spaced-func":298,"./rules/no-sparse-arrays":299,"./rules/no-sync":300,"./rules/no-tabs":301,"./rules/no-template-curly-in-string":302,"./rules/no-ternary":303,"./rules/no-this-before-super":304,"./rules/no-throw-literal":305,"./rules/no-trailing-spaces":306,"./rules/no-undef":308,"./rules/no-undef-init":307,"./rules/no-undefined":309,"./rules/no-underscore-dangle":310,"./rules/no-unexpected-multiline":311,"./rules/no-unmodified-loop-condition":312,"./rules/no-unneeded-ternary":313,"./rules/no-unreachable":314,"./rules/no-unsafe-finally":315,"./rules/no-unsafe-negation":316,"./rules/no-unused-expressions":317,"./rules/no-unused-labels":318,"./rules/no-unused-vars":319,"./rules/no-use-before-define":320,"./rules/no-useless-call":321,"./rules/no-useless-catch":322,"./rules/no-useless-computed-key":323,"./rules/no-useless-concat":324,"./rules/no-useless-constructor":325,"./rules/no-useless-escape":326,"./rules/no-useless-rename":327,"./rules/no-useless-return":328,"./rules/no-var":329,"./rules/no-void":330,"./rules/no-warning-comments":331,"./rules/no-whitespace-before-property":332,"./rules/no-with":333,"./rules/nonblock-statement-body-position":334,"./rules/object-curly-newline":335,"./rules/object-curly-spacing":336,"./rules/object-property-newline":337,"./rules/object-shorthand":338,"./rules/one-var":340,"./rules/one-var-declaration-per-line":339,"./rules/operator-assignment":341,"./rules/operator-linebreak":342,"./rules/padded-blocks":343,"./rules/padding-line-between-statements":344,"./rules/prefer-arrow-callback":345,"./rules/prefer-const":346,"./rules/prefer-destructuring":347,"./rules/prefer-numeric-literals":348,"./rules/prefer-object-spread":349,"./rules/prefer-promise-reject-errors":350,"./rules/prefer-reflect":351,"./rules/prefer-rest-params":352,"./rules/prefer-spread":353,"./rules/prefer-template":354,"./rules/quote-props":355,"./rules/quotes":356,"./rules/radix":357,"./rules/require-atomic-updates":358,"./rules/require-await":359,"./rules/require-jsdoc":360,"./rules/require-unicode-regexp":361,"./rules/require-yield":362,"./rules/rest-spread-spacing":363,"./rules/semi":366,"./rules/semi-spacing":364,"./rules/semi-style":365,"./rules/sort-imports":367,"./rules/sort-keys":368,"./rules/sort-vars":369,"./rules/space-before-blocks":370,"./rules/space-before-function-paren":371,"./rules/space-in-parens":372,"./rules/space-infix-ops":373,"./rules/space-unary-ops":374,"./rules/spaced-comment":375,"./rules/strict":376,"./rules/switch-colon-spacing":377,"./rules/symbol-description":378,"./rules/template-curly-spacing":379,"./rules/template-tag-spacing":380,"./rules/unicode-bom":381,"./rules/use-isnan":382,"./rules/valid-jsdoc":383,"./rules/valid-typeof":384,"./rules/vars-on-top":385,"./rules/wrap-iife":386,"./rules/wrap-regex":387,"./rules/yield-star-spacing":388,"./rules/yoda":389}],124:[function(require,module,exports){
  58112. /**
  58113. * @fileoverview Defines a storage for rules.
  58114. * @author Nicholas C. Zakas
  58115. */
  58116. "use strict";
  58117. //------------------------------------------------------------------------------
  58118. // Requirements
  58119. //------------------------------------------------------------------------------
  58120. 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; }; }();
  58121. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  58122. var lodash = require("lodash");
  58123. var loadRules = require("./load-rules");
  58124. var ruleReplacements = require("../conf/replacements").rules;
  58125. //------------------------------------------------------------------------------
  58126. // Helpers
  58127. //------------------------------------------------------------------------------
  58128. /**
  58129. * Creates a stub rule that gets used when a rule with a given ID is not found.
  58130. * @param {string} ruleId The ID of the missing rule
  58131. * @returns {{create: function(RuleContext): Object}} A rule that reports an error at the first location
  58132. * in the program. The report has the message `Definition for rule '${ruleId}' was not found` if the rule is unknown,
  58133. * or `Rule '${ruleId}' was removed and replaced by: ${replacements.join(", ")}` if the rule is known to have been
  58134. * replaced.
  58135. */
  58136. var createMissingRule = lodash.memoize(function (ruleId) {
  58137. var message = Object.prototype.hasOwnProperty.call(ruleReplacements, ruleId) ? "Rule '" + ruleId + "' was removed and replaced by: " + ruleReplacements[ruleId].join(", ") : "Definition for rule '" + ruleId + "' was not found";
  58138. return {
  58139. create: function create(context) {
  58140. return {
  58141. Program: function Program() {
  58142. context.report({
  58143. loc: { line: 1, column: 0 },
  58144. message: message
  58145. });
  58146. }
  58147. };
  58148. }
  58149. };
  58150. });
  58151. /**
  58152. * Normalizes a rule module to the new-style API
  58153. * @param {(Function|{create: Function})} rule A rule object, which can either be a function
  58154. * ("old-style") or an object with a `create` method ("new-style")
  58155. * @returns {{create: Function}} A new-style rule.
  58156. */
  58157. function normalizeRule(rule) {
  58158. return typeof rule === "function" ? Object.assign({ create: rule }, rule) : rule;
  58159. }
  58160. //------------------------------------------------------------------------------
  58161. // Public Interface
  58162. //------------------------------------------------------------------------------
  58163. var Rules = function () {
  58164. function Rules() {
  58165. _classCallCheck(this, Rules);
  58166. this._rules = Object.create(null);
  58167. this.load();
  58168. }
  58169. /**
  58170. * Registers a rule module for rule id in storage.
  58171. * @param {string} ruleId Rule id (file name).
  58172. * @param {Function} ruleModule Rule handler.
  58173. * @returns {void}
  58174. */
  58175. _createClass(Rules, [{
  58176. key: "define",
  58177. value: function define(ruleId, ruleModule) {
  58178. this._rules[ruleId] = normalizeRule(ruleModule);
  58179. }
  58180. /**
  58181. * Loads and registers all rules from passed rules directory.
  58182. * @param {string} [rulesDir] Path to rules directory, may be relative. Defaults to `lib/rules`.
  58183. * @param {string} cwd Current working directory
  58184. * @returns {void}
  58185. */
  58186. }, {
  58187. key: "load",
  58188. value: function load(rulesDir, cwd) {
  58189. var _this = this;
  58190. var newRules = loadRules(rulesDir, cwd);
  58191. Object.keys(newRules).forEach(function (ruleId) {
  58192. _this.define(ruleId, newRules[ruleId]);
  58193. });
  58194. }
  58195. /**
  58196. * Registers all given rules of a plugin.
  58197. * @param {Object} plugin The plugin object to import.
  58198. * @param {string} pluginName The name of the plugin without prefix (`eslint-plugin-`).
  58199. * @returns {void}
  58200. */
  58201. }, {
  58202. key: "importPlugin",
  58203. value: function importPlugin(plugin, pluginName) {
  58204. var _this2 = this;
  58205. if (plugin.rules) {
  58206. Object.keys(plugin.rules).forEach(function (ruleId) {
  58207. var qualifiedRuleId = pluginName + "/" + ruleId,
  58208. rule = plugin.rules[ruleId];
  58209. _this2.define(qualifiedRuleId, rule);
  58210. });
  58211. }
  58212. }
  58213. /**
  58214. * Access rule handler by id (file name).
  58215. * @param {string} ruleId Rule id (file name).
  58216. * @returns {{create: Function, schema: JsonSchema[]}}
  58217. * A rule. This is normalized to always have the new-style shape with a `create` method.
  58218. */
  58219. }, {
  58220. key: "get",
  58221. value: function get(ruleId) {
  58222. if (!Object.prototype.hasOwnProperty.call(this._rules, ruleId)) {
  58223. return createMissingRule(ruleId);
  58224. }
  58225. if (typeof this._rules[ruleId] === "string") {
  58226. return normalizeRule(require(this._rules[ruleId]));
  58227. }
  58228. return this._rules[ruleId];
  58229. }
  58230. /**
  58231. * Get an object with all currently loaded rules
  58232. * @returns {Map} All loaded rules
  58233. */
  58234. }, {
  58235. key: "getAllLoadedRules",
  58236. value: function getAllLoadedRules() {
  58237. var _this3 = this;
  58238. var allRules = new Map();
  58239. Object.keys(this._rules).forEach(function (name) {
  58240. var rule = _this3.get(name);
  58241. allRules.set(name, rule);
  58242. });
  58243. return allRules;
  58244. }
  58245. }]);
  58246. return Rules;
  58247. }();
  58248. module.exports = Rules;
  58249. },{"../conf/replacements":3,"./load-rules":123,"lodash":92}],125:[function(require,module,exports){
  58250. /**
  58251. * @fileoverview Rule to flag wrapping non-iife in parens
  58252. * @author Gyandeep Singh
  58253. */
  58254. "use strict";
  58255. //------------------------------------------------------------------------------
  58256. // Helpers
  58257. //------------------------------------------------------------------------------
  58258. /**
  58259. * Checks whether or not a given node is an `Identifier` node which was named a given name.
  58260. * @param {ASTNode} node - A node to check.
  58261. * @param {string} name - An expected name of the node.
  58262. * @returns {boolean} `true` if the node is an `Identifier` node which was named as expected.
  58263. */
  58264. function isIdentifier(node, name) {
  58265. return node.type === "Identifier" && node.name === name;
  58266. }
  58267. /**
  58268. * Checks whether or not a given node is an argument of a specified method call.
  58269. * @param {ASTNode} node - A node to check.
  58270. * @param {number} index - An expected index of the node in arguments.
  58271. * @param {string} object - An expected name of the object of the method.
  58272. * @param {string} property - An expected name of the method.
  58273. * @returns {boolean} `true` if the node is an argument of the specified method call.
  58274. */
  58275. function isArgumentOfMethodCall(node, index, object, property) {
  58276. var parent = node.parent;
  58277. return parent.type === "CallExpression" && parent.callee.type === "MemberExpression" && parent.callee.computed === false && isIdentifier(parent.callee.object, object) && isIdentifier(parent.callee.property, property) && parent.arguments[index] === node;
  58278. }
  58279. /**
  58280. * Checks whether or not a given node is a property descriptor.
  58281. * @param {ASTNode} node - A node to check.
  58282. * @returns {boolean} `true` if the node is a property descriptor.
  58283. */
  58284. function isPropertyDescriptor(node) {
  58285. // Object.defineProperty(obj, "foo", {set: ...})
  58286. if (isArgumentOfMethodCall(node, 2, "Object", "defineProperty") || isArgumentOfMethodCall(node, 2, "Reflect", "defineProperty")) {
  58287. return true;
  58288. }
  58289. /*
  58290. * Object.defineProperties(obj, {foo: {set: ...}})
  58291. * Object.create(proto, {foo: {set: ...}})
  58292. */
  58293. var grandparent = node.parent.parent;
  58294. return grandparent.type === "ObjectExpression" && (isArgumentOfMethodCall(grandparent, 1, "Object", "create") || isArgumentOfMethodCall(grandparent, 1, "Object", "defineProperties"));
  58295. }
  58296. //------------------------------------------------------------------------------
  58297. // Rule Definition
  58298. //------------------------------------------------------------------------------
  58299. module.exports = {
  58300. meta: {
  58301. type: "suggestion",
  58302. docs: {
  58303. description: "enforce getter and setter pairs in objects",
  58304. category: "Best Practices",
  58305. recommended: false,
  58306. url: "https://eslint.org/docs/rules/accessor-pairs"
  58307. },
  58308. schema: [{
  58309. type: "object",
  58310. properties: {
  58311. getWithoutSet: {
  58312. type: "boolean"
  58313. },
  58314. setWithoutGet: {
  58315. type: "boolean"
  58316. }
  58317. },
  58318. additionalProperties: false
  58319. }],
  58320. messages: {
  58321. getter: "Getter is not present.",
  58322. setter: "Setter is not present."
  58323. }
  58324. },
  58325. create: function create(context) {
  58326. var config = context.options[0] || {};
  58327. var checkGetWithoutSet = config.getWithoutSet === true;
  58328. var checkSetWithoutGet = config.setWithoutGet !== false;
  58329. /**
  58330. * Checks a object expression to see if it has setter and getter both present or none.
  58331. * @param {ASTNode} node The node to check.
  58332. * @returns {void}
  58333. * @private
  58334. */
  58335. function checkLonelySetGet(node) {
  58336. var isSetPresent = false;
  58337. var isGetPresent = false;
  58338. var isDescriptor = isPropertyDescriptor(node);
  58339. for (var i = 0, end = node.properties.length; i < end; i++) {
  58340. var property = node.properties[i];
  58341. var propToCheck = "";
  58342. if (property.kind === "init") {
  58343. if (isDescriptor && !property.computed) {
  58344. propToCheck = property.key.name;
  58345. }
  58346. } else {
  58347. propToCheck = property.kind;
  58348. }
  58349. switch (propToCheck) {
  58350. case "set":
  58351. isSetPresent = true;
  58352. break;
  58353. case "get":
  58354. isGetPresent = true;
  58355. break;
  58356. default:
  58357. // Do nothing
  58358. }
  58359. if (isSetPresent && isGetPresent) {
  58360. break;
  58361. }
  58362. }
  58363. if (checkSetWithoutGet && isSetPresent && !isGetPresent) {
  58364. context.report({ node: node, messageId: "getter" });
  58365. } else if (checkGetWithoutSet && isGetPresent && !isSetPresent) {
  58366. context.report({ node: node, messageId: "setter" });
  58367. }
  58368. }
  58369. return {
  58370. ObjectExpression: function ObjectExpression(node) {
  58371. if (checkSetWithoutGet || checkGetWithoutSet) {
  58372. checkLonelySetGet(node);
  58373. }
  58374. }
  58375. };
  58376. }
  58377. };
  58378. },{}],126:[function(require,module,exports){
  58379. /**
  58380. * @fileoverview Rule to enforce linebreaks after open and before close array brackets
  58381. * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
  58382. */
  58383. "use strict";
  58384. var astUtils = require("../util/ast-utils");
  58385. //------------------------------------------------------------------------------
  58386. // Rule Definition
  58387. //------------------------------------------------------------------------------
  58388. module.exports = {
  58389. meta: {
  58390. type: "layout",
  58391. docs: {
  58392. description: "enforce linebreaks after opening and before closing array brackets",
  58393. category: "Stylistic Issues",
  58394. recommended: false,
  58395. url: "https://eslint.org/docs/rules/array-bracket-newline"
  58396. },
  58397. fixable: "whitespace",
  58398. schema: [{
  58399. oneOf: [{
  58400. enum: ["always", "never", "consistent"]
  58401. }, {
  58402. type: "object",
  58403. properties: {
  58404. multiline: {
  58405. type: "boolean"
  58406. },
  58407. minItems: {
  58408. type: ["integer", "null"],
  58409. minimum: 0
  58410. }
  58411. },
  58412. additionalProperties: false
  58413. }]
  58414. }],
  58415. messages: {
  58416. unexpectedOpeningLinebreak: "There should be no linebreak after '['.",
  58417. unexpectedClosingLinebreak: "There should be no linebreak before ']'.",
  58418. missingOpeningLinebreak: "A linebreak is required after '['.",
  58419. missingClosingLinebreak: "A linebreak is required before ']'."
  58420. }
  58421. },
  58422. create: function create(context) {
  58423. var sourceCode = context.getSourceCode();
  58424. //----------------------------------------------------------------------
  58425. // Helpers
  58426. //----------------------------------------------------------------------
  58427. /**
  58428. * Normalizes a given option value.
  58429. *
  58430. * @param {string|Object|undefined} option - An option value to parse.
  58431. * @returns {{multiline: boolean, minItems: number}} Normalized option object.
  58432. */
  58433. function normalizeOptionValue(option) {
  58434. var consistent = false;
  58435. var multiline = false;
  58436. var minItems = 0;
  58437. if (option) {
  58438. if (option === "consistent") {
  58439. consistent = true;
  58440. minItems = Number.POSITIVE_INFINITY;
  58441. } else if (option === "always" || option.minItems === 0) {
  58442. minItems = 0;
  58443. } else if (option === "never") {
  58444. minItems = Number.POSITIVE_INFINITY;
  58445. } else {
  58446. multiline = Boolean(option.multiline);
  58447. minItems = option.minItems || Number.POSITIVE_INFINITY;
  58448. }
  58449. } else {
  58450. consistent = false;
  58451. multiline = true;
  58452. minItems = Number.POSITIVE_INFINITY;
  58453. }
  58454. return { consistent: consistent, multiline: multiline, minItems: minItems };
  58455. }
  58456. /**
  58457. * Normalizes a given option value.
  58458. *
  58459. * @param {string|Object|undefined} options - An option value to parse.
  58460. * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object.
  58461. */
  58462. function normalizeOptions(options) {
  58463. var value = normalizeOptionValue(options);
  58464. return { ArrayExpression: value, ArrayPattern: value };
  58465. }
  58466. /**
  58467. * Reports that there shouldn't be a linebreak after the first token
  58468. * @param {ASTNode} node - The node to report in the event of an error.
  58469. * @param {Token} token - The token to use for the report.
  58470. * @returns {void}
  58471. */
  58472. function reportNoBeginningLinebreak(node, token) {
  58473. context.report({
  58474. node: node,
  58475. loc: token.loc,
  58476. messageId: "unexpectedOpeningLinebreak",
  58477. fix: function fix(fixer) {
  58478. var nextToken = sourceCode.getTokenAfter(token, { includeComments: true });
  58479. if (astUtils.isCommentToken(nextToken)) {
  58480. return null;
  58481. }
  58482. return fixer.removeRange([token.range[1], nextToken.range[0]]);
  58483. }
  58484. });
  58485. }
  58486. /**
  58487. * Reports that there shouldn't be a linebreak before the last token
  58488. * @param {ASTNode} node - The node to report in the event of an error.
  58489. * @param {Token} token - The token to use for the report.
  58490. * @returns {void}
  58491. */
  58492. function reportNoEndingLinebreak(node, token) {
  58493. context.report({
  58494. node: node,
  58495. loc: token.loc,
  58496. messageId: "unexpectedClosingLinebreak",
  58497. fix: function fix(fixer) {
  58498. var previousToken = sourceCode.getTokenBefore(token, { includeComments: true });
  58499. if (astUtils.isCommentToken(previousToken)) {
  58500. return null;
  58501. }
  58502. return fixer.removeRange([previousToken.range[1], token.range[0]]);
  58503. }
  58504. });
  58505. }
  58506. /**
  58507. * Reports that there should be a linebreak after the first token
  58508. * @param {ASTNode} node - The node to report in the event of an error.
  58509. * @param {Token} token - The token to use for the report.
  58510. * @returns {void}
  58511. */
  58512. function reportRequiredBeginningLinebreak(node, token) {
  58513. context.report({
  58514. node: node,
  58515. loc: token.loc,
  58516. messageId: "missingOpeningLinebreak",
  58517. fix: function fix(fixer) {
  58518. return fixer.insertTextAfter(token, "\n");
  58519. }
  58520. });
  58521. }
  58522. /**
  58523. * Reports that there should be a linebreak before the last token
  58524. * @param {ASTNode} node - The node to report in the event of an error.
  58525. * @param {Token} token - The token to use for the report.
  58526. * @returns {void}
  58527. */
  58528. function reportRequiredEndingLinebreak(node, token) {
  58529. context.report({
  58530. node: node,
  58531. loc: token.loc,
  58532. messageId: "missingClosingLinebreak",
  58533. fix: function fix(fixer) {
  58534. return fixer.insertTextBefore(token, "\n");
  58535. }
  58536. });
  58537. }
  58538. /**
  58539. * Reports a given node if it violated this rule.
  58540. *
  58541. * @param {ASTNode} node - A node to check. This is an ArrayExpression node or an ArrayPattern node.
  58542. * @returns {void}
  58543. */
  58544. function check(node) {
  58545. var elements = node.elements;
  58546. var normalizedOptions = normalizeOptions(context.options[0]);
  58547. var options = normalizedOptions[node.type];
  58548. var openBracket = sourceCode.getFirstToken(node);
  58549. var closeBracket = sourceCode.getLastToken(node);
  58550. var firstIncComment = sourceCode.getTokenAfter(openBracket, { includeComments: true });
  58551. var lastIncComment = sourceCode.getTokenBefore(closeBracket, { includeComments: true });
  58552. var first = sourceCode.getTokenAfter(openBracket);
  58553. var last = sourceCode.getTokenBefore(closeBracket);
  58554. var needsLinebreaks = elements.length >= options.minItems || options.multiline && elements.length > 0 && firstIncComment.loc.start.line !== lastIncComment.loc.end.line || elements.length === 0 && firstIncComment.type === "Block" && firstIncComment.loc.start.line !== lastIncComment.loc.end.line && firstIncComment === lastIncComment || options.consistent && firstIncComment.loc.start.line !== openBracket.loc.end.line;
  58555. /*
  58556. * Use tokens or comments to check multiline or not.
  58557. * But use only tokens to check whether linebreaks are needed.
  58558. * This allows:
  58559. * var arr = [ // eslint-disable-line foo
  58560. * 'a'
  58561. * ]
  58562. */
  58563. if (needsLinebreaks) {
  58564. if (astUtils.isTokenOnSameLine(openBracket, first)) {
  58565. reportRequiredBeginningLinebreak(node, openBracket);
  58566. }
  58567. if (astUtils.isTokenOnSameLine(last, closeBracket)) {
  58568. reportRequiredEndingLinebreak(node, closeBracket);
  58569. }
  58570. } else {
  58571. if (!astUtils.isTokenOnSameLine(openBracket, first)) {
  58572. reportNoBeginningLinebreak(node, openBracket);
  58573. }
  58574. if (!astUtils.isTokenOnSameLine(last, closeBracket)) {
  58575. reportNoEndingLinebreak(node, closeBracket);
  58576. }
  58577. }
  58578. }
  58579. //----------------------------------------------------------------------
  58580. // Public
  58581. //----------------------------------------------------------------------
  58582. return {
  58583. ArrayPattern: check,
  58584. ArrayExpression: check
  58585. };
  58586. }
  58587. };
  58588. },{"../util/ast-utils":405}],127:[function(require,module,exports){
  58589. /**
  58590. * @fileoverview Disallows or enforces spaces inside of array brackets.
  58591. * @author Jamund Ferguson
  58592. */
  58593. "use strict";
  58594. var astUtils = require("../util/ast-utils");
  58595. //------------------------------------------------------------------------------
  58596. // Rule Definition
  58597. //------------------------------------------------------------------------------
  58598. module.exports = {
  58599. meta: {
  58600. type: "layout",
  58601. docs: {
  58602. description: "enforce consistent spacing inside array brackets",
  58603. category: "Stylistic Issues",
  58604. recommended: false,
  58605. url: "https://eslint.org/docs/rules/array-bracket-spacing"
  58606. },
  58607. fixable: "whitespace",
  58608. schema: [{
  58609. enum: ["always", "never"]
  58610. }, {
  58611. type: "object",
  58612. properties: {
  58613. singleValue: {
  58614. type: "boolean"
  58615. },
  58616. objectsInArrays: {
  58617. type: "boolean"
  58618. },
  58619. arraysInArrays: {
  58620. type: "boolean"
  58621. }
  58622. },
  58623. additionalProperties: false
  58624. }],
  58625. messages: {
  58626. unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
  58627. unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
  58628. missingSpaceAfter: "A space is required after '{{tokenValue}}'.",
  58629. missingSpaceBefore: "A space is required before '{{tokenValue}}'."
  58630. }
  58631. },
  58632. create: function create(context) {
  58633. var spaced = context.options[0] === "always",
  58634. sourceCode = context.getSourceCode();
  58635. /**
  58636. * Determines whether an option is set, relative to the spacing option.
  58637. * If spaced is "always", then check whether option is set to false.
  58638. * If spaced is "never", then check whether option is set to true.
  58639. * @param {Object} option - The option to exclude.
  58640. * @returns {boolean} Whether or not the property is excluded.
  58641. */
  58642. function isOptionSet(option) {
  58643. return context.options[1] ? context.options[1][option] === !spaced : false;
  58644. }
  58645. var options = {
  58646. spaced: spaced,
  58647. singleElementException: isOptionSet("singleValue"),
  58648. objectsInArraysException: isOptionSet("objectsInArrays"),
  58649. arraysInArraysException: isOptionSet("arraysInArrays")
  58650. };
  58651. //--------------------------------------------------------------------------
  58652. // Helpers
  58653. //--------------------------------------------------------------------------
  58654. /**
  58655. * Reports that there shouldn't be a space after the first token
  58656. * @param {ASTNode} node - The node to report in the event of an error.
  58657. * @param {Token} token - The token to use for the report.
  58658. * @returns {void}
  58659. */
  58660. function reportNoBeginningSpace(node, token) {
  58661. context.report({
  58662. node: node,
  58663. loc: token.loc.start,
  58664. messageId: "unexpectedSpaceAfter",
  58665. data: {
  58666. tokenValue: token.value
  58667. },
  58668. fix: function fix(fixer) {
  58669. var nextToken = sourceCode.getTokenAfter(token);
  58670. return fixer.removeRange([token.range[1], nextToken.range[0]]);
  58671. }
  58672. });
  58673. }
  58674. /**
  58675. * Reports that there shouldn't be a space before the last token
  58676. * @param {ASTNode} node - The node to report in the event of an error.
  58677. * @param {Token} token - The token to use for the report.
  58678. * @returns {void}
  58679. */
  58680. function reportNoEndingSpace(node, token) {
  58681. context.report({
  58682. node: node,
  58683. loc: token.loc.start,
  58684. messageId: "unexpectedSpaceBefore",
  58685. data: {
  58686. tokenValue: token.value
  58687. },
  58688. fix: function fix(fixer) {
  58689. var previousToken = sourceCode.getTokenBefore(token);
  58690. return fixer.removeRange([previousToken.range[1], token.range[0]]);
  58691. }
  58692. });
  58693. }
  58694. /**
  58695. * Reports that there should be a space after the first token
  58696. * @param {ASTNode} node - The node to report in the event of an error.
  58697. * @param {Token} token - The token to use for the report.
  58698. * @returns {void}
  58699. */
  58700. function reportRequiredBeginningSpace(node, token) {
  58701. context.report({
  58702. node: node,
  58703. loc: token.loc.start,
  58704. messageId: "missingSpaceAfter",
  58705. data: {
  58706. tokenValue: token.value
  58707. },
  58708. fix: function fix(fixer) {
  58709. return fixer.insertTextAfter(token, " ");
  58710. }
  58711. });
  58712. }
  58713. /**
  58714. * Reports that there should be a space before the last token
  58715. * @param {ASTNode} node - The node to report in the event of an error.
  58716. * @param {Token} token - The token to use for the report.
  58717. * @returns {void}
  58718. */
  58719. function reportRequiredEndingSpace(node, token) {
  58720. context.report({
  58721. node: node,
  58722. loc: token.loc.start,
  58723. messageId: "missingSpaceBefore",
  58724. data: {
  58725. tokenValue: token.value
  58726. },
  58727. fix: function fix(fixer) {
  58728. return fixer.insertTextBefore(token, " ");
  58729. }
  58730. });
  58731. }
  58732. /**
  58733. * Determines if a node is an object type
  58734. * @param {ASTNode} node - The node to check.
  58735. * @returns {boolean} Whether or not the node is an object type.
  58736. */
  58737. function isObjectType(node) {
  58738. return node && (node.type === "ObjectExpression" || node.type === "ObjectPattern");
  58739. }
  58740. /**
  58741. * Determines if a node is an array type
  58742. * @param {ASTNode} node - The node to check.
  58743. * @returns {boolean} Whether or not the node is an array type.
  58744. */
  58745. function isArrayType(node) {
  58746. return node && (node.type === "ArrayExpression" || node.type === "ArrayPattern");
  58747. }
  58748. /**
  58749. * Validates the spacing around array brackets
  58750. * @param {ASTNode} node - The node we're checking for spacing
  58751. * @returns {void}
  58752. */
  58753. function validateArraySpacing(node) {
  58754. if (options.spaced && node.elements.length === 0) {
  58755. return;
  58756. }
  58757. var first = sourceCode.getFirstToken(node),
  58758. second = sourceCode.getFirstToken(node, 1),
  58759. last = node.typeAnnotation ? sourceCode.getTokenBefore(node.typeAnnotation) : sourceCode.getLastToken(node),
  58760. penultimate = sourceCode.getTokenBefore(last),
  58761. firstElement = node.elements[0],
  58762. lastElement = node.elements[node.elements.length - 1];
  58763. var openingBracketMustBeSpaced = options.objectsInArraysException && isObjectType(firstElement) || options.arraysInArraysException && isArrayType(firstElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
  58764. var closingBracketMustBeSpaced = options.objectsInArraysException && isObjectType(lastElement) || options.arraysInArraysException && isArrayType(lastElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
  58765. if (astUtils.isTokenOnSameLine(first, second)) {
  58766. if (openingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(first, second)) {
  58767. reportRequiredBeginningSpace(node, first);
  58768. }
  58769. if (!openingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(first, second)) {
  58770. reportNoBeginningSpace(node, first);
  58771. }
  58772. }
  58773. if (first !== penultimate && astUtils.isTokenOnSameLine(penultimate, last)) {
  58774. if (closingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(penultimate, last)) {
  58775. reportRequiredEndingSpace(node, last);
  58776. }
  58777. if (!closingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(penultimate, last)) {
  58778. reportNoEndingSpace(node, last);
  58779. }
  58780. }
  58781. }
  58782. //--------------------------------------------------------------------------
  58783. // Public
  58784. //--------------------------------------------------------------------------
  58785. return {
  58786. ArrayPattern: validateArraySpacing,
  58787. ArrayExpression: validateArraySpacing
  58788. };
  58789. }
  58790. };
  58791. },{"../util/ast-utils":405}],128:[function(require,module,exports){
  58792. /**
  58793. * @fileoverview Rule to enforce return statements in callbacks of array's methods
  58794. * @author Toru Nagashima
  58795. */
  58796. "use strict";
  58797. //------------------------------------------------------------------------------
  58798. // Requirements
  58799. //------------------------------------------------------------------------------
  58800. var lodash = require("lodash");
  58801. var astUtils = require("../util/ast-utils");
  58802. //------------------------------------------------------------------------------
  58803. // Helpers
  58804. //------------------------------------------------------------------------------
  58805. var TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/;
  58806. var TARGET_METHODS = /^(?:every|filter|find(?:Index)?|map|reduce(?:Right)?|some|sort)$/;
  58807. /**
  58808. * Checks a given code path segment is reachable.
  58809. *
  58810. * @param {CodePathSegment} segment - A segment to check.
  58811. * @returns {boolean} `true` if the segment is reachable.
  58812. */
  58813. function isReachable(segment) {
  58814. return segment.reachable;
  58815. }
  58816. /**
  58817. * Gets a readable location.
  58818. *
  58819. * - FunctionExpression -> the function name or `function` keyword.
  58820. * - ArrowFunctionExpression -> `=>` token.
  58821. *
  58822. * @param {ASTNode} node - A function node to get.
  58823. * @param {SourceCode} sourceCode - A source code to get tokens.
  58824. * @returns {ASTNode|Token} The node or the token of a location.
  58825. */
  58826. function getLocation(node, sourceCode) {
  58827. if (node.type === "ArrowFunctionExpression") {
  58828. return sourceCode.getTokenBefore(node.body);
  58829. }
  58830. return node.id || node;
  58831. }
  58832. /**
  58833. * Checks a given node is a MemberExpression node which has the specified name's
  58834. * property.
  58835. *
  58836. * @param {ASTNode} node - A node to check.
  58837. * @returns {boolean} `true` if the node is a MemberExpression node which has
  58838. * the specified name's property
  58839. */
  58840. function isTargetMethod(node) {
  58841. return node.type === "MemberExpression" && TARGET_METHODS.test(astUtils.getStaticPropertyName(node) || "");
  58842. }
  58843. /**
  58844. * Checks whether or not a given node is a function expression which is the
  58845. * callback of an array method.
  58846. *
  58847. * @param {ASTNode} node - A node to check. This is one of
  58848. * FunctionExpression or ArrowFunctionExpression.
  58849. * @returns {boolean} `true` if the node is the callback of an array method.
  58850. */
  58851. function isCallbackOfArrayMethod(node) {
  58852. var currentNode = node;
  58853. while (currentNode) {
  58854. var parent = currentNode.parent;
  58855. switch (parent.type) {
  58856. /*
  58857. * Looks up the destination. e.g.,
  58858. * foo.every(nativeFoo || function foo() { ... });
  58859. */
  58860. case "LogicalExpression":
  58861. case "ConditionalExpression":
  58862. currentNode = parent;
  58863. break;
  58864. /*
  58865. * If the upper function is IIFE, checks the destination of the return value.
  58866. * e.g.
  58867. * foo.every((function() {
  58868. * // setup...
  58869. * return function callback() { ... };
  58870. * })());
  58871. */
  58872. case "ReturnStatement":
  58873. {
  58874. var func = astUtils.getUpperFunction(parent);
  58875. if (func === null || !astUtils.isCallee(func)) {
  58876. return false;
  58877. }
  58878. currentNode = func.parent;
  58879. break;
  58880. }
  58881. /*
  58882. * e.g.
  58883. * Array.from([], function() {});
  58884. * list.every(function() {});
  58885. */
  58886. case "CallExpression":
  58887. if (astUtils.isArrayFromMethod(parent.callee)) {
  58888. return parent.arguments.length >= 2 && parent.arguments[1] === currentNode;
  58889. }
  58890. if (isTargetMethod(parent.callee)) {
  58891. return parent.arguments.length >= 1 && parent.arguments[0] === currentNode;
  58892. }
  58893. return false;
  58894. // Otherwise this node is not target.
  58895. default:
  58896. return false;
  58897. }
  58898. }
  58899. /* istanbul ignore next: unreachable */
  58900. return false;
  58901. }
  58902. //------------------------------------------------------------------------------
  58903. // Rule Definition
  58904. //------------------------------------------------------------------------------
  58905. module.exports = {
  58906. meta: {
  58907. type: "problem",
  58908. docs: {
  58909. description: "enforce `return` statements in callbacks of array methods",
  58910. category: "Best Practices",
  58911. recommended: false,
  58912. url: "https://eslint.org/docs/rules/array-callback-return"
  58913. },
  58914. schema: [{
  58915. type: "object",
  58916. properties: {
  58917. allowImplicit: {
  58918. type: "boolean"
  58919. }
  58920. },
  58921. additionalProperties: false
  58922. }],
  58923. messages: {
  58924. expectedAtEnd: "Expected to return a value at the end of {{name}}.",
  58925. expectedInside: "Expected to return a value in {{name}}.",
  58926. expectedReturnValue: "{{name}} expected a return value."
  58927. }
  58928. },
  58929. create: function create(context) {
  58930. var options = context.options[0] || { allowImplicit: false };
  58931. var funcInfo = {
  58932. upper: null,
  58933. codePath: null,
  58934. hasReturn: false,
  58935. shouldCheck: false,
  58936. node: null
  58937. };
  58938. /**
  58939. * Checks whether or not the last code path segment is reachable.
  58940. * Then reports this function if the segment is reachable.
  58941. *
  58942. * If the last code path segment is reachable, there are paths which are not
  58943. * returned or thrown.
  58944. *
  58945. * @param {ASTNode} node - A node to check.
  58946. * @returns {void}
  58947. */
  58948. function checkLastSegment(node) {
  58949. if (funcInfo.shouldCheck && funcInfo.codePath.currentSegments.some(isReachable)) {
  58950. context.report({
  58951. node: node,
  58952. loc: getLocation(node, context.getSourceCode()).loc.start,
  58953. messageId: funcInfo.hasReturn ? "expectedAtEnd" : "expectedInside",
  58954. data: {
  58955. name: astUtils.getFunctionNameWithKind(funcInfo.node)
  58956. }
  58957. });
  58958. }
  58959. }
  58960. return {
  58961. // Stacks this function's information.
  58962. onCodePathStart: function onCodePathStart(codePath, node) {
  58963. funcInfo = {
  58964. upper: funcInfo,
  58965. codePath: codePath,
  58966. hasReturn: false,
  58967. shouldCheck: TARGET_NODE_TYPE.test(node.type) && node.body.type === "BlockStatement" && isCallbackOfArrayMethod(node) && !node.async && !node.generator,
  58968. node: node
  58969. };
  58970. },
  58971. // Pops this function's information.
  58972. onCodePathEnd: function onCodePathEnd() {
  58973. funcInfo = funcInfo.upper;
  58974. },
  58975. // Checks the return statement is valid.
  58976. ReturnStatement: function ReturnStatement(node) {
  58977. if (funcInfo.shouldCheck) {
  58978. funcInfo.hasReturn = true;
  58979. // if allowImplicit: false, should also check node.argument
  58980. if (!options.allowImplicit && !node.argument) {
  58981. context.report({
  58982. node: node,
  58983. messageId: "expectedReturnValue",
  58984. data: {
  58985. name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
  58986. }
  58987. });
  58988. }
  58989. }
  58990. },
  58991. // Reports a given function if the last path is reachable.
  58992. "FunctionExpression:exit": checkLastSegment,
  58993. "ArrowFunctionExpression:exit": checkLastSegment
  58994. };
  58995. }
  58996. };
  58997. },{"../util/ast-utils":405,"lodash":92}],129:[function(require,module,exports){
  58998. /**
  58999. * @fileoverview Rule to enforce line breaks after each array element
  59000. * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
  59001. */
  59002. "use strict";
  59003. var astUtils = require("../util/ast-utils");
  59004. //------------------------------------------------------------------------------
  59005. // Rule Definition
  59006. //------------------------------------------------------------------------------
  59007. module.exports = {
  59008. meta: {
  59009. type: "layout",
  59010. docs: {
  59011. description: "enforce line breaks after each array element",
  59012. category: "Stylistic Issues",
  59013. recommended: false,
  59014. url: "https://eslint.org/docs/rules/array-element-newline"
  59015. },
  59016. fixable: "whitespace",
  59017. schema: [{
  59018. oneOf: [{
  59019. enum: ["always", "never", "consistent"]
  59020. }, {
  59021. type: "object",
  59022. properties: {
  59023. multiline: {
  59024. type: "boolean"
  59025. },
  59026. minItems: {
  59027. type: ["integer", "null"],
  59028. minimum: 0
  59029. }
  59030. },
  59031. additionalProperties: false
  59032. }]
  59033. }],
  59034. messages: {
  59035. unexpectedLineBreak: "There should be no linebreak here.",
  59036. missingLineBreak: "There should be a linebreak after this element."
  59037. }
  59038. },
  59039. create: function create(context) {
  59040. var sourceCode = context.getSourceCode();
  59041. //----------------------------------------------------------------------
  59042. // Helpers
  59043. //----------------------------------------------------------------------
  59044. /**
  59045. * Normalizes a given option value.
  59046. *
  59047. * @param {string|Object|undefined} providedOption - An option value to parse.
  59048. * @returns {{multiline: boolean, minItems: number}} Normalized option object.
  59049. */
  59050. function normalizeOptionValue(providedOption) {
  59051. var consistent = false;
  59052. var multiline = false;
  59053. var minItems = void 0;
  59054. var option = providedOption || "always";
  59055. if (!option || option === "always" || option.minItems === 0) {
  59056. minItems = 0;
  59057. } else if (option === "never") {
  59058. minItems = Number.POSITIVE_INFINITY;
  59059. } else if (option === "consistent") {
  59060. consistent = true;
  59061. minItems = Number.POSITIVE_INFINITY;
  59062. } else {
  59063. multiline = Boolean(option.multiline);
  59064. minItems = option.minItems || Number.POSITIVE_INFINITY;
  59065. }
  59066. return { consistent: consistent, multiline: multiline, minItems: minItems };
  59067. }
  59068. /**
  59069. * Normalizes a given option value.
  59070. *
  59071. * @param {string|Object|undefined} options - An option value to parse.
  59072. * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object.
  59073. */
  59074. function normalizeOptions(options) {
  59075. var value = normalizeOptionValue(options);
  59076. return { ArrayExpression: value, ArrayPattern: value };
  59077. }
  59078. /**
  59079. * Reports that there shouldn't be a line break after the first token
  59080. * @param {Token} token - The token to use for the report.
  59081. * @returns {void}
  59082. */
  59083. function reportNoLineBreak(token) {
  59084. var tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true });
  59085. context.report({
  59086. loc: {
  59087. start: tokenBefore.loc.end,
  59088. end: token.loc.start
  59089. },
  59090. messageId: "unexpectedLineBreak",
  59091. fix: function fix(fixer) {
  59092. if (astUtils.isCommentToken(tokenBefore)) {
  59093. return null;
  59094. }
  59095. if (!astUtils.isTokenOnSameLine(tokenBefore, token)) {
  59096. return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ");
  59097. }
  59098. /*
  59099. * This will check if the comma is on the same line as the next element
  59100. * Following array:
  59101. * [
  59102. * 1
  59103. * , 2
  59104. * , 3
  59105. * ]
  59106. *
  59107. * will be fixed to:
  59108. * [
  59109. * 1, 2, 3
  59110. * ]
  59111. */
  59112. var twoTokensBefore = sourceCode.getTokenBefore(tokenBefore, { includeComments: true });
  59113. if (astUtils.isCommentToken(twoTokensBefore)) {
  59114. return null;
  59115. }
  59116. return fixer.replaceTextRange([twoTokensBefore.range[1], tokenBefore.range[0]], "");
  59117. }
  59118. });
  59119. }
  59120. /**
  59121. * Reports that there should be a line break after the first token
  59122. * @param {Token} token - The token to use for the report.
  59123. * @returns {void}
  59124. */
  59125. function reportRequiredLineBreak(token) {
  59126. var tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true });
  59127. context.report({
  59128. loc: {
  59129. start: tokenBefore.loc.end,
  59130. end: token.loc.start
  59131. },
  59132. messageId: "missingLineBreak",
  59133. fix: function fix(fixer) {
  59134. return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n");
  59135. }
  59136. });
  59137. }
  59138. /**
  59139. * Reports a given node if it violated this rule.
  59140. *
  59141. * @param {ASTNode} node - A node to check. This is an ObjectExpression node or an ObjectPattern node.
  59142. * @returns {void}
  59143. */
  59144. function check(node) {
  59145. var elements = node.elements;
  59146. var normalizedOptions = normalizeOptions(context.options[0]);
  59147. var options = normalizedOptions[node.type];
  59148. var elementBreak = false;
  59149. /*
  59150. * MULTILINE: true
  59151. * loop through every element and check
  59152. * if at least one element has linebreaks inside
  59153. * this ensures that following is not valid (due to elements are on the same line):
  59154. *
  59155. * [
  59156. * 1,
  59157. * 2,
  59158. * 3
  59159. * ]
  59160. */
  59161. if (options.multiline) {
  59162. elementBreak = elements.filter(function (element) {
  59163. return element !== null;
  59164. }).some(function (element) {
  59165. return element.loc.start.line !== element.loc.end.line;
  59166. });
  59167. }
  59168. var linebreaksCount = node.elements.map(function (element, i) {
  59169. var previousElement = elements[i - 1];
  59170. if (i === 0 || element === null || previousElement === null) {
  59171. return false;
  59172. }
  59173. var commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
  59174. var lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
  59175. var firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
  59176. return !astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement);
  59177. }).filter(function (isBreak) {
  59178. return isBreak === true;
  59179. }).length;
  59180. var needsLinebreaks = elements.length >= options.minItems || options.multiline && elementBreak || options.consistent && linebreaksCount > 0 && linebreaksCount < node.elements.length;
  59181. elements.forEach(function (element, i) {
  59182. var previousElement = elements[i - 1];
  59183. if (i === 0 || element === null || previousElement === null) {
  59184. return;
  59185. }
  59186. var commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
  59187. var lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
  59188. var firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
  59189. if (needsLinebreaks) {
  59190. if (astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
  59191. reportRequiredLineBreak(firstTokenOfCurrentElement);
  59192. }
  59193. } else {
  59194. if (!astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
  59195. reportNoLineBreak(firstTokenOfCurrentElement);
  59196. }
  59197. }
  59198. });
  59199. }
  59200. //----------------------------------------------------------------------
  59201. // Public
  59202. //----------------------------------------------------------------------
  59203. return {
  59204. ArrayPattern: check,
  59205. ArrayExpression: check
  59206. };
  59207. }
  59208. };
  59209. },{"../util/ast-utils":405}],130:[function(require,module,exports){
  59210. /**
  59211. * @fileoverview Rule to require braces in arrow function body.
  59212. * @author Alberto Rodríguez
  59213. */
  59214. "use strict";
  59215. //------------------------------------------------------------------------------
  59216. // Requirements
  59217. //------------------------------------------------------------------------------
  59218. var astUtils = require("../util/ast-utils");
  59219. //------------------------------------------------------------------------------
  59220. // Rule Definition
  59221. //------------------------------------------------------------------------------
  59222. module.exports = {
  59223. meta: {
  59224. type: "suggestion",
  59225. docs: {
  59226. description: "require braces around arrow function bodies",
  59227. category: "ECMAScript 6",
  59228. recommended: false,
  59229. url: "https://eslint.org/docs/rules/arrow-body-style"
  59230. },
  59231. schema: {
  59232. anyOf: [{
  59233. type: "array",
  59234. items: [{
  59235. enum: ["always", "never"]
  59236. }],
  59237. minItems: 0,
  59238. maxItems: 1
  59239. }, {
  59240. type: "array",
  59241. items: [{
  59242. enum: ["as-needed"]
  59243. }, {
  59244. type: "object",
  59245. properties: {
  59246. requireReturnForObjectLiteral: { type: "boolean" }
  59247. },
  59248. additionalProperties: false
  59249. }],
  59250. minItems: 0,
  59251. maxItems: 2
  59252. }]
  59253. },
  59254. fixable: "code",
  59255. messages: {
  59256. unexpectedOtherBlock: "Unexpected block statement surrounding arrow body.",
  59257. unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
  59258. unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
  59259. unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
  59260. expectedBlock: "Expected block statement surrounding arrow body."
  59261. }
  59262. },
  59263. create: function create(context) {
  59264. var options = context.options;
  59265. var always = options[0] === "always";
  59266. var asNeeded = !options[0] || options[0] === "as-needed";
  59267. var never = options[0] === "never";
  59268. var requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral;
  59269. var sourceCode = context.getSourceCode();
  59270. /**
  59271. * Checks whether the given node has ASI problem or not.
  59272. * @param {Token} token The token to check.
  59273. * @returns {boolean} `true` if it changes semantics if `;` or `}` followed by the token are removed.
  59274. */
  59275. function hasASIProblem(token) {
  59276. return token && token.type === "Punctuator" && /^[([/`+-]/.test(token.value);
  59277. }
  59278. /**
  59279. * Gets the closing parenthesis which is the pair of the given opening parenthesis.
  59280. * @param {Token} token The opening parenthesis token to get.
  59281. * @returns {Token} The found closing parenthesis token.
  59282. */
  59283. function findClosingParen(token) {
  59284. var node = sourceCode.getNodeByRangeIndex(token.range[1]);
  59285. while (!astUtils.isParenthesised(sourceCode, node)) {
  59286. node = node.parent;
  59287. }
  59288. return sourceCode.getTokenAfter(node);
  59289. }
  59290. /**
  59291. * Determines whether a arrow function body needs braces
  59292. * @param {ASTNode} node The arrow function node.
  59293. * @returns {void}
  59294. */
  59295. function validate(node) {
  59296. var arrowBody = node.body;
  59297. if (arrowBody.type === "BlockStatement") {
  59298. var blockBody = arrowBody.body;
  59299. if (blockBody.length !== 1 && !never) {
  59300. return;
  59301. }
  59302. if (asNeeded && requireReturnForObjectLiteral && blockBody[0].type === "ReturnStatement" && blockBody[0].argument && blockBody[0].argument.type === "ObjectExpression") {
  59303. return;
  59304. }
  59305. if (never || asNeeded && blockBody[0].type === "ReturnStatement") {
  59306. var messageId = void 0;
  59307. if (blockBody.length === 0) {
  59308. messageId = "unexpectedEmptyBlock";
  59309. } else if (blockBody.length > 1) {
  59310. messageId = "unexpectedOtherBlock";
  59311. } else if (blockBody[0].argument === null) {
  59312. messageId = "unexpectedSingleBlock";
  59313. } else if (astUtils.isOpeningBraceToken(sourceCode.getFirstToken(blockBody[0], { skip: 1 }))) {
  59314. messageId = "unexpectedObjectBlock";
  59315. } else {
  59316. messageId = "unexpectedSingleBlock";
  59317. }
  59318. context.report({
  59319. node: node,
  59320. loc: arrowBody.loc.start,
  59321. messageId: messageId,
  59322. fix: function fix(fixer) {
  59323. var fixes = [];
  59324. if (blockBody.length !== 1 || blockBody[0].type !== "ReturnStatement" || !blockBody[0].argument || hasASIProblem(sourceCode.getTokenAfter(arrowBody))) {
  59325. return fixes;
  59326. }
  59327. var openingBrace = sourceCode.getFirstToken(arrowBody);
  59328. var closingBrace = sourceCode.getLastToken(arrowBody);
  59329. var firstValueToken = sourceCode.getFirstToken(blockBody[0], 1);
  59330. var lastValueToken = sourceCode.getLastToken(blockBody[0]);
  59331. var commentsExist = sourceCode.commentsExistBetween(openingBrace, firstValueToken) || sourceCode.commentsExistBetween(lastValueToken, closingBrace);
  59332. /*
  59333. * Remove tokens around the return value.
  59334. * If comments don't exist, remove extra spaces as well.
  59335. */
  59336. if (commentsExist) {
  59337. fixes.push(fixer.remove(openingBrace), fixer.remove(closingBrace), fixer.remove(sourceCode.getTokenAfter(openingBrace)) // return keyword
  59338. );
  59339. } else {
  59340. fixes.push(fixer.removeRange([openingBrace.range[0], firstValueToken.range[0]]), fixer.removeRange([lastValueToken.range[1], closingBrace.range[1]]));
  59341. }
  59342. /*
  59343. * If the first token of the reutrn value is `{`,
  59344. * enclose the return value by parentheses to avoid syntax error.
  59345. */
  59346. if (astUtils.isOpeningBraceToken(firstValueToken)) {
  59347. fixes.push(fixer.insertTextBefore(firstValueToken, "("), fixer.insertTextAfter(lastValueToken, ")"));
  59348. }
  59349. /*
  59350. * If the last token of the return statement is semicolon, remove it.
  59351. * Non-block arrow body is an expression, not a statement.
  59352. */
  59353. if (astUtils.isSemicolonToken(lastValueToken)) {
  59354. fixes.push(fixer.remove(lastValueToken));
  59355. }
  59356. return fixes;
  59357. }
  59358. });
  59359. }
  59360. } else {
  59361. if (always || asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression") {
  59362. context.report({
  59363. node: node,
  59364. loc: arrowBody.loc.start,
  59365. messageId: "expectedBlock",
  59366. fix: function fix(fixer) {
  59367. var fixes = [];
  59368. var arrowToken = sourceCode.getTokenBefore(arrowBody, astUtils.isArrowToken);
  59369. var firstBodyToken = sourceCode.getTokenAfter(arrowToken);
  59370. var lastBodyToken = sourceCode.getLastToken(node);
  59371. var isParenthesisedObjectLiteral = astUtils.isOpeningParenToken(firstBodyToken) && astUtils.isOpeningBraceToken(sourceCode.getTokenAfter(firstBodyToken));
  59372. // Wrap the value by a block and a return statement.
  59373. fixes.push(fixer.insertTextBefore(firstBodyToken, "{return "), fixer.insertTextAfter(lastBodyToken, "}"));
  59374. // If the value is object literal, remove parentheses which were forced by syntax.
  59375. if (isParenthesisedObjectLiteral) {
  59376. fixes.push(fixer.remove(firstBodyToken), fixer.remove(findClosingParen(firstBodyToken)));
  59377. }
  59378. return fixes;
  59379. }
  59380. });
  59381. }
  59382. }
  59383. }
  59384. return {
  59385. "ArrowFunctionExpression:exit": validate
  59386. };
  59387. }
  59388. };
  59389. },{"../util/ast-utils":405}],131:[function(require,module,exports){
  59390. /**
  59391. * @fileoverview Rule to require parens in arrow function arguments.
  59392. * @author Jxck
  59393. */
  59394. "use strict";
  59395. //------------------------------------------------------------------------------
  59396. // Requirements
  59397. //------------------------------------------------------------------------------
  59398. var astUtils = require("../util/ast-utils");
  59399. //------------------------------------------------------------------------------
  59400. // Rule Definition
  59401. //------------------------------------------------------------------------------
  59402. module.exports = {
  59403. meta: {
  59404. type: "layout",
  59405. docs: {
  59406. description: "require parentheses around arrow function arguments",
  59407. category: "ECMAScript 6",
  59408. recommended: false,
  59409. url: "https://eslint.org/docs/rules/arrow-parens"
  59410. },
  59411. fixable: "code",
  59412. schema: [{
  59413. enum: ["always", "as-needed"]
  59414. }, {
  59415. type: "object",
  59416. properties: {
  59417. requireForBlockBody: {
  59418. type: "boolean"
  59419. }
  59420. },
  59421. additionalProperties: false
  59422. }],
  59423. messages: {
  59424. unexpectedParens: "Unexpected parentheses around single function argument.",
  59425. expectedParens: "Expected parentheses around arrow function argument.",
  59426. unexpectedParensInline: "Unexpected parentheses around single function argument having a body with no curly braces.",
  59427. expectedParensBlock: "Expected parentheses around arrow function argument having a body with curly braces."
  59428. }
  59429. },
  59430. create: function create(context) {
  59431. var asNeeded = context.options[0] === "as-needed";
  59432. var requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true;
  59433. var sourceCode = context.getSourceCode();
  59434. /**
  59435. * Determines whether a arrow function argument end with `)`
  59436. * @param {ASTNode} node The arrow function node.
  59437. * @returns {void}
  59438. */
  59439. function parens(node) {
  59440. var isAsync = node.async;
  59441. var firstTokenOfParam = sourceCode.getFirstToken(node, isAsync ? 1 : 0);
  59442. /**
  59443. * Remove the parenthesis around a parameter
  59444. * @param {Fixer} fixer Fixer
  59445. * @returns {string} fixed parameter
  59446. */
  59447. function fixParamsWithParenthesis(fixer) {
  59448. var paramToken = sourceCode.getTokenAfter(firstTokenOfParam);
  59449. /*
  59450. * ES8 allows Trailing commas in function parameter lists and calls
  59451. * https://github.com/eslint/eslint/issues/8834
  59452. */
  59453. var closingParenToken = sourceCode.getTokenAfter(paramToken, astUtils.isClosingParenToken);
  59454. var asyncToken = isAsync ? sourceCode.getTokenBefore(firstTokenOfParam) : null;
  59455. var shouldAddSpaceForAsync = asyncToken && asyncToken.range[1] === firstTokenOfParam.range[0];
  59456. return fixer.replaceTextRange([firstTokenOfParam.range[0], closingParenToken.range[1]], "" + (shouldAddSpaceForAsync ? " " : "") + paramToken.value);
  59457. }
  59458. // "as-needed", { "requireForBlockBody": true }: x => x
  59459. if (requireForBlockBody && node.params.length === 1 && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && node.body.type !== "BlockStatement" && !node.returnType) {
  59460. if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
  59461. context.report({
  59462. node: node,
  59463. messageId: "unexpectedParensInline",
  59464. fix: fixParamsWithParenthesis
  59465. });
  59466. }
  59467. return;
  59468. }
  59469. if (requireForBlockBody && node.body.type === "BlockStatement") {
  59470. if (!astUtils.isOpeningParenToken(firstTokenOfParam)) {
  59471. context.report({
  59472. node: node,
  59473. messageId: "expectedParensBlock",
  59474. fix: function fix(fixer) {
  59475. return fixer.replaceText(firstTokenOfParam, "(" + firstTokenOfParam.value + ")");
  59476. }
  59477. });
  59478. }
  59479. return;
  59480. }
  59481. // "as-needed": x => x
  59482. if (asNeeded && node.params.length === 1 && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.returnType) {
  59483. if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
  59484. context.report({
  59485. node: node,
  59486. messageId: "unexpectedParens",
  59487. fix: fixParamsWithParenthesis
  59488. });
  59489. }
  59490. return;
  59491. }
  59492. if (firstTokenOfParam.type === "Identifier") {
  59493. var after = sourceCode.getTokenAfter(firstTokenOfParam);
  59494. // (x) => x
  59495. if (after.value !== ")") {
  59496. context.report({
  59497. node: node,
  59498. messageId: "expectedParens",
  59499. fix: function fix(fixer) {
  59500. return fixer.replaceText(firstTokenOfParam, "(" + firstTokenOfParam.value + ")");
  59501. }
  59502. });
  59503. }
  59504. }
  59505. }
  59506. return {
  59507. ArrowFunctionExpression: parens
  59508. };
  59509. }
  59510. };
  59511. },{"../util/ast-utils":405}],132:[function(require,module,exports){
  59512. /**
  59513. * @fileoverview Rule to define spacing before/after arrow function's arrow.
  59514. * @author Jxck
  59515. */
  59516. "use strict";
  59517. //------------------------------------------------------------------------------
  59518. // Requirements
  59519. //------------------------------------------------------------------------------
  59520. var astUtils = require("../util/ast-utils");
  59521. //------------------------------------------------------------------------------
  59522. // Rule Definition
  59523. //------------------------------------------------------------------------------
  59524. module.exports = {
  59525. meta: {
  59526. type: "layout",
  59527. docs: {
  59528. description: "enforce consistent spacing before and after the arrow in arrow functions",
  59529. category: "ECMAScript 6",
  59530. recommended: false,
  59531. url: "https://eslint.org/docs/rules/arrow-spacing"
  59532. },
  59533. fixable: "whitespace",
  59534. schema: [{
  59535. type: "object",
  59536. properties: {
  59537. before: {
  59538. type: "boolean"
  59539. },
  59540. after: {
  59541. type: "boolean"
  59542. }
  59543. },
  59544. additionalProperties: false
  59545. }],
  59546. messages: {
  59547. expectedBefore: "Missing space before =>.",
  59548. unexpectedBefore: "Unexpected space before =>.",
  59549. expectedAfter: "Missing space after =>.",
  59550. unexpectedAfter: "Unexpected space after =>."
  59551. }
  59552. },
  59553. create: function create(context) {
  59554. // merge rules with default
  59555. var rule = { before: true, after: true },
  59556. option = context.options[0] || {};
  59557. rule.before = option.before !== false;
  59558. rule.after = option.after !== false;
  59559. var sourceCode = context.getSourceCode();
  59560. /**
  59561. * Get tokens of arrow(`=>`) and before/after arrow.
  59562. * @param {ASTNode} node The arrow function node.
  59563. * @returns {Object} Tokens of arrow and before/after arrow.
  59564. */
  59565. function getTokens(node) {
  59566. var arrow = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken);
  59567. return {
  59568. before: sourceCode.getTokenBefore(arrow),
  59569. arrow: arrow,
  59570. after: sourceCode.getTokenAfter(arrow)
  59571. };
  59572. }
  59573. /**
  59574. * Count spaces before/after arrow(`=>`) token.
  59575. * @param {Object} tokens Tokens before/after arrow.
  59576. * @returns {Object} count of space before/after arrow.
  59577. */
  59578. function countSpaces(tokens) {
  59579. var before = tokens.arrow.range[0] - tokens.before.range[1];
  59580. var after = tokens.after.range[0] - tokens.arrow.range[1];
  59581. return { before: before, after: after };
  59582. }
  59583. /**
  59584. * Determines whether space(s) before after arrow(`=>`) is satisfy rule.
  59585. * if before/after value is `true`, there should be space(s).
  59586. * if before/after value is `false`, there should be no space.
  59587. * @param {ASTNode} node The arrow function node.
  59588. * @returns {void}
  59589. */
  59590. function spaces(node) {
  59591. var tokens = getTokens(node);
  59592. var countSpace = countSpaces(tokens);
  59593. if (rule.before) {
  59594. // should be space(s) before arrow
  59595. if (countSpace.before === 0) {
  59596. context.report({
  59597. node: tokens.before,
  59598. messageId: "expectedBefore",
  59599. fix: function fix(fixer) {
  59600. return fixer.insertTextBefore(tokens.arrow, " ");
  59601. }
  59602. });
  59603. }
  59604. } else {
  59605. // should be no space before arrow
  59606. if (countSpace.before > 0) {
  59607. context.report({
  59608. node: tokens.before,
  59609. messageId: "unexpectedBefore",
  59610. fix: function fix(fixer) {
  59611. return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
  59612. }
  59613. });
  59614. }
  59615. }
  59616. if (rule.after) {
  59617. // should be space(s) after arrow
  59618. if (countSpace.after === 0) {
  59619. context.report({
  59620. node: tokens.after,
  59621. messageId: "expectedAfter",
  59622. fix: function fix(fixer) {
  59623. return fixer.insertTextAfter(tokens.arrow, " ");
  59624. }
  59625. });
  59626. }
  59627. } else {
  59628. // should be no space after arrow
  59629. if (countSpace.after > 0) {
  59630. context.report({
  59631. node: tokens.after,
  59632. messageId: "unexpectedAfter",
  59633. fix: function fix(fixer) {
  59634. return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
  59635. }
  59636. });
  59637. }
  59638. }
  59639. }
  59640. return {
  59641. ArrowFunctionExpression: spaces
  59642. };
  59643. }
  59644. };
  59645. },{"../util/ast-utils":405}],133:[function(require,module,exports){
  59646. /**
  59647. * @fileoverview Rule to check for "block scoped" variables by binding context
  59648. * @author Matt DuVall <http://www.mattduvall.com>
  59649. */
  59650. "use strict";
  59651. //------------------------------------------------------------------------------
  59652. // Rule Definition
  59653. //------------------------------------------------------------------------------
  59654. module.exports = {
  59655. meta: {
  59656. type: "suggestion",
  59657. docs: {
  59658. description: "enforce the use of variables within the scope they are defined",
  59659. category: "Best Practices",
  59660. recommended: false,
  59661. url: "https://eslint.org/docs/rules/block-scoped-var"
  59662. },
  59663. schema: [],
  59664. messages: {
  59665. outOfScope: "'{{name}}' used outside of binding context."
  59666. }
  59667. },
  59668. create: function create(context) {
  59669. var stack = [];
  59670. /**
  59671. * Makes a block scope.
  59672. * @param {ASTNode} node - A node of a scope.
  59673. * @returns {void}
  59674. */
  59675. function enterScope(node) {
  59676. stack.push(node.range);
  59677. }
  59678. /**
  59679. * Pops the last block scope.
  59680. * @returns {void}
  59681. */
  59682. function exitScope() {
  59683. stack.pop();
  59684. }
  59685. /**
  59686. * Reports a given reference.
  59687. * @param {eslint-scope.Reference} reference - A reference to report.
  59688. * @returns {void}
  59689. */
  59690. function report(reference) {
  59691. var identifier = reference.identifier;
  59692. context.report({ node: identifier, messageId: "outOfScope", data: { name: identifier.name } });
  59693. }
  59694. /**
  59695. * Finds and reports references which are outside of valid scopes.
  59696. * @param {ASTNode} node - A node to get variables.
  59697. * @returns {void}
  59698. */
  59699. function checkForVariables(node) {
  59700. if (node.kind !== "var") {
  59701. return;
  59702. }
  59703. // Defines a predicate to check whether or not a given reference is outside of valid scope.
  59704. var scopeRange = stack[stack.length - 1];
  59705. /**
  59706. * Check if a reference is out of scope
  59707. * @param {ASTNode} reference node to examine
  59708. * @returns {boolean} True is its outside the scope
  59709. * @private
  59710. */
  59711. function isOutsideOfScope(reference) {
  59712. var idRange = reference.identifier.range;
  59713. return idRange[0] < scopeRange[0] || idRange[1] > scopeRange[1];
  59714. }
  59715. // Gets declared variables, and checks its references.
  59716. var variables = context.getDeclaredVariables(node);
  59717. for (var i = 0; i < variables.length; ++i) {
  59718. // Reports.
  59719. variables[i].references.filter(isOutsideOfScope).forEach(report);
  59720. }
  59721. }
  59722. return {
  59723. Program: function Program(node) {
  59724. stack = [node.range];
  59725. },
  59726. // Manages scopes.
  59727. BlockStatement: enterScope,
  59728. "BlockStatement:exit": exitScope,
  59729. ForStatement: enterScope,
  59730. "ForStatement:exit": exitScope,
  59731. ForInStatement: enterScope,
  59732. "ForInStatement:exit": exitScope,
  59733. ForOfStatement: enterScope,
  59734. "ForOfStatement:exit": exitScope,
  59735. SwitchStatement: enterScope,
  59736. "SwitchStatement:exit": exitScope,
  59737. CatchClause: enterScope,
  59738. "CatchClause:exit": exitScope,
  59739. // Finds and reports references which are outside of valid scope.
  59740. VariableDeclaration: checkForVariables
  59741. };
  59742. }
  59743. };
  59744. },{}],134:[function(require,module,exports){
  59745. /**
  59746. * @fileoverview A rule to disallow or enforce spaces inside of single line blocks.
  59747. * @author Toru Nagashima
  59748. */
  59749. "use strict";
  59750. var util = require("../util/ast-utils");
  59751. //------------------------------------------------------------------------------
  59752. // Rule Definition
  59753. //------------------------------------------------------------------------------
  59754. module.exports = {
  59755. meta: {
  59756. type: "layout",
  59757. docs: {
  59758. description: "disallow or enforce spaces inside of blocks after opening block and before closing block",
  59759. category: "Stylistic Issues",
  59760. recommended: false,
  59761. url: "https://eslint.org/docs/rules/block-spacing"
  59762. },
  59763. fixable: "whitespace",
  59764. schema: [{ enum: ["always", "never"] }],
  59765. messages: {
  59766. missing: "Requires a space {{location}} '{{token}}'",
  59767. extra: "Unexpected space(s) {{location}} '{{token}}'"
  59768. }
  59769. },
  59770. create: function create(context) {
  59771. var always = context.options[0] !== "never",
  59772. messageId = always ? "missing" : "extra",
  59773. sourceCode = context.getSourceCode();
  59774. /**
  59775. * Gets the open brace token from a given node.
  59776. * @param {ASTNode} node - A BlockStatement/SwitchStatement node to get.
  59777. * @returns {Token} The token of the open brace.
  59778. */
  59779. function getOpenBrace(node) {
  59780. if (node.type === "SwitchStatement") {
  59781. if (node.cases.length > 0) {
  59782. return sourceCode.getTokenBefore(node.cases[0]);
  59783. }
  59784. return sourceCode.getLastToken(node, 1);
  59785. }
  59786. return sourceCode.getFirstToken(node);
  59787. }
  59788. /**
  59789. * Checks whether or not:
  59790. * - given tokens are on same line.
  59791. * - there is/isn't a space between given tokens.
  59792. * @param {Token} left - A token to check.
  59793. * @param {Token} right - The token which is next to `left`.
  59794. * @returns {boolean}
  59795. * When the option is `"always"`, `true` if there are one or more spaces between given tokens.
  59796. * When the option is `"never"`, `true` if there are not any spaces between given tokens.
  59797. * If given tokens are not on same line, it's always `true`.
  59798. */
  59799. function isValid(left, right) {
  59800. return !util.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === always;
  59801. }
  59802. /**
  59803. * Reports invalid spacing style inside braces.
  59804. * @param {ASTNode} node - A BlockStatement/SwitchStatement node to get.
  59805. * @returns {void}
  59806. */
  59807. function checkSpacingInsideBraces(node) {
  59808. // Gets braces and the first/last token of content.
  59809. var openBrace = getOpenBrace(node);
  59810. var closeBrace = sourceCode.getLastToken(node);
  59811. var firstToken = sourceCode.getTokenAfter(openBrace, { includeComments: true });
  59812. var lastToken = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
  59813. // Skip if the node is invalid or empty.
  59814. if (openBrace.type !== "Punctuator" || openBrace.value !== "{" || closeBrace.type !== "Punctuator" || closeBrace.value !== "}" || firstToken === closeBrace) {
  59815. return;
  59816. }
  59817. // Skip line comments for option never
  59818. if (!always && firstToken.type === "Line") {
  59819. return;
  59820. }
  59821. // Check.
  59822. if (!isValid(openBrace, firstToken)) {
  59823. context.report({
  59824. node: node,
  59825. loc: openBrace.loc.start,
  59826. messageId: messageId,
  59827. data: {
  59828. location: "after",
  59829. token: openBrace.value
  59830. },
  59831. fix: function fix(fixer) {
  59832. if (always) {
  59833. return fixer.insertTextBefore(firstToken, " ");
  59834. }
  59835. return fixer.removeRange([openBrace.range[1], firstToken.range[0]]);
  59836. }
  59837. });
  59838. }
  59839. if (!isValid(lastToken, closeBrace)) {
  59840. context.report({
  59841. node: node,
  59842. loc: closeBrace.loc.start,
  59843. messageId: messageId,
  59844. data: {
  59845. location: "before",
  59846. token: closeBrace.value
  59847. },
  59848. fix: function fix(fixer) {
  59849. if (always) {
  59850. return fixer.insertTextAfter(lastToken, " ");
  59851. }
  59852. return fixer.removeRange([lastToken.range[1], closeBrace.range[0]]);
  59853. }
  59854. });
  59855. }
  59856. }
  59857. return {
  59858. BlockStatement: checkSpacingInsideBraces,
  59859. SwitchStatement: checkSpacingInsideBraces
  59860. };
  59861. }
  59862. };
  59863. },{"../util/ast-utils":405}],135:[function(require,module,exports){
  59864. /**
  59865. * @fileoverview Rule to flag block statements that do not use the one true brace style
  59866. * @author Ian Christian Myers
  59867. */
  59868. "use strict";
  59869. var astUtils = require("../util/ast-utils");
  59870. //------------------------------------------------------------------------------
  59871. // Rule Definition
  59872. //------------------------------------------------------------------------------
  59873. module.exports = {
  59874. meta: {
  59875. type: "layout",
  59876. docs: {
  59877. description: "enforce consistent brace style for blocks",
  59878. category: "Stylistic Issues",
  59879. recommended: false,
  59880. url: "https://eslint.org/docs/rules/brace-style"
  59881. },
  59882. schema: [{
  59883. enum: ["1tbs", "stroustrup", "allman"]
  59884. }, {
  59885. type: "object",
  59886. properties: {
  59887. allowSingleLine: {
  59888. type: "boolean"
  59889. }
  59890. },
  59891. additionalProperties: false
  59892. }],
  59893. fixable: "whitespace",
  59894. messages: {
  59895. nextLineOpen: "Opening curly brace does not appear on the same line as controlling statement.",
  59896. sameLineOpen: "Opening curly brace appears on the same line as controlling statement.",
  59897. blockSameLine: "Statement inside of curly braces should be on next line.",
  59898. nextLineClose: "Closing curly brace does not appear on the same line as the subsequent block.",
  59899. singleLineClose: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.",
  59900. sameLineClose: "Closing curly brace appears on the same line as the subsequent block."
  59901. }
  59902. },
  59903. create: function create(context) {
  59904. var style = context.options[0] || "1tbs",
  59905. params = context.options[1] || {},
  59906. sourceCode = context.getSourceCode();
  59907. //--------------------------------------------------------------------------
  59908. // Helpers
  59909. //--------------------------------------------------------------------------
  59910. /**
  59911. * Fixes a place where a newline unexpectedly appears
  59912. * @param {Token} firstToken The token before the unexpected newline
  59913. * @param {Token} secondToken The token after the unexpected newline
  59914. * @returns {Function} A fixer function to remove the newlines between the tokens
  59915. */
  59916. function removeNewlineBetween(firstToken, secondToken) {
  59917. var textRange = [firstToken.range[1], secondToken.range[0]];
  59918. var textBetween = sourceCode.text.slice(textRange[0], textRange[1]);
  59919. // Don't do a fix if there is a comment between the tokens
  59920. if (textBetween.trim()) {
  59921. return null;
  59922. }
  59923. return function (fixer) {
  59924. return fixer.replaceTextRange(textRange, " ");
  59925. };
  59926. }
  59927. /**
  59928. * Validates a pair of curly brackets based on the user's config
  59929. * @param {Token} openingCurly The opening curly bracket
  59930. * @param {Token} closingCurly The closing curly bracket
  59931. * @returns {void}
  59932. */
  59933. function validateCurlyPair(openingCurly, closingCurly) {
  59934. var tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly);
  59935. var tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly);
  59936. var tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly);
  59937. var singleLineException = params.allowSingleLine && astUtils.isTokenOnSameLine(openingCurly, closingCurly);
  59938. if (style !== "allman" && !astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) {
  59939. context.report({
  59940. node: openingCurly,
  59941. messageId: "nextLineOpen",
  59942. fix: removeNewlineBetween(tokenBeforeOpeningCurly, openingCurly)
  59943. });
  59944. }
  59945. if (style === "allman" && astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) {
  59946. context.report({
  59947. node: openingCurly,
  59948. messageId: "sameLineOpen",
  59949. fix: function fix(fixer) {
  59950. return fixer.insertTextBefore(openingCurly, "\n");
  59951. }
  59952. });
  59953. }
  59954. if (astUtils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly) && tokenAfterOpeningCurly !== closingCurly && !singleLineException) {
  59955. context.report({
  59956. node: openingCurly,
  59957. messageId: "blockSameLine",
  59958. fix: function fix(fixer) {
  59959. return fixer.insertTextAfter(openingCurly, "\n");
  59960. }
  59961. });
  59962. }
  59963. if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && astUtils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly)) {
  59964. context.report({
  59965. node: closingCurly,
  59966. messageId: "singleLineClose",
  59967. fix: function fix(fixer) {
  59968. return fixer.insertTextBefore(closingCurly, "\n");
  59969. }
  59970. });
  59971. }
  59972. }
  59973. /**
  59974. * Validates the location of a token that appears before a keyword (e.g. a newline before `else`)
  59975. * @param {Token} curlyToken The closing curly token. This is assumed to precede a keyword token (such as `else` or `finally`).
  59976. * @returns {void}
  59977. */
  59978. function validateCurlyBeforeKeyword(curlyToken) {
  59979. var keywordToken = sourceCode.getTokenAfter(curlyToken);
  59980. if (style === "1tbs" && !astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
  59981. context.report({
  59982. node: curlyToken,
  59983. messageId: "nextLineClose",
  59984. fix: removeNewlineBetween(curlyToken, keywordToken)
  59985. });
  59986. }
  59987. if (style !== "1tbs" && astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
  59988. context.report({
  59989. node: curlyToken,
  59990. messageId: "sameLineClose",
  59991. fix: function fix(fixer) {
  59992. return fixer.insertTextAfter(curlyToken, "\n");
  59993. }
  59994. });
  59995. }
  59996. }
  59997. //--------------------------------------------------------------------------
  59998. // Public API
  59999. //--------------------------------------------------------------------------
  60000. return {
  60001. BlockStatement: function BlockStatement(node) {
  60002. if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
  60003. validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
  60004. }
  60005. },
  60006. ClassBody: function ClassBody(node) {
  60007. validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
  60008. },
  60009. SwitchStatement: function SwitchStatement(node) {
  60010. var closingCurly = sourceCode.getLastToken(node);
  60011. var openingCurly = sourceCode.getTokenBefore(node.cases.length ? node.cases[0] : closingCurly);
  60012. validateCurlyPair(openingCurly, closingCurly);
  60013. },
  60014. IfStatement: function IfStatement(node) {
  60015. if (node.consequent.type === "BlockStatement" && node.alternate) {
  60016. // Handle the keyword after the `if` block (before `else`)
  60017. validateCurlyBeforeKeyword(sourceCode.getLastToken(node.consequent));
  60018. }
  60019. },
  60020. TryStatement: function TryStatement(node) {
  60021. // Handle the keyword after the `try` block (before `catch` or `finally`)
  60022. validateCurlyBeforeKeyword(sourceCode.getLastToken(node.block));
  60023. if (node.handler && node.finalizer) {
  60024. // Handle the keyword after the `catch` block (before `finally`)
  60025. validateCurlyBeforeKeyword(sourceCode.getLastToken(node.handler.body));
  60026. }
  60027. }
  60028. };
  60029. }
  60030. };
  60031. },{"../util/ast-utils":405}],136:[function(require,module,exports){
  60032. /**
  60033. * @fileoverview Enforce return after a callback.
  60034. * @author Jamund Ferguson
  60035. */
  60036. "use strict";
  60037. //------------------------------------------------------------------------------
  60038. // Rule Definition
  60039. //------------------------------------------------------------------------------
  60040. module.exports = {
  60041. meta: {
  60042. type: "suggestion",
  60043. docs: {
  60044. description: "require `return` statements after callbacks",
  60045. category: "Node.js and CommonJS",
  60046. recommended: false,
  60047. url: "https://eslint.org/docs/rules/callback-return"
  60048. },
  60049. schema: [{
  60050. type: "array",
  60051. items: { type: "string" }
  60052. }],
  60053. messages: {
  60054. missingReturn: "Expected return with your callback function."
  60055. }
  60056. },
  60057. create: function create(context) {
  60058. var callbacks = context.options[0] || ["callback", "cb", "next"],
  60059. sourceCode = context.getSourceCode();
  60060. //--------------------------------------------------------------------------
  60061. // Helpers
  60062. //--------------------------------------------------------------------------
  60063. /**
  60064. * Find the closest parent matching a list of types.
  60065. * @param {ASTNode} node The node whose parents we are searching
  60066. * @param {Array} types The node types to match
  60067. * @returns {ASTNode} The matched node or undefined.
  60068. */
  60069. function findClosestParentOfType(node, types) {
  60070. if (!node.parent) {
  60071. return null;
  60072. }
  60073. if (types.indexOf(node.parent.type) === -1) {
  60074. return findClosestParentOfType(node.parent, types);
  60075. }
  60076. return node.parent;
  60077. }
  60078. /**
  60079. * Check to see if a node contains only identifers
  60080. * @param {ASTNode} node The node to check
  60081. * @returns {boolean} Whether or not the node contains only identifers
  60082. */
  60083. function containsOnlyIdentifiers(node) {
  60084. if (node.type === "Identifier") {
  60085. return true;
  60086. }
  60087. if (node.type === "MemberExpression") {
  60088. if (node.object.type === "Identifier") {
  60089. return true;
  60090. }
  60091. if (node.object.type === "MemberExpression") {
  60092. return containsOnlyIdentifiers(node.object);
  60093. }
  60094. }
  60095. return false;
  60096. }
  60097. /**
  60098. * Check to see if a CallExpression is in our callback list.
  60099. * @param {ASTNode} node The node to check against our callback names list.
  60100. * @returns {boolean} Whether or not this function matches our callback name.
  60101. */
  60102. function isCallback(node) {
  60103. return containsOnlyIdentifiers(node.callee) && callbacks.indexOf(sourceCode.getText(node.callee)) > -1;
  60104. }
  60105. /**
  60106. * Determines whether or not the callback is part of a callback expression.
  60107. * @param {ASTNode} node The callback node
  60108. * @param {ASTNode} parentNode The expression node
  60109. * @returns {boolean} Whether or not this is part of a callback expression
  60110. */
  60111. function isCallbackExpression(node, parentNode) {
  60112. // ensure the parent node exists and is an expression
  60113. if (!parentNode || parentNode.type !== "ExpressionStatement") {
  60114. return false;
  60115. }
  60116. // cb()
  60117. if (parentNode.expression === node) {
  60118. return true;
  60119. }
  60120. // special case for cb && cb() and similar
  60121. if (parentNode.expression.type === "BinaryExpression" || parentNode.expression.type === "LogicalExpression") {
  60122. if (parentNode.expression.right === node) {
  60123. return true;
  60124. }
  60125. }
  60126. return false;
  60127. }
  60128. //--------------------------------------------------------------------------
  60129. // Public
  60130. //--------------------------------------------------------------------------
  60131. return {
  60132. CallExpression: function CallExpression(node) {
  60133. // if we're not a callback we can return
  60134. if (!isCallback(node)) {
  60135. return;
  60136. }
  60137. // find the closest block, return or loop
  60138. var closestBlock = findClosestParentOfType(node, ["BlockStatement", "ReturnStatement", "ArrowFunctionExpression"]) || {};
  60139. // if our parent is a return we know we're ok
  60140. if (closestBlock.type === "ReturnStatement") {
  60141. return;
  60142. }
  60143. // arrow functions don't always have blocks and implicitly return
  60144. if (closestBlock.type === "ArrowFunctionExpression") {
  60145. return;
  60146. }
  60147. // block statements are part of functions and most if statements
  60148. if (closestBlock.type === "BlockStatement") {
  60149. // find the last item in the block
  60150. var lastItem = closestBlock.body[closestBlock.body.length - 1];
  60151. // if the callback is the last thing in a block that might be ok
  60152. if (isCallbackExpression(node, lastItem)) {
  60153. var parentType = closestBlock.parent.type;
  60154. // but only if the block is part of a function
  60155. if (parentType === "FunctionExpression" || parentType === "FunctionDeclaration" || parentType === "ArrowFunctionExpression") {
  60156. return;
  60157. }
  60158. }
  60159. // ending a block with a return is also ok
  60160. if (lastItem.type === "ReturnStatement") {
  60161. // but only if the callback is immediately before
  60162. if (isCallbackExpression(node, closestBlock.body[closestBlock.body.length - 2])) {
  60163. return;
  60164. }
  60165. }
  60166. }
  60167. // as long as you're the child of a function at this point you should be asked to return
  60168. if (findClosestParentOfType(node, ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"])) {
  60169. context.report({ node: node, messageId: "missingReturn" });
  60170. }
  60171. }
  60172. };
  60173. }
  60174. };
  60175. },{}],137:[function(require,module,exports){
  60176. /**
  60177. * @fileoverview Rule to flag non-camelcased identifiers
  60178. * @author Nicholas C. Zakas
  60179. */
  60180. "use strict";
  60181. //------------------------------------------------------------------------------
  60182. // Rule Definition
  60183. //------------------------------------------------------------------------------
  60184. module.exports = {
  60185. meta: {
  60186. type: "suggestion",
  60187. docs: {
  60188. description: "enforce camelcase naming convention",
  60189. category: "Stylistic Issues",
  60190. recommended: false,
  60191. url: "https://eslint.org/docs/rules/camelcase"
  60192. },
  60193. schema: [{
  60194. type: "object",
  60195. properties: {
  60196. ignoreDestructuring: {
  60197. type: "boolean"
  60198. },
  60199. properties: {
  60200. enum: ["always", "never"]
  60201. },
  60202. allow: {
  60203. type: "array",
  60204. items: [{
  60205. type: "string"
  60206. }],
  60207. minItems: 0,
  60208. uniqueItems: true
  60209. }
  60210. },
  60211. additionalProperties: false
  60212. }],
  60213. messages: {
  60214. notCamelCase: "Identifier '{{name}}' is not in camel case."
  60215. }
  60216. },
  60217. create: function create(context) {
  60218. var options = context.options[0] || {};
  60219. var properties = options.properties || "";
  60220. var ignoreDestructuring = options.ignoreDestructuring || false;
  60221. var allow = options.allow || [];
  60222. if (properties !== "always" && properties !== "never") {
  60223. properties = "always";
  60224. }
  60225. //--------------------------------------------------------------------------
  60226. // Helpers
  60227. //--------------------------------------------------------------------------
  60228. // contains reported nodes to avoid reporting twice on destructuring with shorthand notation
  60229. var reported = [];
  60230. var ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]);
  60231. /**
  60232. * Checks if a string contains an underscore and isn't all upper-case
  60233. * @param {string} name The string to check.
  60234. * @returns {boolean} if the string is underscored
  60235. * @private
  60236. */
  60237. function isUnderscored(name) {
  60238. // if there's an underscore, it might be A_CONSTANT, which is okay
  60239. return name.indexOf("_") > -1 && name !== name.toUpperCase();
  60240. }
  60241. /**
  60242. * Checks if a string match the ignore list
  60243. * @param {string} name The string to check.
  60244. * @returns {boolean} if the string is ignored
  60245. * @private
  60246. */
  60247. function isAllowed(name) {
  60248. return allow.findIndex(function (entry) {
  60249. return name === entry || name.match(new RegExp(entry));
  60250. }) !== -1;
  60251. }
  60252. /**
  60253. * Checks if a parent of a node is an ObjectPattern.
  60254. * @param {ASTNode} node The node to check.
  60255. * @returns {boolean} if the node is inside an ObjectPattern
  60256. * @private
  60257. */
  60258. function isInsideObjectPattern(node) {
  60259. var current = node;
  60260. while (current) {
  60261. var parent = current.parent;
  60262. if (parent && parent.type === "Property" && parent.computed && parent.key === current) {
  60263. return false;
  60264. }
  60265. if (current.type === "ObjectPattern") {
  60266. return true;
  60267. }
  60268. current = parent;
  60269. }
  60270. return false;
  60271. }
  60272. /**
  60273. * Reports an AST node as a rule violation.
  60274. * @param {ASTNode} node The node to report.
  60275. * @returns {void}
  60276. * @private
  60277. */
  60278. function report(node) {
  60279. if (reported.indexOf(node) < 0) {
  60280. reported.push(node);
  60281. context.report({ node: node, messageId: "notCamelCase", data: { name: node.name } });
  60282. }
  60283. }
  60284. return {
  60285. Identifier: function Identifier(node) {
  60286. /*
  60287. * Leading and trailing underscores are commonly used to flag
  60288. * private/protected identifiers, strip them before checking if underscored
  60289. */
  60290. var name = node.name,
  60291. nameIsUnderscored = isUnderscored(name.replace(/^_+|_+$/g, "")),
  60292. effectiveParent = node.parent.type === "MemberExpression" ? node.parent.parent : node.parent;
  60293. // First, we ignore the node if it match the ignore list
  60294. if (isAllowed(name)) {
  60295. return;
  60296. }
  60297. // MemberExpressions get special rules
  60298. if (node.parent.type === "MemberExpression") {
  60299. // "never" check properties
  60300. if (properties === "never") {
  60301. return;
  60302. }
  60303. // Always report underscored object names
  60304. if (node.parent.object.type === "Identifier" && node.parent.object.name === node.name && nameIsUnderscored) {
  60305. report(node);
  60306. // Report AssignmentExpressions only if they are the left side of the assignment
  60307. } else if (effectiveParent.type === "AssignmentExpression" && nameIsUnderscored && (effectiveParent.right.type !== "MemberExpression" || effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name)) {
  60308. report(node);
  60309. }
  60310. /*
  60311. * Properties have their own rules, and
  60312. * AssignmentPattern nodes can be treated like Properties:
  60313. * e.g.: const { no_camelcased = false } = bar;
  60314. */
  60315. } else if (node.parent.type === "Property" || node.parent.type === "AssignmentPattern") {
  60316. if (node.parent.parent && node.parent.parent.type === "ObjectPattern") {
  60317. if (node.parent.shorthand && node.parent.value.left && nameIsUnderscored) {
  60318. report(node);
  60319. }
  60320. var assignmentKeyEqualsValue = node.parent.key.name === node.parent.value.name;
  60321. if (isUnderscored(name) && node.parent.computed) {
  60322. report(node);
  60323. }
  60324. // prevent checking righthand side of destructured object
  60325. if (node.parent.key === node && node.parent.value !== node) {
  60326. return;
  60327. }
  60328. var valueIsUnderscored = node.parent.value.name && nameIsUnderscored;
  60329. // ignore destructuring if the option is set, unless a new identifier is created
  60330. if (valueIsUnderscored && !(assignmentKeyEqualsValue && ignoreDestructuring)) {
  60331. report(node);
  60332. }
  60333. }
  60334. // "never" check properties or always ignore destructuring
  60335. if (properties === "never" || ignoreDestructuring && isInsideObjectPattern(node)) {
  60336. return;
  60337. }
  60338. // don't check right hand side of AssignmentExpression to prevent duplicate warnings
  60339. if (nameIsUnderscored && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && !(node.parent.right === node)) {
  60340. report(node);
  60341. }
  60342. // Check if it's an import specifier
  60343. } else if (["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"].indexOf(node.parent.type) >= 0) {
  60344. // Report only if the local imported identifier is underscored
  60345. if (node.parent.local && node.parent.local.name === node.name && nameIsUnderscored) {
  60346. report(node);
  60347. }
  60348. // Report anything that is underscored that isn't a CallExpression
  60349. } else if (nameIsUnderscored && !ALLOWED_PARENT_TYPES.has(effectiveParent.type)) {
  60350. report(node);
  60351. }
  60352. }
  60353. };
  60354. }
  60355. };
  60356. },{}],138:[function(require,module,exports){
  60357. /**
  60358. * @fileoverview enforce or disallow capitalization of the first letter of a comment
  60359. * @author Kevin Partington
  60360. */
  60361. "use strict";
  60362. //------------------------------------------------------------------------------
  60363. // Requirements
  60364. //------------------------------------------------------------------------------
  60365. var LETTER_PATTERN = require("../util/patterns/letters");
  60366. var astUtils = require("../util/ast-utils");
  60367. //------------------------------------------------------------------------------
  60368. // Helpers
  60369. //------------------------------------------------------------------------------
  60370. var DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
  60371. WHITESPACE = /\s/g,
  60372. MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/,
  60373. // TODO: Combine w/ max-len pattern?
  60374. DEFAULTS = {
  60375. ignorePattern: null,
  60376. ignoreInlineComments: false,
  60377. ignoreConsecutiveComments: false
  60378. };
  60379. /*
  60380. * Base schema body for defining the basic capitalization rule, ignorePattern,
  60381. * and ignoreInlineComments values.
  60382. * This can be used in a few different ways in the actual schema.
  60383. */
  60384. var SCHEMA_BODY = {
  60385. type: "object",
  60386. properties: {
  60387. ignorePattern: {
  60388. type: "string"
  60389. },
  60390. ignoreInlineComments: {
  60391. type: "boolean"
  60392. },
  60393. ignoreConsecutiveComments: {
  60394. type: "boolean"
  60395. }
  60396. },
  60397. additionalProperties: false
  60398. };
  60399. /**
  60400. * Get normalized options for either block or line comments from the given
  60401. * user-provided options.
  60402. * - If the user-provided options is just a string, returns a normalized
  60403. * set of options using default values for all other options.
  60404. * - If the user-provided options is an object, then a normalized option
  60405. * set is returned. Options specified in overrides will take priority
  60406. * over options specified in the main options object, which will in
  60407. * turn take priority over the rule's defaults.
  60408. *
  60409. * @param {Object|string} rawOptions The user-provided options.
  60410. * @param {string} which Either "line" or "block".
  60411. * @returns {Object} The normalized options.
  60412. */
  60413. function getNormalizedOptions(rawOptions, which) {
  60414. if (!rawOptions) {
  60415. return Object.assign({}, DEFAULTS);
  60416. }
  60417. return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions);
  60418. }
  60419. /**
  60420. * Get normalized options for block and line comments.
  60421. *
  60422. * @param {Object|string} rawOptions The user-provided options.
  60423. * @returns {Object} An object with "Line" and "Block" keys and corresponding
  60424. * normalized options objects.
  60425. */
  60426. function getAllNormalizedOptions(rawOptions) {
  60427. return {
  60428. Line: getNormalizedOptions(rawOptions, "line"),
  60429. Block: getNormalizedOptions(rawOptions, "block")
  60430. };
  60431. }
  60432. /**
  60433. * Creates a regular expression for each ignorePattern defined in the rule
  60434. * options.
  60435. *
  60436. * This is done in order to avoid invoking the RegExp constructor repeatedly.
  60437. *
  60438. * @param {Object} normalizedOptions The normalized rule options.
  60439. * @returns {void}
  60440. */
  60441. function createRegExpForIgnorePatterns(normalizedOptions) {
  60442. Object.keys(normalizedOptions).forEach(function (key) {
  60443. var ignorePatternStr = normalizedOptions[key].ignorePattern;
  60444. if (ignorePatternStr) {
  60445. var regExp = RegExp("^\\s*(?:" + ignorePatternStr + ")");
  60446. normalizedOptions[key].ignorePatternRegExp = regExp;
  60447. }
  60448. });
  60449. }
  60450. //------------------------------------------------------------------------------
  60451. // Rule Definition
  60452. //------------------------------------------------------------------------------
  60453. module.exports = {
  60454. meta: {
  60455. type: "suggestion",
  60456. docs: {
  60457. description: "enforce or disallow capitalization of the first letter of a comment",
  60458. category: "Stylistic Issues",
  60459. recommended: false,
  60460. url: "https://eslint.org/docs/rules/capitalized-comments"
  60461. },
  60462. fixable: "code",
  60463. schema: [{ enum: ["always", "never"] }, {
  60464. oneOf: [SCHEMA_BODY, {
  60465. type: "object",
  60466. properties: {
  60467. line: SCHEMA_BODY,
  60468. block: SCHEMA_BODY
  60469. },
  60470. additionalProperties: false
  60471. }]
  60472. }],
  60473. messages: {
  60474. unexpectedLowercaseComment: "Comments should not begin with a lowercase character",
  60475. unexpectedUppercaseComment: "Comments should not begin with an uppercase character"
  60476. }
  60477. },
  60478. create: function create(context) {
  60479. var capitalize = context.options[0] || "always",
  60480. normalizedOptions = getAllNormalizedOptions(context.options[1]),
  60481. sourceCode = context.getSourceCode();
  60482. createRegExpForIgnorePatterns(normalizedOptions);
  60483. //----------------------------------------------------------------------
  60484. // Helpers
  60485. //----------------------------------------------------------------------
  60486. /**
  60487. * Checks whether a comment is an inline comment.
  60488. *
  60489. * For the purpose of this rule, a comment is inline if:
  60490. * 1. The comment is preceded by a token on the same line; and
  60491. * 2. The command is followed by a token on the same line.
  60492. *
  60493. * Note that the comment itself need not be single-line!
  60494. *
  60495. * Also, it follows from this definition that only block comments can
  60496. * be considered as possibly inline. This is because line comments
  60497. * would consume any following tokens on the same line as the comment.
  60498. *
  60499. * @param {ASTNode} comment The comment node to check.
  60500. * @returns {boolean} True if the comment is an inline comment, false
  60501. * otherwise.
  60502. */
  60503. function isInlineComment(comment) {
  60504. var previousToken = sourceCode.getTokenBefore(comment, { includeComments: true }),
  60505. nextToken = sourceCode.getTokenAfter(comment, { includeComments: true });
  60506. return Boolean(previousToken && nextToken && comment.loc.start.line === previousToken.loc.end.line && comment.loc.end.line === nextToken.loc.start.line);
  60507. }
  60508. /**
  60509. * Determine if a comment follows another comment.
  60510. *
  60511. * @param {ASTNode} comment The comment to check.
  60512. * @returns {boolean} True if the comment follows a valid comment.
  60513. */
  60514. function isConsecutiveComment(comment) {
  60515. var previousTokenOrComment = sourceCode.getTokenBefore(comment, { includeComments: true });
  60516. return Boolean(previousTokenOrComment && ["Block", "Line"].indexOf(previousTokenOrComment.type) !== -1);
  60517. }
  60518. /**
  60519. * Check a comment to determine if it is valid for this rule.
  60520. *
  60521. * @param {ASTNode} comment The comment node to process.
  60522. * @param {Object} options The options for checking this comment.
  60523. * @returns {boolean} True if the comment is valid, false otherwise.
  60524. */
  60525. function isCommentValid(comment, options) {
  60526. // 1. Check for default ignore pattern.
  60527. if (DEFAULT_IGNORE_PATTERN.test(comment.value)) {
  60528. return true;
  60529. }
  60530. // 2. Check for custom ignore pattern.
  60531. var commentWithoutAsterisks = comment.value.replace(/\*/g, "");
  60532. if (options.ignorePatternRegExp && options.ignorePatternRegExp.test(commentWithoutAsterisks)) {
  60533. return true;
  60534. }
  60535. // 3. Check for inline comments.
  60536. if (options.ignoreInlineComments && isInlineComment(comment)) {
  60537. return true;
  60538. }
  60539. // 4. Is this a consecutive comment (and are we tolerating those)?
  60540. if (options.ignoreConsecutiveComments && isConsecutiveComment(comment)) {
  60541. return true;
  60542. }
  60543. // 5. Does the comment start with a possible URL?
  60544. if (MAYBE_URL.test(commentWithoutAsterisks)) {
  60545. return true;
  60546. }
  60547. // 6. Is the initial word character a letter?
  60548. var commentWordCharsOnly = commentWithoutAsterisks.replace(WHITESPACE, "");
  60549. if (commentWordCharsOnly.length === 0) {
  60550. return true;
  60551. }
  60552. var firstWordChar = commentWordCharsOnly[0];
  60553. if (!LETTER_PATTERN.test(firstWordChar)) {
  60554. return true;
  60555. }
  60556. // 7. Check the case of the initial word character.
  60557. var isUppercase = firstWordChar !== firstWordChar.toLocaleLowerCase(),
  60558. isLowercase = firstWordChar !== firstWordChar.toLocaleUpperCase();
  60559. if (capitalize === "always" && isLowercase) {
  60560. return false;
  60561. }
  60562. if (capitalize === "never" && isUppercase) {
  60563. return false;
  60564. }
  60565. return true;
  60566. }
  60567. /**
  60568. * Process a comment to determine if it needs to be reported.
  60569. *
  60570. * @param {ASTNode} comment The comment node to process.
  60571. * @returns {void}
  60572. */
  60573. function processComment(comment) {
  60574. var options = normalizedOptions[comment.type],
  60575. commentValid = isCommentValid(comment, options);
  60576. if (!commentValid) {
  60577. var messageId = capitalize === "always" ? "unexpectedLowercaseComment" : "unexpectedUppercaseComment";
  60578. context.report({
  60579. node: null, // Intentionally using loc instead
  60580. loc: comment.loc,
  60581. messageId: messageId,
  60582. fix: function fix(fixer) {
  60583. var match = comment.value.match(LETTER_PATTERN);
  60584. return fixer.replaceTextRange(
  60585. // Offset match.index by 2 to account for the first 2 characters that start the comment (// or /*)
  60586. [comment.range[0] + match.index + 2, comment.range[0] + match.index + 3], capitalize === "always" ? match[0].toLocaleUpperCase() : match[0].toLocaleLowerCase());
  60587. }
  60588. });
  60589. }
  60590. }
  60591. //----------------------------------------------------------------------
  60592. // Public
  60593. //----------------------------------------------------------------------
  60594. return {
  60595. Program: function Program() {
  60596. var comments = sourceCode.getAllComments();
  60597. comments.filter(function (token) {
  60598. return token.type !== "Shebang";
  60599. }).forEach(processComment);
  60600. }
  60601. };
  60602. }
  60603. };
  60604. },{"../util/ast-utils":405,"../util/patterns/letters":411}],139:[function(require,module,exports){
  60605. /**
  60606. * @fileoverview Rule to enforce that all class methods use 'this'.
  60607. * @author Patrick Williams
  60608. */
  60609. "use strict";
  60610. //------------------------------------------------------------------------------
  60611. // Rule Definition
  60612. //------------------------------------------------------------------------------
  60613. module.exports = {
  60614. meta: {
  60615. type: "suggestion",
  60616. docs: {
  60617. description: "enforce that class methods utilize `this`",
  60618. category: "Best Practices",
  60619. recommended: false,
  60620. url: "https://eslint.org/docs/rules/class-methods-use-this"
  60621. },
  60622. schema: [{
  60623. type: "object",
  60624. properties: {
  60625. exceptMethods: {
  60626. type: "array",
  60627. items: {
  60628. type: "string"
  60629. }
  60630. }
  60631. },
  60632. additionalProperties: false
  60633. }],
  60634. messages: {
  60635. missingThis: "Expected 'this' to be used by class method '{{name}}'."
  60636. }
  60637. },
  60638. create: function create(context) {
  60639. var config = context.options[0] ? Object.assign({}, context.options[0]) : {};
  60640. var exceptMethods = new Set(config.exceptMethods || []);
  60641. var stack = [];
  60642. /**
  60643. * Initializes the current context to false and pushes it onto the stack.
  60644. * These booleans represent whether 'this' has been used in the context.
  60645. * @returns {void}
  60646. * @private
  60647. */
  60648. function enterFunction() {
  60649. stack.push(false);
  60650. }
  60651. /**
  60652. * Check if the node is an instance method
  60653. * @param {ASTNode} node - node to check
  60654. * @returns {boolean} True if its an instance method
  60655. * @private
  60656. */
  60657. function isInstanceMethod(node) {
  60658. return !node.static && node.kind !== "constructor" && node.type === "MethodDefinition";
  60659. }
  60660. /**
  60661. * Check if the node is an instance method not excluded by config
  60662. * @param {ASTNode} node - node to check
  60663. * @returns {boolean} True if it is an instance method, and not excluded by config
  60664. * @private
  60665. */
  60666. function isIncludedInstanceMethod(node) {
  60667. return isInstanceMethod(node) && !exceptMethods.has(node.key.name);
  60668. }
  60669. /**
  60670. * Checks if we are leaving a function that is a method, and reports if 'this' has not been used.
  60671. * Static methods and the constructor are exempt.
  60672. * Then pops the context off the stack.
  60673. * @param {ASTNode} node - A function node that was entered.
  60674. * @returns {void}
  60675. * @private
  60676. */
  60677. function exitFunction(node) {
  60678. var methodUsesThis = stack.pop();
  60679. if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) {
  60680. context.report({
  60681. node: node,
  60682. messageId: "missingThis",
  60683. data: {
  60684. name: node.parent.key.name
  60685. }
  60686. });
  60687. }
  60688. }
  60689. /**
  60690. * Mark the current context as having used 'this'.
  60691. * @returns {void}
  60692. * @private
  60693. */
  60694. function markThisUsed() {
  60695. if (stack.length) {
  60696. stack[stack.length - 1] = true;
  60697. }
  60698. }
  60699. return {
  60700. FunctionDeclaration: enterFunction,
  60701. "FunctionDeclaration:exit": exitFunction,
  60702. FunctionExpression: enterFunction,
  60703. "FunctionExpression:exit": exitFunction,
  60704. ThisExpression: markThisUsed,
  60705. Super: markThisUsed
  60706. };
  60707. }
  60708. };
  60709. },{}],140:[function(require,module,exports){
  60710. /**
  60711. * @fileoverview Rule to forbid or enforce dangling commas.
  60712. * @author Ian Christian Myers
  60713. */
  60714. "use strict";
  60715. //------------------------------------------------------------------------------
  60716. // Requirements
  60717. //------------------------------------------------------------------------------
  60718. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  60719. var lodash = require("lodash");
  60720. var astUtils = require("../util/ast-utils");
  60721. //------------------------------------------------------------------------------
  60722. // Helpers
  60723. //------------------------------------------------------------------------------
  60724. var DEFAULT_OPTIONS = Object.freeze({
  60725. arrays: "never",
  60726. objects: "never",
  60727. imports: "never",
  60728. exports: "never",
  60729. functions: "ignore"
  60730. });
  60731. /**
  60732. * Checks whether or not a trailing comma is allowed in a given node.
  60733. * If the `lastItem` is `RestElement` or `RestProperty`, it disallows trailing commas.
  60734. *
  60735. * @param {ASTNode} lastItem - The node of the last element in the given node.
  60736. * @returns {boolean} `true` if a trailing comma is allowed.
  60737. */
  60738. function isTrailingCommaAllowed(lastItem) {
  60739. return !(lastItem.type === "RestElement" || lastItem.type === "RestProperty" || lastItem.type === "ExperimentalRestProperty");
  60740. }
  60741. /**
  60742. * Normalize option value.
  60743. *
  60744. * @param {string|Object|undefined} optionValue - The 1st option value to normalize.
  60745. * @returns {Object} The normalized option value.
  60746. */
  60747. function normalizeOptions(optionValue) {
  60748. if (typeof optionValue === "string") {
  60749. return {
  60750. arrays: optionValue,
  60751. objects: optionValue,
  60752. imports: optionValue,
  60753. exports: optionValue,
  60754. // For backward compatibility, always ignore functions.
  60755. functions: "ignore"
  60756. };
  60757. }
  60758. if ((typeof optionValue === "undefined" ? "undefined" : _typeof(optionValue)) === "object" && optionValue !== null) {
  60759. return {
  60760. arrays: optionValue.arrays || DEFAULT_OPTIONS.arrays,
  60761. objects: optionValue.objects || DEFAULT_OPTIONS.objects,
  60762. imports: optionValue.imports || DEFAULT_OPTIONS.imports,
  60763. exports: optionValue.exports || DEFAULT_OPTIONS.exports,
  60764. functions: optionValue.functions || DEFAULT_OPTIONS.functions
  60765. };
  60766. }
  60767. return DEFAULT_OPTIONS;
  60768. }
  60769. //------------------------------------------------------------------------------
  60770. // Rule Definition
  60771. //------------------------------------------------------------------------------
  60772. module.exports = {
  60773. meta: {
  60774. type: "layout",
  60775. docs: {
  60776. description: "require or disallow trailing commas",
  60777. category: "Stylistic Issues",
  60778. recommended: false,
  60779. url: "https://eslint.org/docs/rules/comma-dangle"
  60780. },
  60781. fixable: "code",
  60782. schema: {
  60783. definitions: {
  60784. value: {
  60785. enum: ["always-multiline", "always", "never", "only-multiline"]
  60786. },
  60787. valueWithIgnore: {
  60788. enum: ["always-multiline", "always", "ignore", "never", "only-multiline"]
  60789. }
  60790. },
  60791. type: "array",
  60792. items: [{
  60793. oneOf: [{
  60794. $ref: "#/definitions/value"
  60795. }, {
  60796. type: "object",
  60797. properties: {
  60798. arrays: { $ref: "#/definitions/valueWithIgnore" },
  60799. objects: { $ref: "#/definitions/valueWithIgnore" },
  60800. imports: { $ref: "#/definitions/valueWithIgnore" },
  60801. exports: { $ref: "#/definitions/valueWithIgnore" },
  60802. functions: { $ref: "#/definitions/valueWithIgnore" }
  60803. },
  60804. additionalProperties: false
  60805. }]
  60806. }]
  60807. },
  60808. messages: {
  60809. unexpected: "Unexpected trailing comma.",
  60810. missing: "Missing trailing comma."
  60811. }
  60812. },
  60813. create: function create(context) {
  60814. var options = normalizeOptions(context.options[0]);
  60815. var sourceCode = context.getSourceCode();
  60816. /**
  60817. * Gets the last item of the given node.
  60818. * @param {ASTNode} node - The node to get.
  60819. * @returns {ASTNode|null} The last node or null.
  60820. */
  60821. function getLastItem(node) {
  60822. switch (node.type) {
  60823. case "ObjectExpression":
  60824. case "ObjectPattern":
  60825. return lodash.last(node.properties);
  60826. case "ArrayExpression":
  60827. case "ArrayPattern":
  60828. return lodash.last(node.elements);
  60829. case "ImportDeclaration":
  60830. case "ExportNamedDeclaration":
  60831. return lodash.last(node.specifiers);
  60832. case "FunctionDeclaration":
  60833. case "FunctionExpression":
  60834. case "ArrowFunctionExpression":
  60835. return lodash.last(node.params);
  60836. case "CallExpression":
  60837. case "NewExpression":
  60838. return lodash.last(node.arguments);
  60839. default:
  60840. return null;
  60841. }
  60842. }
  60843. /**
  60844. * Gets the trailing comma token of the given node.
  60845. * If the trailing comma does not exist, this returns the token which is
  60846. * the insertion point of the trailing comma token.
  60847. *
  60848. * @param {ASTNode} node - The node to get.
  60849. * @param {ASTNode} lastItem - The last item of the node.
  60850. * @returns {Token} The trailing comma token or the insertion point.
  60851. */
  60852. function getTrailingToken(node, lastItem) {
  60853. switch (node.type) {
  60854. case "ObjectExpression":
  60855. case "ArrayExpression":
  60856. case "CallExpression":
  60857. case "NewExpression":
  60858. return sourceCode.getLastToken(node, 1);
  60859. default:
  60860. {
  60861. var nextToken = sourceCode.getTokenAfter(lastItem);
  60862. if (astUtils.isCommaToken(nextToken)) {
  60863. return nextToken;
  60864. }
  60865. return sourceCode.getLastToken(lastItem);
  60866. }
  60867. }
  60868. }
  60869. /**
  60870. * Checks whether or not a given node is multiline.
  60871. * This rule handles a given node as multiline when the closing parenthesis
  60872. * and the last element are not on the same line.
  60873. *
  60874. * @param {ASTNode} node - A node to check.
  60875. * @returns {boolean} `true` if the node is multiline.
  60876. */
  60877. function isMultiline(node) {
  60878. var lastItem = getLastItem(node);
  60879. if (!lastItem) {
  60880. return false;
  60881. }
  60882. var penultimateToken = getTrailingToken(node, lastItem);
  60883. var lastToken = sourceCode.getTokenAfter(penultimateToken);
  60884. return lastToken.loc.end.line !== penultimateToken.loc.end.line;
  60885. }
  60886. /**
  60887. * Reports a trailing comma if it exists.
  60888. *
  60889. * @param {ASTNode} node - A node to check. Its type is one of
  60890. * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
  60891. * ImportDeclaration, and ExportNamedDeclaration.
  60892. * @returns {void}
  60893. */
  60894. function forbidTrailingComma(node) {
  60895. var lastItem = getLastItem(node);
  60896. if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") {
  60897. return;
  60898. }
  60899. var trailingToken = getTrailingToken(node, lastItem);
  60900. if (astUtils.isCommaToken(trailingToken)) {
  60901. context.report({
  60902. node: lastItem,
  60903. loc: trailingToken.loc.start,
  60904. messageId: "unexpected",
  60905. fix: function fix(fixer) {
  60906. return fixer.remove(trailingToken);
  60907. }
  60908. });
  60909. }
  60910. }
  60911. /**
  60912. * Reports the last element of a given node if it does not have a trailing
  60913. * comma.
  60914. *
  60915. * If a given node is `ArrayPattern` which has `RestElement`, the trailing
  60916. * comma is disallowed, so report if it exists.
  60917. *
  60918. * @param {ASTNode} node - A node to check. Its type is one of
  60919. * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
  60920. * ImportDeclaration, and ExportNamedDeclaration.
  60921. * @returns {void}
  60922. */
  60923. function forceTrailingComma(node) {
  60924. var lastItem = getLastItem(node);
  60925. if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") {
  60926. return;
  60927. }
  60928. if (!isTrailingCommaAllowed(lastItem)) {
  60929. forbidTrailingComma(node);
  60930. return;
  60931. }
  60932. var trailingToken = getTrailingToken(node, lastItem);
  60933. if (trailingToken.value !== ",") {
  60934. context.report({
  60935. node: lastItem,
  60936. loc: trailingToken.loc.end,
  60937. messageId: "missing",
  60938. fix: function fix(fixer) {
  60939. return fixer.insertTextAfter(trailingToken, ",");
  60940. }
  60941. });
  60942. }
  60943. }
  60944. /**
  60945. * If a given node is multiline, reports the last element of a given node
  60946. * when it does not have a trailing comma.
  60947. * Otherwise, reports a trailing comma if it exists.
  60948. *
  60949. * @param {ASTNode} node - A node to check. Its type is one of
  60950. * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
  60951. * ImportDeclaration, and ExportNamedDeclaration.
  60952. * @returns {void}
  60953. */
  60954. function forceTrailingCommaIfMultiline(node) {
  60955. if (isMultiline(node)) {
  60956. forceTrailingComma(node);
  60957. } else {
  60958. forbidTrailingComma(node);
  60959. }
  60960. }
  60961. /**
  60962. * Only if a given node is not multiline, reports the last element of a given node
  60963. * when it does not have a trailing comma.
  60964. * Otherwise, reports a trailing comma if it exists.
  60965. *
  60966. * @param {ASTNode} node - A node to check. Its type is one of
  60967. * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
  60968. * ImportDeclaration, and ExportNamedDeclaration.
  60969. * @returns {void}
  60970. */
  60971. function allowTrailingCommaIfMultiline(node) {
  60972. if (!isMultiline(node)) {
  60973. forbidTrailingComma(node);
  60974. }
  60975. }
  60976. var predicate = {
  60977. always: forceTrailingComma,
  60978. "always-multiline": forceTrailingCommaIfMultiline,
  60979. "only-multiline": allowTrailingCommaIfMultiline,
  60980. never: forbidTrailingComma,
  60981. ignore: lodash.noop
  60982. };
  60983. return {
  60984. ObjectExpression: predicate[options.objects],
  60985. ObjectPattern: predicate[options.objects],
  60986. ArrayExpression: predicate[options.arrays],
  60987. ArrayPattern: predicate[options.arrays],
  60988. ImportDeclaration: predicate[options.imports],
  60989. ExportNamedDeclaration: predicate[options.exports],
  60990. FunctionDeclaration: predicate[options.functions],
  60991. FunctionExpression: predicate[options.functions],
  60992. ArrowFunctionExpression: predicate[options.functions],
  60993. CallExpression: predicate[options.functions],
  60994. NewExpression: predicate[options.functions]
  60995. };
  60996. }
  60997. };
  60998. },{"../util/ast-utils":405,"lodash":92}],141:[function(require,module,exports){
  60999. /**
  61000. * @fileoverview Comma spacing - validates spacing before and after comma
  61001. * @author Vignesh Anand aka vegetableman.
  61002. */
  61003. "use strict";
  61004. var astUtils = require("../util/ast-utils");
  61005. //------------------------------------------------------------------------------
  61006. // Rule Definition
  61007. //------------------------------------------------------------------------------
  61008. module.exports = {
  61009. meta: {
  61010. type: "layout",
  61011. docs: {
  61012. description: "enforce consistent spacing before and after commas",
  61013. category: "Stylistic Issues",
  61014. recommended: false,
  61015. url: "https://eslint.org/docs/rules/comma-spacing"
  61016. },
  61017. fixable: "whitespace",
  61018. schema: [{
  61019. type: "object",
  61020. properties: {
  61021. before: {
  61022. type: "boolean"
  61023. },
  61024. after: {
  61025. type: "boolean"
  61026. }
  61027. },
  61028. additionalProperties: false
  61029. }],
  61030. messages: {
  61031. missing: "A space is required {{loc}} ','.",
  61032. unexpected: "There should be no space {{loc}} ','."
  61033. }
  61034. },
  61035. create: function create(context) {
  61036. var sourceCode = context.getSourceCode();
  61037. var tokensAndComments = sourceCode.tokensAndComments;
  61038. var options = {
  61039. before: context.options[0] ? !!context.options[0].before : false,
  61040. after: context.options[0] ? !!context.options[0].after : true
  61041. };
  61042. //--------------------------------------------------------------------------
  61043. // Helpers
  61044. //--------------------------------------------------------------------------
  61045. // list of comma tokens to ignore for the check of leading whitespace
  61046. var commaTokensToIgnore = [];
  61047. /**
  61048. * Reports a spacing error with an appropriate message.
  61049. * @param {ASTNode} node The binary expression node to report.
  61050. * @param {string} loc Is the error "before" or "after" the comma?
  61051. * @param {ASTNode} otherNode The node at the left or right of `node`
  61052. * @returns {void}
  61053. * @private
  61054. */
  61055. function report(node, loc, otherNode) {
  61056. context.report({
  61057. node: node,
  61058. fix: function fix(fixer) {
  61059. if (options[loc]) {
  61060. if (loc === "before") {
  61061. return fixer.insertTextBefore(node, " ");
  61062. }
  61063. return fixer.insertTextAfter(node, " ");
  61064. }
  61065. var start = void 0,
  61066. end = void 0;
  61067. var newText = "";
  61068. if (loc === "before") {
  61069. start = otherNode.range[1];
  61070. end = node.range[0];
  61071. } else {
  61072. start = node.range[1];
  61073. end = otherNode.range[0];
  61074. }
  61075. return fixer.replaceTextRange([start, end], newText);
  61076. },
  61077. messageId: options[loc] ? "missing" : "unexpected",
  61078. data: {
  61079. loc: loc
  61080. }
  61081. });
  61082. }
  61083. /**
  61084. * Validates the spacing around a comma token.
  61085. * @param {Object} tokens - The tokens to be validated.
  61086. * @param {Token} tokens.comma The token representing the comma.
  61087. * @param {Token} [tokens.left] The last token before the comma.
  61088. * @param {Token} [tokens.right] The first token after the comma.
  61089. * @param {Token|ASTNode} reportItem The item to use when reporting an error.
  61090. * @returns {void}
  61091. * @private
  61092. */
  61093. function validateCommaItemSpacing(tokens, reportItem) {
  61094. if (tokens.left && astUtils.isTokenOnSameLine(tokens.left, tokens.comma) && options.before !== sourceCode.isSpaceBetweenTokens(tokens.left, tokens.comma)) {
  61095. report(reportItem, "before", tokens.left);
  61096. }
  61097. if (tokens.right && !options.after && tokens.right.type === "Line") {
  61098. return;
  61099. }
  61100. if (tokens.right && astUtils.isTokenOnSameLine(tokens.comma, tokens.right) && options.after !== sourceCode.isSpaceBetweenTokens(tokens.comma, tokens.right)) {
  61101. report(reportItem, "after", tokens.right);
  61102. }
  61103. }
  61104. /**
  61105. * Adds null elements of the given ArrayExpression or ArrayPattern node to the ignore list.
  61106. * @param {ASTNode} node An ArrayExpression or ArrayPattern node.
  61107. * @returns {void}
  61108. */
  61109. function addNullElementsToIgnoreList(node) {
  61110. var previousToken = sourceCode.getFirstToken(node);
  61111. node.elements.forEach(function (element) {
  61112. var token = void 0;
  61113. if (element === null) {
  61114. token = sourceCode.getTokenAfter(previousToken);
  61115. if (astUtils.isCommaToken(token)) {
  61116. commaTokensToIgnore.push(token);
  61117. }
  61118. } else {
  61119. token = sourceCode.getTokenAfter(element);
  61120. }
  61121. previousToken = token;
  61122. });
  61123. }
  61124. //--------------------------------------------------------------------------
  61125. // Public
  61126. //--------------------------------------------------------------------------
  61127. return {
  61128. "Program:exit": function ProgramExit() {
  61129. tokensAndComments.forEach(function (token, i) {
  61130. if (!astUtils.isCommaToken(token)) {
  61131. return;
  61132. }
  61133. if (token && token.type === "JSXText") {
  61134. return;
  61135. }
  61136. var previousToken = tokensAndComments[i - 1];
  61137. var nextToken = tokensAndComments[i + 1];
  61138. validateCommaItemSpacing({
  61139. comma: token,
  61140. left: astUtils.isCommaToken(previousToken) || commaTokensToIgnore.indexOf(token) > -1 ? null : previousToken,
  61141. right: astUtils.isCommaToken(nextToken) ? null : nextToken
  61142. }, token);
  61143. });
  61144. },
  61145. ArrayExpression: addNullElementsToIgnoreList,
  61146. ArrayPattern: addNullElementsToIgnoreList
  61147. };
  61148. }
  61149. };
  61150. },{"../util/ast-utils":405}],142:[function(require,module,exports){
  61151. /**
  61152. * @fileoverview Comma style - enforces comma styles of two types: last and first
  61153. * @author Vignesh Anand aka vegetableman
  61154. */
  61155. "use strict";
  61156. var astUtils = require("../util/ast-utils");
  61157. //------------------------------------------------------------------------------
  61158. // Rule Definition
  61159. //------------------------------------------------------------------------------
  61160. module.exports = {
  61161. meta: {
  61162. type: "layout",
  61163. docs: {
  61164. description: "enforce consistent comma style",
  61165. category: "Stylistic Issues",
  61166. recommended: false,
  61167. url: "https://eslint.org/docs/rules/comma-style"
  61168. },
  61169. fixable: "code",
  61170. schema: [{
  61171. enum: ["first", "last"]
  61172. }, {
  61173. type: "object",
  61174. properties: {
  61175. exceptions: {
  61176. type: "object",
  61177. additionalProperties: {
  61178. type: "boolean"
  61179. }
  61180. }
  61181. },
  61182. additionalProperties: false
  61183. }],
  61184. messages: {
  61185. unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.",
  61186. expectedCommaFirst: "',' should be placed first.",
  61187. expectedCommaLast: "',' should be placed last."
  61188. }
  61189. },
  61190. create: function create(context) {
  61191. var style = context.options[0] || "last",
  61192. sourceCode = context.getSourceCode();
  61193. var exceptions = {
  61194. ArrayPattern: true,
  61195. ArrowFunctionExpression: true,
  61196. CallExpression: true,
  61197. FunctionDeclaration: true,
  61198. FunctionExpression: true,
  61199. ImportDeclaration: true,
  61200. ObjectPattern: true,
  61201. NewExpression: true
  61202. };
  61203. if (context.options.length === 2 && Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
  61204. var keys = Object.keys(context.options[1].exceptions);
  61205. for (var i = 0; i < keys.length; i++) {
  61206. exceptions[keys[i]] = context.options[1].exceptions[keys[i]];
  61207. }
  61208. }
  61209. //--------------------------------------------------------------------------
  61210. // Helpers
  61211. //--------------------------------------------------------------------------
  61212. /**
  61213. * Modified text based on the style
  61214. * @param {string} styleType Style type
  61215. * @param {string} text Source code text
  61216. * @returns {string} modified text
  61217. * @private
  61218. */
  61219. function getReplacedText(styleType, text) {
  61220. switch (styleType) {
  61221. case "between":
  61222. return "," + text.replace(astUtils.LINEBREAK_MATCHER, "");
  61223. case "first":
  61224. return text + ",";
  61225. case "last":
  61226. return "," + text;
  61227. default:
  61228. return "";
  61229. }
  61230. }
  61231. /**
  61232. * Determines the fixer function for a given style.
  61233. * @param {string} styleType comma style
  61234. * @param {ASTNode} previousItemToken The token to check.
  61235. * @param {ASTNode} commaToken The token to check.
  61236. * @param {ASTNode} currentItemToken The token to check.
  61237. * @returns {Function} Fixer function
  61238. * @private
  61239. */
  61240. function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) {
  61241. var text = sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) + sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]);
  61242. var range = [previousItemToken.range[1], currentItemToken.range[0]];
  61243. return function (fixer) {
  61244. return fixer.replaceTextRange(range, getReplacedText(styleType, text));
  61245. };
  61246. }
  61247. /**
  61248. * Validates the spacing around single items in lists.
  61249. * @param {Token} previousItemToken The last token from the previous item.
  61250. * @param {Token} commaToken The token representing the comma.
  61251. * @param {Token} currentItemToken The first token of the current item.
  61252. * @param {Token} reportItem The item to use when reporting an error.
  61253. * @returns {void}
  61254. * @private
  61255. */
  61256. function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) {
  61257. // if single line
  61258. if (astUtils.isTokenOnSameLine(commaToken, currentItemToken) && astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
  61259. // do nothing.
  61260. } else if (!astUtils.isTokenOnSameLine(commaToken, currentItemToken) && !astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
  61261. var comment = sourceCode.getCommentsAfter(commaToken)[0];
  61262. var styleType = comment && comment.type === "Block" && astUtils.isTokenOnSameLine(commaToken, comment) ? style : "between";
  61263. // lone comma
  61264. context.report({
  61265. node: reportItem,
  61266. loc: {
  61267. line: commaToken.loc.end.line,
  61268. column: commaToken.loc.start.column
  61269. },
  61270. messageId: "unexpectedLineBeforeAndAfterComma",
  61271. fix: getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken)
  61272. });
  61273. } else if (style === "first" && !astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
  61274. context.report({
  61275. node: reportItem,
  61276. messageId: "expectedCommaFirst",
  61277. fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
  61278. });
  61279. } else if (style === "last" && astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
  61280. context.report({
  61281. node: reportItem,
  61282. loc: {
  61283. line: commaToken.loc.end.line,
  61284. column: commaToken.loc.end.column
  61285. },
  61286. messageId: "expectedCommaLast",
  61287. fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
  61288. });
  61289. }
  61290. }
  61291. /**
  61292. * Checks the comma placement with regards to a declaration/property/element
  61293. * @param {ASTNode} node The binary expression node to check
  61294. * @param {string} property The property of the node containing child nodes.
  61295. * @private
  61296. * @returns {void}
  61297. */
  61298. function validateComma(node, property) {
  61299. var items = node[property],
  61300. arrayLiteral = node.type === "ArrayExpression" || node.type === "ArrayPattern";
  61301. if (items.length > 1 || arrayLiteral) {
  61302. // seed as opening [
  61303. var previousItemToken = sourceCode.getFirstToken(node);
  61304. items.forEach(function (item) {
  61305. var commaToken = item ? sourceCode.getTokenBefore(item) : previousItemToken,
  61306. currentItemToken = item ? sourceCode.getFirstToken(item) : sourceCode.getTokenAfter(commaToken),
  61307. reportItem = item || currentItemToken;
  61308. /*
  61309. * This works by comparing three token locations:
  61310. * - previousItemToken is the last token of the previous item
  61311. * - commaToken is the location of the comma before the current item
  61312. * - currentItemToken is the first token of the current item
  61313. *
  61314. * These values get switched around if item is undefined.
  61315. * previousItemToken will refer to the last token not belonging
  61316. * to the current item, which could be a comma or an opening
  61317. * square bracket. currentItemToken could be a comma.
  61318. *
  61319. * All comparisons are done based on these tokens directly, so
  61320. * they are always valid regardless of an undefined item.
  61321. */
  61322. if (astUtils.isCommaToken(commaToken)) {
  61323. validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem);
  61324. }
  61325. if (item) {
  61326. var tokenAfterItem = sourceCode.getTokenAfter(item, astUtils.isNotClosingParenToken);
  61327. previousItemToken = tokenAfterItem ? sourceCode.getTokenBefore(tokenAfterItem) : sourceCode.ast.tokens[sourceCode.ast.tokens.length - 1];
  61328. }
  61329. });
  61330. /*
  61331. * Special case for array literals that have empty last items, such
  61332. * as [ 1, 2, ]. These arrays only have two items show up in the
  61333. * AST, so we need to look at the token to verify that there's no
  61334. * dangling comma.
  61335. */
  61336. if (arrayLiteral) {
  61337. var lastToken = sourceCode.getLastToken(node),
  61338. nextToLastToken = sourceCode.getTokenBefore(lastToken);
  61339. if (astUtils.isCommaToken(nextToLastToken)) {
  61340. validateCommaItemSpacing(sourceCode.getTokenBefore(nextToLastToken), nextToLastToken, lastToken, lastToken);
  61341. }
  61342. }
  61343. }
  61344. }
  61345. //--------------------------------------------------------------------------
  61346. // Public
  61347. //--------------------------------------------------------------------------
  61348. var nodes = {};
  61349. if (!exceptions.VariableDeclaration) {
  61350. nodes.VariableDeclaration = function (node) {
  61351. validateComma(node, "declarations");
  61352. };
  61353. }
  61354. if (!exceptions.ObjectExpression) {
  61355. nodes.ObjectExpression = function (node) {
  61356. validateComma(node, "properties");
  61357. };
  61358. }
  61359. if (!exceptions.ObjectPattern) {
  61360. nodes.ObjectPattern = function (node) {
  61361. validateComma(node, "properties");
  61362. };
  61363. }
  61364. if (!exceptions.ArrayExpression) {
  61365. nodes.ArrayExpression = function (node) {
  61366. validateComma(node, "elements");
  61367. };
  61368. }
  61369. if (!exceptions.ArrayPattern) {
  61370. nodes.ArrayPattern = function (node) {
  61371. validateComma(node, "elements");
  61372. };
  61373. }
  61374. if (!exceptions.FunctionDeclaration) {
  61375. nodes.FunctionDeclaration = function (node) {
  61376. validateComma(node, "params");
  61377. };
  61378. }
  61379. if (!exceptions.FunctionExpression) {
  61380. nodes.FunctionExpression = function (node) {
  61381. validateComma(node, "params");
  61382. };
  61383. }
  61384. if (!exceptions.ArrowFunctionExpression) {
  61385. nodes.ArrowFunctionExpression = function (node) {
  61386. validateComma(node, "params");
  61387. };
  61388. }
  61389. if (!exceptions.CallExpression) {
  61390. nodes.CallExpression = function (node) {
  61391. validateComma(node, "arguments");
  61392. };
  61393. }
  61394. if (!exceptions.ImportDeclaration) {
  61395. nodes.ImportDeclaration = function (node) {
  61396. validateComma(node, "specifiers");
  61397. };
  61398. }
  61399. if (!exceptions.NewExpression) {
  61400. nodes.NewExpression = function (node) {
  61401. validateComma(node, "arguments");
  61402. };
  61403. }
  61404. return nodes;
  61405. }
  61406. };
  61407. },{"../util/ast-utils":405}],143:[function(require,module,exports){
  61408. /**
  61409. * @fileoverview Counts the cyclomatic complexity of each function of the script. See http://en.wikipedia.org/wiki/Cyclomatic_complexity.
  61410. * Counts the number of if, conditional, for, whilte, try, switch/case,
  61411. * @author Patrick Brosset
  61412. */
  61413. "use strict";
  61414. //------------------------------------------------------------------------------
  61415. // Requirements
  61416. //------------------------------------------------------------------------------
  61417. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  61418. var lodash = require("lodash");
  61419. var astUtils = require("../util/ast-utils");
  61420. //------------------------------------------------------------------------------
  61421. // Rule Definition
  61422. //------------------------------------------------------------------------------
  61423. module.exports = {
  61424. meta: {
  61425. type: "suggestion",
  61426. docs: {
  61427. description: "enforce a maximum cyclomatic complexity allowed in a program",
  61428. category: "Best Practices",
  61429. recommended: false,
  61430. url: "https://eslint.org/docs/rules/complexity"
  61431. },
  61432. schema: [{
  61433. oneOf: [{
  61434. type: "integer",
  61435. minimum: 0
  61436. }, {
  61437. type: "object",
  61438. properties: {
  61439. maximum: {
  61440. type: "integer",
  61441. minimum: 0
  61442. },
  61443. max: {
  61444. type: "integer",
  61445. minimum: 0
  61446. }
  61447. },
  61448. additionalProperties: false
  61449. }]
  61450. }],
  61451. messages: {
  61452. complex: "{{name}} has a complexity of {{complexity}}."
  61453. }
  61454. },
  61455. create: function create(context) {
  61456. var option = context.options[0];
  61457. var THRESHOLD = 20;
  61458. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
  61459. THRESHOLD = option.maximum;
  61460. }
  61461. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
  61462. THRESHOLD = option.max;
  61463. }
  61464. if (typeof option === "number") {
  61465. THRESHOLD = option;
  61466. }
  61467. //--------------------------------------------------------------------------
  61468. // Helpers
  61469. //--------------------------------------------------------------------------
  61470. // Using a stack to store complexity (handling nested functions)
  61471. var fns = [];
  61472. /**
  61473. * When parsing a new function, store it in our function stack
  61474. * @returns {void}
  61475. * @private
  61476. */
  61477. function startFunction() {
  61478. fns.push(1);
  61479. }
  61480. /**
  61481. * Evaluate the node at the end of function
  61482. * @param {ASTNode} node node to evaluate
  61483. * @returns {void}
  61484. * @private
  61485. */
  61486. function endFunction(node) {
  61487. var name = lodash.upperFirst(astUtils.getFunctionNameWithKind(node));
  61488. var complexity = fns.pop();
  61489. if (complexity > THRESHOLD) {
  61490. context.report({
  61491. node: node,
  61492. messageId: "complex",
  61493. data: { name: name, complexity: complexity }
  61494. });
  61495. }
  61496. }
  61497. /**
  61498. * Increase the complexity of the function in context
  61499. * @returns {void}
  61500. * @private
  61501. */
  61502. function increaseComplexity() {
  61503. if (fns.length) {
  61504. fns[fns.length - 1]++;
  61505. }
  61506. }
  61507. /**
  61508. * Increase the switch complexity in context
  61509. * @param {ASTNode} node node to evaluate
  61510. * @returns {void}
  61511. * @private
  61512. */
  61513. function increaseSwitchComplexity(node) {
  61514. // Avoiding `default`
  61515. if (node.test) {
  61516. increaseComplexity();
  61517. }
  61518. }
  61519. //--------------------------------------------------------------------------
  61520. // Public API
  61521. //--------------------------------------------------------------------------
  61522. return {
  61523. FunctionDeclaration: startFunction,
  61524. FunctionExpression: startFunction,
  61525. ArrowFunctionExpression: startFunction,
  61526. "FunctionDeclaration:exit": endFunction,
  61527. "FunctionExpression:exit": endFunction,
  61528. "ArrowFunctionExpression:exit": endFunction,
  61529. CatchClause: increaseComplexity,
  61530. ConditionalExpression: increaseComplexity,
  61531. LogicalExpression: increaseComplexity,
  61532. ForStatement: increaseComplexity,
  61533. ForInStatement: increaseComplexity,
  61534. ForOfStatement: increaseComplexity,
  61535. IfStatement: increaseComplexity,
  61536. SwitchCase: increaseSwitchComplexity,
  61537. WhileStatement: increaseComplexity,
  61538. DoWhileStatement: increaseComplexity
  61539. };
  61540. }
  61541. };
  61542. },{"../util/ast-utils":405,"lodash":92}],144:[function(require,module,exports){
  61543. /**
  61544. * @fileoverview Disallows or enforces spaces inside computed properties.
  61545. * @author Jamund Ferguson
  61546. */
  61547. "use strict";
  61548. var astUtils = require("../util/ast-utils");
  61549. //------------------------------------------------------------------------------
  61550. // Rule Definition
  61551. //------------------------------------------------------------------------------
  61552. module.exports = {
  61553. meta: {
  61554. type: "layout",
  61555. docs: {
  61556. description: "enforce consistent spacing inside computed property brackets",
  61557. category: "Stylistic Issues",
  61558. recommended: false,
  61559. url: "https://eslint.org/docs/rules/computed-property-spacing"
  61560. },
  61561. fixable: "whitespace",
  61562. schema: [{
  61563. enum: ["always", "never"]
  61564. }],
  61565. messages: {
  61566. unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
  61567. unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
  61568. missingSpaceBefore: "A space is required before '{{tokenValue}}'.",
  61569. missingSpaceAfter: "A space is required after '{{tokenValue}}'."
  61570. }
  61571. },
  61572. create: function create(context) {
  61573. var sourceCode = context.getSourceCode();
  61574. var propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never"
  61575. //--------------------------------------------------------------------------
  61576. // Helpers
  61577. //--------------------------------------------------------------------------
  61578. /**
  61579. * Reports that there shouldn't be a space after the first token
  61580. * @param {ASTNode} node - The node to report in the event of an error.
  61581. * @param {Token} token - The token to use for the report.
  61582. * @param {Token} tokenAfter - The token after `token`.
  61583. * @returns {void}
  61584. */
  61585. function reportNoBeginningSpace(node, token, tokenAfter) {
  61586. context.report({
  61587. node: node,
  61588. loc: token.loc.start,
  61589. messageId: "unexpectedSpaceAfter",
  61590. data: {
  61591. tokenValue: token.value
  61592. },
  61593. fix: function fix(fixer) {
  61594. return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
  61595. }
  61596. });
  61597. }
  61598. /**
  61599. * Reports that there shouldn't be a space before the last token
  61600. * @param {ASTNode} node - The node to report in the event of an error.
  61601. * @param {Token} token - The token to use for the report.
  61602. * @param {Token} tokenBefore - The token before `token`.
  61603. * @returns {void}
  61604. */
  61605. function reportNoEndingSpace(node, token, tokenBefore) {
  61606. context.report({
  61607. node: node,
  61608. loc: token.loc.start,
  61609. messageId: "unexpectedSpaceBefore",
  61610. data: {
  61611. tokenValue: token.value
  61612. },
  61613. fix: function fix(fixer) {
  61614. return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
  61615. }
  61616. });
  61617. }
  61618. /**
  61619. * Reports that there should be a space after the first token
  61620. * @param {ASTNode} node - The node to report in the event of an error.
  61621. * @param {Token} token - The token to use for the report.
  61622. * @returns {void}
  61623. */
  61624. function reportRequiredBeginningSpace(node, token) {
  61625. context.report({
  61626. node: node,
  61627. loc: token.loc.start,
  61628. messageId: "missingSpaceAfter",
  61629. data: {
  61630. tokenValue: token.value
  61631. },
  61632. fix: function fix(fixer) {
  61633. return fixer.insertTextAfter(token, " ");
  61634. }
  61635. });
  61636. }
  61637. /**
  61638. * Reports that there should be a space before the last token
  61639. * @param {ASTNode} node - The node to report in the event of an error.
  61640. * @param {Token} token - The token to use for the report.
  61641. * @returns {void}
  61642. */
  61643. function reportRequiredEndingSpace(node, token) {
  61644. context.report({
  61645. node: node,
  61646. loc: token.loc.start,
  61647. messageId: "missingSpaceBefore",
  61648. data: {
  61649. tokenValue: token.value
  61650. },
  61651. fix: function fix(fixer) {
  61652. return fixer.insertTextBefore(token, " ");
  61653. }
  61654. });
  61655. }
  61656. /**
  61657. * Returns a function that checks the spacing of a node on the property name
  61658. * that was passed in.
  61659. * @param {string} propertyName The property on the node to check for spacing
  61660. * @returns {Function} A function that will check spacing on a node
  61661. */
  61662. function checkSpacing(propertyName) {
  61663. return function (node) {
  61664. if (!node.computed) {
  61665. return;
  61666. }
  61667. var property = node[propertyName];
  61668. var before = sourceCode.getTokenBefore(property),
  61669. first = sourceCode.getFirstToken(property),
  61670. last = sourceCode.getLastToken(property),
  61671. after = sourceCode.getTokenAfter(property);
  61672. if (astUtils.isTokenOnSameLine(before, first)) {
  61673. if (propertyNameMustBeSpaced) {
  61674. if (!sourceCode.isSpaceBetweenTokens(before, first) && astUtils.isTokenOnSameLine(before, first)) {
  61675. reportRequiredBeginningSpace(node, before);
  61676. }
  61677. } else {
  61678. if (sourceCode.isSpaceBetweenTokens(before, first)) {
  61679. reportNoBeginningSpace(node, before, first);
  61680. }
  61681. }
  61682. }
  61683. if (astUtils.isTokenOnSameLine(last, after)) {
  61684. if (propertyNameMustBeSpaced) {
  61685. if (!sourceCode.isSpaceBetweenTokens(last, after) && astUtils.isTokenOnSameLine(last, after)) {
  61686. reportRequiredEndingSpace(node, after);
  61687. }
  61688. } else {
  61689. if (sourceCode.isSpaceBetweenTokens(last, after)) {
  61690. reportNoEndingSpace(node, after, last);
  61691. }
  61692. }
  61693. }
  61694. };
  61695. }
  61696. //--------------------------------------------------------------------------
  61697. // Public
  61698. //--------------------------------------------------------------------------
  61699. return {
  61700. Property: checkSpacing("key"),
  61701. MemberExpression: checkSpacing("property")
  61702. };
  61703. }
  61704. };
  61705. },{"../util/ast-utils":405}],145:[function(require,module,exports){
  61706. /**
  61707. * @fileoverview Rule to flag consistent return values
  61708. * @author Nicholas C. Zakas
  61709. */
  61710. "use strict";
  61711. //------------------------------------------------------------------------------
  61712. // Requirements
  61713. //------------------------------------------------------------------------------
  61714. var lodash = require("lodash");
  61715. var astUtils = require("../util/ast-utils");
  61716. //------------------------------------------------------------------------------
  61717. // Helpers
  61718. //------------------------------------------------------------------------------
  61719. /**
  61720. * Checks whether or not a given node is an `Identifier` node which was named a given name.
  61721. * @param {ASTNode} node - A node to check.
  61722. * @param {string} name - An expected name of the node.
  61723. * @returns {boolean} `true` if the node is an `Identifier` node which was named as expected.
  61724. */
  61725. function isIdentifier(node, name) {
  61726. return node.type === "Identifier" && node.name === name;
  61727. }
  61728. /**
  61729. * Checks whether or not a given code path segment is unreachable.
  61730. * @param {CodePathSegment} segment - A CodePathSegment to check.
  61731. * @returns {boolean} `true` if the segment is unreachable.
  61732. */
  61733. function isUnreachable(segment) {
  61734. return !segment.reachable;
  61735. }
  61736. /**
  61737. * Checks whether a given node is a `constructor` method in an ES6 class
  61738. * @param {ASTNode} node A node to check
  61739. * @returns {boolean} `true` if the node is a `constructor` method
  61740. */
  61741. function isClassConstructor(node) {
  61742. return node.type === "FunctionExpression" && node.parent && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
  61743. }
  61744. //------------------------------------------------------------------------------
  61745. // Rule Definition
  61746. //------------------------------------------------------------------------------
  61747. module.exports = {
  61748. meta: {
  61749. type: "suggestion",
  61750. docs: {
  61751. description: "require `return` statements to either always or never specify values",
  61752. category: "Best Practices",
  61753. recommended: false,
  61754. url: "https://eslint.org/docs/rules/consistent-return"
  61755. },
  61756. schema: [{
  61757. type: "object",
  61758. properties: {
  61759. treatUndefinedAsUnspecified: {
  61760. type: "boolean"
  61761. }
  61762. },
  61763. additionalProperties: false
  61764. }],
  61765. messages: {
  61766. missingReturn: "Expected to return a value at the end of {{name}}.",
  61767. missingReturnValue: "{{name}} expected a return value.",
  61768. unexpectedReturnValue: "{{name}} expected no return value."
  61769. }
  61770. },
  61771. create: function create(context) {
  61772. var options = context.options[0] || {};
  61773. var treatUndefinedAsUnspecified = options.treatUndefinedAsUnspecified === true;
  61774. var funcInfo = null;
  61775. /**
  61776. * Checks whether of not the implicit returning is consistent if the last
  61777. * code path segment is reachable.
  61778. *
  61779. * @param {ASTNode} node - A program/function node to check.
  61780. * @returns {void}
  61781. */
  61782. function checkLastSegment(node) {
  61783. var loc = void 0,
  61784. name = void 0;
  61785. /*
  61786. * Skip if it expected no return value or unreachable.
  61787. * When unreachable, all paths are returned or thrown.
  61788. */
  61789. if (!funcInfo.hasReturnValue || funcInfo.codePath.currentSegments.every(isUnreachable) || astUtils.isES5Constructor(node) || isClassConstructor(node)) {
  61790. return;
  61791. }
  61792. // Adjust a location and a message.
  61793. if (node.type === "Program") {
  61794. // The head of program.
  61795. loc = { line: 1, column: 0 };
  61796. name = "program";
  61797. } else if (node.type === "ArrowFunctionExpression") {
  61798. // `=>` token
  61799. loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
  61800. } else if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method) {
  61801. // Method name.
  61802. loc = node.parent.key.loc.start;
  61803. } else {
  61804. // Function name or `function` keyword.
  61805. loc = (node.id || node).loc.start;
  61806. }
  61807. if (!name) {
  61808. name = astUtils.getFunctionNameWithKind(node);
  61809. }
  61810. // Reports.
  61811. context.report({
  61812. node: node,
  61813. loc: loc,
  61814. messageId: "missingReturn",
  61815. data: { name: name }
  61816. });
  61817. }
  61818. return {
  61819. // Initializes/Disposes state of each code path.
  61820. onCodePathStart: function onCodePathStart(codePath, node) {
  61821. funcInfo = {
  61822. upper: funcInfo,
  61823. codePath: codePath,
  61824. hasReturn: false,
  61825. hasReturnValue: false,
  61826. messageId: "",
  61827. node: node
  61828. };
  61829. },
  61830. onCodePathEnd: function onCodePathEnd() {
  61831. funcInfo = funcInfo.upper;
  61832. },
  61833. // Reports a given return statement if it's inconsistent.
  61834. ReturnStatement: function ReturnStatement(node) {
  61835. var argument = node.argument;
  61836. var hasReturnValue = Boolean(argument);
  61837. if (treatUndefinedAsUnspecified && hasReturnValue) {
  61838. hasReturnValue = !isIdentifier(argument, "undefined") && argument.operator !== "void";
  61839. }
  61840. if (!funcInfo.hasReturn) {
  61841. funcInfo.hasReturn = true;
  61842. funcInfo.hasReturnValue = hasReturnValue;
  61843. funcInfo.messageId = hasReturnValue ? "missingReturnValue" : "unexpectedReturnValue";
  61844. funcInfo.data = {
  61845. name: funcInfo.node.type === "Program" ? "Program" : lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
  61846. };
  61847. } else if (funcInfo.hasReturnValue !== hasReturnValue) {
  61848. context.report({
  61849. node: node,
  61850. messageId: funcInfo.messageId,
  61851. data: funcInfo.data
  61852. });
  61853. }
  61854. },
  61855. // Reports a given program/function if the implicit returning is not consistent.
  61856. "Program:exit": checkLastSegment,
  61857. "FunctionDeclaration:exit": checkLastSegment,
  61858. "FunctionExpression:exit": checkLastSegment,
  61859. "ArrowFunctionExpression:exit": checkLastSegment
  61860. };
  61861. }
  61862. };
  61863. },{"../util/ast-utils":405,"lodash":92}],146:[function(require,module,exports){
  61864. /**
  61865. * @fileoverview Rule to enforce consistent naming of "this" context variables
  61866. * @author Raphael Pigulla
  61867. */
  61868. "use strict";
  61869. //------------------------------------------------------------------------------
  61870. // Rule Definition
  61871. //------------------------------------------------------------------------------
  61872. module.exports = {
  61873. meta: {
  61874. type: "suggestion",
  61875. docs: {
  61876. description: "enforce consistent naming when capturing the current execution context",
  61877. category: "Stylistic Issues",
  61878. recommended: false,
  61879. url: "https://eslint.org/docs/rules/consistent-this"
  61880. },
  61881. schema: {
  61882. type: "array",
  61883. items: {
  61884. type: "string",
  61885. minLength: 1
  61886. },
  61887. uniqueItems: true
  61888. },
  61889. messages: {
  61890. aliasNotAssignedToThis: "Designated alias '{{name}}' is not assigned to 'this'.",
  61891. unexpectedAlias: "Unexpected alias '{{name}}' for 'this'."
  61892. }
  61893. },
  61894. create: function create(context) {
  61895. var aliases = [];
  61896. if (context.options.length === 0) {
  61897. aliases.push("that");
  61898. } else {
  61899. aliases = context.options;
  61900. }
  61901. /**
  61902. * Reports that a variable declarator or assignment expression is assigning
  61903. * a non-'this' value to the specified alias.
  61904. * @param {ASTNode} node - The assigning node.
  61905. * @param {string} name - the name of the alias that was incorrectly used.
  61906. * @returns {void}
  61907. */
  61908. function reportBadAssignment(node, name) {
  61909. context.report({ node: node, messageId: "aliasNotAssignedToThis", data: { name: name } });
  61910. }
  61911. /**
  61912. * Checks that an assignment to an identifier only assigns 'this' to the
  61913. * appropriate alias, and the alias is only assigned to 'this'.
  61914. * @param {ASTNode} node - The assigning node.
  61915. * @param {Identifier} name - The name of the variable assigned to.
  61916. * @param {Expression} value - The value of the assignment.
  61917. * @returns {void}
  61918. */
  61919. function checkAssignment(node, name, value) {
  61920. var isThis = value.type === "ThisExpression";
  61921. if (aliases.indexOf(name) !== -1) {
  61922. if (!isThis || node.operator && node.operator !== "=") {
  61923. reportBadAssignment(node, name);
  61924. }
  61925. } else if (isThis) {
  61926. context.report({ node: node, messageId: "unexpectedAlias", data: { name: name } });
  61927. }
  61928. }
  61929. /**
  61930. * Ensures that a variable declaration of the alias in a program or function
  61931. * is assigned to the correct value.
  61932. * @param {string} alias alias the check the assignment of.
  61933. * @param {Object} scope scope of the current code we are checking.
  61934. * @private
  61935. * @returns {void}
  61936. */
  61937. function checkWasAssigned(alias, scope) {
  61938. var variable = scope.set.get(alias);
  61939. if (!variable) {
  61940. return;
  61941. }
  61942. if (variable.defs.some(function (def) {
  61943. return def.node.type === "VariableDeclarator" && def.node.init !== null;
  61944. })) {
  61945. return;
  61946. }
  61947. /*
  61948. * The alias has been declared and not assigned: check it was
  61949. * assigned later in the same scope.
  61950. */
  61951. if (!variable.references.some(function (reference) {
  61952. var write = reference.writeExpr;
  61953. return reference.from === scope && write && write.type === "ThisExpression" && write.parent.operator === "=";
  61954. })) {
  61955. variable.defs.map(function (def) {
  61956. return def.node;
  61957. }).forEach(function (node) {
  61958. reportBadAssignment(node, alias);
  61959. });
  61960. }
  61961. }
  61962. /**
  61963. * Check each alias to ensure that is was assinged to the correct value.
  61964. * @returns {void}
  61965. */
  61966. function ensureWasAssigned() {
  61967. var scope = context.getScope();
  61968. aliases.forEach(function (alias) {
  61969. checkWasAssigned(alias, scope);
  61970. });
  61971. }
  61972. return {
  61973. "Program:exit": ensureWasAssigned,
  61974. "FunctionExpression:exit": ensureWasAssigned,
  61975. "FunctionDeclaration:exit": ensureWasAssigned,
  61976. VariableDeclarator: function VariableDeclarator(node) {
  61977. var id = node.id;
  61978. var isDestructuring = id.type === "ArrayPattern" || id.type === "ObjectPattern";
  61979. if (node.init !== null && !isDestructuring) {
  61980. checkAssignment(node, id.name, node.init);
  61981. }
  61982. },
  61983. AssignmentExpression: function AssignmentExpression(node) {
  61984. if (node.left.type === "Identifier") {
  61985. checkAssignment(node, node.left.name, node.right);
  61986. }
  61987. }
  61988. };
  61989. }
  61990. };
  61991. },{}],147:[function(require,module,exports){
  61992. /**
  61993. * @fileoverview A rule to verify `super()` callings in constructor.
  61994. * @author Toru Nagashima
  61995. */
  61996. "use strict";
  61997. //------------------------------------------------------------------------------
  61998. // Helpers
  61999. //------------------------------------------------------------------------------
  62000. /**
  62001. * Checks whether a given code path segment is reachable or not.
  62002. *
  62003. * @param {CodePathSegment} segment - A code path segment to check.
  62004. * @returns {boolean} `true` if the segment is reachable.
  62005. */
  62006. function isReachable(segment) {
  62007. return segment.reachable;
  62008. }
  62009. /**
  62010. * Checks whether or not a given node is a constructor.
  62011. * @param {ASTNode} node - A node to check. This node type is one of
  62012. * `Program`, `FunctionDeclaration`, `FunctionExpression`, and
  62013. * `ArrowFunctionExpression`.
  62014. * @returns {boolean} `true` if the node is a constructor.
  62015. */
  62016. function isConstructorFunction(node) {
  62017. return node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
  62018. }
  62019. /**
  62020. * Checks whether a given node can be a constructor or not.
  62021. *
  62022. * @param {ASTNode} node - A node to check.
  62023. * @returns {boolean} `true` if the node can be a constructor.
  62024. */
  62025. function isPossibleConstructor(node) {
  62026. if (!node) {
  62027. return false;
  62028. }
  62029. switch (node.type) {
  62030. case "ClassExpression":
  62031. case "FunctionExpression":
  62032. case "ThisExpression":
  62033. case "MemberExpression":
  62034. case "CallExpression":
  62035. case "NewExpression":
  62036. case "YieldExpression":
  62037. case "TaggedTemplateExpression":
  62038. case "MetaProperty":
  62039. return true;
  62040. case "Identifier":
  62041. return node.name !== "undefined";
  62042. case "AssignmentExpression":
  62043. return isPossibleConstructor(node.right);
  62044. case "LogicalExpression":
  62045. return isPossibleConstructor(node.left) || isPossibleConstructor(node.right);
  62046. case "ConditionalExpression":
  62047. return isPossibleConstructor(node.alternate) || isPossibleConstructor(node.consequent);
  62048. case "SequenceExpression":
  62049. {
  62050. var lastExpression = node.expressions[node.expressions.length - 1];
  62051. return isPossibleConstructor(lastExpression);
  62052. }
  62053. default:
  62054. return false;
  62055. }
  62056. }
  62057. //------------------------------------------------------------------------------
  62058. // Rule Definition
  62059. //------------------------------------------------------------------------------
  62060. module.exports = {
  62061. meta: {
  62062. type: "problem",
  62063. docs: {
  62064. description: "require `super()` calls in constructors",
  62065. category: "ECMAScript 6",
  62066. recommended: true,
  62067. url: "https://eslint.org/docs/rules/constructor-super"
  62068. },
  62069. schema: [],
  62070. messages: {
  62071. missingSome: "Lacked a call of 'super()' in some code paths.",
  62072. missingAll: "Expected to call 'super()'.",
  62073. duplicate: "Unexpected duplicate 'super()'.",
  62074. badSuper: "Unexpected 'super()' because 'super' is not a constructor.",
  62075. unexpected: "Unexpected 'super()'."
  62076. }
  62077. },
  62078. create: function create(context) {
  62079. /*
  62080. * {{hasExtends: boolean, scope: Scope, codePath: CodePath}[]}
  62081. * Information for each constructor.
  62082. * - upper: Information of the upper constructor.
  62083. * - hasExtends: A flag which shows whether own class has a valid `extends`
  62084. * part.
  62085. * - scope: The scope of own class.
  62086. * - codePath: The code path object of the constructor.
  62087. */
  62088. var funcInfo = null;
  62089. /*
  62090. * {Map<string, {calledInSomePaths: boolean, calledInEveryPaths: boolean}>}
  62091. * Information for each code path segment.
  62092. * - calledInSomePaths: A flag of be called `super()` in some code paths.
  62093. * - calledInEveryPaths: A flag of be called `super()` in all code paths.
  62094. * - validNodes:
  62095. */
  62096. var segInfoMap = Object.create(null);
  62097. /**
  62098. * Gets the flag which shows `super()` is called in some paths.
  62099. * @param {CodePathSegment} segment - A code path segment to get.
  62100. * @returns {boolean} The flag which shows `super()` is called in some paths
  62101. */
  62102. function isCalledInSomePath(segment) {
  62103. return segment.reachable && segInfoMap[segment.id].calledInSomePaths;
  62104. }
  62105. /**
  62106. * Gets the flag which shows `super()` is called in all paths.
  62107. * @param {CodePathSegment} segment - A code path segment to get.
  62108. * @returns {boolean} The flag which shows `super()` is called in all paths.
  62109. */
  62110. function isCalledInEveryPath(segment) {
  62111. /*
  62112. * If specific segment is the looped segment of the current segment,
  62113. * skip the segment.
  62114. * If not skipped, this never becomes true after a loop.
  62115. */
  62116. if (segment.nextSegments.length === 1 && segment.nextSegments[0].isLoopedPrevSegment(segment)) {
  62117. return true;
  62118. }
  62119. return segment.reachable && segInfoMap[segment.id].calledInEveryPaths;
  62120. }
  62121. return {
  62122. /**
  62123. * Stacks a constructor information.
  62124. * @param {CodePath} codePath - A code path which was started.
  62125. * @param {ASTNode} node - The current node.
  62126. * @returns {void}
  62127. */
  62128. onCodePathStart: function onCodePathStart(codePath, node) {
  62129. if (isConstructorFunction(node)) {
  62130. // Class > ClassBody > MethodDefinition > FunctionExpression
  62131. var classNode = node.parent.parent.parent;
  62132. var superClass = classNode.superClass;
  62133. funcInfo = {
  62134. upper: funcInfo,
  62135. isConstructor: true,
  62136. hasExtends: Boolean(superClass),
  62137. superIsConstructor: isPossibleConstructor(superClass),
  62138. codePath: codePath
  62139. };
  62140. } else {
  62141. funcInfo = {
  62142. upper: funcInfo,
  62143. isConstructor: false,
  62144. hasExtends: false,
  62145. superIsConstructor: false,
  62146. codePath: codePath
  62147. };
  62148. }
  62149. },
  62150. /**
  62151. * Pops a constructor information.
  62152. * And reports if `super()` lacked.
  62153. * @param {CodePath} codePath - A code path which was ended.
  62154. * @param {ASTNode} node - The current node.
  62155. * @returns {void}
  62156. */
  62157. onCodePathEnd: function onCodePathEnd(codePath, node) {
  62158. var hasExtends = funcInfo.hasExtends;
  62159. // Pop.
  62160. funcInfo = funcInfo.upper;
  62161. if (!hasExtends) {
  62162. return;
  62163. }
  62164. // Reports if `super()` lacked.
  62165. var segments = codePath.returnedSegments;
  62166. var calledInEveryPaths = segments.every(isCalledInEveryPath);
  62167. var calledInSomePaths = segments.some(isCalledInSomePath);
  62168. if (!calledInEveryPaths) {
  62169. context.report({
  62170. messageId: calledInSomePaths ? "missingSome" : "missingAll",
  62171. node: node.parent
  62172. });
  62173. }
  62174. },
  62175. /**
  62176. * Initialize information of a given code path segment.
  62177. * @param {CodePathSegment} segment - A code path segment to initialize.
  62178. * @returns {void}
  62179. */
  62180. onCodePathSegmentStart: function onCodePathSegmentStart(segment) {
  62181. if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
  62182. return;
  62183. }
  62184. // Initialize info.
  62185. var info = segInfoMap[segment.id] = {
  62186. calledInSomePaths: false,
  62187. calledInEveryPaths: false,
  62188. validNodes: []
  62189. };
  62190. // When there are previous segments, aggregates these.
  62191. var prevSegments = segment.prevSegments;
  62192. if (prevSegments.length > 0) {
  62193. info.calledInSomePaths = prevSegments.some(isCalledInSomePath);
  62194. info.calledInEveryPaths = prevSegments.every(isCalledInEveryPath);
  62195. }
  62196. },
  62197. /**
  62198. * Update information of the code path segment when a code path was
  62199. * looped.
  62200. * @param {CodePathSegment} fromSegment - The code path segment of the
  62201. * end of a loop.
  62202. * @param {CodePathSegment} toSegment - A code path segment of the head
  62203. * of a loop.
  62204. * @returns {void}
  62205. */
  62206. onCodePathSegmentLoop: function onCodePathSegmentLoop(fromSegment, toSegment) {
  62207. if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
  62208. return;
  62209. }
  62210. // Update information inside of the loop.
  62211. var isRealLoop = toSegment.prevSegments.length >= 2;
  62212. funcInfo.codePath.traverseSegments({ first: toSegment, last: fromSegment }, function (segment) {
  62213. var info = segInfoMap[segment.id];
  62214. var prevSegments = segment.prevSegments;
  62215. // Updates flags.
  62216. info.calledInSomePaths = prevSegments.some(isCalledInSomePath);
  62217. info.calledInEveryPaths = prevSegments.every(isCalledInEveryPath);
  62218. // If flags become true anew, reports the valid nodes.
  62219. if (info.calledInSomePaths || isRealLoop) {
  62220. var nodes = info.validNodes;
  62221. info.validNodes = [];
  62222. for (var i = 0; i < nodes.length; ++i) {
  62223. var node = nodes[i];
  62224. context.report({
  62225. messageId: "duplicate",
  62226. node: node
  62227. });
  62228. }
  62229. }
  62230. });
  62231. },
  62232. /**
  62233. * Checks for a call of `super()`.
  62234. * @param {ASTNode} node - A CallExpression node to check.
  62235. * @returns {void}
  62236. */
  62237. "CallExpression:exit": function CallExpressionExit(node) {
  62238. if (!(funcInfo && funcInfo.isConstructor)) {
  62239. return;
  62240. }
  62241. // Skips except `super()`.
  62242. if (node.callee.type !== "Super") {
  62243. return;
  62244. }
  62245. // Reports if needed.
  62246. if (funcInfo.hasExtends) {
  62247. var segments = funcInfo.codePath.currentSegments;
  62248. var duplicate = false;
  62249. var info = null;
  62250. for (var i = 0; i < segments.length; ++i) {
  62251. var segment = segments[i];
  62252. if (segment.reachable) {
  62253. info = segInfoMap[segment.id];
  62254. duplicate = duplicate || info.calledInSomePaths;
  62255. info.calledInSomePaths = info.calledInEveryPaths = true;
  62256. }
  62257. }
  62258. if (info) {
  62259. if (duplicate) {
  62260. context.report({
  62261. messageId: "duplicate",
  62262. node: node
  62263. });
  62264. } else if (!funcInfo.superIsConstructor) {
  62265. context.report({
  62266. messageId: "badSuper",
  62267. node: node
  62268. });
  62269. } else {
  62270. info.validNodes.push(node);
  62271. }
  62272. }
  62273. } else if (funcInfo.codePath.currentSegments.some(isReachable)) {
  62274. context.report({
  62275. messageId: "unexpected",
  62276. node: node
  62277. });
  62278. }
  62279. },
  62280. /**
  62281. * Set the mark to the returned path as `super()` was called.
  62282. * @param {ASTNode} node - A ReturnStatement node to check.
  62283. * @returns {void}
  62284. */
  62285. ReturnStatement: function ReturnStatement(node) {
  62286. if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
  62287. return;
  62288. }
  62289. // Skips if no argument.
  62290. if (!node.argument) {
  62291. return;
  62292. }
  62293. // Returning argument is a substitute of 'super()'.
  62294. var segments = funcInfo.codePath.currentSegments;
  62295. for (var i = 0; i < segments.length; ++i) {
  62296. var segment = segments[i];
  62297. if (segment.reachable) {
  62298. var info = segInfoMap[segment.id];
  62299. info.calledInSomePaths = info.calledInEveryPaths = true;
  62300. }
  62301. }
  62302. },
  62303. /**
  62304. * Resets state.
  62305. * @returns {void}
  62306. */
  62307. "Program:exit": function ProgramExit() {
  62308. segInfoMap = Object.create(null);
  62309. }
  62310. };
  62311. }
  62312. };
  62313. },{}],148:[function(require,module,exports){
  62314. /**
  62315. * @fileoverview Rule to flag statements without curly braces
  62316. * @author Nicholas C. Zakas
  62317. */
  62318. "use strict";
  62319. //------------------------------------------------------------------------------
  62320. // Requirements
  62321. //------------------------------------------------------------------------------
  62322. var astUtils = require("../util/ast-utils");
  62323. //------------------------------------------------------------------------------
  62324. // Rule Definition
  62325. //------------------------------------------------------------------------------
  62326. module.exports = {
  62327. meta: {
  62328. type: "suggestion",
  62329. docs: {
  62330. description: "enforce consistent brace style for all control statements",
  62331. category: "Best Practices",
  62332. recommended: false,
  62333. url: "https://eslint.org/docs/rules/curly"
  62334. },
  62335. schema: {
  62336. anyOf: [{
  62337. type: "array",
  62338. items: [{
  62339. enum: ["all"]
  62340. }],
  62341. minItems: 0,
  62342. maxItems: 1
  62343. }, {
  62344. type: "array",
  62345. items: [{
  62346. enum: ["multi", "multi-line", "multi-or-nest"]
  62347. }, {
  62348. enum: ["consistent"]
  62349. }],
  62350. minItems: 0,
  62351. maxItems: 2
  62352. }]
  62353. },
  62354. fixable: "code",
  62355. messages: {
  62356. missingCurlyAfter: "Expected { after '{{name}}'.",
  62357. missingCurlyAfterCondition: "Expected { after '{{name}}' condition.",
  62358. unexpectedCurlyAfter: "Unnecessary { after '{{name}}'.",
  62359. unexpectedCurlyAfterCondition: "Unnecessary { after '{{name}}' condition."
  62360. }
  62361. },
  62362. create: function create(context) {
  62363. var multiOnly = context.options[0] === "multi";
  62364. var multiLine = context.options[0] === "multi-line";
  62365. var multiOrNest = context.options[0] === "multi-or-nest";
  62366. var consistent = context.options[1] === "consistent";
  62367. var sourceCode = context.getSourceCode();
  62368. //--------------------------------------------------------------------------
  62369. // Helpers
  62370. //--------------------------------------------------------------------------
  62371. /**
  62372. * Determines if a given node is a one-liner that's on the same line as it's preceding code.
  62373. * @param {ASTNode} node The node to check.
  62374. * @returns {boolean} True if the node is a one-liner that's on the same line as it's preceding code.
  62375. * @private
  62376. */
  62377. function isCollapsedOneLiner(node) {
  62378. var before = sourceCode.getTokenBefore(node);
  62379. var last = sourceCode.getLastToken(node);
  62380. var lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
  62381. return before.loc.start.line === lastExcludingSemicolon.loc.end.line;
  62382. }
  62383. /**
  62384. * Determines if a given node is a one-liner.
  62385. * @param {ASTNode} node The node to check.
  62386. * @returns {boolean} True if the node is a one-liner.
  62387. * @private
  62388. */
  62389. function isOneLiner(node) {
  62390. var first = sourceCode.getFirstToken(node),
  62391. last = sourceCode.getLastToken(node);
  62392. return first.loc.start.line === last.loc.end.line;
  62393. }
  62394. /**
  62395. * Checks if the given token is an `else` token or not.
  62396. *
  62397. * @param {Token} token - The token to check.
  62398. * @returns {boolean} `true` if the token is an `else` token.
  62399. */
  62400. function isElseKeywordToken(token) {
  62401. return token.value === "else" && token.type === "Keyword";
  62402. }
  62403. /**
  62404. * Gets the `else` keyword token of a given `IfStatement` node.
  62405. * @param {ASTNode} node - A `IfStatement` node to get.
  62406. * @returns {Token} The `else` keyword token.
  62407. */
  62408. function getElseKeyword(node) {
  62409. return node.alternate && sourceCode.getFirstTokenBetween(node.consequent, node.alternate, isElseKeywordToken);
  62410. }
  62411. /**
  62412. * Checks a given IfStatement node requires braces of the consequent chunk.
  62413. * This returns `true` when below:
  62414. *
  62415. * 1. The given node has the `alternate` node.
  62416. * 2. There is a `IfStatement` which doesn't have `alternate` node in the
  62417. * trailing statement chain of the `consequent` node.
  62418. *
  62419. * @param {ASTNode} node - A IfStatement node to check.
  62420. * @returns {boolean} `true` if the node requires braces of the consequent chunk.
  62421. */
  62422. function requiresBraceOfConsequent(node) {
  62423. if (node.alternate && node.consequent.type === "BlockStatement") {
  62424. if (node.consequent.body.length >= 2) {
  62425. return true;
  62426. }
  62427. for (var currentNode = node.consequent.body[0]; currentNode; currentNode = astUtils.getTrailingStatement(currentNode)) {
  62428. if (currentNode.type === "IfStatement" && !currentNode.alternate) {
  62429. return true;
  62430. }
  62431. }
  62432. }
  62433. return false;
  62434. }
  62435. /**
  62436. * Determines if a semicolon needs to be inserted after removing a set of curly brackets, in order to avoid a SyntaxError.
  62437. * @param {Token} closingBracket The } token
  62438. * @returns {boolean} `true` if a semicolon needs to be inserted after the last statement in the block.
  62439. */
  62440. function needsSemicolon(closingBracket) {
  62441. var tokenBefore = sourceCode.getTokenBefore(closingBracket);
  62442. var tokenAfter = sourceCode.getTokenAfter(closingBracket);
  62443. var lastBlockNode = sourceCode.getNodeByRangeIndex(tokenBefore.range[0]);
  62444. if (astUtils.isSemicolonToken(tokenBefore)) {
  62445. // If the last statement already has a semicolon, don't add another one.
  62446. return false;
  62447. }
  62448. if (!tokenAfter) {
  62449. // If there are no statements after this block, there is no need to add a semicolon.
  62450. return false;
  62451. }
  62452. if (lastBlockNode.type === "BlockStatement" && lastBlockNode.parent.type !== "FunctionExpression" && lastBlockNode.parent.type !== "ArrowFunctionExpression") {
  62453. /*
  62454. * If the last node surrounded by curly brackets is a BlockStatement (other than a FunctionExpression or an ArrowFunctionExpression),
  62455. * don't insert a semicolon. Otherwise, the semicolon would be parsed as a separate statement, which would cause
  62456. * a SyntaxError if it was followed by `else`.
  62457. */
  62458. return false;
  62459. }
  62460. if (tokenBefore.loc.end.line === tokenAfter.loc.start.line) {
  62461. // If the next token is on the same line, insert a semicolon.
  62462. return true;
  62463. }
  62464. if (/^[([/`+-]/.test(tokenAfter.value)) {
  62465. // If the next token starts with a character that would disrupt ASI, insert a semicolon.
  62466. return true;
  62467. }
  62468. if (tokenBefore.type === "Punctuator" && (tokenBefore.value === "++" || tokenBefore.value === "--")) {
  62469. // If the last token is ++ or --, insert a semicolon to avoid disrupting ASI.
  62470. return true;
  62471. }
  62472. // Otherwise, do not insert a semicolon.
  62473. return false;
  62474. }
  62475. /**
  62476. * Prepares to check the body of a node to see if it's a block statement.
  62477. * @param {ASTNode} node The node to report if there's a problem.
  62478. * @param {ASTNode} body The body node to check for blocks.
  62479. * @param {string} name The name to report if there's a problem.
  62480. * @param {{ condition: boolean }} opts Options to pass to the report functions
  62481. * @returns {Object} a prepared check object, with "actual", "expected", "check" properties.
  62482. * "actual" will be `true` or `false` whether the body is already a block statement.
  62483. * "expected" will be `true` or `false` if the body should be a block statement or not, or
  62484. * `null` if it doesn't matter, depending on the rule options. It can be modified to change
  62485. * the final behavior of "check".
  62486. * "check" will be a function reporting appropriate problems depending on the other
  62487. * properties.
  62488. */
  62489. function prepareCheck(node, body, name, opts) {
  62490. var hasBlock = body.type === "BlockStatement";
  62491. var expected = null;
  62492. if (node.type === "IfStatement" && node.consequent === body && requiresBraceOfConsequent(node)) {
  62493. expected = true;
  62494. } else if (multiOnly) {
  62495. if (hasBlock && body.body.length === 1) {
  62496. expected = false;
  62497. }
  62498. } else if (multiLine) {
  62499. if (!isCollapsedOneLiner(body)) {
  62500. expected = true;
  62501. }
  62502. } else if (multiOrNest) {
  62503. if (hasBlock && body.body.length === 1 && isOneLiner(body.body[0])) {
  62504. var leadingComments = sourceCode.getCommentsBefore(body.body[0]);
  62505. expected = leadingComments.length > 0;
  62506. } else if (!isOneLiner(body)) {
  62507. expected = true;
  62508. }
  62509. } else {
  62510. expected = true;
  62511. }
  62512. return {
  62513. actual: hasBlock,
  62514. expected: expected,
  62515. check: function check() {
  62516. if (this.expected !== null && this.expected !== this.actual) {
  62517. if (this.expected) {
  62518. context.report({
  62519. node: node,
  62520. loc: (name !== "else" ? node : getElseKeyword(node)).loc.start,
  62521. messageId: opts && opts.condition ? "missingCurlyAfterCondition" : "missingCurlyAfter",
  62522. data: {
  62523. name: name
  62524. },
  62525. fix: function fix(fixer) {
  62526. return fixer.replaceText(body, "{" + sourceCode.getText(body) + "}");
  62527. }
  62528. });
  62529. } else {
  62530. context.report({
  62531. node: node,
  62532. loc: (name !== "else" ? node : getElseKeyword(node)).loc.start,
  62533. messageId: opts && opts.condition ? "unexpectedCurlyAfterCondition" : "unexpectedCurlyAfter",
  62534. data: {
  62535. name: name
  62536. },
  62537. fix: function fix(fixer) {
  62538. /*
  62539. * `do while` expressions sometimes need a space to be inserted after `do`.
  62540. * e.g. `do{foo()} while (bar)` should be corrected to `do foo() while (bar)`
  62541. */
  62542. var needsPrecedingSpace = node.type === "DoWhileStatement" && sourceCode.getTokenBefore(body).range[1] === body.range[0] && !astUtils.canTokensBeAdjacent("do", sourceCode.getFirstToken(body, { skip: 1 }));
  62543. var openingBracket = sourceCode.getFirstToken(body);
  62544. var closingBracket = sourceCode.getLastToken(body);
  62545. var lastTokenInBlock = sourceCode.getTokenBefore(closingBracket);
  62546. if (needsSemicolon(closingBracket)) {
  62547. /*
  62548. * If removing braces would cause a SyntaxError due to multiple statements on the same line (or
  62549. * change the semantics of the code due to ASI), don't perform a fix.
  62550. */
  62551. return null;
  62552. }
  62553. var resultingBodyText = sourceCode.getText().slice(openingBracket.range[1], lastTokenInBlock.range[0]) + sourceCode.getText(lastTokenInBlock) + sourceCode.getText().slice(lastTokenInBlock.range[1], closingBracket.range[0]);
  62554. return fixer.replaceText(body, (needsPrecedingSpace ? " " : "") + resultingBodyText);
  62555. }
  62556. });
  62557. }
  62558. }
  62559. }
  62560. };
  62561. }
  62562. /**
  62563. * Prepares to check the bodies of a "if", "else if" and "else" chain.
  62564. * @param {ASTNode} node The first IfStatement node of the chain.
  62565. * @returns {Object[]} prepared checks for each body of the chain. See `prepareCheck` for more
  62566. * information.
  62567. */
  62568. function prepareIfChecks(node) {
  62569. var preparedChecks = [];
  62570. for (var currentNode = node; currentNode; currentNode = currentNode.alternate) {
  62571. preparedChecks.push(prepareCheck(currentNode, currentNode.consequent, "if", { condition: true }));
  62572. if (currentNode.alternate && currentNode.alternate.type !== "IfStatement") {
  62573. preparedChecks.push(prepareCheck(currentNode, currentNode.alternate, "else"));
  62574. break;
  62575. }
  62576. }
  62577. if (consistent) {
  62578. /*
  62579. * If any node should have or already have braces, make sure they
  62580. * all have braces.
  62581. * If all nodes shouldn't have braces, make sure they don't.
  62582. */
  62583. var expected = preparedChecks.some(function (preparedCheck) {
  62584. if (preparedCheck.expected !== null) {
  62585. return preparedCheck.expected;
  62586. }
  62587. return preparedCheck.actual;
  62588. });
  62589. preparedChecks.forEach(function (preparedCheck) {
  62590. preparedCheck.expected = expected;
  62591. });
  62592. }
  62593. return preparedChecks;
  62594. }
  62595. //--------------------------------------------------------------------------
  62596. // Public
  62597. //--------------------------------------------------------------------------
  62598. return {
  62599. IfStatement: function IfStatement(node) {
  62600. if (node.parent.type !== "IfStatement") {
  62601. prepareIfChecks(node).forEach(function (preparedCheck) {
  62602. preparedCheck.check();
  62603. });
  62604. }
  62605. },
  62606. WhileStatement: function WhileStatement(node) {
  62607. prepareCheck(node, node.body, "while", { condition: true }).check();
  62608. },
  62609. DoWhileStatement: function DoWhileStatement(node) {
  62610. prepareCheck(node, node.body, "do").check();
  62611. },
  62612. ForStatement: function ForStatement(node) {
  62613. prepareCheck(node, node.body, "for", { condition: true }).check();
  62614. },
  62615. ForInStatement: function ForInStatement(node) {
  62616. prepareCheck(node, node.body, "for-in").check();
  62617. },
  62618. ForOfStatement: function ForOfStatement(node) {
  62619. prepareCheck(node, node.body, "for-of").check();
  62620. }
  62621. };
  62622. }
  62623. };
  62624. },{"../util/ast-utils":405}],149:[function(require,module,exports){
  62625. /**
  62626. * @fileoverview require default case in switch statements
  62627. * @author Aliaksei Shytkin
  62628. */
  62629. "use strict";
  62630. var DEFAULT_COMMENT_PATTERN = /^no default$/i;
  62631. //------------------------------------------------------------------------------
  62632. // Rule Definition
  62633. //------------------------------------------------------------------------------
  62634. module.exports = {
  62635. meta: {
  62636. type: "suggestion",
  62637. docs: {
  62638. description: "require `default` cases in `switch` statements",
  62639. category: "Best Practices",
  62640. recommended: false,
  62641. url: "https://eslint.org/docs/rules/default-case"
  62642. },
  62643. schema: [{
  62644. type: "object",
  62645. properties: {
  62646. commentPattern: {
  62647. type: "string"
  62648. }
  62649. },
  62650. additionalProperties: false
  62651. }],
  62652. messages: {
  62653. missingDefaultCase: "Expected a default case."
  62654. }
  62655. },
  62656. create: function create(context) {
  62657. var options = context.options[0] || {};
  62658. var commentPattern = options.commentPattern ? new RegExp(options.commentPattern) : DEFAULT_COMMENT_PATTERN;
  62659. var sourceCode = context.getSourceCode();
  62660. //--------------------------------------------------------------------------
  62661. // Helpers
  62662. //--------------------------------------------------------------------------
  62663. /**
  62664. * Shortcut to get last element of array
  62665. * @param {*[]} collection Array
  62666. * @returns {*} Last element
  62667. */
  62668. function last(collection) {
  62669. return collection[collection.length - 1];
  62670. }
  62671. //--------------------------------------------------------------------------
  62672. // Public
  62673. //--------------------------------------------------------------------------
  62674. return {
  62675. SwitchStatement: function SwitchStatement(node) {
  62676. if (!node.cases.length) {
  62677. /*
  62678. * skip check of empty switch because there is no easy way
  62679. * to extract comments inside it now
  62680. */
  62681. return;
  62682. }
  62683. var hasDefault = node.cases.some(function (v) {
  62684. return v.test === null;
  62685. });
  62686. if (!hasDefault) {
  62687. var comment = void 0;
  62688. var lastCase = last(node.cases);
  62689. var comments = sourceCode.getCommentsAfter(lastCase);
  62690. if (comments.length) {
  62691. comment = last(comments);
  62692. }
  62693. if (!comment || !commentPattern.test(comment.value.trim())) {
  62694. context.report({ node: node, messageId: "missingDefaultCase" });
  62695. }
  62696. }
  62697. }
  62698. };
  62699. }
  62700. };
  62701. },{}],150:[function(require,module,exports){
  62702. /**
  62703. * @fileoverview Validates newlines before and after dots
  62704. * @author Greg Cochard
  62705. */
  62706. "use strict";
  62707. var astUtils = require("../util/ast-utils");
  62708. //------------------------------------------------------------------------------
  62709. // Rule Definition
  62710. //------------------------------------------------------------------------------
  62711. module.exports = {
  62712. meta: {
  62713. type: "layout",
  62714. docs: {
  62715. description: "enforce consistent newlines before and after dots",
  62716. category: "Best Practices",
  62717. recommended: false,
  62718. url: "https://eslint.org/docs/rules/dot-location"
  62719. },
  62720. schema: [{
  62721. enum: ["object", "property"]
  62722. }],
  62723. fixable: "code",
  62724. messages: {
  62725. expectedDotAfterObject: "Expected dot to be on same line as object.",
  62726. expectedDotBeforeProperty: "Expected dot to be on same line as property."
  62727. }
  62728. },
  62729. create: function create(context) {
  62730. var config = context.options[0];
  62731. // default to onObject if no preference is passed
  62732. var onObject = config === "object" || !config;
  62733. var sourceCode = context.getSourceCode();
  62734. /**
  62735. * Reports if the dot between object and property is on the correct loccation.
  62736. * @param {ASTNode} obj The object owning the property.
  62737. * @param {ASTNode} prop The property of the object.
  62738. * @param {ASTNode} node The corresponding node of the token.
  62739. * @returns {void}
  62740. */
  62741. function checkDotLocation(obj, prop, node) {
  62742. var dot = sourceCode.getTokenBefore(prop);
  62743. var textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]);
  62744. var textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);
  62745. if (dot.type === "Punctuator" && dot.value === ".") {
  62746. if (onObject) {
  62747. if (!astUtils.isTokenOnSameLine(obj, dot)) {
  62748. var neededTextAfterObj = astUtils.isDecimalInteger(obj) ? " " : "";
  62749. context.report({
  62750. node: node,
  62751. loc: dot.loc.start,
  62752. messageId: "expectedDotAfterObject",
  62753. fix: function fix(fixer) {
  62754. return fixer.replaceTextRange([obj.range[1], prop.range[0]], neededTextAfterObj + "." + textBeforeDot + textAfterDot);
  62755. }
  62756. });
  62757. }
  62758. } else if (!astUtils.isTokenOnSameLine(dot, prop)) {
  62759. context.report({
  62760. node: node,
  62761. loc: dot.loc.start,
  62762. messageId: "expectedDotBeforeProperty",
  62763. fix: function fix(fixer) {
  62764. return fixer.replaceTextRange([obj.range[1], prop.range[0]], "" + textBeforeDot + textAfterDot + ".");
  62765. }
  62766. });
  62767. }
  62768. }
  62769. }
  62770. /**
  62771. * Checks the spacing of the dot within a member expression.
  62772. * @param {ASTNode} node The node to check.
  62773. * @returns {void}
  62774. */
  62775. function checkNode(node) {
  62776. checkDotLocation(node.object, node.property, node);
  62777. }
  62778. return {
  62779. MemberExpression: checkNode
  62780. };
  62781. }
  62782. };
  62783. },{"../util/ast-utils":405}],151:[function(require,module,exports){
  62784. /**
  62785. * @fileoverview Rule to warn about using dot notation instead of square bracket notation when possible.
  62786. * @author Josh Perez
  62787. */
  62788. "use strict";
  62789. //------------------------------------------------------------------------------
  62790. // Requirements
  62791. //------------------------------------------------------------------------------
  62792. var astUtils = require("../util/ast-utils");
  62793. //------------------------------------------------------------------------------
  62794. // Rule Definition
  62795. //------------------------------------------------------------------------------
  62796. var validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
  62797. var keywords = require("../util/keywords");
  62798. module.exports = {
  62799. meta: {
  62800. type: "suggestion",
  62801. docs: {
  62802. description: "enforce dot notation whenever possible",
  62803. category: "Best Practices",
  62804. recommended: false,
  62805. url: "https://eslint.org/docs/rules/dot-notation"
  62806. },
  62807. schema: [{
  62808. type: "object",
  62809. properties: {
  62810. allowKeywords: {
  62811. type: "boolean"
  62812. },
  62813. allowPattern: {
  62814. type: "string"
  62815. }
  62816. },
  62817. additionalProperties: false
  62818. }],
  62819. fixable: "code",
  62820. messages: {
  62821. useDot: "[{{key}}] is better written in dot notation.",
  62822. useBrackets: ".{{key}} is a syntax error."
  62823. }
  62824. },
  62825. create: function create(context) {
  62826. var options = context.options[0] || {};
  62827. var allowKeywords = options.allowKeywords === void 0 || !!options.allowKeywords;
  62828. var sourceCode = context.getSourceCode();
  62829. var allowPattern = void 0;
  62830. if (options.allowPattern) {
  62831. allowPattern = new RegExp(options.allowPattern);
  62832. }
  62833. /**
  62834. * Check if the property is valid dot notation
  62835. * @param {ASTNode} node The dot notation node
  62836. * @param {string} value Value which is to be checked
  62837. * @returns {void}
  62838. */
  62839. function checkComputedProperty(node, value) {
  62840. if (validIdentifier.test(value) && (allowKeywords || keywords.indexOf(String(value)) === -1) && !(allowPattern && allowPattern.test(value))) {
  62841. var formattedValue = node.property.type === "Literal" ? JSON.stringify(value) : "`" + value + "`";
  62842. context.report({
  62843. node: node.property,
  62844. messageId: "useDot",
  62845. data: {
  62846. key: formattedValue
  62847. },
  62848. fix: function fix(fixer) {
  62849. var leftBracket = sourceCode.getTokenAfter(node.object, astUtils.isOpeningBracketToken);
  62850. var rightBracket = sourceCode.getLastToken(node);
  62851. if (sourceCode.getFirstTokenBetween(leftBracket, rightBracket, { includeComments: true, filter: astUtils.isCommentToken })) {
  62852. // Don't perform any fixes if there are comments inside the brackets.
  62853. return null;
  62854. }
  62855. var tokenAfterProperty = sourceCode.getTokenAfter(rightBracket);
  62856. var needsSpaceAfterProperty = tokenAfterProperty && rightBracket.range[1] === tokenAfterProperty.range[0] && !astUtils.canTokensBeAdjacent(String(value), tokenAfterProperty);
  62857. var textBeforeDot = astUtils.isDecimalInteger(node.object) ? " " : "";
  62858. var textAfterProperty = needsSpaceAfterProperty ? " " : "";
  62859. return fixer.replaceTextRange([leftBracket.range[0], rightBracket.range[1]], textBeforeDot + "." + value + textAfterProperty);
  62860. }
  62861. });
  62862. }
  62863. }
  62864. return {
  62865. MemberExpression: function MemberExpression(node) {
  62866. if (node.computed && node.property.type === "Literal") {
  62867. checkComputedProperty(node, node.property.value);
  62868. }
  62869. if (node.computed && node.property.type === "TemplateLiteral" && node.property.expressions.length === 0) {
  62870. checkComputedProperty(node, node.property.quasis[0].value.cooked);
  62871. }
  62872. if (!allowKeywords && !node.computed && keywords.indexOf(String(node.property.name)) !== -1) {
  62873. context.report({
  62874. node: node.property,
  62875. messageId: "useBrackets",
  62876. data: {
  62877. key: node.property.name
  62878. },
  62879. fix: function fix(fixer) {
  62880. var dot = sourceCode.getTokenBefore(node.property);
  62881. var textAfterDot = sourceCode.text.slice(dot.range[1], node.property.range[0]);
  62882. if (textAfterDot.trim()) {
  62883. // Don't perform any fixes if there are comments between the dot and the property name.
  62884. return null;
  62885. }
  62886. if (node.object.type === "Identifier" && node.object.name === "let") {
  62887. /*
  62888. * A statement that starts with `let[` is parsed as a destructuring variable declaration, not
  62889. * a MemberExpression.
  62890. */
  62891. return null;
  62892. }
  62893. return fixer.replaceTextRange([dot.range[0], node.property.range[1]], "[" + textAfterDot + "\"" + node.property.name + "\"]");
  62894. }
  62895. });
  62896. }
  62897. }
  62898. };
  62899. }
  62900. };
  62901. },{"../util/ast-utils":405,"../util/keywords":409}],152:[function(require,module,exports){
  62902. /**
  62903. * @fileoverview Require or disallow newline at the end of files
  62904. * @author Nodeca Team <https://github.com/nodeca>
  62905. */
  62906. "use strict";
  62907. //------------------------------------------------------------------------------
  62908. // Requirements
  62909. //------------------------------------------------------------------------------
  62910. var lodash = require("lodash");
  62911. //------------------------------------------------------------------------------
  62912. // Rule Definition
  62913. //------------------------------------------------------------------------------
  62914. module.exports = {
  62915. meta: {
  62916. type: "layout",
  62917. docs: {
  62918. description: "require or disallow newline at the end of files",
  62919. category: "Stylistic Issues",
  62920. recommended: false,
  62921. url: "https://eslint.org/docs/rules/eol-last"
  62922. },
  62923. fixable: "whitespace",
  62924. schema: [{
  62925. enum: ["always", "never", "unix", "windows"]
  62926. }],
  62927. messages: {
  62928. missing: "Newline required at end of file but not found.",
  62929. unexpected: "Newline not allowed at end of file."
  62930. }
  62931. },
  62932. create: function create(context) {
  62933. //--------------------------------------------------------------------------
  62934. // Public
  62935. //--------------------------------------------------------------------------
  62936. return {
  62937. Program: function checkBadEOF(node) {
  62938. var sourceCode = context.getSourceCode(),
  62939. src = sourceCode.getText(),
  62940. location = {
  62941. column: lodash.last(sourceCode.lines).length,
  62942. line: sourceCode.lines.length
  62943. },
  62944. LF = "\n",
  62945. CRLF = "\r" + LF,
  62946. endsWithNewline = lodash.endsWith(src, LF);
  62947. /*
  62948. * Empty source is always valid: No content in file so we don't
  62949. * need to lint for a newline on the last line of content.
  62950. */
  62951. if (!src.length) {
  62952. return;
  62953. }
  62954. var mode = context.options[0] || "always",
  62955. appendCRLF = false;
  62956. if (mode === "unix") {
  62957. // `"unix"` should behave exactly as `"always"`
  62958. mode = "always";
  62959. }
  62960. if (mode === "windows") {
  62961. // `"windows"` should behave exactly as `"always"`, but append CRLF in the fixer for backwards compatibility
  62962. mode = "always";
  62963. appendCRLF = true;
  62964. }
  62965. if (mode === "always" && !endsWithNewline) {
  62966. // File is not newline-terminated, but should be
  62967. context.report({
  62968. node: node,
  62969. loc: location,
  62970. messageId: "missing",
  62971. fix: function fix(fixer) {
  62972. return fixer.insertTextAfterRange([0, src.length], appendCRLF ? CRLF : LF);
  62973. }
  62974. });
  62975. } else if (mode === "never" && endsWithNewline) {
  62976. // File is newline-terminated, but shouldn't be
  62977. context.report({
  62978. node: node,
  62979. loc: location,
  62980. messageId: "unexpected",
  62981. fix: function fix(fixer) {
  62982. var finalEOLs = /(?:\r?\n)+$/,
  62983. match = finalEOLs.exec(sourceCode.text),
  62984. start = match.index,
  62985. end = sourceCode.text.length;
  62986. return fixer.replaceTextRange([start, end], "");
  62987. }
  62988. });
  62989. }
  62990. }
  62991. };
  62992. }
  62993. };
  62994. },{"lodash":92}],153:[function(require,module,exports){
  62995. /**
  62996. * @fileoverview Rule to flag statements that use != and == instead of !== and ===
  62997. * @author Nicholas C. Zakas
  62998. */
  62999. "use strict";
  63000. //------------------------------------------------------------------------------
  63001. // Requirements
  63002. //------------------------------------------------------------------------------
  63003. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  63004. var astUtils = require("../util/ast-utils");
  63005. //------------------------------------------------------------------------------
  63006. // Rule Definition
  63007. //------------------------------------------------------------------------------
  63008. module.exports = {
  63009. meta: {
  63010. type: "suggestion",
  63011. docs: {
  63012. description: "require the use of `===` and `!==`",
  63013. category: "Best Practices",
  63014. recommended: false,
  63015. url: "https://eslint.org/docs/rules/eqeqeq"
  63016. },
  63017. schema: {
  63018. anyOf: [{
  63019. type: "array",
  63020. items: [{
  63021. enum: ["always"]
  63022. }, {
  63023. type: "object",
  63024. properties: {
  63025. null: {
  63026. enum: ["always", "never", "ignore"]
  63027. }
  63028. },
  63029. additionalProperties: false
  63030. }],
  63031. additionalItems: false
  63032. }, {
  63033. type: "array",
  63034. items: [{
  63035. enum: ["smart", "allow-null"]
  63036. }],
  63037. additionalItems: false
  63038. }]
  63039. },
  63040. fixable: "code",
  63041. messages: {
  63042. unexpected: "Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'."
  63043. }
  63044. },
  63045. create: function create(context) {
  63046. var config = context.options[0] || "always";
  63047. var options = context.options[1] || {};
  63048. var sourceCode = context.getSourceCode();
  63049. var nullOption = config === "always" ? options.null || "always" : "ignore";
  63050. var enforceRuleForNull = nullOption === "always";
  63051. var enforceInverseRuleForNull = nullOption === "never";
  63052. /**
  63053. * Checks if an expression is a typeof expression
  63054. * @param {ASTNode} node The node to check
  63055. * @returns {boolean} if the node is a typeof expression
  63056. */
  63057. function isTypeOf(node) {
  63058. return node.type === "UnaryExpression" && node.operator === "typeof";
  63059. }
  63060. /**
  63061. * Checks if either operand of a binary expression is a typeof operation
  63062. * @param {ASTNode} node The node to check
  63063. * @returns {boolean} if one of the operands is typeof
  63064. * @private
  63065. */
  63066. function isTypeOfBinary(node) {
  63067. return isTypeOf(node.left) || isTypeOf(node.right);
  63068. }
  63069. /**
  63070. * Checks if operands are literals of the same type (via typeof)
  63071. * @param {ASTNode} node The node to check
  63072. * @returns {boolean} if operands are of same type
  63073. * @private
  63074. */
  63075. function areLiteralsAndSameType(node) {
  63076. return node.left.type === "Literal" && node.right.type === "Literal" && _typeof(node.left.value) === _typeof(node.right.value);
  63077. }
  63078. /**
  63079. * Checks if one of the operands is a literal null
  63080. * @param {ASTNode} node The node to check
  63081. * @returns {boolean} if operands are null
  63082. * @private
  63083. */
  63084. function isNullCheck(node) {
  63085. return astUtils.isNullLiteral(node.right) || astUtils.isNullLiteral(node.left);
  63086. }
  63087. /**
  63088. * Gets the location (line and column) of the binary expression's operator
  63089. * @param {ASTNode} node The binary expression node to check
  63090. * @returns {Object} { line, column } location of operator
  63091. * @private
  63092. */
  63093. function getOperatorLocation(node) {
  63094. var opToken = sourceCode.getTokenAfter(node.left);
  63095. return { line: opToken.loc.start.line, column: opToken.loc.start.column };
  63096. }
  63097. /**
  63098. * Reports a message for this rule.
  63099. * @param {ASTNode} node The binary expression node that was checked
  63100. * @param {string} expectedOperator The operator that was expected (either '==', '!=', '===', or '!==')
  63101. * @returns {void}
  63102. * @private
  63103. */
  63104. function report(node, expectedOperator) {
  63105. context.report({
  63106. node: node,
  63107. loc: getOperatorLocation(node),
  63108. messageId: "unexpected",
  63109. data: { expectedOperator: expectedOperator, actualOperator: node.operator },
  63110. fix: function fix(fixer) {
  63111. // If the comparison is a `typeof` comparison or both sides are literals with the same type, then it's safe to fix.
  63112. if (isTypeOfBinary(node) || areLiteralsAndSameType(node)) {
  63113. var operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, function (token) {
  63114. return token.value === node.operator;
  63115. });
  63116. return fixer.replaceText(operatorToken, expectedOperator);
  63117. }
  63118. return null;
  63119. }
  63120. });
  63121. }
  63122. return {
  63123. BinaryExpression: function BinaryExpression(node) {
  63124. var isNull = isNullCheck(node);
  63125. if (node.operator !== "==" && node.operator !== "!=") {
  63126. if (enforceInverseRuleForNull && isNull) {
  63127. report(node, node.operator.slice(0, -1));
  63128. }
  63129. return;
  63130. }
  63131. if (config === "smart" && (isTypeOfBinary(node) || areLiteralsAndSameType(node) || isNull)) {
  63132. return;
  63133. }
  63134. if (!enforceRuleForNull && isNull) {
  63135. return;
  63136. }
  63137. report(node, node.operator + "=");
  63138. }
  63139. };
  63140. }
  63141. };
  63142. },{"../util/ast-utils":405}],154:[function(require,module,exports){
  63143. /**
  63144. * @fileoverview enforce "for" loop update clause moving the counter in the right direction.(for-direction)
  63145. * @author Aladdin-ADD<hh_2013@foxmail.com>
  63146. */
  63147. "use strict";
  63148. //------------------------------------------------------------------------------
  63149. // Rule Definition
  63150. //------------------------------------------------------------------------------
  63151. module.exports = {
  63152. meta: {
  63153. type: "problem",
  63154. docs: {
  63155. description: "enforce \"for\" loop update clause moving the counter in the right direction.",
  63156. category: "Possible Errors",
  63157. recommended: true,
  63158. url: "https://eslint.org/docs/rules/for-direction"
  63159. },
  63160. fixable: null,
  63161. schema: [],
  63162. messages: {
  63163. incorrectDirection: "The update clause in this loop moves the variable in the wrong direction."
  63164. }
  63165. },
  63166. create: function create(context) {
  63167. /**
  63168. * report an error.
  63169. * @param {ASTNode} node the node to report.
  63170. * @returns {void}
  63171. */
  63172. function report(node) {
  63173. context.report({
  63174. node: node,
  63175. messageId: "incorrectDirection"
  63176. });
  63177. }
  63178. /**
  63179. * check UpdateExpression add/sub the counter
  63180. * @param {ASTNode} update UpdateExpression to check
  63181. * @param {string} counter variable name to check
  63182. * @returns {int} if add return 1, if sub return -1, if nochange, return 0
  63183. */
  63184. function getUpdateDirection(update, counter) {
  63185. if (update.argument.type === "Identifier" && update.argument.name === counter) {
  63186. if (update.operator === "++") {
  63187. return 1;
  63188. }
  63189. if (update.operator === "--") {
  63190. return -1;
  63191. }
  63192. }
  63193. return 0;
  63194. }
  63195. /**
  63196. * check AssignmentExpression add/sub the counter
  63197. * @param {ASTNode} update AssignmentExpression to check
  63198. * @param {string} counter variable name to check
  63199. * @returns {int} if add return 1, if sub return -1, if nochange, return 0
  63200. */
  63201. function getAssignmentDirection(update, counter) {
  63202. if (update.left.name === counter) {
  63203. if (update.operator === "+=") {
  63204. return 1;
  63205. }
  63206. if (update.operator === "-=") {
  63207. return -1;
  63208. }
  63209. }
  63210. return 0;
  63211. }
  63212. return {
  63213. ForStatement: function ForStatement(node) {
  63214. if (node.test && node.test.type === "BinaryExpression" && node.test.left.type === "Identifier" && node.update) {
  63215. var counter = node.test.left.name;
  63216. var operator = node.test.operator;
  63217. var update = node.update;
  63218. if (operator === "<" || operator === "<=") {
  63219. // report error if update sub the counter (--, -=)
  63220. if (update.type === "UpdateExpression" && getUpdateDirection(update, counter) < 0) {
  63221. report(node);
  63222. }
  63223. if (update.type === "AssignmentExpression" && getAssignmentDirection(update, counter) < 0) {
  63224. report(node);
  63225. }
  63226. } else if (operator === ">" || operator === ">=") {
  63227. // report error if update add the counter (++, +=)
  63228. if (update.type === "UpdateExpression" && getUpdateDirection(update, counter) > 0) {
  63229. report(node);
  63230. }
  63231. if (update.type === "AssignmentExpression" && getAssignmentDirection(update, counter) > 0) {
  63232. report(node);
  63233. }
  63234. }
  63235. }
  63236. }
  63237. };
  63238. }
  63239. };
  63240. },{}],155:[function(require,module,exports){
  63241. /**
  63242. * @fileoverview Rule to control spacing within function calls
  63243. * @author Matt DuVall <http://www.mattduvall.com>
  63244. */
  63245. "use strict";
  63246. //------------------------------------------------------------------------------
  63247. // Requirements
  63248. //------------------------------------------------------------------------------
  63249. var astUtils = require("../util/ast-utils");
  63250. //------------------------------------------------------------------------------
  63251. // Rule Definition
  63252. //------------------------------------------------------------------------------
  63253. module.exports = {
  63254. meta: {
  63255. type: "layout",
  63256. docs: {
  63257. description: "require or disallow spacing between function identifiers and their invocations",
  63258. category: "Stylistic Issues",
  63259. recommended: false,
  63260. url: "https://eslint.org/docs/rules/func-call-spacing"
  63261. },
  63262. fixable: "whitespace",
  63263. schema: {
  63264. anyOf: [{
  63265. type: "array",
  63266. items: [{
  63267. enum: ["never"]
  63268. }],
  63269. minItems: 0,
  63270. maxItems: 1
  63271. }, {
  63272. type: "array",
  63273. items: [{
  63274. enum: ["always"]
  63275. }, {
  63276. type: "object",
  63277. properties: {
  63278. allowNewlines: {
  63279. type: "boolean"
  63280. }
  63281. },
  63282. additionalProperties: false
  63283. }],
  63284. minItems: 0,
  63285. maxItems: 2
  63286. }]
  63287. },
  63288. messages: {
  63289. unexpected: "Unexpected newline between function name and paren.",
  63290. missing: "Missing space between function name and paren."
  63291. }
  63292. },
  63293. create: function create(context) {
  63294. var never = context.options[0] !== "always";
  63295. var allowNewlines = !never && context.options[1] && context.options[1].allowNewlines;
  63296. var sourceCode = context.getSourceCode();
  63297. var text = sourceCode.getText();
  63298. /**
  63299. * Check if open space is present in a function name
  63300. * @param {ASTNode} node node to evaluate
  63301. * @returns {void}
  63302. * @private
  63303. */
  63304. function checkSpacing(node) {
  63305. var lastToken = sourceCode.getLastToken(node);
  63306. var lastCalleeToken = sourceCode.getLastToken(node.callee);
  63307. var parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, astUtils.isOpeningParenToken);
  63308. var prevToken = parenToken && sourceCode.getTokenBefore(parenToken);
  63309. // Parens in NewExpression are optional
  63310. if (!(parenToken && parenToken.range[1] < node.range[1])) {
  63311. return;
  63312. }
  63313. var textBetweenTokens = text.slice(prevToken.range[1], parenToken.range[0]).replace(/\/\*.*?\*\//g, "");
  63314. var hasWhitespace = /\s/.test(textBetweenTokens);
  63315. var hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens);
  63316. /*
  63317. * never allowNewlines hasWhitespace hasNewline message
  63318. * F F F F Missing space between function name and paren.
  63319. * F F F T (Invalid `!hasWhitespace && hasNewline`)
  63320. * F F T T Unexpected newline between function name and paren.
  63321. * F F T F (OK)
  63322. * F T T F (OK)
  63323. * F T T T (OK)
  63324. * F T F T (Invalid `!hasWhitespace && hasNewline`)
  63325. * F T F F Missing space between function name and paren.
  63326. * T T F F (Invalid `never && allowNewlines`)
  63327. * T T F T (Invalid `!hasWhitespace && hasNewline`)
  63328. * T T T T (Invalid `never && allowNewlines`)
  63329. * T T T F (Invalid `never && allowNewlines`)
  63330. * T F T F Unexpected space between function name and paren.
  63331. * T F T T Unexpected space between function name and paren.
  63332. * T F F T (Invalid `!hasWhitespace && hasNewline`)
  63333. * T F F F (OK)
  63334. *
  63335. * T T Unexpected space between function name and paren.
  63336. * F F Missing space between function name and paren.
  63337. * F F T Unexpected newline between function name and paren.
  63338. */
  63339. if (never && hasWhitespace) {
  63340. context.report({
  63341. node: node,
  63342. loc: lastCalleeToken.loc.start,
  63343. messageId: "unexpected",
  63344. fix: function fix(fixer) {
  63345. /*
  63346. * Only autofix if there is no newline
  63347. * https://github.com/eslint/eslint/issues/7787
  63348. */
  63349. if (!hasNewline) {
  63350. return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
  63351. }
  63352. return null;
  63353. }
  63354. });
  63355. } else if (!never && !hasWhitespace) {
  63356. context.report({
  63357. node: node,
  63358. loc: lastCalleeToken.loc.start,
  63359. messageId: "missing",
  63360. fix: function fix(fixer) {
  63361. return fixer.insertTextBefore(parenToken, " ");
  63362. }
  63363. });
  63364. } else if (!never && !allowNewlines && hasNewline) {
  63365. context.report({
  63366. node: node,
  63367. loc: lastCalleeToken.loc.start,
  63368. messageId: "unexpected",
  63369. fix: function fix(fixer) {
  63370. return fixer.replaceTextRange([prevToken.range[1], parenToken.range[0]], " ");
  63371. }
  63372. });
  63373. }
  63374. }
  63375. return {
  63376. CallExpression: checkSpacing,
  63377. NewExpression: checkSpacing
  63378. };
  63379. }
  63380. };
  63381. },{"../util/ast-utils":405}],156:[function(require,module,exports){
  63382. /**
  63383. * @fileoverview Rule to require function names to match the name of the variable or property to which they are assigned.
  63384. * @author Annie Zhang, Pavel Strashkin
  63385. */
  63386. "use strict";
  63387. //--------------------------------------------------------------------------
  63388. // Requirements
  63389. //--------------------------------------------------------------------------
  63390. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  63391. var astUtils = require("../util/ast-utils");
  63392. var esutils = require("esutils");
  63393. //--------------------------------------------------------------------------
  63394. // Helpers
  63395. //--------------------------------------------------------------------------
  63396. /**
  63397. * Determines if a pattern is `module.exports` or `module["exports"]`
  63398. * @param {ASTNode} pattern The left side of the AssignmentExpression
  63399. * @returns {boolean} True if the pattern is `module.exports` or `module["exports"]`
  63400. */
  63401. function isModuleExports(pattern) {
  63402. if (pattern.type === "MemberExpression" && pattern.object.type === "Identifier" && pattern.object.name === "module") {
  63403. // module.exports
  63404. if (pattern.property.type === "Identifier" && pattern.property.name === "exports") {
  63405. return true;
  63406. }
  63407. // module["exports"]
  63408. if (pattern.property.type === "Literal" && pattern.property.value === "exports") {
  63409. return true;
  63410. }
  63411. }
  63412. return false;
  63413. }
  63414. /**
  63415. * Determines if a string name is a valid identifier
  63416. * @param {string} name The string to be checked
  63417. * @param {int} ecmaVersion The ECMAScript version if specified in the parserOptions config
  63418. * @returns {boolean} True if the string is a valid identifier
  63419. */
  63420. function isIdentifier(name, ecmaVersion) {
  63421. if (ecmaVersion >= 6) {
  63422. return esutils.keyword.isIdentifierES6(name);
  63423. }
  63424. return esutils.keyword.isIdentifierES5(name);
  63425. }
  63426. //------------------------------------------------------------------------------
  63427. // Rule Definition
  63428. //------------------------------------------------------------------------------
  63429. var alwaysOrNever = { enum: ["always", "never"] };
  63430. var optionsObject = {
  63431. type: "object",
  63432. properties: {
  63433. considerPropertyDescriptor: {
  63434. type: "boolean"
  63435. },
  63436. includeCommonJSModuleExports: {
  63437. type: "boolean"
  63438. }
  63439. },
  63440. additionalProperties: false
  63441. };
  63442. module.exports = {
  63443. meta: {
  63444. type: "suggestion",
  63445. docs: {
  63446. description: "require function names to match the name of the variable or property to which they are assigned",
  63447. category: "Stylistic Issues",
  63448. recommended: false,
  63449. url: "https://eslint.org/docs/rules/func-name-matching"
  63450. },
  63451. schema: {
  63452. anyOf: [{
  63453. type: "array",
  63454. additionalItems: false,
  63455. items: [alwaysOrNever, optionsObject]
  63456. }, {
  63457. type: "array",
  63458. additionalItems: false,
  63459. items: [optionsObject]
  63460. }]
  63461. },
  63462. messages: {
  63463. matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`",
  63464. matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`",
  63465. notMatchProperty: "Function name `{{funcName}}` should not match property name `{{name}}`",
  63466. notMatchVariable: "Function name `{{funcName}}` should not match variable name `{{name}}`"
  63467. }
  63468. },
  63469. create: function create(context) {
  63470. var options = (_typeof(context.options[0]) === "object" ? context.options[0] : context.options[1]) || {};
  63471. var nameMatches = typeof context.options[0] === "string" ? context.options[0] : "always";
  63472. var considerPropertyDescriptor = options.considerPropertyDescriptor;
  63473. var includeModuleExports = options.includeCommonJSModuleExports;
  63474. var ecmaVersion = context.parserOptions && context.parserOptions.ecmaVersion ? context.parserOptions.ecmaVersion : 5;
  63475. /**
  63476. * Check whether node is a certain CallExpression.
  63477. * @param {string} objName object name
  63478. * @param {string} funcName function name
  63479. * @param {ASTNode} node The node to check
  63480. * @returns {boolean} `true` if node matches CallExpression
  63481. */
  63482. function isPropertyCall(objName, funcName, node) {
  63483. if (!node) {
  63484. return false;
  63485. }
  63486. return node.type === "CallExpression" && node.callee.object.name === objName && node.callee.property.name === funcName;
  63487. }
  63488. /**
  63489. * Compares identifiers based on the nameMatches option
  63490. * @param {string} x the first identifier
  63491. * @param {string} y the second identifier
  63492. * @returns {boolean} whether the two identifiers should warn.
  63493. */
  63494. function shouldWarn(x, y) {
  63495. return nameMatches === "always" && x !== y || nameMatches === "never" && x === y;
  63496. }
  63497. /**
  63498. * Reports
  63499. * @param {ASTNode} node The node to report
  63500. * @param {string} name The variable or property name
  63501. * @param {string} funcName The function name
  63502. * @param {boolean} isProp True if the reported node is a property assignment
  63503. * @returns {void}
  63504. */
  63505. function report(node, name, funcName, isProp) {
  63506. var messageId = void 0;
  63507. if (nameMatches === "always" && isProp) {
  63508. messageId = "matchProperty";
  63509. } else if (nameMatches === "always") {
  63510. messageId = "matchVariable";
  63511. } else if (isProp) {
  63512. messageId = "notMatchProperty";
  63513. } else {
  63514. messageId = "notMatchVariable";
  63515. }
  63516. context.report({
  63517. node: node,
  63518. messageId: messageId,
  63519. data: {
  63520. name: name,
  63521. funcName: funcName
  63522. }
  63523. });
  63524. }
  63525. /**
  63526. * Determines whether a given node is a string literal
  63527. * @param {ASTNode} node The node to check
  63528. * @returns {boolean} `true` if the node is a string literal
  63529. */
  63530. function isStringLiteral(node) {
  63531. return node.type === "Literal" && typeof node.value === "string";
  63532. }
  63533. //--------------------------------------------------------------------------
  63534. // Public
  63535. //--------------------------------------------------------------------------
  63536. return {
  63537. VariableDeclarator: function VariableDeclarator(node) {
  63538. if (!node.init || node.init.type !== "FunctionExpression" || node.id.type !== "Identifier") {
  63539. return;
  63540. }
  63541. if (node.init.id && shouldWarn(node.id.name, node.init.id.name)) {
  63542. report(node, node.id.name, node.init.id.name, false);
  63543. }
  63544. },
  63545. AssignmentExpression: function AssignmentExpression(node) {
  63546. if (node.right.type !== "FunctionExpression" || node.left.computed && node.left.property.type !== "Literal" || !includeModuleExports && isModuleExports(node.left) || node.left.type !== "Identifier" && node.left.type !== "MemberExpression") {
  63547. return;
  63548. }
  63549. var isProp = node.left.type === "MemberExpression";
  63550. var name = isProp ? astUtils.getStaticPropertyName(node.left) : node.left.name;
  63551. if (node.right.id && isIdentifier(name) && shouldWarn(name, node.right.id.name)) {
  63552. report(node, name, node.right.id.name, isProp);
  63553. }
  63554. },
  63555. Property: function Property(node) {
  63556. if (node.value.type !== "FunctionExpression" || !node.value.id || node.computed && !isStringLiteral(node.key)) {
  63557. return;
  63558. }
  63559. if (node.key.type === "Identifier") {
  63560. var functionName = node.value.id.name;
  63561. var propertyName = node.key.name;
  63562. if (considerPropertyDescriptor && propertyName === "value") {
  63563. if (isPropertyCall("Object", "defineProperty", node.parent.parent) || isPropertyCall("Reflect", "defineProperty", node.parent.parent)) {
  63564. var property = node.parent.parent.arguments[1];
  63565. if (isStringLiteral(property) && shouldWarn(property.value, functionName)) {
  63566. report(node, property.value, functionName, true);
  63567. }
  63568. } else if (isPropertyCall("Object", "defineProperties", node.parent.parent.parent.parent)) {
  63569. propertyName = node.parent.parent.key.name;
  63570. if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) {
  63571. report(node, propertyName, functionName, true);
  63572. }
  63573. } else if (isPropertyCall("Object", "create", node.parent.parent.parent.parent)) {
  63574. propertyName = node.parent.parent.key.name;
  63575. if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) {
  63576. report(node, propertyName, functionName, true);
  63577. }
  63578. } else if (shouldWarn(propertyName, functionName)) {
  63579. report(node, propertyName, functionName, true);
  63580. }
  63581. } else if (shouldWarn(propertyName, functionName)) {
  63582. report(node, propertyName, functionName, true);
  63583. }
  63584. return;
  63585. }
  63586. if (isStringLiteral(node.key) && isIdentifier(node.key.value, ecmaVersion) && shouldWarn(node.key.value, node.value.id.name)) {
  63587. report(node, node.key.value, node.value.id.name, true);
  63588. }
  63589. }
  63590. };
  63591. }
  63592. };
  63593. },{"../util/ast-utils":405,"esutils":80}],157:[function(require,module,exports){
  63594. /**
  63595. * @fileoverview Rule to warn when a function expression does not have a name.
  63596. * @author Kyle T. Nunery
  63597. */
  63598. "use strict";
  63599. //------------------------------------------------------------------------------
  63600. // Requirements
  63601. //------------------------------------------------------------------------------
  63602. var astUtils = require("../util/ast-utils");
  63603. /**
  63604. * Checks whether or not a given variable is a function name.
  63605. * @param {eslint-scope.Variable} variable - A variable to check.
  63606. * @returns {boolean} `true` if the variable is a function name.
  63607. */
  63608. function isFunctionName(variable) {
  63609. return variable && variable.defs[0].type === "FunctionName";
  63610. }
  63611. //------------------------------------------------------------------------------
  63612. // Rule Definition
  63613. //------------------------------------------------------------------------------
  63614. module.exports = {
  63615. meta: {
  63616. type: "suggestion",
  63617. docs: {
  63618. description: "require or disallow named `function` expressions",
  63619. category: "Stylistic Issues",
  63620. recommended: false,
  63621. url: "https://eslint.org/docs/rules/func-names"
  63622. },
  63623. schema: {
  63624. definitions: {
  63625. value: {
  63626. enum: ["always", "as-needed", "never"]
  63627. }
  63628. },
  63629. items: [{
  63630. $ref: "#/definitions/value"
  63631. }, {
  63632. type: "object",
  63633. properties: {
  63634. generators: {
  63635. $ref: "#/definitions/value"
  63636. }
  63637. },
  63638. additionalProperties: false
  63639. }]
  63640. },
  63641. messages: {
  63642. unnamed: "Unexpected unnamed {{name}}.",
  63643. named: "Unexpected named {{name}}."
  63644. }
  63645. },
  63646. create: function create(context) {
  63647. /**
  63648. * Returns the config option for the given node.
  63649. * @param {ASTNode} node - A node to get the config for.
  63650. * @returns {string} The config option.
  63651. */
  63652. function getConfigForNode(node) {
  63653. if (node.generator && context.options.length > 1 && context.options[1].generators) {
  63654. return context.options[1].generators;
  63655. }
  63656. return context.options[0] || "always";
  63657. }
  63658. /**
  63659. * Determines whether the current FunctionExpression node is a get, set, or
  63660. * shorthand method in an object literal or a class.
  63661. * @param {ASTNode} node - A node to check.
  63662. * @returns {boolean} True if the node is a get, set, or shorthand method.
  63663. */
  63664. function isObjectOrClassMethod(node) {
  63665. var parent = node.parent;
  63666. return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.method || parent.kind === "get" || parent.kind === "set");
  63667. }
  63668. /**
  63669. * Determines whether the current FunctionExpression node has a name that would be
  63670. * inferred from context in a conforming ES6 environment.
  63671. * @param {ASTNode} node - A node to check.
  63672. * @returns {boolean} True if the node would have a name assigned automatically.
  63673. */
  63674. function hasInferredName(node) {
  63675. var parent = node.parent;
  63676. return isObjectOrClassMethod(node) || parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node || parent.type === "Property" && parent.value === node || parent.type === "AssignmentExpression" && parent.left.type === "Identifier" && parent.right === node || parent.type === "ExportDefaultDeclaration" && parent.declaration === node || parent.type === "AssignmentPattern" && parent.right === node;
  63677. }
  63678. /**
  63679. * Reports that an unnamed function should be named
  63680. * @param {ASTNode} node - The node to report in the event of an error.
  63681. * @returns {void}
  63682. */
  63683. function reportUnexpectedUnnamedFunction(node) {
  63684. context.report({
  63685. node: node,
  63686. messageId: "unnamed",
  63687. data: { name: astUtils.getFunctionNameWithKind(node) }
  63688. });
  63689. }
  63690. /**
  63691. * Reports that a named function should be unnamed
  63692. * @param {ASTNode} node - The node to report in the event of an error.
  63693. * @returns {void}
  63694. */
  63695. function reportUnexpectedNamedFunction(node) {
  63696. context.report({
  63697. node: node,
  63698. messageId: "named",
  63699. data: { name: astUtils.getFunctionNameWithKind(node) }
  63700. });
  63701. }
  63702. return {
  63703. "FunctionExpression:exit": function FunctionExpressionExit(node) {
  63704. // Skip recursive functions.
  63705. var nameVar = context.getDeclaredVariables(node)[0];
  63706. if (isFunctionName(nameVar) && nameVar.references.length > 0) {
  63707. return;
  63708. }
  63709. var hasName = Boolean(node.id && node.id.name);
  63710. var config = getConfigForNode(node);
  63711. if (config === "never") {
  63712. if (hasName) {
  63713. reportUnexpectedNamedFunction(node);
  63714. }
  63715. } else if (config === "as-needed") {
  63716. if (!hasName && !hasInferredName(node)) {
  63717. reportUnexpectedUnnamedFunction(node);
  63718. }
  63719. } else {
  63720. if (!hasName && !isObjectOrClassMethod(node)) {
  63721. reportUnexpectedUnnamedFunction(node);
  63722. }
  63723. }
  63724. }
  63725. };
  63726. }
  63727. };
  63728. },{"../util/ast-utils":405}],158:[function(require,module,exports){
  63729. /**
  63730. * @fileoverview Rule to enforce a particular function style
  63731. * @author Nicholas C. Zakas
  63732. */
  63733. "use strict";
  63734. //------------------------------------------------------------------------------
  63735. // Rule Definition
  63736. //------------------------------------------------------------------------------
  63737. module.exports = {
  63738. meta: {
  63739. type: "suggestion",
  63740. docs: {
  63741. description: "enforce the consistent use of either `function` declarations or expressions",
  63742. category: "Stylistic Issues",
  63743. recommended: false,
  63744. url: "https://eslint.org/docs/rules/func-style"
  63745. },
  63746. schema: [{
  63747. enum: ["declaration", "expression"]
  63748. }, {
  63749. type: "object",
  63750. properties: {
  63751. allowArrowFunctions: {
  63752. type: "boolean"
  63753. }
  63754. },
  63755. additionalProperties: false
  63756. }],
  63757. messages: {
  63758. expression: "Expected a function expression.",
  63759. declaration: "Expected a function declaration."
  63760. }
  63761. },
  63762. create: function create(context) {
  63763. var style = context.options[0],
  63764. allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions === true,
  63765. enforceDeclarations = style === "declaration",
  63766. stack = [];
  63767. var nodesToCheck = {
  63768. FunctionDeclaration: function FunctionDeclaration(node) {
  63769. stack.push(false);
  63770. if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") {
  63771. context.report({ node: node, messageId: "expression" });
  63772. }
  63773. },
  63774. "FunctionDeclaration:exit": function FunctionDeclarationExit() {
  63775. stack.pop();
  63776. },
  63777. FunctionExpression: function FunctionExpression(node) {
  63778. stack.push(false);
  63779. if (enforceDeclarations && node.parent.type === "VariableDeclarator") {
  63780. context.report({ node: node.parent, messageId: "declaration" });
  63781. }
  63782. },
  63783. "FunctionExpression:exit": function FunctionExpressionExit() {
  63784. stack.pop();
  63785. },
  63786. ThisExpression: function ThisExpression() {
  63787. if (stack.length > 0) {
  63788. stack[stack.length - 1] = true;
  63789. }
  63790. }
  63791. };
  63792. if (!allowArrowFunctions) {
  63793. nodesToCheck.ArrowFunctionExpression = function () {
  63794. stack.push(false);
  63795. };
  63796. nodesToCheck["ArrowFunctionExpression:exit"] = function (node) {
  63797. var hasThisExpr = stack.pop();
  63798. if (enforceDeclarations && !hasThisExpr && node.parent.type === "VariableDeclarator") {
  63799. context.report({ node: node.parent, messageId: "declaration" });
  63800. }
  63801. };
  63802. }
  63803. return nodesToCheck;
  63804. }
  63805. };
  63806. },{}],159:[function(require,module,exports){
  63807. /**
  63808. * @fileoverview enforce consistent line breaks inside function parentheses
  63809. * @author Teddy Katz
  63810. */
  63811. "use strict";
  63812. //------------------------------------------------------------------------------
  63813. // Requirements
  63814. //------------------------------------------------------------------------------
  63815. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  63816. var astUtils = require("../util/ast-utils");
  63817. //------------------------------------------------------------------------------
  63818. // Rule Definition
  63819. //------------------------------------------------------------------------------
  63820. module.exports = {
  63821. meta: {
  63822. type: "layout",
  63823. docs: {
  63824. description: "enforce consistent line breaks inside function parentheses",
  63825. category: "Stylistic Issues",
  63826. recommended: false,
  63827. url: "https://eslint.org/docs/rules/function-paren-newline"
  63828. },
  63829. fixable: "whitespace",
  63830. schema: [{
  63831. oneOf: [{
  63832. enum: ["always", "never", "consistent", "multiline"]
  63833. }, {
  63834. type: "object",
  63835. properties: {
  63836. minItems: {
  63837. type: "integer",
  63838. minimum: 0
  63839. }
  63840. },
  63841. additionalProperties: false
  63842. }]
  63843. }],
  63844. messages: {
  63845. expectedBefore: "Expected newline before ')'.",
  63846. expectedAfter: "Expected newline after '('.",
  63847. unexpectedBefore: "Unexpected newline before '('.",
  63848. unexpectedAfter: "Unexpected newline after ')'."
  63849. }
  63850. },
  63851. create: function create(context) {
  63852. var sourceCode = context.getSourceCode();
  63853. var rawOption = context.options[0] || "multiline";
  63854. var multilineOption = rawOption === "multiline";
  63855. var consistentOption = rawOption === "consistent";
  63856. var minItems = void 0;
  63857. if ((typeof rawOption === "undefined" ? "undefined" : _typeof(rawOption)) === "object") {
  63858. minItems = rawOption.minItems;
  63859. } else if (rawOption === "always") {
  63860. minItems = 0;
  63861. } else if (rawOption === "never") {
  63862. minItems = Infinity;
  63863. } else {
  63864. minItems = null;
  63865. }
  63866. //----------------------------------------------------------------------
  63867. // Helpers
  63868. //----------------------------------------------------------------------
  63869. /**
  63870. * Determines whether there should be newlines inside function parens
  63871. * @param {ASTNode[]} elements The arguments or parameters in the list
  63872. * @param {boolean} hasLeftNewline `true` if the left paren has a newline in the current code.
  63873. * @returns {boolean} `true` if there should be newlines inside the function parens
  63874. */
  63875. function shouldHaveNewlines(elements, hasLeftNewline) {
  63876. if (multilineOption) {
  63877. return elements.some(function (element, index) {
  63878. return index !== elements.length - 1 && element.loc.end.line !== elements[index + 1].loc.start.line;
  63879. });
  63880. }
  63881. if (consistentOption) {
  63882. return hasLeftNewline;
  63883. }
  63884. return elements.length >= minItems;
  63885. }
  63886. /**
  63887. * Validates a list of arguments or parameters
  63888. * @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
  63889. * @param {ASTNode[]} elements The arguments or parameters in the list
  63890. * @returns {void}
  63891. */
  63892. function validateParens(parens, elements) {
  63893. var leftParen = parens.leftParen;
  63894. var rightParen = parens.rightParen;
  63895. var tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
  63896. var tokenBeforeRightParen = sourceCode.getTokenBefore(rightParen);
  63897. var hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
  63898. var hasRightNewline = !astUtils.isTokenOnSameLine(tokenBeforeRightParen, rightParen);
  63899. var needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
  63900. if (hasLeftNewline && !needsNewlines) {
  63901. context.report({
  63902. node: leftParen,
  63903. messageId: "unexpectedAfter",
  63904. fix: function fix(fixer) {
  63905. return sourceCode.getText().slice(leftParen.range[1], tokenAfterLeftParen.range[0]).trim()
  63906. // If there is a comment between the ( and the first element, don't do a fix.
  63907. ? null : fixer.removeRange([leftParen.range[1], tokenAfterLeftParen.range[0]]);
  63908. }
  63909. });
  63910. } else if (!hasLeftNewline && needsNewlines) {
  63911. context.report({
  63912. node: leftParen,
  63913. messageId: "expectedAfter",
  63914. fix: function fix(fixer) {
  63915. return fixer.insertTextAfter(leftParen, "\n");
  63916. }
  63917. });
  63918. }
  63919. if (hasRightNewline && !needsNewlines) {
  63920. context.report({
  63921. node: rightParen,
  63922. messageId: "unexpectedBefore",
  63923. fix: function fix(fixer) {
  63924. return sourceCode.getText().slice(tokenBeforeRightParen.range[1], rightParen.range[0]).trim()
  63925. // If there is a comment between the last element and the ), don't do a fix.
  63926. ? null : fixer.removeRange([tokenBeforeRightParen.range[1], rightParen.range[0]]);
  63927. }
  63928. });
  63929. } else if (!hasRightNewline && needsNewlines) {
  63930. context.report({
  63931. node: rightParen,
  63932. messageId: "expectedBefore",
  63933. fix: function fix(fixer) {
  63934. return fixer.insertTextBefore(rightParen, "\n");
  63935. }
  63936. });
  63937. }
  63938. }
  63939. /**
  63940. * Gets the left paren and right paren tokens of a node.
  63941. * @param {ASTNode} node The node with parens
  63942. * @returns {Object} An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token.
  63943. * Can also return `null` if an expression has no parens (e.g. a NewExpression with no arguments, or an ArrowFunctionExpression
  63944. * with a single parameter)
  63945. */
  63946. function getParenTokens(node) {
  63947. switch (node.type) {
  63948. case "NewExpression":
  63949. if (!node.arguments.length && !(astUtils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) && astUtils.isClosingParenToken(sourceCode.getLastToken(node)))) {
  63950. // If the NewExpression does not have parens (e.g. `new Foo`), return null.
  63951. return null;
  63952. }
  63953. // falls through
  63954. case "CallExpression":
  63955. return {
  63956. leftParen: sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken),
  63957. rightParen: sourceCode.getLastToken(node)
  63958. };
  63959. case "FunctionDeclaration":
  63960. case "FunctionExpression":
  63961. {
  63962. var leftParen = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
  63963. var rightParen = node.params.length ? sourceCode.getTokenAfter(node.params[node.params.length - 1], astUtils.isClosingParenToken) : sourceCode.getTokenAfter(leftParen);
  63964. return { leftParen: leftParen, rightParen: rightParen };
  63965. }
  63966. case "ArrowFunctionExpression":
  63967. {
  63968. var firstToken = sourceCode.getFirstToken(node);
  63969. if (!astUtils.isOpeningParenToken(firstToken)) {
  63970. // If the ArrowFunctionExpression has a single param without parens, return null.
  63971. return null;
  63972. }
  63973. return {
  63974. leftParen: firstToken,
  63975. rightParen: sourceCode.getTokenBefore(node.body, astUtils.isClosingParenToken)
  63976. };
  63977. }
  63978. default:
  63979. throw new TypeError("unexpected node with type " + node.type);
  63980. }
  63981. }
  63982. /**
  63983. * Validates the parentheses for a node
  63984. * @param {ASTNode} node The node with parens
  63985. * @returns {void}
  63986. */
  63987. function validateNode(node) {
  63988. var parens = getParenTokens(node);
  63989. if (parens) {
  63990. validateParens(parens, astUtils.isFunction(node) ? node.params : node.arguments);
  63991. }
  63992. }
  63993. //----------------------------------------------------------------------
  63994. // Public
  63995. //----------------------------------------------------------------------
  63996. return {
  63997. ArrowFunctionExpression: validateNode,
  63998. CallExpression: validateNode,
  63999. FunctionDeclaration: validateNode,
  64000. FunctionExpression: validateNode,
  64001. NewExpression: validateNode
  64002. };
  64003. }
  64004. };
  64005. },{"../util/ast-utils":405}],160:[function(require,module,exports){
  64006. /**
  64007. * @fileoverview Rule to check the spacing around the * in generator functions.
  64008. * @author Jamund Ferguson
  64009. */
  64010. "use strict";
  64011. //------------------------------------------------------------------------------
  64012. // Rule Definition
  64013. //------------------------------------------------------------------------------
  64014. var OVERRIDE_SCHEMA = {
  64015. oneOf: [{
  64016. enum: ["before", "after", "both", "neither"]
  64017. }, {
  64018. type: "object",
  64019. properties: {
  64020. before: { type: "boolean" },
  64021. after: { type: "boolean" }
  64022. },
  64023. additionalProperties: false
  64024. }]
  64025. };
  64026. module.exports = {
  64027. meta: {
  64028. type: "layout",
  64029. docs: {
  64030. description: "enforce consistent spacing around `*` operators in generator functions",
  64031. category: "ECMAScript 6",
  64032. recommended: false,
  64033. url: "https://eslint.org/docs/rules/generator-star-spacing"
  64034. },
  64035. fixable: "whitespace",
  64036. schema: [{
  64037. oneOf: [{
  64038. enum: ["before", "after", "both", "neither"]
  64039. }, {
  64040. type: "object",
  64041. properties: {
  64042. before: { type: "boolean" },
  64043. after: { type: "boolean" },
  64044. named: OVERRIDE_SCHEMA,
  64045. anonymous: OVERRIDE_SCHEMA,
  64046. method: OVERRIDE_SCHEMA
  64047. },
  64048. additionalProperties: false
  64049. }]
  64050. }],
  64051. messages: {
  64052. missingBefore: "Missing space before *.",
  64053. missingAfter: "Missing space after *.",
  64054. unexpectedBefore: "Unexpected space before *.",
  64055. unexpectedAfter: "Unexpected space after *."
  64056. }
  64057. },
  64058. create: function create(context) {
  64059. var optionDefinitions = {
  64060. before: { before: true, after: false },
  64061. after: { before: false, after: true },
  64062. both: { before: true, after: true },
  64063. neither: { before: false, after: false }
  64064. };
  64065. /**
  64066. * Returns resolved option definitions based on an option and defaults
  64067. *
  64068. * @param {any} option - The option object or string value
  64069. * @param {Object} defaults - The defaults to use if options are not present
  64070. * @returns {Object} the resolved object definition
  64071. */
  64072. function optionToDefinition(option, defaults) {
  64073. if (!option) {
  64074. return defaults;
  64075. }
  64076. return typeof option === "string" ? optionDefinitions[option] : Object.assign({}, defaults, option);
  64077. }
  64078. var modes = function (option) {
  64079. var defaults = optionToDefinition(option, optionDefinitions.before);
  64080. return {
  64081. named: optionToDefinition(option.named, defaults),
  64082. anonymous: optionToDefinition(option.anonymous, defaults),
  64083. method: optionToDefinition(option.method, defaults)
  64084. };
  64085. }(context.options[0] || {});
  64086. var sourceCode = context.getSourceCode();
  64087. /**
  64088. * Checks if the given token is a star token or not.
  64089. *
  64090. * @param {Token} token - The token to check.
  64091. * @returns {boolean} `true` if the token is a star token.
  64092. */
  64093. function isStarToken(token) {
  64094. return token.value === "*" && token.type === "Punctuator";
  64095. }
  64096. /**
  64097. * Gets the generator star token of the given function node.
  64098. *
  64099. * @param {ASTNode} node - The function node to get.
  64100. * @returns {Token} Found star token.
  64101. */
  64102. function getStarToken(node) {
  64103. return sourceCode.getFirstToken(node.parent.method || node.parent.type === "MethodDefinition" ? node.parent : node, isStarToken);
  64104. }
  64105. /**
  64106. * capitalize a given string.
  64107. * @param {string} str the given string.
  64108. * @returns {string} the capitalized string.
  64109. */
  64110. function capitalize(str) {
  64111. return str[0].toUpperCase() + str.slice(1);
  64112. }
  64113. /**
  64114. * Checks the spacing between two tokens before or after the star token.
  64115. *
  64116. * @param {string} kind Either "named", "anonymous", or "method"
  64117. * @param {string} side Either "before" or "after".
  64118. * @param {Token} leftToken `function` keyword token if side is "before", or
  64119. * star token if side is "after".
  64120. * @param {Token} rightToken Star token if side is "before", or identifier
  64121. * token if side is "after".
  64122. * @returns {void}
  64123. */
  64124. function checkSpacing(kind, side, leftToken, rightToken) {
  64125. if (!!(rightToken.range[0] - leftToken.range[1]) !== modes[kind][side]) {
  64126. var after = leftToken.value === "*";
  64127. var spaceRequired = modes[kind][side];
  64128. var node = after ? leftToken : rightToken;
  64129. var messageId = "" + (spaceRequired ? "missing" : "unexpected") + capitalize(side);
  64130. context.report({
  64131. node: node,
  64132. messageId: messageId,
  64133. fix: function fix(fixer) {
  64134. if (spaceRequired) {
  64135. if (after) {
  64136. return fixer.insertTextAfter(node, " ");
  64137. }
  64138. return fixer.insertTextBefore(node, " ");
  64139. }
  64140. return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
  64141. }
  64142. });
  64143. }
  64144. }
  64145. /**
  64146. * Enforces the spacing around the star if node is a generator function.
  64147. *
  64148. * @param {ASTNode} node A function expression or declaration node.
  64149. * @returns {void}
  64150. */
  64151. function checkFunction(node) {
  64152. if (!node.generator) {
  64153. return;
  64154. }
  64155. var starToken = getStarToken(node);
  64156. var prevToken = sourceCode.getTokenBefore(starToken);
  64157. var nextToken = sourceCode.getTokenAfter(starToken);
  64158. var kind = "named";
  64159. if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method) {
  64160. kind = "method";
  64161. } else if (!node.id) {
  64162. kind = "anonymous";
  64163. }
  64164. // Only check before when preceded by `function`|`static` keyword
  64165. if (!(kind === "method" && starToken === sourceCode.getFirstToken(node.parent))) {
  64166. checkSpacing(kind, "before", prevToken, starToken);
  64167. }
  64168. checkSpacing(kind, "after", starToken, nextToken);
  64169. }
  64170. return {
  64171. FunctionDeclaration: checkFunction,
  64172. FunctionExpression: checkFunction
  64173. };
  64174. }
  64175. };
  64176. },{}],161:[function(require,module,exports){
  64177. /**
  64178. * @fileoverview Enforces that a return statement is present in property getters.
  64179. * @author Aladdin-ADD(hh_2013@foxmail.com)
  64180. */
  64181. "use strict";
  64182. //------------------------------------------------------------------------------
  64183. // Requirements
  64184. //------------------------------------------------------------------------------
  64185. var astUtils = require("../util/ast-utils");
  64186. //------------------------------------------------------------------------------
  64187. // Helpers
  64188. //------------------------------------------------------------------------------
  64189. var TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/;
  64190. /**
  64191. * Checks a given code path segment is reachable.
  64192. *
  64193. * @param {CodePathSegment} segment - A segment to check.
  64194. * @returns {boolean} `true` if the segment is reachable.
  64195. */
  64196. function isReachable(segment) {
  64197. return segment.reachable;
  64198. }
  64199. /**
  64200. * Gets a readable location.
  64201. *
  64202. * - FunctionExpression -> the function name or `function` keyword.
  64203. *
  64204. * @param {ASTNode} node - A function node to get.
  64205. * @returns {ASTNode|Token} The node or the token of a location.
  64206. */
  64207. function getId(node) {
  64208. return node.id || node;
  64209. }
  64210. //------------------------------------------------------------------------------
  64211. // Rule Definition
  64212. //------------------------------------------------------------------------------
  64213. module.exports = {
  64214. meta: {
  64215. type: "problem",
  64216. docs: {
  64217. description: "enforce `return` statements in getters",
  64218. category: "Possible Errors",
  64219. recommended: true,
  64220. url: "https://eslint.org/docs/rules/getter-return"
  64221. },
  64222. fixable: null,
  64223. schema: [{
  64224. type: "object",
  64225. properties: {
  64226. allowImplicit: {
  64227. type: "boolean"
  64228. }
  64229. },
  64230. additionalProperties: false
  64231. }],
  64232. messages: {
  64233. expected: "Expected to return a value in {{name}}.",
  64234. expectedAlways: "Expected {{name}} to always return a value."
  64235. }
  64236. },
  64237. create: function create(context) {
  64238. var options = context.options[0] || { allowImplicit: false };
  64239. var funcInfo = {
  64240. upper: null,
  64241. codePath: null,
  64242. hasReturn: false,
  64243. shouldCheck: false,
  64244. node: null
  64245. };
  64246. /**
  64247. * Checks whether or not the last code path segment is reachable.
  64248. * Then reports this function if the segment is reachable.
  64249. *
  64250. * If the last code path segment is reachable, there are paths which are not
  64251. * returned or thrown.
  64252. *
  64253. * @param {ASTNode} node - A node to check.
  64254. * @returns {void}
  64255. */
  64256. function checkLastSegment(node) {
  64257. if (funcInfo.shouldCheck && funcInfo.codePath.currentSegments.some(isReachable)) {
  64258. context.report({
  64259. node: node,
  64260. loc: getId(node).loc.start,
  64261. messageId: funcInfo.hasReturn ? "expectedAlways" : "expected",
  64262. data: {
  64263. name: astUtils.getFunctionNameWithKind(funcInfo.node)
  64264. }
  64265. });
  64266. }
  64267. }
  64268. /**
  64269. * Checks whether a node means a getter function.
  64270. * @param {ASTNode} node - a node to check.
  64271. * @returns {boolean} if node means a getter, return true; else return false.
  64272. */
  64273. function isGetter(node) {
  64274. var parent = node.parent;
  64275. if (TARGET_NODE_TYPE.test(node.type) && node.body.type === "BlockStatement") {
  64276. if (parent.kind === "get") {
  64277. return true;
  64278. }
  64279. if (parent.type === "Property" && astUtils.getStaticPropertyName(parent) === "get" && parent.parent.type === "ObjectExpression") {
  64280. // Object.defineProperty()
  64281. if (parent.parent.parent.type === "CallExpression" && astUtils.getStaticPropertyName(parent.parent.parent.callee) === "defineProperty") {
  64282. return true;
  64283. }
  64284. // Object.defineProperties()
  64285. if (parent.parent.parent.type === "Property" && parent.parent.parent.parent.type === "ObjectExpression" && parent.parent.parent.parent.parent.type === "CallExpression" && astUtils.getStaticPropertyName(parent.parent.parent.parent.parent.callee) === "defineProperties") {
  64286. return true;
  64287. }
  64288. }
  64289. }
  64290. return false;
  64291. }
  64292. return {
  64293. // Stacks this function's information.
  64294. onCodePathStart: function onCodePathStart(codePath, node) {
  64295. funcInfo = {
  64296. upper: funcInfo,
  64297. codePath: codePath,
  64298. hasReturn: false,
  64299. shouldCheck: isGetter(node),
  64300. node: node
  64301. };
  64302. },
  64303. // Pops this function's information.
  64304. onCodePathEnd: function onCodePathEnd() {
  64305. funcInfo = funcInfo.upper;
  64306. },
  64307. // Checks the return statement is valid.
  64308. ReturnStatement: function ReturnStatement(node) {
  64309. if (funcInfo.shouldCheck) {
  64310. funcInfo.hasReturn = true;
  64311. // if allowImplicit: false, should also check node.argument
  64312. if (!options.allowImplicit && !node.argument) {
  64313. context.report({
  64314. node: node,
  64315. messageId: "expected",
  64316. data: {
  64317. name: astUtils.getFunctionNameWithKind(funcInfo.node)
  64318. }
  64319. });
  64320. }
  64321. }
  64322. },
  64323. // Reports a given function if the last path is reachable.
  64324. "FunctionExpression:exit": checkLastSegment,
  64325. "ArrowFunctionExpression:exit": checkLastSegment
  64326. };
  64327. }
  64328. };
  64329. },{"../util/ast-utils":405}],162:[function(require,module,exports){
  64330. /**
  64331. * @fileoverview Rule for disallowing require() outside of the top-level module context
  64332. * @author Jamund Ferguson
  64333. */
  64334. "use strict";
  64335. var ACCEPTABLE_PARENTS = ["AssignmentExpression", "VariableDeclarator", "MemberExpression", "ExpressionStatement", "CallExpression", "ConditionalExpression", "Program", "VariableDeclaration"];
  64336. /**
  64337. * Finds the eslint-scope reference in the given scope.
  64338. * @param {Object} scope The scope to search.
  64339. * @param {ASTNode} node The identifier node.
  64340. * @returns {Reference|null} Returns the found reference or null if none were found.
  64341. */
  64342. function findReference(scope, node) {
  64343. var references = scope.references.filter(function (reference) {
  64344. return reference.identifier.range[0] === node.range[0] && reference.identifier.range[1] === node.range[1];
  64345. });
  64346. /* istanbul ignore else: correctly returns null */
  64347. if (references.length === 1) {
  64348. return references[0];
  64349. }
  64350. return null;
  64351. }
  64352. /**
  64353. * Checks if the given identifier node is shadowed in the given scope.
  64354. * @param {Object} scope The current scope.
  64355. * @param {ASTNode} node The identifier node to check.
  64356. * @returns {boolean} Whether or not the name is shadowed.
  64357. */
  64358. function isShadowed(scope, node) {
  64359. var reference = findReference(scope, node);
  64360. return reference && reference.resolved && reference.resolved.defs.length > 0;
  64361. }
  64362. module.exports = {
  64363. meta: {
  64364. type: "suggestion",
  64365. docs: {
  64366. description: "require `require()` calls to be placed at top-level module scope",
  64367. category: "Node.js and CommonJS",
  64368. recommended: false,
  64369. url: "https://eslint.org/docs/rules/global-require"
  64370. },
  64371. schema: []
  64372. },
  64373. create: function create(context) {
  64374. return {
  64375. CallExpression: function CallExpression(node) {
  64376. var currentScope = context.getScope();
  64377. if (node.callee.name === "require" && !isShadowed(currentScope, node.callee)) {
  64378. var isGoodRequire = context.getAncestors().every(function (parent) {
  64379. return ACCEPTABLE_PARENTS.indexOf(parent.type) > -1;
  64380. });
  64381. if (!isGoodRequire) {
  64382. context.report({ node: node, message: "Unexpected require()." });
  64383. }
  64384. }
  64385. }
  64386. };
  64387. }
  64388. };
  64389. },{}],163:[function(require,module,exports){
  64390. /**
  64391. * @fileoverview Rule to flag for-in loops without if statements inside
  64392. * @author Nicholas C. Zakas
  64393. */
  64394. "use strict";
  64395. //------------------------------------------------------------------------------
  64396. // Rule Definition
  64397. //------------------------------------------------------------------------------
  64398. module.exports = {
  64399. meta: {
  64400. type: "suggestion",
  64401. docs: {
  64402. description: "require `for-in` loops to include an `if` statement",
  64403. category: "Best Practices",
  64404. recommended: false,
  64405. url: "https://eslint.org/docs/rules/guard-for-in"
  64406. },
  64407. schema: []
  64408. },
  64409. create: function create(context) {
  64410. return {
  64411. ForInStatement: function ForInStatement(node) {
  64412. var body = node.body;
  64413. // empty statement
  64414. if (body.type === "EmptyStatement") {
  64415. return;
  64416. }
  64417. // if statement
  64418. if (body.type === "IfStatement") {
  64419. return;
  64420. }
  64421. // empty block
  64422. if (body.type === "BlockStatement" && body.body.length === 0) {
  64423. return;
  64424. }
  64425. // block with just if statement
  64426. if (body.type === "BlockStatement" && body.body.length === 1 && body.body[0].type === "IfStatement") {
  64427. return;
  64428. }
  64429. // block that starts with if statement
  64430. if (body.type === "BlockStatement" && body.body.length >= 1 && body.body[0].type === "IfStatement") {
  64431. var i = body.body[0];
  64432. // ... whose consequent is a continue
  64433. if (i.consequent.type === "ContinueStatement") {
  64434. return;
  64435. }
  64436. // ... whose consequent is a block that contains only a continue
  64437. if (i.consequent.type === "BlockStatement" && i.consequent.body.length === 1 && i.consequent.body[0].type === "ContinueStatement") {
  64438. return;
  64439. }
  64440. }
  64441. context.report({ node: node, message: "The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype." });
  64442. }
  64443. };
  64444. }
  64445. };
  64446. },{}],164:[function(require,module,exports){
  64447. /**
  64448. * @fileoverview Ensure handling of errors when we know they exist.
  64449. * @author Jamund Ferguson
  64450. */
  64451. "use strict";
  64452. //------------------------------------------------------------------------------
  64453. // Rule Definition
  64454. //------------------------------------------------------------------------------
  64455. module.exports = {
  64456. meta: {
  64457. type: "suggestion",
  64458. docs: {
  64459. description: "require error handling in callbacks",
  64460. category: "Node.js and CommonJS",
  64461. recommended: false,
  64462. url: "https://eslint.org/docs/rules/handle-callback-err"
  64463. },
  64464. schema: [{
  64465. type: "string"
  64466. }]
  64467. },
  64468. create: function create(context) {
  64469. var errorArgument = context.options[0] || "err";
  64470. /**
  64471. * Checks if the given argument should be interpreted as a regexp pattern.
  64472. * @param {string} stringToCheck The string which should be checked.
  64473. * @returns {boolean} Whether or not the string should be interpreted as a pattern.
  64474. */
  64475. function isPattern(stringToCheck) {
  64476. var firstChar = stringToCheck[0];
  64477. return firstChar === "^";
  64478. }
  64479. /**
  64480. * Checks if the given name matches the configured error argument.
  64481. * @param {string} name The name which should be compared.
  64482. * @returns {boolean} Whether or not the given name matches the configured error variable name.
  64483. */
  64484. function matchesConfiguredErrorName(name) {
  64485. if (isPattern(errorArgument)) {
  64486. var regexp = new RegExp(errorArgument);
  64487. return regexp.test(name);
  64488. }
  64489. return name === errorArgument;
  64490. }
  64491. /**
  64492. * Get the parameters of a given function scope.
  64493. * @param {Object} scope The function scope.
  64494. * @returns {Array} All parameters of the given scope.
  64495. */
  64496. function getParameters(scope) {
  64497. return scope.variables.filter(function (variable) {
  64498. return variable.defs[0] && variable.defs[0].type === "Parameter";
  64499. });
  64500. }
  64501. /**
  64502. * Check to see if we're handling the error object properly.
  64503. * @param {ASTNode} node The AST node to check.
  64504. * @returns {void}
  64505. */
  64506. function checkForError(node) {
  64507. var scope = context.getScope(),
  64508. parameters = getParameters(scope),
  64509. firstParameter = parameters[0];
  64510. if (firstParameter && matchesConfiguredErrorName(firstParameter.name)) {
  64511. if (firstParameter.references.length === 0) {
  64512. context.report({ node: node, message: "Expected error to be handled." });
  64513. }
  64514. }
  64515. }
  64516. return {
  64517. FunctionDeclaration: checkForError,
  64518. FunctionExpression: checkForError,
  64519. ArrowFunctionExpression: checkForError
  64520. };
  64521. }
  64522. };
  64523. },{}],165:[function(require,module,exports){
  64524. /**
  64525. * @fileoverview Rule that warns when identifier names that are
  64526. * blacklisted in the configuration are used.
  64527. * @author Keith Cirkel (http://keithcirkel.co.uk)
  64528. */
  64529. "use strict";
  64530. //------------------------------------------------------------------------------
  64531. // Rule Definition
  64532. //------------------------------------------------------------------------------
  64533. module.exports = {
  64534. meta: {
  64535. type: "suggestion",
  64536. docs: {
  64537. description: "disallow specified identifiers",
  64538. category: "Stylistic Issues",
  64539. recommended: false,
  64540. url: "https://eslint.org/docs/rules/id-blacklist"
  64541. },
  64542. schema: {
  64543. type: "array",
  64544. items: {
  64545. type: "string"
  64546. },
  64547. uniqueItems: true
  64548. }
  64549. },
  64550. create: function create(context) {
  64551. //--------------------------------------------------------------------------
  64552. // Helpers
  64553. //--------------------------------------------------------------------------
  64554. var blacklist = context.options;
  64555. /**
  64556. * Checks if a string matches the provided pattern
  64557. * @param {string} name The string to check.
  64558. * @returns {boolean} if the string is a match
  64559. * @private
  64560. */
  64561. function isInvalid(name) {
  64562. return blacklist.indexOf(name) !== -1;
  64563. }
  64564. /**
  64565. * Verifies if we should report an error or not based on the effective
  64566. * parent node and the identifier name.
  64567. * @param {ASTNode} effectiveParent The effective parent node of the node to be reported
  64568. * @param {string} name The identifier name of the identifier node
  64569. * @returns {boolean} whether an error should be reported or not
  64570. */
  64571. function shouldReport(effectiveParent, name) {
  64572. return effectiveParent.type !== "CallExpression" && effectiveParent.type !== "NewExpression" && isInvalid(name);
  64573. }
  64574. /**
  64575. * Reports an AST node as a rule violation.
  64576. * @param {ASTNode} node The node to report.
  64577. * @returns {void}
  64578. * @private
  64579. */
  64580. function report(node) {
  64581. context.report({
  64582. node: node,
  64583. message: "Identifier '{{name}}' is blacklisted.",
  64584. data: {
  64585. name: node.name
  64586. }
  64587. });
  64588. }
  64589. return {
  64590. Identifier: function Identifier(node) {
  64591. var name = node.name,
  64592. effectiveParent = node.parent.type === "MemberExpression" ? node.parent.parent : node.parent;
  64593. // MemberExpressions get special rules
  64594. if (node.parent.type === "MemberExpression") {
  64595. // Always check object names
  64596. if (node.parent.object.type === "Identifier" && node.parent.object.name === node.name) {
  64597. if (isInvalid(name)) {
  64598. report(node);
  64599. }
  64600. // Report AssignmentExpressions only if they are the left side of the assignment
  64601. } else if (effectiveParent.type === "AssignmentExpression" && (effectiveParent.right.type !== "MemberExpression" || effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name)) {
  64602. if (isInvalid(name)) {
  64603. report(node);
  64604. }
  64605. }
  64606. // Properties have their own rules
  64607. } else if (node.parent.type === "Property") {
  64608. if (shouldReport(effectiveParent, name)) {
  64609. report(node);
  64610. }
  64611. // Report anything that is a match and not a CallExpression
  64612. } else if (shouldReport(effectiveParent, name)) {
  64613. report(node);
  64614. }
  64615. }
  64616. };
  64617. }
  64618. };
  64619. },{}],166:[function(require,module,exports){
  64620. /**
  64621. * @fileoverview Rule that warns when identifier names are shorter or longer
  64622. * than the values provided in configuration.
  64623. * @author Burak Yigit Kaya aka BYK
  64624. */
  64625. "use strict";
  64626. //------------------------------------------------------------------------------
  64627. // Rule Definition
  64628. //------------------------------------------------------------------------------
  64629. module.exports = {
  64630. meta: {
  64631. type: "suggestion",
  64632. docs: {
  64633. description: "enforce minimum and maximum identifier lengths",
  64634. category: "Stylistic Issues",
  64635. recommended: false,
  64636. url: "https://eslint.org/docs/rules/id-length"
  64637. },
  64638. schema: [{
  64639. type: "object",
  64640. properties: {
  64641. min: {
  64642. type: "number"
  64643. },
  64644. max: {
  64645. type: "number"
  64646. },
  64647. exceptions: {
  64648. type: "array",
  64649. uniqueItems: true,
  64650. items: {
  64651. type: "string"
  64652. }
  64653. },
  64654. properties: {
  64655. enum: ["always", "never"]
  64656. }
  64657. },
  64658. additionalProperties: false
  64659. }]
  64660. },
  64661. create: function create(context) {
  64662. var options = context.options[0] || {};
  64663. var minLength = typeof options.min !== "undefined" ? options.min : 2;
  64664. var maxLength = typeof options.max !== "undefined" ? options.max : Infinity;
  64665. var properties = options.properties !== "never";
  64666. var exceptions = (options.exceptions ? options.exceptions : []).reduce(function (obj, item) {
  64667. obj[item] = true;
  64668. return obj;
  64669. }, {});
  64670. var SUPPORTED_EXPRESSIONS = {
  64671. MemberExpression: properties && function (parent) {
  64672. return !parent.computed && (
  64673. // regular property assignment
  64674. parent.parent.left === parent && parent.parent.type === "AssignmentExpression" ||
  64675. // or the last identifier in an ObjectPattern destructuring
  64676. parent.parent.type === "Property" && parent.parent.value === parent && parent.parent.parent.type === "ObjectPattern" && parent.parent.parent.parent.left === parent.parent.parent);
  64677. },
  64678. AssignmentPattern: function AssignmentPattern(parent, node) {
  64679. return parent.left === node;
  64680. },
  64681. VariableDeclarator: function VariableDeclarator(parent, node) {
  64682. return parent.id === node;
  64683. },
  64684. Property: properties && function (parent, node) {
  64685. return parent.key === node;
  64686. },
  64687. ImportDefaultSpecifier: true,
  64688. RestElement: true,
  64689. FunctionExpression: true,
  64690. ArrowFunctionExpression: true,
  64691. ClassDeclaration: true,
  64692. FunctionDeclaration: true,
  64693. MethodDefinition: true,
  64694. CatchClause: true
  64695. };
  64696. return {
  64697. Identifier: function Identifier(node) {
  64698. var name = node.name;
  64699. var parent = node.parent;
  64700. var isShort = name.length < minLength;
  64701. var isLong = name.length > maxLength;
  64702. if (!(isShort || isLong) || exceptions[name]) {
  64703. return; // Nothing to report
  64704. }
  64705. var isValidExpression = SUPPORTED_EXPRESSIONS[parent.type];
  64706. if (isValidExpression && (isValidExpression === true || isValidExpression(parent, node))) {
  64707. context.report({
  64708. node: node,
  64709. message: isShort ? "Identifier name '{{name}}' is too short (< {{min}})." : "Identifier name '{{name}}' is too long (> {{max}}).",
  64710. data: { name: name, min: minLength, max: maxLength }
  64711. });
  64712. }
  64713. }
  64714. };
  64715. }
  64716. };
  64717. },{}],167:[function(require,module,exports){
  64718. /**
  64719. * @fileoverview Rule to flag non-matching identifiers
  64720. * @author Matthieu Larcher
  64721. */
  64722. "use strict";
  64723. //------------------------------------------------------------------------------
  64724. // Rule Definition
  64725. //------------------------------------------------------------------------------
  64726. module.exports = {
  64727. meta: {
  64728. type: "suggestion",
  64729. docs: {
  64730. description: "require identifiers to match a specified regular expression",
  64731. category: "Stylistic Issues",
  64732. recommended: false,
  64733. url: "https://eslint.org/docs/rules/id-match"
  64734. },
  64735. schema: [{
  64736. type: "string"
  64737. }, {
  64738. type: "object",
  64739. properties: {
  64740. properties: {
  64741. type: "boolean"
  64742. },
  64743. onlyDeclarations: {
  64744. type: "boolean"
  64745. },
  64746. ignoreDestructuring: {
  64747. type: "boolean"
  64748. }
  64749. }
  64750. }]
  64751. },
  64752. create: function create(context) {
  64753. //--------------------------------------------------------------------------
  64754. // Options
  64755. //--------------------------------------------------------------------------
  64756. var pattern = context.options[0] || "^.+$",
  64757. regexp = new RegExp(pattern);
  64758. var options = context.options[1] || {},
  64759. properties = !!options.properties,
  64760. onlyDeclarations = !!options.onlyDeclarations,
  64761. ignoreDestructuring = !!options.ignoreDestructuring;
  64762. //--------------------------------------------------------------------------
  64763. // Helpers
  64764. //--------------------------------------------------------------------------
  64765. // contains reported nodes to avoid reporting twice on destructuring with shorthand notation
  64766. var reported = new Map();
  64767. var ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]);
  64768. var DECLARATION_TYPES = new Set(["FunctionDeclaration", "VariableDeclarator"]);
  64769. var IMPORT_TYPES = new Set(["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"]);
  64770. /**
  64771. * Checks if a string matches the provided pattern
  64772. * @param {string} name The string to check.
  64773. * @returns {boolean} if the string is a match
  64774. * @private
  64775. */
  64776. function isInvalid(name) {
  64777. return !regexp.test(name);
  64778. }
  64779. /**
  64780. * Checks if a parent of a node is an ObjectPattern.
  64781. * @param {ASTNode} node The node to check.
  64782. * @returns {boolean} if the node is inside an ObjectPattern
  64783. * @private
  64784. */
  64785. function isInsideObjectPattern(node) {
  64786. var parent = node.parent;
  64787. while (parent) {
  64788. if (parent.type === "ObjectPattern") {
  64789. return true;
  64790. }
  64791. parent = parent.parent;
  64792. }
  64793. return false;
  64794. }
  64795. /**
  64796. * Verifies if we should report an error or not based on the effective
  64797. * parent node and the identifier name.
  64798. * @param {ASTNode} effectiveParent The effective parent node of the node to be reported
  64799. * @param {string} name The identifier name of the identifier node
  64800. * @returns {boolean} whether an error should be reported or not
  64801. */
  64802. function shouldReport(effectiveParent, name) {
  64803. return (!onlyDeclarations || DECLARATION_TYPES.has(effectiveParent.type)) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && isInvalid(name);
  64804. }
  64805. /**
  64806. * Reports an AST node as a rule violation.
  64807. * @param {ASTNode} node The node to report.
  64808. * @returns {void}
  64809. * @private
  64810. */
  64811. function report(node) {
  64812. if (!reported.has(node)) {
  64813. context.report({
  64814. node: node,
  64815. message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.",
  64816. data: {
  64817. name: node.name,
  64818. pattern: pattern
  64819. }
  64820. });
  64821. reported.set(node, true);
  64822. }
  64823. }
  64824. return {
  64825. Identifier: function Identifier(node) {
  64826. var name = node.name,
  64827. parent = node.parent,
  64828. effectiveParent = parent.type === "MemberExpression" ? parent.parent : parent;
  64829. if (parent.type === "MemberExpression") {
  64830. if (!properties) {
  64831. return;
  64832. }
  64833. // Always check object names
  64834. if (parent.object.type === "Identifier" && parent.object.name === name) {
  64835. if (isInvalid(name)) {
  64836. report(node);
  64837. }
  64838. // Report AssignmentExpressions left side's assigned variable id
  64839. } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name) {
  64840. if (isInvalid(name)) {
  64841. report(node);
  64842. }
  64843. // Report AssignmentExpressions only if they are the left side of the assignment
  64844. } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.right.type !== "MemberExpression") {
  64845. if (isInvalid(name)) {
  64846. report(node);
  64847. }
  64848. }
  64849. /*
  64850. * Properties have their own rules, and
  64851. * AssignmentPattern nodes can be treated like Properties:
  64852. * e.g.: const { no_camelcased = false } = bar;
  64853. */
  64854. } else if (parent.type === "Property" || parent.type === "AssignmentPattern") {
  64855. if (parent.parent && parent.parent.type === "ObjectPattern") {
  64856. if (parent.shorthand && parent.value.left && isInvalid(name)) {
  64857. report(node);
  64858. }
  64859. var assignmentKeyEqualsValue = parent.key.name === parent.value.name;
  64860. // prevent checking righthand side of destructured object
  64861. if (!assignmentKeyEqualsValue && parent.key === node) {
  64862. return;
  64863. }
  64864. var valueIsInvalid = parent.value.name && isInvalid(name);
  64865. // ignore destructuring if the option is set, unless a new identifier is created
  64866. if (valueIsInvalid && !(assignmentKeyEqualsValue && ignoreDestructuring)) {
  64867. report(node);
  64868. }
  64869. }
  64870. // never check properties or always ignore destructuring
  64871. if (!properties || ignoreDestructuring && isInsideObjectPattern(node)) {
  64872. return;
  64873. }
  64874. // don't check right hand side of AssignmentExpression to prevent duplicate warnings
  64875. if (parent.right !== node && shouldReport(effectiveParent, name)) {
  64876. report(node);
  64877. }
  64878. // Check if it's an import specifier
  64879. } else if (IMPORT_TYPES.has(parent.type)) {
  64880. // Report only if the local imported identifier is invalid
  64881. if (parent.local && parent.local.name === node.name && isInvalid(name)) {
  64882. report(node);
  64883. }
  64884. // Report anything that is invalid that isn't a CallExpression
  64885. } else if (shouldReport(effectiveParent, name)) {
  64886. report(node);
  64887. }
  64888. }
  64889. };
  64890. }
  64891. };
  64892. },{}],168:[function(require,module,exports){
  64893. /**
  64894. * @fileoverview enforce the location of arrow function bodies
  64895. * @author Sharmila Jesupaul
  64896. */
  64897. "use strict";
  64898. var _require = require("../util/ast-utils"),
  64899. isArrowToken = _require.isArrowToken,
  64900. isParenthesised = _require.isParenthesised,
  64901. isOpeningParenToken = _require.isOpeningParenToken;
  64902. //------------------------------------------------------------------------------
  64903. // Rule Definition
  64904. //------------------------------------------------------------------------------
  64905. module.exports = {
  64906. meta: {
  64907. type: "layout",
  64908. docs: {
  64909. description: "enforce the location of arrow function bodies",
  64910. category: "Stylistic Issues",
  64911. recommended: false,
  64912. url: "https://eslint.org/docs/rules/implicit-arrow-linebreak"
  64913. },
  64914. fixable: "whitespace",
  64915. schema: [{
  64916. enum: ["beside", "below"]
  64917. }]
  64918. },
  64919. create: function create(context) {
  64920. var sourceCode = context.getSourceCode();
  64921. //----------------------------------------------------------------------
  64922. // Helpers
  64923. //----------------------------------------------------------------------
  64924. /**
  64925. * Gets the applicable preference for a particular keyword
  64926. * @returns {string} The applicable option for the keyword, e.g. 'beside'
  64927. */
  64928. function getOption() {
  64929. return context.options[0] || "beside";
  64930. }
  64931. /**
  64932. * Formats the comments depending on whether it's a line or block comment.
  64933. * @param {Comment[]} comments The array of comments between the arrow and body
  64934. * @param {Integer} column The column number of the first token
  64935. * @returns {string} A string of comment text joined by line breaks
  64936. */
  64937. function formatComments(comments, column) {
  64938. var whiteSpaces = " ".repeat(column);
  64939. return comments.map(function (comment) {
  64940. if (comment.type === "Line") {
  64941. return "//" + comment.value;
  64942. }
  64943. return "/*" + comment.value + "*/";
  64944. }).join("\n" + whiteSpaces) + "\n" + whiteSpaces;
  64945. }
  64946. /**
  64947. * Finds the first token to prepend comments to depending on the parent type
  64948. * @param {Node} node The validated node
  64949. * @returns {Token|Node} The node to prepend comments to
  64950. */
  64951. function findFirstToken(node) {
  64952. switch (node.parent.type) {
  64953. case "VariableDeclarator":
  64954. // If the parent is first or only declarator, return the declaration, else, declarator
  64955. return sourceCode.getFirstToken(node.parent.parent.declarations.length === 1 || node.parent.parent.declarations[0].id.name === node.parent.id.name ? node.parent.parent : node.parent);
  64956. case "CallExpression":
  64957. case "Property":
  64958. // find the object key
  64959. return sourceCode.getFirstToken(node.parent);
  64960. default:
  64961. return node;
  64962. }
  64963. }
  64964. /**
  64965. * Helper function for adding parentheses fixes for nodes containing nested arrow functions
  64966. * @param {Fixer} fixer Fixer
  64967. * @param {Token} arrow - The arrow token
  64968. * @param {ASTNode} arrowBody - The arrow function body
  64969. * @returns {Function[]} autofixer -- wraps function bodies with parentheses
  64970. */
  64971. function addParentheses(fixer, arrow, arrowBody) {
  64972. var parenthesesFixes = [];
  64973. var closingParentheses = "";
  64974. var followingBody = arrowBody;
  64975. var currentArrow = arrow;
  64976. while (currentArrow) {
  64977. if (!isParenthesised(sourceCode, followingBody)) {
  64978. parenthesesFixes.push(fixer.insertTextAfter(currentArrow, " ("));
  64979. var paramsToken = sourceCode.getTokenBefore(currentArrow, function (token) {
  64980. return isOpeningParenToken(token) || token.type === "Identifier";
  64981. });
  64982. var whiteSpaces = " ".repeat(paramsToken.loc.start.column);
  64983. closingParentheses = "\n" + whiteSpaces + ")" + closingParentheses;
  64984. }
  64985. currentArrow = sourceCode.getTokenAfter(currentArrow, isArrowToken);
  64986. if (currentArrow) {
  64987. followingBody = sourceCode.getTokenAfter(currentArrow, function (token) {
  64988. return !isOpeningParenToken(token);
  64989. });
  64990. }
  64991. }
  64992. return [].concat(parenthesesFixes, [fixer.insertTextAfter(arrowBody, closingParentheses)]);
  64993. }
  64994. /**
  64995. * Autofixes the function body to collapse onto the same line as the arrow.
  64996. * If comments exist, prepends the comments before the arrow function.
  64997. * If the function body contains arrow functions, appends the function bodies with parentheses.
  64998. * @param {Token} arrowToken The arrow token.
  64999. * @param {ASTNode} arrowBody the function body
  65000. * @param {ASTNode} node The evaluated node
  65001. * @returns {Function} autofixer -- validates the node to adhere to besides
  65002. */
  65003. function autoFixBesides(arrowToken, arrowBody, node) {
  65004. return function (fixer) {
  65005. var placeBesides = fixer.replaceTextRange([arrowToken.range[1], arrowBody.range[0]], " ");
  65006. var comments = sourceCode.getCommentsInside(node).filter(function (comment) {
  65007. return comment.loc.start.line < arrowBody.loc.start.line;
  65008. });
  65009. if (comments.length) {
  65010. // If the grandparent is not a variable declarator
  65011. if (arrowBody.parent && arrowBody.parent.parent && arrowBody.parent.parent.type !== "VariableDeclarator") {
  65012. // If any arrow functions follow, return the necessary parens fixes.
  65013. if (sourceCode.getTokenAfter(arrowToken, isArrowToken) && arrowBody.parent.parent.type !== "VariableDeclarator") {
  65014. return addParentheses(fixer, arrowToken, arrowBody);
  65015. }
  65016. // If any arrow functions precede, the necessary fixes have already been returned, so return null.
  65017. if (sourceCode.getTokenBefore(arrowToken, isArrowToken) && arrowBody.parent.parent.type !== "VariableDeclarator") {
  65018. return null;
  65019. }
  65020. }
  65021. var firstToken = findFirstToken(node);
  65022. var commentText = formatComments(comments, firstToken.loc.start.column);
  65023. var commentBeforeExpression = fixer.insertTextBeforeRange(firstToken.range, commentText);
  65024. return [placeBesides, commentBeforeExpression];
  65025. }
  65026. return placeBesides;
  65027. };
  65028. }
  65029. /**
  65030. * Validates the location of an arrow function body
  65031. * @param {ASTNode} node The arrow function body
  65032. * @returns {void}
  65033. */
  65034. function validateExpression(node) {
  65035. var option = getOption();
  65036. var tokenBefore = sourceCode.getTokenBefore(node.body);
  65037. var hasParens = tokenBefore.value === "(";
  65038. if (node.type === "BlockStatement") {
  65039. return;
  65040. }
  65041. var fixerTarget = node.body;
  65042. if (hasParens) {
  65043. // Gets the first token before the function body that is not an open paren
  65044. tokenBefore = sourceCode.getTokenBefore(node.body, function (token) {
  65045. return token.value !== "(";
  65046. });
  65047. fixerTarget = sourceCode.getTokenAfter(tokenBefore);
  65048. }
  65049. if (tokenBefore.loc.end.line === fixerTarget.loc.start.line && option === "below") {
  65050. context.report({
  65051. node: fixerTarget,
  65052. message: "Expected a linebreak before this expression.",
  65053. fix: function fix(fixer) {
  65054. return fixer.insertTextBefore(fixerTarget, "\n");
  65055. }
  65056. });
  65057. } else if (tokenBefore.loc.end.line !== fixerTarget.loc.start.line && option === "beside") {
  65058. context.report({
  65059. node: fixerTarget,
  65060. message: "Expected no linebreak before this expression.",
  65061. fix: autoFixBesides(tokenBefore, fixerTarget, node)
  65062. });
  65063. }
  65064. }
  65065. //----------------------------------------------------------------------
  65066. // Public
  65067. //----------------------------------------------------------------------
  65068. return {
  65069. ArrowFunctionExpression: function ArrowFunctionExpression(node) {
  65070. return validateExpression(node);
  65071. }
  65072. };
  65073. }
  65074. };
  65075. },{"../util/ast-utils":405}],169:[function(require,module,exports){
  65076. /**
  65077. * @fileoverview This option sets a specific tab width for your code
  65078. *
  65079. * This rule has been ported and modified from nodeca.
  65080. * @author Vitaly Puzrin
  65081. * @author Gyandeep Singh
  65082. */
  65083. "use strict";
  65084. //------------------------------------------------------------------------------
  65085. // Requirements
  65086. //------------------------------------------------------------------------------
  65087. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  65088. var astUtils = require("../util/ast-utils");
  65089. //------------------------------------------------------------------------------
  65090. // Rule Definition
  65091. //------------------------------------------------------------------------------
  65092. /* istanbul ignore next: this rule has known coverage issues, but it's deprecated and shouldn't be updated in the future anyway. */
  65093. module.exports = {
  65094. meta: {
  65095. type: "layout",
  65096. docs: {
  65097. description: "enforce consistent indentation",
  65098. category: "Stylistic Issues",
  65099. recommended: false,
  65100. url: "https://eslint.org/docs/rules/indent-legacy"
  65101. },
  65102. deprecated: true,
  65103. replacedBy: ["indent"],
  65104. fixable: "whitespace",
  65105. schema: [{
  65106. oneOf: [{
  65107. enum: ["tab"]
  65108. }, {
  65109. type: "integer",
  65110. minimum: 0
  65111. }]
  65112. }, {
  65113. type: "object",
  65114. properties: {
  65115. SwitchCase: {
  65116. type: "integer",
  65117. minimum: 0
  65118. },
  65119. VariableDeclarator: {
  65120. oneOf: [{
  65121. type: "integer",
  65122. minimum: 0
  65123. }, {
  65124. type: "object",
  65125. properties: {
  65126. var: {
  65127. type: "integer",
  65128. minimum: 0
  65129. },
  65130. let: {
  65131. type: "integer",
  65132. minimum: 0
  65133. },
  65134. const: {
  65135. type: "integer",
  65136. minimum: 0
  65137. }
  65138. }
  65139. }]
  65140. },
  65141. outerIIFEBody: {
  65142. type: "integer",
  65143. minimum: 0
  65144. },
  65145. MemberExpression: {
  65146. type: "integer",
  65147. minimum: 0
  65148. },
  65149. FunctionDeclaration: {
  65150. type: "object",
  65151. properties: {
  65152. parameters: {
  65153. oneOf: [{
  65154. type: "integer",
  65155. minimum: 0
  65156. }, {
  65157. enum: ["first"]
  65158. }]
  65159. },
  65160. body: {
  65161. type: "integer",
  65162. minimum: 0
  65163. }
  65164. }
  65165. },
  65166. FunctionExpression: {
  65167. type: "object",
  65168. properties: {
  65169. parameters: {
  65170. oneOf: [{
  65171. type: "integer",
  65172. minimum: 0
  65173. }, {
  65174. enum: ["first"]
  65175. }]
  65176. },
  65177. body: {
  65178. type: "integer",
  65179. minimum: 0
  65180. }
  65181. }
  65182. },
  65183. CallExpression: {
  65184. type: "object",
  65185. properties: {
  65186. parameters: {
  65187. oneOf: [{
  65188. type: "integer",
  65189. minimum: 0
  65190. }, {
  65191. enum: ["first"]
  65192. }]
  65193. }
  65194. }
  65195. },
  65196. ArrayExpression: {
  65197. oneOf: [{
  65198. type: "integer",
  65199. minimum: 0
  65200. }, {
  65201. enum: ["first"]
  65202. }]
  65203. },
  65204. ObjectExpression: {
  65205. oneOf: [{
  65206. type: "integer",
  65207. minimum: 0
  65208. }, {
  65209. enum: ["first"]
  65210. }]
  65211. }
  65212. },
  65213. additionalProperties: false
  65214. }]
  65215. },
  65216. create: function create(context) {
  65217. var DEFAULT_VARIABLE_INDENT = 1;
  65218. var DEFAULT_PARAMETER_INDENT = null; // For backwards compatibility, don't check parameter indentation unless specified in the config
  65219. var DEFAULT_FUNCTION_BODY_INDENT = 1;
  65220. var indentType = "space";
  65221. var indentSize = 4;
  65222. var options = {
  65223. SwitchCase: 0,
  65224. VariableDeclarator: {
  65225. var: DEFAULT_VARIABLE_INDENT,
  65226. let: DEFAULT_VARIABLE_INDENT,
  65227. const: DEFAULT_VARIABLE_INDENT
  65228. },
  65229. outerIIFEBody: null,
  65230. FunctionDeclaration: {
  65231. parameters: DEFAULT_PARAMETER_INDENT,
  65232. body: DEFAULT_FUNCTION_BODY_INDENT
  65233. },
  65234. FunctionExpression: {
  65235. parameters: DEFAULT_PARAMETER_INDENT,
  65236. body: DEFAULT_FUNCTION_BODY_INDENT
  65237. },
  65238. CallExpression: {
  65239. arguments: DEFAULT_PARAMETER_INDENT
  65240. },
  65241. ArrayExpression: 1,
  65242. ObjectExpression: 1
  65243. };
  65244. var sourceCode = context.getSourceCode();
  65245. if (context.options.length) {
  65246. if (context.options[0] === "tab") {
  65247. indentSize = 1;
  65248. indentType = "tab";
  65249. } else /* istanbul ignore else : this will be caught by options validation */if (typeof context.options[0] === "number") {
  65250. indentSize = context.options[0];
  65251. indentType = "space";
  65252. }
  65253. if (context.options[1]) {
  65254. var opts = context.options[1];
  65255. options.SwitchCase = opts.SwitchCase || 0;
  65256. var variableDeclaratorRules = opts.VariableDeclarator;
  65257. if (typeof variableDeclaratorRules === "number") {
  65258. options.VariableDeclarator = {
  65259. var: variableDeclaratorRules,
  65260. let: variableDeclaratorRules,
  65261. const: variableDeclaratorRules
  65262. };
  65263. } else if ((typeof variableDeclaratorRules === "undefined" ? "undefined" : _typeof(variableDeclaratorRules)) === "object") {
  65264. Object.assign(options.VariableDeclarator, variableDeclaratorRules);
  65265. }
  65266. if (typeof opts.outerIIFEBody === "number") {
  65267. options.outerIIFEBody = opts.outerIIFEBody;
  65268. }
  65269. if (typeof opts.MemberExpression === "number") {
  65270. options.MemberExpression = opts.MemberExpression;
  65271. }
  65272. if (_typeof(opts.FunctionDeclaration) === "object") {
  65273. Object.assign(options.FunctionDeclaration, opts.FunctionDeclaration);
  65274. }
  65275. if (_typeof(opts.FunctionExpression) === "object") {
  65276. Object.assign(options.FunctionExpression, opts.FunctionExpression);
  65277. }
  65278. if (_typeof(opts.CallExpression) === "object") {
  65279. Object.assign(options.CallExpression, opts.CallExpression);
  65280. }
  65281. if (typeof opts.ArrayExpression === "number" || typeof opts.ArrayExpression === "string") {
  65282. options.ArrayExpression = opts.ArrayExpression;
  65283. }
  65284. if (typeof opts.ObjectExpression === "number" || typeof opts.ObjectExpression === "string") {
  65285. options.ObjectExpression = opts.ObjectExpression;
  65286. }
  65287. }
  65288. }
  65289. var caseIndentStore = {};
  65290. /**
  65291. * Creates an error message for a line, given the expected/actual indentation.
  65292. * @param {int} expectedAmount The expected amount of indentation characters for this line
  65293. * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
  65294. * @param {int} actualTabs The actual number of indentation tabs that were found on this line
  65295. * @returns {string} An error message for this line
  65296. */
  65297. function createErrorMessage(expectedAmount, actualSpaces, actualTabs) {
  65298. var expectedStatement = expectedAmount + " " + indentType + (expectedAmount === 1 ? "" : "s"); // e.g. "2 tabs"
  65299. var foundSpacesWord = "space" + (actualSpaces === 1 ? "" : "s"); // e.g. "space"
  65300. var foundTabsWord = "tab" + (actualTabs === 1 ? "" : "s"); // e.g. "tabs"
  65301. var foundStatement = void 0;
  65302. if (actualSpaces > 0 && actualTabs > 0) {
  65303. foundStatement = actualSpaces + " " + foundSpacesWord + " and " + actualTabs + " " + foundTabsWord; // e.g. "1 space and 2 tabs"
  65304. } else if (actualSpaces > 0) {
  65305. /*
  65306. * Abbreviate the message if the expected indentation is also spaces.
  65307. * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces'
  65308. */
  65309. foundStatement = indentType === "space" ? actualSpaces : actualSpaces + " " + foundSpacesWord;
  65310. } else if (actualTabs > 0) {
  65311. foundStatement = indentType === "tab" ? actualTabs : actualTabs + " " + foundTabsWord;
  65312. } else {
  65313. foundStatement = "0";
  65314. }
  65315. return "Expected indentation of " + expectedStatement + " but found " + foundStatement + ".";
  65316. }
  65317. /**
  65318. * Reports a given indent violation
  65319. * @param {ASTNode} node Node violating the indent rule
  65320. * @param {int} needed Expected indentation character count
  65321. * @param {int} gottenSpaces Indentation space count in the actual node/code
  65322. * @param {int} gottenTabs Indentation tab count in the actual node/code
  65323. * @param {Object=} loc Error line and column location
  65324. * @param {boolean} isLastNodeCheck Is the error for last node check
  65325. * @returns {void}
  65326. */
  65327. function report(node, needed, gottenSpaces, gottenTabs, loc, isLastNodeCheck) {
  65328. if (gottenSpaces && gottenTabs) {
  65329. // To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines that have both spaces and tabs.
  65330. return;
  65331. }
  65332. var desiredIndent = (indentType === "space" ? " " : "\t").repeat(needed);
  65333. var textRange = isLastNodeCheck ? [node.range[1] - node.loc.end.column, node.range[1] - node.loc.end.column + gottenSpaces + gottenTabs] : [node.range[0] - node.loc.start.column, node.range[0] - node.loc.start.column + gottenSpaces + gottenTabs];
  65334. context.report({
  65335. node: node,
  65336. loc: loc,
  65337. message: createErrorMessage(needed, gottenSpaces, gottenTabs),
  65338. fix: function fix(fixer) {
  65339. return fixer.replaceTextRange(textRange, desiredIndent);
  65340. }
  65341. });
  65342. }
  65343. /**
  65344. * Get the actual indent of node
  65345. * @param {ASTNode|Token} node Node to examine
  65346. * @param {boolean} [byLastLine=false] get indent of node's last line
  65347. * @returns {Object} The node's indent. Contains keys `space` and `tab`, representing the indent of each character. Also
  65348. * contains keys `goodChar` and `badChar`, where `goodChar` is the amount of the user's desired indentation character, and
  65349. * `badChar` is the amount of the other indentation character.
  65350. */
  65351. function getNodeIndent(node, byLastLine) {
  65352. var token = byLastLine ? sourceCode.getLastToken(node) : sourceCode.getFirstToken(node);
  65353. var srcCharsBeforeNode = sourceCode.getText(token, token.loc.start.column).split("");
  65354. var indentChars = srcCharsBeforeNode.slice(0, srcCharsBeforeNode.findIndex(function (char) {
  65355. return char !== " " && char !== "\t";
  65356. }));
  65357. var spaces = indentChars.filter(function (char) {
  65358. return char === " ";
  65359. }).length;
  65360. var tabs = indentChars.filter(function (char) {
  65361. return char === "\t";
  65362. }).length;
  65363. return {
  65364. space: spaces,
  65365. tab: tabs,
  65366. goodChar: indentType === "space" ? spaces : tabs,
  65367. badChar: indentType === "space" ? tabs : spaces
  65368. };
  65369. }
  65370. /**
  65371. * Checks node is the first in its own start line. By default it looks by start line.
  65372. * @param {ASTNode} node The node to check
  65373. * @param {boolean} [byEndLocation=false] Lookup based on start position or end
  65374. * @returns {boolean} true if its the first in the its start line
  65375. */
  65376. function isNodeFirstInLine(node, byEndLocation) {
  65377. var firstToken = byEndLocation === true ? sourceCode.getLastToken(node, 1) : sourceCode.getTokenBefore(node),
  65378. startLine = byEndLocation === true ? node.loc.end.line : node.loc.start.line,
  65379. endLine = firstToken ? firstToken.loc.end.line : -1;
  65380. return startLine !== endLine;
  65381. }
  65382. /**
  65383. * Check indent for node
  65384. * @param {ASTNode} node Node to check
  65385. * @param {int} neededIndent needed indent
  65386. * @returns {void}
  65387. */
  65388. function checkNodeIndent(node, neededIndent) {
  65389. var actualIndent = getNodeIndent(node, false);
  65390. if (node.type !== "ArrayExpression" && node.type !== "ObjectExpression" && (actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) && isNodeFirstInLine(node)) {
  65391. report(node, neededIndent, actualIndent.space, actualIndent.tab);
  65392. }
  65393. if (node.type === "IfStatement" && node.alternate) {
  65394. var elseToken = sourceCode.getTokenBefore(node.alternate);
  65395. checkNodeIndent(elseToken, neededIndent);
  65396. if (!isNodeFirstInLine(node.alternate)) {
  65397. checkNodeIndent(node.alternate, neededIndent);
  65398. }
  65399. }
  65400. if (node.type === "TryStatement" && node.handler) {
  65401. var catchToken = sourceCode.getFirstToken(node.handler);
  65402. checkNodeIndent(catchToken, neededIndent);
  65403. }
  65404. if (node.type === "TryStatement" && node.finalizer) {
  65405. var finallyToken = sourceCode.getTokenBefore(node.finalizer);
  65406. checkNodeIndent(finallyToken, neededIndent);
  65407. }
  65408. if (node.type === "DoWhileStatement") {
  65409. var whileToken = sourceCode.getTokenAfter(node.body);
  65410. checkNodeIndent(whileToken, neededIndent);
  65411. }
  65412. }
  65413. /**
  65414. * Check indent for nodes list
  65415. * @param {ASTNode[]} nodes list of node objects
  65416. * @param {int} indent needed indent
  65417. * @returns {void}
  65418. */
  65419. function checkNodesIndent(nodes, indent) {
  65420. nodes.forEach(function (node) {
  65421. return checkNodeIndent(node, indent);
  65422. });
  65423. }
  65424. /**
  65425. * Check last node line indent this detects, that block closed correctly
  65426. * @param {ASTNode} node Node to examine
  65427. * @param {int} lastLineIndent needed indent
  65428. * @returns {void}
  65429. */
  65430. function checkLastNodeLineIndent(node, lastLineIndent) {
  65431. var lastToken = sourceCode.getLastToken(node);
  65432. var endIndent = getNodeIndent(lastToken, true);
  65433. if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) {
  65434. report(node, lastLineIndent, endIndent.space, endIndent.tab, { line: lastToken.loc.start.line, column: lastToken.loc.start.column }, true);
  65435. }
  65436. }
  65437. /**
  65438. * Check last node line indent this detects, that block closed correctly
  65439. * This function for more complicated return statement case, where closing parenthesis may be followed by ';'
  65440. * @param {ASTNode} node Node to examine
  65441. * @param {int} firstLineIndent first line needed indent
  65442. * @returns {void}
  65443. */
  65444. function checkLastReturnStatementLineIndent(node, firstLineIndent) {
  65445. /*
  65446. * in case if return statement ends with ');' we have traverse back to ')'
  65447. * otherwise we'll measure indent for ';' and replace ')'
  65448. */
  65449. var lastToken = sourceCode.getLastToken(node, astUtils.isClosingParenToken);
  65450. var textBeforeClosingParenthesis = sourceCode.getText(lastToken, lastToken.loc.start.column).slice(0, -1);
  65451. if (textBeforeClosingParenthesis.trim()) {
  65452. // There are tokens before the closing paren, don't report this case
  65453. return;
  65454. }
  65455. var endIndent = getNodeIndent(lastToken, true);
  65456. if (endIndent.goodChar !== firstLineIndent) {
  65457. report(node, firstLineIndent, endIndent.space, endIndent.tab, { line: lastToken.loc.start.line, column: lastToken.loc.start.column }, true);
  65458. }
  65459. }
  65460. /**
  65461. * Check first node line indent is correct
  65462. * @param {ASTNode} node Node to examine
  65463. * @param {int} firstLineIndent needed indent
  65464. * @returns {void}
  65465. */
  65466. function checkFirstNodeLineIndent(node, firstLineIndent) {
  65467. var startIndent = getNodeIndent(node, false);
  65468. if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) {
  65469. report(node, firstLineIndent, startIndent.space, startIndent.tab, { line: node.loc.start.line, column: node.loc.start.column });
  65470. }
  65471. }
  65472. /**
  65473. * Returns a parent node of given node based on a specified type
  65474. * if not present then return null
  65475. * @param {ASTNode} node node to examine
  65476. * @param {string} type type that is being looked for
  65477. * @param {string} stopAtList end points for the evaluating code
  65478. * @returns {ASTNode|void} if found then node otherwise null
  65479. */
  65480. function getParentNodeByType(node, type, stopAtList) {
  65481. var parent = node.parent;
  65482. var stopAtSet = new Set(stopAtList || ["Program"]);
  65483. while (parent.type !== type && !stopAtSet.has(parent.type) && parent.type !== "Program") {
  65484. parent = parent.parent;
  65485. }
  65486. return parent.type === type ? parent : null;
  65487. }
  65488. /**
  65489. * Returns the VariableDeclarator based on the current node
  65490. * if not present then return null
  65491. * @param {ASTNode} node node to examine
  65492. * @returns {ASTNode|void} if found then node otherwise null
  65493. */
  65494. function getVariableDeclaratorNode(node) {
  65495. return getParentNodeByType(node, "VariableDeclarator");
  65496. }
  65497. /**
  65498. * Check to see if the node is part of the multi-line variable declaration.
  65499. * Also if its on the same line as the varNode
  65500. * @param {ASTNode} node node to check
  65501. * @param {ASTNode} varNode variable declaration node to check against
  65502. * @returns {boolean} True if all the above condition satisfy
  65503. */
  65504. function isNodeInVarOnTop(node, varNode) {
  65505. return varNode && varNode.parent.loc.start.line === node.loc.start.line && varNode.parent.declarations.length > 1;
  65506. }
  65507. /**
  65508. * Check to see if the argument before the callee node is multi-line and
  65509. * there should only be 1 argument before the callee node
  65510. * @param {ASTNode} node node to check
  65511. * @returns {boolean} True if arguments are multi-line
  65512. */
  65513. function isArgBeforeCalleeNodeMultiline(node) {
  65514. var parent = node.parent;
  65515. if (parent.arguments.length >= 2 && parent.arguments[1] === node) {
  65516. return parent.arguments[0].loc.end.line > parent.arguments[0].loc.start.line;
  65517. }
  65518. return false;
  65519. }
  65520. /**
  65521. * Check to see if the node is a file level IIFE
  65522. * @param {ASTNode} node The function node to check.
  65523. * @returns {boolean} True if the node is the outer IIFE
  65524. */
  65525. function isOuterIIFE(node) {
  65526. var parent = node.parent;
  65527. var stmt = parent.parent;
  65528. /*
  65529. * Verify that the node is an IIEF
  65530. */
  65531. if (parent.type !== "CallExpression" || parent.callee !== node) {
  65532. return false;
  65533. }
  65534. /*
  65535. * Navigate legal ancestors to determine whether this IIEF is outer
  65536. */
  65537. while (stmt.type === "UnaryExpression" && (stmt.operator === "!" || stmt.operator === "~" || stmt.operator === "+" || stmt.operator === "-") || stmt.type === "AssignmentExpression" || stmt.type === "LogicalExpression" || stmt.type === "SequenceExpression" || stmt.type === "VariableDeclarator") {
  65538. stmt = stmt.parent;
  65539. }
  65540. return (stmt.type === "ExpressionStatement" || stmt.type === "VariableDeclaration") && stmt.parent && stmt.parent.type === "Program";
  65541. }
  65542. /**
  65543. * Check indent for function block content
  65544. * @param {ASTNode} node A BlockStatement node that is inside of a function.
  65545. * @returns {void}
  65546. */
  65547. function checkIndentInFunctionBlock(node) {
  65548. /*
  65549. * Search first caller in chain.
  65550. * Ex.:
  65551. *
  65552. * Models <- Identifier
  65553. * .User
  65554. * .find()
  65555. * .exec(function() {
  65556. * // function body
  65557. * });
  65558. *
  65559. * Looks for 'Models'
  65560. */
  65561. var calleeNode = node.parent; // FunctionExpression
  65562. var indent = void 0;
  65563. if (calleeNode.parent && (calleeNode.parent.type === "Property" || calleeNode.parent.type === "ArrayExpression")) {
  65564. // If function is part of array or object, comma can be put at left
  65565. indent = getNodeIndent(calleeNode, false).goodChar;
  65566. } else {
  65567. // If function is standalone, simple calculate indent
  65568. indent = getNodeIndent(calleeNode).goodChar;
  65569. }
  65570. if (calleeNode.parent.type === "CallExpression") {
  65571. var calleeParent = calleeNode.parent;
  65572. if (calleeNode.type !== "FunctionExpression" && calleeNode.type !== "ArrowFunctionExpression") {
  65573. if (calleeParent && calleeParent.loc.start.line < node.loc.start.line) {
  65574. indent = getNodeIndent(calleeParent).goodChar;
  65575. }
  65576. } else {
  65577. if (isArgBeforeCalleeNodeMultiline(calleeNode) && calleeParent.callee.loc.start.line === calleeParent.callee.loc.end.line && !isNodeFirstInLine(calleeNode)) {
  65578. indent = getNodeIndent(calleeParent).goodChar;
  65579. }
  65580. }
  65581. }
  65582. /*
  65583. * function body indent should be indent + indent size, unless this
  65584. * is a FunctionDeclaration, FunctionExpression, or outer IIFE and the corresponding options are enabled.
  65585. */
  65586. var functionOffset = indentSize;
  65587. if (options.outerIIFEBody !== null && isOuterIIFE(calleeNode)) {
  65588. functionOffset = options.outerIIFEBody * indentSize;
  65589. } else if (calleeNode.type === "FunctionExpression") {
  65590. functionOffset = options.FunctionExpression.body * indentSize;
  65591. } else if (calleeNode.type === "FunctionDeclaration") {
  65592. functionOffset = options.FunctionDeclaration.body * indentSize;
  65593. }
  65594. indent += functionOffset;
  65595. // check if the node is inside a variable
  65596. var parentVarNode = getVariableDeclaratorNode(node);
  65597. if (parentVarNode && isNodeInVarOnTop(node, parentVarNode)) {
  65598. indent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
  65599. }
  65600. if (node.body.length > 0) {
  65601. checkNodesIndent(node.body, indent);
  65602. }
  65603. checkLastNodeLineIndent(node, indent - functionOffset);
  65604. }
  65605. /**
  65606. * Checks if the given node starts and ends on the same line
  65607. * @param {ASTNode} node The node to check
  65608. * @returns {boolean} Whether or not the block starts and ends on the same line.
  65609. */
  65610. function isSingleLineNode(node) {
  65611. var lastToken = sourceCode.getLastToken(node),
  65612. startLine = node.loc.start.line,
  65613. endLine = lastToken.loc.end.line;
  65614. return startLine === endLine;
  65615. }
  65616. /**
  65617. * Check to see if the first element inside an array is an object and on the same line as the node
  65618. * If the node is not an array then it will return false.
  65619. * @param {ASTNode} node node to check
  65620. * @returns {boolean} success/failure
  65621. */
  65622. function isFirstArrayElementOnSameLine(node) {
  65623. if (node.type === "ArrayExpression" && node.elements[0]) {
  65624. return node.elements[0].loc.start.line === node.loc.start.line && node.elements[0].type === "ObjectExpression";
  65625. }
  65626. return false;
  65627. }
  65628. /**
  65629. * Check indent for array block content or object block content
  65630. * @param {ASTNode} node node to examine
  65631. * @returns {void}
  65632. */
  65633. function checkIndentInArrayOrObjectBlock(node) {
  65634. // Skip inline
  65635. if (isSingleLineNode(node)) {
  65636. return;
  65637. }
  65638. var elements = node.type === "ArrayExpression" ? node.elements : node.properties;
  65639. // filter out empty elements example would be [ , 2] so remove first element as espree considers it as null
  65640. elements = elements.filter(function (elem) {
  65641. return elem !== null;
  65642. });
  65643. var nodeIndent = void 0;
  65644. var elementsIndent = void 0;
  65645. var parentVarNode = getVariableDeclaratorNode(node);
  65646. // TODO - come up with a better strategy in future
  65647. if (isNodeFirstInLine(node)) {
  65648. var parent = node.parent;
  65649. nodeIndent = getNodeIndent(parent).goodChar;
  65650. if (!parentVarNode || parentVarNode.loc.start.line !== node.loc.start.line) {
  65651. if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) {
  65652. if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) {
  65653. nodeIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
  65654. } else if (parent.type === "ObjectExpression" || parent.type === "ArrayExpression") {
  65655. var parentElements = node.parent.type === "ObjectExpression" ? node.parent.properties : node.parent.elements;
  65656. if (parentElements[0] && parentElements[0].loc.start.line === parent.loc.start.line && parentElements[0].loc.end.line !== parent.loc.start.line) {
  65657. /*
  65658. * If the first element of the array spans multiple lines, don't increase the expected indentation of the rest.
  65659. * e.g. [{
  65660. * foo: 1
  65661. * },
  65662. * {
  65663. * bar: 1
  65664. * }]
  65665. * the second object is not indented.
  65666. */
  65667. } else if (typeof options[parent.type] === "number") {
  65668. nodeIndent += options[parent.type] * indentSize;
  65669. } else {
  65670. nodeIndent = parentElements[0].loc.start.column;
  65671. }
  65672. } else if (parent.type === "CallExpression" || parent.type === "NewExpression") {
  65673. if (typeof options.CallExpression.arguments === "number") {
  65674. nodeIndent += options.CallExpression.arguments * indentSize;
  65675. } else if (options.CallExpression.arguments === "first") {
  65676. if (parent.arguments.indexOf(node) !== -1) {
  65677. nodeIndent = parent.arguments[0].loc.start.column;
  65678. }
  65679. } else {
  65680. nodeIndent += indentSize;
  65681. }
  65682. } else if (parent.type === "LogicalExpression" || parent.type === "ArrowFunctionExpression") {
  65683. nodeIndent += indentSize;
  65684. }
  65685. }
  65686. } else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && parent.type !== "MemberExpression" && parent.type !== "ExpressionStatement" && parent.type !== "AssignmentExpression" && parent.type !== "Property") {
  65687. nodeIndent += indentSize;
  65688. }
  65689. checkFirstNodeLineIndent(node, nodeIndent);
  65690. } else {
  65691. nodeIndent = getNodeIndent(node).goodChar;
  65692. }
  65693. if (options[node.type] === "first") {
  65694. elementsIndent = elements.length ? elements[0].loc.start.column : 0; // If there are no elements, elementsIndent doesn't matter.
  65695. } else {
  65696. elementsIndent = nodeIndent + indentSize * options[node.type];
  65697. }
  65698. /*
  65699. * Check if the node is a multiple variable declaration; if so, then
  65700. * make sure indentation takes that into account.
  65701. */
  65702. if (isNodeInVarOnTop(node, parentVarNode)) {
  65703. elementsIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
  65704. }
  65705. checkNodesIndent(elements, elementsIndent);
  65706. if (elements.length > 0) {
  65707. // Skip last block line check if last item in same line
  65708. if (elements[elements.length - 1].loc.end.line === node.loc.end.line) {
  65709. return;
  65710. }
  65711. }
  65712. checkLastNodeLineIndent(node, nodeIndent + (isNodeInVarOnTop(node, parentVarNode) ? options.VariableDeclarator[parentVarNode.parent.kind] * indentSize : 0));
  65713. }
  65714. /**
  65715. * Check if the node or node body is a BlockStatement or not
  65716. * @param {ASTNode} node node to test
  65717. * @returns {boolean} True if it or its body is a block statement
  65718. */
  65719. function isNodeBodyBlock(node) {
  65720. return node.type === "BlockStatement" || node.type === "ClassBody" || node.body && node.body.type === "BlockStatement" || node.consequent && node.consequent.type === "BlockStatement";
  65721. }
  65722. /**
  65723. * Check indentation for blocks
  65724. * @param {ASTNode} node node to check
  65725. * @returns {void}
  65726. */
  65727. function blockIndentationCheck(node) {
  65728. // Skip inline blocks
  65729. if (isSingleLineNode(node)) {
  65730. return;
  65731. }
  65732. if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "FunctionDeclaration" || node.parent.type === "ArrowFunctionExpression")) {
  65733. checkIndentInFunctionBlock(node);
  65734. return;
  65735. }
  65736. var indent = void 0;
  65737. var nodesToCheck = [];
  65738. /*
  65739. * For this statements we should check indent from statement beginning,
  65740. * not from the beginning of the block.
  65741. */
  65742. var statementsWithProperties = ["IfStatement", "WhileStatement", "ForStatement", "ForInStatement", "ForOfStatement", "DoWhileStatement", "ClassDeclaration", "TryStatement"];
  65743. if (node.parent && statementsWithProperties.indexOf(node.parent.type) !== -1 && isNodeBodyBlock(node)) {
  65744. indent = getNodeIndent(node.parent).goodChar;
  65745. } else if (node.parent && node.parent.type === "CatchClause") {
  65746. indent = getNodeIndent(node.parent.parent).goodChar;
  65747. } else {
  65748. indent = getNodeIndent(node).goodChar;
  65749. }
  65750. if (node.type === "IfStatement" && node.consequent.type !== "BlockStatement") {
  65751. nodesToCheck = [node.consequent];
  65752. } else if (Array.isArray(node.body)) {
  65753. nodesToCheck = node.body;
  65754. } else {
  65755. nodesToCheck = [node.body];
  65756. }
  65757. if (nodesToCheck.length > 0) {
  65758. checkNodesIndent(nodesToCheck, indent + indentSize);
  65759. }
  65760. if (node.type === "BlockStatement") {
  65761. checkLastNodeLineIndent(node, indent);
  65762. }
  65763. }
  65764. /**
  65765. * Filter out the elements which are on the same line of each other or the node.
  65766. * basically have only 1 elements from each line except the variable declaration line.
  65767. * @param {ASTNode} node Variable declaration node
  65768. * @returns {ASTNode[]} Filtered elements
  65769. */
  65770. function filterOutSameLineVars(node) {
  65771. return node.declarations.reduce(function (finalCollection, elem) {
  65772. var lastElem = finalCollection[finalCollection.length - 1];
  65773. if (elem.loc.start.line !== node.loc.start.line && !lastElem || lastElem && lastElem.loc.start.line !== elem.loc.start.line) {
  65774. finalCollection.push(elem);
  65775. }
  65776. return finalCollection;
  65777. }, []);
  65778. }
  65779. /**
  65780. * Check indentation for variable declarations
  65781. * @param {ASTNode} node node to examine
  65782. * @returns {void}
  65783. */
  65784. function checkIndentInVariableDeclarations(node) {
  65785. var elements = filterOutSameLineVars(node);
  65786. var nodeIndent = getNodeIndent(node).goodChar;
  65787. var lastElement = elements[elements.length - 1];
  65788. var elementsIndent = nodeIndent + indentSize * options.VariableDeclarator[node.kind];
  65789. checkNodesIndent(elements, elementsIndent);
  65790. // Only check the last line if there is any token after the last item
  65791. if (sourceCode.getLastToken(node).loc.end.line <= lastElement.loc.end.line) {
  65792. return;
  65793. }
  65794. var tokenBeforeLastElement = sourceCode.getTokenBefore(lastElement);
  65795. if (tokenBeforeLastElement.value === ",") {
  65796. // Special case for comma-first syntax where the semicolon is indented
  65797. checkLastNodeLineIndent(node, getNodeIndent(tokenBeforeLastElement).goodChar);
  65798. } else {
  65799. checkLastNodeLineIndent(node, elementsIndent - indentSize);
  65800. }
  65801. }
  65802. /**
  65803. * Check and decide whether to check for indentation for blockless nodes
  65804. * Scenarios are for or while statements without braces around them
  65805. * @param {ASTNode} node node to examine
  65806. * @returns {void}
  65807. */
  65808. function blockLessNodes(node) {
  65809. if (node.body.type !== "BlockStatement") {
  65810. blockIndentationCheck(node);
  65811. }
  65812. }
  65813. /**
  65814. * Returns the expected indentation for the case statement
  65815. * @param {ASTNode} node node to examine
  65816. * @param {int} [providedSwitchIndent] indent for switch statement
  65817. * @returns {int} indent size
  65818. */
  65819. function expectedCaseIndent(node, providedSwitchIndent) {
  65820. var switchNode = node.type === "SwitchStatement" ? node : node.parent;
  65821. var switchIndent = typeof providedSwitchIndent === "undefined" ? getNodeIndent(switchNode).goodChar : providedSwitchIndent;
  65822. var caseIndent = void 0;
  65823. if (caseIndentStore[switchNode.loc.start.line]) {
  65824. return caseIndentStore[switchNode.loc.start.line];
  65825. }
  65826. if (switchNode.cases.length > 0 && options.SwitchCase === 0) {
  65827. caseIndent = switchIndent;
  65828. } else {
  65829. caseIndent = switchIndent + indentSize * options.SwitchCase;
  65830. }
  65831. caseIndentStore[switchNode.loc.start.line] = caseIndent;
  65832. return caseIndent;
  65833. }
  65834. /**
  65835. * Checks wether a return statement is wrapped in ()
  65836. * @param {ASTNode} node node to examine
  65837. * @returns {boolean} the result
  65838. */
  65839. function isWrappedInParenthesis(node) {
  65840. var regex = /^return\s*?\(\s*?\);*?/;
  65841. var statementWithoutArgument = sourceCode.getText(node).replace(sourceCode.getText(node.argument), "");
  65842. return regex.test(statementWithoutArgument);
  65843. }
  65844. return {
  65845. Program: function Program(node) {
  65846. if (node.body.length > 0) {
  65847. // Root nodes should have no indent
  65848. checkNodesIndent(node.body, getNodeIndent(node).goodChar);
  65849. }
  65850. },
  65851. ClassBody: blockIndentationCheck,
  65852. BlockStatement: blockIndentationCheck,
  65853. WhileStatement: blockLessNodes,
  65854. ForStatement: blockLessNodes,
  65855. ForInStatement: blockLessNodes,
  65856. ForOfStatement: blockLessNodes,
  65857. DoWhileStatement: blockLessNodes,
  65858. IfStatement: function IfStatement(node) {
  65859. if (node.consequent.type !== "BlockStatement" && node.consequent.loc.start.line > node.loc.start.line) {
  65860. blockIndentationCheck(node);
  65861. }
  65862. },
  65863. VariableDeclaration: function VariableDeclaration(node) {
  65864. if (node.declarations[node.declarations.length - 1].loc.start.line > node.declarations[0].loc.start.line) {
  65865. checkIndentInVariableDeclarations(node);
  65866. }
  65867. },
  65868. ObjectExpression: function ObjectExpression(node) {
  65869. checkIndentInArrayOrObjectBlock(node);
  65870. },
  65871. ArrayExpression: function ArrayExpression(node) {
  65872. checkIndentInArrayOrObjectBlock(node);
  65873. },
  65874. MemberExpression: function MemberExpression(node) {
  65875. if (typeof options.MemberExpression === "undefined") {
  65876. return;
  65877. }
  65878. if (isSingleLineNode(node)) {
  65879. return;
  65880. }
  65881. /*
  65882. * The typical layout of variable declarations and assignments
  65883. * alter the expectation of correct indentation. Skip them.
  65884. * TODO: Add appropriate configuration options for variable
  65885. * declarations and assignments.
  65886. */
  65887. if (getParentNodeByType(node, "VariableDeclarator", ["FunctionExpression", "ArrowFunctionExpression"])) {
  65888. return;
  65889. }
  65890. if (getParentNodeByType(node, "AssignmentExpression", ["FunctionExpression"])) {
  65891. return;
  65892. }
  65893. var propertyIndent = getNodeIndent(node).goodChar + indentSize * options.MemberExpression;
  65894. var checkNodes = [node.property];
  65895. var dot = sourceCode.getTokenBefore(node.property);
  65896. if (dot.type === "Punctuator" && dot.value === ".") {
  65897. checkNodes.push(dot);
  65898. }
  65899. checkNodesIndent(checkNodes, propertyIndent);
  65900. },
  65901. SwitchStatement: function SwitchStatement(node) {
  65902. // Switch is not a 'BlockStatement'
  65903. var switchIndent = getNodeIndent(node).goodChar;
  65904. var caseIndent = expectedCaseIndent(node, switchIndent);
  65905. checkNodesIndent(node.cases, caseIndent);
  65906. checkLastNodeLineIndent(node, switchIndent);
  65907. },
  65908. SwitchCase: function SwitchCase(node) {
  65909. // Skip inline cases
  65910. if (isSingleLineNode(node)) {
  65911. return;
  65912. }
  65913. var caseIndent = expectedCaseIndent(node);
  65914. checkNodesIndent(node.consequent, caseIndent + indentSize);
  65915. },
  65916. FunctionDeclaration: function FunctionDeclaration(node) {
  65917. if (isSingleLineNode(node)) {
  65918. return;
  65919. }
  65920. if (options.FunctionDeclaration.parameters === "first" && node.params.length) {
  65921. checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column);
  65922. } else if (options.FunctionDeclaration.parameters !== null) {
  65923. checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionDeclaration.parameters);
  65924. }
  65925. },
  65926. FunctionExpression: function FunctionExpression(node) {
  65927. if (isSingleLineNode(node)) {
  65928. return;
  65929. }
  65930. if (options.FunctionExpression.parameters === "first" && node.params.length) {
  65931. checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column);
  65932. } else if (options.FunctionExpression.parameters !== null) {
  65933. checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionExpression.parameters);
  65934. }
  65935. },
  65936. ReturnStatement: function ReturnStatement(node) {
  65937. if (isSingleLineNode(node)) {
  65938. return;
  65939. }
  65940. var firstLineIndent = getNodeIndent(node).goodChar;
  65941. // in case if return statement is wrapped in parenthesis
  65942. if (isWrappedInParenthesis(node)) {
  65943. checkLastReturnStatementLineIndent(node, firstLineIndent);
  65944. } else {
  65945. checkNodeIndent(node, firstLineIndent);
  65946. }
  65947. },
  65948. CallExpression: function CallExpression(node) {
  65949. if (isSingleLineNode(node)) {
  65950. return;
  65951. }
  65952. if (options.CallExpression.arguments === "first" && node.arguments.length) {
  65953. checkNodesIndent(node.arguments.slice(1), node.arguments[0].loc.start.column);
  65954. } else if (options.CallExpression.arguments !== null) {
  65955. checkNodesIndent(node.arguments, getNodeIndent(node).goodChar + indentSize * options.CallExpression.arguments);
  65956. }
  65957. }
  65958. };
  65959. }
  65960. };
  65961. },{"../util/ast-utils":405}],170:[function(require,module,exports){
  65962. /**
  65963. * @fileoverview This rule sets a specific indentation style and width for your code
  65964. *
  65965. * @author Teddy Katz
  65966. * @author Vitaly Puzrin
  65967. * @author Gyandeep Singh
  65968. */
  65969. "use strict";
  65970. //------------------------------------------------------------------------------
  65971. // Requirements
  65972. //------------------------------------------------------------------------------
  65973. 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; }; }();
  65974. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  65975. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  65976. var lodash = require("lodash");
  65977. var astUtils = require("../util/ast-utils");
  65978. var createTree = require("functional-red-black-tree");
  65979. //------------------------------------------------------------------------------
  65980. // Rule Definition
  65981. //------------------------------------------------------------------------------
  65982. var KNOWN_NODES = new Set(["AssignmentExpression", "AssignmentPattern", "ArrayExpression", "ArrayPattern", "ArrowFunctionExpression", "AwaitExpression", "BlockStatement", "BinaryExpression", "BreakStatement", "CallExpression", "CatchClause", "ClassBody", "ClassDeclaration", "ClassExpression", "ConditionalExpression", "ContinueStatement", "DoWhileStatement", "DebuggerStatement", "EmptyStatement", "ExperimentalRestProperty", "ExperimentalSpreadProperty", "ExpressionStatement", "ForStatement", "ForInStatement", "ForOfStatement", "FunctionDeclaration", "FunctionExpression", "Identifier", "IfStatement", "Literal", "LabeledStatement", "LogicalExpression", "MemberExpression", "MetaProperty", "MethodDefinition", "NewExpression", "ObjectExpression", "ObjectPattern", "Program", "Property", "RestElement", "ReturnStatement", "SequenceExpression", "SpreadElement", "Super", "SwitchCase", "SwitchStatement", "TaggedTemplateExpression", "TemplateElement", "TemplateLiteral", "ThisExpression", "ThrowStatement", "TryStatement", "UnaryExpression", "UpdateExpression", "VariableDeclaration", "VariableDeclarator", "WhileStatement", "WithStatement", "YieldExpression", "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", "JSXEmptyExpression", "JSXExpressionContainer", "JSXElement", "JSXClosingElement", "JSXOpeningElement", "JSXAttribute", "JSXSpreadAttribute", "JSXText", "ExportDefaultDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration", "ExportSpecifier", "ImportDeclaration", "ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier"]);
  65983. /*
  65984. * General rule strategy:
  65985. * 1. An OffsetStorage instance stores a map of desired offsets, where each token has a specified offset from another
  65986. * specified token or to the first column.
  65987. * 2. As the AST is traversed, modify the desired offsets of tokens accordingly. For example, when entering a
  65988. * BlockStatement, offset all of the tokens in the BlockStatement by 1 indent level from the opening curly
  65989. * brace of the BlockStatement.
  65990. * 3. After traversing the AST, calculate the expected indentation levels of every token according to the
  65991. * OffsetStorage container.
  65992. * 4. For each line, compare the expected indentation of the first token to the actual indentation in the file,
  65993. * and report the token if the two values are not equal.
  65994. */
  65995. /**
  65996. * A mutable balanced binary search tree that stores (key, value) pairs. The keys are numeric, and must be unique.
  65997. * This is intended to be a generic wrapper around a balanced binary search tree library, so that the underlying implementation
  65998. * can easily be swapped out.
  65999. */
  66000. var BinarySearchTree = function () {
  66001. /**
  66002. * Creates an empty tree
  66003. */
  66004. function BinarySearchTree() {
  66005. _classCallCheck(this, BinarySearchTree);
  66006. this._rbTree = createTree();
  66007. }
  66008. /**
  66009. * Inserts an entry into the tree.
  66010. * @param {number} key The entry's key
  66011. * @param {*} value The entry's value
  66012. * @returns {void}
  66013. */
  66014. _createClass(BinarySearchTree, [{
  66015. key: "insert",
  66016. value: function insert(key, value) {
  66017. var iterator = this._rbTree.find(key);
  66018. if (iterator.valid) {
  66019. this._rbTree = iterator.update(value);
  66020. } else {
  66021. this._rbTree = this._rbTree.insert(key, value);
  66022. }
  66023. }
  66024. /**
  66025. * Finds the entry with the largest key less than or equal to the provided key
  66026. * @param {number} key The provided key
  66027. * @returns {{key: number, value: *}|null} The found entry, or null if no such entry exists.
  66028. */
  66029. }, {
  66030. key: "findLe",
  66031. value: function findLe(key) {
  66032. var iterator = this._rbTree.le(key);
  66033. return iterator && { key: iterator.key, value: iterator.value };
  66034. }
  66035. /**
  66036. * Deletes all of the keys in the interval [start, end)
  66037. * @param {number} start The start of the range
  66038. * @param {number} end The end of the range
  66039. * @returns {void}
  66040. */
  66041. }, {
  66042. key: "deleteRange",
  66043. value: function deleteRange(start, end) {
  66044. // Exit without traversing the tree if the range has zero size.
  66045. if (start === end) {
  66046. return;
  66047. }
  66048. var iterator = this._rbTree.ge(start);
  66049. while (iterator.valid && iterator.key < end) {
  66050. this._rbTree = this._rbTree.remove(iterator.key);
  66051. iterator.next();
  66052. }
  66053. }
  66054. }]);
  66055. return BinarySearchTree;
  66056. }();
  66057. /**
  66058. * A helper class to get token-based info related to indentation
  66059. */
  66060. var TokenInfo = function () {
  66061. /**
  66062. * @param {SourceCode} sourceCode A SourceCode object
  66063. */
  66064. function TokenInfo(sourceCode) {
  66065. _classCallCheck(this, TokenInfo);
  66066. this.sourceCode = sourceCode;
  66067. this.firstTokensByLineNumber = sourceCode.tokensAndComments.reduce(function (map, token) {
  66068. if (!map.has(token.loc.start.line)) {
  66069. map.set(token.loc.start.line, token);
  66070. }
  66071. if (!map.has(token.loc.end.line) && sourceCode.text.slice(token.range[1] - token.loc.end.column, token.range[1]).trim()) {
  66072. map.set(token.loc.end.line, token);
  66073. }
  66074. return map;
  66075. }, new Map());
  66076. }
  66077. /**
  66078. * Gets the first token on a given token's line
  66079. * @param {Token|ASTNode} token a node or token
  66080. * @returns {Token} The first token on the given line
  66081. */
  66082. _createClass(TokenInfo, [{
  66083. key: "getFirstTokenOfLine",
  66084. value: function getFirstTokenOfLine(token) {
  66085. return this.firstTokensByLineNumber.get(token.loc.start.line);
  66086. }
  66087. /**
  66088. * Determines whether a token is the first token in its line
  66089. * @param {Token} token The token
  66090. * @returns {boolean} `true` if the token is the first on its line
  66091. */
  66092. }, {
  66093. key: "isFirstTokenOfLine",
  66094. value: function isFirstTokenOfLine(token) {
  66095. return this.getFirstTokenOfLine(token) === token;
  66096. }
  66097. /**
  66098. * Get the actual indent of a token
  66099. * @param {Token} token Token to examine. This should be the first token on its line.
  66100. * @returns {string} The indentation characters that precede the token
  66101. */
  66102. }, {
  66103. key: "getTokenIndent",
  66104. value: function getTokenIndent(token) {
  66105. return this.sourceCode.text.slice(token.range[0] - token.loc.start.column, token.range[0]);
  66106. }
  66107. }]);
  66108. return TokenInfo;
  66109. }();
  66110. /**
  66111. * A class to store information on desired offsets of tokens from each other
  66112. */
  66113. var OffsetStorage = function () {
  66114. /**
  66115. * @param {TokenInfo} tokenInfo a TokenInfo instance
  66116. * @param {number} indentSize The desired size of each indentation level
  66117. * @param {string} indentType The indentation character
  66118. */
  66119. function OffsetStorage(tokenInfo, indentSize, indentType) {
  66120. _classCallCheck(this, OffsetStorage);
  66121. this._tokenInfo = tokenInfo;
  66122. this._indentSize = indentSize;
  66123. this._indentType = indentType;
  66124. this._tree = new BinarySearchTree();
  66125. this._tree.insert(0, { offset: 0, from: null, force: false });
  66126. this._lockedFirstTokens = new WeakMap();
  66127. this._desiredIndentCache = new WeakMap();
  66128. this._ignoredTokens = new WeakSet();
  66129. }
  66130. _createClass(OffsetStorage, [{
  66131. key: "_getOffsetDescriptor",
  66132. value: function _getOffsetDescriptor(token) {
  66133. return this._tree.findLe(token.range[0]).value;
  66134. }
  66135. /**
  66136. * Sets the offset column of token B to match the offset column of token A.
  66137. * **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In
  66138. * most cases, `setDesiredOffset` should be used instead.
  66139. * @param {Token} baseToken The first token
  66140. * @param {Token} offsetToken The second token, whose offset should be matched to the first token
  66141. * @returns {void}
  66142. */
  66143. }, {
  66144. key: "matchOffsetOf",
  66145. value: function matchOffsetOf(baseToken, offsetToken) {
  66146. /*
  66147. * lockedFirstTokens is a map from a token whose indentation is controlled by the "first" option to
  66148. * the token that it depends on. For example, with the `ArrayExpression: first` option, the first
  66149. * token of each element in the array after the first will be mapped to the first token of the first
  66150. * element. The desired indentation of each of these tokens is computed based on the desired indentation
  66151. * of the "first" element, rather than through the normal offset mechanism.
  66152. */
  66153. this._lockedFirstTokens.set(offsetToken, baseToken);
  66154. }
  66155. /**
  66156. * Sets the desired offset of a token.
  66157. *
  66158. * This uses a line-based offset collapsing behavior to handle tokens on the same line.
  66159. * For example, consider the following two cases:
  66160. *
  66161. * (
  66162. * [
  66163. * bar
  66164. * ]
  66165. * )
  66166. *
  66167. * ([
  66168. * bar
  66169. * ])
  66170. *
  66171. * Based on the first case, it's clear that the `bar` token needs to have an offset of 1 indent level (4 spaces) from
  66172. * the `[` token, and the `[` token has to have an offset of 1 indent level from the `(` token. Since the `(` token is
  66173. * the first on its line (with an indent of 0 spaces), the `bar` token needs to be offset by 2 indent levels (8 spaces)
  66174. * from the start of its line.
  66175. *
  66176. * However, in the second case `bar` should only be indented by 4 spaces. This is because the offset of 1 indent level
  66177. * between the `(` and the `[` tokens gets "collapsed" because the two tokens are on the same line. As a result, the
  66178. * `(` token is mapped to the `[` token with an offset of 0, and the rule correctly decides that `bar` should be indented
  66179. * by 1 indent level from the start of the line.
  66180. *
  66181. * This is useful because rule listeners can usually just call `setDesiredOffset` for all the tokens in the node,
  66182. * without needing to check which lines those tokens are on.
  66183. *
  66184. * Note that since collapsing only occurs when two tokens are on the same line, there are a few cases where non-intuitive
  66185. * behavior can occur. For example, consider the following cases:
  66186. *
  66187. * foo(
  66188. * ).
  66189. * bar(
  66190. * baz
  66191. * )
  66192. *
  66193. * foo(
  66194. * ).bar(
  66195. * baz
  66196. * )
  66197. *
  66198. * Based on the first example, it would seem that `bar` should be offset by 1 indent level from `foo`, and `baz`
  66199. * should be offset by 1 indent level from `bar`. However, this is not correct, because it would result in `baz`
  66200. * being indented by 2 indent levels in the second case (since `foo`, `bar`, and `baz` are all on separate lines, no
  66201. * collapsing would occur).
  66202. *
  66203. * Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and
  66204. * offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed
  66205. * in the second case.
  66206. *
  66207. * @param {Token} token The token
  66208. * @param {Token} fromToken The token that `token` should be offset from
  66209. * @param {number} offset The desired indent level
  66210. * @returns {void}
  66211. */
  66212. }, {
  66213. key: "setDesiredOffset",
  66214. value: function setDesiredOffset(token, fromToken, offset) {
  66215. return this.setDesiredOffsets(token.range, fromToken, offset);
  66216. }
  66217. /**
  66218. * Sets the desired offset of all tokens in a range
  66219. * It's common for node listeners in this file to need to apply the same offset to a large, contiguous range of tokens.
  66220. * Moreover, the offset of any given token is usually updated multiple times (roughly once for each node that contains
  66221. * it). This means that the offset of each token is updated O(AST depth) times.
  66222. * It would not be performant to store and update the offsets for each token independently, because the rule would end
  66223. * up having a time complexity of O(number of tokens * AST depth), which is quite slow for large files.
  66224. *
  66225. * Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following
  66226. * list could represent the state of the offset tree at a given point:
  66227. *
  66228. * * Tokens starting in the interval [0, 15) are aligned with the beginning of the file
  66229. * * Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token
  66230. * * Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token
  66231. * * Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token
  66232. * * Tokens starting in the interval [820, ∞) are offset by 1 indent level from the `baz` token
  66233. *
  66234. * The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using:
  66235. * `setDesiredOffsets([30, 43], fooToken, 1);`
  66236. *
  66237. * @param {[number, number]} range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied.
  66238. * @param {Token} fromToken The token that this is offset from
  66239. * @param {number} offset The desired indent level
  66240. * @param {boolean} force `true` if this offset should not use the normal collapsing behavior. This should almost always be false.
  66241. * @returns {void}
  66242. */
  66243. }, {
  66244. key: "setDesiredOffsets",
  66245. value: function setDesiredOffsets(range, fromToken, offset, force) {
  66246. /*
  66247. * Offset ranges are stored as a collection of nodes, where each node maps a numeric key to an offset
  66248. * descriptor. The tree for the example above would have the following nodes:
  66249. *
  66250. * * key: 0, value: { offset: 0, from: null }
  66251. * * key: 15, value: { offset: 1, from: barToken }
  66252. * * key: 30, value: { offset: 1, from: fooToken }
  66253. * * key: 43, value: { offset: 2, from: barToken }
  66254. * * key: 820, value: { offset: 1, from: bazToken }
  66255. *
  66256. * To find the offset descriptor for any given token, one needs to find the node with the largest key
  66257. * which is <= token.start. To make this operation fast, the nodes are stored in a balanced binary
  66258. * search tree indexed by key.
  66259. */
  66260. var descriptorToInsert = { offset: offset, from: fromToken, force: force };
  66261. var descriptorAfterRange = this._tree.findLe(range[1]).value;
  66262. var fromTokenIsInRange = fromToken && fromToken.range[0] >= range[0] && fromToken.range[1] <= range[1];
  66263. var fromTokenDescriptor = fromTokenIsInRange && this._getOffsetDescriptor(fromToken);
  66264. // First, remove any existing nodes in the range from the tree.
  66265. this._tree.deleteRange(range[0] + 1, range[1]);
  66266. // Insert a new node into the tree for this range
  66267. this._tree.insert(range[0], descriptorToInsert);
  66268. /*
  66269. * To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously,
  66270. * even if it's in the current range.
  66271. */
  66272. if (fromTokenIsInRange) {
  66273. this._tree.insert(fromToken.range[0], fromTokenDescriptor);
  66274. this._tree.insert(fromToken.range[1], descriptorToInsert);
  66275. }
  66276. /*
  66277. * To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following
  66278. * tokens the same as it was before.
  66279. */
  66280. this._tree.insert(range[1], descriptorAfterRange);
  66281. }
  66282. /**
  66283. * Gets the desired indent of a token
  66284. * @param {Token} token The token
  66285. * @returns {string} The desired indent of the token
  66286. */
  66287. }, {
  66288. key: "getDesiredIndent",
  66289. value: function getDesiredIndent(token) {
  66290. if (!this._desiredIndentCache.has(token)) {
  66291. if (this._ignoredTokens.has(token)) {
  66292. /*
  66293. * If the token is ignored, use the actual indent of the token as the desired indent.
  66294. * This ensures that no errors are reported for this token.
  66295. */
  66296. this._desiredIndentCache.set(token, this._tokenInfo.getTokenIndent(token));
  66297. } else if (this._lockedFirstTokens.has(token)) {
  66298. var firstToken = this._lockedFirstTokens.get(token);
  66299. this._desiredIndentCache.set(token,
  66300. // (indentation for the first element's line)
  66301. this.getDesiredIndent(this._tokenInfo.getFirstTokenOfLine(firstToken)) +
  66302. // (space between the start of the first element's line and the first element)
  66303. this._indentType.repeat(firstToken.loc.start.column - this._tokenInfo.getFirstTokenOfLine(firstToken).loc.start.column));
  66304. } else {
  66305. var offsetInfo = this._getOffsetDescriptor(token);
  66306. var offset = offsetInfo.from && offsetInfo.from.loc.start.line === token.loc.start.line && !/^\s*?\n/.test(token.value) && !offsetInfo.force ? 0 : offsetInfo.offset * this._indentSize;
  66307. this._desiredIndentCache.set(token, (offsetInfo.from ? this.getDesiredIndent(offsetInfo.from) : "") + this._indentType.repeat(offset));
  66308. }
  66309. }
  66310. return this._desiredIndentCache.get(token);
  66311. }
  66312. /**
  66313. * Ignores a token, preventing it from being reported.
  66314. * @param {Token} token The token
  66315. * @returns {void}
  66316. */
  66317. }, {
  66318. key: "ignoreToken",
  66319. value: function ignoreToken(token) {
  66320. if (this._tokenInfo.isFirstTokenOfLine(token)) {
  66321. this._ignoredTokens.add(token);
  66322. }
  66323. }
  66324. /**
  66325. * Gets the first token that the given token's indentation is dependent on
  66326. * @param {Token} token The token
  66327. * @returns {Token} The token that the given token depends on, or `null` if the given token is at the top level
  66328. */
  66329. }, {
  66330. key: "getFirstDependency",
  66331. value: function getFirstDependency(token) {
  66332. return this._getOffsetDescriptor(token).from;
  66333. }
  66334. }]);
  66335. return OffsetStorage;
  66336. }();
  66337. var ELEMENT_LIST_SCHEMA = {
  66338. oneOf: [{
  66339. type: "integer",
  66340. minimum: 0
  66341. }, {
  66342. enum: ["first", "off"]
  66343. }]
  66344. };
  66345. module.exports = {
  66346. meta: {
  66347. type: "layout",
  66348. docs: {
  66349. description: "enforce consistent indentation",
  66350. category: "Stylistic Issues",
  66351. recommended: false,
  66352. url: "https://eslint.org/docs/rules/indent"
  66353. },
  66354. fixable: "whitespace",
  66355. schema: [{
  66356. oneOf: [{
  66357. enum: ["tab"]
  66358. }, {
  66359. type: "integer",
  66360. minimum: 0
  66361. }]
  66362. }, {
  66363. type: "object",
  66364. properties: {
  66365. SwitchCase: {
  66366. type: "integer",
  66367. minimum: 0
  66368. },
  66369. VariableDeclarator: {
  66370. oneOf: [ELEMENT_LIST_SCHEMA, {
  66371. type: "object",
  66372. properties: {
  66373. var: ELEMENT_LIST_SCHEMA,
  66374. let: ELEMENT_LIST_SCHEMA,
  66375. const: ELEMENT_LIST_SCHEMA
  66376. },
  66377. additionalProperties: false
  66378. }]
  66379. },
  66380. outerIIFEBody: {
  66381. type: "integer",
  66382. minimum: 0
  66383. },
  66384. MemberExpression: {
  66385. oneOf: [{
  66386. type: "integer",
  66387. minimum: 0
  66388. }, {
  66389. enum: ["off"]
  66390. }]
  66391. },
  66392. FunctionDeclaration: {
  66393. type: "object",
  66394. properties: {
  66395. parameters: ELEMENT_LIST_SCHEMA,
  66396. body: {
  66397. type: "integer",
  66398. minimum: 0
  66399. }
  66400. },
  66401. additionalProperties: false
  66402. },
  66403. FunctionExpression: {
  66404. type: "object",
  66405. properties: {
  66406. parameters: ELEMENT_LIST_SCHEMA,
  66407. body: {
  66408. type: "integer",
  66409. minimum: 0
  66410. }
  66411. },
  66412. additionalProperties: false
  66413. },
  66414. CallExpression: {
  66415. type: "object",
  66416. properties: {
  66417. arguments: ELEMENT_LIST_SCHEMA
  66418. },
  66419. additionalProperties: false
  66420. },
  66421. ArrayExpression: ELEMENT_LIST_SCHEMA,
  66422. ObjectExpression: ELEMENT_LIST_SCHEMA,
  66423. ImportDeclaration: ELEMENT_LIST_SCHEMA,
  66424. flatTernaryExpressions: {
  66425. type: "boolean"
  66426. },
  66427. ignoredNodes: {
  66428. type: "array",
  66429. items: {
  66430. type: "string",
  66431. not: {
  66432. pattern: ":exit$"
  66433. }
  66434. }
  66435. },
  66436. ignoreComments: {
  66437. type: "boolean"
  66438. }
  66439. },
  66440. additionalProperties: false
  66441. }]
  66442. },
  66443. create: function create(context) {
  66444. var DEFAULT_VARIABLE_INDENT = 1;
  66445. var DEFAULT_PARAMETER_INDENT = 1;
  66446. var DEFAULT_FUNCTION_BODY_INDENT = 1;
  66447. var indentType = "space";
  66448. var indentSize = 4;
  66449. var options = {
  66450. SwitchCase: 0,
  66451. VariableDeclarator: {
  66452. var: DEFAULT_VARIABLE_INDENT,
  66453. let: DEFAULT_VARIABLE_INDENT,
  66454. const: DEFAULT_VARIABLE_INDENT
  66455. },
  66456. outerIIFEBody: 1,
  66457. FunctionDeclaration: {
  66458. parameters: DEFAULT_PARAMETER_INDENT,
  66459. body: DEFAULT_FUNCTION_BODY_INDENT
  66460. },
  66461. FunctionExpression: {
  66462. parameters: DEFAULT_PARAMETER_INDENT,
  66463. body: DEFAULT_FUNCTION_BODY_INDENT
  66464. },
  66465. CallExpression: {
  66466. arguments: DEFAULT_PARAMETER_INDENT
  66467. },
  66468. MemberExpression: 1,
  66469. ArrayExpression: 1,
  66470. ObjectExpression: 1,
  66471. ImportDeclaration: 1,
  66472. flatTernaryExpressions: false,
  66473. ignoredNodes: [],
  66474. ignoreComments: false
  66475. };
  66476. if (context.options.length) {
  66477. if (context.options[0] === "tab") {
  66478. indentSize = 1;
  66479. indentType = "tab";
  66480. } else {
  66481. indentSize = context.options[0];
  66482. indentType = "space";
  66483. }
  66484. if (context.options[1]) {
  66485. lodash.merge(options, context.options[1]);
  66486. if (typeof options.VariableDeclarator === "number" || options.VariableDeclarator === "first") {
  66487. options.VariableDeclarator = {
  66488. var: options.VariableDeclarator,
  66489. let: options.VariableDeclarator,
  66490. const: options.VariableDeclarator
  66491. };
  66492. }
  66493. }
  66494. }
  66495. var sourceCode = context.getSourceCode();
  66496. var tokenInfo = new TokenInfo(sourceCode);
  66497. var offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t");
  66498. var parameterParens = new WeakSet();
  66499. /**
  66500. * Creates an error message for a line, given the expected/actual indentation.
  66501. * @param {int} expectedAmount The expected amount of indentation characters for this line
  66502. * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
  66503. * @param {int} actualTabs The actual number of indentation tabs that were found on this line
  66504. * @returns {string} An error message for this line
  66505. */
  66506. function createErrorMessage(expectedAmount, actualSpaces, actualTabs) {
  66507. var expectedStatement = expectedAmount + " " + indentType + (expectedAmount === 1 ? "" : "s"); // e.g. "2 tabs"
  66508. var foundSpacesWord = "space" + (actualSpaces === 1 ? "" : "s"); // e.g. "space"
  66509. var foundTabsWord = "tab" + (actualTabs === 1 ? "" : "s"); // e.g. "tabs"
  66510. var foundStatement = void 0;
  66511. if (actualSpaces > 0) {
  66512. /*
  66513. * Abbreviate the message if the expected indentation is also spaces.
  66514. * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces'
  66515. */
  66516. foundStatement = indentType === "space" ? actualSpaces : actualSpaces + " " + foundSpacesWord;
  66517. } else if (actualTabs > 0) {
  66518. foundStatement = indentType === "tab" ? actualTabs : actualTabs + " " + foundTabsWord;
  66519. } else {
  66520. foundStatement = "0";
  66521. }
  66522. return "Expected indentation of " + expectedStatement + " but found " + foundStatement + ".";
  66523. }
  66524. /**
  66525. * Reports a given indent violation
  66526. * @param {Token} token Token violating the indent rule
  66527. * @param {string} neededIndent Expected indentation string
  66528. * @returns {void}
  66529. */
  66530. function report(token, neededIndent) {
  66531. var actualIndent = Array.from(tokenInfo.getTokenIndent(token));
  66532. var numSpaces = actualIndent.filter(function (char) {
  66533. return char === " ";
  66534. }).length;
  66535. var numTabs = actualIndent.filter(function (char) {
  66536. return char === "\t";
  66537. }).length;
  66538. context.report({
  66539. node: token,
  66540. message: createErrorMessage(neededIndent.length, numSpaces, numTabs),
  66541. loc: {
  66542. start: { line: token.loc.start.line, column: 0 },
  66543. end: { line: token.loc.start.line, column: token.loc.start.column }
  66544. },
  66545. fix: function fix(fixer) {
  66546. var range = [token.range[0] - token.loc.start.column, token.range[0]];
  66547. var newText = neededIndent;
  66548. return fixer.replaceTextRange(range, newText);
  66549. }
  66550. });
  66551. }
  66552. /**
  66553. * Checks if a token's indentation is correct
  66554. * @param {Token} token Token to examine
  66555. * @param {string} desiredIndent Desired indentation of the string
  66556. * @returns {boolean} `true` if the token's indentation is correct
  66557. */
  66558. function validateTokenIndent(token, desiredIndent) {
  66559. var indentation = tokenInfo.getTokenIndent(token);
  66560. return indentation === desiredIndent ||
  66561. // To avoid conflicts with no-mixed-spaces-and-tabs, don't report mixed spaces and tabs.
  66562. indentation.includes(" ") && indentation.includes("\t");
  66563. }
  66564. /**
  66565. * Check to see if the node is a file level IIFE
  66566. * @param {ASTNode} node The function node to check.
  66567. * @returns {boolean} True if the node is the outer IIFE
  66568. */
  66569. function isOuterIIFE(node) {
  66570. /*
  66571. * Verify that the node is an IIFE
  66572. */
  66573. if (!node.parent || node.parent.type !== "CallExpression" || node.parent.callee !== node) {
  66574. return false;
  66575. }
  66576. /*
  66577. * Navigate legal ancestors to determine whether this IIFE is outer.
  66578. * A "legal ancestor" is an expression or statement that causes the function to get executed immediately.
  66579. * For example, `!(function(){})()` is an outer IIFE even though it is preceded by a ! operator.
  66580. */
  66581. var statement = node.parent && node.parent.parent;
  66582. while (statement.type === "UnaryExpression" && ["!", "~", "+", "-"].indexOf(statement.operator) > -1 || statement.type === "AssignmentExpression" || statement.type === "LogicalExpression" || statement.type === "SequenceExpression" || statement.type === "VariableDeclarator") {
  66583. statement = statement.parent;
  66584. }
  66585. return (statement.type === "ExpressionStatement" || statement.type === "VariableDeclaration") && statement.parent.type === "Program";
  66586. }
  66587. /**
  66588. * Counts the number of linebreaks that follow the last non-whitespace character in a string
  66589. * @param {string} string The string to check
  66590. * @returns {number} The number of JavaScript linebreaks that follow the last non-whitespace character,
  66591. * or the total number of linebreaks if the string is all whitespace.
  66592. */
  66593. function countTrailingLinebreaks(string) {
  66594. var trailingWhitespace = string.match(/\s*$/)[0];
  66595. var linebreakMatches = trailingWhitespace.match(astUtils.createGlobalLinebreakMatcher());
  66596. return linebreakMatches === null ? 0 : linebreakMatches.length;
  66597. }
  66598. /**
  66599. * Check indentation for lists of elements (arrays, objects, function params)
  66600. * @param {ASTNode[]} elements List of elements that should be offset
  66601. * @param {Token} startToken The start token of the list that element should be aligned against, e.g. '['
  66602. * @param {Token} endToken The end token of the list, e.g. ']'
  66603. * @param {number|string} offset The amount that the elements should be offset
  66604. * @returns {void}
  66605. */
  66606. function addElementListIndent(elements, startToken, endToken, offset) {
  66607. /**
  66608. * Gets the first token of a given element, including surrounding parentheses.
  66609. * @param {ASTNode} element A node in the `elements` list
  66610. * @returns {Token} The first token of this element
  66611. */
  66612. function getFirstToken(element) {
  66613. var token = sourceCode.getTokenBefore(element);
  66614. while (astUtils.isOpeningParenToken(token) && token !== startToken) {
  66615. token = sourceCode.getTokenBefore(token);
  66616. }
  66617. return sourceCode.getTokenAfter(token);
  66618. }
  66619. // Run through all the tokens in the list, and offset them by one indent level (mainly for comments, other things will end up overridden)
  66620. offsets.setDesiredOffsets([startToken.range[1], endToken.range[0]], startToken, typeof offset === "number" ? offset : 1);
  66621. offsets.setDesiredOffset(endToken, startToken, 0);
  66622. // If the preference is "first" but there is no first element (e.g. sparse arrays w/ empty first slot), fall back to 1 level.
  66623. if (offset === "first" && elements.length && !elements[0]) {
  66624. return;
  66625. }
  66626. elements.forEach(function (element, index) {
  66627. if (!element) {
  66628. // Skip holes in arrays
  66629. return;
  66630. }
  66631. if (offset === "off") {
  66632. // Ignore the first token of every element if the "off" option is used
  66633. offsets.ignoreToken(getFirstToken(element));
  66634. }
  66635. // Offset the following elements correctly relative to the first element
  66636. if (index === 0) {
  66637. return;
  66638. }
  66639. if (offset === "first" && tokenInfo.isFirstTokenOfLine(getFirstToken(element))) {
  66640. offsets.matchOffsetOf(getFirstToken(elements[0]), getFirstToken(element));
  66641. } else {
  66642. var previousElement = elements[index - 1];
  66643. var firstTokenOfPreviousElement = previousElement && getFirstToken(previousElement);
  66644. var previousElementLastToken = previousElement && sourceCode.getLastToken(previousElement);
  66645. if (previousElement && previousElementLastToken.loc.end.line - countTrailingLinebreaks(previousElementLastToken.value) > startToken.loc.end.line) {
  66646. offsets.setDesiredOffsets([previousElement.range[1], element.range[1]], firstTokenOfPreviousElement, 0);
  66647. }
  66648. }
  66649. });
  66650. }
  66651. /**
  66652. * Check and decide whether to check for indentation for blockless nodes
  66653. * Scenarios are for or while statements without braces around them
  66654. * @param {ASTNode} node node to examine
  66655. * @returns {void}
  66656. */
  66657. function addBlocklessNodeIndent(node) {
  66658. if (node.type !== "BlockStatement") {
  66659. var lastParentToken = sourceCode.getTokenBefore(node, astUtils.isNotOpeningParenToken);
  66660. var firstBodyToken = sourceCode.getFirstToken(node);
  66661. var lastBodyToken = sourceCode.getLastToken(node);
  66662. while (astUtils.isOpeningParenToken(sourceCode.getTokenBefore(firstBodyToken)) && astUtils.isClosingParenToken(sourceCode.getTokenAfter(lastBodyToken))) {
  66663. firstBodyToken = sourceCode.getTokenBefore(firstBodyToken);
  66664. lastBodyToken = sourceCode.getTokenAfter(lastBodyToken);
  66665. }
  66666. offsets.setDesiredOffsets([firstBodyToken.range[0], lastBodyToken.range[1]], lastParentToken, 1);
  66667. /*
  66668. * For blockless nodes with semicolon-first style, don't indent the semicolon.
  66669. * e.g.
  66670. * if (foo) bar()
  66671. * ; [1, 2, 3].map(foo)
  66672. */
  66673. var lastToken = sourceCode.getLastToken(node);
  66674. if (node.type !== "EmptyStatement" && astUtils.isSemicolonToken(lastToken)) {
  66675. offsets.setDesiredOffset(lastToken, lastParentToken, 0);
  66676. }
  66677. }
  66678. }
  66679. /**
  66680. * Checks the indentation for nodes that are like function calls (`CallExpression` and `NewExpression`)
  66681. * @param {ASTNode} node A CallExpression or NewExpression node
  66682. * @returns {void}
  66683. */
  66684. function addFunctionCallIndent(node) {
  66685. var openingParen = void 0;
  66686. if (node.arguments.length) {
  66687. openingParen = sourceCode.getFirstTokenBetween(node.callee, node.arguments[0], astUtils.isOpeningParenToken);
  66688. } else {
  66689. openingParen = sourceCode.getLastToken(node, 1);
  66690. }
  66691. var closingParen = sourceCode.getLastToken(node);
  66692. parameterParens.add(openingParen);
  66693. parameterParens.add(closingParen);
  66694. offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0);
  66695. addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments);
  66696. }
  66697. /**
  66698. * Checks the indentation of parenthesized values, given a list of tokens in a program
  66699. * @param {Token[]} tokens A list of tokens
  66700. * @returns {void}
  66701. */
  66702. function addParensIndent(tokens) {
  66703. var parenStack = [];
  66704. var parenPairs = [];
  66705. tokens.forEach(function (nextToken) {
  66706. // Accumulate a list of parenthesis pairs
  66707. if (astUtils.isOpeningParenToken(nextToken)) {
  66708. parenStack.push(nextToken);
  66709. } else if (astUtils.isClosingParenToken(nextToken)) {
  66710. parenPairs.unshift({ left: parenStack.pop(), right: nextToken });
  66711. }
  66712. });
  66713. parenPairs.forEach(function (pair) {
  66714. var leftParen = pair.left;
  66715. var rightParen = pair.right;
  66716. // We only want to handle parens around expressions, so exclude parentheses that are in function parameters and function call arguments.
  66717. if (!parameterParens.has(leftParen) && !parameterParens.has(rightParen)) {
  66718. var parenthesizedTokens = new Set(sourceCode.getTokensBetween(leftParen, rightParen));
  66719. parenthesizedTokens.forEach(function (token) {
  66720. if (!parenthesizedTokens.has(offsets.getFirstDependency(token))) {
  66721. offsets.setDesiredOffset(token, leftParen, 1);
  66722. }
  66723. });
  66724. }
  66725. offsets.setDesiredOffset(rightParen, leftParen, 0);
  66726. });
  66727. }
  66728. /**
  66729. * Ignore all tokens within an unknown node whose offset do not depend
  66730. * on another token's offset within the unknown node
  66731. * @param {ASTNode} node Unknown Node
  66732. * @returns {void}
  66733. */
  66734. function ignoreNode(node) {
  66735. var unknownNodeTokens = new Set(sourceCode.getTokens(node, { includeComments: true }));
  66736. unknownNodeTokens.forEach(function (token) {
  66737. if (!unknownNodeTokens.has(offsets.getFirstDependency(token))) {
  66738. var firstTokenOfLine = tokenInfo.getFirstTokenOfLine(token);
  66739. if (token === firstTokenOfLine) {
  66740. offsets.ignoreToken(token);
  66741. } else {
  66742. offsets.setDesiredOffset(token, firstTokenOfLine, 0);
  66743. }
  66744. }
  66745. });
  66746. }
  66747. /**
  66748. * Check whether the given token is on the first line of a statement.
  66749. * @param {Token} token The token to check.
  66750. * @param {ASTNode} leafNode The expression node that the token belongs directly.
  66751. * @returns {boolean} `true` if the token is on the first line of a statement.
  66752. */
  66753. function isOnFirstLineOfStatement(token, leafNode) {
  66754. var node = leafNode;
  66755. while (node.parent && !node.parent.type.endsWith("Statement") && !node.parent.type.endsWith("Declaration")) {
  66756. node = node.parent;
  66757. }
  66758. node = node.parent;
  66759. return !node || node.loc.start.line === token.loc.start.line;
  66760. }
  66761. /**
  66762. * Check whether there are any blank (whitespace-only) lines between
  66763. * two tokens on separate lines.
  66764. * @param {Token} firstToken The first token.
  66765. * @param {Token} secondToken The second token.
  66766. * @returns {boolean} `true` if the tokens are on separate lines and
  66767. * there exists a blank line between them, `false` otherwise.
  66768. */
  66769. function hasBlankLinesBetween(firstToken, secondToken) {
  66770. var firstTokenLine = firstToken.loc.end.line;
  66771. var secondTokenLine = secondToken.loc.start.line;
  66772. if (firstTokenLine === secondTokenLine || firstTokenLine === secondTokenLine - 1) {
  66773. return false;
  66774. }
  66775. for (var line = firstTokenLine + 1; line < secondTokenLine; ++line) {
  66776. if (!tokenInfo.firstTokensByLineNumber.has(line)) {
  66777. return true;
  66778. }
  66779. }
  66780. return false;
  66781. }
  66782. var ignoredNodeFirstTokens = new Set();
  66783. var baseOffsetListeners = {
  66784. "ArrayExpression, ArrayPattern": function ArrayExpressionArrayPattern(node) {
  66785. var openingBracket = sourceCode.getFirstToken(node);
  66786. var closingBracket = sourceCode.getTokenAfter(lodash.findLast(node.elements) || openingBracket, astUtils.isClosingBracketToken);
  66787. addElementListIndent(node.elements, openingBracket, closingBracket, options.ArrayExpression);
  66788. },
  66789. "ObjectExpression, ObjectPattern": function ObjectExpressionObjectPattern(node) {
  66790. var openingCurly = sourceCode.getFirstToken(node);
  66791. var closingCurly = sourceCode.getTokenAfter(node.properties.length ? node.properties[node.properties.length - 1] : openingCurly, astUtils.isClosingBraceToken);
  66792. addElementListIndent(node.properties, openingCurly, closingCurly, options.ObjectExpression);
  66793. },
  66794. ArrowFunctionExpression: function ArrowFunctionExpression(node) {
  66795. var firstToken = sourceCode.getFirstToken(node);
  66796. if (astUtils.isOpeningParenToken(firstToken)) {
  66797. var openingParen = firstToken;
  66798. var closingParen = sourceCode.getTokenBefore(node.body, astUtils.isClosingParenToken);
  66799. parameterParens.add(openingParen);
  66800. parameterParens.add(closingParen);
  66801. addElementListIndent(node.params, openingParen, closingParen, options.FunctionExpression.parameters);
  66802. }
  66803. addBlocklessNodeIndent(node.body);
  66804. },
  66805. AssignmentExpression: function AssignmentExpression(node) {
  66806. var operator = sourceCode.getFirstTokenBetween(node.left, node.right, function (token) {
  66807. return token.value === node.operator;
  66808. });
  66809. offsets.setDesiredOffsets([operator.range[0], node.range[1]], sourceCode.getLastToken(node.left), 1);
  66810. offsets.ignoreToken(operator);
  66811. offsets.ignoreToken(sourceCode.getTokenAfter(operator));
  66812. },
  66813. "BinaryExpression, LogicalExpression": function BinaryExpressionLogicalExpression(node) {
  66814. var operator = sourceCode.getFirstTokenBetween(node.left, node.right, function (token) {
  66815. return token.value === node.operator;
  66816. });
  66817. /*
  66818. * For backwards compatibility, don't check BinaryExpression indents, e.g.
  66819. * var foo = bar &&
  66820. * baz;
  66821. */
  66822. var tokenAfterOperator = sourceCode.getTokenAfter(operator);
  66823. offsets.ignoreToken(operator);
  66824. offsets.ignoreToken(tokenAfterOperator);
  66825. offsets.setDesiredOffset(tokenAfterOperator, operator, 0);
  66826. },
  66827. "BlockStatement, ClassBody": function BlockStatementClassBody(node) {
  66828. var blockIndentLevel = void 0;
  66829. if (node.parent && isOuterIIFE(node.parent)) {
  66830. blockIndentLevel = options.outerIIFEBody;
  66831. } else if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "ArrowFunctionExpression")) {
  66832. blockIndentLevel = options.FunctionExpression.body;
  66833. } else if (node.parent && node.parent.type === "FunctionDeclaration") {
  66834. blockIndentLevel = options.FunctionDeclaration.body;
  66835. } else {
  66836. blockIndentLevel = 1;
  66837. }
  66838. /*
  66839. * For blocks that aren't lone statements, ensure that the opening curly brace
  66840. * is aligned with the parent.
  66841. */
  66842. if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
  66843. offsets.setDesiredOffset(sourceCode.getFirstToken(node), sourceCode.getFirstToken(node.parent), 0);
  66844. }
  66845. addElementListIndent(node.body, sourceCode.getFirstToken(node), sourceCode.getLastToken(node), blockIndentLevel);
  66846. },
  66847. CallExpression: addFunctionCallIndent,
  66848. "ClassDeclaration[superClass], ClassExpression[superClass]": function ClassDeclarationSuperClassClassExpressionSuperClass(node) {
  66849. var classToken = sourceCode.getFirstToken(node);
  66850. var extendsToken = sourceCode.getTokenBefore(node.superClass, astUtils.isNotOpeningParenToken);
  66851. offsets.setDesiredOffsets([extendsToken.range[0], node.body.range[0]], classToken, 1);
  66852. },
  66853. ConditionalExpression: function ConditionalExpression(node) {
  66854. var firstToken = sourceCode.getFirstToken(node);
  66855. // `flatTernaryExpressions` option is for the following style:
  66856. // var a =
  66857. // foo > 0 ? bar :
  66858. // foo < 0 ? baz :
  66859. // /*else*/ qiz ;
  66860. if (!options.flatTernaryExpressions || !astUtils.isTokenOnSameLine(node.test, node.consequent) || isOnFirstLineOfStatement(firstToken, node)) {
  66861. var questionMarkToken = sourceCode.getFirstTokenBetween(node.test, node.consequent, function (token) {
  66862. return token.type === "Punctuator" && token.value === "?";
  66863. });
  66864. var colonToken = sourceCode.getFirstTokenBetween(node.consequent, node.alternate, function (token) {
  66865. return token.type === "Punctuator" && token.value === ":";
  66866. });
  66867. var firstConsequentToken = sourceCode.getTokenAfter(questionMarkToken);
  66868. var lastConsequentToken = sourceCode.getTokenBefore(colonToken);
  66869. var firstAlternateToken = sourceCode.getTokenAfter(colonToken);
  66870. offsets.setDesiredOffset(questionMarkToken, firstToken, 1);
  66871. offsets.setDesiredOffset(colonToken, firstToken, 1);
  66872. offsets.setDesiredOffset(firstConsequentToken, firstToken, 1);
  66873. /*
  66874. * The alternate and the consequent should usually have the same indentation.
  66875. * If they share part of a line, align the alternate against the first token of the consequent.
  66876. * This allows the alternate to be indented correctly in cases like this:
  66877. * foo ? (
  66878. * bar
  66879. * ) : ( // this '(' is aligned with the '(' above, so it's considered to be aligned with `foo`
  66880. * baz // as a result, `baz` is offset by 1 rather than 2
  66881. * )
  66882. */
  66883. if (lastConsequentToken.loc.end.line === firstAlternateToken.loc.start.line) {
  66884. offsets.setDesiredOffset(firstAlternateToken, firstConsequentToken, 0);
  66885. } else {
  66886. /**
  66887. * If the alternate and consequent do not share part of a line, offset the alternate from the first
  66888. * token of the conditional expression. For example:
  66889. * foo ? bar
  66890. * : baz
  66891. *
  66892. * If `baz` were aligned with `bar` rather than being offset by 1 from `foo`, `baz` would end up
  66893. * having no expected indentation.
  66894. */
  66895. offsets.setDesiredOffset(firstAlternateToken, firstToken, 1);
  66896. }
  66897. }
  66898. },
  66899. "DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement": function DoWhileStatementWhileStatementForInStatementForOfStatement(node) {
  66900. return addBlocklessNodeIndent(node.body);
  66901. },
  66902. ExportNamedDeclaration: function ExportNamedDeclaration(node) {
  66903. if (node.declaration === null) {
  66904. var closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken);
  66905. // Indent the specifiers in `export {foo, bar, baz}`
  66906. addElementListIndent(node.specifiers, sourceCode.getFirstToken(node, { skip: 1 }), closingCurly, 1);
  66907. if (node.source) {
  66908. // Indent everything after and including the `from` token in `export {foo, bar, baz} from 'qux'`
  66909. offsets.setDesiredOffsets([closingCurly.range[1], node.range[1]], sourceCode.getFirstToken(node), 1);
  66910. }
  66911. }
  66912. },
  66913. ForStatement: function ForStatement(node) {
  66914. var forOpeningParen = sourceCode.getFirstToken(node, 1);
  66915. if (node.init) {
  66916. offsets.setDesiredOffsets(node.init.range, forOpeningParen, 1);
  66917. }
  66918. if (node.test) {
  66919. offsets.setDesiredOffsets(node.test.range, forOpeningParen, 1);
  66920. }
  66921. if (node.update) {
  66922. offsets.setDesiredOffsets(node.update.range, forOpeningParen, 1);
  66923. }
  66924. addBlocklessNodeIndent(node.body);
  66925. },
  66926. "FunctionDeclaration, FunctionExpression": function FunctionDeclarationFunctionExpression(node) {
  66927. var closingParen = sourceCode.getTokenBefore(node.body);
  66928. var openingParen = sourceCode.getTokenBefore(node.params.length ? node.params[0] : closingParen);
  66929. parameterParens.add(openingParen);
  66930. parameterParens.add(closingParen);
  66931. addElementListIndent(node.params, openingParen, closingParen, options[node.type].parameters);
  66932. },
  66933. IfStatement: function IfStatement(node) {
  66934. addBlocklessNodeIndent(node.consequent);
  66935. if (node.alternate && node.alternate.type !== "IfStatement") {
  66936. addBlocklessNodeIndent(node.alternate);
  66937. }
  66938. },
  66939. ImportDeclaration: function ImportDeclaration(node) {
  66940. if (node.specifiers.some(function (specifier) {
  66941. return specifier.type === "ImportSpecifier";
  66942. })) {
  66943. var openingCurly = sourceCode.getFirstToken(node, astUtils.isOpeningBraceToken);
  66944. var closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken);
  66945. addElementListIndent(node.specifiers.filter(function (specifier) {
  66946. return specifier.type === "ImportSpecifier";
  66947. }), openingCurly, closingCurly, options.ImportDeclaration);
  66948. }
  66949. var fromToken = sourceCode.getLastToken(node, function (token) {
  66950. return token.type === "Identifier" && token.value === "from";
  66951. });
  66952. var sourceToken = sourceCode.getLastToken(node, function (token) {
  66953. return token.type === "String";
  66954. });
  66955. var semiToken = sourceCode.getLastToken(node, function (token) {
  66956. return token.type === "Punctuator" && token.value === ";";
  66957. });
  66958. if (fromToken) {
  66959. var end = semiToken && semiToken.range[1] === sourceToken.range[1] ? node.range[1] : sourceToken.range[1];
  66960. offsets.setDesiredOffsets([fromToken.range[0], end], sourceCode.getFirstToken(node), 1);
  66961. }
  66962. },
  66963. "MemberExpression, JSXMemberExpression, MetaProperty": function MemberExpressionJSXMemberExpressionMetaProperty(node) {
  66964. var object = node.type === "MetaProperty" ? node.meta : node.object;
  66965. var firstNonObjectToken = sourceCode.getFirstTokenBetween(object, node.property, astUtils.isNotClosingParenToken);
  66966. var secondNonObjectToken = sourceCode.getTokenAfter(firstNonObjectToken);
  66967. var objectParenCount = sourceCode.getTokensBetween(object, node.property, { filter: astUtils.isClosingParenToken }).length;
  66968. var firstObjectToken = objectParenCount ? sourceCode.getTokenBefore(object, { skip: objectParenCount - 1 }) : sourceCode.getFirstToken(object);
  66969. var lastObjectToken = sourceCode.getTokenBefore(firstNonObjectToken);
  66970. var firstPropertyToken = node.computed ? firstNonObjectToken : secondNonObjectToken;
  66971. if (node.computed) {
  66972. // For computed MemberExpressions, match the closing bracket with the opening bracket.
  66973. offsets.setDesiredOffset(sourceCode.getLastToken(node), firstNonObjectToken, 0);
  66974. offsets.setDesiredOffsets(node.property.range, firstNonObjectToken, 1);
  66975. }
  66976. /*
  66977. * If the object ends on the same line that the property starts, match against the last token
  66978. * of the object, to ensure that the MemberExpression is not indented.
  66979. *
  66980. * Otherwise, match against the first token of the object, e.g.
  66981. * foo
  66982. * .bar
  66983. * .baz // <-- offset by 1 from `foo`
  66984. */
  66985. var offsetBase = lastObjectToken.loc.end.line === firstPropertyToken.loc.start.line ? lastObjectToken : firstObjectToken;
  66986. if (typeof options.MemberExpression === "number") {
  66987. // Match the dot (for non-computed properties) or the opening bracket (for computed properties) against the object.
  66988. offsets.setDesiredOffset(firstNonObjectToken, offsetBase, options.MemberExpression);
  66989. /*
  66990. * For computed MemberExpressions, match the first token of the property against the opening bracket.
  66991. * Otherwise, match the first token of the property against the object.
  66992. */
  66993. offsets.setDesiredOffset(secondNonObjectToken, node.computed ? firstNonObjectToken : offsetBase, options.MemberExpression);
  66994. } else {
  66995. // If the MemberExpression option is off, ignore the dot and the first token of the property.
  66996. offsets.ignoreToken(firstNonObjectToken);
  66997. offsets.ignoreToken(secondNonObjectToken);
  66998. // To ignore the property indentation, ensure that the property tokens depend on the ignored tokens.
  66999. offsets.setDesiredOffset(firstNonObjectToken, offsetBase, 0);
  67000. offsets.setDesiredOffset(secondNonObjectToken, firstNonObjectToken, 0);
  67001. }
  67002. },
  67003. NewExpression: function NewExpression(node) {
  67004. // Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo`
  67005. if (node.arguments.length > 0 || astUtils.isClosingParenToken(sourceCode.getLastToken(node)) && astUtils.isOpeningParenToken(sourceCode.getLastToken(node, 1))) {
  67006. addFunctionCallIndent(node);
  67007. }
  67008. },
  67009. Property: function Property(node) {
  67010. if (!node.shorthand && !node.method && node.kind === "init") {
  67011. var colon = sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isColonToken);
  67012. offsets.ignoreToken(sourceCode.getTokenAfter(colon));
  67013. }
  67014. },
  67015. SwitchStatement: function SwitchStatement(node) {
  67016. var openingCurly = sourceCode.getTokenAfter(node.discriminant, astUtils.isOpeningBraceToken);
  67017. var closingCurly = sourceCode.getLastToken(node);
  67018. offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, options.SwitchCase);
  67019. if (node.cases.length) {
  67020. sourceCode.getTokensBetween(node.cases[node.cases.length - 1], closingCurly, { includeComments: true, filter: astUtils.isCommentToken }).forEach(function (token) {
  67021. return offsets.ignoreToken(token);
  67022. });
  67023. }
  67024. },
  67025. SwitchCase: function SwitchCase(node) {
  67026. if (!(node.consequent.length === 1 && node.consequent[0].type === "BlockStatement")) {
  67027. var caseKeyword = sourceCode.getFirstToken(node);
  67028. var tokenAfterCurrentCase = sourceCode.getTokenAfter(node);
  67029. offsets.setDesiredOffsets([caseKeyword.range[1], tokenAfterCurrentCase.range[0]], caseKeyword, 1);
  67030. }
  67031. },
  67032. TemplateLiteral: function TemplateLiteral(node) {
  67033. node.expressions.forEach(function (expression, index) {
  67034. var previousQuasi = node.quasis[index];
  67035. var nextQuasi = node.quasis[index + 1];
  67036. var tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line ? sourceCode.getFirstToken(previousQuasi) : null;
  67037. offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1);
  67038. offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0);
  67039. });
  67040. },
  67041. VariableDeclaration: function VariableDeclaration(node) {
  67042. var variableIndent = Object.prototype.hasOwnProperty.call(options.VariableDeclarator, node.kind) ? options.VariableDeclarator[node.kind] : DEFAULT_VARIABLE_INDENT;
  67043. var firstToken = sourceCode.getFirstToken(node),
  67044. lastToken = sourceCode.getLastToken(node);
  67045. if (options.VariableDeclarator[node.kind] === "first") {
  67046. if (node.declarations.length > 1) {
  67047. addElementListIndent(node.declarations, firstToken, lastToken, "first");
  67048. return;
  67049. }
  67050. variableIndent = DEFAULT_VARIABLE_INDENT;
  67051. }
  67052. if (node.declarations[node.declarations.length - 1].loc.start.line > node.loc.start.line) {
  67053. /*
  67054. * VariableDeclarator indentation is a bit different from other forms of indentation, in that the
  67055. * indentation of an opening bracket sometimes won't match that of a closing bracket. For example,
  67056. * the following indentations are correct:
  67057. *
  67058. * var foo = {
  67059. * ok: true
  67060. * };
  67061. *
  67062. * var foo = {
  67063. * ok: true,
  67064. * },
  67065. * bar = 1;
  67066. *
  67067. * Account for when exiting the AST (after indentations have already been set for the nodes in
  67068. * the declaration) by manually increasing the indentation level of the tokens in this declarator
  67069. * on the same line as the start of the declaration, provided that there are declarators that
  67070. * follow this one.
  67071. */
  67072. offsets.setDesiredOffsets(node.range, firstToken, variableIndent, true);
  67073. } else {
  67074. offsets.setDesiredOffsets(node.range, firstToken, variableIndent);
  67075. }
  67076. if (astUtils.isSemicolonToken(lastToken)) {
  67077. offsets.ignoreToken(lastToken);
  67078. }
  67079. },
  67080. VariableDeclarator: function VariableDeclarator(node) {
  67081. if (node.init) {
  67082. var equalOperator = sourceCode.getTokenBefore(node.init, astUtils.isNotOpeningParenToken);
  67083. var tokenAfterOperator = sourceCode.getTokenAfter(equalOperator);
  67084. offsets.ignoreToken(equalOperator);
  67085. offsets.ignoreToken(tokenAfterOperator);
  67086. offsets.setDesiredOffsets([tokenAfterOperator.range[0], node.range[1]], equalOperator, 1);
  67087. offsets.setDesiredOffset(equalOperator, sourceCode.getLastToken(node.id), 0);
  67088. }
  67089. },
  67090. "JSXAttribute[value]": function JSXAttributeValue(node) {
  67091. var equalsToken = sourceCode.getFirstTokenBetween(node.name, node.value, function (token) {
  67092. return token.type === "Punctuator" && token.value === "=";
  67093. });
  67094. offsets.setDesiredOffsets([equalsToken.range[0], node.value.range[1]], sourceCode.getFirstToken(node.name), 1);
  67095. },
  67096. JSXElement: function JSXElement(node) {
  67097. if (node.closingElement) {
  67098. addElementListIndent(node.children, sourceCode.getFirstToken(node.openingElement), sourceCode.getFirstToken(node.closingElement), 1);
  67099. }
  67100. },
  67101. JSXOpeningElement: function JSXOpeningElement(node) {
  67102. var firstToken = sourceCode.getFirstToken(node);
  67103. var closingToken = void 0;
  67104. if (node.selfClosing) {
  67105. closingToken = sourceCode.getLastToken(node, { skip: 1 });
  67106. offsets.setDesiredOffset(sourceCode.getLastToken(node), closingToken, 0);
  67107. } else {
  67108. closingToken = sourceCode.getLastToken(node);
  67109. }
  67110. offsets.setDesiredOffsets(node.name.range, sourceCode.getFirstToken(node));
  67111. addElementListIndent(node.attributes, firstToken, closingToken, 1);
  67112. },
  67113. JSXClosingElement: function JSXClosingElement(node) {
  67114. var firstToken = sourceCode.getFirstToken(node);
  67115. offsets.setDesiredOffsets(node.name.range, firstToken, 1);
  67116. },
  67117. JSXExpressionContainer: function JSXExpressionContainer(node) {
  67118. var openingCurly = sourceCode.getFirstToken(node);
  67119. var closingCurly = sourceCode.getLastToken(node);
  67120. offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, 1);
  67121. },
  67122. "*": function _(node) {
  67123. var firstToken = sourceCode.getFirstToken(node);
  67124. // Ensure that the children of every node are indented at least as much as the first token.
  67125. if (firstToken && !ignoredNodeFirstTokens.has(firstToken)) {
  67126. offsets.setDesiredOffsets(node.range, firstToken, 0);
  67127. }
  67128. }
  67129. };
  67130. var listenerCallQueue = [];
  67131. /*
  67132. * To ignore the indentation of a node:
  67133. * 1. Don't call the node's listener when entering it (if it has a listener)
  67134. * 2. Don't set any offsets against the first token of the node.
  67135. * 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets.
  67136. */
  67137. var offsetListeners = lodash.mapValues(baseOffsetListeners,
  67138. /*
  67139. * Offset listener calls are deferred until traversal is finished, and are called as
  67140. * part of the final `Program:exit` listener. This is necessary because a node might
  67141. * be matched by multiple selectors.
  67142. *
  67143. * Example: Suppose there is an offset listener for `Identifier`, and the user has
  67144. * specified in configuration that `MemberExpression > Identifier` should be ignored.
  67145. * Due to selector specificity rules, the `Identifier` listener will get called first. However,
  67146. * if a given Identifier node is supposed to be ignored, then the `Identifier` offset listener
  67147. * should not have been called at all. Without doing extra selector matching, we don't know
  67148. * whether the Identifier matches the `MemberExpression > Identifier` selector until the
  67149. * `MemberExpression > Identifier` listener is called.
  67150. *
  67151. * To avoid this, the `Identifier` listener isn't called until traversal finishes and all
  67152. * ignored nodes are known.
  67153. */
  67154. function (listener) {
  67155. return function (node) {
  67156. return listenerCallQueue.push({ listener: listener, node: node });
  67157. };
  67158. });
  67159. // For each ignored node selector, set up a listener to collect it into the `ignoredNodes` set.
  67160. var ignoredNodes = new Set();
  67161. /**
  67162. * Ignores a node
  67163. * @param {ASTNode} node The node to ignore
  67164. * @returns {void}
  67165. */
  67166. function addToIgnoredNodes(node) {
  67167. ignoredNodes.add(node);
  67168. ignoredNodeFirstTokens.add(sourceCode.getFirstToken(node));
  67169. }
  67170. var ignoredNodeListeners = options.ignoredNodes.reduce(function (listeners, ignoredSelector) {
  67171. return Object.assign(listeners, _defineProperty({}, ignoredSelector, addToIgnoredNodes));
  67172. }, {});
  67173. /*
  67174. * Join the listeners, and add a listener to verify that all tokens actually have the correct indentation
  67175. * at the end.
  67176. *
  67177. * Using Object.assign will cause some offset listeners to be overwritten if the same selector also appears
  67178. * in `ignoredNodeListeners`. This isn't a problem because all of the matching nodes will be ignored,
  67179. * so those listeners wouldn't be called anyway.
  67180. */
  67181. return Object.assign(offsetListeners, ignoredNodeListeners, {
  67182. "*:exit": function exit(node) {
  67183. // If a node's type is nonstandard, we can't tell how its children should be offset, so ignore it.
  67184. if (!KNOWN_NODES.has(node.type)) {
  67185. addToIgnoredNodes(node);
  67186. }
  67187. },
  67188. "Program:exit": function ProgramExit() {
  67189. // If ignoreComments option is enabled, ignore all comment tokens.
  67190. if (options.ignoreComments) {
  67191. sourceCode.getAllComments().forEach(function (comment) {
  67192. return offsets.ignoreToken(comment);
  67193. });
  67194. }
  67195. // Invoke the queued offset listeners for the nodes that aren't ignored.
  67196. listenerCallQueue.filter(function (nodeInfo) {
  67197. return !ignoredNodes.has(nodeInfo.node);
  67198. }).forEach(function (nodeInfo) {
  67199. return nodeInfo.listener(nodeInfo.node);
  67200. });
  67201. // Update the offsets for ignored nodes to prevent their child tokens from being reported.
  67202. ignoredNodes.forEach(ignoreNode);
  67203. addParensIndent(sourceCode.ast.tokens);
  67204. /*
  67205. * Create a Map from (tokenOrComment) => (precedingToken).
  67206. * This is necessary because sourceCode.getTokenBefore does not handle a comment as an argument correctly.
  67207. */
  67208. var precedingTokens = sourceCode.ast.comments.reduce(function (commentMap, comment) {
  67209. var tokenOrCommentBefore = sourceCode.getTokenBefore(comment, { includeComments: true });
  67210. return commentMap.set(comment, commentMap.has(tokenOrCommentBefore) ? commentMap.get(tokenOrCommentBefore) : tokenOrCommentBefore);
  67211. }, new WeakMap());
  67212. sourceCode.lines.forEach(function (line, lineIndex) {
  67213. var lineNumber = lineIndex + 1;
  67214. if (!tokenInfo.firstTokensByLineNumber.has(lineNumber)) {
  67215. // Don't check indentation on blank lines
  67216. return;
  67217. }
  67218. var firstTokenOfLine = tokenInfo.firstTokensByLineNumber.get(lineNumber);
  67219. if (firstTokenOfLine.loc.start.line !== lineNumber) {
  67220. // Don't check the indentation of multi-line tokens (e.g. template literals or block comments) twice.
  67221. return;
  67222. }
  67223. // If the token matches the expected expected indentation, don't report it.
  67224. if (validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine))) {
  67225. return;
  67226. }
  67227. if (astUtils.isCommentToken(firstTokenOfLine)) {
  67228. var tokenBefore = precedingTokens.get(firstTokenOfLine);
  67229. var tokenAfter = tokenBefore ? sourceCode.getTokenAfter(tokenBefore) : sourceCode.ast.tokens[0];
  67230. var mayAlignWithBefore = tokenBefore && !hasBlankLinesBetween(tokenBefore, firstTokenOfLine);
  67231. var mayAlignWithAfter = tokenAfter && !hasBlankLinesBetween(firstTokenOfLine, tokenAfter);
  67232. // If a comment matches the expected indentation of the token immediately before or after, don't report it.
  67233. if (mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) || mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))) {
  67234. return;
  67235. }
  67236. }
  67237. // Otherwise, report the token/comment.
  67238. report(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine));
  67239. });
  67240. }
  67241. });
  67242. }
  67243. };
  67244. },{"../util/ast-utils":405,"functional-red-black-tree":83,"lodash":92}],171:[function(require,module,exports){
  67245. /**
  67246. * @fileoverview A rule to control the style of variable initializations.
  67247. * @author Colin Ihrig
  67248. */
  67249. "use strict";
  67250. //------------------------------------------------------------------------------
  67251. // Helpers
  67252. //------------------------------------------------------------------------------
  67253. /**
  67254. * Checks whether or not a given node is a for loop.
  67255. * @param {ASTNode} block - A node to check.
  67256. * @returns {boolean} `true` when the node is a for loop.
  67257. */
  67258. function isForLoop(block) {
  67259. return block.type === "ForInStatement" || block.type === "ForOfStatement" || block.type === "ForStatement";
  67260. }
  67261. /**
  67262. * Checks whether or not a given declarator node has its initializer.
  67263. * @param {ASTNode} node - A declarator node to check.
  67264. * @returns {boolean} `true` when the node has its initializer.
  67265. */
  67266. function isInitialized(node) {
  67267. var declaration = node.parent;
  67268. var block = declaration.parent;
  67269. if (isForLoop(block)) {
  67270. if (block.type === "ForStatement") {
  67271. return block.init === declaration;
  67272. }
  67273. return block.left === declaration;
  67274. }
  67275. return Boolean(node.init);
  67276. }
  67277. //------------------------------------------------------------------------------
  67278. // Rule Definition
  67279. //------------------------------------------------------------------------------
  67280. module.exports = {
  67281. meta: {
  67282. type: "suggestion",
  67283. docs: {
  67284. description: "require or disallow initialization in variable declarations",
  67285. category: "Variables",
  67286. recommended: false,
  67287. url: "https://eslint.org/docs/rules/init-declarations"
  67288. },
  67289. schema: {
  67290. anyOf: [{
  67291. type: "array",
  67292. items: [{
  67293. enum: ["always"]
  67294. }],
  67295. minItems: 0,
  67296. maxItems: 1
  67297. }, {
  67298. type: "array",
  67299. items: [{
  67300. enum: ["never"]
  67301. }, {
  67302. type: "object",
  67303. properties: {
  67304. ignoreForLoopInit: {
  67305. type: "boolean"
  67306. }
  67307. },
  67308. additionalProperties: false
  67309. }],
  67310. minItems: 0,
  67311. maxItems: 2
  67312. }]
  67313. }
  67314. },
  67315. create: function create(context) {
  67316. var MODE_ALWAYS = "always",
  67317. MODE_NEVER = "never";
  67318. var mode = context.options[0] || MODE_ALWAYS;
  67319. var params = context.options[1] || {};
  67320. //--------------------------------------------------------------------------
  67321. // Public API
  67322. //--------------------------------------------------------------------------
  67323. return {
  67324. "VariableDeclaration:exit": function VariableDeclarationExit(node) {
  67325. var kind = node.kind,
  67326. declarations = node.declarations;
  67327. for (var i = 0; i < declarations.length; ++i) {
  67328. var declaration = declarations[i],
  67329. id = declaration.id,
  67330. initialized = isInitialized(declaration),
  67331. isIgnoredForLoop = params.ignoreForLoopInit && isForLoop(node.parent);
  67332. if (id.type !== "Identifier") {
  67333. continue;
  67334. }
  67335. if (mode === MODE_ALWAYS && !initialized) {
  67336. context.report({
  67337. node: declaration,
  67338. message: "Variable '{{idName}}' should be initialized on declaration.",
  67339. data: {
  67340. idName: id.name
  67341. }
  67342. });
  67343. } else if (mode === MODE_NEVER && kind !== "const" && initialized && !isIgnoredForLoop) {
  67344. context.report({
  67345. node: declaration,
  67346. message: "Variable '{{idName}}' should not be initialized on declaration.",
  67347. data: {
  67348. idName: id.name
  67349. }
  67350. });
  67351. }
  67352. }
  67353. }
  67354. };
  67355. }
  67356. };
  67357. },{}],172:[function(require,module,exports){
  67358. /**
  67359. * @fileoverview A rule to ensure consistent quotes used in jsx syntax.
  67360. * @author Mathias Schreck <https://github.com/lo1tuma>
  67361. */
  67362. "use strict";
  67363. //------------------------------------------------------------------------------
  67364. // Requirements
  67365. //------------------------------------------------------------------------------
  67366. var astUtils = require("../util/ast-utils");
  67367. //------------------------------------------------------------------------------
  67368. // Constants
  67369. //------------------------------------------------------------------------------
  67370. var QUOTE_SETTINGS = {
  67371. "prefer-double": {
  67372. quote: "\"",
  67373. description: "singlequote",
  67374. convert: function convert(str) {
  67375. return str.replace(/'/g, "\"");
  67376. }
  67377. },
  67378. "prefer-single": {
  67379. quote: "'",
  67380. description: "doublequote",
  67381. convert: function convert(str) {
  67382. return str.replace(/"/g, "'");
  67383. }
  67384. }
  67385. };
  67386. //------------------------------------------------------------------------------
  67387. // Rule Definition
  67388. //------------------------------------------------------------------------------
  67389. module.exports = {
  67390. meta: {
  67391. type: "layout",
  67392. docs: {
  67393. description: "enforce the consistent use of either double or single quotes in JSX attributes",
  67394. category: "Stylistic Issues",
  67395. recommended: false,
  67396. url: "https://eslint.org/docs/rules/jsx-quotes"
  67397. },
  67398. fixable: "whitespace",
  67399. schema: [{
  67400. enum: ["prefer-single", "prefer-double"]
  67401. }]
  67402. },
  67403. create: function create(context) {
  67404. var quoteOption = context.options[0] || "prefer-double",
  67405. setting = QUOTE_SETTINGS[quoteOption];
  67406. /**
  67407. * Checks if the given string literal node uses the expected quotes
  67408. * @param {ASTNode} node - A string literal node.
  67409. * @returns {boolean} Whether or not the string literal used the expected quotes.
  67410. * @public
  67411. */
  67412. function usesExpectedQuotes(node) {
  67413. return node.value.indexOf(setting.quote) !== -1 || astUtils.isSurroundedBy(node.raw, setting.quote);
  67414. }
  67415. return {
  67416. JSXAttribute: function JSXAttribute(node) {
  67417. var attributeValue = node.value;
  67418. if (attributeValue && astUtils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) {
  67419. context.report({
  67420. node: attributeValue,
  67421. message: "Unexpected usage of {{description}}.",
  67422. data: {
  67423. description: setting.description
  67424. },
  67425. fix: function fix(fixer) {
  67426. return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw));
  67427. }
  67428. });
  67429. }
  67430. }
  67431. };
  67432. }
  67433. };
  67434. },{"../util/ast-utils":405}],173:[function(require,module,exports){
  67435. /**
  67436. * @fileoverview Rule to specify spacing of object literal keys and values
  67437. * @author Brandon Mills
  67438. */
  67439. "use strict";
  67440. //------------------------------------------------------------------------------
  67441. // Requirements
  67442. //------------------------------------------------------------------------------
  67443. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  67444. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  67445. var astUtils = require("../util/ast-utils");
  67446. //------------------------------------------------------------------------------
  67447. // Helpers
  67448. //------------------------------------------------------------------------------
  67449. /**
  67450. * Checks whether a string contains a line terminator as defined in
  67451. * http://www.ecma-international.org/ecma-262/5.1/#sec-7.3
  67452. * @param {string} str String to test.
  67453. * @returns {boolean} True if str contains a line terminator.
  67454. */
  67455. function containsLineTerminator(str) {
  67456. return astUtils.LINEBREAK_MATCHER.test(str);
  67457. }
  67458. /**
  67459. * Gets the last element of an array.
  67460. * @param {Array} arr An array.
  67461. * @returns {any} Last element of arr.
  67462. */
  67463. function last(arr) {
  67464. return arr[arr.length - 1];
  67465. }
  67466. /**
  67467. * Checks whether a node is contained on a single line.
  67468. * @param {ASTNode} node AST Node being evaluated.
  67469. * @returns {boolean} True if the node is a single line.
  67470. */
  67471. function isSingleLine(node) {
  67472. return node.loc.end.line === node.loc.start.line;
  67473. }
  67474. /**
  67475. * Initializes a single option property from the configuration with defaults for undefined values
  67476. * @param {Object} toOptions Object to be initialized
  67477. * @param {Object} fromOptions Object to be initialized from
  67478. * @returns {Object} The object with correctly initialized options and values
  67479. */
  67480. function initOptionProperty(toOptions, fromOptions) {
  67481. toOptions.mode = fromOptions.mode || "strict";
  67482. // Set value of beforeColon
  67483. if (typeof fromOptions.beforeColon !== "undefined") {
  67484. toOptions.beforeColon = +fromOptions.beforeColon;
  67485. } else {
  67486. toOptions.beforeColon = 0;
  67487. }
  67488. // Set value of afterColon
  67489. if (typeof fromOptions.afterColon !== "undefined") {
  67490. toOptions.afterColon = +fromOptions.afterColon;
  67491. } else {
  67492. toOptions.afterColon = 1;
  67493. }
  67494. // Set align if exists
  67495. if (typeof fromOptions.align !== "undefined") {
  67496. if (_typeof(fromOptions.align) === "object") {
  67497. toOptions.align = fromOptions.align;
  67498. } else {
  67499. // "string"
  67500. toOptions.align = {
  67501. on: fromOptions.align,
  67502. mode: toOptions.mode,
  67503. beforeColon: toOptions.beforeColon,
  67504. afterColon: toOptions.afterColon
  67505. };
  67506. }
  67507. }
  67508. return toOptions;
  67509. }
  67510. /**
  67511. * Initializes all the option values (singleLine, multiLine and align) from the configuration with defaults for undefined values
  67512. * @param {Object} toOptions Object to be initialized
  67513. * @param {Object} fromOptions Object to be initialized from
  67514. * @returns {Object} The object with correctly initialized options and values
  67515. */
  67516. function initOptions(toOptions, fromOptions) {
  67517. if (_typeof(fromOptions.align) === "object") {
  67518. // Initialize the alignment configuration
  67519. toOptions.align = initOptionProperty({}, fromOptions.align);
  67520. toOptions.align.on = fromOptions.align.on || "colon";
  67521. toOptions.align.mode = fromOptions.align.mode || "strict";
  67522. toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
  67523. toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions);
  67524. } else {
  67525. // string or undefined
  67526. toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
  67527. toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions);
  67528. // If alignment options are defined in multiLine, pull them out into the general align configuration
  67529. if (toOptions.multiLine.align) {
  67530. toOptions.align = {
  67531. on: toOptions.multiLine.align.on,
  67532. mode: toOptions.multiLine.align.mode || toOptions.multiLine.mode,
  67533. beforeColon: toOptions.multiLine.align.beforeColon,
  67534. afterColon: toOptions.multiLine.align.afterColon
  67535. };
  67536. }
  67537. }
  67538. return toOptions;
  67539. }
  67540. //------------------------------------------------------------------------------
  67541. // Rule Definition
  67542. //------------------------------------------------------------------------------
  67543. var messages = {
  67544. key: "{{error}} space after {{computed}}key '{{key}}'.",
  67545. value: "{{error}} space before value for {{computed}}key '{{key}}'."
  67546. };
  67547. module.exports = {
  67548. meta: {
  67549. type: "layout",
  67550. docs: {
  67551. description: "enforce consistent spacing between keys and values in object literal properties",
  67552. category: "Stylistic Issues",
  67553. recommended: false,
  67554. url: "https://eslint.org/docs/rules/key-spacing"
  67555. },
  67556. fixable: "whitespace",
  67557. schema: [{
  67558. anyOf: [{
  67559. type: "object",
  67560. properties: {
  67561. align: {
  67562. anyOf: [{
  67563. enum: ["colon", "value"]
  67564. }, {
  67565. type: "object",
  67566. properties: {
  67567. mode: {
  67568. enum: ["strict", "minimum"]
  67569. },
  67570. on: {
  67571. enum: ["colon", "value"]
  67572. },
  67573. beforeColon: {
  67574. type: "boolean"
  67575. },
  67576. afterColon: {
  67577. type: "boolean"
  67578. }
  67579. },
  67580. additionalProperties: false
  67581. }]
  67582. },
  67583. mode: {
  67584. enum: ["strict", "minimum"]
  67585. },
  67586. beforeColon: {
  67587. type: "boolean"
  67588. },
  67589. afterColon: {
  67590. type: "boolean"
  67591. }
  67592. },
  67593. additionalProperties: false
  67594. }, {
  67595. type: "object",
  67596. properties: {
  67597. singleLine: {
  67598. type: "object",
  67599. properties: {
  67600. mode: {
  67601. enum: ["strict", "minimum"]
  67602. },
  67603. beforeColon: {
  67604. type: "boolean"
  67605. },
  67606. afterColon: {
  67607. type: "boolean"
  67608. }
  67609. },
  67610. additionalProperties: false
  67611. },
  67612. multiLine: {
  67613. type: "object",
  67614. properties: {
  67615. align: {
  67616. anyOf: [{
  67617. enum: ["colon", "value"]
  67618. }, {
  67619. type: "object",
  67620. properties: {
  67621. mode: {
  67622. enum: ["strict", "minimum"]
  67623. },
  67624. on: {
  67625. enum: ["colon", "value"]
  67626. },
  67627. beforeColon: {
  67628. type: "boolean"
  67629. },
  67630. afterColon: {
  67631. type: "boolean"
  67632. }
  67633. },
  67634. additionalProperties: false
  67635. }]
  67636. },
  67637. mode: {
  67638. enum: ["strict", "minimum"]
  67639. },
  67640. beforeColon: {
  67641. type: "boolean"
  67642. },
  67643. afterColon: {
  67644. type: "boolean"
  67645. }
  67646. },
  67647. additionalProperties: false
  67648. }
  67649. },
  67650. additionalProperties: false
  67651. }, {
  67652. type: "object",
  67653. properties: {
  67654. singleLine: {
  67655. type: "object",
  67656. properties: {
  67657. mode: {
  67658. enum: ["strict", "minimum"]
  67659. },
  67660. beforeColon: {
  67661. type: "boolean"
  67662. },
  67663. afterColon: {
  67664. type: "boolean"
  67665. }
  67666. },
  67667. additionalProperties: false
  67668. },
  67669. multiLine: {
  67670. type: "object",
  67671. properties: {
  67672. mode: {
  67673. enum: ["strict", "minimum"]
  67674. },
  67675. beforeColon: {
  67676. type: "boolean"
  67677. },
  67678. afterColon: {
  67679. type: "boolean"
  67680. }
  67681. },
  67682. additionalProperties: false
  67683. },
  67684. align: {
  67685. type: "object",
  67686. properties: {
  67687. mode: {
  67688. enum: ["strict", "minimum"]
  67689. },
  67690. on: {
  67691. enum: ["colon", "value"]
  67692. },
  67693. beforeColon: {
  67694. type: "boolean"
  67695. },
  67696. afterColon: {
  67697. type: "boolean"
  67698. }
  67699. },
  67700. additionalProperties: false
  67701. }
  67702. },
  67703. additionalProperties: false
  67704. }]
  67705. }]
  67706. },
  67707. create: function create(context) {
  67708. /**
  67709. * OPTIONS
  67710. * "key-spacing": [2, {
  67711. * beforeColon: false,
  67712. * afterColon: true,
  67713. * align: "colon" // Optional, or "value"
  67714. * }
  67715. */
  67716. var options = context.options[0] || {},
  67717. ruleOptions = initOptions({}, options),
  67718. multiLineOptions = ruleOptions.multiLine,
  67719. singleLineOptions = ruleOptions.singleLine,
  67720. alignmentOptions = ruleOptions.align || null;
  67721. var sourceCode = context.getSourceCode();
  67722. /**
  67723. * Checks whether a property is a member of the property group it follows.
  67724. * @param {ASTNode} lastMember The last Property known to be in the group.
  67725. * @param {ASTNode} candidate The next Property that might be in the group.
  67726. * @returns {boolean} True if the candidate property is part of the group.
  67727. */
  67728. function continuesPropertyGroup(lastMember, candidate) {
  67729. var groupEndLine = lastMember.loc.start.line,
  67730. candidateStartLine = candidate.loc.start.line;
  67731. if (candidateStartLine - groupEndLine <= 1) {
  67732. return true;
  67733. }
  67734. /*
  67735. * Check that the first comment is adjacent to the end of the group, the
  67736. * last comment is adjacent to the candidate property, and that successive
  67737. * comments are adjacent to each other.
  67738. */
  67739. var leadingComments = sourceCode.getCommentsBefore(candidate);
  67740. if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateStartLine - last(leadingComments).loc.end.line <= 1) {
  67741. for (var i = 1; i < leadingComments.length; i++) {
  67742. if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) {
  67743. return false;
  67744. }
  67745. }
  67746. return true;
  67747. }
  67748. return false;
  67749. }
  67750. /**
  67751. * Determines if the given property is key-value property.
  67752. * @param {ASTNode} property Property node to check.
  67753. * @returns {boolean} Whether the property is a key-value property.
  67754. */
  67755. function isKeyValueProperty(property) {
  67756. return !(property.method || property.shorthand || property.kind !== "init" || property.type !== "Property");
  67757. }
  67758. /**
  67759. * Starting from the given a node (a property.key node here) looks forward
  67760. * until it finds the last token before a colon punctuator and returns it.
  67761. * @param {ASTNode} node The node to start looking from.
  67762. * @returns {ASTNode} The last token before a colon punctuator.
  67763. */
  67764. function getLastTokenBeforeColon(node) {
  67765. var colonToken = sourceCode.getTokenAfter(node, astUtils.isColonToken);
  67766. return sourceCode.getTokenBefore(colonToken);
  67767. }
  67768. /**
  67769. * Starting from the given a node (a property.key node here) looks forward
  67770. * until it finds the colon punctuator and returns it.
  67771. * @param {ASTNode} node The node to start looking from.
  67772. * @returns {ASTNode} The colon punctuator.
  67773. */
  67774. function getNextColon(node) {
  67775. return sourceCode.getTokenAfter(node, astUtils.isColonToken);
  67776. }
  67777. /**
  67778. * Gets an object literal property's key as the identifier name or string value.
  67779. * @param {ASTNode} property Property node whose key to retrieve.
  67780. * @returns {string} The property's key.
  67781. */
  67782. function getKey(property) {
  67783. var key = property.key;
  67784. if (property.computed) {
  67785. return sourceCode.getText().slice(key.range[0], key.range[1]);
  67786. }
  67787. return property.key.name || property.key.value;
  67788. }
  67789. /**
  67790. * Reports an appropriately-formatted error if spacing is incorrect on one
  67791. * side of the colon.
  67792. * @param {ASTNode} property Key-value pair in an object literal.
  67793. * @param {string} side Side being verified - either "key" or "value".
  67794. * @param {string} whitespace Actual whitespace string.
  67795. * @param {int} expected Expected whitespace length.
  67796. * @param {string} mode Value of the mode as "strict" or "minimum"
  67797. * @returns {void}
  67798. */
  67799. function report(property, side, whitespace, expected, mode) {
  67800. var diff = whitespace.length - expected,
  67801. nextColon = getNextColon(property.key),
  67802. tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: true }),
  67803. tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: true }),
  67804. isKeySide = side === "key",
  67805. locStart = isKeySide ? tokenBeforeColon.loc.start : tokenAfterColon.loc.start,
  67806. isExtra = diff > 0,
  67807. diffAbs = Math.abs(diff),
  67808. spaces = Array(diffAbs + 1).join(" ");
  67809. if ((diff && mode === "strict" || diff < 0 && mode === "minimum" || diff > 0 && !expected && mode === "minimum") && !(expected && containsLineTerminator(whitespace))) {
  67810. var fix = void 0;
  67811. if (isExtra) {
  67812. var range = void 0;
  67813. // Remove whitespace
  67814. if (isKeySide) {
  67815. range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs];
  67816. } else {
  67817. range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]];
  67818. }
  67819. fix = function fix(fixer) {
  67820. return fixer.removeRange(range);
  67821. };
  67822. } else {
  67823. // Add whitespace
  67824. if (isKeySide) {
  67825. fix = function fix(fixer) {
  67826. return fixer.insertTextAfter(tokenBeforeColon, spaces);
  67827. };
  67828. } else {
  67829. fix = function fix(fixer) {
  67830. return fixer.insertTextBefore(tokenAfterColon, spaces);
  67831. };
  67832. }
  67833. }
  67834. context.report({
  67835. node: property[side],
  67836. loc: locStart,
  67837. message: messages[side],
  67838. data: {
  67839. error: isExtra ? "Extra" : "Missing",
  67840. computed: property.computed ? "computed " : "",
  67841. key: getKey(property)
  67842. },
  67843. fix: fix
  67844. });
  67845. }
  67846. }
  67847. /**
  67848. * Gets the number of characters in a key, including quotes around string
  67849. * keys and braces around computed property keys.
  67850. * @param {ASTNode} property Property of on object literal.
  67851. * @returns {int} Width of the key.
  67852. */
  67853. function getKeyWidth(property) {
  67854. var startToken = sourceCode.getFirstToken(property);
  67855. var endToken = getLastTokenBeforeColon(property.key);
  67856. return endToken.range[1] - startToken.range[0];
  67857. }
  67858. /**
  67859. * Gets the whitespace around the colon in an object literal property.
  67860. * @param {ASTNode} property Property node from an object literal.
  67861. * @returns {Object} Whitespace before and after the property's colon.
  67862. */
  67863. function getPropertyWhitespace(property) {
  67864. var whitespace = /(\s*):(\s*)/.exec(sourceCode.getText().slice(property.key.range[1], property.value.range[0]));
  67865. if (whitespace) {
  67866. return {
  67867. beforeColon: whitespace[1],
  67868. afterColon: whitespace[2]
  67869. };
  67870. }
  67871. return null;
  67872. }
  67873. /**
  67874. * Creates groups of properties.
  67875. * @param {ASTNode} node ObjectExpression node being evaluated.
  67876. * @returns {Array.<ASTNode[]>} Groups of property AST node lists.
  67877. */
  67878. function createGroups(node) {
  67879. if (node.properties.length === 1) {
  67880. return [node.properties];
  67881. }
  67882. return node.properties.reduce(function (groups, property) {
  67883. var currentGroup = last(groups),
  67884. prev = last(currentGroup);
  67885. if (!prev || continuesPropertyGroup(prev, property)) {
  67886. currentGroup.push(property);
  67887. } else {
  67888. groups.push([property]);
  67889. }
  67890. return groups;
  67891. }, [[]]);
  67892. }
  67893. /**
  67894. * Verifies correct vertical alignment of a group of properties.
  67895. * @param {ASTNode[]} properties List of Property AST nodes.
  67896. * @returns {void}
  67897. */
  67898. function verifyGroupAlignment(properties) {
  67899. var length = properties.length,
  67900. widths = properties.map(getKeyWidth),
  67901. // Width of keys, including quotes
  67902. align = alignmentOptions.on; // "value" or "colon"
  67903. var targetWidth = Math.max.apply(Math, _toConsumableArray(widths)),
  67904. beforeColon = void 0,
  67905. afterColon = void 0,
  67906. mode = void 0;
  67907. if (alignmentOptions && length > 1) {
  67908. // When aligning values within a group, use the alignment configuration.
  67909. beforeColon = alignmentOptions.beforeColon;
  67910. afterColon = alignmentOptions.afterColon;
  67911. mode = alignmentOptions.mode;
  67912. } else {
  67913. beforeColon = multiLineOptions.beforeColon;
  67914. afterColon = multiLineOptions.afterColon;
  67915. mode = alignmentOptions.mode;
  67916. }
  67917. // Conditionally include one space before or after colon
  67918. targetWidth += align === "colon" ? beforeColon : afterColon;
  67919. for (var i = 0; i < length; i++) {
  67920. var property = properties[i];
  67921. var whitespace = getPropertyWhitespace(property);
  67922. if (whitespace) {
  67923. // Object literal getters/setters lack a colon
  67924. var width = widths[i];
  67925. if (align === "value") {
  67926. report(property, "key", whitespace.beforeColon, beforeColon, mode);
  67927. report(property, "value", whitespace.afterColon, targetWidth - width, mode);
  67928. } else {
  67929. // align = "colon"
  67930. report(property, "key", whitespace.beforeColon, targetWidth - width, mode);
  67931. report(property, "value", whitespace.afterColon, afterColon, mode);
  67932. }
  67933. }
  67934. }
  67935. }
  67936. /**
  67937. * Verifies vertical alignment, taking into account groups of properties.
  67938. * @param {ASTNode} node ObjectExpression node being evaluated.
  67939. * @returns {void}
  67940. */
  67941. function verifyAlignment(node) {
  67942. createGroups(node).forEach(function (group) {
  67943. verifyGroupAlignment(group.filter(isKeyValueProperty));
  67944. });
  67945. }
  67946. /**
  67947. * Verifies spacing of property conforms to specified options.
  67948. * @param {ASTNode} node Property node being evaluated.
  67949. * @param {Object} lineOptions Configured singleLine or multiLine options
  67950. * @returns {void}
  67951. */
  67952. function verifySpacing(node, lineOptions) {
  67953. var actual = getPropertyWhitespace(node);
  67954. if (actual) {
  67955. // Object literal getters/setters lack colons
  67956. report(node, "key", actual.beforeColon, lineOptions.beforeColon, lineOptions.mode);
  67957. report(node, "value", actual.afterColon, lineOptions.afterColon, lineOptions.mode);
  67958. }
  67959. }
  67960. /**
  67961. * Verifies spacing of each property in a list.
  67962. * @param {ASTNode[]} properties List of Property AST nodes.
  67963. * @returns {void}
  67964. */
  67965. function verifyListSpacing(properties) {
  67966. var length = properties.length;
  67967. for (var i = 0; i < length; i++) {
  67968. verifySpacing(properties[i], singleLineOptions);
  67969. }
  67970. }
  67971. //--------------------------------------------------------------------------
  67972. // Public API
  67973. //--------------------------------------------------------------------------
  67974. if (alignmentOptions) {
  67975. // Verify vertical alignment
  67976. return {
  67977. ObjectExpression: function ObjectExpression(node) {
  67978. if (isSingleLine(node)) {
  67979. verifyListSpacing(node.properties.filter(isKeyValueProperty));
  67980. } else {
  67981. verifyAlignment(node);
  67982. }
  67983. }
  67984. };
  67985. }
  67986. // Obey beforeColon and afterColon in each property as configured
  67987. return {
  67988. Property: function Property(node) {
  67989. verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
  67990. }
  67991. };
  67992. }
  67993. };
  67994. },{"../util/ast-utils":405}],174:[function(require,module,exports){
  67995. /**
  67996. * @fileoverview Rule to enforce spacing before and after keywords.
  67997. * @author Toru Nagashima
  67998. */
  67999. "use strict";
  68000. //------------------------------------------------------------------------------
  68001. // Requirements
  68002. //------------------------------------------------------------------------------
  68003. var astUtils = require("../util/ast-utils"),
  68004. keywords = require("../util/keywords");
  68005. //------------------------------------------------------------------------------
  68006. // Constants
  68007. //------------------------------------------------------------------------------
  68008. var PREV_TOKEN = /^[)\]}>]$/;
  68009. var NEXT_TOKEN = /^(?:[([{<~!]|\+\+?|--?)$/;
  68010. var PREV_TOKEN_M = /^[)\]}>*]$/;
  68011. var NEXT_TOKEN_M = /^[{*]$/;
  68012. var TEMPLATE_OPEN_PAREN = /\$\{$/;
  68013. var TEMPLATE_CLOSE_PAREN = /^\}/;
  68014. var CHECK_TYPE = /^(?:JSXElement|RegularExpression|String|Template)$/;
  68015. var KEYS = keywords.concat(["as", "async", "await", "from", "get", "let", "of", "set", "yield"]);
  68016. // check duplications.
  68017. (function () {
  68018. KEYS.sort();
  68019. for (var i = 1; i < KEYS.length; ++i) {
  68020. if (KEYS[i] === KEYS[i - 1]) {
  68021. throw new Error("Duplication was found in the keyword list: " + KEYS[i]);
  68022. }
  68023. }
  68024. })();
  68025. //------------------------------------------------------------------------------
  68026. // Helpers
  68027. //------------------------------------------------------------------------------
  68028. /**
  68029. * Checks whether or not a given token is a "Template" token ends with "${".
  68030. *
  68031. * @param {Token} token - A token to check.
  68032. * @returns {boolean} `true` if the token is a "Template" token ends with "${".
  68033. */
  68034. function isOpenParenOfTemplate(token) {
  68035. return token.type === "Template" && TEMPLATE_OPEN_PAREN.test(token.value);
  68036. }
  68037. /**
  68038. * Checks whether or not a given token is a "Template" token starts with "}".
  68039. *
  68040. * @param {Token} token - A token to check.
  68041. * @returns {boolean} `true` if the token is a "Template" token starts with "}".
  68042. */
  68043. function isCloseParenOfTemplate(token) {
  68044. return token.type === "Template" && TEMPLATE_CLOSE_PAREN.test(token.value);
  68045. }
  68046. //------------------------------------------------------------------------------
  68047. // Rule Definition
  68048. //------------------------------------------------------------------------------
  68049. module.exports = {
  68050. meta: {
  68051. type: "layout",
  68052. docs: {
  68053. description: "enforce consistent spacing before and after keywords",
  68054. category: "Stylistic Issues",
  68055. recommended: false,
  68056. url: "https://eslint.org/docs/rules/keyword-spacing"
  68057. },
  68058. fixable: "whitespace",
  68059. schema: [{
  68060. type: "object",
  68061. properties: {
  68062. before: { type: "boolean" },
  68063. after: { type: "boolean" },
  68064. overrides: {
  68065. type: "object",
  68066. properties: KEYS.reduce(function (retv, key) {
  68067. retv[key] = {
  68068. type: "object",
  68069. properties: {
  68070. before: { type: "boolean" },
  68071. after: { type: "boolean" }
  68072. },
  68073. additionalProperties: false
  68074. };
  68075. return retv;
  68076. }, {}),
  68077. additionalProperties: false
  68078. }
  68079. },
  68080. additionalProperties: false
  68081. }]
  68082. },
  68083. create: function create(context) {
  68084. var sourceCode = context.getSourceCode();
  68085. /**
  68086. * Reports a given token if there are not space(s) before the token.
  68087. *
  68088. * @param {Token} token - A token to report.
  68089. * @param {RegExp} pattern - A pattern of the previous token to check.
  68090. * @returns {void}
  68091. */
  68092. function expectSpaceBefore(token, pattern) {
  68093. var prevToken = sourceCode.getTokenBefore(token);
  68094. if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && astUtils.isTokenOnSameLine(prevToken, token) && !sourceCode.isSpaceBetweenTokens(prevToken, token)) {
  68095. context.report({
  68096. loc: token.loc.start,
  68097. message: "Expected space(s) before \"{{value}}\".",
  68098. data: token,
  68099. fix: function fix(fixer) {
  68100. return fixer.insertTextBefore(token, " ");
  68101. }
  68102. });
  68103. }
  68104. }
  68105. /**
  68106. * Reports a given token if there are space(s) before the token.
  68107. *
  68108. * @param {Token} token - A token to report.
  68109. * @param {RegExp} pattern - A pattern of the previous token to check.
  68110. * @returns {void}
  68111. */
  68112. function unexpectSpaceBefore(token, pattern) {
  68113. var prevToken = sourceCode.getTokenBefore(token);
  68114. if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && astUtils.isTokenOnSameLine(prevToken, token) && sourceCode.isSpaceBetweenTokens(prevToken, token)) {
  68115. context.report({
  68116. loc: token.loc.start,
  68117. message: "Unexpected space(s) before \"{{value}}\".",
  68118. data: token,
  68119. fix: function fix(fixer) {
  68120. return fixer.removeRange([prevToken.range[1], token.range[0]]);
  68121. }
  68122. });
  68123. }
  68124. }
  68125. /**
  68126. * Reports a given token if there are not space(s) after the token.
  68127. *
  68128. * @param {Token} token - A token to report.
  68129. * @param {RegExp} pattern - A pattern of the next token to check.
  68130. * @returns {void}
  68131. */
  68132. function expectSpaceAfter(token, pattern) {
  68133. var nextToken = sourceCode.getTokenAfter(token);
  68134. if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && astUtils.isTokenOnSameLine(token, nextToken) && !sourceCode.isSpaceBetweenTokens(token, nextToken)) {
  68135. context.report({
  68136. loc: token.loc.start,
  68137. message: "Expected space(s) after \"{{value}}\".",
  68138. data: token,
  68139. fix: function fix(fixer) {
  68140. return fixer.insertTextAfter(token, " ");
  68141. }
  68142. });
  68143. }
  68144. }
  68145. /**
  68146. * Reports a given token if there are space(s) after the token.
  68147. *
  68148. * @param {Token} token - A token to report.
  68149. * @param {RegExp} pattern - A pattern of the next token to check.
  68150. * @returns {void}
  68151. */
  68152. function unexpectSpaceAfter(token, pattern) {
  68153. var nextToken = sourceCode.getTokenAfter(token);
  68154. if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && astUtils.isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetweenTokens(token, nextToken)) {
  68155. context.report({
  68156. loc: token.loc.start,
  68157. message: "Unexpected space(s) after \"{{value}}\".",
  68158. data: token,
  68159. fix: function fix(fixer) {
  68160. return fixer.removeRange([token.range[1], nextToken.range[0]]);
  68161. }
  68162. });
  68163. }
  68164. }
  68165. /**
  68166. * Parses the option object and determines check methods for each keyword.
  68167. *
  68168. * @param {Object|undefined} options - The option object to parse.
  68169. * @returns {Object} - Normalized option object.
  68170. * Keys are keywords (there are for every keyword).
  68171. * Values are instances of `{"before": function, "after": function}`.
  68172. */
  68173. function parseOptions(options) {
  68174. var before = !options || options.before !== false;
  68175. var after = !options || options.after !== false;
  68176. var defaultValue = {
  68177. before: before ? expectSpaceBefore : unexpectSpaceBefore,
  68178. after: after ? expectSpaceAfter : unexpectSpaceAfter
  68179. };
  68180. var overrides = options && options.overrides || {};
  68181. var retv = Object.create(null);
  68182. for (var i = 0; i < KEYS.length; ++i) {
  68183. var key = KEYS[i];
  68184. var override = overrides[key];
  68185. if (override) {
  68186. var thisBefore = "before" in override ? override.before : before;
  68187. var thisAfter = "after" in override ? override.after : after;
  68188. retv[key] = {
  68189. before: thisBefore ? expectSpaceBefore : unexpectSpaceBefore,
  68190. after: thisAfter ? expectSpaceAfter : unexpectSpaceAfter
  68191. };
  68192. } else {
  68193. retv[key] = defaultValue;
  68194. }
  68195. }
  68196. return retv;
  68197. }
  68198. var checkMethodMap = parseOptions(context.options[0]);
  68199. /**
  68200. * Reports a given token if usage of spacing followed by the token is
  68201. * invalid.
  68202. *
  68203. * @param {Token} token - A token to report.
  68204. * @param {RegExp|undefined} pattern - Optional. A pattern of the previous
  68205. * token to check.
  68206. * @returns {void}
  68207. */
  68208. function checkSpacingBefore(token, pattern) {
  68209. checkMethodMap[token.value].before(token, pattern || PREV_TOKEN);
  68210. }
  68211. /**
  68212. * Reports a given token if usage of spacing preceded by the token is
  68213. * invalid.
  68214. *
  68215. * @param {Token} token - A token to report.
  68216. * @param {RegExp|undefined} pattern - Optional. A pattern of the next
  68217. * token to check.
  68218. * @returns {void}
  68219. */
  68220. function checkSpacingAfter(token, pattern) {
  68221. checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN);
  68222. }
  68223. /**
  68224. * Reports a given token if usage of spacing around the token is invalid.
  68225. *
  68226. * @param {Token} token - A token to report.
  68227. * @returns {void}
  68228. */
  68229. function checkSpacingAround(token) {
  68230. checkSpacingBefore(token);
  68231. checkSpacingAfter(token);
  68232. }
  68233. /**
  68234. * Reports the first token of a given node if the first token is a keyword
  68235. * and usage of spacing around the token is invalid.
  68236. *
  68237. * @param {ASTNode|null} node - A node to report.
  68238. * @returns {void}
  68239. */
  68240. function checkSpacingAroundFirstToken(node) {
  68241. var firstToken = node && sourceCode.getFirstToken(node);
  68242. if (firstToken && firstToken.type === "Keyword") {
  68243. checkSpacingAround(firstToken);
  68244. }
  68245. }
  68246. /**
  68247. * Reports the first token of a given node if the first token is a keyword
  68248. * and usage of spacing followed by the token is invalid.
  68249. *
  68250. * This is used for unary operators (e.g. `typeof`), `function`, and `super`.
  68251. * Other rules are handling usage of spacing preceded by those keywords.
  68252. *
  68253. * @param {ASTNode|null} node - A node to report.
  68254. * @returns {void}
  68255. */
  68256. function checkSpacingBeforeFirstToken(node) {
  68257. var firstToken = node && sourceCode.getFirstToken(node);
  68258. if (firstToken && firstToken.type === "Keyword") {
  68259. checkSpacingBefore(firstToken);
  68260. }
  68261. }
  68262. /**
  68263. * Reports the previous token of a given node if the token is a keyword and
  68264. * usage of spacing around the token is invalid.
  68265. *
  68266. * @param {ASTNode|null} node - A node to report.
  68267. * @returns {void}
  68268. */
  68269. function checkSpacingAroundTokenBefore(node) {
  68270. if (node) {
  68271. var token = sourceCode.getTokenBefore(node, astUtils.isKeywordToken);
  68272. checkSpacingAround(token);
  68273. }
  68274. }
  68275. /**
  68276. * Reports `async` or `function` keywords of a given node if usage of
  68277. * spacing around those keywords is invalid.
  68278. *
  68279. * @param {ASTNode} node - A node to report.
  68280. * @returns {void}
  68281. */
  68282. function checkSpacingForFunction(node) {
  68283. var firstToken = node && sourceCode.getFirstToken(node);
  68284. if (firstToken && (firstToken.type === "Keyword" && firstToken.value === "function" || firstToken.value === "async")) {
  68285. checkSpacingBefore(firstToken);
  68286. }
  68287. }
  68288. /**
  68289. * Reports `class` and `extends` keywords of a given node if usage of
  68290. * spacing around those keywords is invalid.
  68291. *
  68292. * @param {ASTNode} node - A node to report.
  68293. * @returns {void}
  68294. */
  68295. function checkSpacingForClass(node) {
  68296. checkSpacingAroundFirstToken(node);
  68297. checkSpacingAroundTokenBefore(node.superClass);
  68298. }
  68299. /**
  68300. * Reports `if` and `else` keywords of a given node if usage of spacing
  68301. * around those keywords is invalid.
  68302. *
  68303. * @param {ASTNode} node - A node to report.
  68304. * @returns {void}
  68305. */
  68306. function checkSpacingForIfStatement(node) {
  68307. checkSpacingAroundFirstToken(node);
  68308. checkSpacingAroundTokenBefore(node.alternate);
  68309. }
  68310. /**
  68311. * Reports `try`, `catch`, and `finally` keywords of a given node if usage
  68312. * of spacing around those keywords is invalid.
  68313. *
  68314. * @param {ASTNode} node - A node to report.
  68315. * @returns {void}
  68316. */
  68317. function checkSpacingForTryStatement(node) {
  68318. checkSpacingAroundFirstToken(node);
  68319. checkSpacingAroundFirstToken(node.handler);
  68320. checkSpacingAroundTokenBefore(node.finalizer);
  68321. }
  68322. /**
  68323. * Reports `do` and `while` keywords of a given node if usage of spacing
  68324. * around those keywords is invalid.
  68325. *
  68326. * @param {ASTNode} node - A node to report.
  68327. * @returns {void}
  68328. */
  68329. function checkSpacingForDoWhileStatement(node) {
  68330. checkSpacingAroundFirstToken(node);
  68331. checkSpacingAroundTokenBefore(node.test);
  68332. }
  68333. /**
  68334. * Reports `for` and `in` keywords of a given node if usage of spacing
  68335. * around those keywords is invalid.
  68336. *
  68337. * @param {ASTNode} node - A node to report.
  68338. * @returns {void}
  68339. */
  68340. function checkSpacingForForInStatement(node) {
  68341. checkSpacingAroundFirstToken(node);
  68342. checkSpacingAroundTokenBefore(node.right);
  68343. }
  68344. /**
  68345. * Reports `for` and `of` keywords of a given node if usage of spacing
  68346. * around those keywords is invalid.
  68347. *
  68348. * @param {ASTNode} node - A node to report.
  68349. * @returns {void}
  68350. */
  68351. function checkSpacingForForOfStatement(node) {
  68352. if (node.await) {
  68353. checkSpacingBefore(sourceCode.getFirstToken(node, 0));
  68354. checkSpacingAfter(sourceCode.getFirstToken(node, 1));
  68355. } else {
  68356. checkSpacingAroundFirstToken(node);
  68357. }
  68358. checkSpacingAround(sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken));
  68359. }
  68360. /**
  68361. * Reports `import`, `export`, `as`, and `from` keywords of a given node if
  68362. * usage of spacing around those keywords is invalid.
  68363. *
  68364. * This rule handles the `*` token in module declarations.
  68365. *
  68366. * import*as A from "./a"; /*error Expected space(s) after "import".
  68367. * error Expected space(s) before "as".
  68368. *
  68369. * @param {ASTNode} node - A node to report.
  68370. * @returns {void}
  68371. */
  68372. function checkSpacingForModuleDeclaration(node) {
  68373. var firstToken = sourceCode.getFirstToken(node);
  68374. checkSpacingBefore(firstToken, PREV_TOKEN_M);
  68375. checkSpacingAfter(firstToken, NEXT_TOKEN_M);
  68376. if (node.type === "ExportDefaultDeclaration") {
  68377. checkSpacingAround(sourceCode.getTokenAfter(firstToken));
  68378. }
  68379. if (node.source) {
  68380. var fromToken = sourceCode.getTokenBefore(node.source);
  68381. checkSpacingBefore(fromToken, PREV_TOKEN_M);
  68382. checkSpacingAfter(fromToken, NEXT_TOKEN_M);
  68383. }
  68384. }
  68385. /**
  68386. * Reports `as` keyword of a given node if usage of spacing around this
  68387. * keyword is invalid.
  68388. *
  68389. * @param {ASTNode} node - A node to report.
  68390. * @returns {void}
  68391. */
  68392. function checkSpacingForImportNamespaceSpecifier(node) {
  68393. var asToken = sourceCode.getFirstToken(node, 1);
  68394. checkSpacingBefore(asToken, PREV_TOKEN_M);
  68395. }
  68396. /**
  68397. * Reports `static`, `get`, and `set` keywords of a given node if usage of
  68398. * spacing around those keywords is invalid.
  68399. *
  68400. * @param {ASTNode} node - A node to report.
  68401. * @returns {void}
  68402. */
  68403. function checkSpacingForProperty(node) {
  68404. if (node.static) {
  68405. checkSpacingAroundFirstToken(node);
  68406. }
  68407. if (node.kind === "get" || node.kind === "set" || (node.method || node.type === "MethodDefinition") && node.value.async) {
  68408. var token = sourceCode.getTokenBefore(node.key, function (tok) {
  68409. switch (tok.value) {
  68410. case "get":
  68411. case "set":
  68412. case "async":
  68413. return true;
  68414. default:
  68415. return false;
  68416. }
  68417. });
  68418. if (!token) {
  68419. throw new Error("Failed to find token get, set, or async beside method name");
  68420. }
  68421. checkSpacingAround(token);
  68422. }
  68423. }
  68424. /**
  68425. * Reports `await` keyword of a given node if usage of spacing before
  68426. * this keyword is invalid.
  68427. *
  68428. * @param {ASTNode} node - A node to report.
  68429. * @returns {void}
  68430. */
  68431. function checkSpacingForAwaitExpression(node) {
  68432. checkSpacingBefore(sourceCode.getFirstToken(node));
  68433. }
  68434. return {
  68435. // Statements
  68436. DebuggerStatement: checkSpacingAroundFirstToken,
  68437. WithStatement: checkSpacingAroundFirstToken,
  68438. // Statements - Control flow
  68439. BreakStatement: checkSpacingAroundFirstToken,
  68440. ContinueStatement: checkSpacingAroundFirstToken,
  68441. ReturnStatement: checkSpacingAroundFirstToken,
  68442. ThrowStatement: checkSpacingAroundFirstToken,
  68443. TryStatement: checkSpacingForTryStatement,
  68444. // Statements - Choice
  68445. IfStatement: checkSpacingForIfStatement,
  68446. SwitchStatement: checkSpacingAroundFirstToken,
  68447. SwitchCase: checkSpacingAroundFirstToken,
  68448. // Statements - Loops
  68449. DoWhileStatement: checkSpacingForDoWhileStatement,
  68450. ForInStatement: checkSpacingForForInStatement,
  68451. ForOfStatement: checkSpacingForForOfStatement,
  68452. ForStatement: checkSpacingAroundFirstToken,
  68453. WhileStatement: checkSpacingAroundFirstToken,
  68454. // Statements - Declarations
  68455. ClassDeclaration: checkSpacingForClass,
  68456. ExportNamedDeclaration: checkSpacingForModuleDeclaration,
  68457. ExportDefaultDeclaration: checkSpacingForModuleDeclaration,
  68458. ExportAllDeclaration: checkSpacingForModuleDeclaration,
  68459. FunctionDeclaration: checkSpacingForFunction,
  68460. ImportDeclaration: checkSpacingForModuleDeclaration,
  68461. VariableDeclaration: checkSpacingAroundFirstToken,
  68462. // Expressions
  68463. ArrowFunctionExpression: checkSpacingForFunction,
  68464. AwaitExpression: checkSpacingForAwaitExpression,
  68465. ClassExpression: checkSpacingForClass,
  68466. FunctionExpression: checkSpacingForFunction,
  68467. NewExpression: checkSpacingBeforeFirstToken,
  68468. Super: checkSpacingBeforeFirstToken,
  68469. ThisExpression: checkSpacingBeforeFirstToken,
  68470. UnaryExpression: checkSpacingBeforeFirstToken,
  68471. YieldExpression: checkSpacingBeforeFirstToken,
  68472. // Others
  68473. ImportNamespaceSpecifier: checkSpacingForImportNamespaceSpecifier,
  68474. MethodDefinition: checkSpacingForProperty,
  68475. Property: checkSpacingForProperty
  68476. };
  68477. }
  68478. };
  68479. },{"../util/ast-utils":405,"../util/keywords":409}],175:[function(require,module,exports){
  68480. /**
  68481. * @fileoverview Rule to enforce the position of line comments
  68482. * @author Alberto Rodríguez
  68483. */
  68484. "use strict";
  68485. var astUtils = require("../util/ast-utils");
  68486. //------------------------------------------------------------------------------
  68487. // Rule Definition
  68488. //------------------------------------------------------------------------------
  68489. module.exports = {
  68490. meta: {
  68491. type: "layout",
  68492. docs: {
  68493. description: "enforce position of line comments",
  68494. category: "Stylistic Issues",
  68495. recommended: false,
  68496. url: "https://eslint.org/docs/rules/line-comment-position"
  68497. },
  68498. schema: [{
  68499. oneOf: [{
  68500. enum: ["above", "beside"]
  68501. }, {
  68502. type: "object",
  68503. properties: {
  68504. position: {
  68505. enum: ["above", "beside"]
  68506. },
  68507. ignorePattern: {
  68508. type: "string"
  68509. },
  68510. applyDefaultPatterns: {
  68511. type: "boolean"
  68512. },
  68513. applyDefaultIgnorePatterns: {
  68514. type: "boolean"
  68515. }
  68516. },
  68517. additionalProperties: false
  68518. }]
  68519. }]
  68520. },
  68521. create: function create(context) {
  68522. var options = context.options[0];
  68523. var above = void 0,
  68524. ignorePattern = void 0,
  68525. applyDefaultIgnorePatterns = true;
  68526. if (!options || typeof options === "string") {
  68527. above = !options || options === "above";
  68528. } else {
  68529. above = !options.position || options.position === "above";
  68530. ignorePattern = options.ignorePattern;
  68531. if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) {
  68532. applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
  68533. } else {
  68534. applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false;
  68535. }
  68536. }
  68537. var defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
  68538. var fallThroughRegExp = /^\s*falls?\s?through/;
  68539. var customIgnoreRegExp = new RegExp(ignorePattern);
  68540. var sourceCode = context.getSourceCode();
  68541. //--------------------------------------------------------------------------
  68542. // Public
  68543. //--------------------------------------------------------------------------
  68544. return {
  68545. Program: function Program() {
  68546. var comments = sourceCode.getAllComments();
  68547. comments.filter(function (token) {
  68548. return token.type === "Line";
  68549. }).forEach(function (node) {
  68550. if (applyDefaultIgnorePatterns && (defaultIgnoreRegExp.test(node.value) || fallThroughRegExp.test(node.value))) {
  68551. return;
  68552. }
  68553. if (ignorePattern && customIgnoreRegExp.test(node.value)) {
  68554. return;
  68555. }
  68556. var previous = sourceCode.getTokenBefore(node, { includeComments: true });
  68557. var isOnSameLine = previous && previous.loc.end.line === node.loc.start.line;
  68558. if (above) {
  68559. if (isOnSameLine) {
  68560. context.report({
  68561. node: node,
  68562. message: "Expected comment to be above code."
  68563. });
  68564. }
  68565. } else {
  68566. if (!isOnSameLine) {
  68567. context.report({
  68568. node: node,
  68569. message: "Expected comment to be beside code."
  68570. });
  68571. }
  68572. }
  68573. });
  68574. }
  68575. };
  68576. }
  68577. };
  68578. },{"../util/ast-utils":405}],176:[function(require,module,exports){
  68579. /**
  68580. * @fileoverview Rule to enforce a single linebreak style.
  68581. * @author Erik Mueller
  68582. */
  68583. "use strict";
  68584. //------------------------------------------------------------------------------
  68585. // Requirements
  68586. //------------------------------------------------------------------------------
  68587. var astUtils = require("../util/ast-utils");
  68588. //------------------------------------------------------------------------------
  68589. // Rule Definition
  68590. //------------------------------------------------------------------------------
  68591. module.exports = {
  68592. meta: {
  68593. type: "layout",
  68594. docs: {
  68595. description: "enforce consistent linebreak style",
  68596. category: "Stylistic Issues",
  68597. recommended: false,
  68598. url: "https://eslint.org/docs/rules/linebreak-style"
  68599. },
  68600. fixable: "whitespace",
  68601. schema: [{
  68602. enum: ["unix", "windows"]
  68603. }]
  68604. },
  68605. create: function create(context) {
  68606. var EXPECTED_LF_MSG = "Expected linebreaks to be 'LF' but found 'CRLF'.",
  68607. EXPECTED_CRLF_MSG = "Expected linebreaks to be 'CRLF' but found 'LF'.";
  68608. var sourceCode = context.getSourceCode();
  68609. //--------------------------------------------------------------------------
  68610. // Helpers
  68611. //--------------------------------------------------------------------------
  68612. /**
  68613. * Builds a fix function that replaces text at the specified range in the source text.
  68614. * @param {int[]} range The range to replace
  68615. * @param {string} text The text to insert.
  68616. * @returns {Function} Fixer function
  68617. * @private
  68618. */
  68619. function createFix(range, text) {
  68620. return function (fixer) {
  68621. return fixer.replaceTextRange(range, text);
  68622. };
  68623. }
  68624. //--------------------------------------------------------------------------
  68625. // Public
  68626. //--------------------------------------------------------------------------
  68627. return {
  68628. Program: function checkForlinebreakStyle(node) {
  68629. var linebreakStyle = context.options[0] || "unix",
  68630. expectedLF = linebreakStyle === "unix",
  68631. expectedLFChars = expectedLF ? "\n" : "\r\n",
  68632. source = sourceCode.getText(),
  68633. pattern = astUtils.createGlobalLinebreakMatcher();
  68634. var match = void 0;
  68635. var i = 0;
  68636. while ((match = pattern.exec(source)) !== null) {
  68637. i++;
  68638. if (match[0] === expectedLFChars) {
  68639. continue;
  68640. }
  68641. var index = match.index;
  68642. var range = [index, index + match[0].length];
  68643. context.report({
  68644. node: node,
  68645. loc: {
  68646. line: i,
  68647. column: sourceCode.lines[i - 1].length
  68648. },
  68649. message: expectedLF ? EXPECTED_LF_MSG : EXPECTED_CRLF_MSG,
  68650. fix: createFix(range, expectedLFChars)
  68651. });
  68652. }
  68653. }
  68654. };
  68655. }
  68656. };
  68657. },{"../util/ast-utils":405}],177:[function(require,module,exports){
  68658. /**
  68659. * @fileoverview Enforces empty lines around comments.
  68660. * @author Jamund Ferguson
  68661. */
  68662. "use strict";
  68663. //------------------------------------------------------------------------------
  68664. // Requirements
  68665. //------------------------------------------------------------------------------
  68666. var lodash = require("lodash"),
  68667. astUtils = require("../util/ast-utils");
  68668. //------------------------------------------------------------------------------
  68669. // Helpers
  68670. //------------------------------------------------------------------------------
  68671. /**
  68672. * Return an array with with any line numbers that are empty.
  68673. * @param {Array} lines An array of each line of the file.
  68674. * @returns {Array} An array of line numbers.
  68675. */
  68676. function getEmptyLineNums(lines) {
  68677. var emptyLines = lines.map(function (line, i) {
  68678. return {
  68679. code: line.trim(),
  68680. num: i + 1
  68681. };
  68682. }).filter(function (line) {
  68683. return !line.code;
  68684. }).map(function (line) {
  68685. return line.num;
  68686. });
  68687. return emptyLines;
  68688. }
  68689. /**
  68690. * Return an array with with any line numbers that contain comments.
  68691. * @param {Array} comments An array of comment tokens.
  68692. * @returns {Array} An array of line numbers.
  68693. */
  68694. function getCommentLineNums(comments) {
  68695. var lines = [];
  68696. comments.forEach(function (token) {
  68697. var start = token.loc.start.line;
  68698. var end = token.loc.end.line;
  68699. lines.push(start, end);
  68700. });
  68701. return lines;
  68702. }
  68703. //------------------------------------------------------------------------------
  68704. // Rule Definition
  68705. //------------------------------------------------------------------------------
  68706. module.exports = {
  68707. meta: {
  68708. type: "layout",
  68709. docs: {
  68710. description: "require empty lines around comments",
  68711. category: "Stylistic Issues",
  68712. recommended: false,
  68713. url: "https://eslint.org/docs/rules/lines-around-comment"
  68714. },
  68715. fixable: "whitespace",
  68716. schema: [{
  68717. type: "object",
  68718. properties: {
  68719. beforeBlockComment: {
  68720. type: "boolean"
  68721. },
  68722. afterBlockComment: {
  68723. type: "boolean"
  68724. },
  68725. beforeLineComment: {
  68726. type: "boolean"
  68727. },
  68728. afterLineComment: {
  68729. type: "boolean"
  68730. },
  68731. allowBlockStart: {
  68732. type: "boolean"
  68733. },
  68734. allowBlockEnd: {
  68735. type: "boolean"
  68736. },
  68737. allowClassStart: {
  68738. type: "boolean"
  68739. },
  68740. allowClassEnd: {
  68741. type: "boolean"
  68742. },
  68743. allowObjectStart: {
  68744. type: "boolean"
  68745. },
  68746. allowObjectEnd: {
  68747. type: "boolean"
  68748. },
  68749. allowArrayStart: {
  68750. type: "boolean"
  68751. },
  68752. allowArrayEnd: {
  68753. type: "boolean"
  68754. },
  68755. ignorePattern: {
  68756. type: "string"
  68757. },
  68758. applyDefaultIgnorePatterns: {
  68759. type: "boolean"
  68760. }
  68761. },
  68762. additionalProperties: false
  68763. }]
  68764. },
  68765. create: function create(context) {
  68766. var options = context.options[0] ? Object.assign({}, context.options[0]) : {};
  68767. var ignorePattern = options.ignorePattern;
  68768. var defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
  68769. var customIgnoreRegExp = new RegExp(ignorePattern);
  68770. var applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
  68771. options.beforeLineComment = options.beforeLineComment || false;
  68772. options.afterLineComment = options.afterLineComment || false;
  68773. options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true;
  68774. options.afterBlockComment = options.afterBlockComment || false;
  68775. options.allowBlockStart = options.allowBlockStart || false;
  68776. options.allowBlockEnd = options.allowBlockEnd || false;
  68777. var sourceCode = context.getSourceCode();
  68778. var lines = sourceCode.lines,
  68779. numLines = lines.length + 1,
  68780. comments = sourceCode.getAllComments(),
  68781. commentLines = getCommentLineNums(comments),
  68782. emptyLines = getEmptyLineNums(lines),
  68783. commentAndEmptyLines = commentLines.concat(emptyLines);
  68784. /**
  68785. * Returns whether or not comments are on lines starting with or ending with code
  68786. * @param {token} token The comment token to check.
  68787. * @returns {boolean} True if the comment is not alone.
  68788. */
  68789. function codeAroundComment(token) {
  68790. var currentToken = token;
  68791. do {
  68792. currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true });
  68793. } while (currentToken && astUtils.isCommentToken(currentToken));
  68794. if (currentToken && astUtils.isTokenOnSameLine(currentToken, token)) {
  68795. return true;
  68796. }
  68797. currentToken = token;
  68798. do {
  68799. currentToken = sourceCode.getTokenAfter(currentToken, { includeComments: true });
  68800. } while (currentToken && astUtils.isCommentToken(currentToken));
  68801. if (currentToken && astUtils.isTokenOnSameLine(token, currentToken)) {
  68802. return true;
  68803. }
  68804. return false;
  68805. }
  68806. /**
  68807. * Returns whether or not comments are inside a node type or not.
  68808. * @param {ASTNode} parent The Comment parent node.
  68809. * @param {string} nodeType The parent type to check against.
  68810. * @returns {boolean} True if the comment is inside nodeType.
  68811. */
  68812. function isParentNodeType(parent, nodeType) {
  68813. return parent.type === nodeType || parent.body && parent.body.type === nodeType || parent.consequent && parent.consequent.type === nodeType;
  68814. }
  68815. /**
  68816. * Returns the parent node that contains the given token.
  68817. * @param {token} token The token to check.
  68818. * @returns {ASTNode} The parent node that contains the given token.
  68819. */
  68820. function getParentNodeOfToken(token) {
  68821. return sourceCode.getNodeByRangeIndex(token.range[0]);
  68822. }
  68823. /**
  68824. * Returns whether or not comments are at the parent start or not.
  68825. * @param {token} token The Comment token.
  68826. * @param {string} nodeType The parent type to check against.
  68827. * @returns {boolean} True if the comment is at parent start.
  68828. */
  68829. function isCommentAtParentStart(token, nodeType) {
  68830. var parent = getParentNodeOfToken(token);
  68831. return parent && isParentNodeType(parent, nodeType) && token.loc.start.line - parent.loc.start.line === 1;
  68832. }
  68833. /**
  68834. * Returns whether or not comments are at the parent end or not.
  68835. * @param {token} token The Comment token.
  68836. * @param {string} nodeType The parent type to check against.
  68837. * @returns {boolean} True if the comment is at parent end.
  68838. */
  68839. function isCommentAtParentEnd(token, nodeType) {
  68840. var parent = getParentNodeOfToken(token);
  68841. return parent && isParentNodeType(parent, nodeType) && parent.loc.end.line - token.loc.end.line === 1;
  68842. }
  68843. /**
  68844. * Returns whether or not comments are at the block start or not.
  68845. * @param {token} token The Comment token.
  68846. * @returns {boolean} True if the comment is at block start.
  68847. */
  68848. function isCommentAtBlockStart(token) {
  68849. return isCommentAtParentStart(token, "ClassBody") || isCommentAtParentStart(token, "BlockStatement") || isCommentAtParentStart(token, "SwitchCase");
  68850. }
  68851. /**
  68852. * Returns whether or not comments are at the block end or not.
  68853. * @param {token} token The Comment token.
  68854. * @returns {boolean} True if the comment is at block end.
  68855. */
  68856. function isCommentAtBlockEnd(token) {
  68857. return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement");
  68858. }
  68859. /**
  68860. * Returns whether or not comments are at the class start or not.
  68861. * @param {token} token The Comment token.
  68862. * @returns {boolean} True if the comment is at class start.
  68863. */
  68864. function isCommentAtClassStart(token) {
  68865. return isCommentAtParentStart(token, "ClassBody");
  68866. }
  68867. /**
  68868. * Returns whether or not comments are at the class end or not.
  68869. * @param {token} token The Comment token.
  68870. * @returns {boolean} True if the comment is at class end.
  68871. */
  68872. function isCommentAtClassEnd(token) {
  68873. return isCommentAtParentEnd(token, "ClassBody");
  68874. }
  68875. /**
  68876. * Returns whether or not comments are at the object start or not.
  68877. * @param {token} token The Comment token.
  68878. * @returns {boolean} True if the comment is at object start.
  68879. */
  68880. function isCommentAtObjectStart(token) {
  68881. return isCommentAtParentStart(token, "ObjectExpression") || isCommentAtParentStart(token, "ObjectPattern");
  68882. }
  68883. /**
  68884. * Returns whether or not comments are at the object end or not.
  68885. * @param {token} token The Comment token.
  68886. * @returns {boolean} True if the comment is at object end.
  68887. */
  68888. function isCommentAtObjectEnd(token) {
  68889. return isCommentAtParentEnd(token, "ObjectExpression") || isCommentAtParentEnd(token, "ObjectPattern");
  68890. }
  68891. /**
  68892. * Returns whether or not comments are at the array start or not.
  68893. * @param {token} token The Comment token.
  68894. * @returns {boolean} True if the comment is at array start.
  68895. */
  68896. function isCommentAtArrayStart(token) {
  68897. return isCommentAtParentStart(token, "ArrayExpression") || isCommentAtParentStart(token, "ArrayPattern");
  68898. }
  68899. /**
  68900. * Returns whether or not comments are at the array end or not.
  68901. * @param {token} token The Comment token.
  68902. * @returns {boolean} True if the comment is at array end.
  68903. */
  68904. function isCommentAtArrayEnd(token) {
  68905. return isCommentAtParentEnd(token, "ArrayExpression") || isCommentAtParentEnd(token, "ArrayPattern");
  68906. }
  68907. /**
  68908. * Checks if a comment token has lines around it (ignores inline comments)
  68909. * @param {token} token The Comment token.
  68910. * @param {Object} opts Options to determine the newline.
  68911. * @param {boolean} opts.after Should have a newline after this line.
  68912. * @param {boolean} opts.before Should have a newline before this line.
  68913. * @returns {void}
  68914. */
  68915. function checkForEmptyLine(token, opts) {
  68916. if (applyDefaultIgnorePatterns && defaultIgnoreRegExp.test(token.value)) {
  68917. return;
  68918. }
  68919. if (ignorePattern && customIgnoreRegExp.test(token.value)) {
  68920. return;
  68921. }
  68922. var after = opts.after,
  68923. before = opts.before;
  68924. var prevLineNum = token.loc.start.line - 1,
  68925. nextLineNum = token.loc.end.line + 1,
  68926. commentIsNotAlone = codeAroundComment(token);
  68927. var blockStartAllowed = options.allowBlockStart && isCommentAtBlockStart(token) && !(options.allowClassStart === false && isCommentAtClassStart(token)),
  68928. blockEndAllowed = options.allowBlockEnd && isCommentAtBlockEnd(token) && !(options.allowClassEnd === false && isCommentAtClassEnd(token)),
  68929. classStartAllowed = options.allowClassStart && isCommentAtClassStart(token),
  68930. classEndAllowed = options.allowClassEnd && isCommentAtClassEnd(token),
  68931. objectStartAllowed = options.allowObjectStart && isCommentAtObjectStart(token),
  68932. objectEndAllowed = options.allowObjectEnd && isCommentAtObjectEnd(token),
  68933. arrayStartAllowed = options.allowArrayStart && isCommentAtArrayStart(token),
  68934. arrayEndAllowed = options.allowArrayEnd && isCommentAtArrayEnd(token);
  68935. var exceptionStartAllowed = blockStartAllowed || classStartAllowed || objectStartAllowed || arrayStartAllowed;
  68936. var exceptionEndAllowed = blockEndAllowed || classEndAllowed || objectEndAllowed || arrayEndAllowed;
  68937. // ignore top of the file and bottom of the file
  68938. if (prevLineNum < 1) {
  68939. before = false;
  68940. }
  68941. if (nextLineNum >= numLines) {
  68942. after = false;
  68943. }
  68944. // we ignore all inline comments
  68945. if (commentIsNotAlone) {
  68946. return;
  68947. }
  68948. var previousTokenOrComment = sourceCode.getTokenBefore(token, { includeComments: true });
  68949. var nextTokenOrComment = sourceCode.getTokenAfter(token, { includeComments: true });
  68950. // check for newline before
  68951. if (!exceptionStartAllowed && before && !lodash.includes(commentAndEmptyLines, prevLineNum) && !(astUtils.isCommentToken(previousTokenOrComment) && astUtils.isTokenOnSameLine(previousTokenOrComment, token))) {
  68952. var lineStart = token.range[0] - token.loc.start.column;
  68953. var range = [lineStart, lineStart];
  68954. context.report({
  68955. node: token,
  68956. message: "Expected line before comment.",
  68957. fix: function fix(fixer) {
  68958. return fixer.insertTextBeforeRange(range, "\n");
  68959. }
  68960. });
  68961. }
  68962. // check for newline after
  68963. if (!exceptionEndAllowed && after && !lodash.includes(commentAndEmptyLines, nextLineNum) && !(astUtils.isCommentToken(nextTokenOrComment) && astUtils.isTokenOnSameLine(token, nextTokenOrComment))) {
  68964. context.report({
  68965. node: token,
  68966. message: "Expected line after comment.",
  68967. fix: function fix(fixer) {
  68968. return fixer.insertTextAfter(token, "\n");
  68969. }
  68970. });
  68971. }
  68972. }
  68973. //--------------------------------------------------------------------------
  68974. // Public
  68975. //--------------------------------------------------------------------------
  68976. return {
  68977. Program: function Program() {
  68978. comments.forEach(function (token) {
  68979. if (token.type === "Line") {
  68980. if (options.beforeLineComment || options.afterLineComment) {
  68981. checkForEmptyLine(token, {
  68982. after: options.afterLineComment,
  68983. before: options.beforeLineComment
  68984. });
  68985. }
  68986. } else if (token.type === "Block") {
  68987. if (options.beforeBlockComment || options.afterBlockComment) {
  68988. checkForEmptyLine(token, {
  68989. after: options.afterBlockComment,
  68990. before: options.beforeBlockComment
  68991. });
  68992. }
  68993. }
  68994. });
  68995. }
  68996. };
  68997. }
  68998. };
  68999. },{"../util/ast-utils":405,"lodash":92}],178:[function(require,module,exports){
  69000. /**
  69001. * @fileoverview Require or disallow newlines around directives.
  69002. * @author Kai Cataldo
  69003. * @deprecated
  69004. */
  69005. "use strict";
  69006. var astUtils = require("../util/ast-utils");
  69007. //------------------------------------------------------------------------------
  69008. // Rule Definition
  69009. //------------------------------------------------------------------------------
  69010. module.exports = {
  69011. meta: {
  69012. type: "layout",
  69013. docs: {
  69014. description: "require or disallow newlines around directives",
  69015. category: "Stylistic Issues",
  69016. recommended: false,
  69017. url: "https://eslint.org/docs/rules/lines-around-directive"
  69018. },
  69019. schema: [{
  69020. oneOf: [{
  69021. enum: ["always", "never"]
  69022. }, {
  69023. type: "object",
  69024. properties: {
  69025. before: {
  69026. enum: ["always", "never"]
  69027. },
  69028. after: {
  69029. enum: ["always", "never"]
  69030. }
  69031. },
  69032. additionalProperties: false,
  69033. minProperties: 2
  69034. }]
  69035. }],
  69036. fixable: "whitespace",
  69037. deprecated: true,
  69038. replacedBy: ["padding-line-between-statements"]
  69039. },
  69040. create: function create(context) {
  69041. var sourceCode = context.getSourceCode();
  69042. var config = context.options[0] || "always";
  69043. var expectLineBefore = typeof config === "string" ? config : config.before;
  69044. var expectLineAfter = typeof config === "string" ? config : config.after;
  69045. //--------------------------------------------------------------------------
  69046. // Helpers
  69047. //--------------------------------------------------------------------------
  69048. /**
  69049. * Check if node is preceded by a blank newline.
  69050. * @param {ASTNode} node Node to check.
  69051. * @returns {boolean} Whether or not the passed in node is preceded by a blank newline.
  69052. */
  69053. function hasNewlineBefore(node) {
  69054. var tokenBefore = sourceCode.getTokenBefore(node, { includeComments: true });
  69055. var tokenLineBefore = tokenBefore ? tokenBefore.loc.end.line : 0;
  69056. return node.loc.start.line - tokenLineBefore >= 2;
  69057. }
  69058. /**
  69059. * Gets the last token of a node that is on the same line as the rest of the node.
  69060. * This will usually be the last token of the node, but it will be the second-to-last token if the node has a trailing
  69061. * semicolon on a different line.
  69062. * @param {ASTNode} node A directive node
  69063. * @returns {Token} The last token of the node on the line
  69064. */
  69065. function getLastTokenOnLine(node) {
  69066. var lastToken = sourceCode.getLastToken(node);
  69067. var secondToLastToken = sourceCode.getTokenBefore(lastToken);
  69068. return astUtils.isSemicolonToken(lastToken) && lastToken.loc.start.line > secondToLastToken.loc.end.line ? secondToLastToken : lastToken;
  69069. }
  69070. /**
  69071. * Check if node is followed by a blank newline.
  69072. * @param {ASTNode} node Node to check.
  69073. * @returns {boolean} Whether or not the passed in node is followed by a blank newline.
  69074. */
  69075. function hasNewlineAfter(node) {
  69076. var lastToken = getLastTokenOnLine(node);
  69077. var tokenAfter = sourceCode.getTokenAfter(lastToken, { includeComments: true });
  69078. return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2;
  69079. }
  69080. /**
  69081. * Report errors for newlines around directives.
  69082. * @param {ASTNode} node Node to check.
  69083. * @param {string} location Whether the error was found before or after the directive.
  69084. * @param {boolean} expected Whether or not a newline was expected or unexpected.
  69085. * @returns {void}
  69086. */
  69087. function reportError(node, location, expected) {
  69088. context.report({
  69089. node: node,
  69090. message: "{{expected}} newline {{location}} \"{{value}}\" directive.",
  69091. data: {
  69092. expected: expected ? "Expected" : "Unexpected",
  69093. value: node.expression.value,
  69094. location: location
  69095. },
  69096. fix: function fix(fixer) {
  69097. var lastToken = getLastTokenOnLine(node);
  69098. if (expected) {
  69099. return location === "before" ? fixer.insertTextBefore(node, "\n") : fixer.insertTextAfter(lastToken, "\n");
  69100. }
  69101. return fixer.removeRange(location === "before" ? [node.range[0] - 1, node.range[0]] : [lastToken.range[1], lastToken.range[1] + 1]);
  69102. }
  69103. });
  69104. }
  69105. /**
  69106. * Check lines around directives in node
  69107. * @param {ASTNode} node - node to check
  69108. * @returns {void}
  69109. */
  69110. function checkDirectives(node) {
  69111. var directives = astUtils.getDirectivePrologue(node);
  69112. if (!directives.length) {
  69113. return;
  69114. }
  69115. var firstDirective = directives[0];
  69116. var leadingComments = sourceCode.getCommentsBefore(firstDirective);
  69117. /*
  69118. * Only check before the first directive if it is preceded by a comment or if it is at the top of
  69119. * the file and expectLineBefore is set to "never". This is to not force a newline at the top of
  69120. * the file if there are no comments as well as for compatibility with padded-blocks.
  69121. */
  69122. if (leadingComments.length) {
  69123. if (expectLineBefore === "always" && !hasNewlineBefore(firstDirective)) {
  69124. reportError(firstDirective, "before", true);
  69125. }
  69126. if (expectLineBefore === "never" && hasNewlineBefore(firstDirective)) {
  69127. reportError(firstDirective, "before", false);
  69128. }
  69129. } else if (node.type === "Program" && expectLineBefore === "never" && !leadingComments.length && hasNewlineBefore(firstDirective)) {
  69130. reportError(firstDirective, "before", false);
  69131. }
  69132. var lastDirective = directives[directives.length - 1];
  69133. var statements = node.type === "Program" ? node.body : node.body.body;
  69134. /*
  69135. * Do not check after the last directive if the body only
  69136. * contains a directive prologue and isn't followed by a comment to ensure
  69137. * this rule behaves well with padded-blocks.
  69138. */
  69139. if (lastDirective === statements[statements.length - 1] && !lastDirective.trailingComments) {
  69140. return;
  69141. }
  69142. if (expectLineAfter === "always" && !hasNewlineAfter(lastDirective)) {
  69143. reportError(lastDirective, "after", true);
  69144. }
  69145. if (expectLineAfter === "never" && hasNewlineAfter(lastDirective)) {
  69146. reportError(lastDirective, "after", false);
  69147. }
  69148. }
  69149. //--------------------------------------------------------------------------
  69150. // Public
  69151. //--------------------------------------------------------------------------
  69152. return {
  69153. Program: checkDirectives,
  69154. FunctionDeclaration: checkDirectives,
  69155. FunctionExpression: checkDirectives,
  69156. ArrowFunctionExpression: checkDirectives
  69157. };
  69158. }
  69159. };
  69160. },{"../util/ast-utils":405}],179:[function(require,module,exports){
  69161. /**
  69162. * @fileoverview Rule to check empty newline between class members
  69163. * @author 薛定谔的猫<hh_2013@foxmail.com>
  69164. */
  69165. "use strict";
  69166. var astUtils = require("../util/ast-utils");
  69167. //------------------------------------------------------------------------------
  69168. // Rule Definition
  69169. //------------------------------------------------------------------------------
  69170. module.exports = {
  69171. meta: {
  69172. type: "layout",
  69173. docs: {
  69174. description: "require or disallow an empty line between class members",
  69175. category: "Stylistic Issues",
  69176. recommended: false,
  69177. url: "https://eslint.org/docs/rules/lines-between-class-members"
  69178. },
  69179. fixable: "whitespace",
  69180. schema: [{
  69181. enum: ["always", "never"]
  69182. }, {
  69183. type: "object",
  69184. properties: {
  69185. exceptAfterSingleLine: {
  69186. type: "boolean"
  69187. }
  69188. },
  69189. additionalProperties: false
  69190. }]
  69191. },
  69192. create: function create(context) {
  69193. var options = [];
  69194. options[0] = context.options[0] || "always";
  69195. options[1] = context.options[1] || { exceptAfterSingleLine: false };
  69196. var ALWAYS_MESSAGE = "Expected blank line between class members.";
  69197. var NEVER_MESSAGE = "Unexpected blank line between class members.";
  69198. var sourceCode = context.getSourceCode();
  69199. /**
  69200. * Checks if there is padding between two tokens
  69201. * @param {Token} first The first token
  69202. * @param {Token} second The second token
  69203. * @returns {boolean} True if there is at least a line between the tokens
  69204. */
  69205. function isPaddingBetweenTokens(first, second) {
  69206. var comments = sourceCode.getCommentsBefore(second);
  69207. var len = comments.length;
  69208. // If there is no comments
  69209. if (len === 0) {
  69210. var _linesBetweenFstAndSnd = second.loc.start.line - first.loc.end.line - 1;
  69211. return _linesBetweenFstAndSnd >= 1;
  69212. }
  69213. // If there are comments
  69214. var sumOfCommentLines = 0; // the numbers of lines of comments
  69215. var prevCommentLineNum = -1; // line number of the end of the previous comment
  69216. for (var i = 0; i < len; i++) {
  69217. var commentLinesOfThisComment = comments[i].loc.end.line - comments[i].loc.start.line + 1;
  69218. sumOfCommentLines += commentLinesOfThisComment;
  69219. /*
  69220. * If this comment and the previous comment are in the same line,
  69221. * the count of comment lines is duplicated. So decrement sumOfCommentLines.
  69222. */
  69223. if (prevCommentLineNum === comments[i].loc.start.line) {
  69224. sumOfCommentLines -= 1;
  69225. }
  69226. prevCommentLineNum = comments[i].loc.end.line;
  69227. }
  69228. /*
  69229. * If the first block and the first comment are in the same line,
  69230. * the count of comment lines is duplicated. So decrement sumOfCommentLines.
  69231. */
  69232. if (first.loc.end.line === comments[0].loc.start.line) {
  69233. sumOfCommentLines -= 1;
  69234. }
  69235. /*
  69236. * If the last comment and the second block are in the same line,
  69237. * the count of comment lines is duplicated. So decrement sumOfCommentLines.
  69238. */
  69239. if (comments[len - 1].loc.end.line === second.loc.start.line) {
  69240. sumOfCommentLines -= 1;
  69241. }
  69242. var linesBetweenFstAndSnd = second.loc.start.line - first.loc.end.line - 1;
  69243. return linesBetweenFstAndSnd - sumOfCommentLines >= 1;
  69244. }
  69245. return {
  69246. ClassBody: function ClassBody(node) {
  69247. var body = node.body;
  69248. var _loop = function _loop(i) {
  69249. var curFirst = sourceCode.getFirstToken(body[i]);
  69250. var curLast = sourceCode.getLastToken(body[i]);
  69251. var nextFirst = sourceCode.getFirstToken(body[i + 1]);
  69252. var isPadded = isPaddingBetweenTokens(curLast, nextFirst);
  69253. var isMulti = !astUtils.isTokenOnSameLine(curFirst, curLast);
  69254. var skip = !isMulti && options[1].exceptAfterSingleLine;
  69255. if (options[0] === "always" && !skip && !isPadded || options[0] === "never" && isPadded) {
  69256. context.report({
  69257. node: body[i + 1],
  69258. message: isPadded ? NEVER_MESSAGE : ALWAYS_MESSAGE,
  69259. fix: function fix(fixer) {
  69260. return isPadded ? fixer.replaceTextRange([curLast.range[1], nextFirst.range[0]], "\n") : fixer.insertTextAfter(curLast, "\n");
  69261. }
  69262. });
  69263. }
  69264. };
  69265. for (var i = 0; i < body.length - 1; i++) {
  69266. _loop(i);
  69267. }
  69268. }
  69269. };
  69270. }
  69271. };
  69272. },{"../util/ast-utils":405}],180:[function(require,module,exports){
  69273. /**
  69274. * @fileoverview Enforce a maximum number of classes per file
  69275. * @author James Garbutt <https://github.com/43081j>
  69276. */
  69277. "use strict";
  69278. //------------------------------------------------------------------------------
  69279. // Requirements
  69280. //------------------------------------------------------------------------------
  69281. //------------------------------------------------------------------------------
  69282. // Rule Definition
  69283. //------------------------------------------------------------------------------
  69284. module.exports = {
  69285. meta: {
  69286. type: "suggestion",
  69287. docs: {
  69288. description: "enforce a maximum number of classes per file",
  69289. category: "Best Practices",
  69290. recommended: false,
  69291. url: "https://eslint.org/docs/rules/max-classes-per-file"
  69292. },
  69293. schema: [{
  69294. type: "integer",
  69295. minimum: 1
  69296. }],
  69297. messages: {
  69298. maximumExceeded: "Number of classes per file must not exceed {{ max }}"
  69299. }
  69300. },
  69301. create: function create(context) {
  69302. var maxClasses = context.options[0] || 1;
  69303. var classCount = 0;
  69304. return {
  69305. Program: function Program() {
  69306. classCount = 0;
  69307. },
  69308. "Program:exit": function ProgramExit(node) {
  69309. if (classCount > maxClasses) {
  69310. context.report({
  69311. node: node,
  69312. messageId: "maximumExceeded",
  69313. data: {
  69314. max: maxClasses
  69315. }
  69316. });
  69317. }
  69318. },
  69319. "ClassDeclaration, ClassExpression": function ClassDeclarationClassExpression() {
  69320. classCount++;
  69321. }
  69322. };
  69323. }
  69324. };
  69325. },{}],181:[function(require,module,exports){
  69326. /**
  69327. * @fileoverview A rule to set the maximum depth block can be nested in a function.
  69328. * @author Ian Christian Myers
  69329. */
  69330. "use strict";
  69331. //------------------------------------------------------------------------------
  69332. // Rule Definition
  69333. //------------------------------------------------------------------------------
  69334. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  69335. module.exports = {
  69336. meta: {
  69337. type: "suggestion",
  69338. docs: {
  69339. description: "enforce a maximum depth that blocks can be nested",
  69340. category: "Stylistic Issues",
  69341. recommended: false,
  69342. url: "https://eslint.org/docs/rules/max-depth"
  69343. },
  69344. schema: [{
  69345. oneOf: [{
  69346. type: "integer",
  69347. minimum: 0
  69348. }, {
  69349. type: "object",
  69350. properties: {
  69351. maximum: {
  69352. type: "integer",
  69353. minimum: 0
  69354. },
  69355. max: {
  69356. type: "integer",
  69357. minimum: 0
  69358. }
  69359. },
  69360. additionalProperties: false
  69361. }]
  69362. }]
  69363. },
  69364. create: function create(context) {
  69365. //--------------------------------------------------------------------------
  69366. // Helpers
  69367. //--------------------------------------------------------------------------
  69368. var functionStack = [],
  69369. option = context.options[0];
  69370. var maxDepth = 4;
  69371. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
  69372. maxDepth = option.maximum;
  69373. }
  69374. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
  69375. maxDepth = option.max;
  69376. }
  69377. if (typeof option === "number") {
  69378. maxDepth = option;
  69379. }
  69380. /**
  69381. * When parsing a new function, store it in our function stack
  69382. * @returns {void}
  69383. * @private
  69384. */
  69385. function startFunction() {
  69386. functionStack.push(0);
  69387. }
  69388. /**
  69389. * When parsing is done then pop out the reference
  69390. * @returns {void}
  69391. * @private
  69392. */
  69393. function endFunction() {
  69394. functionStack.pop();
  69395. }
  69396. /**
  69397. * Save the block and Evaluate the node
  69398. * @param {ASTNode} node node to evaluate
  69399. * @returns {void}
  69400. * @private
  69401. */
  69402. function pushBlock(node) {
  69403. var len = ++functionStack[functionStack.length - 1];
  69404. if (len > maxDepth) {
  69405. context.report({ node: node, message: "Blocks are nested too deeply ({{depth}}).", data: { depth: len } });
  69406. }
  69407. }
  69408. /**
  69409. * Pop the saved block
  69410. * @returns {void}
  69411. * @private
  69412. */
  69413. function popBlock() {
  69414. functionStack[functionStack.length - 1]--;
  69415. }
  69416. //--------------------------------------------------------------------------
  69417. // Public API
  69418. //--------------------------------------------------------------------------
  69419. return {
  69420. Program: startFunction,
  69421. FunctionDeclaration: startFunction,
  69422. FunctionExpression: startFunction,
  69423. ArrowFunctionExpression: startFunction,
  69424. IfStatement: function IfStatement(node) {
  69425. if (node.parent.type !== "IfStatement") {
  69426. pushBlock(node);
  69427. }
  69428. },
  69429. SwitchStatement: pushBlock,
  69430. TryStatement: pushBlock,
  69431. DoWhileStatement: pushBlock,
  69432. WhileStatement: pushBlock,
  69433. WithStatement: pushBlock,
  69434. ForStatement: pushBlock,
  69435. ForInStatement: pushBlock,
  69436. ForOfStatement: pushBlock,
  69437. "IfStatement:exit": popBlock,
  69438. "SwitchStatement:exit": popBlock,
  69439. "TryStatement:exit": popBlock,
  69440. "DoWhileStatement:exit": popBlock,
  69441. "WhileStatement:exit": popBlock,
  69442. "WithStatement:exit": popBlock,
  69443. "ForStatement:exit": popBlock,
  69444. "ForInStatement:exit": popBlock,
  69445. "ForOfStatement:exit": popBlock,
  69446. "FunctionDeclaration:exit": endFunction,
  69447. "FunctionExpression:exit": endFunction,
  69448. "ArrowFunctionExpression:exit": endFunction,
  69449. "Program:exit": endFunction
  69450. };
  69451. }
  69452. };
  69453. },{}],182:[function(require,module,exports){
  69454. /**
  69455. * @fileoverview Rule to check for max length on a line.
  69456. * @author Matt DuVall <http://www.mattduvall.com>
  69457. */
  69458. "use strict";
  69459. //------------------------------------------------------------------------------
  69460. // Constants
  69461. //------------------------------------------------------------------------------
  69462. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  69463. var OPTIONS_SCHEMA = {
  69464. type: "object",
  69465. properties: {
  69466. code: {
  69467. type: "integer",
  69468. minimum: 0
  69469. },
  69470. comments: {
  69471. type: "integer",
  69472. minimum: 0
  69473. },
  69474. tabWidth: {
  69475. type: "integer",
  69476. minimum: 0
  69477. },
  69478. ignorePattern: {
  69479. type: "string"
  69480. },
  69481. ignoreComments: {
  69482. type: "boolean"
  69483. },
  69484. ignoreStrings: {
  69485. type: "boolean"
  69486. },
  69487. ignoreUrls: {
  69488. type: "boolean"
  69489. },
  69490. ignoreTemplateLiterals: {
  69491. type: "boolean"
  69492. },
  69493. ignoreRegExpLiterals: {
  69494. type: "boolean"
  69495. },
  69496. ignoreTrailingComments: {
  69497. type: "boolean"
  69498. }
  69499. },
  69500. additionalProperties: false
  69501. };
  69502. var OPTIONS_OR_INTEGER_SCHEMA = {
  69503. anyOf: [OPTIONS_SCHEMA, {
  69504. type: "integer",
  69505. minimum: 0
  69506. }]
  69507. };
  69508. //------------------------------------------------------------------------------
  69509. // Rule Definition
  69510. //------------------------------------------------------------------------------
  69511. module.exports = {
  69512. meta: {
  69513. type: "layout",
  69514. docs: {
  69515. description: "enforce a maximum line length",
  69516. category: "Stylistic Issues",
  69517. recommended: false,
  69518. url: "https://eslint.org/docs/rules/max-len"
  69519. },
  69520. schema: [OPTIONS_OR_INTEGER_SCHEMA, OPTIONS_OR_INTEGER_SCHEMA, OPTIONS_SCHEMA]
  69521. },
  69522. create: function create(context) {
  69523. /*
  69524. * Inspired by http://tools.ietf.org/html/rfc3986#appendix-B, however:
  69525. * - They're matching an entire string that we know is a URI
  69526. * - We're matching part of a string where we think there *might* be a URL
  69527. * - We're only concerned about URLs, as picking out any URI would cause
  69528. * too many false positives
  69529. * - We don't care about matching the entire URL, any small segment is fine
  69530. */
  69531. var URL_REGEXP = /[^:/?#]:\/\/[^?#]/;
  69532. var sourceCode = context.getSourceCode();
  69533. /**
  69534. * Computes the length of a line that may contain tabs. The width of each
  69535. * tab will be the number of spaces to the next tab stop.
  69536. * @param {string} line The line.
  69537. * @param {int} tabWidth The width of each tab stop in spaces.
  69538. * @returns {int} The computed line length.
  69539. * @private
  69540. */
  69541. function computeLineLength(line, tabWidth) {
  69542. var extraCharacterCount = 0;
  69543. line.replace(/\t/g, function (match, offset) {
  69544. var totalOffset = offset + extraCharacterCount,
  69545. previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0,
  69546. spaceCount = tabWidth - previousTabStopOffset;
  69547. extraCharacterCount += spaceCount - 1; // -1 for the replaced tab
  69548. });
  69549. return Array.from(line).length + extraCharacterCount;
  69550. }
  69551. // The options object must be the last option specified…
  69552. var lastOption = context.options[context.options.length - 1];
  69553. var options = (typeof lastOption === "undefined" ? "undefined" : _typeof(lastOption)) === "object" ? Object.create(lastOption) : {};
  69554. // …but max code length…
  69555. if (typeof context.options[0] === "number") {
  69556. options.code = context.options[0];
  69557. }
  69558. // …and tabWidth can be optionally specified directly as integers.
  69559. if (typeof context.options[1] === "number") {
  69560. options.tabWidth = context.options[1];
  69561. }
  69562. var maxLength = options.code || 80,
  69563. tabWidth = options.tabWidth || 4,
  69564. ignoreComments = options.ignoreComments || false,
  69565. ignoreStrings = options.ignoreStrings || false,
  69566. ignoreTemplateLiterals = options.ignoreTemplateLiterals || false,
  69567. ignoreRegExpLiterals = options.ignoreRegExpLiterals || false,
  69568. ignoreTrailingComments = options.ignoreTrailingComments || options.ignoreComments || false,
  69569. ignoreUrls = options.ignoreUrls || false,
  69570. maxCommentLength = options.comments;
  69571. var ignorePattern = options.ignorePattern || null;
  69572. if (ignorePattern) {
  69573. ignorePattern = new RegExp(ignorePattern);
  69574. }
  69575. //--------------------------------------------------------------------------
  69576. // Helpers
  69577. //--------------------------------------------------------------------------
  69578. /**
  69579. * Tells if a given comment is trailing: it starts on the current line and
  69580. * extends to or past the end of the current line.
  69581. * @param {string} line The source line we want to check for a trailing comment on
  69582. * @param {number} lineNumber The one-indexed line number for line
  69583. * @param {ASTNode} comment The comment to inspect
  69584. * @returns {boolean} If the comment is trailing on the given line
  69585. */
  69586. function isTrailingComment(line, lineNumber, comment) {
  69587. return comment && comment.loc.start.line === lineNumber && lineNumber <= comment.loc.end.line && (comment.loc.end.line > lineNumber || comment.loc.end.column === line.length);
  69588. }
  69589. /**
  69590. * Tells if a comment encompasses the entire line.
  69591. * @param {string} line The source line with a trailing comment
  69592. * @param {number} lineNumber The one-indexed line number this is on
  69593. * @param {ASTNode} comment The comment to remove
  69594. * @returns {boolean} If the comment covers the entire line
  69595. */
  69596. function isFullLineComment(line, lineNumber, comment) {
  69597. var start = comment.loc.start,
  69598. end = comment.loc.end,
  69599. isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim();
  69600. return comment && (start.line < lineNumber || start.line === lineNumber && isFirstTokenOnLine) && (end.line > lineNumber || end.line === lineNumber && end.column === line.length);
  69601. }
  69602. /**
  69603. * Gets the line after the comment and any remaining trailing whitespace is
  69604. * stripped.
  69605. * @param {string} line The source line with a trailing comment
  69606. * @param {ASTNode} comment The comment to remove
  69607. * @returns {string} Line without comment and trailing whitepace
  69608. */
  69609. function stripTrailingComment(line, comment) {
  69610. // loc.column is zero-indexed
  69611. return line.slice(0, comment.loc.start.column).replace(/\s+$/, "");
  69612. }
  69613. /**
  69614. * Ensure that an array exists at [key] on `object`, and add `value` to it.
  69615. *
  69616. * @param {Object} object the object to mutate
  69617. * @param {string} key the object's key
  69618. * @param {*} value the value to add
  69619. * @returns {void}
  69620. * @private
  69621. */
  69622. function ensureArrayAndPush(object, key, value) {
  69623. if (!Array.isArray(object[key])) {
  69624. object[key] = [];
  69625. }
  69626. object[key].push(value);
  69627. }
  69628. /**
  69629. * Retrieves an array containing all strings (" or ') in the source code.
  69630. *
  69631. * @returns {ASTNode[]} An array of string nodes.
  69632. */
  69633. function getAllStrings() {
  69634. return sourceCode.ast.tokens.filter(function (token) {
  69635. return token.type === "String" || token.type === "JSXText" && sourceCode.getNodeByRangeIndex(token.range[0] - 1).type === "JSXAttribute";
  69636. });
  69637. }
  69638. /**
  69639. * Retrieves an array containing all template literals in the source code.
  69640. *
  69641. * @returns {ASTNode[]} An array of template literal nodes.
  69642. */
  69643. function getAllTemplateLiterals() {
  69644. return sourceCode.ast.tokens.filter(function (token) {
  69645. return token.type === "Template";
  69646. });
  69647. }
  69648. /**
  69649. * Retrieves an array containing all RegExp literals in the source code.
  69650. *
  69651. * @returns {ASTNode[]} An array of RegExp literal nodes.
  69652. */
  69653. function getAllRegExpLiterals() {
  69654. return sourceCode.ast.tokens.filter(function (token) {
  69655. return token.type === "RegularExpression";
  69656. });
  69657. }
  69658. /**
  69659. * A reducer to group an AST node by line number, both start and end.
  69660. *
  69661. * @param {Object} acc the accumulator
  69662. * @param {ASTNode} node the AST node in question
  69663. * @returns {Object} the modified accumulator
  69664. * @private
  69665. */
  69666. function groupByLineNumber(acc, node) {
  69667. for (var i = node.loc.start.line; i <= node.loc.end.line; ++i) {
  69668. ensureArrayAndPush(acc, i, node);
  69669. }
  69670. return acc;
  69671. }
  69672. /**
  69673. * Check the program for max length
  69674. * @param {ASTNode} node Node to examine
  69675. * @returns {void}
  69676. * @private
  69677. */
  69678. function checkProgramForMaxLength(node) {
  69679. // split (honors line-ending)
  69680. var lines = sourceCode.lines,
  69681. // list of comments to ignore
  69682. comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? sourceCode.getAllComments() : [];
  69683. // we iterate over comments in parallel with the lines
  69684. var commentsIndex = 0;
  69685. var strings = getAllStrings();
  69686. var stringsByLine = strings.reduce(groupByLineNumber, {});
  69687. var templateLiterals = getAllTemplateLiterals();
  69688. var templateLiteralsByLine = templateLiterals.reduce(groupByLineNumber, {});
  69689. var regExpLiterals = getAllRegExpLiterals();
  69690. var regExpLiteralsByLine = regExpLiterals.reduce(groupByLineNumber, {});
  69691. lines.forEach(function (line, i) {
  69692. // i is zero-indexed, line numbers are one-indexed
  69693. var lineNumber = i + 1;
  69694. /*
  69695. * if we're checking comment length; we need to know whether this
  69696. * line is a comment
  69697. */
  69698. var lineIsComment = false;
  69699. var textToMeasure = void 0;
  69700. /*
  69701. * We can short-circuit the comment checks if we're already out of
  69702. * comments to check.
  69703. */
  69704. if (commentsIndex < comments.length) {
  69705. var comment = null;
  69706. // iterate over comments until we find one past the current line
  69707. do {
  69708. comment = comments[++commentsIndex];
  69709. } while (comment && comment.loc.start.line <= lineNumber);
  69710. // and step back by one
  69711. comment = comments[--commentsIndex];
  69712. if (isFullLineComment(line, lineNumber, comment)) {
  69713. lineIsComment = true;
  69714. textToMeasure = line;
  69715. } else if (ignoreTrailingComments && isTrailingComment(line, lineNumber, comment)) {
  69716. textToMeasure = stripTrailingComment(line, comment);
  69717. } else {
  69718. textToMeasure = line;
  69719. }
  69720. } else {
  69721. textToMeasure = line;
  69722. }
  69723. if (ignorePattern && ignorePattern.test(textToMeasure) || ignoreUrls && URL_REGEXP.test(textToMeasure) || ignoreStrings && stringsByLine[lineNumber] || ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] || ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber]) {
  69724. // ignore this line
  69725. return;
  69726. }
  69727. var lineLength = computeLineLength(textToMeasure, tabWidth);
  69728. var commentLengthApplies = lineIsComment && maxCommentLength;
  69729. if (lineIsComment && ignoreComments) {
  69730. return;
  69731. }
  69732. if (commentLengthApplies) {
  69733. if (lineLength > maxCommentLength) {
  69734. context.report({
  69735. node: node,
  69736. loc: { line: lineNumber, column: 0 },
  69737. message: "Line {{lineNumber}} exceeds the maximum comment line length of {{maxCommentLength}}.",
  69738. data: {
  69739. lineNumber: i + 1,
  69740. maxCommentLength: maxCommentLength
  69741. }
  69742. });
  69743. }
  69744. } else if (lineLength > maxLength) {
  69745. context.report({
  69746. node: node,
  69747. loc: { line: lineNumber, column: 0 },
  69748. message: "Line {{lineNumber}} exceeds the maximum line length of {{maxLength}}.",
  69749. data: {
  69750. lineNumber: i + 1,
  69751. maxLength: maxLength
  69752. }
  69753. });
  69754. }
  69755. });
  69756. }
  69757. //--------------------------------------------------------------------------
  69758. // Public API
  69759. //--------------------------------------------------------------------------
  69760. return {
  69761. Program: checkProgramForMaxLength
  69762. };
  69763. }
  69764. };
  69765. },{}],183:[function(require,module,exports){
  69766. /**
  69767. * @fileoverview A rule to set the maximum number of line of code in a function.
  69768. * @author Pete Ward <peteward44@gmail.com>
  69769. */
  69770. "use strict";
  69771. //------------------------------------------------------------------------------
  69772. // Requirements
  69773. //------------------------------------------------------------------------------
  69774. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  69775. var astUtils = require("../util/ast-utils");
  69776. //------------------------------------------------------------------------------
  69777. // Constants
  69778. //------------------------------------------------------------------------------
  69779. var OPTIONS_SCHEMA = {
  69780. type: "object",
  69781. properties: {
  69782. max: {
  69783. type: "integer",
  69784. minimum: 0
  69785. },
  69786. skipComments: {
  69787. type: "boolean"
  69788. },
  69789. skipBlankLines: {
  69790. type: "boolean"
  69791. },
  69792. IIFEs: {
  69793. type: "boolean"
  69794. }
  69795. },
  69796. additionalProperties: false
  69797. };
  69798. var OPTIONS_OR_INTEGER_SCHEMA = {
  69799. oneOf: [OPTIONS_SCHEMA, {
  69800. type: "integer",
  69801. minimum: 1
  69802. }]
  69803. };
  69804. /**
  69805. * Given a list of comment nodes, return a map with numeric keys (source code line numbers) and comment token values.
  69806. * @param {Array} comments An array of comment nodes.
  69807. * @returns {Map.<string,Node>} A map with numeric keys (source code line numbers) and comment token values.
  69808. */
  69809. function getCommentLineNumbers(comments) {
  69810. var map = new Map();
  69811. if (!comments) {
  69812. return map;
  69813. }
  69814. comments.forEach(function (comment) {
  69815. for (var i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
  69816. map.set(i, comment);
  69817. }
  69818. });
  69819. return map;
  69820. }
  69821. //------------------------------------------------------------------------------
  69822. // Rule Definition
  69823. //------------------------------------------------------------------------------
  69824. module.exports = {
  69825. meta: {
  69826. type: "suggestion",
  69827. docs: {
  69828. description: "enforce a maximum number of line of code in a function",
  69829. category: "Stylistic Issues",
  69830. recommended: false,
  69831. url: "https://eslint.org/docs/rules/max-lines-per-function"
  69832. },
  69833. schema: [OPTIONS_OR_INTEGER_SCHEMA]
  69834. },
  69835. create: function create(context) {
  69836. var sourceCode = context.getSourceCode();
  69837. var lines = sourceCode.lines;
  69838. var option = context.options[0];
  69839. var maxLines = 50;
  69840. var skipComments = false;
  69841. var skipBlankLines = false;
  69842. var IIFEs = false;
  69843. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object") {
  69844. if (typeof option.max === "number") {
  69845. maxLines = option.max;
  69846. }
  69847. if (typeof option.skipComments === "boolean") {
  69848. skipComments = option.skipComments;
  69849. }
  69850. if (typeof option.skipBlankLines === "boolean") {
  69851. skipBlankLines = option.skipBlankLines;
  69852. }
  69853. if (typeof option.IIFEs === "boolean") {
  69854. IIFEs = option.IIFEs;
  69855. }
  69856. } else if (typeof option === "number") {
  69857. maxLines = option;
  69858. }
  69859. var commentLineNumbers = getCommentLineNumbers(sourceCode.getAllComments());
  69860. //--------------------------------------------------------------------------
  69861. // Helpers
  69862. //--------------------------------------------------------------------------
  69863. /**
  69864. * Tells if a comment encompasses the entire line.
  69865. * @param {string} line The source line with a trailing comment
  69866. * @param {number} lineNumber The one-indexed line number this is on
  69867. * @param {ASTNode} comment The comment to remove
  69868. * @returns {boolean} If the comment covers the entire line
  69869. */
  69870. function isFullLineComment(line, lineNumber, comment) {
  69871. var start = comment.loc.start,
  69872. end = comment.loc.end,
  69873. isFirstTokenOnLine = start.line === lineNumber && !line.slice(0, start.column).trim(),
  69874. isLastTokenOnLine = end.line === lineNumber && !line.slice(end.column).trim();
  69875. return comment && (start.line < lineNumber || isFirstTokenOnLine) && (end.line > lineNumber || isLastTokenOnLine);
  69876. }
  69877. /**
  69878. * Identifies is a node is a FunctionExpression which is part of an IIFE
  69879. * @param {ASTNode} node Node to test
  69880. * @returns {boolean} True if it's an IIFE
  69881. */
  69882. function isIIFE(node) {
  69883. return node.type === "FunctionExpression" && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
  69884. }
  69885. /**
  69886. * Identifies is a node is a FunctionExpression which is embedded within a MethodDefinition or Property
  69887. * @param {ASTNode} node Node to test
  69888. * @returns {boolean} True if it's a FunctionExpression embedded within a MethodDefinition or Property
  69889. */
  69890. function isEmbedded(node) {
  69891. if (!node.parent) {
  69892. return false;
  69893. }
  69894. if (node !== node.parent.value) {
  69895. return false;
  69896. }
  69897. if (node.parent.type === "MethodDefinition") {
  69898. return true;
  69899. }
  69900. if (node.parent.type === "Property") {
  69901. return node.parent.method === true || node.parent.kind === "get" || node.parent.kind === "set";
  69902. }
  69903. return false;
  69904. }
  69905. /**
  69906. * Count the lines in the function
  69907. * @param {ASTNode} funcNode Function AST node
  69908. * @returns {void}
  69909. * @private
  69910. */
  69911. function processFunction(funcNode) {
  69912. var node = isEmbedded(funcNode) ? funcNode.parent : funcNode;
  69913. if (!IIFEs && isIIFE(node)) {
  69914. return;
  69915. }
  69916. var lineCount = 0;
  69917. for (var i = node.loc.start.line - 1; i < node.loc.end.line; ++i) {
  69918. var line = lines[i];
  69919. if (skipComments) {
  69920. if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) {
  69921. continue;
  69922. }
  69923. }
  69924. if (skipBlankLines) {
  69925. if (line.match(/^\s*$/)) {
  69926. continue;
  69927. }
  69928. }
  69929. lineCount++;
  69930. }
  69931. if (lineCount > maxLines) {
  69932. var name = astUtils.getFunctionNameWithKind(funcNode);
  69933. context.report({
  69934. node: node,
  69935. message: "{{name}} has too many lines ({{lineCount}}). Maximum allowed is {{maxLines}}.",
  69936. data: { name: name, lineCount: lineCount, maxLines: maxLines }
  69937. });
  69938. }
  69939. }
  69940. //--------------------------------------------------------------------------
  69941. // Public API
  69942. //--------------------------------------------------------------------------
  69943. return {
  69944. FunctionDeclaration: processFunction,
  69945. FunctionExpression: processFunction,
  69946. ArrowFunctionExpression: processFunction
  69947. };
  69948. }
  69949. };
  69950. },{"../util/ast-utils":405}],184:[function(require,module,exports){
  69951. /**
  69952. * @fileoverview enforce a maximum file length
  69953. * @author Alberto Rodríguez
  69954. */
  69955. "use strict";
  69956. //------------------------------------------------------------------------------
  69957. // Requirements
  69958. //------------------------------------------------------------------------------
  69959. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  69960. var lodash = require("lodash");
  69961. var astUtils = require("../util/ast-utils");
  69962. //------------------------------------------------------------------------------
  69963. // Rule Definition
  69964. //------------------------------------------------------------------------------
  69965. module.exports = {
  69966. meta: {
  69967. type: "suggestion",
  69968. docs: {
  69969. description: "enforce a maximum number of lines per file",
  69970. category: "Stylistic Issues",
  69971. recommended: false,
  69972. url: "https://eslint.org/docs/rules/max-lines"
  69973. },
  69974. schema: [{
  69975. oneOf: [{
  69976. type: "integer",
  69977. minimum: 0
  69978. }, {
  69979. type: "object",
  69980. properties: {
  69981. max: {
  69982. type: "integer",
  69983. minimum: 0
  69984. },
  69985. skipComments: {
  69986. type: "boolean"
  69987. },
  69988. skipBlankLines: {
  69989. type: "boolean"
  69990. }
  69991. },
  69992. additionalProperties: false
  69993. }]
  69994. }]
  69995. },
  69996. create: function create(context) {
  69997. var option = context.options[0];
  69998. var max = 300;
  69999. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
  70000. max = option.max;
  70001. }
  70002. if (typeof option === "number") {
  70003. max = option;
  70004. }
  70005. var skipComments = option && option.skipComments;
  70006. var skipBlankLines = option && option.skipBlankLines;
  70007. var sourceCode = context.getSourceCode();
  70008. /**
  70009. * Returns whether or not a token is a comment node type
  70010. * @param {Token} token The token to check
  70011. * @returns {boolean} True if the token is a comment node
  70012. */
  70013. function isCommentNodeType(token) {
  70014. return token && (token.type === "Block" || token.type === "Line");
  70015. }
  70016. /**
  70017. * Returns the line numbers of a comment that don't have any code on the same line
  70018. * @param {Node} comment The comment node to check
  70019. * @returns {int[]} The line numbers
  70020. */
  70021. function getLinesWithoutCode(comment) {
  70022. var start = comment.loc.start.line;
  70023. var end = comment.loc.end.line;
  70024. var token = void 0;
  70025. token = comment;
  70026. do {
  70027. token = sourceCode.getTokenBefore(token, { includeComments: true });
  70028. } while (isCommentNodeType(token));
  70029. if (token && astUtils.isTokenOnSameLine(token, comment)) {
  70030. start += 1;
  70031. }
  70032. token = comment;
  70033. do {
  70034. token = sourceCode.getTokenAfter(token, { includeComments: true });
  70035. } while (isCommentNodeType(token));
  70036. if (token && astUtils.isTokenOnSameLine(comment, token)) {
  70037. end -= 1;
  70038. }
  70039. if (start <= end) {
  70040. return lodash.range(start, end + 1);
  70041. }
  70042. return [];
  70043. }
  70044. return {
  70045. "Program:exit": function ProgramExit() {
  70046. var lines = sourceCode.lines.map(function (text, i) {
  70047. return { lineNumber: i + 1, text: text };
  70048. });
  70049. if (skipBlankLines) {
  70050. lines = lines.filter(function (l) {
  70051. return l.text.trim() !== "";
  70052. });
  70053. }
  70054. if (skipComments) {
  70055. var comments = sourceCode.getAllComments();
  70056. var commentLines = lodash.flatten(comments.map(function (comment) {
  70057. return getLinesWithoutCode(comment);
  70058. }));
  70059. lines = lines.filter(function (l) {
  70060. return !lodash.includes(commentLines, l.lineNumber);
  70061. });
  70062. }
  70063. if (lines.length > max) {
  70064. context.report({
  70065. loc: { line: 1, column: 0 },
  70066. message: "File must be at most {{max}} lines long. It's {{actual}} lines long.",
  70067. data: {
  70068. max: max,
  70069. actual: lines.length
  70070. }
  70071. });
  70072. }
  70073. }
  70074. };
  70075. }
  70076. };
  70077. },{"../util/ast-utils":405,"lodash":92}],185:[function(require,module,exports){
  70078. /**
  70079. * @fileoverview Rule to enforce a maximum number of nested callbacks.
  70080. * @author Ian Christian Myers
  70081. */
  70082. "use strict";
  70083. //------------------------------------------------------------------------------
  70084. // Rule Definition
  70085. //------------------------------------------------------------------------------
  70086. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  70087. module.exports = {
  70088. meta: {
  70089. type: "suggestion",
  70090. docs: {
  70091. description: "enforce a maximum depth that callbacks can be nested",
  70092. category: "Stylistic Issues",
  70093. recommended: false,
  70094. url: "https://eslint.org/docs/rules/max-nested-callbacks"
  70095. },
  70096. schema: [{
  70097. oneOf: [{
  70098. type: "integer",
  70099. minimum: 0
  70100. }, {
  70101. type: "object",
  70102. properties: {
  70103. maximum: {
  70104. type: "integer",
  70105. minimum: 0
  70106. },
  70107. max: {
  70108. type: "integer",
  70109. minimum: 0
  70110. }
  70111. },
  70112. additionalProperties: false
  70113. }]
  70114. }]
  70115. },
  70116. create: function create(context) {
  70117. //--------------------------------------------------------------------------
  70118. // Constants
  70119. //--------------------------------------------------------------------------
  70120. var option = context.options[0];
  70121. var THRESHOLD = 10;
  70122. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
  70123. THRESHOLD = option.maximum;
  70124. }
  70125. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
  70126. THRESHOLD = option.max;
  70127. }
  70128. if (typeof option === "number") {
  70129. THRESHOLD = option;
  70130. }
  70131. //--------------------------------------------------------------------------
  70132. // Helpers
  70133. //--------------------------------------------------------------------------
  70134. var callbackStack = [];
  70135. /**
  70136. * Checks a given function node for too many callbacks.
  70137. * @param {ASTNode} node The node to check.
  70138. * @returns {void}
  70139. * @private
  70140. */
  70141. function checkFunction(node) {
  70142. var parent = node.parent;
  70143. if (parent.type === "CallExpression") {
  70144. callbackStack.push(node);
  70145. }
  70146. if (callbackStack.length > THRESHOLD) {
  70147. var opts = { num: callbackStack.length, max: THRESHOLD };
  70148. context.report({ node: node, message: "Too many nested callbacks ({{num}}). Maximum allowed is {{max}}.", data: opts });
  70149. }
  70150. }
  70151. /**
  70152. * Pops the call stack.
  70153. * @returns {void}
  70154. * @private
  70155. */
  70156. function popStack() {
  70157. callbackStack.pop();
  70158. }
  70159. //--------------------------------------------------------------------------
  70160. // Public API
  70161. //--------------------------------------------------------------------------
  70162. return {
  70163. ArrowFunctionExpression: checkFunction,
  70164. "ArrowFunctionExpression:exit": popStack,
  70165. FunctionExpression: checkFunction,
  70166. "FunctionExpression:exit": popStack
  70167. };
  70168. }
  70169. };
  70170. },{}],186:[function(require,module,exports){
  70171. /**
  70172. * @fileoverview Rule to flag when a function has too many parameters
  70173. * @author Ilya Volodin
  70174. */
  70175. "use strict";
  70176. //------------------------------------------------------------------------------
  70177. // Requirements
  70178. //------------------------------------------------------------------------------
  70179. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  70180. var lodash = require("lodash");
  70181. var astUtils = require("../util/ast-utils");
  70182. //------------------------------------------------------------------------------
  70183. // Rule Definition
  70184. //------------------------------------------------------------------------------
  70185. module.exports = {
  70186. meta: {
  70187. type: "suggestion",
  70188. docs: {
  70189. description: "enforce a maximum number of parameters in function definitions",
  70190. category: "Stylistic Issues",
  70191. recommended: false,
  70192. url: "https://eslint.org/docs/rules/max-params"
  70193. },
  70194. schema: [{
  70195. oneOf: [{
  70196. type: "integer",
  70197. minimum: 0
  70198. }, {
  70199. type: "object",
  70200. properties: {
  70201. maximum: {
  70202. type: "integer",
  70203. minimum: 0
  70204. },
  70205. max: {
  70206. type: "integer",
  70207. minimum: 0
  70208. }
  70209. },
  70210. additionalProperties: false
  70211. }]
  70212. }]
  70213. },
  70214. create: function create(context) {
  70215. var sourceCode = context.getSourceCode();
  70216. var option = context.options[0];
  70217. var numParams = 3;
  70218. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
  70219. numParams = option.maximum;
  70220. }
  70221. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
  70222. numParams = option.max;
  70223. }
  70224. if (typeof option === "number") {
  70225. numParams = option;
  70226. }
  70227. /**
  70228. * Checks a function to see if it has too many parameters.
  70229. * @param {ASTNode} node The node to check.
  70230. * @returns {void}
  70231. * @private
  70232. */
  70233. function checkFunction(node) {
  70234. if (node.params.length > numParams) {
  70235. context.report({
  70236. loc: astUtils.getFunctionHeadLoc(node, sourceCode),
  70237. node: node,
  70238. message: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}.",
  70239. data: {
  70240. name: lodash.upperFirst(astUtils.getFunctionNameWithKind(node)),
  70241. count: node.params.length,
  70242. max: numParams
  70243. }
  70244. });
  70245. }
  70246. }
  70247. return {
  70248. FunctionDeclaration: checkFunction,
  70249. ArrowFunctionExpression: checkFunction,
  70250. FunctionExpression: checkFunction
  70251. };
  70252. }
  70253. };
  70254. },{"../util/ast-utils":405,"lodash":92}],187:[function(require,module,exports){
  70255. /**
  70256. * @fileoverview Specify the maximum number of statements allowed per line.
  70257. * @author Kenneth Williams
  70258. */
  70259. "use strict";
  70260. //------------------------------------------------------------------------------
  70261. // Requirements
  70262. //------------------------------------------------------------------------------
  70263. var astUtils = require("../util/ast-utils");
  70264. //------------------------------------------------------------------------------
  70265. // Rule Definition
  70266. //------------------------------------------------------------------------------
  70267. module.exports = {
  70268. meta: {
  70269. type: "layout",
  70270. docs: {
  70271. description: "enforce a maximum number of statements allowed per line",
  70272. category: "Stylistic Issues",
  70273. recommended: false,
  70274. url: "https://eslint.org/docs/rules/max-statements-per-line"
  70275. },
  70276. schema: [{
  70277. type: "object",
  70278. properties: {
  70279. max: {
  70280. type: "integer",
  70281. minimum: 1
  70282. }
  70283. },
  70284. additionalProperties: false
  70285. }]
  70286. },
  70287. create: function create(context) {
  70288. var sourceCode = context.getSourceCode(),
  70289. options = context.options[0] || {},
  70290. maxStatementsPerLine = typeof options.max !== "undefined" ? options.max : 1,
  70291. message = "This line has {{numberOfStatementsOnThisLine}} {{statements}}. Maximum allowed is {{maxStatementsPerLine}}.";
  70292. var lastStatementLine = 0,
  70293. numberOfStatementsOnThisLine = 0,
  70294. firstExtraStatement = void 0;
  70295. //--------------------------------------------------------------------------
  70296. // Helpers
  70297. //--------------------------------------------------------------------------
  70298. var SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)$/;
  70299. /**
  70300. * Reports with the first extra statement, and clears it.
  70301. *
  70302. * @returns {void}
  70303. */
  70304. function reportFirstExtraStatementAndClear() {
  70305. if (firstExtraStatement) {
  70306. context.report({
  70307. node: firstExtraStatement,
  70308. message: message,
  70309. data: {
  70310. numberOfStatementsOnThisLine: numberOfStatementsOnThisLine,
  70311. maxStatementsPerLine: maxStatementsPerLine,
  70312. statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements"
  70313. }
  70314. });
  70315. }
  70316. firstExtraStatement = null;
  70317. }
  70318. /**
  70319. * Gets the actual last token of a given node.
  70320. *
  70321. * @param {ASTNode} node - A node to get. This is a node except EmptyStatement.
  70322. * @returns {Token} The actual last token.
  70323. */
  70324. function getActualLastToken(node) {
  70325. return sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
  70326. }
  70327. /**
  70328. * Addresses a given node.
  70329. * It updates the state of this rule, then reports the node if the node violated this rule.
  70330. *
  70331. * @param {ASTNode} node - A node to check.
  70332. * @returns {void}
  70333. */
  70334. function enterStatement(node) {
  70335. var line = node.loc.start.line;
  70336. /*
  70337. * Skip to allow non-block statements if this is direct child of control statements.
  70338. * `if (a) foo();` is counted as 1.
  70339. * But `if (a) foo(); else foo();` should be counted as 2.
  70340. */
  70341. if (SINGLE_CHILD_ALLOWED.test(node.parent.type) && node.parent.alternate !== node) {
  70342. return;
  70343. }
  70344. // Update state.
  70345. if (line === lastStatementLine) {
  70346. numberOfStatementsOnThisLine += 1;
  70347. } else {
  70348. reportFirstExtraStatementAndClear();
  70349. numberOfStatementsOnThisLine = 1;
  70350. lastStatementLine = line;
  70351. }
  70352. // Reports if the node violated this rule.
  70353. if (numberOfStatementsOnThisLine === maxStatementsPerLine + 1) {
  70354. firstExtraStatement = firstExtraStatement || node;
  70355. }
  70356. }
  70357. /**
  70358. * Updates the state of this rule with the end line of leaving node to check with the next statement.
  70359. *
  70360. * @param {ASTNode} node - A node to check.
  70361. * @returns {void}
  70362. */
  70363. function leaveStatement(node) {
  70364. var line = getActualLastToken(node).loc.end.line;
  70365. // Update state.
  70366. if (line !== lastStatementLine) {
  70367. reportFirstExtraStatementAndClear();
  70368. numberOfStatementsOnThisLine = 1;
  70369. lastStatementLine = line;
  70370. }
  70371. }
  70372. //--------------------------------------------------------------------------
  70373. // Public API
  70374. //--------------------------------------------------------------------------
  70375. return {
  70376. BreakStatement: enterStatement,
  70377. ClassDeclaration: enterStatement,
  70378. ContinueStatement: enterStatement,
  70379. DebuggerStatement: enterStatement,
  70380. DoWhileStatement: enterStatement,
  70381. ExpressionStatement: enterStatement,
  70382. ForInStatement: enterStatement,
  70383. ForOfStatement: enterStatement,
  70384. ForStatement: enterStatement,
  70385. FunctionDeclaration: enterStatement,
  70386. IfStatement: enterStatement,
  70387. ImportDeclaration: enterStatement,
  70388. LabeledStatement: enterStatement,
  70389. ReturnStatement: enterStatement,
  70390. SwitchStatement: enterStatement,
  70391. ThrowStatement: enterStatement,
  70392. TryStatement: enterStatement,
  70393. VariableDeclaration: enterStatement,
  70394. WhileStatement: enterStatement,
  70395. WithStatement: enterStatement,
  70396. ExportNamedDeclaration: enterStatement,
  70397. ExportDefaultDeclaration: enterStatement,
  70398. ExportAllDeclaration: enterStatement,
  70399. "BreakStatement:exit": leaveStatement,
  70400. "ClassDeclaration:exit": leaveStatement,
  70401. "ContinueStatement:exit": leaveStatement,
  70402. "DebuggerStatement:exit": leaveStatement,
  70403. "DoWhileStatement:exit": leaveStatement,
  70404. "ExpressionStatement:exit": leaveStatement,
  70405. "ForInStatement:exit": leaveStatement,
  70406. "ForOfStatement:exit": leaveStatement,
  70407. "ForStatement:exit": leaveStatement,
  70408. "FunctionDeclaration:exit": leaveStatement,
  70409. "IfStatement:exit": leaveStatement,
  70410. "ImportDeclaration:exit": leaveStatement,
  70411. "LabeledStatement:exit": leaveStatement,
  70412. "ReturnStatement:exit": leaveStatement,
  70413. "SwitchStatement:exit": leaveStatement,
  70414. "ThrowStatement:exit": leaveStatement,
  70415. "TryStatement:exit": leaveStatement,
  70416. "VariableDeclaration:exit": leaveStatement,
  70417. "WhileStatement:exit": leaveStatement,
  70418. "WithStatement:exit": leaveStatement,
  70419. "ExportNamedDeclaration:exit": leaveStatement,
  70420. "ExportDefaultDeclaration:exit": leaveStatement,
  70421. "ExportAllDeclaration:exit": leaveStatement,
  70422. "Program:exit": reportFirstExtraStatementAndClear
  70423. };
  70424. }
  70425. };
  70426. },{"../util/ast-utils":405}],188:[function(require,module,exports){
  70427. /**
  70428. * @fileoverview A rule to set the maximum number of statements in a function.
  70429. * @author Ian Christian Myers
  70430. */
  70431. "use strict";
  70432. //------------------------------------------------------------------------------
  70433. // Requirements
  70434. //------------------------------------------------------------------------------
  70435. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  70436. var lodash = require("lodash");
  70437. var astUtils = require("../util/ast-utils");
  70438. //------------------------------------------------------------------------------
  70439. // Rule Definition
  70440. //------------------------------------------------------------------------------
  70441. module.exports = {
  70442. meta: {
  70443. type: "suggestion",
  70444. docs: {
  70445. description: "enforce a maximum number of statements allowed in function blocks",
  70446. category: "Stylistic Issues",
  70447. recommended: false,
  70448. url: "https://eslint.org/docs/rules/max-statements"
  70449. },
  70450. schema: [{
  70451. oneOf: [{
  70452. type: "integer",
  70453. minimum: 0
  70454. }, {
  70455. type: "object",
  70456. properties: {
  70457. maximum: {
  70458. type: "integer",
  70459. minimum: 0
  70460. },
  70461. max: {
  70462. type: "integer",
  70463. minimum: 0
  70464. }
  70465. },
  70466. additionalProperties: false
  70467. }]
  70468. }, {
  70469. type: "object",
  70470. properties: {
  70471. ignoreTopLevelFunctions: {
  70472. type: "boolean"
  70473. }
  70474. },
  70475. additionalProperties: false
  70476. }]
  70477. },
  70478. create: function create(context) {
  70479. //--------------------------------------------------------------------------
  70480. // Helpers
  70481. //--------------------------------------------------------------------------
  70482. var functionStack = [],
  70483. option = context.options[0],
  70484. ignoreTopLevelFunctions = context.options[1] && context.options[1].ignoreTopLevelFunctions || false,
  70485. topLevelFunctions = [];
  70486. var maxStatements = 10;
  70487. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
  70488. maxStatements = option.maximum;
  70489. }
  70490. if ((typeof option === "undefined" ? "undefined" : _typeof(option)) === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
  70491. maxStatements = option.max;
  70492. }
  70493. if (typeof option === "number") {
  70494. maxStatements = option;
  70495. }
  70496. /**
  70497. * Reports a node if it has too many statements
  70498. * @param {ASTNode} node node to evaluate
  70499. * @param {int} count Number of statements in node
  70500. * @param {int} max Maximum number of statements allowed
  70501. * @returns {void}
  70502. * @private
  70503. */
  70504. function reportIfTooManyStatements(node, count, max) {
  70505. if (count > max) {
  70506. var name = lodash.upperFirst(astUtils.getFunctionNameWithKind(node));
  70507. context.report({
  70508. node: node,
  70509. message: "{{name}} has too many statements ({{count}}). Maximum allowed is {{max}}.",
  70510. data: { name: name, count: count, max: max }
  70511. });
  70512. }
  70513. }
  70514. /**
  70515. * When parsing a new function, store it in our function stack
  70516. * @returns {void}
  70517. * @private
  70518. */
  70519. function startFunction() {
  70520. functionStack.push(0);
  70521. }
  70522. /**
  70523. * Evaluate the node at the end of function
  70524. * @param {ASTNode} node node to evaluate
  70525. * @returns {void}
  70526. * @private
  70527. */
  70528. function endFunction(node) {
  70529. var count = functionStack.pop();
  70530. if (ignoreTopLevelFunctions && functionStack.length === 0) {
  70531. topLevelFunctions.push({ node: node, count: count });
  70532. } else {
  70533. reportIfTooManyStatements(node, count, maxStatements);
  70534. }
  70535. }
  70536. /**
  70537. * Increment the count of the functions
  70538. * @param {ASTNode} node node to evaluate
  70539. * @returns {void}
  70540. * @private
  70541. */
  70542. function countStatements(node) {
  70543. functionStack[functionStack.length - 1] += node.body.length;
  70544. }
  70545. //--------------------------------------------------------------------------
  70546. // Public API
  70547. //--------------------------------------------------------------------------
  70548. return {
  70549. FunctionDeclaration: startFunction,
  70550. FunctionExpression: startFunction,
  70551. ArrowFunctionExpression: startFunction,
  70552. BlockStatement: countStatements,
  70553. "FunctionDeclaration:exit": endFunction,
  70554. "FunctionExpression:exit": endFunction,
  70555. "ArrowFunctionExpression:exit": endFunction,
  70556. "Program:exit": function ProgramExit() {
  70557. if (topLevelFunctions.length === 1) {
  70558. return;
  70559. }
  70560. topLevelFunctions.forEach(function (element) {
  70561. var count = element.count;
  70562. var node = element.node;
  70563. reportIfTooManyStatements(node, count, maxStatements);
  70564. });
  70565. }
  70566. };
  70567. }
  70568. };
  70569. },{"../util/ast-utils":405,"lodash":92}],189:[function(require,module,exports){
  70570. /**
  70571. * @fileoverview enforce a particular style for multiline comments
  70572. * @author Teddy Katz
  70573. */
  70574. "use strict";
  70575. var astUtils = require("../util/ast-utils");
  70576. //------------------------------------------------------------------------------
  70577. // Rule Definition
  70578. //------------------------------------------------------------------------------
  70579. module.exports = {
  70580. meta: {
  70581. type: "suggestion",
  70582. docs: {
  70583. description: "enforce a particular style for multiline comments",
  70584. category: "Stylistic Issues",
  70585. recommended: false,
  70586. url: "https://eslint.org/docs/rules/multiline-comment-style"
  70587. },
  70588. fixable: "whitespace",
  70589. schema: [{ enum: ["starred-block", "separate-lines", "bare-block"] }]
  70590. },
  70591. create: function create(context) {
  70592. var sourceCode = context.getSourceCode();
  70593. var option = context.options[0] || "starred-block";
  70594. var EXPECTED_BLOCK_ERROR = "Expected a block comment instead of consecutive line comments.";
  70595. var START_NEWLINE_ERROR = "Expected a linebreak after '/*'.";
  70596. var END_NEWLINE_ERROR = "Expected a linebreak before '*/'.";
  70597. var MISSING_STAR_ERROR = "Expected a '*' at the start of this line.";
  70598. var ALIGNMENT_ERROR = "Expected this line to be aligned with the start of the comment.";
  70599. var EXPECTED_LINES_ERROR = "Expected multiple line comments instead of a block comment.";
  70600. //----------------------------------------------------------------------
  70601. // Helpers
  70602. //----------------------------------------------------------------------
  70603. /**
  70604. * Gets a list of comment lines in a group
  70605. * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment
  70606. * @returns {string[]} A list of comment lines
  70607. */
  70608. function getCommentLines(commentGroup) {
  70609. if (commentGroup[0].type === "Line") {
  70610. return commentGroup.map(function (comment) {
  70611. return comment.value;
  70612. });
  70613. }
  70614. return commentGroup[0].value.split(astUtils.LINEBREAK_MATCHER).map(function (line) {
  70615. return line.replace(/^\s*\*?/, "");
  70616. });
  70617. }
  70618. /**
  70619. * Converts a comment into starred-block form
  70620. * @param {Token} firstComment The first comment of the group being converted
  70621. * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
  70622. * @returns {string} A representation of the comment value in starred-block form, excluding start and end markers
  70623. */
  70624. function convertToStarredBlock(firstComment, commentLinesList) {
  70625. var initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
  70626. var starredLines = commentLinesList.map(function (line) {
  70627. return initialOffset + " *" + line;
  70628. });
  70629. return "\n" + starredLines.join("\n") + "\n" + initialOffset + " ";
  70630. }
  70631. /**
  70632. * Converts a comment into separate-line form
  70633. * @param {Token} firstComment The first comment of the group being converted
  70634. * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
  70635. * @returns {string} A representation of the comment value in separate-line form
  70636. */
  70637. function convertToSeparateLines(firstComment, commentLinesList) {
  70638. var initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
  70639. var separateLines = commentLinesList.map(function (line) {
  70640. return "// " + line.trim();
  70641. });
  70642. return separateLines.join("\n" + initialOffset);
  70643. }
  70644. /**
  70645. * Converts a comment into bare-block form
  70646. * @param {Token} firstComment The first comment of the group being converted
  70647. * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
  70648. * @returns {string} A representation of the comment value in bare-block form
  70649. */
  70650. function convertToBlock(firstComment, commentLinesList) {
  70651. var initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
  70652. var blockLines = commentLinesList.map(function (line) {
  70653. return line.trim();
  70654. });
  70655. return "/* " + blockLines.join("\n" + initialOffset + " ") + " */";
  70656. }
  70657. /**
  70658. * Check a comment is JSDoc form
  70659. * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment
  70660. * @returns {boolean} if commentGroup is JSDoc form, return true
  70661. */
  70662. function isJSDoc(commentGroup) {
  70663. var lines = commentGroup[0].value.split(astUtils.LINEBREAK_MATCHER);
  70664. return commentGroup[0].type === "Block" && /^\*\s*$/.test(lines[0]) && lines.slice(1, -1).every(function (line) {
  70665. return (/^\s* /.test(line)
  70666. );
  70667. }) && /^\s*$/.test(lines[lines.length - 1]);
  70668. }
  70669. /**
  70670. * Each method checks a group of comments to see if it's valid according to the given option.
  70671. * @param {Token[]} commentGroup A list of comments that appear together. This will either contain a single
  70672. * block comment or multiple line comments.
  70673. * @returns {void}
  70674. */
  70675. var commentGroupCheckers = {
  70676. "starred-block": function starredBlock(commentGroup) {
  70677. var commentLines = getCommentLines(commentGroup);
  70678. if (commentLines.some(function (value) {
  70679. return value.includes("*/");
  70680. })) {
  70681. return;
  70682. }
  70683. if (commentGroup.length > 1) {
  70684. context.report({
  70685. loc: {
  70686. start: commentGroup[0].loc.start,
  70687. end: commentGroup[commentGroup.length - 1].loc.end
  70688. },
  70689. message: EXPECTED_BLOCK_ERROR,
  70690. fix: function fix(fixer) {
  70691. var range = [commentGroup[0].range[0], commentGroup[commentGroup.length - 1].range[1]];
  70692. var starredBlock = "/*" + convertToStarredBlock(commentGroup[0], commentLines) + "*/";
  70693. return commentLines.some(function (value) {
  70694. return value.startsWith("/");
  70695. }) ? null : fixer.replaceTextRange(range, starredBlock);
  70696. }
  70697. });
  70698. } else {
  70699. (function () {
  70700. var block = commentGroup[0];
  70701. var lines = block.value.split(astUtils.LINEBREAK_MATCHER);
  70702. var expectedLinePrefix = sourceCode.text.slice(block.range[0] - block.loc.start.column, block.range[0]) + " *";
  70703. if (!/^\*?\s*$/.test(lines[0])) {
  70704. var start = block.value.startsWith("*") ? block.range[0] + 1 : block.range[0];
  70705. context.report({
  70706. loc: {
  70707. start: block.loc.start,
  70708. end: { line: block.loc.start.line, column: block.loc.start.column + 2 }
  70709. },
  70710. message: START_NEWLINE_ERROR,
  70711. fix: function fix(fixer) {
  70712. return fixer.insertTextAfterRange([start, start + 2], "\n" + expectedLinePrefix);
  70713. }
  70714. });
  70715. }
  70716. if (!/^\s*$/.test(lines[lines.length - 1])) {
  70717. context.report({
  70718. loc: {
  70719. start: { line: block.loc.end.line, column: block.loc.end.column - 2 },
  70720. end: block.loc.end
  70721. },
  70722. message: END_NEWLINE_ERROR,
  70723. fix: function fix(fixer) {
  70724. return fixer.replaceTextRange([block.range[1] - 2, block.range[1]], "\n" + expectedLinePrefix + "/");
  70725. }
  70726. });
  70727. }
  70728. var _loop = function _loop(lineNumber) {
  70729. var lineText = sourceCode.lines[lineNumber - 1];
  70730. if (!lineText.startsWith(expectedLinePrefix)) {
  70731. context.report({
  70732. loc: {
  70733. start: { line: lineNumber, column: 0 },
  70734. end: { line: lineNumber, column: sourceCode.lines[lineNumber - 1].length }
  70735. },
  70736. message: /^\s*\*/.test(lineText) ? ALIGNMENT_ERROR : MISSING_STAR_ERROR,
  70737. fix: function fix(fixer) {
  70738. var lineStartIndex = sourceCode.getIndexFromLoc({ line: lineNumber, column: 0 });
  70739. var linePrefixLength = lineText.match(/^\s*\*? ?/)[0].length;
  70740. var commentStartIndex = lineStartIndex + linePrefixLength;
  70741. var replacementText = lineNumber === block.loc.end.line || lineText.length === linePrefixLength ? expectedLinePrefix : expectedLinePrefix + " ";
  70742. return fixer.replaceTextRange([lineStartIndex, commentStartIndex], replacementText);
  70743. }
  70744. });
  70745. }
  70746. };
  70747. for (var lineNumber = block.loc.start.line + 1; lineNumber <= block.loc.end.line; lineNumber++) {
  70748. _loop(lineNumber);
  70749. }
  70750. })();
  70751. }
  70752. },
  70753. "separate-lines": function separateLines(commentGroup) {
  70754. if (!isJSDoc(commentGroup) && commentGroup[0].type === "Block") {
  70755. var commentLines = getCommentLines(commentGroup);
  70756. var block = commentGroup[0];
  70757. var tokenAfter = sourceCode.getTokenAfter(block, { includeComments: true });
  70758. if (tokenAfter && block.loc.end.line === tokenAfter.loc.start.line) {
  70759. return;
  70760. }
  70761. context.report({
  70762. loc: {
  70763. start: block.loc.start,
  70764. end: { line: block.loc.start.line, column: block.loc.start.column + 2 }
  70765. },
  70766. message: EXPECTED_LINES_ERROR,
  70767. fix: function fix(fixer) {
  70768. return fixer.replaceText(block, convertToSeparateLines(block, commentLines.filter(function (line) {
  70769. return line;
  70770. })));
  70771. }
  70772. });
  70773. }
  70774. },
  70775. "bare-block": function bareBlock(commentGroup) {
  70776. if (!isJSDoc(commentGroup)) {
  70777. var commentLines = getCommentLines(commentGroup);
  70778. // disallows consecutive line comments in favor of using a block comment.
  70779. if (commentGroup[0].type === "Line" && commentLines.length > 1 && !commentLines.some(function (value) {
  70780. return value.includes("*/");
  70781. })) {
  70782. context.report({
  70783. loc: {
  70784. start: commentGroup[0].loc.start,
  70785. end: commentGroup[commentGroup.length - 1].loc.end
  70786. },
  70787. message: EXPECTED_BLOCK_ERROR,
  70788. fix: function fix(fixer) {
  70789. var range = [commentGroup[0].range[0], commentGroup[commentGroup.length - 1].range[1]];
  70790. var block = convertToBlock(commentGroup[0], commentLines.filter(function (line) {
  70791. return line;
  70792. }));
  70793. return fixer.replaceTextRange(range, block);
  70794. }
  70795. });
  70796. }
  70797. // prohibits block comments from having a * at the beginning of each line.
  70798. if (commentGroup[0].type === "Block") {
  70799. var block = commentGroup[0];
  70800. var lines = block.value.split(astUtils.LINEBREAK_MATCHER).filter(function (line) {
  70801. return line.trim();
  70802. });
  70803. if (lines.length > 0 && lines.every(function (line) {
  70804. return (/^\s*\*/.test(line)
  70805. );
  70806. })) {
  70807. context.report({
  70808. loc: {
  70809. start: block.loc.start,
  70810. end: { line: block.loc.start.line, column: block.loc.start.column + 2 }
  70811. },
  70812. message: EXPECTED_BLOCK_ERROR,
  70813. fix: function fix(fixer) {
  70814. return fixer.replaceText(block, convertToBlock(block, commentLines.filter(function (line) {
  70815. return line;
  70816. })));
  70817. }
  70818. });
  70819. }
  70820. }
  70821. }
  70822. }
  70823. };
  70824. //----------------------------------------------------------------------
  70825. // Public
  70826. //----------------------------------------------------------------------
  70827. return {
  70828. Program: function Program() {
  70829. return sourceCode.getAllComments().filter(function (comment) {
  70830. return comment.type !== "Shebang";
  70831. }).filter(function (comment) {
  70832. return !astUtils.COMMENTS_IGNORE_PATTERN.test(comment.value);
  70833. }).filter(function (comment) {
  70834. var tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true });
  70835. return !tokenBefore || tokenBefore.loc.end.line < comment.loc.start.line;
  70836. }).reduce(function (commentGroups, comment, index, commentList) {
  70837. var tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true });
  70838. if (comment.type === "Line" && index && commentList[index - 1].type === "Line" && tokenBefore && tokenBefore.loc.end.line === comment.loc.start.line - 1 && tokenBefore === commentList[index - 1]) {
  70839. commentGroups[commentGroups.length - 1].push(comment);
  70840. } else {
  70841. commentGroups.push([comment]);
  70842. }
  70843. return commentGroups;
  70844. }, []).filter(function (commentGroup) {
  70845. return !(commentGroup.length === 1 && commentGroup[0].loc.start.line === commentGroup[0].loc.end.line);
  70846. }).forEach(commentGroupCheckers[option]);
  70847. }
  70848. };
  70849. }
  70850. };
  70851. },{"../util/ast-utils":405}],190:[function(require,module,exports){
  70852. /**
  70853. * @fileoverview Enforce newlines between operands of ternary expressions
  70854. * @author Kai Cataldo
  70855. */
  70856. "use strict";
  70857. var astUtils = require("../util/ast-utils");
  70858. //------------------------------------------------------------------------------
  70859. // Rule Definition
  70860. //------------------------------------------------------------------------------
  70861. module.exports = {
  70862. meta: {
  70863. type: "layout",
  70864. docs: {
  70865. description: "enforce newlines between operands of ternary expressions",
  70866. category: "Stylistic Issues",
  70867. recommended: false,
  70868. url: "https://eslint.org/docs/rules/multiline-ternary"
  70869. },
  70870. schema: [{
  70871. enum: ["always", "always-multiline", "never"]
  70872. }]
  70873. },
  70874. create: function create(context) {
  70875. var option = context.options[0];
  70876. var multiline = option !== "never";
  70877. var allowSingleLine = option === "always-multiline";
  70878. //--------------------------------------------------------------------------
  70879. // Helpers
  70880. //--------------------------------------------------------------------------
  70881. /**
  70882. * Tests whether node is preceded by supplied tokens
  70883. * @param {ASTNode} node - node to check
  70884. * @param {ASTNode} parentNode - parent of node to report
  70885. * @param {boolean} expected - whether newline was expected or not
  70886. * @returns {void}
  70887. * @private
  70888. */
  70889. function reportError(node, parentNode, expected) {
  70890. context.report({
  70891. node: node,
  70892. message: "{{expected}} newline between {{typeOfError}} of ternary expression.",
  70893. data: {
  70894. expected: expected ? "Expected" : "Unexpected",
  70895. typeOfError: node === parentNode.test ? "test and consequent" : "consequent and alternate"
  70896. }
  70897. });
  70898. }
  70899. //--------------------------------------------------------------------------
  70900. // Public
  70901. //--------------------------------------------------------------------------
  70902. return {
  70903. ConditionalExpression: function ConditionalExpression(node) {
  70904. var areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(node.test, node.consequent);
  70905. var areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(node.consequent, node.alternate);
  70906. if (!multiline) {
  70907. if (!areTestAndConsequentOnSameLine) {
  70908. reportError(node.test, node, false);
  70909. }
  70910. if (!areConsequentAndAlternateOnSameLine) {
  70911. reportError(node.consequent, node, false);
  70912. }
  70913. } else {
  70914. if (allowSingleLine && node.loc.start.line === node.loc.end.line) {
  70915. return;
  70916. }
  70917. if (areTestAndConsequentOnSameLine) {
  70918. reportError(node.test, node, true);
  70919. }
  70920. if (areConsequentAndAlternateOnSameLine) {
  70921. reportError(node.consequent, node, true);
  70922. }
  70923. }
  70924. }
  70925. };
  70926. }
  70927. };
  70928. },{"../util/ast-utils":405}],191:[function(require,module,exports){
  70929. /**
  70930. * @fileoverview Rule to flag use of constructors without capital letters
  70931. * @author Nicholas C. Zakas
  70932. */
  70933. "use strict";
  70934. //------------------------------------------------------------------------------
  70935. // Requirements
  70936. //------------------------------------------------------------------------------
  70937. //------------------------------------------------------------------------------
  70938. // Helpers
  70939. //------------------------------------------------------------------------------
  70940. var CAPS_ALLOWED = ["Array", "Boolean", "Date", "Error", "Function", "Number", "Object", "RegExp", "String", "Symbol"];
  70941. /**
  70942. * Ensure that if the key is provided, it must be an array.
  70943. * @param {Object} obj Object to check with `key`.
  70944. * @param {string} key Object key to check on `obj`.
  70945. * @param {*} fallback If obj[key] is not present, this will be returned.
  70946. * @returns {string[]} Returns obj[key] if it's an Array, otherwise `fallback`
  70947. */
  70948. function checkArray(obj, key, fallback) {
  70949. /* istanbul ignore if */
  70950. if (Object.prototype.hasOwnProperty.call(obj, key) && !Array.isArray(obj[key])) {
  70951. throw new TypeError(key + ", if provided, must be an Array");
  70952. }
  70953. return obj[key] || fallback;
  70954. }
  70955. /**
  70956. * A reducer function to invert an array to an Object mapping the string form of the key, to `true`.
  70957. * @param {Object} map Accumulator object for the reduce.
  70958. * @param {string} key Object key to set to `true`.
  70959. * @returns {Object} Returns the updated Object for further reduction.
  70960. */
  70961. function invert(map, key) {
  70962. map[key] = true;
  70963. return map;
  70964. }
  70965. /**
  70966. * Creates an object with the cap is new exceptions as its keys and true as their values.
  70967. * @param {Object} config Rule configuration
  70968. * @returns {Object} Object with cap is new exceptions.
  70969. */
  70970. function calculateCapIsNewExceptions(config) {
  70971. var capIsNewExceptions = checkArray(config, "capIsNewExceptions", CAPS_ALLOWED);
  70972. if (capIsNewExceptions !== CAPS_ALLOWED) {
  70973. capIsNewExceptions = capIsNewExceptions.concat(CAPS_ALLOWED);
  70974. }
  70975. return capIsNewExceptions.reduce(invert, {});
  70976. }
  70977. //------------------------------------------------------------------------------
  70978. // Rule Definition
  70979. //------------------------------------------------------------------------------
  70980. module.exports = {
  70981. meta: {
  70982. type: "suggestion",
  70983. docs: {
  70984. description: "require constructor names to begin with a capital letter",
  70985. category: "Stylistic Issues",
  70986. recommended: false,
  70987. url: "https://eslint.org/docs/rules/new-cap"
  70988. },
  70989. schema: [{
  70990. type: "object",
  70991. properties: {
  70992. newIsCap: {
  70993. type: "boolean"
  70994. },
  70995. capIsNew: {
  70996. type: "boolean"
  70997. },
  70998. newIsCapExceptions: {
  70999. type: "array",
  71000. items: {
  71001. type: "string"
  71002. }
  71003. },
  71004. newIsCapExceptionPattern: {
  71005. type: "string"
  71006. },
  71007. capIsNewExceptions: {
  71008. type: "array",
  71009. items: {
  71010. type: "string"
  71011. }
  71012. },
  71013. capIsNewExceptionPattern: {
  71014. type: "string"
  71015. },
  71016. properties: {
  71017. type: "boolean"
  71018. }
  71019. },
  71020. additionalProperties: false
  71021. }]
  71022. },
  71023. create: function create(context) {
  71024. var config = context.options[0] ? Object.assign({}, context.options[0]) : {};
  71025. config.newIsCap = config.newIsCap !== false;
  71026. config.capIsNew = config.capIsNew !== false;
  71027. var skipProperties = config.properties === false;
  71028. var newIsCapExceptions = checkArray(config, "newIsCapExceptions", []).reduce(invert, {});
  71029. var newIsCapExceptionPattern = config.newIsCapExceptionPattern ? new RegExp(config.newIsCapExceptionPattern) : null;
  71030. var capIsNewExceptions = calculateCapIsNewExceptions(config);
  71031. var capIsNewExceptionPattern = config.capIsNewExceptionPattern ? new RegExp(config.capIsNewExceptionPattern) : null;
  71032. var listeners = {};
  71033. var sourceCode = context.getSourceCode();
  71034. //--------------------------------------------------------------------------
  71035. // Helpers
  71036. //--------------------------------------------------------------------------
  71037. /**
  71038. * Get exact callee name from expression
  71039. * @param {ASTNode} node CallExpression or NewExpression node
  71040. * @returns {string} name
  71041. */
  71042. function extractNameFromExpression(node) {
  71043. var name = "";
  71044. if (node.callee.type === "MemberExpression") {
  71045. var property = node.callee.property;
  71046. if (property.type === "Literal" && typeof property.value === "string") {
  71047. name = property.value;
  71048. } else if (property.type === "Identifier" && !node.callee.computed) {
  71049. name = property.name;
  71050. }
  71051. } else {
  71052. name = node.callee.name;
  71053. }
  71054. return name;
  71055. }
  71056. /**
  71057. * Returns the capitalization state of the string -
  71058. * Whether the first character is uppercase, lowercase, or non-alphabetic
  71059. * @param {string} str String
  71060. * @returns {string} capitalization state: "non-alpha", "lower", or "upper"
  71061. */
  71062. function getCap(str) {
  71063. var firstChar = str.charAt(0);
  71064. var firstCharLower = firstChar.toLowerCase();
  71065. var firstCharUpper = firstChar.toUpperCase();
  71066. if (firstCharLower === firstCharUpper) {
  71067. // char has no uppercase variant, so it's non-alphabetic
  71068. return "non-alpha";
  71069. }
  71070. if (firstChar === firstCharLower) {
  71071. return "lower";
  71072. }
  71073. return "upper";
  71074. }
  71075. /**
  71076. * Check if capitalization is allowed for a CallExpression
  71077. * @param {Object} allowedMap Object mapping calleeName to a Boolean
  71078. * @param {ASTNode} node CallExpression node
  71079. * @param {string} calleeName Capitalized callee name from a CallExpression
  71080. * @param {Object} pattern RegExp object from options pattern
  71081. * @returns {boolean} Returns true if the callee may be capitalized
  71082. */
  71083. function isCapAllowed(allowedMap, node, calleeName, pattern) {
  71084. var sourceText = sourceCode.getText(node.callee);
  71085. if (allowedMap[calleeName] || allowedMap[sourceText]) {
  71086. return true;
  71087. }
  71088. if (pattern && pattern.test(sourceText)) {
  71089. return true;
  71090. }
  71091. if (calleeName === "UTC" && node.callee.type === "MemberExpression") {
  71092. // allow if callee is Date.UTC
  71093. return node.callee.object.type === "Identifier" && node.callee.object.name === "Date";
  71094. }
  71095. return skipProperties && node.callee.type === "MemberExpression";
  71096. }
  71097. /**
  71098. * Reports the given message for the given node. The location will be the start of the property or the callee.
  71099. * @param {ASTNode} node CallExpression or NewExpression node.
  71100. * @param {string} message The message to report.
  71101. * @returns {void}
  71102. */
  71103. function report(node, message) {
  71104. var callee = node.callee;
  71105. if (callee.type === "MemberExpression") {
  71106. callee = callee.property;
  71107. }
  71108. context.report({ node: node, loc: callee.loc.start, message: message });
  71109. }
  71110. //--------------------------------------------------------------------------
  71111. // Public
  71112. //--------------------------------------------------------------------------
  71113. if (config.newIsCap) {
  71114. listeners.NewExpression = function (node) {
  71115. var constructorName = extractNameFromExpression(node);
  71116. if (constructorName) {
  71117. var capitalization = getCap(constructorName);
  71118. var isAllowed = capitalization !== "lower" || isCapAllowed(newIsCapExceptions, node, constructorName, newIsCapExceptionPattern);
  71119. if (!isAllowed) {
  71120. report(node, "A constructor name should not start with a lowercase letter.");
  71121. }
  71122. }
  71123. };
  71124. }
  71125. if (config.capIsNew) {
  71126. listeners.CallExpression = function (node) {
  71127. var calleeName = extractNameFromExpression(node);
  71128. if (calleeName) {
  71129. var capitalization = getCap(calleeName);
  71130. var isAllowed = capitalization !== "upper" || isCapAllowed(capIsNewExceptions, node, calleeName, capIsNewExceptionPattern);
  71131. if (!isAllowed) {
  71132. report(node, "A function with a name starting with an uppercase letter should only be used as a constructor.");
  71133. }
  71134. }
  71135. };
  71136. }
  71137. return listeners;
  71138. }
  71139. };
  71140. },{}],192:[function(require,module,exports){
  71141. /**
  71142. * @fileoverview Rule to flag when using constructor without parentheses
  71143. * @author Ilya Volodin
  71144. */
  71145. "use strict";
  71146. //------------------------------------------------------------------------------
  71147. // Requirements
  71148. //------------------------------------------------------------------------------
  71149. var astUtils = require("../util/ast-utils");
  71150. //------------------------------------------------------------------------------
  71151. // Helpers
  71152. //------------------------------------------------------------------------------
  71153. //------------------------------------------------------------------------------
  71154. // Rule Definition
  71155. //------------------------------------------------------------------------------
  71156. module.exports = {
  71157. meta: {
  71158. type: "layout",
  71159. docs: {
  71160. description: "require parentheses when invoking a constructor with no arguments",
  71161. category: "Stylistic Issues",
  71162. recommended: false,
  71163. url: "https://eslint.org/docs/rules/new-parens"
  71164. },
  71165. schema: [],
  71166. fixable: "code"
  71167. },
  71168. create: function create(context) {
  71169. var sourceCode = context.getSourceCode();
  71170. return {
  71171. NewExpression: function NewExpression(node) {
  71172. if (node.arguments.length !== 0) {
  71173. return; // shortcut: if there are arguments, there have to be parens
  71174. }
  71175. var lastToken = sourceCode.getLastToken(node);
  71176. var hasLastParen = lastToken && astUtils.isClosingParenToken(lastToken);
  71177. var hasParens = hasLastParen && astUtils.isOpeningParenToken(sourceCode.getTokenBefore(lastToken));
  71178. if (!hasParens) {
  71179. context.report({
  71180. node: node,
  71181. message: "Missing '()' invoking a constructor.",
  71182. fix: function fix(fixer) {
  71183. return fixer.insertTextAfter(node, "()");
  71184. }
  71185. });
  71186. }
  71187. }
  71188. };
  71189. }
  71190. };
  71191. },{"../util/ast-utils":405}],193:[function(require,module,exports){
  71192. /**
  71193. * @fileoverview Rule to check empty newline after "var" statement
  71194. * @author Gopal Venkatesan
  71195. * @deprecated
  71196. */
  71197. "use strict";
  71198. //------------------------------------------------------------------------------
  71199. // Requirements
  71200. //------------------------------------------------------------------------------
  71201. var astUtils = require("../util/ast-utils");
  71202. //------------------------------------------------------------------------------
  71203. // Rule Definition
  71204. //------------------------------------------------------------------------------
  71205. module.exports = {
  71206. meta: {
  71207. type: "layout",
  71208. docs: {
  71209. description: "require or disallow an empty line after variable declarations",
  71210. category: "Stylistic Issues",
  71211. recommended: false,
  71212. url: "https://eslint.org/docs/rules/newline-after-var"
  71213. },
  71214. schema: [{
  71215. enum: ["never", "always"]
  71216. }],
  71217. fixable: "whitespace",
  71218. deprecated: true,
  71219. replacedBy: ["padding-line-between-statements"]
  71220. },
  71221. create: function create(context) {
  71222. var ALWAYS_MESSAGE = "Expected blank line after variable declarations.",
  71223. NEVER_MESSAGE = "Unexpected blank line after variable declarations.";
  71224. var sourceCode = context.getSourceCode();
  71225. // Default `mode` to "always".
  71226. var mode = context.options[0] === "never" ? "never" : "always";
  71227. // Cache starting and ending line numbers of comments for faster lookup
  71228. var commentEndLine = sourceCode.getAllComments().reduce(function (result, token) {
  71229. result[token.loc.start.line] = token.loc.end.line;
  71230. return result;
  71231. }, {});
  71232. //--------------------------------------------------------------------------
  71233. // Helpers
  71234. //--------------------------------------------------------------------------
  71235. /**
  71236. * Gets a token from the given node to compare line to the next statement.
  71237. *
  71238. * In general, the token is the last token of the node. However, the token is the second last token if the following conditions satisfy.
  71239. *
  71240. * - The last token is semicolon.
  71241. * - The semicolon is on a different line from the previous token of the semicolon.
  71242. *
  71243. * This behavior would address semicolon-less style code. e.g.:
  71244. *
  71245. * var foo = 1
  71246. *
  71247. * ;(a || b).doSomething()
  71248. *
  71249. * @param {ASTNode} node - The node to get.
  71250. * @returns {Token} The token to compare line to the next statement.
  71251. */
  71252. function getLastToken(node) {
  71253. var lastToken = sourceCode.getLastToken(node);
  71254. if (lastToken.type === "Punctuator" && lastToken.value === ";") {
  71255. var prevToken = sourceCode.getTokenBefore(lastToken);
  71256. if (prevToken.loc.end.line !== lastToken.loc.start.line) {
  71257. return prevToken;
  71258. }
  71259. }
  71260. return lastToken;
  71261. }
  71262. /**
  71263. * Determine if provided keyword is a variable declaration
  71264. * @private
  71265. * @param {string} keyword - keyword to test
  71266. * @returns {boolean} True if `keyword` is a type of var
  71267. */
  71268. function isVar(keyword) {
  71269. return keyword === "var" || keyword === "let" || keyword === "const";
  71270. }
  71271. /**
  71272. * Determine if provided keyword is a variant of for specifiers
  71273. * @private
  71274. * @param {string} keyword - keyword to test
  71275. * @returns {boolean} True if `keyword` is a variant of for specifier
  71276. */
  71277. function isForTypeSpecifier(keyword) {
  71278. return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
  71279. }
  71280. /**
  71281. * Determine if provided keyword is an export specifiers
  71282. * @private
  71283. * @param {string} nodeType - nodeType to test
  71284. * @returns {boolean} True if `nodeType` is an export specifier
  71285. */
  71286. function isExportSpecifier(nodeType) {
  71287. return nodeType === "ExportNamedDeclaration" || nodeType === "ExportSpecifier" || nodeType === "ExportDefaultDeclaration" || nodeType === "ExportAllDeclaration";
  71288. }
  71289. /**
  71290. * Determine if provided node is the last of their parent block.
  71291. * @private
  71292. * @param {ASTNode} node - node to test
  71293. * @returns {boolean} True if `node` is last of their parent block.
  71294. */
  71295. function isLastNode(node) {
  71296. var token = sourceCode.getTokenAfter(node);
  71297. return !token || token.type === "Punctuator" && token.value === "}";
  71298. }
  71299. /**
  71300. * Gets the last line of a group of consecutive comments
  71301. * @param {number} commentStartLine The starting line of the group
  71302. * @returns {number} The number of the last comment line of the group
  71303. */
  71304. function getLastCommentLineOfBlock(commentStartLine) {
  71305. var currentCommentEnd = commentEndLine[commentStartLine];
  71306. return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd;
  71307. }
  71308. /**
  71309. * Determine if a token starts more than one line after a comment ends
  71310. * @param {token} token The token being checked
  71311. * @param {integer} commentStartLine The line number on which the comment starts
  71312. * @returns {boolean} True if `token` does not start immediately after a comment
  71313. */
  71314. function hasBlankLineAfterComment(token, commentStartLine) {
  71315. return token.loc.start.line > getLastCommentLineOfBlock(commentStartLine) + 1;
  71316. }
  71317. /**
  71318. * Checks that a blank line exists after a variable declaration when mode is
  71319. * set to "always", or checks that there is no blank line when mode is set
  71320. * to "never"
  71321. * @private
  71322. * @param {ASTNode} node - `VariableDeclaration` node to test
  71323. * @returns {void}
  71324. */
  71325. function checkForBlankLine(node) {
  71326. /*
  71327. * lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will
  71328. * sometimes be second-last if there is a semicolon on a different line.
  71329. */
  71330. var lastToken = getLastToken(node),
  71331. /*
  71332. * If lastToken is the last token of the node, nextToken should be the token after the node. Otherwise, nextToken
  71333. * is the last token of the node.
  71334. */
  71335. nextToken = lastToken === sourceCode.getLastToken(node) ? sourceCode.getTokenAfter(node) : sourceCode.getLastToken(node),
  71336. nextLineNum = lastToken.loc.end.line + 1;
  71337. // Ignore if there is no following statement
  71338. if (!nextToken) {
  71339. return;
  71340. }
  71341. // Ignore if parent of node is a for variant
  71342. if (isForTypeSpecifier(node.parent.type)) {
  71343. return;
  71344. }
  71345. // Ignore if parent of node is an export specifier
  71346. if (isExportSpecifier(node.parent.type)) {
  71347. return;
  71348. }
  71349. /*
  71350. * Some coding styles use multiple `var` statements, so do nothing if
  71351. * the next token is a `var` statement.
  71352. */
  71353. if (nextToken.type === "Keyword" && isVar(nextToken.value)) {
  71354. return;
  71355. }
  71356. // Ignore if it is last statement in a block
  71357. if (isLastNode(node)) {
  71358. return;
  71359. }
  71360. // Next statement is not a `var`...
  71361. var noNextLineToken = nextToken.loc.start.line > nextLineNum;
  71362. var hasNextLineComment = typeof commentEndLine[nextLineNum] !== "undefined";
  71363. if (mode === "never" && noNextLineToken && !hasNextLineComment) {
  71364. context.report({
  71365. node: node,
  71366. message: NEVER_MESSAGE,
  71367. data: { identifier: node.name },
  71368. fix: function fix(fixer) {
  71369. var linesBetween = sourceCode.getText().slice(lastToken.range[1], nextToken.range[0]).split(astUtils.LINEBREAK_MATCHER);
  71370. return fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], linesBetween.slice(0, -1).join("") + "\n" + linesBetween[linesBetween.length - 1]);
  71371. }
  71372. });
  71373. }
  71374. // Token on the next line, or comment without blank line
  71375. if (mode === "always" && (!noNextLineToken || hasNextLineComment && !hasBlankLineAfterComment(nextToken, nextLineNum))) {
  71376. context.report({
  71377. node: node,
  71378. message: ALWAYS_MESSAGE,
  71379. data: { identifier: node.name },
  71380. fix: function fix(fixer) {
  71381. if ((noNextLineToken ? getLastCommentLineOfBlock(nextLineNum) : lastToken.loc.end.line) === nextToken.loc.start.line) {
  71382. return fixer.insertTextBefore(nextToken, "\n\n");
  71383. }
  71384. return fixer.insertTextBeforeRange([nextToken.range[0] - nextToken.loc.start.column, nextToken.range[1]], "\n");
  71385. }
  71386. });
  71387. }
  71388. }
  71389. //--------------------------------------------------------------------------
  71390. // Public
  71391. //--------------------------------------------------------------------------
  71392. return {
  71393. VariableDeclaration: checkForBlankLine
  71394. };
  71395. }
  71396. };
  71397. },{"../util/ast-utils":405}],194:[function(require,module,exports){
  71398. /**
  71399. * @fileoverview Rule to require newlines before `return` statement
  71400. * @author Kai Cataldo
  71401. * @deprecated
  71402. */
  71403. "use strict";
  71404. //------------------------------------------------------------------------------
  71405. // Rule Definition
  71406. //------------------------------------------------------------------------------
  71407. module.exports = {
  71408. meta: {
  71409. type: "layout",
  71410. docs: {
  71411. description: "require an empty line before `return` statements",
  71412. category: "Stylistic Issues",
  71413. recommended: false,
  71414. url: "https://eslint.org/docs/rules/newline-before-return"
  71415. },
  71416. fixable: "whitespace",
  71417. schema: [],
  71418. deprecated: true,
  71419. replacedBy: ["padding-line-between-statements"]
  71420. },
  71421. create: function create(context) {
  71422. var sourceCode = context.getSourceCode();
  71423. //--------------------------------------------------------------------------
  71424. // Helpers
  71425. //--------------------------------------------------------------------------
  71426. /**
  71427. * Tests whether node is preceded by supplied tokens
  71428. * @param {ASTNode} node - node to check
  71429. * @param {Array} testTokens - array of tokens to test against
  71430. * @returns {boolean} Whether or not the node is preceded by one of the supplied tokens
  71431. * @private
  71432. */
  71433. function isPrecededByTokens(node, testTokens) {
  71434. var tokenBefore = sourceCode.getTokenBefore(node);
  71435. return testTokens.some(function (token) {
  71436. return tokenBefore.value === token;
  71437. });
  71438. }
  71439. /**
  71440. * Checks whether node is the first node after statement or in block
  71441. * @param {ASTNode} node - node to check
  71442. * @returns {boolean} Whether or not the node is the first node after statement or in block
  71443. * @private
  71444. */
  71445. function isFirstNode(node) {
  71446. var parentType = node.parent.type;
  71447. if (node.parent.body) {
  71448. return Array.isArray(node.parent.body) ? node.parent.body[0] === node : node.parent.body === node;
  71449. }
  71450. if (parentType === "IfStatement") {
  71451. return isPrecededByTokens(node, ["else", ")"]);
  71452. }
  71453. if (parentType === "DoWhileStatement") {
  71454. return isPrecededByTokens(node, ["do"]);
  71455. }
  71456. if (parentType === "SwitchCase") {
  71457. return isPrecededByTokens(node, [":"]);
  71458. }
  71459. return isPrecededByTokens(node, [")"]);
  71460. }
  71461. /**
  71462. * Returns the number of lines of comments that precede the node
  71463. * @param {ASTNode} node - node to check for overlapping comments
  71464. * @param {number} lineNumTokenBefore - line number of previous token, to check for overlapping comments
  71465. * @returns {number} Number of lines of comments that precede the node
  71466. * @private
  71467. */
  71468. function calcCommentLines(node, lineNumTokenBefore) {
  71469. var comments = sourceCode.getCommentsBefore(node);
  71470. var numLinesComments = 0;
  71471. if (!comments.length) {
  71472. return numLinesComments;
  71473. }
  71474. comments.forEach(function (comment) {
  71475. numLinesComments++;
  71476. if (comment.type === "Block") {
  71477. numLinesComments += comment.loc.end.line - comment.loc.start.line;
  71478. }
  71479. // avoid counting lines with inline comments twice
  71480. if (comment.loc.start.line === lineNumTokenBefore) {
  71481. numLinesComments--;
  71482. }
  71483. if (comment.loc.end.line === node.loc.start.line) {
  71484. numLinesComments--;
  71485. }
  71486. });
  71487. return numLinesComments;
  71488. }
  71489. /**
  71490. * Returns the line number of the token before the node that is passed in as an argument
  71491. * @param {ASTNode} node - The node to use as the start of the calculation
  71492. * @returns {number} Line number of the token before `node`
  71493. * @private
  71494. */
  71495. function getLineNumberOfTokenBefore(node) {
  71496. var tokenBefore = sourceCode.getTokenBefore(node);
  71497. var lineNumTokenBefore = void 0;
  71498. /**
  71499. * Global return (at the beginning of a script) is a special case.
  71500. * If there is no token before `return`, then we expect no line
  71501. * break before the return. Comments are allowed to occupy lines
  71502. * before the global return, just no blank lines.
  71503. * Setting lineNumTokenBefore to zero in that case results in the
  71504. * desired behavior.
  71505. */
  71506. if (tokenBefore) {
  71507. lineNumTokenBefore = tokenBefore.loc.end.line;
  71508. } else {
  71509. lineNumTokenBefore = 0; // global return at beginning of script
  71510. }
  71511. return lineNumTokenBefore;
  71512. }
  71513. /**
  71514. * Checks whether node is preceded by a newline
  71515. * @param {ASTNode} node - node to check
  71516. * @returns {boolean} Whether or not the node is preceded by a newline
  71517. * @private
  71518. */
  71519. function hasNewlineBefore(node) {
  71520. var lineNumNode = node.loc.start.line;
  71521. var lineNumTokenBefore = getLineNumberOfTokenBefore(node);
  71522. var commentLines = calcCommentLines(node, lineNumTokenBefore);
  71523. return lineNumNode - lineNumTokenBefore - commentLines > 1;
  71524. }
  71525. /**
  71526. * Checks whether it is safe to apply a fix to a given return statement.
  71527. *
  71528. * The fix is not considered safe if the given return statement has leading comments,
  71529. * as we cannot safely determine if the newline should be added before or after the comments.
  71530. * For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211
  71531. *
  71532. * @param {ASTNode} node - The return statement node to check.
  71533. * @returns {boolean} `true` if it can fix the node.
  71534. * @private
  71535. */
  71536. function canFix(node) {
  71537. var leadingComments = sourceCode.getCommentsBefore(node);
  71538. var lastLeadingComment = leadingComments[leadingComments.length - 1];
  71539. var tokenBefore = sourceCode.getTokenBefore(node);
  71540. if (leadingComments.length === 0) {
  71541. return true;
  71542. }
  71543. /*
  71544. * if the last leading comment ends in the same line as the previous token and
  71545. * does not share a line with the `return` node, we can consider it safe to fix.
  71546. * Example:
  71547. * function a() {
  71548. * var b; //comment
  71549. * return;
  71550. * }
  71551. */
  71552. if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line && lastLeadingComment.loc.end.line !== node.loc.start.line) {
  71553. return true;
  71554. }
  71555. return false;
  71556. }
  71557. //--------------------------------------------------------------------------
  71558. // Public
  71559. //--------------------------------------------------------------------------
  71560. return {
  71561. ReturnStatement: function ReturnStatement(node) {
  71562. if (!isFirstNode(node) && !hasNewlineBefore(node)) {
  71563. context.report({
  71564. node: node,
  71565. message: "Expected newline before return statement.",
  71566. fix: function fix(fixer) {
  71567. if (canFix(node)) {
  71568. var tokenBefore = sourceCode.getTokenBefore(node);
  71569. var newlines = node.loc.start.line === tokenBefore.loc.end.line ? "\n\n" : "\n";
  71570. return fixer.insertTextBefore(node, newlines);
  71571. }
  71572. return null;
  71573. }
  71574. });
  71575. }
  71576. }
  71577. };
  71578. }
  71579. };
  71580. },{}],195:[function(require,module,exports){
  71581. /**
  71582. * @fileoverview Rule to ensure newline per method call when chaining calls
  71583. * @author Rajendra Patil
  71584. * @author Burak Yigit Kaya
  71585. */
  71586. "use strict";
  71587. var astUtils = require("../util/ast-utils");
  71588. //------------------------------------------------------------------------------
  71589. // Rule Definition
  71590. //------------------------------------------------------------------------------
  71591. module.exports = {
  71592. meta: {
  71593. type: "layout",
  71594. docs: {
  71595. description: "require a newline after each call in a method chain",
  71596. category: "Stylistic Issues",
  71597. recommended: false,
  71598. url: "https://eslint.org/docs/rules/newline-per-chained-call"
  71599. },
  71600. fixable: "whitespace",
  71601. schema: [{
  71602. type: "object",
  71603. properties: {
  71604. ignoreChainWithDepth: {
  71605. type: "integer",
  71606. minimum: 1,
  71607. maximum: 10
  71608. }
  71609. },
  71610. additionalProperties: false
  71611. }]
  71612. },
  71613. create: function create(context) {
  71614. var options = context.options[0] || {},
  71615. ignoreChainWithDepth = options.ignoreChainWithDepth || 2;
  71616. var sourceCode = context.getSourceCode();
  71617. /**
  71618. * Get the prefix of a given MemberExpression node.
  71619. * If the MemberExpression node is a computed value it returns a
  71620. * left bracket. If not it returns a period.
  71621. *
  71622. * @param {ASTNode} node - A MemberExpression node to get
  71623. * @returns {string} The prefix of the node.
  71624. */
  71625. function getPrefix(node) {
  71626. return node.computed ? "[" : ".";
  71627. }
  71628. /**
  71629. * Gets the property text of a given MemberExpression node.
  71630. * If the text is multiline, this returns only the first line.
  71631. *
  71632. * @param {ASTNode} node - A MemberExpression node to get.
  71633. * @returns {string} The property text of the node.
  71634. */
  71635. function getPropertyText(node) {
  71636. var prefix = getPrefix(node);
  71637. var lines = sourceCode.getText(node.property).split(astUtils.LINEBREAK_MATCHER);
  71638. var suffix = node.computed && lines.length === 1 ? "]" : "";
  71639. return prefix + lines[0] + suffix;
  71640. }
  71641. return {
  71642. "CallExpression:exit": function CallExpressionExit(node) {
  71643. if (!node.callee || node.callee.type !== "MemberExpression") {
  71644. return;
  71645. }
  71646. var callee = node.callee;
  71647. var parent = callee.object;
  71648. var depth = 1;
  71649. while (parent && parent.callee) {
  71650. depth += 1;
  71651. parent = parent.callee.object;
  71652. }
  71653. if (depth > ignoreChainWithDepth && astUtils.isTokenOnSameLine(callee.object, callee.property)) {
  71654. context.report({
  71655. node: callee.property,
  71656. loc: callee.property.loc.start,
  71657. message: "Expected line break before `{{callee}}`.",
  71658. data: {
  71659. callee: getPropertyText(callee)
  71660. },
  71661. fix: function fix(fixer) {
  71662. var firstTokenAfterObject = sourceCode.getTokenAfter(callee.object, astUtils.isNotClosingParenToken);
  71663. return fixer.insertTextBefore(firstTokenAfterObject, "\n");
  71664. }
  71665. });
  71666. }
  71667. }
  71668. };
  71669. }
  71670. };
  71671. },{"../util/ast-utils":405}],196:[function(require,module,exports){
  71672. /**
  71673. * @fileoverview Rule to flag use of alert, confirm, prompt
  71674. * @author Nicholas C. Zakas
  71675. */
  71676. "use strict";
  71677. //------------------------------------------------------------------------------
  71678. // Requirements
  71679. //------------------------------------------------------------------------------
  71680. var getPropertyName = require("../util/ast-utils").getStaticPropertyName;
  71681. //------------------------------------------------------------------------------
  71682. // Helpers
  71683. //------------------------------------------------------------------------------
  71684. /**
  71685. * Checks if the given name is a prohibited identifier.
  71686. * @param {string} name The name to check
  71687. * @returns {boolean} Whether or not the name is prohibited.
  71688. */
  71689. function isProhibitedIdentifier(name) {
  71690. return (/^(alert|confirm|prompt)$/.test(name)
  71691. );
  71692. }
  71693. /**
  71694. * Finds the eslint-scope reference in the given scope.
  71695. * @param {Object} scope The scope to search.
  71696. * @param {ASTNode} node The identifier node.
  71697. * @returns {Reference|null} Returns the found reference or null if none were found.
  71698. */
  71699. function findReference(scope, node) {
  71700. var references = scope.references.filter(function (reference) {
  71701. return reference.identifier.range[0] === node.range[0] && reference.identifier.range[1] === node.range[1];
  71702. });
  71703. if (references.length === 1) {
  71704. return references[0];
  71705. }
  71706. return null;
  71707. }
  71708. /**
  71709. * Checks if the given identifier node is shadowed in the given scope.
  71710. * @param {Object} scope The current scope.
  71711. * @param {string} node The identifier node to check
  71712. * @returns {boolean} Whether or not the name is shadowed.
  71713. */
  71714. function isShadowed(scope, node) {
  71715. var reference = findReference(scope, node);
  71716. return reference && reference.resolved && reference.resolved.defs.length > 0;
  71717. }
  71718. /**
  71719. * Checks if the given identifier node is a ThisExpression in the global scope or the global window property.
  71720. * @param {Object} scope The current scope.
  71721. * @param {string} node The identifier node to check
  71722. * @returns {boolean} Whether or not the node is a reference to the global object.
  71723. */
  71724. function isGlobalThisReferenceOrGlobalWindow(scope, node) {
  71725. if (scope.type === "global" && node.type === "ThisExpression") {
  71726. return true;
  71727. }
  71728. if (node.name === "window") {
  71729. return !isShadowed(scope, node);
  71730. }
  71731. return false;
  71732. }
  71733. //------------------------------------------------------------------------------
  71734. // Rule Definition
  71735. //------------------------------------------------------------------------------
  71736. module.exports = {
  71737. meta: {
  71738. type: "suggestion",
  71739. docs: {
  71740. description: "disallow the use of `alert`, `confirm`, and `prompt`",
  71741. category: "Best Practices",
  71742. recommended: false,
  71743. url: "https://eslint.org/docs/rules/no-alert"
  71744. },
  71745. schema: [],
  71746. messages: {
  71747. unexpected: "Unexpected {{name}}."
  71748. }
  71749. },
  71750. create: function create(context) {
  71751. return {
  71752. CallExpression: function CallExpression(node) {
  71753. var callee = node.callee,
  71754. currentScope = context.getScope();
  71755. // without window.
  71756. if (callee.type === "Identifier") {
  71757. var name = callee.name;
  71758. if (!isShadowed(currentScope, callee) && isProhibitedIdentifier(callee.name)) {
  71759. context.report({
  71760. node: node,
  71761. messageId: "unexpected",
  71762. data: { name: name }
  71763. });
  71764. }
  71765. } else if (callee.type === "MemberExpression" && isGlobalThisReferenceOrGlobalWindow(currentScope, callee.object)) {
  71766. var _name = getPropertyName(callee);
  71767. if (isProhibitedIdentifier(_name)) {
  71768. context.report({
  71769. node: node,
  71770. messageId: "unexpected",
  71771. data: { name: _name }
  71772. });
  71773. }
  71774. }
  71775. }
  71776. };
  71777. }
  71778. };
  71779. },{"../util/ast-utils":405}],197:[function(require,module,exports){
  71780. /**
  71781. * @fileoverview Disallow construction of dense arrays using the Array constructor
  71782. * @author Matt DuVall <http://www.mattduvall.com/>
  71783. */
  71784. "use strict";
  71785. //------------------------------------------------------------------------------
  71786. // Rule Definition
  71787. //------------------------------------------------------------------------------
  71788. module.exports = {
  71789. meta: {
  71790. type: "suggestion",
  71791. docs: {
  71792. description: "disallow `Array` constructors",
  71793. category: "Stylistic Issues",
  71794. recommended: false,
  71795. url: "https://eslint.org/docs/rules/no-array-constructor"
  71796. },
  71797. schema: [],
  71798. messages: {
  71799. preferLiteral: "The array literal notation [] is preferable."
  71800. }
  71801. },
  71802. create: function create(context) {
  71803. /**
  71804. * Disallow construction of dense arrays using the Array constructor
  71805. * @param {ASTNode} node node to evaluate
  71806. * @returns {void}
  71807. * @private
  71808. */
  71809. function check(node) {
  71810. if (node.arguments.length !== 1 && node.callee.type === "Identifier" && node.callee.name === "Array") {
  71811. context.report({ node: node, messageId: "preferLiteral" });
  71812. }
  71813. }
  71814. return {
  71815. CallExpression: check,
  71816. NewExpression: check
  71817. };
  71818. }
  71819. };
  71820. },{}],198:[function(require,module,exports){
  71821. /**
  71822. * @fileoverview disallow using an async function as a Promise executor
  71823. * @author Teddy Katz
  71824. */
  71825. "use strict";
  71826. //------------------------------------------------------------------------------
  71827. // Rule Definition
  71828. //------------------------------------------------------------------------------
  71829. module.exports = {
  71830. meta: {
  71831. type: "problem",
  71832. docs: {
  71833. description: "disallow using an async function as a Promise executor",
  71834. category: "Possible Errors",
  71835. recommended: false,
  71836. url: "https://eslint.org/docs/rules/no-async-promise-executor"
  71837. },
  71838. fixable: null,
  71839. schema: []
  71840. },
  71841. create: function create(context) {
  71842. return {
  71843. "NewExpression[callee.name='Promise'][arguments.0.async=true]": function NewExpressionCalleeNamePromiseArguments0AsyncTrue(node) {
  71844. context.report({
  71845. node: context.getSourceCode().getFirstToken(node.arguments[0], function (token) {
  71846. return token.value === "async";
  71847. }),
  71848. message: "Promise executor functions should not be async."
  71849. });
  71850. }
  71851. };
  71852. }
  71853. };
  71854. },{}],199:[function(require,module,exports){
  71855. /**
  71856. * @fileoverview Rule to disallow uses of await inside of loops.
  71857. * @author Nat Mote (nmote)
  71858. */
  71859. "use strict";
  71860. /**
  71861. * Check whether it should stop traversing ancestors at the given node.
  71862. * @param {ASTNode} node A node to check.
  71863. * @returns {boolean} `true` if it should stop traversing.
  71864. */
  71865. function isBoundary(node) {
  71866. var t = node.type;
  71867. return t === "FunctionDeclaration" || t === "FunctionExpression" || t === "ArrowFunctionExpression" ||
  71868. /*
  71869. * Don't report the await expressions on for-await-of loop since it's
  71870. * asynchronous iteration intentionally.
  71871. */
  71872. t === "ForOfStatement" && node.await === true;
  71873. }
  71874. /**
  71875. * Check whether the given node is in loop.
  71876. * @param {ASTNode} node A node to check.
  71877. * @param {ASTNode} parent A parent node to check.
  71878. * @returns {boolean} `true` if the node is in loop.
  71879. */
  71880. function isLooped(node, parent) {
  71881. switch (parent.type) {
  71882. case "ForStatement":
  71883. return node === parent.test || node === parent.update || node === parent.body;
  71884. case "ForOfStatement":
  71885. case "ForInStatement":
  71886. return node === parent.body;
  71887. case "WhileStatement":
  71888. case "DoWhileStatement":
  71889. return node === parent.test || node === parent.body;
  71890. default:
  71891. return false;
  71892. }
  71893. }
  71894. module.exports = {
  71895. meta: {
  71896. type: "problem",
  71897. docs: {
  71898. description: "disallow `await` inside of loops",
  71899. category: "Possible Errors",
  71900. recommended: false,
  71901. url: "https://eslint.org/docs/rules/no-await-in-loop"
  71902. },
  71903. schema: [],
  71904. messages: {
  71905. unexpectedAwait: "Unexpected `await` inside a loop."
  71906. }
  71907. },
  71908. create: function create(context) {
  71909. /**
  71910. * Validate an await expression.
  71911. * @param {ASTNode} awaitNode An AwaitExpression or ForOfStatement node to validate.
  71912. * @returns {void}
  71913. */
  71914. function validate(awaitNode) {
  71915. if (awaitNode.type === "ForOfStatement" && !awaitNode.await) {
  71916. return;
  71917. }
  71918. var node = awaitNode;
  71919. var parent = node.parent;
  71920. while (parent && !isBoundary(parent)) {
  71921. if (isLooped(node, parent)) {
  71922. context.report({
  71923. node: awaitNode,
  71924. messageId: "unexpectedAwait"
  71925. });
  71926. return;
  71927. }
  71928. node = parent;
  71929. parent = parent.parent;
  71930. }
  71931. }
  71932. return {
  71933. AwaitExpression: validate,
  71934. ForOfStatement: validate
  71935. };
  71936. }
  71937. };
  71938. },{}],200:[function(require,module,exports){
  71939. /**
  71940. * @fileoverview Rule to flag bitwise identifiers
  71941. * @author Nicholas C. Zakas
  71942. */
  71943. "use strict";
  71944. /*
  71945. *
  71946. * Set of bitwise operators.
  71947. *
  71948. */
  71949. var BITWISE_OPERATORS = ["^", "|", "&", "<<", ">>", ">>>", "^=", "|=", "&=", "<<=", ">>=", ">>>=", "~"];
  71950. //------------------------------------------------------------------------------
  71951. // Rule Definition
  71952. //------------------------------------------------------------------------------
  71953. module.exports = {
  71954. meta: {
  71955. type: "suggestion",
  71956. docs: {
  71957. description: "disallow bitwise operators",
  71958. category: "Stylistic Issues",
  71959. recommended: false,
  71960. url: "https://eslint.org/docs/rules/no-bitwise"
  71961. },
  71962. schema: [{
  71963. type: "object",
  71964. properties: {
  71965. allow: {
  71966. type: "array",
  71967. items: {
  71968. enum: BITWISE_OPERATORS
  71969. },
  71970. uniqueItems: true
  71971. },
  71972. int32Hint: {
  71973. type: "boolean"
  71974. }
  71975. },
  71976. additionalProperties: false
  71977. }],
  71978. messages: {
  71979. unexpected: "Unexpected use of '{{operator}}'."
  71980. }
  71981. },
  71982. create: function create(context) {
  71983. var options = context.options[0] || {};
  71984. var allowed = options.allow || [];
  71985. var int32Hint = options.int32Hint === true;
  71986. /**
  71987. * Reports an unexpected use of a bitwise operator.
  71988. * @param {ASTNode} node Node which contains the bitwise operator.
  71989. * @returns {void}
  71990. */
  71991. function report(node) {
  71992. context.report({ node: node, messageId: "unexpected", data: { operator: node.operator } });
  71993. }
  71994. /**
  71995. * Checks if the given node has a bitwise operator.
  71996. * @param {ASTNode} node The node to check.
  71997. * @returns {boolean} Whether or not the node has a bitwise operator.
  71998. */
  71999. function hasBitwiseOperator(node) {
  72000. return BITWISE_OPERATORS.indexOf(node.operator) !== -1;
  72001. }
  72002. /**
  72003. * Checks if exceptions were provided, e.g. `{ allow: ['~', '|'] }`.
  72004. * @param {ASTNode} node The node to check.
  72005. * @returns {boolean} Whether or not the node has a bitwise operator.
  72006. */
  72007. function allowedOperator(node) {
  72008. return allowed.indexOf(node.operator) !== -1;
  72009. }
  72010. /**
  72011. * Checks if the given bitwise operator is used for integer typecasting, i.e. "|0"
  72012. * @param {ASTNode} node The node to check.
  72013. * @returns {boolean} whether the node is used in integer typecasting.
  72014. */
  72015. function isInt32Hint(node) {
  72016. return int32Hint && node.operator === "|" && node.right && node.right.type === "Literal" && node.right.value === 0;
  72017. }
  72018. /**
  72019. * Report if the given node contains a bitwise operator.
  72020. * @param {ASTNode} node The node to check.
  72021. * @returns {void}
  72022. */
  72023. function checkNodeForBitwiseOperator(node) {
  72024. if (hasBitwiseOperator(node) && !allowedOperator(node) && !isInt32Hint(node)) {
  72025. report(node);
  72026. }
  72027. }
  72028. return {
  72029. AssignmentExpression: checkNodeForBitwiseOperator,
  72030. BinaryExpression: checkNodeForBitwiseOperator,
  72031. UnaryExpression: checkNodeForBitwiseOperator
  72032. };
  72033. }
  72034. };
  72035. },{}],201:[function(require,module,exports){
  72036. /**
  72037. * @fileoverview disallow use of the Buffer() constructor
  72038. * @author Teddy Katz
  72039. */
  72040. "use strict";
  72041. //------------------------------------------------------------------------------
  72042. // Rule Definition
  72043. //------------------------------------------------------------------------------
  72044. module.exports = {
  72045. meta: {
  72046. type: "problem",
  72047. docs: {
  72048. description: "disallow use of the `Buffer()` constructor",
  72049. category: "Node.js and CommonJS",
  72050. recommended: false,
  72051. url: "https://eslint.org/docs/rules/no-buffer-constructor"
  72052. },
  72053. schema: [],
  72054. messages: {
  72055. deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead."
  72056. }
  72057. },
  72058. create: function create(context) {
  72059. //----------------------------------------------------------------------
  72060. // Public
  72061. //----------------------------------------------------------------------
  72062. return {
  72063. "CallExpression[callee.name='Buffer'], NewExpression[callee.name='Buffer']": function CallExpressionCalleeNameBufferNewExpressionCalleeNameBuffer(node) {
  72064. context.report({
  72065. node: node,
  72066. messageId: "deprecated",
  72067. data: { expr: node.type === "CallExpression" ? "Buffer()" : "new Buffer()" }
  72068. });
  72069. }
  72070. };
  72071. }
  72072. };
  72073. },{}],202:[function(require,module,exports){
  72074. /**
  72075. * @fileoverview Rule to flag use of arguments.callee and arguments.caller.
  72076. * @author Nicholas C. Zakas
  72077. */
  72078. "use strict";
  72079. //------------------------------------------------------------------------------
  72080. // Rule Definition
  72081. //------------------------------------------------------------------------------
  72082. module.exports = {
  72083. meta: {
  72084. type: "suggestion",
  72085. docs: {
  72086. description: "disallow the use of `arguments.caller` or `arguments.callee`",
  72087. category: "Best Practices",
  72088. recommended: false,
  72089. url: "https://eslint.org/docs/rules/no-caller"
  72090. },
  72091. schema: [],
  72092. messages: {
  72093. unexpected: "Avoid arguments.{{prop}}."
  72094. }
  72095. },
  72096. create: function create(context) {
  72097. return {
  72098. MemberExpression: function MemberExpression(node) {
  72099. var objectName = node.object.name,
  72100. propertyName = node.property.name;
  72101. if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) {
  72102. context.report({ node: node, messageId: "unexpected", data: { prop: propertyName } });
  72103. }
  72104. }
  72105. };
  72106. }
  72107. };
  72108. },{}],203:[function(require,module,exports){
  72109. /**
  72110. * @fileoverview Rule to flag use of an lexical declarations inside a case clause
  72111. * @author Erik Arvidsson
  72112. */
  72113. "use strict";
  72114. //------------------------------------------------------------------------------
  72115. // Rule Definition
  72116. //------------------------------------------------------------------------------
  72117. module.exports = {
  72118. meta: {
  72119. type: "suggestion",
  72120. docs: {
  72121. description: "disallow lexical declarations in case clauses",
  72122. category: "Best Practices",
  72123. recommended: true,
  72124. url: "https://eslint.org/docs/rules/no-case-declarations"
  72125. },
  72126. schema: [],
  72127. messages: {
  72128. unexpected: "Unexpected lexical declaration in case block."
  72129. }
  72130. },
  72131. create: function create(context) {
  72132. /**
  72133. * Checks whether or not a node is a lexical declaration.
  72134. * @param {ASTNode} node A direct child statement of a switch case.
  72135. * @returns {boolean} Whether or not the node is a lexical declaration.
  72136. */
  72137. function isLexicalDeclaration(node) {
  72138. switch (node.type) {
  72139. case "FunctionDeclaration":
  72140. case "ClassDeclaration":
  72141. return true;
  72142. case "VariableDeclaration":
  72143. return node.kind !== "var";
  72144. default:
  72145. return false;
  72146. }
  72147. }
  72148. return {
  72149. SwitchCase: function SwitchCase(node) {
  72150. for (var i = 0; i < node.consequent.length; i++) {
  72151. var statement = node.consequent[i];
  72152. if (isLexicalDeclaration(statement)) {
  72153. context.report({
  72154. node: statement,
  72155. messageId: "unexpected"
  72156. });
  72157. }
  72158. }
  72159. }
  72160. };
  72161. }
  72162. };
  72163. },{}],204:[function(require,module,exports){
  72164. /**
  72165. * @fileoverview Rule to flag variable leak in CatchClauses in IE 8 and earlier
  72166. * @author Ian Christian Myers
  72167. * @deprecated in ESLint v5.1.0
  72168. */
  72169. "use strict";
  72170. //------------------------------------------------------------------------------
  72171. // Requirements
  72172. //------------------------------------------------------------------------------
  72173. var astUtils = require("../util/ast-utils");
  72174. //------------------------------------------------------------------------------
  72175. // Rule Definition
  72176. //------------------------------------------------------------------------------
  72177. module.exports = {
  72178. meta: {
  72179. type: "suggestion",
  72180. docs: {
  72181. description: "disallow `catch` clause parameters from shadowing variables in the outer scope",
  72182. category: "Variables",
  72183. recommended: false,
  72184. url: "https://eslint.org/docs/rules/no-catch-shadow"
  72185. },
  72186. replacedBy: ["no-shadow"],
  72187. deprecated: true,
  72188. schema: [],
  72189. messages: {
  72190. mutable: "Value of '{{name}}' may be overwritten in IE 8 and earlier."
  72191. }
  72192. },
  72193. create: function create(context) {
  72194. //--------------------------------------------------------------------------
  72195. // Helpers
  72196. //--------------------------------------------------------------------------
  72197. /**
  72198. * Check if the parameters are been shadowed
  72199. * @param {Object} scope current scope
  72200. * @param {string} name parameter name
  72201. * @returns {boolean} True is its been shadowed
  72202. */
  72203. function paramIsShadowing(scope, name) {
  72204. return astUtils.getVariableByName(scope, name) !== null;
  72205. }
  72206. //--------------------------------------------------------------------------
  72207. // Public API
  72208. //--------------------------------------------------------------------------
  72209. return {
  72210. "CatchClause[param!=null]": function CatchClauseParamNull(node) {
  72211. var scope = context.getScope();
  72212. /*
  72213. * When ecmaVersion >= 6, CatchClause creates its own scope
  72214. * so start from one upper scope to exclude the current node
  72215. */
  72216. if (scope.block === node) {
  72217. scope = scope.upper;
  72218. }
  72219. if (paramIsShadowing(scope, node.param.name)) {
  72220. context.report({ node: node, messageId: "mutable", data: { name: node.param.name } });
  72221. }
  72222. }
  72223. };
  72224. }
  72225. };
  72226. },{"../util/ast-utils":405}],205:[function(require,module,exports){
  72227. /**
  72228. * @fileoverview A rule to disallow modifying variables of class declarations
  72229. * @author Toru Nagashima
  72230. */
  72231. "use strict";
  72232. var astUtils = require("../util/ast-utils");
  72233. //------------------------------------------------------------------------------
  72234. // Rule Definition
  72235. //------------------------------------------------------------------------------
  72236. module.exports = {
  72237. meta: {
  72238. type: "problem",
  72239. docs: {
  72240. description: "disallow reassigning class members",
  72241. category: "ECMAScript 6",
  72242. recommended: true,
  72243. url: "https://eslint.org/docs/rules/no-class-assign"
  72244. },
  72245. schema: [],
  72246. messages: {
  72247. class: "'{{name}}' is a class."
  72248. }
  72249. },
  72250. create: function create(context) {
  72251. /**
  72252. * Finds and reports references that are non initializer and writable.
  72253. * @param {Variable} variable - A variable to check.
  72254. * @returns {void}
  72255. */
  72256. function checkVariable(variable) {
  72257. astUtils.getModifyingReferences(variable.references).forEach(function (reference) {
  72258. context.report({ node: reference.identifier, messageId: "class", data: { name: reference.identifier.name } });
  72259. });
  72260. }
  72261. /**
  72262. * Finds and reports references that are non initializer and writable.
  72263. * @param {ASTNode} node - A ClassDeclaration/ClassExpression node to check.
  72264. * @returns {void}
  72265. */
  72266. function checkForClass(node) {
  72267. context.getDeclaredVariables(node).forEach(checkVariable);
  72268. }
  72269. return {
  72270. ClassDeclaration: checkForClass,
  72271. ClassExpression: checkForClass
  72272. };
  72273. }
  72274. };
  72275. },{"../util/ast-utils":405}],206:[function(require,module,exports){
  72276. /**
  72277. * @fileoverview The rule should warn against code that tries to compare against -0.
  72278. * @author Aladdin-ADD <hh_2013@foxmail.com>
  72279. */
  72280. "use strict";
  72281. //------------------------------------------------------------------------------
  72282. // Rule Definition
  72283. //------------------------------------------------------------------------------
  72284. module.exports = {
  72285. meta: {
  72286. type: "problem",
  72287. docs: {
  72288. description: "disallow comparing against -0",
  72289. category: "Possible Errors",
  72290. recommended: true,
  72291. url: "https://eslint.org/docs/rules/no-compare-neg-zero"
  72292. },
  72293. fixable: null,
  72294. schema: [],
  72295. messages: {
  72296. unexpected: "Do not use the '{{operator}}' operator to compare against -0."
  72297. }
  72298. },
  72299. create: function create(context) {
  72300. //--------------------------------------------------------------------------
  72301. // Helpers
  72302. //--------------------------------------------------------------------------
  72303. /**
  72304. * Checks a given node is -0
  72305. *
  72306. * @param {ASTNode} node - A node to check.
  72307. * @returns {boolean} `true` if the node is -0.
  72308. */
  72309. function isNegZero(node) {
  72310. return node.type === "UnaryExpression" && node.operator === "-" && node.argument.type === "Literal" && node.argument.value === 0;
  72311. }
  72312. var OPERATORS_TO_CHECK = new Set([">", ">=", "<", "<=", "==", "===", "!=", "!=="]);
  72313. return {
  72314. BinaryExpression: function BinaryExpression(node) {
  72315. if (OPERATORS_TO_CHECK.has(node.operator)) {
  72316. if (isNegZero(node.left) || isNegZero(node.right)) {
  72317. context.report({
  72318. node: node,
  72319. messageId: "unexpected",
  72320. data: { operator: node.operator }
  72321. });
  72322. }
  72323. }
  72324. }
  72325. };
  72326. }
  72327. };
  72328. },{}],207:[function(require,module,exports){
  72329. /**
  72330. * @fileoverview Rule to flag assignment in a conditional statement's test expression
  72331. * @author Stephen Murray <spmurrayzzz>
  72332. */
  72333. "use strict";
  72334. var astUtils = require("../util/ast-utils");
  72335. var NODE_DESCRIPTIONS = {
  72336. DoWhileStatement: "a 'do...while' statement",
  72337. ForStatement: "a 'for' statement",
  72338. IfStatement: "an 'if' statement",
  72339. WhileStatement: "a 'while' statement"
  72340. };
  72341. //------------------------------------------------------------------------------
  72342. // Rule Definition
  72343. //------------------------------------------------------------------------------
  72344. module.exports = {
  72345. meta: {
  72346. type: "problem",
  72347. docs: {
  72348. description: "disallow assignment operators in conditional expressions",
  72349. category: "Possible Errors",
  72350. recommended: true,
  72351. url: "https://eslint.org/docs/rules/no-cond-assign"
  72352. },
  72353. schema: [{
  72354. enum: ["except-parens", "always"]
  72355. }],
  72356. messages: {
  72357. unexpected: "Unexpected assignment within {{type}}.",
  72358. // must match JSHint's error message
  72359. missing: "Expected a conditional expression and instead saw an assignment."
  72360. }
  72361. },
  72362. create: function create(context) {
  72363. var prohibitAssign = context.options[0] || "except-parens";
  72364. var sourceCode = context.getSourceCode();
  72365. /**
  72366. * Check whether an AST node is the test expression for a conditional statement.
  72367. * @param {!Object} node The node to test.
  72368. * @returns {boolean} `true` if the node is the text expression for a conditional statement; otherwise, `false`.
  72369. */
  72370. function isConditionalTestExpression(node) {
  72371. return node.parent && node.parent.test && node === node.parent.test;
  72372. }
  72373. /**
  72374. * Given an AST node, perform a bottom-up search for the first ancestor that represents a conditional statement.
  72375. * @param {!Object} node The node to use at the start of the search.
  72376. * @returns {?Object} The closest ancestor node that represents a conditional statement.
  72377. */
  72378. function findConditionalAncestor(node) {
  72379. var currentAncestor = node;
  72380. do {
  72381. if (isConditionalTestExpression(currentAncestor)) {
  72382. return currentAncestor.parent;
  72383. }
  72384. } while ((currentAncestor = currentAncestor.parent) && !astUtils.isFunction(currentAncestor));
  72385. return null;
  72386. }
  72387. /**
  72388. * Check whether the code represented by an AST node is enclosed in two sets of parentheses.
  72389. * @param {!Object} node The node to test.
  72390. * @returns {boolean} `true` if the code is enclosed in two sets of parentheses; otherwise, `false`.
  72391. */
  72392. function isParenthesisedTwice(node) {
  72393. var previousToken = sourceCode.getTokenBefore(node, 1),
  72394. nextToken = sourceCode.getTokenAfter(node, 1);
  72395. return astUtils.isParenthesised(sourceCode, node) && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
  72396. }
  72397. /**
  72398. * Check a conditional statement's test expression for top-level assignments that are not enclosed in parentheses.
  72399. * @param {!Object} node The node for the conditional statement.
  72400. * @returns {void}
  72401. */
  72402. function testForAssign(node) {
  72403. if (node.test && node.test.type === "AssignmentExpression" && (node.type === "ForStatement" ? !astUtils.isParenthesised(sourceCode, node.test) : !isParenthesisedTwice(node.test))) {
  72404. context.report({
  72405. node: node,
  72406. loc: node.test.loc.start,
  72407. messageId: "missing"
  72408. });
  72409. }
  72410. }
  72411. /**
  72412. * Check whether an assignment expression is descended from a conditional statement's test expression.
  72413. * @param {!Object} node The node for the assignment expression.
  72414. * @returns {void}
  72415. */
  72416. function testForConditionalAncestor(node) {
  72417. var ancestor = findConditionalAncestor(node);
  72418. if (ancestor) {
  72419. context.report({
  72420. node: ancestor,
  72421. messageId: "unexpected",
  72422. data: {
  72423. type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type
  72424. }
  72425. });
  72426. }
  72427. }
  72428. if (prohibitAssign === "always") {
  72429. return {
  72430. AssignmentExpression: testForConditionalAncestor
  72431. };
  72432. }
  72433. return {
  72434. DoWhileStatement: testForAssign,
  72435. ForStatement: testForAssign,
  72436. IfStatement: testForAssign,
  72437. WhileStatement: testForAssign,
  72438. ConditionalExpression: testForAssign
  72439. };
  72440. }
  72441. };
  72442. },{"../util/ast-utils":405}],208:[function(require,module,exports){
  72443. /**
  72444. * @fileoverview A rule to warn against using arrow functions when they could be
  72445. * confused with comparisions
  72446. * @author Jxck <https://github.com/Jxck>
  72447. */
  72448. "use strict";
  72449. var astUtils = require("../util/ast-utils.js");
  72450. //------------------------------------------------------------------------------
  72451. // Helpers
  72452. //------------------------------------------------------------------------------
  72453. /**
  72454. * Checks whether or not a node is a conditional expression.
  72455. * @param {ASTNode} node - node to test
  72456. * @returns {boolean} `true` if the node is a conditional expression.
  72457. */
  72458. function isConditional(node) {
  72459. return node && node.type === "ConditionalExpression";
  72460. }
  72461. //------------------------------------------------------------------------------
  72462. // Rule Definition
  72463. //------------------------------------------------------------------------------
  72464. module.exports = {
  72465. meta: {
  72466. type: "suggestion",
  72467. docs: {
  72468. description: "disallow arrow functions where they could be confused with comparisons",
  72469. category: "ECMAScript 6",
  72470. recommended: false,
  72471. url: "https://eslint.org/docs/rules/no-confusing-arrow"
  72472. },
  72473. fixable: "code",
  72474. schema: [{
  72475. type: "object",
  72476. properties: {
  72477. allowParens: { type: "boolean" }
  72478. },
  72479. additionalProperties: false
  72480. }],
  72481. messages: {
  72482. confusing: "Arrow function used ambiguously with a conditional expression."
  72483. }
  72484. },
  72485. create: function create(context) {
  72486. var config = context.options[0] || {};
  72487. var sourceCode = context.getSourceCode();
  72488. /**
  72489. * Reports if an arrow function contains an ambiguous conditional.
  72490. * @param {ASTNode} node - A node to check and report.
  72491. * @returns {void}
  72492. */
  72493. function checkArrowFunc(node) {
  72494. var body = node.body;
  72495. if (isConditional(body) && !(config.allowParens && astUtils.isParenthesised(sourceCode, body))) {
  72496. context.report({
  72497. node: node,
  72498. messageId: "confusing",
  72499. fix: function fix(fixer) {
  72500. // if `allowParens` is not set to true dont bother wrapping in parens
  72501. return config.allowParens && fixer.replaceText(node.body, "(" + sourceCode.getText(node.body) + ")");
  72502. }
  72503. });
  72504. }
  72505. }
  72506. return {
  72507. ArrowFunctionExpression: checkArrowFunc
  72508. };
  72509. }
  72510. };
  72511. },{"../util/ast-utils.js":405}],209:[function(require,module,exports){
  72512. /**
  72513. * @fileoverview Rule to flag use of console object
  72514. * @author Nicholas C. Zakas
  72515. */
  72516. "use strict";
  72517. //------------------------------------------------------------------------------
  72518. // Requirements
  72519. //------------------------------------------------------------------------------
  72520. var astUtils = require("../util/ast-utils");
  72521. //------------------------------------------------------------------------------
  72522. // Rule Definition
  72523. //------------------------------------------------------------------------------
  72524. module.exports = {
  72525. meta: {
  72526. type: "suggestion",
  72527. docs: {
  72528. description: "disallow the use of `console`",
  72529. category: "Possible Errors",
  72530. recommended: true,
  72531. url: "https://eslint.org/docs/rules/no-console"
  72532. },
  72533. schema: [{
  72534. type: "object",
  72535. properties: {
  72536. allow: {
  72537. type: "array",
  72538. items: {
  72539. type: "string"
  72540. },
  72541. minItems: 1,
  72542. uniqueItems: true
  72543. }
  72544. },
  72545. additionalProperties: false
  72546. }],
  72547. messages: {
  72548. unexpected: "Unexpected console statement."
  72549. }
  72550. },
  72551. create: function create(context) {
  72552. var options = context.options[0] || {};
  72553. var allowed = options.allow || [];
  72554. /**
  72555. * Checks whether the given reference is 'console' or not.
  72556. *
  72557. * @param {eslint-scope.Reference} reference - The reference to check.
  72558. * @returns {boolean} `true` if the reference is 'console'.
  72559. */
  72560. function isConsole(reference) {
  72561. var id = reference.identifier;
  72562. return id && id.name === "console";
  72563. }
  72564. /**
  72565. * Checks whether the property name of the given MemberExpression node
  72566. * is allowed by options or not.
  72567. *
  72568. * @param {ASTNode} node - The MemberExpression node to check.
  72569. * @returns {boolean} `true` if the property name of the node is allowed.
  72570. */
  72571. function isAllowed(node) {
  72572. var propertyName = astUtils.getStaticPropertyName(node);
  72573. return propertyName && allowed.indexOf(propertyName) !== -1;
  72574. }
  72575. /**
  72576. * Checks whether the given reference is a member access which is not
  72577. * allowed by options or not.
  72578. *
  72579. * @param {eslint-scope.Reference} reference - The reference to check.
  72580. * @returns {boolean} `true` if the reference is a member access which
  72581. * is not allowed by options.
  72582. */
  72583. function isMemberAccessExceptAllowed(reference) {
  72584. var node = reference.identifier;
  72585. var parent = node.parent;
  72586. return parent.type === "MemberExpression" && parent.object === node && !isAllowed(parent);
  72587. }
  72588. /**
  72589. * Reports the given reference as a violation.
  72590. *
  72591. * @param {eslint-scope.Reference} reference - The reference to report.
  72592. * @returns {void}
  72593. */
  72594. function report(reference) {
  72595. var node = reference.identifier.parent;
  72596. context.report({
  72597. node: node,
  72598. loc: node.loc,
  72599. messageId: "unexpected"
  72600. });
  72601. }
  72602. return {
  72603. "Program:exit": function ProgramExit() {
  72604. var scope = context.getScope();
  72605. var consoleVar = astUtils.getVariableByName(scope, "console");
  72606. var shadowed = consoleVar && consoleVar.defs.length > 0;
  72607. /*
  72608. * 'scope.through' includes all references to undefined
  72609. * variables. If the variable 'console' is not defined, it uses
  72610. * 'scope.through'.
  72611. */
  72612. var references = consoleVar ? consoleVar.references : scope.through.filter(isConsole);
  72613. if (!shadowed) {
  72614. references.filter(isMemberAccessExceptAllowed).forEach(report);
  72615. }
  72616. }
  72617. };
  72618. }
  72619. };
  72620. },{"../util/ast-utils":405}],210:[function(require,module,exports){
  72621. /**
  72622. * @fileoverview A rule to disallow modifying variables that are declared using `const`
  72623. * @author Toru Nagashima
  72624. */
  72625. "use strict";
  72626. var astUtils = require("../util/ast-utils");
  72627. //------------------------------------------------------------------------------
  72628. // Rule Definition
  72629. //------------------------------------------------------------------------------
  72630. module.exports = {
  72631. meta: {
  72632. type: "problem",
  72633. docs: {
  72634. description: "disallow reassigning `const` variables",
  72635. category: "ECMAScript 6",
  72636. recommended: true,
  72637. url: "https://eslint.org/docs/rules/no-const-assign"
  72638. },
  72639. schema: [],
  72640. messages: {
  72641. const: "'{{name}}' is constant."
  72642. }
  72643. },
  72644. create: function create(context) {
  72645. /**
  72646. * Finds and reports references that are non initializer and writable.
  72647. * @param {Variable} variable - A variable to check.
  72648. * @returns {void}
  72649. */
  72650. function checkVariable(variable) {
  72651. astUtils.getModifyingReferences(variable.references).forEach(function (reference) {
  72652. context.report({ node: reference.identifier, messageId: "const", data: { name: reference.identifier.name } });
  72653. });
  72654. }
  72655. return {
  72656. VariableDeclaration: function VariableDeclaration(node) {
  72657. if (node.kind === "const") {
  72658. context.getDeclaredVariables(node).forEach(checkVariable);
  72659. }
  72660. }
  72661. };
  72662. }
  72663. };
  72664. },{"../util/ast-utils":405}],211:[function(require,module,exports){
  72665. /**
  72666. * @fileoverview Rule to flag use constant conditions
  72667. * @author Christian Schulz <http://rndm.de>
  72668. */
  72669. "use strict";
  72670. //------------------------------------------------------------------------------
  72671. // Rule Definition
  72672. //------------------------------------------------------------------------------
  72673. module.exports = {
  72674. meta: {
  72675. type: "problem",
  72676. docs: {
  72677. description: "disallow constant expressions in conditions",
  72678. category: "Possible Errors",
  72679. recommended: true,
  72680. url: "https://eslint.org/docs/rules/no-constant-condition"
  72681. },
  72682. schema: [{
  72683. type: "object",
  72684. properties: {
  72685. checkLoops: {
  72686. type: "boolean"
  72687. }
  72688. },
  72689. additionalProperties: false
  72690. }],
  72691. messages: {
  72692. unexpected: "Unexpected constant condition."
  72693. }
  72694. },
  72695. create: function create(context) {
  72696. var options = context.options[0] || {},
  72697. checkLoops = options.checkLoops !== false,
  72698. loopSetStack = [];
  72699. var loopsInCurrentScope = new Set();
  72700. //--------------------------------------------------------------------------
  72701. // Helpers
  72702. //--------------------------------------------------------------------------
  72703. /**
  72704. * Checks if a branch node of LogicalExpression short circuits the whole condition
  72705. * @param {ASTNode} node The branch of main condition which needs to be checked
  72706. * @param {string} operator The operator of the main LogicalExpression.
  72707. * @returns {boolean} true when condition short circuits whole condition
  72708. */
  72709. function isLogicalIdentity(node, operator) {
  72710. switch (node.type) {
  72711. case "Literal":
  72712. return operator === "||" && node.value === true || operator === "&&" && node.value === false;
  72713. case "UnaryExpression":
  72714. return operator === "&&" && node.operator === "void";
  72715. case "LogicalExpression":
  72716. return isLogicalIdentity(node.left, node.operator) || isLogicalIdentity(node.right, node.operator);
  72717. // no default
  72718. }
  72719. return false;
  72720. }
  72721. /**
  72722. * Checks if a node has a constant truthiness value.
  72723. * @param {ASTNode} node The AST node to check.
  72724. * @param {boolean} inBooleanPosition `false` if checking branch of a condition.
  72725. * `true` in all other cases
  72726. * @returns {Bool} true when node's truthiness is constant
  72727. * @private
  72728. */
  72729. function isConstant(node, inBooleanPosition) {
  72730. switch (node.type) {
  72731. case "Literal":
  72732. case "ArrowFunctionExpression":
  72733. case "FunctionExpression":
  72734. case "ObjectExpression":
  72735. case "ArrayExpression":
  72736. return true;
  72737. case "UnaryExpression":
  72738. if (node.operator === "void") {
  72739. return true;
  72740. }
  72741. return node.operator === "typeof" && inBooleanPosition || isConstant(node.argument, true);
  72742. case "BinaryExpression":
  72743. return isConstant(node.left, false) && isConstant(node.right, false) && node.operator !== "in";
  72744. case "LogicalExpression":
  72745. {
  72746. var isLeftConstant = isConstant(node.left, inBooleanPosition);
  72747. var isRightConstant = isConstant(node.right, inBooleanPosition);
  72748. var isLeftShortCircuit = isLeftConstant && isLogicalIdentity(node.left, node.operator);
  72749. var isRightShortCircuit = isRightConstant && isLogicalIdentity(node.right, node.operator);
  72750. return isLeftConstant && isRightConstant || isLeftShortCircuit || isRightShortCircuit;
  72751. }
  72752. case "AssignmentExpression":
  72753. return node.operator === "=" && isConstant(node.right, inBooleanPosition);
  72754. case "SequenceExpression":
  72755. return isConstant(node.expressions[node.expressions.length - 1], inBooleanPosition);
  72756. // no default
  72757. }
  72758. return false;
  72759. }
  72760. /**
  72761. * Tracks when the given node contains a constant condition.
  72762. * @param {ASTNode} node The AST node to check.
  72763. * @returns {void}
  72764. * @private
  72765. */
  72766. function trackConstantConditionLoop(node) {
  72767. if (node.test && isConstant(node.test, true)) {
  72768. loopsInCurrentScope.add(node);
  72769. }
  72770. }
  72771. /**
  72772. * Reports when the set contains the given constant condition node
  72773. * @param {ASTNode} node The AST node to check.
  72774. * @returns {void}
  72775. * @private
  72776. */
  72777. function checkConstantConditionLoopInSet(node) {
  72778. if (loopsInCurrentScope.has(node)) {
  72779. loopsInCurrentScope.delete(node);
  72780. context.report({ node: node.test, messageId: "unexpected" });
  72781. }
  72782. }
  72783. /**
  72784. * Reports when the given node contains a constant condition.
  72785. * @param {ASTNode} node The AST node to check.
  72786. * @returns {void}
  72787. * @private
  72788. */
  72789. function reportIfConstant(node) {
  72790. if (node.test && isConstant(node.test, true)) {
  72791. context.report({ node: node.test, messageId: "unexpected" });
  72792. }
  72793. }
  72794. /**
  72795. * Stores current set of constant loops in loopSetStack temporarily
  72796. * and uses a new set to track constant loops
  72797. * @returns {void}
  72798. * @private
  72799. */
  72800. function enterFunction() {
  72801. loopSetStack.push(loopsInCurrentScope);
  72802. loopsInCurrentScope = new Set();
  72803. }
  72804. /**
  72805. * Reports when the set still contains stored constant conditions
  72806. * @returns {void}
  72807. * @private
  72808. */
  72809. function exitFunction() {
  72810. loopsInCurrentScope = loopSetStack.pop();
  72811. }
  72812. /**
  72813. * Checks node when checkLoops option is enabled
  72814. * @param {ASTNode} node The AST node to check.
  72815. * @returns {void}
  72816. * @private
  72817. */
  72818. function checkLoop(node) {
  72819. if (checkLoops) {
  72820. trackConstantConditionLoop(node);
  72821. }
  72822. }
  72823. //--------------------------------------------------------------------------
  72824. // Public
  72825. //--------------------------------------------------------------------------
  72826. return {
  72827. ConditionalExpression: reportIfConstant,
  72828. IfStatement: reportIfConstant,
  72829. WhileStatement: checkLoop,
  72830. "WhileStatement:exit": checkConstantConditionLoopInSet,
  72831. DoWhileStatement: checkLoop,
  72832. "DoWhileStatement:exit": checkConstantConditionLoopInSet,
  72833. ForStatement: checkLoop,
  72834. "ForStatement > .test": function ForStatementTest(node) {
  72835. return checkLoop(node.parent);
  72836. },
  72837. "ForStatement:exit": checkConstantConditionLoopInSet,
  72838. FunctionDeclaration: enterFunction,
  72839. "FunctionDeclaration:exit": exitFunction,
  72840. FunctionExpression: enterFunction,
  72841. "FunctionExpression:exit": exitFunction,
  72842. YieldExpression: function YieldExpression() {
  72843. return loopsInCurrentScope.clear();
  72844. }
  72845. };
  72846. }
  72847. };
  72848. },{}],212:[function(require,module,exports){
  72849. /**
  72850. * @fileoverview Rule to flag use of continue statement
  72851. * @author Borislav Zhivkov
  72852. */
  72853. "use strict";
  72854. //------------------------------------------------------------------------------
  72855. // Rule Definition
  72856. //------------------------------------------------------------------------------
  72857. module.exports = {
  72858. meta: {
  72859. type: "suggestion",
  72860. docs: {
  72861. description: "disallow `continue` statements",
  72862. category: "Stylistic Issues",
  72863. recommended: false,
  72864. url: "https://eslint.org/docs/rules/no-continue"
  72865. },
  72866. schema: [],
  72867. messages: {
  72868. unexpected: "Unexpected use of continue statement."
  72869. }
  72870. },
  72871. create: function create(context) {
  72872. return {
  72873. ContinueStatement: function ContinueStatement(node) {
  72874. context.report({ node: node, messageId: "unexpected" });
  72875. }
  72876. };
  72877. }
  72878. };
  72879. },{}],213:[function(require,module,exports){
  72880. /**
  72881. * @fileoverview Rule to forbid control charactes from regular expressions.
  72882. * @author Nicholas C. Zakas
  72883. */
  72884. "use strict";
  72885. 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; }; }();
  72886. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  72887. var RegExpValidator = require("regexpp").RegExpValidator;
  72888. var collector = new (function () {
  72889. function _class() {
  72890. _classCallCheck(this, _class);
  72891. this.ecmaVersion = 2018;
  72892. this._source = "";
  72893. this._controlChars = [];
  72894. this._validator = new RegExpValidator(this);
  72895. }
  72896. _createClass(_class, [{
  72897. key: "onPatternEnter",
  72898. value: function onPatternEnter() {
  72899. this._controlChars = [];
  72900. }
  72901. }, {
  72902. key: "onCharacter",
  72903. value: function onCharacter(start, end, cp) {
  72904. if (cp >= 0x00 && cp <= 0x1F && (this._source.codePointAt(start) === cp || this._source.slice(start, end).startsWith("\\x") || this._source.slice(start, end).startsWith("\\u"))) {
  72905. this._controlChars.push("\\x" + ("0" + cp.toString(16)).slice(-2));
  72906. }
  72907. }
  72908. }, {
  72909. key: "collectControlChars",
  72910. value: function collectControlChars(regexpStr) {
  72911. try {
  72912. this._source = regexpStr;
  72913. this._validator.validatePattern(regexpStr); // Call onCharacter hook
  72914. } catch (err) {
  72915. // Ignore syntax errors in RegExp.
  72916. }
  72917. return this._controlChars;
  72918. }
  72919. }]);
  72920. return _class;
  72921. }())();
  72922. //------------------------------------------------------------------------------
  72923. // Rule Definition
  72924. //------------------------------------------------------------------------------
  72925. module.exports = {
  72926. meta: {
  72927. type: "problem",
  72928. docs: {
  72929. description: "disallow control characters in regular expressions",
  72930. category: "Possible Errors",
  72931. recommended: true,
  72932. url: "https://eslint.org/docs/rules/no-control-regex"
  72933. },
  72934. schema: [],
  72935. messages: {
  72936. unexpected: "Unexpected control character(s) in regular expression: {{controlChars}}."
  72937. }
  72938. },
  72939. create: function create(context) {
  72940. /**
  72941. * Get the regex expression
  72942. * @param {ASTNode} node node to evaluate
  72943. * @returns {RegExp|null} Regex if found else null
  72944. * @private
  72945. */
  72946. function getRegExpPattern(node) {
  72947. if (node.regex) {
  72948. return node.regex.pattern;
  72949. }
  72950. if (typeof node.value === "string" && (node.parent.type === "NewExpression" || node.parent.type === "CallExpression") && node.parent.callee.type === "Identifier" && node.parent.callee.name === "RegExp" && node.parent.arguments[0] === node) {
  72951. return node.value;
  72952. }
  72953. return null;
  72954. }
  72955. return {
  72956. Literal: function Literal(node) {
  72957. var pattern = getRegExpPattern(node);
  72958. if (pattern) {
  72959. var controlCharacters = collector.collectControlChars(pattern);
  72960. if (controlCharacters.length > 0) {
  72961. context.report({
  72962. node: node,
  72963. messageId: "unexpected",
  72964. data: {
  72965. controlChars: controlCharacters.join(", ")
  72966. }
  72967. });
  72968. }
  72969. }
  72970. }
  72971. };
  72972. }
  72973. };
  72974. },{"regexpp":104}],214:[function(require,module,exports){
  72975. /**
  72976. * @fileoverview Rule to flag use of a debugger statement
  72977. * @author Nicholas C. Zakas
  72978. */
  72979. "use strict";
  72980. //------------------------------------------------------------------------------
  72981. // Rule Definition
  72982. //------------------------------------------------------------------------------
  72983. module.exports = {
  72984. meta: {
  72985. type: "problem",
  72986. docs: {
  72987. description: "disallow the use of `debugger`",
  72988. category: "Possible Errors",
  72989. recommended: true,
  72990. url: "https://eslint.org/docs/rules/no-debugger"
  72991. },
  72992. fixable: null,
  72993. schema: [],
  72994. messages: {
  72995. unexpected: "Unexpected 'debugger' statement."
  72996. }
  72997. },
  72998. create: function create(context) {
  72999. return {
  73000. DebuggerStatement: function DebuggerStatement(node) {
  73001. context.report({
  73002. node: node,
  73003. messageId: "unexpected"
  73004. });
  73005. }
  73006. };
  73007. }
  73008. };
  73009. },{}],215:[function(require,module,exports){
  73010. /**
  73011. * @fileoverview Rule to flag when deleting variables
  73012. * @author Ilya Volodin
  73013. */
  73014. "use strict";
  73015. //------------------------------------------------------------------------------
  73016. // Rule Definition
  73017. //------------------------------------------------------------------------------
  73018. module.exports = {
  73019. meta: {
  73020. type: "suggestion",
  73021. docs: {
  73022. description: "disallow deleting variables",
  73023. category: "Variables",
  73024. recommended: true,
  73025. url: "https://eslint.org/docs/rules/no-delete-var"
  73026. },
  73027. schema: [],
  73028. messages: {
  73029. unexpected: "Variables should not be deleted."
  73030. }
  73031. },
  73032. create: function create(context) {
  73033. return {
  73034. UnaryExpression: function UnaryExpression(node) {
  73035. if (node.operator === "delete" && node.argument.type === "Identifier") {
  73036. context.report({ node: node, messageId: "unexpected" });
  73037. }
  73038. }
  73039. };
  73040. }
  73041. };
  73042. },{}],216:[function(require,module,exports){
  73043. /**
  73044. * @fileoverview Rule to check for ambiguous div operator in regexes
  73045. * @author Matt DuVall <http://www.mattduvall.com>
  73046. */
  73047. "use strict";
  73048. //------------------------------------------------------------------------------
  73049. // Rule Definition
  73050. //------------------------------------------------------------------------------
  73051. module.exports = {
  73052. meta: {
  73053. type: "suggestion",
  73054. docs: {
  73055. description: "disallow division operators explicitly at the beginning of regular expressions",
  73056. category: "Best Practices",
  73057. recommended: false,
  73058. url: "https://eslint.org/docs/rules/no-div-regex"
  73059. },
  73060. schema: [],
  73061. messages: {
  73062. unexpected: "A regular expression literal can be confused with '/='."
  73063. }
  73064. },
  73065. create: function create(context) {
  73066. var sourceCode = context.getSourceCode();
  73067. return {
  73068. Literal: function Literal(node) {
  73069. var token = sourceCode.getFirstToken(node);
  73070. if (token.type === "RegularExpression" && token.value[1] === "=") {
  73071. context.report({ node: node, messageId: "unexpected" });
  73072. }
  73073. }
  73074. };
  73075. }
  73076. };
  73077. },{}],217:[function(require,module,exports){
  73078. /**
  73079. * @fileoverview Rule to flag duplicate arguments
  73080. * @author Jamund Ferguson
  73081. */
  73082. "use strict";
  73083. //------------------------------------------------------------------------------
  73084. // Rule Definition
  73085. //------------------------------------------------------------------------------
  73086. module.exports = {
  73087. meta: {
  73088. type: "problem",
  73089. docs: {
  73090. description: "disallow duplicate arguments in `function` definitions",
  73091. category: "Possible Errors",
  73092. recommended: true,
  73093. url: "https://eslint.org/docs/rules/no-dupe-args"
  73094. },
  73095. schema: [],
  73096. messages: {
  73097. unexpected: "Duplicate param '{{name}}'."
  73098. }
  73099. },
  73100. create: function create(context) {
  73101. //--------------------------------------------------------------------------
  73102. // Helpers
  73103. //--------------------------------------------------------------------------
  73104. /**
  73105. * Checks whether or not a given definition is a parameter's.
  73106. * @param {eslint-scope.DefEntry} def - A definition to check.
  73107. * @returns {boolean} `true` if the definition is a parameter's.
  73108. */
  73109. function isParameter(def) {
  73110. return def.type === "Parameter";
  73111. }
  73112. /**
  73113. * Determines if a given node has duplicate parameters.
  73114. * @param {ASTNode} node The node to check.
  73115. * @returns {void}
  73116. * @private
  73117. */
  73118. function checkParams(node) {
  73119. var variables = context.getDeclaredVariables(node);
  73120. for (var i = 0; i < variables.length; ++i) {
  73121. var variable = variables[i];
  73122. // Checks and reports duplications.
  73123. var defs = variable.defs.filter(isParameter);
  73124. if (defs.length >= 2) {
  73125. context.report({
  73126. node: node,
  73127. messageId: "unexpected",
  73128. data: { name: variable.name }
  73129. });
  73130. }
  73131. }
  73132. }
  73133. //--------------------------------------------------------------------------
  73134. // Public API
  73135. //--------------------------------------------------------------------------
  73136. return {
  73137. FunctionDeclaration: checkParams,
  73138. FunctionExpression: checkParams
  73139. };
  73140. }
  73141. };
  73142. },{}],218:[function(require,module,exports){
  73143. /**
  73144. * @fileoverview A rule to disallow duplicate name in class members.
  73145. * @author Toru Nagashima
  73146. */
  73147. "use strict";
  73148. //------------------------------------------------------------------------------
  73149. // Rule Definition
  73150. //------------------------------------------------------------------------------
  73151. module.exports = {
  73152. meta: {
  73153. type: "problem",
  73154. docs: {
  73155. description: "disallow duplicate class members",
  73156. category: "ECMAScript 6",
  73157. recommended: true,
  73158. url: "https://eslint.org/docs/rules/no-dupe-class-members"
  73159. },
  73160. schema: [],
  73161. messages: {
  73162. unexpected: "Duplicate name '{{name}}'."
  73163. }
  73164. },
  73165. create: function create(context) {
  73166. var stack = [];
  73167. /**
  73168. * Gets state of a given member name.
  73169. * @param {string} name - A name of a member.
  73170. * @param {boolean} isStatic - A flag which specifies that is a static member.
  73171. * @returns {Object} A state of a given member name.
  73172. * - retv.init {boolean} A flag which shows the name is declared as normal member.
  73173. * - retv.get {boolean} A flag which shows the name is declared as getter.
  73174. * - retv.set {boolean} A flag which shows the name is declared as setter.
  73175. */
  73176. function getState(name, isStatic) {
  73177. var stateMap = stack[stack.length - 1];
  73178. var key = "$" + name; // to avoid "__proto__".
  73179. if (!stateMap[key]) {
  73180. stateMap[key] = {
  73181. nonStatic: { init: false, get: false, set: false },
  73182. static: { init: false, get: false, set: false }
  73183. };
  73184. }
  73185. return stateMap[key][isStatic ? "static" : "nonStatic"];
  73186. }
  73187. /**
  73188. * Gets the name text of a given node.
  73189. *
  73190. * @param {ASTNode} node - A node to get the name.
  73191. * @returns {string} The name text of the node.
  73192. */
  73193. function getName(node) {
  73194. switch (node.type) {
  73195. case "Identifier":
  73196. return node.name;
  73197. case "Literal":
  73198. return String(node.value);
  73199. /* istanbul ignore next: syntax error */
  73200. default:
  73201. return "";
  73202. }
  73203. }
  73204. return {
  73205. // Initializes the stack of state of member declarations.
  73206. Program: function Program() {
  73207. stack = [];
  73208. },
  73209. // Initializes state of member declarations for the class.
  73210. ClassBody: function ClassBody() {
  73211. stack.push(Object.create(null));
  73212. },
  73213. // Disposes the state for the class.
  73214. "ClassBody:exit": function ClassBodyExit() {
  73215. stack.pop();
  73216. },
  73217. // Reports the node if its name has been declared already.
  73218. MethodDefinition: function MethodDefinition(node) {
  73219. if (node.computed) {
  73220. return;
  73221. }
  73222. var name = getName(node.key);
  73223. var state = getState(name, node.static);
  73224. var isDuplicate = false;
  73225. if (node.kind === "get") {
  73226. isDuplicate = state.init || state.get;
  73227. state.get = true;
  73228. } else if (node.kind === "set") {
  73229. isDuplicate = state.init || state.set;
  73230. state.set = true;
  73231. } else {
  73232. isDuplicate = state.init || state.get || state.set;
  73233. state.init = true;
  73234. }
  73235. if (isDuplicate) {
  73236. context.report({ node: node, messageId: "unexpected", data: { name: name } });
  73237. }
  73238. }
  73239. };
  73240. }
  73241. };
  73242. },{}],219:[function(require,module,exports){
  73243. /**
  73244. * @fileoverview Rule to flag use of duplicate keys in an object.
  73245. * @author Ian Christian Myers
  73246. */
  73247. "use strict";
  73248. //------------------------------------------------------------------------------
  73249. // Requirements
  73250. //------------------------------------------------------------------------------
  73251. 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; }; }();
  73252. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  73253. var astUtils = require("../util/ast-utils");
  73254. //------------------------------------------------------------------------------
  73255. // Helpers
  73256. //------------------------------------------------------------------------------
  73257. var GET_KIND = /^(?:init|get)$/;
  73258. var SET_KIND = /^(?:init|set)$/;
  73259. /**
  73260. * The class which stores properties' information of an object.
  73261. */
  73262. var ObjectInfo = function () {
  73263. /**
  73264. * @param {ObjectInfo|null} upper - The information of the outer object.
  73265. * @param {ASTNode} node - The ObjectExpression node of this information.
  73266. */
  73267. function ObjectInfo(upper, node) {
  73268. _classCallCheck(this, ObjectInfo);
  73269. this.upper = upper;
  73270. this.node = node;
  73271. this.properties = new Map();
  73272. }
  73273. /**
  73274. * Gets the information of the given Property node.
  73275. * @param {ASTNode} node - The Property node to get.
  73276. * @returns {{get: boolean, set: boolean}} The information of the property.
  73277. */
  73278. _createClass(ObjectInfo, [{
  73279. key: "getPropertyInfo",
  73280. value: function getPropertyInfo(node) {
  73281. var name = astUtils.getStaticPropertyName(node);
  73282. if (!this.properties.has(name)) {
  73283. this.properties.set(name, { get: false, set: false });
  73284. }
  73285. return this.properties.get(name);
  73286. }
  73287. /**
  73288. * Checks whether the given property has been defined already or not.
  73289. * @param {ASTNode} node - The Property node to check.
  73290. * @returns {boolean} `true` if the property has been defined.
  73291. */
  73292. }, {
  73293. key: "isPropertyDefined",
  73294. value: function isPropertyDefined(node) {
  73295. var entry = this.getPropertyInfo(node);
  73296. return GET_KIND.test(node.kind) && entry.get || SET_KIND.test(node.kind) && entry.set;
  73297. }
  73298. /**
  73299. * Defines the given property.
  73300. * @param {ASTNode} node - The Property node to define.
  73301. * @returns {void}
  73302. */
  73303. }, {
  73304. key: "defineProperty",
  73305. value: function defineProperty(node) {
  73306. var entry = this.getPropertyInfo(node);
  73307. if (GET_KIND.test(node.kind)) {
  73308. entry.get = true;
  73309. }
  73310. if (SET_KIND.test(node.kind)) {
  73311. entry.set = true;
  73312. }
  73313. }
  73314. }]);
  73315. return ObjectInfo;
  73316. }();
  73317. //------------------------------------------------------------------------------
  73318. // Rule Definition
  73319. //------------------------------------------------------------------------------
  73320. module.exports = {
  73321. meta: {
  73322. type: "problem",
  73323. docs: {
  73324. description: "disallow duplicate keys in object literals",
  73325. category: "Possible Errors",
  73326. recommended: true,
  73327. url: "https://eslint.org/docs/rules/no-dupe-keys"
  73328. },
  73329. schema: [],
  73330. messages: {
  73331. unexpected: "Duplicate key '{{name}}'."
  73332. }
  73333. },
  73334. create: function create(context) {
  73335. var info = null;
  73336. return {
  73337. ObjectExpression: function ObjectExpression(node) {
  73338. info = new ObjectInfo(info, node);
  73339. },
  73340. "ObjectExpression:exit": function ObjectExpressionExit() {
  73341. info = info.upper;
  73342. },
  73343. Property: function Property(node) {
  73344. var name = astUtils.getStaticPropertyName(node);
  73345. // Skip destructuring.
  73346. if (node.parent.type !== "ObjectExpression") {
  73347. return;
  73348. }
  73349. // Skip if the name is not static.
  73350. if (!name) {
  73351. return;
  73352. }
  73353. // Reports if the name is defined already.
  73354. if (info.isPropertyDefined(node)) {
  73355. context.report({
  73356. node: info.node,
  73357. loc: node.key.loc,
  73358. messageId: "unexpected",
  73359. data: { name: name }
  73360. });
  73361. }
  73362. // Update info.
  73363. info.defineProperty(node);
  73364. }
  73365. };
  73366. }
  73367. };
  73368. },{"../util/ast-utils":405}],220:[function(require,module,exports){
  73369. /**
  73370. * @fileoverview Rule to disallow a duplicate case label.
  73371. * @author Dieter Oberkofler
  73372. * @author Burak Yigit Kaya
  73373. */
  73374. "use strict";
  73375. //------------------------------------------------------------------------------
  73376. // Rule Definition
  73377. //------------------------------------------------------------------------------
  73378. module.exports = {
  73379. meta: {
  73380. type: "problem",
  73381. docs: {
  73382. description: "disallow duplicate case labels",
  73383. category: "Possible Errors",
  73384. recommended: true,
  73385. url: "https://eslint.org/docs/rules/no-duplicate-case"
  73386. },
  73387. schema: [],
  73388. messages: {
  73389. unexpected: "Duplicate case label."
  73390. }
  73391. },
  73392. create: function create(context) {
  73393. var sourceCode = context.getSourceCode();
  73394. return {
  73395. SwitchStatement: function SwitchStatement(node) {
  73396. var mapping = {};
  73397. node.cases.forEach(function (switchCase) {
  73398. var key = sourceCode.getText(switchCase.test);
  73399. if (mapping[key]) {
  73400. context.report({ node: switchCase, messageId: "unexpected" });
  73401. } else {
  73402. mapping[key] = switchCase;
  73403. }
  73404. });
  73405. }
  73406. };
  73407. }
  73408. };
  73409. },{}],221:[function(require,module,exports){
  73410. /**
  73411. * @fileoverview Restrict usage of duplicate imports.
  73412. * @author Simen Bekkhus
  73413. */
  73414. "use strict";
  73415. //------------------------------------------------------------------------------
  73416. // Rule Definition
  73417. //------------------------------------------------------------------------------
  73418. /**
  73419. * Returns the name of the module imported or re-exported.
  73420. *
  73421. * @param {ASTNode} node - A node to get.
  73422. * @returns {string} the name of the module, or empty string if no name.
  73423. */
  73424. function getValue(node) {
  73425. if (node && node.source && node.source.value) {
  73426. return node.source.value.trim();
  73427. }
  73428. return "";
  73429. }
  73430. /**
  73431. * Checks if the name of the import or export exists in the given array, and reports if so.
  73432. *
  73433. * @param {RuleContext} context - The ESLint rule context object.
  73434. * @param {ASTNode} node - A node to get.
  73435. * @param {string} value - The name of the imported or exported module.
  73436. * @param {string[]} array - The array containing other imports or exports in the file.
  73437. * @param {string} message - A message to be reported after the name of the module
  73438. *
  73439. * @returns {void} No return value
  73440. */
  73441. function checkAndReport(context, node, value, array, message) {
  73442. if (array.indexOf(value) !== -1) {
  73443. context.report({
  73444. node: node,
  73445. message: "'{{module}}' {{message}}",
  73446. data: {
  73447. module: value,
  73448. message: message
  73449. }
  73450. });
  73451. }
  73452. }
  73453. /**
  73454. * @callback nodeCallback
  73455. * @param {ASTNode} node - A node to handle.
  73456. */
  73457. /**
  73458. * Returns a function handling the imports of a given file
  73459. *
  73460. * @param {RuleContext} context - The ESLint rule context object.
  73461. * @param {boolean} includeExports - Whether or not to check for exports in addition to imports.
  73462. * @param {string[]} importsInFile - The array containing other imports in the file.
  73463. * @param {string[]} exportsInFile - The array containing other exports in the file.
  73464. *
  73465. * @returns {nodeCallback} A function passed to ESLint to handle the statement.
  73466. */
  73467. function handleImports(context, includeExports, importsInFile, exportsInFile) {
  73468. return function (node) {
  73469. var value = getValue(node);
  73470. if (value) {
  73471. checkAndReport(context, node, value, importsInFile, "import is duplicated.");
  73472. if (includeExports) {
  73473. checkAndReport(context, node, value, exportsInFile, "import is duplicated as export.");
  73474. }
  73475. importsInFile.push(value);
  73476. }
  73477. };
  73478. }
  73479. /**
  73480. * Returns a function handling the exports of a given file
  73481. *
  73482. * @param {RuleContext} context - The ESLint rule context object.
  73483. * @param {string[]} importsInFile - The array containing other imports in the file.
  73484. * @param {string[]} exportsInFile - The array containing other exports in the file.
  73485. *
  73486. * @returns {nodeCallback} A function passed to ESLint to handle the statement.
  73487. */
  73488. function handleExports(context, importsInFile, exportsInFile) {
  73489. return function (node) {
  73490. var value = getValue(node);
  73491. if (value) {
  73492. checkAndReport(context, node, value, exportsInFile, "export is duplicated.");
  73493. checkAndReport(context, node, value, importsInFile, "export is duplicated as import.");
  73494. exportsInFile.push(value);
  73495. }
  73496. };
  73497. }
  73498. module.exports = {
  73499. meta: {
  73500. type: "problem",
  73501. docs: {
  73502. description: "disallow duplicate module imports",
  73503. category: "ECMAScript 6",
  73504. recommended: false,
  73505. url: "https://eslint.org/docs/rules/no-duplicate-imports"
  73506. },
  73507. schema: [{
  73508. type: "object",
  73509. properties: {
  73510. includeExports: {
  73511. type: "boolean"
  73512. }
  73513. },
  73514. additionalProperties: false
  73515. }]
  73516. },
  73517. create: function create(context) {
  73518. var includeExports = (context.options[0] || {}).includeExports,
  73519. importsInFile = [],
  73520. exportsInFile = [];
  73521. var handlers = {
  73522. ImportDeclaration: handleImports(context, includeExports, importsInFile, exportsInFile)
  73523. };
  73524. if (includeExports) {
  73525. handlers.ExportNamedDeclaration = handleExports(context, importsInFile, exportsInFile);
  73526. handlers.ExportAllDeclaration = handleExports(context, importsInFile, exportsInFile);
  73527. }
  73528. return handlers;
  73529. }
  73530. };
  73531. },{}],222:[function(require,module,exports){
  73532. /**
  73533. * @fileoverview Rule to flag `else` after a `return` in `if`
  73534. * @author Ian Christian Myers
  73535. */
  73536. "use strict";
  73537. //------------------------------------------------------------------------------
  73538. // Requirements
  73539. //------------------------------------------------------------------------------
  73540. var astUtils = require("../util/ast-utils");
  73541. var FixTracker = require("../util/fix-tracker");
  73542. //------------------------------------------------------------------------------
  73543. // Rule Definition
  73544. //------------------------------------------------------------------------------
  73545. module.exports = {
  73546. meta: {
  73547. type: "suggestion",
  73548. docs: {
  73549. description: "disallow `else` blocks after `return` statements in `if` statements",
  73550. category: "Best Practices",
  73551. recommended: false,
  73552. url: "https://eslint.org/docs/rules/no-else-return"
  73553. },
  73554. schema: [{
  73555. type: "object",
  73556. properties: {
  73557. allowElseIf: {
  73558. type: "boolean"
  73559. }
  73560. },
  73561. additionalProperties: false
  73562. }],
  73563. fixable: "code",
  73564. messages: {
  73565. unexpected: "Unnecessary 'else' after 'return'."
  73566. }
  73567. },
  73568. create: function create(context) {
  73569. //--------------------------------------------------------------------------
  73570. // Helpers
  73571. //--------------------------------------------------------------------------
  73572. /**
  73573. * Display the context report if rule is violated
  73574. *
  73575. * @param {Node} node The 'else' node
  73576. * @returns {void}
  73577. */
  73578. function displayReport(node) {
  73579. context.report({
  73580. node: node,
  73581. messageId: "unexpected",
  73582. fix: function fix(fixer) {
  73583. var sourceCode = context.getSourceCode();
  73584. var startToken = sourceCode.getFirstToken(node);
  73585. var elseToken = sourceCode.getTokenBefore(startToken);
  73586. var source = sourceCode.getText(node);
  73587. var lastIfToken = sourceCode.getTokenBefore(elseToken);
  73588. var fixedSource = void 0,
  73589. firstTokenOfElseBlock = void 0;
  73590. if (startToken.type === "Punctuator" && startToken.value === "{") {
  73591. firstTokenOfElseBlock = sourceCode.getTokenAfter(startToken);
  73592. } else {
  73593. firstTokenOfElseBlock = startToken;
  73594. }
  73595. /*
  73596. * If the if block does not have curly braces and does not end in a semicolon
  73597. * and the else block starts with (, [, /, +, ` or -, then it is not
  73598. * safe to remove the else keyword, because ASI will not add a semicolon
  73599. * after the if block
  73600. */
  73601. var ifBlockMaybeUnsafe = node.parent.consequent.type !== "BlockStatement" && lastIfToken.value !== ";";
  73602. var elseBlockUnsafe = /^[([/+`-]/.test(firstTokenOfElseBlock.value);
  73603. if (ifBlockMaybeUnsafe && elseBlockUnsafe) {
  73604. return null;
  73605. }
  73606. var endToken = sourceCode.getLastToken(node);
  73607. var lastTokenOfElseBlock = sourceCode.getTokenBefore(endToken);
  73608. if (lastTokenOfElseBlock.value !== ";") {
  73609. var nextToken = sourceCode.getTokenAfter(endToken);
  73610. var nextTokenUnsafe = nextToken && /^[([/+`-]/.test(nextToken.value);
  73611. var nextTokenOnSameLine = nextToken && nextToken.loc.start.line === lastTokenOfElseBlock.loc.start.line;
  73612. /*
  73613. * If the else block contents does not end in a semicolon,
  73614. * and the else block starts with (, [, /, +, ` or -, then it is not
  73615. * safe to remove the else block, because ASI will not add a semicolon
  73616. * after the remaining else block contents
  73617. */
  73618. if (nextTokenUnsafe || nextTokenOnSameLine && nextToken.value !== "}") {
  73619. return null;
  73620. }
  73621. }
  73622. if (startToken.type === "Punctuator" && startToken.value === "{") {
  73623. fixedSource = source.slice(1, -1);
  73624. } else {
  73625. fixedSource = source;
  73626. }
  73627. /*
  73628. * Extend the replacement range to include the entire
  73629. * function to avoid conflicting with no-useless-return.
  73630. * https://github.com/eslint/eslint/issues/8026
  73631. */
  73632. return new FixTracker(fixer, sourceCode).retainEnclosingFunction(node).replaceTextRange([elseToken.range[0], node.range[1]], fixedSource);
  73633. }
  73634. });
  73635. }
  73636. /**
  73637. * Check to see if the node is a ReturnStatement
  73638. *
  73639. * @param {Node} node The node being evaluated
  73640. * @returns {boolean} True if node is a return
  73641. */
  73642. function checkForReturn(node) {
  73643. return node.type === "ReturnStatement";
  73644. }
  73645. /**
  73646. * Naive return checking, does not iterate through the whole
  73647. * BlockStatement because we make the assumption that the ReturnStatement
  73648. * will be the last node in the body of the BlockStatement.
  73649. *
  73650. * @param {Node} node The consequent/alternate node
  73651. * @returns {boolean} True if it has a return
  73652. */
  73653. function naiveHasReturn(node) {
  73654. if (node.type === "BlockStatement") {
  73655. var body = node.body,
  73656. lastChildNode = body[body.length - 1];
  73657. return lastChildNode && checkForReturn(lastChildNode);
  73658. }
  73659. return checkForReturn(node);
  73660. }
  73661. /**
  73662. * Check to see if the node is valid for evaluation,
  73663. * meaning it has an else.
  73664. *
  73665. * @param {Node} node The node being evaluated
  73666. * @returns {boolean} True if the node is valid
  73667. */
  73668. function hasElse(node) {
  73669. return node.alternate && node.consequent;
  73670. }
  73671. /**
  73672. * If the consequent is an IfStatement, check to see if it has an else
  73673. * and both its consequent and alternate path return, meaning this is
  73674. * a nested case of rule violation. If-Else not considered currently.
  73675. *
  73676. * @param {Node} node The consequent node
  73677. * @returns {boolean} True if this is a nested rule violation
  73678. */
  73679. function checkForIf(node) {
  73680. return node.type === "IfStatement" && hasElse(node) && naiveHasReturn(node.alternate) && naiveHasReturn(node.consequent);
  73681. }
  73682. /**
  73683. * Check the consequent/body node to make sure it is not
  73684. * a ReturnStatement or an IfStatement that returns on both
  73685. * code paths.
  73686. *
  73687. * @param {Node} node The consequent or body node
  73688. * @returns {boolean} `true` if it is a Return/If node that always returns.
  73689. */
  73690. function checkForReturnOrIf(node) {
  73691. return checkForReturn(node) || checkForIf(node);
  73692. }
  73693. /**
  73694. * Check whether a node returns in every codepath.
  73695. * @param {Node} node The node to be checked
  73696. * @returns {boolean} `true` if it returns on every codepath.
  73697. */
  73698. function alwaysReturns(node) {
  73699. if (node.type === "BlockStatement") {
  73700. // If we have a BlockStatement, check each consequent body node.
  73701. return node.body.some(checkForReturnOrIf);
  73702. }
  73703. /*
  73704. * If not a block statement, make sure the consequent isn't a
  73705. * ReturnStatement or an IfStatement with returns on both paths.
  73706. */
  73707. return checkForReturnOrIf(node);
  73708. }
  73709. /**
  73710. * Check the if statement, but don't catch else-if blocks.
  73711. * @returns {void}
  73712. * @param {Node} node The node for the if statement to check
  73713. * @private
  73714. */
  73715. function checkIfWithoutElse(node) {
  73716. var parent = node.parent;
  73717. /*
  73718. * Fixing this would require splitting one statement into two, so no error should
  73719. * be reported if this node is in a position where only one statement is allowed.
  73720. */
  73721. if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
  73722. return;
  73723. }
  73724. var consequents = [];
  73725. var alternate = void 0;
  73726. for (var currentNode = node; currentNode.type === "IfStatement"; currentNode = currentNode.alternate) {
  73727. if (!currentNode.alternate) {
  73728. return;
  73729. }
  73730. consequents.push(currentNode.consequent);
  73731. alternate = currentNode.alternate;
  73732. }
  73733. if (consequents.every(alwaysReturns)) {
  73734. displayReport(alternate);
  73735. }
  73736. }
  73737. /**
  73738. * Check the if statement
  73739. * @returns {void}
  73740. * @param {Node} node The node for the if statement to check
  73741. * @private
  73742. */
  73743. function checkIfWithElse(node) {
  73744. var parent = node.parent;
  73745. /*
  73746. * Fixing this would require splitting one statement into two, so no error should
  73747. * be reported if this node is in a position where only one statement is allowed.
  73748. */
  73749. if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
  73750. return;
  73751. }
  73752. var alternate = node.alternate;
  73753. if (alternate && alwaysReturns(node.consequent)) {
  73754. displayReport(alternate);
  73755. }
  73756. }
  73757. var allowElseIf = !(context.options[0] && context.options[0].allowElseIf === false);
  73758. //--------------------------------------------------------------------------
  73759. // Public API
  73760. //--------------------------------------------------------------------------
  73761. return {
  73762. "IfStatement:exit": allowElseIf ? checkIfWithoutElse : checkIfWithElse
  73763. };
  73764. }
  73765. };
  73766. },{"../util/ast-utils":405,"../util/fix-tracker":407}],223:[function(require,module,exports){
  73767. /**
  73768. * @fileoverview Rule to flag the use of empty character classes in regular expressions
  73769. * @author Ian Christian Myers
  73770. */
  73771. "use strict";
  73772. //------------------------------------------------------------------------------
  73773. // Helpers
  73774. //------------------------------------------------------------------------------
  73775. /*
  73776. * plain-English description of the following regexp:
  73777. * 0. `^` fix the match at the beginning of the string
  73778. * 1. `\/`: the `/` that begins the regexp
  73779. * 2. `([^\\[]|\\.|\[([^\\\]]|\\.)+\])*`: regexp contents; 0 or more of the following
  73780. * 2.0. `[^\\[]`: any character that's not a `\` or a `[` (anything but escape sequences and character classes)
  73781. * 2.1. `\\.`: an escape sequence
  73782. * 2.2. `\[([^\\\]]|\\.)+\]`: a character class that isn't empty
  73783. * 3. `\/` the `/` that ends the regexp
  73784. * 4. `[gimuy]*`: optional regexp flags
  73785. * 5. `$`: fix the match at the end of the string
  73786. */
  73787. var regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)+])*\/[gimuys]*$/;
  73788. //------------------------------------------------------------------------------
  73789. // Rule Definition
  73790. //------------------------------------------------------------------------------
  73791. module.exports = {
  73792. meta: {
  73793. type: "problem",
  73794. docs: {
  73795. description: "disallow empty character classes in regular expressions",
  73796. category: "Possible Errors",
  73797. recommended: true,
  73798. url: "https://eslint.org/docs/rules/no-empty-character-class"
  73799. },
  73800. schema: [],
  73801. messages: {
  73802. unexpected: "Empty class."
  73803. }
  73804. },
  73805. create: function create(context) {
  73806. var sourceCode = context.getSourceCode();
  73807. return {
  73808. Literal: function Literal(node) {
  73809. var token = sourceCode.getFirstToken(node);
  73810. if (token.type === "RegularExpression" && !regex.test(token.value)) {
  73811. context.report({ node: node, messageId: "unexpected" });
  73812. }
  73813. }
  73814. };
  73815. }
  73816. };
  73817. },{}],224:[function(require,module,exports){
  73818. /**
  73819. * @fileoverview Rule to disallow empty functions.
  73820. * @author Toru Nagashima
  73821. */
  73822. "use strict";
  73823. //------------------------------------------------------------------------------
  73824. // Requirements
  73825. //------------------------------------------------------------------------------
  73826. var astUtils = require("../util/ast-utils");
  73827. //------------------------------------------------------------------------------
  73828. // Helpers
  73829. //------------------------------------------------------------------------------
  73830. var ALLOW_OPTIONS = Object.freeze(["functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors"]);
  73831. /**
  73832. * Gets the kind of a given function node.
  73833. *
  73834. * @param {ASTNode} node - A function node to get. This is one of
  73835. * an ArrowFunctionExpression, a FunctionDeclaration, or a
  73836. * FunctionExpression.
  73837. * @returns {string} The kind of the function. This is one of "functions",
  73838. * "arrowFunctions", "generatorFunctions", "asyncFunctions", "methods",
  73839. * "generatorMethods", "asyncMethods", "getters", "setters", and
  73840. * "constructors".
  73841. */
  73842. function getKind(node) {
  73843. var parent = node.parent;
  73844. var kind = "";
  73845. if (node.type === "ArrowFunctionExpression") {
  73846. return "arrowFunctions";
  73847. }
  73848. // Detects main kind.
  73849. if (parent.type === "Property") {
  73850. if (parent.kind === "get") {
  73851. return "getters";
  73852. }
  73853. if (parent.kind === "set") {
  73854. return "setters";
  73855. }
  73856. kind = parent.method ? "methods" : "functions";
  73857. } else if (parent.type === "MethodDefinition") {
  73858. if (parent.kind === "get") {
  73859. return "getters";
  73860. }
  73861. if (parent.kind === "set") {
  73862. return "setters";
  73863. }
  73864. if (parent.kind === "constructor") {
  73865. return "constructors";
  73866. }
  73867. kind = "methods";
  73868. } else {
  73869. kind = "functions";
  73870. }
  73871. // Detects prefix.
  73872. var prefix = "";
  73873. if (node.generator) {
  73874. prefix = "generator";
  73875. } else if (node.async) {
  73876. prefix = "async";
  73877. } else {
  73878. return kind;
  73879. }
  73880. return prefix + kind[0].toUpperCase() + kind.slice(1);
  73881. }
  73882. //------------------------------------------------------------------------------
  73883. // Rule Definition
  73884. //------------------------------------------------------------------------------
  73885. module.exports = {
  73886. meta: {
  73887. type: "suggestion",
  73888. docs: {
  73889. description: "disallow empty functions",
  73890. category: "Best Practices",
  73891. recommended: false,
  73892. url: "https://eslint.org/docs/rules/no-empty-function"
  73893. },
  73894. schema: [{
  73895. type: "object",
  73896. properties: {
  73897. allow: {
  73898. type: "array",
  73899. items: { enum: ALLOW_OPTIONS },
  73900. uniqueItems: true
  73901. }
  73902. },
  73903. additionalProperties: false
  73904. }],
  73905. messages: {
  73906. unexpected: "Unexpected empty {{name}}."
  73907. }
  73908. },
  73909. create: function create(context) {
  73910. var options = context.options[0] || {};
  73911. var allowed = options.allow || [];
  73912. var sourceCode = context.getSourceCode();
  73913. /**
  73914. * Reports a given function node if the node matches the following patterns.
  73915. *
  73916. * - Not allowed by options.
  73917. * - The body is empty.
  73918. * - The body doesn't have any comments.
  73919. *
  73920. * @param {ASTNode} node - A function node to report. This is one of
  73921. * an ArrowFunctionExpression, a FunctionDeclaration, or a
  73922. * FunctionExpression.
  73923. * @returns {void}
  73924. */
  73925. function reportIfEmpty(node) {
  73926. var kind = getKind(node);
  73927. var name = astUtils.getFunctionNameWithKind(node);
  73928. var innerComments = sourceCode.getTokens(node.body, {
  73929. includeComments: true,
  73930. filter: astUtils.isCommentToken
  73931. });
  73932. if (allowed.indexOf(kind) === -1 && node.body.type === "BlockStatement" && node.body.body.length === 0 && innerComments.length === 0) {
  73933. context.report({
  73934. node: node,
  73935. loc: node.body.loc.start,
  73936. messageId: "unexpected",
  73937. data: { name: name }
  73938. });
  73939. }
  73940. }
  73941. return {
  73942. ArrowFunctionExpression: reportIfEmpty,
  73943. FunctionDeclaration: reportIfEmpty,
  73944. FunctionExpression: reportIfEmpty
  73945. };
  73946. }
  73947. };
  73948. },{"../util/ast-utils":405}],225:[function(require,module,exports){
  73949. /**
  73950. * @fileoverview Rule to disallow an empty pattern
  73951. * @author Alberto Rodríguez
  73952. */
  73953. "use strict";
  73954. //------------------------------------------------------------------------------
  73955. // Rule Definition
  73956. //------------------------------------------------------------------------------
  73957. module.exports = {
  73958. meta: {
  73959. type: "problem",
  73960. docs: {
  73961. description: "disallow empty destructuring patterns",
  73962. category: "Best Practices",
  73963. recommended: true,
  73964. url: "https://eslint.org/docs/rules/no-empty-pattern"
  73965. },
  73966. schema: [],
  73967. messages: {
  73968. unexpected: "Unexpected empty {{type}} pattern."
  73969. }
  73970. },
  73971. create: function create(context) {
  73972. return {
  73973. ObjectPattern: function ObjectPattern(node) {
  73974. if (node.properties.length === 0) {
  73975. context.report({ node: node, messageId: "unexpected", data: { type: "object" } });
  73976. }
  73977. },
  73978. ArrayPattern: function ArrayPattern(node) {
  73979. if (node.elements.length === 0) {
  73980. context.report({ node: node, messageId: "unexpected", data: { type: "array" } });
  73981. }
  73982. }
  73983. };
  73984. }
  73985. };
  73986. },{}],226:[function(require,module,exports){
  73987. /**
  73988. * @fileoverview Rule to flag use of an empty block statement
  73989. * @author Nicholas C. Zakas
  73990. */
  73991. "use strict";
  73992. //------------------------------------------------------------------------------
  73993. // Requirements
  73994. //------------------------------------------------------------------------------
  73995. var astUtils = require("../util/ast-utils");
  73996. //------------------------------------------------------------------------------
  73997. // Rule Definition
  73998. //------------------------------------------------------------------------------
  73999. module.exports = {
  74000. meta: {
  74001. type: "suggestion",
  74002. docs: {
  74003. description: "disallow empty block statements",
  74004. category: "Possible Errors",
  74005. recommended: true,
  74006. url: "https://eslint.org/docs/rules/no-empty"
  74007. },
  74008. schema: [{
  74009. type: "object",
  74010. properties: {
  74011. allowEmptyCatch: {
  74012. type: "boolean"
  74013. }
  74014. },
  74015. additionalProperties: false
  74016. }],
  74017. messages: {
  74018. unexpected: "Empty {{type}} statement."
  74019. }
  74020. },
  74021. create: function create(context) {
  74022. var options = context.options[0] || {},
  74023. allowEmptyCatch = options.allowEmptyCatch || false;
  74024. var sourceCode = context.getSourceCode();
  74025. return {
  74026. BlockStatement: function BlockStatement(node) {
  74027. // if the body is not empty, we can just return immediately
  74028. if (node.body.length !== 0) {
  74029. return;
  74030. }
  74031. // a function is generally allowed to be empty
  74032. if (astUtils.isFunction(node.parent)) {
  74033. return;
  74034. }
  74035. if (allowEmptyCatch && node.parent.type === "CatchClause") {
  74036. return;
  74037. }
  74038. // any other block is only allowed to be empty, if it contains a comment
  74039. if (sourceCode.getCommentsInside(node).length > 0) {
  74040. return;
  74041. }
  74042. context.report({ node: node, messageId: "unexpected", data: { type: "block" } });
  74043. },
  74044. SwitchStatement: function SwitchStatement(node) {
  74045. if (typeof node.cases === "undefined" || node.cases.length === 0) {
  74046. context.report({ node: node, messageId: "unexpected", data: { type: "switch" } });
  74047. }
  74048. }
  74049. };
  74050. }
  74051. };
  74052. },{"../util/ast-utils":405}],227:[function(require,module,exports){
  74053. /**
  74054. * @fileoverview Rule to flag comparisons to null without a type-checking
  74055. * operator.
  74056. * @author Ian Christian Myers
  74057. */
  74058. "use strict";
  74059. //------------------------------------------------------------------------------
  74060. // Rule Definition
  74061. //------------------------------------------------------------------------------
  74062. module.exports = {
  74063. meta: {
  74064. type: "suggestion",
  74065. docs: {
  74066. description: "disallow `null` comparisons without type-checking operators",
  74067. category: "Best Practices",
  74068. recommended: false,
  74069. url: "https://eslint.org/docs/rules/no-eq-null"
  74070. },
  74071. schema: [],
  74072. messages: {
  74073. unexpected: "Use '===' to compare with null."
  74074. }
  74075. },
  74076. create: function create(context) {
  74077. return {
  74078. BinaryExpression: function BinaryExpression(node) {
  74079. var badOperator = node.operator === "==" || node.operator === "!=";
  74080. if (node.right.type === "Literal" && node.right.raw === "null" && badOperator || node.left.type === "Literal" && node.left.raw === "null" && badOperator) {
  74081. context.report({ node: node, messageId: "unexpected" });
  74082. }
  74083. }
  74084. };
  74085. }
  74086. };
  74087. },{}],228:[function(require,module,exports){
  74088. /**
  74089. * @fileoverview Rule to flag use of eval() statement
  74090. * @author Nicholas C. Zakas
  74091. */
  74092. "use strict";
  74093. //------------------------------------------------------------------------------
  74094. // Requirements
  74095. //------------------------------------------------------------------------------
  74096. var astUtils = require("../util/ast-utils");
  74097. //------------------------------------------------------------------------------
  74098. // Helpers
  74099. //------------------------------------------------------------------------------
  74100. var candidatesOfGlobalObject = Object.freeze(["global", "window"]);
  74101. /**
  74102. * Checks a given node is a Identifier node of the specified name.
  74103. *
  74104. * @param {ASTNode} node - A node to check.
  74105. * @param {string} name - A name to check.
  74106. * @returns {boolean} `true` if the node is a Identifier node of the name.
  74107. */
  74108. function isIdentifier(node, name) {
  74109. return node.type === "Identifier" && node.name === name;
  74110. }
  74111. /**
  74112. * Checks a given node is a Literal node of the specified string value.
  74113. *
  74114. * @param {ASTNode} node - A node to check.
  74115. * @param {string} name - A name to check.
  74116. * @returns {boolean} `true` if the node is a Literal node of the name.
  74117. */
  74118. function isConstant(node, name) {
  74119. switch (node.type) {
  74120. case "Literal":
  74121. return node.value === name;
  74122. case "TemplateLiteral":
  74123. return node.expressions.length === 0 && node.quasis[0].value.cooked === name;
  74124. default:
  74125. return false;
  74126. }
  74127. }
  74128. /**
  74129. * Checks a given node is a MemberExpression node which has the specified name's
  74130. * property.
  74131. *
  74132. * @param {ASTNode} node - A node to check.
  74133. * @param {string} name - A name to check.
  74134. * @returns {boolean} `true` if the node is a MemberExpression node which has
  74135. * the specified name's property
  74136. */
  74137. function isMember(node, name) {
  74138. return node.type === "MemberExpression" && (node.computed ? isConstant : isIdentifier)(node.property, name);
  74139. }
  74140. //------------------------------------------------------------------------------
  74141. // Rule Definition
  74142. //------------------------------------------------------------------------------
  74143. module.exports = {
  74144. meta: {
  74145. type: "suggestion",
  74146. docs: {
  74147. description: "disallow the use of `eval()`",
  74148. category: "Best Practices",
  74149. recommended: false,
  74150. url: "https://eslint.org/docs/rules/no-eval"
  74151. },
  74152. schema: [{
  74153. type: "object",
  74154. properties: {
  74155. allowIndirect: { type: "boolean" }
  74156. },
  74157. additionalProperties: false
  74158. }],
  74159. messages: {
  74160. unexpected: "eval can be harmful."
  74161. }
  74162. },
  74163. create: function create(context) {
  74164. var allowIndirect = Boolean(context.options[0] && context.options[0].allowIndirect);
  74165. var sourceCode = context.getSourceCode();
  74166. var funcInfo = null;
  74167. /**
  74168. * Pushs a variable scope (Program or Function) information to the stack.
  74169. *
  74170. * This is used in order to check whether or not `this` binding is a
  74171. * reference to the global object.
  74172. *
  74173. * @param {ASTNode} node - A node of the scope. This is one of Program,
  74174. * FunctionDeclaration, FunctionExpression, and ArrowFunctionExpression.
  74175. * @returns {void}
  74176. */
  74177. function enterVarScope(node) {
  74178. var strict = context.getScope().isStrict;
  74179. funcInfo = {
  74180. upper: funcInfo,
  74181. node: node,
  74182. strict: strict,
  74183. defaultThis: false,
  74184. initialized: strict
  74185. };
  74186. }
  74187. /**
  74188. * Pops a variable scope from the stack.
  74189. *
  74190. * @returns {void}
  74191. */
  74192. function exitVarScope() {
  74193. funcInfo = funcInfo.upper;
  74194. }
  74195. /**
  74196. * Reports a given node.
  74197. *
  74198. * `node` is `Identifier` or `MemberExpression`.
  74199. * The parent of `node` might be `CallExpression`.
  74200. *
  74201. * The location of the report is always `eval` `Identifier` (or possibly
  74202. * `Literal`). The type of the report is `CallExpression` if the parent is
  74203. * `CallExpression`. Otherwise, it's the given node type.
  74204. *
  74205. * @param {ASTNode} node - A node to report.
  74206. * @returns {void}
  74207. */
  74208. function report(node) {
  74209. var parent = node.parent;
  74210. var locationNode = node.type === "MemberExpression" ? node.property : node;
  74211. var reportNode = parent.type === "CallExpression" && parent.callee === node ? parent : node;
  74212. context.report({
  74213. node: reportNode,
  74214. loc: locationNode.loc.start,
  74215. messageId: "unexpected"
  74216. });
  74217. }
  74218. /**
  74219. * Reports accesses of `eval` via the global object.
  74220. *
  74221. * @param {eslint-scope.Scope} globalScope - The global scope.
  74222. * @returns {void}
  74223. */
  74224. function reportAccessingEvalViaGlobalObject(globalScope) {
  74225. for (var i = 0; i < candidatesOfGlobalObject.length; ++i) {
  74226. var name = candidatesOfGlobalObject[i];
  74227. var variable = astUtils.getVariableByName(globalScope, name);
  74228. if (!variable) {
  74229. continue;
  74230. }
  74231. var references = variable.references;
  74232. for (var j = 0; j < references.length; ++j) {
  74233. var identifier = references[j].identifier;
  74234. var node = identifier.parent;
  74235. // To detect code like `window.window.eval`.
  74236. while (isMember(node, name)) {
  74237. node = node.parent;
  74238. }
  74239. // Reports.
  74240. if (isMember(node, "eval")) {
  74241. report(node);
  74242. }
  74243. }
  74244. }
  74245. }
  74246. /**
  74247. * Reports all accesses of `eval` (excludes direct calls to eval).
  74248. *
  74249. * @param {eslint-scope.Scope} globalScope - The global scope.
  74250. * @returns {void}
  74251. */
  74252. function reportAccessingEval(globalScope) {
  74253. var variable = astUtils.getVariableByName(globalScope, "eval");
  74254. if (!variable) {
  74255. return;
  74256. }
  74257. var references = variable.references;
  74258. for (var i = 0; i < references.length; ++i) {
  74259. var reference = references[i];
  74260. var id = reference.identifier;
  74261. if (id.name === "eval" && !astUtils.isCallee(id)) {
  74262. // Is accessing to eval (excludes direct calls to eval)
  74263. report(id);
  74264. }
  74265. }
  74266. }
  74267. if (allowIndirect) {
  74268. // Checks only direct calls to eval. It's simple!
  74269. return {
  74270. "CallExpression:exit": function CallExpressionExit(node) {
  74271. var callee = node.callee;
  74272. if (isIdentifier(callee, "eval")) {
  74273. report(callee);
  74274. }
  74275. }
  74276. };
  74277. }
  74278. return {
  74279. "CallExpression:exit": function CallExpressionExit(node) {
  74280. var callee = node.callee;
  74281. if (isIdentifier(callee, "eval")) {
  74282. report(callee);
  74283. }
  74284. },
  74285. Program: function Program(node) {
  74286. var scope = context.getScope(),
  74287. features = context.parserOptions.ecmaFeatures || {},
  74288. strict = scope.isStrict || node.sourceType === "module" || features.globalReturn && scope.childScopes[0].isStrict;
  74289. funcInfo = {
  74290. upper: null,
  74291. node: node,
  74292. strict: strict,
  74293. defaultThis: true,
  74294. initialized: true
  74295. };
  74296. },
  74297. "Program:exit": function ProgramExit() {
  74298. var globalScope = context.getScope();
  74299. exitVarScope();
  74300. reportAccessingEval(globalScope);
  74301. reportAccessingEvalViaGlobalObject(globalScope);
  74302. },
  74303. FunctionDeclaration: enterVarScope,
  74304. "FunctionDeclaration:exit": exitVarScope,
  74305. FunctionExpression: enterVarScope,
  74306. "FunctionExpression:exit": exitVarScope,
  74307. ArrowFunctionExpression: enterVarScope,
  74308. "ArrowFunctionExpression:exit": exitVarScope,
  74309. ThisExpression: function ThisExpression(node) {
  74310. if (!isMember(node.parent, "eval")) {
  74311. return;
  74312. }
  74313. /*
  74314. * `this.eval` is found.
  74315. * Checks whether or not the value of `this` is the global object.
  74316. */
  74317. if (!funcInfo.initialized) {
  74318. funcInfo.initialized = true;
  74319. funcInfo.defaultThis = astUtils.isDefaultThisBinding(funcInfo.node, sourceCode);
  74320. }
  74321. if (!funcInfo.strict && funcInfo.defaultThis) {
  74322. // `this.eval` is possible built-in `eval`.
  74323. report(node.parent);
  74324. }
  74325. }
  74326. };
  74327. }
  74328. };
  74329. },{"../util/ast-utils":405}],229:[function(require,module,exports){
  74330. /**
  74331. * @fileoverview Rule to flag assignment of the exception parameter
  74332. * @author Stephen Murray <spmurrayzzz>
  74333. */
  74334. "use strict";
  74335. var astUtils = require("../util/ast-utils");
  74336. //------------------------------------------------------------------------------
  74337. // Rule Definition
  74338. //------------------------------------------------------------------------------
  74339. module.exports = {
  74340. meta: {
  74341. type: "problem",
  74342. docs: {
  74343. description: "disallow reassigning exceptions in `catch` clauses",
  74344. category: "Possible Errors",
  74345. recommended: true,
  74346. url: "https://eslint.org/docs/rules/no-ex-assign"
  74347. },
  74348. schema: [],
  74349. messages: {
  74350. unexpected: "Do not assign to the exception parameter."
  74351. }
  74352. },
  74353. create: function create(context) {
  74354. /**
  74355. * Finds and reports references that are non initializer and writable.
  74356. * @param {Variable} variable - A variable to check.
  74357. * @returns {void}
  74358. */
  74359. function checkVariable(variable) {
  74360. astUtils.getModifyingReferences(variable.references).forEach(function (reference) {
  74361. context.report({ node: reference.identifier, messageId: "unexpected" });
  74362. });
  74363. }
  74364. return {
  74365. CatchClause: function CatchClause(node) {
  74366. context.getDeclaredVariables(node).forEach(checkVariable);
  74367. }
  74368. };
  74369. }
  74370. };
  74371. },{"../util/ast-utils":405}],230:[function(require,module,exports){
  74372. /**
  74373. * @fileoverview Rule to flag adding properties to native object's prototypes.
  74374. * @author David Nelson
  74375. */
  74376. "use strict";
  74377. //------------------------------------------------------------------------------
  74378. // Requirements
  74379. //------------------------------------------------------------------------------
  74380. var astUtils = require("../util/ast-utils");
  74381. var globals = require("globals");
  74382. //------------------------------------------------------------------------------
  74383. // Helpers
  74384. //------------------------------------------------------------------------------
  74385. var propertyDefinitionMethods = new Set(["defineProperty", "defineProperties"]);
  74386. //------------------------------------------------------------------------------
  74387. // Rule Definition
  74388. //------------------------------------------------------------------------------
  74389. module.exports = {
  74390. meta: {
  74391. type: "suggestion",
  74392. docs: {
  74393. description: "disallow extending native types",
  74394. category: "Best Practices",
  74395. recommended: false,
  74396. url: "https://eslint.org/docs/rules/no-extend-native"
  74397. },
  74398. schema: [{
  74399. type: "object",
  74400. properties: {
  74401. exceptions: {
  74402. type: "array",
  74403. items: {
  74404. type: "string"
  74405. },
  74406. uniqueItems: true
  74407. }
  74408. },
  74409. additionalProperties: false
  74410. }],
  74411. messages: {
  74412. unexpected: "{{builtin}} prototype is read only, properties should not be added."
  74413. }
  74414. },
  74415. create: function create(context) {
  74416. var config = context.options[0] || {};
  74417. var exceptions = new Set(config.exceptions || []);
  74418. var modifiedBuiltins = new Set(Object.keys(globals.builtin).filter(function (builtin) {
  74419. return builtin[0].toUpperCase() === builtin[0];
  74420. }).filter(function (builtin) {
  74421. return !exceptions.has(builtin);
  74422. }));
  74423. /**
  74424. * Reports a lint error for the given node.
  74425. * @param {ASTNode} node The node to report.
  74426. * @param {string} builtin The name of the native builtin being extended.
  74427. * @returns {void}
  74428. */
  74429. function reportNode(node, builtin) {
  74430. context.report({
  74431. node: node,
  74432. messageId: "unexpected",
  74433. data: {
  74434. builtin: builtin
  74435. }
  74436. });
  74437. }
  74438. /**
  74439. * Check to see if the `prototype` property of the given object
  74440. * identifier node is being accessed.
  74441. * @param {ASTNode} identifierNode The Identifier representing the object
  74442. * to check.
  74443. * @returns {boolean} True if the identifier is the object of a
  74444. * MemberExpression and its `prototype` property is being accessed,
  74445. * false otherwise.
  74446. */
  74447. function isPrototypePropertyAccessed(identifierNode) {
  74448. return Boolean(identifierNode && identifierNode.parent && identifierNode.parent.type === "MemberExpression" && identifierNode.parent.object === identifierNode && astUtils.getStaticPropertyName(identifierNode.parent) === "prototype");
  74449. }
  74450. /**
  74451. * Checks that an identifier is an object of a prototype whose member
  74452. * is being assigned in an AssignmentExpression.
  74453. * Example: Object.prototype.foo = "bar"
  74454. * @param {ASTNode} identifierNode The identifier to check.
  74455. * @returns {boolean} True if the identifier's prototype is modified.
  74456. */
  74457. function isInPrototypePropertyAssignment(identifierNode) {
  74458. return Boolean(isPrototypePropertyAccessed(identifierNode) && identifierNode.parent.parent.type === "MemberExpression" && identifierNode.parent.parent.parent.type === "AssignmentExpression" && identifierNode.parent.parent.parent.left === identifierNode.parent.parent);
  74459. }
  74460. /**
  74461. * Checks that an identifier is an object of a prototype whose member
  74462. * is being extended via the Object.defineProperty() or
  74463. * Object.defineProperties() methods.
  74464. * Example: Object.defineProperty(Array.prototype, "foo", ...)
  74465. * Example: Object.defineProperties(Array.prototype, ...)
  74466. * @param {ASTNode} identifierNode The identifier to check.
  74467. * @returns {boolean} True if the identifier's prototype is modified.
  74468. */
  74469. function isInDefinePropertyCall(identifierNode) {
  74470. return Boolean(isPrototypePropertyAccessed(identifierNode) && identifierNode.parent.parent.type === "CallExpression" && identifierNode.parent.parent.arguments[0] === identifierNode.parent && identifierNode.parent.parent.callee.type === "MemberExpression" && identifierNode.parent.parent.callee.object.type === "Identifier" && identifierNode.parent.parent.callee.object.name === "Object" && identifierNode.parent.parent.callee.property.type === "Identifier" && propertyDefinitionMethods.has(identifierNode.parent.parent.callee.property.name));
  74471. }
  74472. /**
  74473. * Check to see if object prototype access is part of a prototype
  74474. * extension. There are three ways a prototype can be extended:
  74475. * 1. Assignment to prototype property (Object.prototype.foo = 1)
  74476. * 2. Object.defineProperty()/Object.defineProperties() on a prototype
  74477. * If prototype extension is detected, report the AssignmentExpression
  74478. * or CallExpression node.
  74479. * @param {ASTNode} identifierNode The Identifier representing the object
  74480. * which prototype is being accessed and possibly extended.
  74481. * @returns {void}
  74482. */
  74483. function checkAndReportPrototypeExtension(identifierNode) {
  74484. if (isInPrototypePropertyAssignment(identifierNode)) {
  74485. // Identifier --> MemberExpression --> MemberExpression --> AssignmentExpression
  74486. reportNode(identifierNode.parent.parent.parent, identifierNode.name);
  74487. } else if (isInDefinePropertyCall(identifierNode)) {
  74488. // Identifier --> MemberExpression --> CallExpression
  74489. reportNode(identifierNode.parent.parent, identifierNode.name);
  74490. }
  74491. }
  74492. return {
  74493. "Program:exit": function ProgramExit() {
  74494. var globalScope = context.getScope();
  74495. modifiedBuiltins.forEach(function (builtin) {
  74496. var builtinVar = globalScope.set.get(builtin);
  74497. if (builtinVar && builtinVar.references) {
  74498. builtinVar.references.map(function (ref) {
  74499. return ref.identifier;
  74500. }).forEach(checkAndReportPrototypeExtension);
  74501. }
  74502. });
  74503. }
  74504. };
  74505. }
  74506. };
  74507. },{"../util/ast-utils":405,"globals":85}],231:[function(require,module,exports){
  74508. /**
  74509. * @fileoverview Rule to flag unnecessary bind calls
  74510. * @author Bence Dányi <bence@danyi.me>
  74511. */
  74512. "use strict";
  74513. //------------------------------------------------------------------------------
  74514. // Requirements
  74515. //------------------------------------------------------------------------------
  74516. var astUtils = require("../util/ast-utils");
  74517. //------------------------------------------------------------------------------
  74518. // Helpers
  74519. //------------------------------------------------------------------------------
  74520. var SIDE_EFFECT_FREE_NODE_TYPES = new Set(["Literal", "Identifier", "ThisExpression", "FunctionExpression"]);
  74521. //------------------------------------------------------------------------------
  74522. // Rule Definition
  74523. //------------------------------------------------------------------------------
  74524. module.exports = {
  74525. meta: {
  74526. type: "suggestion",
  74527. docs: {
  74528. description: "disallow unnecessary calls to `.bind()`",
  74529. category: "Best Practices",
  74530. recommended: false,
  74531. url: "https://eslint.org/docs/rules/no-extra-bind"
  74532. },
  74533. schema: [],
  74534. fixable: "code",
  74535. messages: {
  74536. unexpected: "The function binding is unnecessary."
  74537. }
  74538. },
  74539. create: function create(context) {
  74540. var scopeInfo = null;
  74541. /**
  74542. * Checks if a node is free of side effects.
  74543. *
  74544. * This check is stricter than it needs to be, in order to keep the implementation simple.
  74545. *
  74546. * @param {ASTNode} node A node to check.
  74547. * @returns {boolean} True if the node is known to be side-effect free, false otherwise.
  74548. */
  74549. function isSideEffectFree(node) {
  74550. return SIDE_EFFECT_FREE_NODE_TYPES.has(node.type);
  74551. }
  74552. /**
  74553. * Reports a given function node.
  74554. *
  74555. * @param {ASTNode} node - A node to report. This is a FunctionExpression or
  74556. * an ArrowFunctionExpression.
  74557. * @returns {void}
  74558. */
  74559. function report(node) {
  74560. context.report({
  74561. node: node.parent.parent,
  74562. messageId: "unexpected",
  74563. loc: node.parent.property.loc.start,
  74564. fix: function fix(fixer) {
  74565. if (node.parent.parent.arguments.length && !isSideEffectFree(node.parent.parent.arguments[0])) {
  74566. return null;
  74567. }
  74568. var firstTokenToRemove = context.getSourceCode().getFirstTokenBetween(node.parent.object, node.parent.property, astUtils.isNotClosingParenToken);
  74569. return fixer.removeRange([firstTokenToRemove.range[0], node.parent.parent.range[1]]);
  74570. }
  74571. });
  74572. }
  74573. /**
  74574. * Checks whether or not a given function node is the callee of `.bind()`
  74575. * method.
  74576. *
  74577. * e.g. `(function() {}.bind(foo))`
  74578. *
  74579. * @param {ASTNode} node - A node to report. This is a FunctionExpression or
  74580. * an ArrowFunctionExpression.
  74581. * @returns {boolean} `true` if the node is the callee of `.bind()` method.
  74582. */
  74583. function isCalleeOfBindMethod(node) {
  74584. var parent = node.parent;
  74585. var grandparent = parent.parent;
  74586. return grandparent && grandparent.type === "CallExpression" && grandparent.callee === parent && grandparent.arguments.length === 1 && parent.type === "MemberExpression" && parent.object === node && astUtils.getStaticPropertyName(parent) === "bind";
  74587. }
  74588. /**
  74589. * Adds a scope information object to the stack.
  74590. *
  74591. * @param {ASTNode} node - A node to add. This node is a FunctionExpression
  74592. * or a FunctionDeclaration node.
  74593. * @returns {void}
  74594. */
  74595. function enterFunction(node) {
  74596. scopeInfo = {
  74597. isBound: isCalleeOfBindMethod(node),
  74598. thisFound: false,
  74599. upper: scopeInfo
  74600. };
  74601. }
  74602. /**
  74603. * Removes the scope information object from the top of the stack.
  74604. * At the same time, this reports the function node if the function has
  74605. * `.bind()` and the `this` keywords found.
  74606. *
  74607. * @param {ASTNode} node - A node to remove. This node is a
  74608. * FunctionExpression or a FunctionDeclaration node.
  74609. * @returns {void}
  74610. */
  74611. function exitFunction(node) {
  74612. if (scopeInfo.isBound && !scopeInfo.thisFound) {
  74613. report(node);
  74614. }
  74615. scopeInfo = scopeInfo.upper;
  74616. }
  74617. /**
  74618. * Reports a given arrow function if the function is callee of `.bind()`
  74619. * method.
  74620. *
  74621. * @param {ASTNode} node - A node to report. This node is an
  74622. * ArrowFunctionExpression.
  74623. * @returns {void}
  74624. */
  74625. function exitArrowFunction(node) {
  74626. if (isCalleeOfBindMethod(node)) {
  74627. report(node);
  74628. }
  74629. }
  74630. /**
  74631. * Set the mark as the `this` keyword was found in this scope.
  74632. *
  74633. * @returns {void}
  74634. */
  74635. function markAsThisFound() {
  74636. if (scopeInfo) {
  74637. scopeInfo.thisFound = true;
  74638. }
  74639. }
  74640. return {
  74641. "ArrowFunctionExpression:exit": exitArrowFunction,
  74642. FunctionDeclaration: enterFunction,
  74643. "FunctionDeclaration:exit": exitFunction,
  74644. FunctionExpression: enterFunction,
  74645. "FunctionExpression:exit": exitFunction,
  74646. ThisExpression: markAsThisFound
  74647. };
  74648. }
  74649. };
  74650. },{"../util/ast-utils":405}],232:[function(require,module,exports){
  74651. /**
  74652. * @fileoverview Rule to flag unnecessary double negation in Boolean contexts
  74653. * @author Brandon Mills
  74654. */
  74655. "use strict";
  74656. //------------------------------------------------------------------------------
  74657. // Requirements
  74658. //------------------------------------------------------------------------------
  74659. var astUtils = require("../util/ast-utils");
  74660. //------------------------------------------------------------------------------
  74661. // Rule Definition
  74662. //------------------------------------------------------------------------------
  74663. module.exports = {
  74664. meta: {
  74665. type: "suggestion",
  74666. docs: {
  74667. description: "disallow unnecessary boolean casts",
  74668. category: "Possible Errors",
  74669. recommended: true,
  74670. url: "https://eslint.org/docs/rules/no-extra-boolean-cast"
  74671. },
  74672. schema: [],
  74673. fixable: "code",
  74674. messages: {
  74675. unexpectedCall: "Redundant Boolean call.",
  74676. unexpectedNegation: "Redundant double negation."
  74677. }
  74678. },
  74679. create: function create(context) {
  74680. var sourceCode = context.getSourceCode();
  74681. // Node types which have a test which will coerce values to booleans.
  74682. var BOOLEAN_NODE_TYPES = ["IfStatement", "DoWhileStatement", "WhileStatement", "ConditionalExpression", "ForStatement"];
  74683. /**
  74684. * Check if a node is in a context where its value would be coerced to a boolean at runtime.
  74685. *
  74686. * @param {Object} node The node
  74687. * @param {Object} parent Its parent
  74688. * @returns {boolean} If it is in a boolean context
  74689. */
  74690. function isInBooleanContext(node, parent) {
  74691. return BOOLEAN_NODE_TYPES.indexOf(parent.type) !== -1 && node === parent.test ||
  74692. // !<bool>
  74693. parent.type === "UnaryExpression" && parent.operator === "!";
  74694. }
  74695. return {
  74696. UnaryExpression: function UnaryExpression(node) {
  74697. var ancestors = context.getAncestors(),
  74698. parent = ancestors.pop(),
  74699. grandparent = ancestors.pop();
  74700. // Exit early if it's guaranteed not to match
  74701. if (node.operator !== "!" || parent.type !== "UnaryExpression" || parent.operator !== "!") {
  74702. return;
  74703. }
  74704. if (isInBooleanContext(parent, grandparent) ||
  74705. // Boolean(<bool>) and new Boolean(<bool>)
  74706. (grandparent.type === "CallExpression" || grandparent.type === "NewExpression") && grandparent.callee.type === "Identifier" && grandparent.callee.name === "Boolean") {
  74707. context.report({
  74708. node: node,
  74709. messageId: "unexpectedNegation",
  74710. fix: function fix(fixer) {
  74711. return fixer.replaceText(parent, sourceCode.getText(node.argument));
  74712. }
  74713. });
  74714. }
  74715. },
  74716. CallExpression: function CallExpression(node) {
  74717. var parent = node.parent;
  74718. if (node.callee.type !== "Identifier" || node.callee.name !== "Boolean") {
  74719. return;
  74720. }
  74721. if (isInBooleanContext(node, parent)) {
  74722. context.report({
  74723. node: node,
  74724. messageId: "unexpectedCall",
  74725. fix: function fix(fixer) {
  74726. if (!node.arguments.length) {
  74727. return fixer.replaceText(parent, "true");
  74728. }
  74729. if (node.arguments.length > 1 || node.arguments[0].type === "SpreadElement") {
  74730. return null;
  74731. }
  74732. var argument = node.arguments[0];
  74733. if (astUtils.getPrecedence(argument) < astUtils.getPrecedence(node.parent)) {
  74734. return fixer.replaceText(node, "(" + sourceCode.getText(argument) + ")");
  74735. }
  74736. return fixer.replaceText(node, sourceCode.getText(argument));
  74737. }
  74738. });
  74739. }
  74740. }
  74741. };
  74742. }
  74743. };
  74744. },{"../util/ast-utils":405}],233:[function(require,module,exports){
  74745. /**
  74746. * @fileoverview Rule to disallow unnecessary labels
  74747. * @author Toru Nagashima
  74748. */
  74749. "use strict";
  74750. //------------------------------------------------------------------------------
  74751. // Requirements
  74752. //------------------------------------------------------------------------------
  74753. var astUtils = require("../util/ast-utils");
  74754. //------------------------------------------------------------------------------
  74755. // Rule Definition
  74756. //------------------------------------------------------------------------------
  74757. module.exports = {
  74758. meta: {
  74759. type: "suggestion",
  74760. docs: {
  74761. description: "disallow unnecessary labels",
  74762. category: "Best Practices",
  74763. recommended: false,
  74764. url: "https://eslint.org/docs/rules/no-extra-label"
  74765. },
  74766. schema: [],
  74767. fixable: "code",
  74768. messages: {
  74769. unexpected: "This label '{{name}}' is unnecessary."
  74770. }
  74771. },
  74772. create: function create(context) {
  74773. var sourceCode = context.getSourceCode();
  74774. var scopeInfo = null;
  74775. /**
  74776. * Creates a new scope with a breakable statement.
  74777. *
  74778. * @param {ASTNode} node - A node to create. This is a BreakableStatement.
  74779. * @returns {void}
  74780. */
  74781. function enterBreakableStatement(node) {
  74782. scopeInfo = {
  74783. label: node.parent.type === "LabeledStatement" ? node.parent.label : null,
  74784. breakable: true,
  74785. upper: scopeInfo
  74786. };
  74787. }
  74788. /**
  74789. * Removes the top scope of the stack.
  74790. *
  74791. * @returns {void}
  74792. */
  74793. function exitBreakableStatement() {
  74794. scopeInfo = scopeInfo.upper;
  74795. }
  74796. /**
  74797. * Creates a new scope with a labeled statement.
  74798. *
  74799. * This ignores it if the body is a breakable statement.
  74800. * In this case it's handled in the `enterBreakableStatement` function.
  74801. *
  74802. * @param {ASTNode} node - A node to create. This is a LabeledStatement.
  74803. * @returns {void}
  74804. */
  74805. function enterLabeledStatement(node) {
  74806. if (!astUtils.isBreakableStatement(node.body)) {
  74807. scopeInfo = {
  74808. label: node.label,
  74809. breakable: false,
  74810. upper: scopeInfo
  74811. };
  74812. }
  74813. }
  74814. /**
  74815. * Removes the top scope of the stack.
  74816. *
  74817. * This ignores it if the body is a breakable statement.
  74818. * In this case it's handled in the `exitBreakableStatement` function.
  74819. *
  74820. * @param {ASTNode} node - A node. This is a LabeledStatement.
  74821. * @returns {void}
  74822. */
  74823. function exitLabeledStatement(node) {
  74824. if (!astUtils.isBreakableStatement(node.body)) {
  74825. scopeInfo = scopeInfo.upper;
  74826. }
  74827. }
  74828. /**
  74829. * Reports a given control node if it's unnecessary.
  74830. *
  74831. * @param {ASTNode} node - A node. This is a BreakStatement or a
  74832. * ContinueStatement.
  74833. * @returns {void}
  74834. */
  74835. function reportIfUnnecessary(node) {
  74836. if (!node.label) {
  74837. return;
  74838. }
  74839. var labelNode = node.label;
  74840. for (var info = scopeInfo; info !== null; info = info.upper) {
  74841. if (info.breakable || info.label && info.label.name === labelNode.name) {
  74842. if (info.breakable && info.label && info.label.name === labelNode.name) {
  74843. context.report({
  74844. node: labelNode,
  74845. messageId: "unexpected",
  74846. data: labelNode,
  74847. fix: function fix(fixer) {
  74848. return fixer.removeRange([sourceCode.getFirstToken(node).range[1], labelNode.range[1]]);
  74849. }
  74850. });
  74851. }
  74852. return;
  74853. }
  74854. }
  74855. }
  74856. return {
  74857. WhileStatement: enterBreakableStatement,
  74858. "WhileStatement:exit": exitBreakableStatement,
  74859. DoWhileStatement: enterBreakableStatement,
  74860. "DoWhileStatement:exit": exitBreakableStatement,
  74861. ForStatement: enterBreakableStatement,
  74862. "ForStatement:exit": exitBreakableStatement,
  74863. ForInStatement: enterBreakableStatement,
  74864. "ForInStatement:exit": exitBreakableStatement,
  74865. ForOfStatement: enterBreakableStatement,
  74866. "ForOfStatement:exit": exitBreakableStatement,
  74867. SwitchStatement: enterBreakableStatement,
  74868. "SwitchStatement:exit": exitBreakableStatement,
  74869. LabeledStatement: enterLabeledStatement,
  74870. "LabeledStatement:exit": exitLabeledStatement,
  74871. BreakStatement: reportIfUnnecessary,
  74872. ContinueStatement: reportIfUnnecessary
  74873. };
  74874. }
  74875. };
  74876. },{"../util/ast-utils":405}],234:[function(require,module,exports){
  74877. /**
  74878. * @fileoverview Disallow parenthesising higher precedence subexpressions.
  74879. * @author Michael Ficarra
  74880. */
  74881. "use strict";
  74882. //------------------------------------------------------------------------------
  74883. // Rule Definition
  74884. //------------------------------------------------------------------------------
  74885. var astUtils = require("../util/ast-utils.js");
  74886. module.exports = {
  74887. meta: {
  74888. type: "layout",
  74889. docs: {
  74890. description: "disallow unnecessary parentheses",
  74891. category: "Possible Errors",
  74892. recommended: false,
  74893. url: "https://eslint.org/docs/rules/no-extra-parens"
  74894. },
  74895. fixable: "code",
  74896. schema: {
  74897. anyOf: [{
  74898. type: "array",
  74899. items: [{
  74900. enum: ["functions"]
  74901. }],
  74902. minItems: 0,
  74903. maxItems: 1
  74904. }, {
  74905. type: "array",
  74906. items: [{
  74907. enum: ["all"]
  74908. }, {
  74909. type: "object",
  74910. properties: {
  74911. conditionalAssign: { type: "boolean" },
  74912. nestedBinaryExpressions: { type: "boolean" },
  74913. returnAssign: { type: "boolean" },
  74914. ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] },
  74915. enforceForArrowConditionals: { type: "boolean" }
  74916. },
  74917. additionalProperties: false
  74918. }],
  74919. minItems: 0,
  74920. maxItems: 2
  74921. }]
  74922. },
  74923. messages: {
  74924. unexpected: "Unnecessary parentheses around expression."
  74925. }
  74926. },
  74927. create: function create(context) {
  74928. var sourceCode = context.getSourceCode();
  74929. var tokensToIgnore = new WeakSet();
  74930. var isParenthesised = astUtils.isParenthesised.bind(astUtils, sourceCode);
  74931. var precedence = astUtils.getPrecedence;
  74932. var ALL_NODES = context.options[0] !== "functions";
  74933. var EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false;
  74934. var NESTED_BINARY = ALL_NODES && context.options[1] && context.options[1].nestedBinaryExpressions === false;
  74935. var EXCEPT_RETURN_ASSIGN = ALL_NODES && context.options[1] && context.options[1].returnAssign === false;
  74936. var IGNORE_JSX = ALL_NODES && context.options[1] && context.options[1].ignoreJSX;
  74937. var IGNORE_ARROW_CONDITIONALS = ALL_NODES && context.options[1] && context.options[1].enforceForArrowConditionals === false;
  74938. var PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({ type: "AssignmentExpression" });
  74939. var PRECEDENCE_OF_UPDATE_EXPR = precedence({ type: "UpdateExpression" });
  74940. /**
  74941. * Determines if this rule should be enforced for a node given the current configuration.
  74942. * @param {ASTNode} node - The node to be checked.
  74943. * @returns {boolean} True if the rule should be enforced for this node.
  74944. * @private
  74945. */
  74946. function ruleApplies(node) {
  74947. if (node.type === "JSXElement" || node.type === "JSXFragment") {
  74948. var isSingleLine = node.loc.start.line === node.loc.end.line;
  74949. switch (IGNORE_JSX) {
  74950. // Exclude this JSX element from linting
  74951. case "all":
  74952. return false;
  74953. // Exclude this JSX element if it is multi-line element
  74954. case "multi-line":
  74955. return isSingleLine;
  74956. // Exclude this JSX element if it is single-line element
  74957. case "single-line":
  74958. return !isSingleLine;
  74959. // Nothing special to be done for JSX elements
  74960. case "none":
  74961. break;
  74962. // no default
  74963. }
  74964. }
  74965. return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
  74966. }
  74967. /**
  74968. * Determines if a node is surrounded by parentheses twice.
  74969. * @param {ASTNode} node - The node to be checked.
  74970. * @returns {boolean} True if the node is doubly parenthesised.
  74971. * @private
  74972. */
  74973. function isParenthesisedTwice(node) {
  74974. var previousToken = sourceCode.getTokenBefore(node, 1),
  74975. nextToken = sourceCode.getTokenAfter(node, 1);
  74976. return isParenthesised(node) && previousToken && nextToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
  74977. }
  74978. /**
  74979. * Determines if a node is surrounded by (potentially) invalid parentheses.
  74980. * @param {ASTNode} node - The node to be checked.
  74981. * @returns {boolean} True if the node is incorrectly parenthesised.
  74982. * @private
  74983. */
  74984. function hasExcessParens(node) {
  74985. return ruleApplies(node) && isParenthesised(node);
  74986. }
  74987. /**
  74988. * Determines if a node that is expected to be parenthesised is surrounded by
  74989. * (potentially) invalid extra parentheses.
  74990. * @param {ASTNode} node - The node to be checked.
  74991. * @returns {boolean} True if the node is has an unexpected extra pair of parentheses.
  74992. * @private
  74993. */
  74994. function hasDoubleExcessParens(node) {
  74995. return ruleApplies(node) && isParenthesisedTwice(node);
  74996. }
  74997. /**
  74998. * Determines if a node test expression is allowed to have a parenthesised assignment
  74999. * @param {ASTNode} node - The node to be checked.
  75000. * @returns {boolean} True if the assignment can be parenthesised.
  75001. * @private
  75002. */
  75003. function isCondAssignException(node) {
  75004. return EXCEPT_COND_ASSIGN && node.test.type === "AssignmentExpression";
  75005. }
  75006. /**
  75007. * Determines if a node is in a return statement
  75008. * @param {ASTNode} node - The node to be checked.
  75009. * @returns {boolean} True if the node is in a return statement.
  75010. * @private
  75011. */
  75012. function isInReturnStatement(node) {
  75013. for (var currentNode = node; currentNode; currentNode = currentNode.parent) {
  75014. if (currentNode.type === "ReturnStatement" || currentNode.type === "ArrowFunctionExpression" && currentNode.body.type !== "BlockStatement") {
  75015. return true;
  75016. }
  75017. }
  75018. return false;
  75019. }
  75020. /**
  75021. * Determines if a constructor function is newed-up with parens
  75022. * @param {ASTNode} newExpression - The NewExpression node to be checked.
  75023. * @returns {boolean} True if the constructor is called with parens.
  75024. * @private
  75025. */
  75026. function isNewExpressionWithParens(newExpression) {
  75027. var lastToken = sourceCode.getLastToken(newExpression);
  75028. var penultimateToken = sourceCode.getTokenBefore(lastToken);
  75029. return newExpression.arguments.length > 0 || astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClosingParenToken(lastToken);
  75030. }
  75031. /**
  75032. * Determines if a node is or contains an assignment expression
  75033. * @param {ASTNode} node - The node to be checked.
  75034. * @returns {boolean} True if the node is or contains an assignment expression.
  75035. * @private
  75036. */
  75037. function containsAssignment(node) {
  75038. if (node.type === "AssignmentExpression") {
  75039. return true;
  75040. }
  75041. if (node.type === "ConditionalExpression" && (node.consequent.type === "AssignmentExpression" || node.alternate.type === "AssignmentExpression")) {
  75042. return true;
  75043. }
  75044. if (node.left && node.left.type === "AssignmentExpression" || node.right && node.right.type === "AssignmentExpression") {
  75045. return true;
  75046. }
  75047. return false;
  75048. }
  75049. /**
  75050. * Determines if a node is contained by or is itself a return statement and is allowed to have a parenthesised assignment
  75051. * @param {ASTNode} node - The node to be checked.
  75052. * @returns {boolean} True if the assignment can be parenthesised.
  75053. * @private
  75054. */
  75055. function isReturnAssignException(node) {
  75056. if (!EXCEPT_RETURN_ASSIGN || !isInReturnStatement(node)) {
  75057. return false;
  75058. }
  75059. if (node.type === "ReturnStatement") {
  75060. return node.argument && containsAssignment(node.argument);
  75061. }
  75062. if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") {
  75063. return containsAssignment(node.body);
  75064. }
  75065. return containsAssignment(node);
  75066. }
  75067. /**
  75068. * Determines if a node following a [no LineTerminator here] restriction is
  75069. * surrounded by (potentially) invalid extra parentheses.
  75070. * @param {Token} token - The token preceding the [no LineTerminator here] restriction.
  75071. * @param {ASTNode} node - The node to be checked.
  75072. * @returns {boolean} True if the node is incorrectly parenthesised.
  75073. * @private
  75074. */
  75075. function hasExcessParensNoLineTerminator(token, node) {
  75076. if (token.loc.end.line === node.loc.start.line) {
  75077. return hasExcessParens(node);
  75078. }
  75079. return hasDoubleExcessParens(node);
  75080. }
  75081. /**
  75082. * Determines whether a node should be preceded by an additional space when removing parens
  75083. * @param {ASTNode} node node to evaluate; must be surrounded by parentheses
  75084. * @returns {boolean} `true` if a space should be inserted before the node
  75085. * @private
  75086. */
  75087. function requiresLeadingSpace(node) {
  75088. var leftParenToken = sourceCode.getTokenBefore(node);
  75089. var tokenBeforeLeftParen = sourceCode.getTokenBefore(node, 1);
  75090. var firstToken = sourceCode.getFirstToken(node);
  75091. return tokenBeforeLeftParen && tokenBeforeLeftParen.range[1] === leftParenToken.range[0] && leftParenToken.range[1] === firstToken.range[0] && !astUtils.canTokensBeAdjacent(tokenBeforeLeftParen, firstToken);
  75092. }
  75093. /**
  75094. * Determines whether a node should be followed by an additional space when removing parens
  75095. * @param {ASTNode} node node to evaluate; must be surrounded by parentheses
  75096. * @returns {boolean} `true` if a space should be inserted after the node
  75097. * @private
  75098. */
  75099. function requiresTrailingSpace(node) {
  75100. var nextTwoTokens = sourceCode.getTokensAfter(node, { count: 2 });
  75101. var rightParenToken = nextTwoTokens[0];
  75102. var tokenAfterRightParen = nextTwoTokens[1];
  75103. var tokenBeforeRightParen = sourceCode.getLastToken(node);
  75104. return rightParenToken && tokenAfterRightParen && !sourceCode.isSpaceBetweenTokens(rightParenToken, tokenAfterRightParen) && !astUtils.canTokensBeAdjacent(tokenBeforeRightParen, tokenAfterRightParen);
  75105. }
  75106. /**
  75107. * Determines if a given expression node is an IIFE
  75108. * @param {ASTNode} node The node to check
  75109. * @returns {boolean} `true` if the given node is an IIFE
  75110. */
  75111. function isIIFE(node) {
  75112. return node.type === "CallExpression" && node.callee.type === "FunctionExpression";
  75113. }
  75114. /**
  75115. * Report the node
  75116. * @param {ASTNode} node node to evaluate
  75117. * @returns {void}
  75118. * @private
  75119. */
  75120. function report(node) {
  75121. var leftParenToken = sourceCode.getTokenBefore(node);
  75122. var rightParenToken = sourceCode.getTokenAfter(node);
  75123. if (!isParenthesisedTwice(node)) {
  75124. if (tokensToIgnore.has(sourceCode.getFirstToken(node))) {
  75125. return;
  75126. }
  75127. if (isIIFE(node) && !isParenthesised(node.callee)) {
  75128. return;
  75129. }
  75130. }
  75131. context.report({
  75132. node: node,
  75133. loc: leftParenToken.loc.start,
  75134. messageId: "unexpected",
  75135. fix: function fix(fixer) {
  75136. var parenthesizedSource = sourceCode.text.slice(leftParenToken.range[1], rightParenToken.range[0]);
  75137. return fixer.replaceTextRange([leftParenToken.range[0], rightParenToken.range[1]], (requiresLeadingSpace(node) ? " " : "") + parenthesizedSource + (requiresTrailingSpace(node) ? " " : ""));
  75138. }
  75139. });
  75140. }
  75141. /**
  75142. * Evaluate Unary update
  75143. * @param {ASTNode} node node to evaluate
  75144. * @returns {void}
  75145. * @private
  75146. */
  75147. function checkUnaryUpdate(node) {
  75148. if (node.type === "UnaryExpression" && node.argument.type === "BinaryExpression" && node.argument.operator === "**") {
  75149. return;
  75150. }
  75151. if (hasExcessParens(node.argument) && precedence(node.argument) >= precedence(node)) {
  75152. report(node.argument);
  75153. }
  75154. }
  75155. /**
  75156. * Check if a member expression contains a call expression
  75157. * @param {ASTNode} node MemberExpression node to evaluate
  75158. * @returns {boolean} true if found, false if not
  75159. */
  75160. function doesMemberExpressionContainCallExpression(node) {
  75161. var currentNode = node.object;
  75162. var currentNodeType = node.object.type;
  75163. while (currentNodeType === "MemberExpression") {
  75164. currentNode = currentNode.object;
  75165. currentNodeType = currentNode.type;
  75166. }
  75167. return currentNodeType === "CallExpression";
  75168. }
  75169. /**
  75170. * Evaluate a new call
  75171. * @param {ASTNode} node node to evaluate
  75172. * @returns {void}
  75173. * @private
  75174. */
  75175. function checkCallNew(node) {
  75176. var callee = node.callee;
  75177. if (hasExcessParens(callee) && precedence(callee) >= precedence(node)) {
  75178. var hasNewParensException = callee.type === "NewExpression" && !isNewExpressionWithParens(callee);
  75179. if (hasDoubleExcessParens(callee) || !isIIFE(node) && !hasNewParensException && !(
  75180. /*
  75181. * Allow extra parens around a new expression if
  75182. * there are intervening parentheses.
  75183. */
  75184. callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee))) {
  75185. report(node.callee);
  75186. }
  75187. }
  75188. if (node.arguments.length === 1) {
  75189. if (hasDoubleExcessParens(node.arguments[0]) && precedence(node.arguments[0]) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) {
  75190. report(node.arguments[0]);
  75191. }
  75192. } else {
  75193. node.arguments.filter(function (arg) {
  75194. return hasExcessParens(arg) && precedence(arg) >= PRECEDENCE_OF_ASSIGNMENT_EXPR;
  75195. }).forEach(report);
  75196. }
  75197. }
  75198. /**
  75199. * Evaluate binary logicals
  75200. * @param {ASTNode} node node to evaluate
  75201. * @returns {void}
  75202. * @private
  75203. */
  75204. function checkBinaryLogical(node) {
  75205. var prec = precedence(node);
  75206. var leftPrecedence = precedence(node.left);
  75207. var rightPrecedence = precedence(node.right);
  75208. var isExponentiation = node.operator === "**";
  75209. var shouldSkipLeft = NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression") || node.left.type === "UnaryExpression" && isExponentiation;
  75210. var shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression");
  75211. if (!shouldSkipLeft && hasExcessParens(node.left) && (leftPrecedence > prec || leftPrecedence === prec && !isExponentiation)) {
  75212. report(node.left);
  75213. }
  75214. if (!shouldSkipRight && hasExcessParens(node.right) && (rightPrecedence > prec || rightPrecedence === prec && isExponentiation)) {
  75215. report(node.right);
  75216. }
  75217. }
  75218. /**
  75219. * Check the parentheses around the super class of the given class definition.
  75220. * @param {ASTNode} node The node of class declarations to check.
  75221. * @returns {void}
  75222. */
  75223. function checkClass(node) {
  75224. if (!node.superClass) {
  75225. return;
  75226. }
  75227. /*
  75228. * If `node.superClass` is a LeftHandSideExpression, parentheses are extra.
  75229. * Otherwise, parentheses are needed.
  75230. */
  75231. var hasExtraParens = precedence(node.superClass) > PRECEDENCE_OF_UPDATE_EXPR ? hasExcessParens(node.superClass) : hasDoubleExcessParens(node.superClass);
  75232. if (hasExtraParens) {
  75233. report(node.superClass);
  75234. }
  75235. }
  75236. /**
  75237. * Check the parentheses around the argument of the given spread operator.
  75238. * @param {ASTNode} node The node of spread elements/properties to check.
  75239. * @returns {void}
  75240. */
  75241. function checkSpreadOperator(node) {
  75242. var hasExtraParens = precedence(node.argument) >= PRECEDENCE_OF_ASSIGNMENT_EXPR ? hasExcessParens(node.argument) : hasDoubleExcessParens(node.argument);
  75243. if (hasExtraParens) {
  75244. report(node.argument);
  75245. }
  75246. }
  75247. /**
  75248. * Checks the parentheses for an ExpressionStatement or ExportDefaultDeclaration
  75249. * @param {ASTNode} node The ExpressionStatement.expression or ExportDefaultDeclaration.declaration node
  75250. * @returns {void}
  75251. */
  75252. function checkExpressionOrExportStatement(node) {
  75253. var firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node);
  75254. var secondToken = sourceCode.getTokenAfter(firstToken, astUtils.isNotOpeningParenToken);
  75255. var thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null;
  75256. if (astUtils.isOpeningParenToken(firstToken) && (astUtils.isOpeningBraceToken(secondToken) || secondToken.type === "Keyword" && (secondToken.value === "function" || secondToken.value === "class" || secondToken.value === "let" && astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(secondToken, astUtils.isNotClosingParenToken))) || secondToken && secondToken.type === "Identifier" && secondToken.value === "async" && thirdToken && thirdToken.type === "Keyword" && thirdToken.value === "function")) {
  75257. tokensToIgnore.add(secondToken);
  75258. }
  75259. if (hasExcessParens(node)) {
  75260. report(node);
  75261. }
  75262. }
  75263. return {
  75264. ArrayExpression: function ArrayExpression(node) {
  75265. node.elements.filter(function (e) {
  75266. return e && hasExcessParens(e) && precedence(e) >= PRECEDENCE_OF_ASSIGNMENT_EXPR;
  75267. }).forEach(report);
  75268. },
  75269. ArrowFunctionExpression: function ArrowFunctionExpression(node) {
  75270. if (isReturnAssignException(node)) {
  75271. return;
  75272. }
  75273. if (node.body.type === "ConditionalExpression" && IGNORE_ARROW_CONDITIONALS && !isParenthesisedTwice(node.body)) {
  75274. return;
  75275. }
  75276. if (node.body.type !== "BlockStatement") {
  75277. var firstBodyToken = sourceCode.getFirstToken(node.body, astUtils.isNotOpeningParenToken);
  75278. var tokenBeforeFirst = sourceCode.getTokenBefore(firstBodyToken);
  75279. if (astUtils.isOpeningParenToken(tokenBeforeFirst) && astUtils.isOpeningBraceToken(firstBodyToken)) {
  75280. tokensToIgnore.add(firstBodyToken);
  75281. }
  75282. if (hasExcessParens(node.body) && precedence(node.body) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) {
  75283. report(node.body);
  75284. }
  75285. }
  75286. },
  75287. AssignmentExpression: function AssignmentExpression(node) {
  75288. if (isReturnAssignException(node)) {
  75289. return;
  75290. }
  75291. if (hasExcessParens(node.right) && precedence(node.right) >= precedence(node)) {
  75292. report(node.right);
  75293. }
  75294. },
  75295. BinaryExpression: checkBinaryLogical,
  75296. CallExpression: checkCallNew,
  75297. ConditionalExpression: function ConditionalExpression(node) {
  75298. if (isReturnAssignException(node)) {
  75299. return;
  75300. }
  75301. if (hasExcessParens(node.test) && precedence(node.test) >= precedence({ type: "LogicalExpression", operator: "||" })) {
  75302. report(node.test);
  75303. }
  75304. if (hasExcessParens(node.consequent) && precedence(node.consequent) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) {
  75305. report(node.consequent);
  75306. }
  75307. if (hasExcessParens(node.alternate) && precedence(node.alternate) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) {
  75308. report(node.alternate);
  75309. }
  75310. },
  75311. DoWhileStatement: function DoWhileStatement(node) {
  75312. if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) {
  75313. report(node.test);
  75314. }
  75315. },
  75316. ExportDefaultDeclaration: function ExportDefaultDeclaration(node) {
  75317. return checkExpressionOrExportStatement(node.declaration);
  75318. },
  75319. ExpressionStatement: function ExpressionStatement(node) {
  75320. return checkExpressionOrExportStatement(node.expression);
  75321. },
  75322. "ForInStatement, ForOfStatement": function ForInStatementForOfStatement(node) {
  75323. if (node.left.type !== "VariableDeclarator") {
  75324. var firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken);
  75325. if (firstLeftToken.value === "let" && (
  75326. /*
  75327. * If `let` is the only thing on the left side of the loop, it's the loop variable: `for ((let) of foo);`
  75328. * Removing it will cause a syntax error, because it will be parsed as the start of a VariableDeclarator.
  75329. */
  75330. firstLeftToken.range[1] === node.left.range[1] || /*
  75331. * If `let` is followed by a `[` token, it's a property access on the `let` value: `for ((let[foo]) of bar);`
  75332. * Removing it will cause the property access to be parsed as a destructuring declaration of `foo` instead.
  75333. */
  75334. astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken)))) {
  75335. tokensToIgnore.add(firstLeftToken);
  75336. }
  75337. }
  75338. if (!(node.type === "ForOfStatement" && node.right.type === "SequenceExpression") && hasExcessParens(node.right)) {
  75339. report(node.right);
  75340. }
  75341. if (hasExcessParens(node.left)) {
  75342. report(node.left);
  75343. }
  75344. },
  75345. ForStatement: function ForStatement(node) {
  75346. if (node.init && hasExcessParens(node.init)) {
  75347. report(node.init);
  75348. }
  75349. if (node.test && hasExcessParens(node.test) && !isCondAssignException(node)) {
  75350. report(node.test);
  75351. }
  75352. if (node.update && hasExcessParens(node.update)) {
  75353. report(node.update);
  75354. }
  75355. },
  75356. IfStatement: function IfStatement(node) {
  75357. if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) {
  75358. report(node.test);
  75359. }
  75360. },
  75361. LogicalExpression: checkBinaryLogical,
  75362. MemberExpression: function MemberExpression(node) {
  75363. var nodeObjHasExcessParens = hasExcessParens(node.object);
  75364. if (nodeObjHasExcessParens && precedence(node.object) >= precedence(node) && (node.computed || !(astUtils.isDecimalInteger(node.object) ||
  75365. // RegExp literal is allowed to have parens (#1589)
  75366. node.object.type === "Literal" && node.object.regex))) {
  75367. report(node.object);
  75368. }
  75369. if (nodeObjHasExcessParens && node.object.type === "CallExpression" && node.parent.type !== "NewExpression") {
  75370. report(node.object);
  75371. }
  75372. if (node.computed && hasExcessParens(node.property)) {
  75373. report(node.property);
  75374. }
  75375. },
  75376. NewExpression: checkCallNew,
  75377. ObjectExpression: function ObjectExpression(node) {
  75378. node.properties.filter(function (property) {
  75379. var value = property.value;
  75380. return value && hasExcessParens(value) && precedence(value) >= PRECEDENCE_OF_ASSIGNMENT_EXPR;
  75381. }).forEach(function (property) {
  75382. return report(property.value);
  75383. });
  75384. },
  75385. ReturnStatement: function ReturnStatement(node) {
  75386. var returnToken = sourceCode.getFirstToken(node);
  75387. if (isReturnAssignException(node)) {
  75388. return;
  75389. }
  75390. if (node.argument && hasExcessParensNoLineTerminator(returnToken, node.argument) &&
  75391. // RegExp literal is allowed to have parens (#1589)
  75392. !(node.argument.type === "Literal" && node.argument.regex)) {
  75393. report(node.argument);
  75394. }
  75395. },
  75396. SequenceExpression: function SequenceExpression(node) {
  75397. node.expressions.filter(function (e) {
  75398. return hasExcessParens(e) && precedence(e) >= precedence(node);
  75399. }).forEach(report);
  75400. },
  75401. SwitchCase: function SwitchCase(node) {
  75402. if (node.test && hasExcessParens(node.test)) {
  75403. report(node.test);
  75404. }
  75405. },
  75406. SwitchStatement: function SwitchStatement(node) {
  75407. if (hasDoubleExcessParens(node.discriminant)) {
  75408. report(node.discriminant);
  75409. }
  75410. },
  75411. ThrowStatement: function ThrowStatement(node) {
  75412. var throwToken = sourceCode.getFirstToken(node);
  75413. if (hasExcessParensNoLineTerminator(throwToken, node.argument)) {
  75414. report(node.argument);
  75415. }
  75416. },
  75417. UnaryExpression: checkUnaryUpdate,
  75418. UpdateExpression: checkUnaryUpdate,
  75419. AwaitExpression: checkUnaryUpdate,
  75420. VariableDeclarator: function VariableDeclarator(node) {
  75421. if (node.init && hasExcessParens(node.init) && precedence(node.init) >= PRECEDENCE_OF_ASSIGNMENT_EXPR &&
  75422. // RegExp literal is allowed to have parens (#1589)
  75423. !(node.init.type === "Literal" && node.init.regex)) {
  75424. report(node.init);
  75425. }
  75426. },
  75427. WhileStatement: function WhileStatement(node) {
  75428. if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) {
  75429. report(node.test);
  75430. }
  75431. },
  75432. WithStatement: function WithStatement(node) {
  75433. if (hasDoubleExcessParens(node.object)) {
  75434. report(node.object);
  75435. }
  75436. },
  75437. YieldExpression: function YieldExpression(node) {
  75438. if (node.argument) {
  75439. var yieldToken = sourceCode.getFirstToken(node);
  75440. if (precedence(node.argument) >= precedence(node) && hasExcessParensNoLineTerminator(yieldToken, node.argument) || hasDoubleExcessParens(node.argument)) {
  75441. report(node.argument);
  75442. }
  75443. }
  75444. },
  75445. ClassDeclaration: checkClass,
  75446. ClassExpression: checkClass,
  75447. SpreadElement: checkSpreadOperator,
  75448. SpreadProperty: checkSpreadOperator,
  75449. ExperimentalSpreadProperty: checkSpreadOperator
  75450. };
  75451. }
  75452. };
  75453. },{"../util/ast-utils.js":405}],235:[function(require,module,exports){
  75454. /**
  75455. * @fileoverview Rule to flag use of unnecessary semicolons
  75456. * @author Nicholas C. Zakas
  75457. */
  75458. "use strict";
  75459. //------------------------------------------------------------------------------
  75460. // Requirements
  75461. //------------------------------------------------------------------------------
  75462. var FixTracker = require("../util/fix-tracker");
  75463. var astUtils = require("../util/ast-utils");
  75464. //------------------------------------------------------------------------------
  75465. // Rule Definition
  75466. //------------------------------------------------------------------------------
  75467. module.exports = {
  75468. meta: {
  75469. type: "suggestion",
  75470. docs: {
  75471. description: "disallow unnecessary semicolons",
  75472. category: "Possible Errors",
  75473. recommended: true,
  75474. url: "https://eslint.org/docs/rules/no-extra-semi"
  75475. },
  75476. fixable: "code",
  75477. schema: [],
  75478. messages: {
  75479. unexpected: "Unnecessary semicolon."
  75480. }
  75481. },
  75482. create: function create(context) {
  75483. var sourceCode = context.getSourceCode();
  75484. /**
  75485. * Reports an unnecessary semicolon error.
  75486. * @param {Node|Token} nodeOrToken - A node or a token to be reported.
  75487. * @returns {void}
  75488. */
  75489. function report(nodeOrToken) {
  75490. context.report({
  75491. node: nodeOrToken,
  75492. messageId: "unexpected",
  75493. fix: function fix(fixer) {
  75494. /*
  75495. * Expand the replacement range to include the surrounding
  75496. * tokens to avoid conflicting with semi.
  75497. * https://github.com/eslint/eslint/issues/7928
  75498. */
  75499. return new FixTracker(fixer, context.getSourceCode()).retainSurroundingTokens(nodeOrToken).remove(nodeOrToken);
  75500. }
  75501. });
  75502. }
  75503. /**
  75504. * Checks for a part of a class body.
  75505. * This checks tokens from a specified token to a next MethodDefinition or the end of class body.
  75506. *
  75507. * @param {Token} firstToken - The first token to check.
  75508. * @returns {void}
  75509. */
  75510. function checkForPartOfClassBody(firstToken) {
  75511. for (var token = firstToken; token.type === "Punctuator" && !astUtils.isClosingBraceToken(token); token = sourceCode.getTokenAfter(token)) {
  75512. if (astUtils.isSemicolonToken(token)) {
  75513. report(token);
  75514. }
  75515. }
  75516. }
  75517. return {
  75518. /**
  75519. * Reports this empty statement, except if the parent node is a loop.
  75520. * @param {Node} node - A EmptyStatement node to be reported.
  75521. * @returns {void}
  75522. */
  75523. EmptyStatement: function EmptyStatement(node) {
  75524. var parent = node.parent,
  75525. allowedParentTypes = ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement", "IfStatement", "LabeledStatement", "WithStatement"];
  75526. if (allowedParentTypes.indexOf(parent.type) === -1) {
  75527. report(node);
  75528. }
  75529. },
  75530. /**
  75531. * Checks tokens from the head of this class body to the first MethodDefinition or the end of this class body.
  75532. * @param {Node} node - A ClassBody node to check.
  75533. * @returns {void}
  75534. */
  75535. ClassBody: function ClassBody(node) {
  75536. checkForPartOfClassBody(sourceCode.getFirstToken(node, 1)); // 0 is `{`.
  75537. },
  75538. /**
  75539. * Checks tokens from this MethodDefinition to the next MethodDefinition or the end of this class body.
  75540. * @param {Node} node - A MethodDefinition node of the start point.
  75541. * @returns {void}
  75542. */
  75543. MethodDefinition: function MethodDefinition(node) {
  75544. checkForPartOfClassBody(sourceCode.getTokenAfter(node));
  75545. }
  75546. };
  75547. }
  75548. };
  75549. },{"../util/ast-utils":405,"../util/fix-tracker":407}],236:[function(require,module,exports){
  75550. /**
  75551. * @fileoverview Rule to flag fall-through cases in switch statements.
  75552. * @author Matt DuVall <http://mattduvall.com/>
  75553. */
  75554. "use strict";
  75555. //------------------------------------------------------------------------------
  75556. // Requirements
  75557. //------------------------------------------------------------------------------
  75558. var lodash = require("lodash");
  75559. //------------------------------------------------------------------------------
  75560. // Helpers
  75561. //------------------------------------------------------------------------------
  75562. var DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/i;
  75563. /**
  75564. * Checks whether or not a given node has a fallthrough comment.
  75565. * @param {ASTNode} node - A SwitchCase node to get comments.
  75566. * @param {RuleContext} context - A rule context which stores comments.
  75567. * @param {RegExp} fallthroughCommentPattern - A pattern to match comment to.
  75568. * @returns {boolean} `true` if the node has a valid fallthrough comment.
  75569. */
  75570. function hasFallthroughComment(node, context, fallthroughCommentPattern) {
  75571. var sourceCode = context.getSourceCode();
  75572. var comment = lodash.last(sourceCode.getCommentsBefore(node));
  75573. return Boolean(comment && fallthroughCommentPattern.test(comment.value));
  75574. }
  75575. /**
  75576. * Checks whether or not a given code path segment is reachable.
  75577. * @param {CodePathSegment} segment - A CodePathSegment to check.
  75578. * @returns {boolean} `true` if the segment is reachable.
  75579. */
  75580. function isReachable(segment) {
  75581. return segment.reachable;
  75582. }
  75583. /**
  75584. * Checks whether a node and a token are separated by blank lines
  75585. * @param {ASTNode} node - The node to check
  75586. * @param {Token} token - The token to compare against
  75587. * @returns {boolean} `true` if there are blank lines between node and token
  75588. */
  75589. function hasBlankLinesBetween(node, token) {
  75590. return token.loc.start.line > node.loc.end.line + 1;
  75591. }
  75592. //------------------------------------------------------------------------------
  75593. // Rule Definition
  75594. //------------------------------------------------------------------------------
  75595. module.exports = {
  75596. meta: {
  75597. type: "problem",
  75598. docs: {
  75599. description: "disallow fallthrough of `case` statements",
  75600. category: "Best Practices",
  75601. recommended: true,
  75602. url: "https://eslint.org/docs/rules/no-fallthrough"
  75603. },
  75604. schema: [{
  75605. type: "object",
  75606. properties: {
  75607. commentPattern: {
  75608. type: "string"
  75609. }
  75610. },
  75611. additionalProperties: false
  75612. }]
  75613. },
  75614. create: function create(context) {
  75615. var options = context.options[0] || {};
  75616. var currentCodePath = null;
  75617. var sourceCode = context.getSourceCode();
  75618. /*
  75619. * We need to use leading comments of the next SwitchCase node because
  75620. * trailing comments is wrong if semicolons are omitted.
  75621. */
  75622. var fallthroughCase = null;
  75623. var fallthroughCommentPattern = null;
  75624. if (options.commentPattern) {
  75625. fallthroughCommentPattern = new RegExp(options.commentPattern);
  75626. } else {
  75627. fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT;
  75628. }
  75629. return {
  75630. onCodePathStart: function onCodePathStart(codePath) {
  75631. currentCodePath = codePath;
  75632. },
  75633. onCodePathEnd: function onCodePathEnd() {
  75634. currentCodePath = currentCodePath.upper;
  75635. },
  75636. SwitchCase: function SwitchCase(node) {
  75637. /*
  75638. * Checks whether or not there is a fallthrough comment.
  75639. * And reports the previous fallthrough node if that does not exist.
  75640. */
  75641. if (fallthroughCase && !hasFallthroughComment(node, context, fallthroughCommentPattern)) {
  75642. context.report({
  75643. message: "Expected a 'break' statement before '{{type}}'.",
  75644. data: { type: node.test ? "case" : "default" },
  75645. node: node
  75646. });
  75647. }
  75648. fallthroughCase = null;
  75649. },
  75650. "SwitchCase:exit": function SwitchCaseExit(node) {
  75651. var nextToken = sourceCode.getTokenAfter(node);
  75652. /*
  75653. * `reachable` meant fall through because statements preceded by
  75654. * `break`, `return`, or `throw` are unreachable.
  75655. * And allows empty cases and the last case.
  75656. */
  75657. if (currentCodePath.currentSegments.some(isReachable) && (node.consequent.length > 0 || hasBlankLinesBetween(node, nextToken)) && lodash.last(node.parent.cases) !== node) {
  75658. fallthroughCase = node;
  75659. }
  75660. }
  75661. };
  75662. }
  75663. };
  75664. },{"lodash":92}],237:[function(require,module,exports){
  75665. /**
  75666. * @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal
  75667. * @author James Allardice
  75668. */
  75669. "use strict";
  75670. //------------------------------------------------------------------------------
  75671. // Requirements
  75672. //------------------------------------------------------------------------------
  75673. var astUtils = require("../util/ast-utils");
  75674. //------------------------------------------------------------------------------
  75675. // Rule Definition
  75676. //------------------------------------------------------------------------------
  75677. module.exports = {
  75678. meta: {
  75679. type: "suggestion",
  75680. docs: {
  75681. description: "disallow leading or trailing decimal points in numeric literals",
  75682. category: "Best Practices",
  75683. recommended: false,
  75684. url: "https://eslint.org/docs/rules/no-floating-decimal"
  75685. },
  75686. schema: [],
  75687. fixable: "code"
  75688. },
  75689. create: function create(context) {
  75690. var sourceCode = context.getSourceCode();
  75691. return {
  75692. Literal: function Literal(node) {
  75693. if (typeof node.value === "number") {
  75694. if (node.raw.startsWith(".")) {
  75695. context.report({
  75696. node: node,
  75697. message: "A leading decimal point can be confused with a dot.",
  75698. fix: function fix(fixer) {
  75699. var tokenBefore = sourceCode.getTokenBefore(node);
  75700. var needsSpaceBefore = tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, "0" + node.raw);
  75701. return fixer.insertTextBefore(node, needsSpaceBefore ? " 0" : "0");
  75702. }
  75703. });
  75704. }
  75705. if (node.raw.indexOf(".") === node.raw.length - 1) {
  75706. context.report({
  75707. node: node,
  75708. message: "A trailing decimal point can be confused with a dot.",
  75709. fix: function fix(fixer) {
  75710. return fixer.insertTextAfter(node, "0");
  75711. }
  75712. });
  75713. }
  75714. }
  75715. }
  75716. };
  75717. }
  75718. };
  75719. },{"../util/ast-utils":405}],238:[function(require,module,exports){
  75720. /**
  75721. * @fileoverview Rule to flag use of function declaration identifiers as variables.
  75722. * @author Ian Christian Myers
  75723. */
  75724. "use strict";
  75725. var astUtils = require("../util/ast-utils");
  75726. //------------------------------------------------------------------------------
  75727. // Rule Definition
  75728. //------------------------------------------------------------------------------
  75729. module.exports = {
  75730. meta: {
  75731. type: "problem",
  75732. docs: {
  75733. description: "disallow reassigning `function` declarations",
  75734. category: "Possible Errors",
  75735. recommended: true,
  75736. url: "https://eslint.org/docs/rules/no-func-assign"
  75737. },
  75738. schema: []
  75739. },
  75740. create: function create(context) {
  75741. /**
  75742. * Reports a reference if is non initializer and writable.
  75743. * @param {References} references - Collection of reference to check.
  75744. * @returns {void}
  75745. */
  75746. function checkReference(references) {
  75747. astUtils.getModifyingReferences(references).forEach(function (reference) {
  75748. context.report({ node: reference.identifier, message: "'{{name}}' is a function.", data: { name: reference.identifier.name } });
  75749. });
  75750. }
  75751. /**
  75752. * Finds and reports references that are non initializer and writable.
  75753. * @param {Variable} variable - A variable to check.
  75754. * @returns {void}
  75755. */
  75756. function checkVariable(variable) {
  75757. if (variable.defs[0].type === "FunctionName") {
  75758. checkReference(variable.references);
  75759. }
  75760. }
  75761. /**
  75762. * Checks parameters of a given function node.
  75763. * @param {ASTNode} node - A function node to check.
  75764. * @returns {void}
  75765. */
  75766. function checkForFunction(node) {
  75767. context.getDeclaredVariables(node).forEach(checkVariable);
  75768. }
  75769. return {
  75770. FunctionDeclaration: checkForFunction,
  75771. FunctionExpression: checkForFunction
  75772. };
  75773. }
  75774. };
  75775. },{"../util/ast-utils":405}],239:[function(require,module,exports){
  75776. /**
  75777. * @fileoverview Rule to disallow assignments to native objects or read-only global variables
  75778. * @author Ilya Volodin
  75779. */
  75780. "use strict";
  75781. //------------------------------------------------------------------------------
  75782. // Rule Definition
  75783. //------------------------------------------------------------------------------
  75784. module.exports = {
  75785. meta: {
  75786. type: "suggestion",
  75787. docs: {
  75788. description: "disallow assignments to native objects or read-only global variables",
  75789. category: "Best Practices",
  75790. recommended: true,
  75791. url: "https://eslint.org/docs/rules/no-global-assign"
  75792. },
  75793. schema: [{
  75794. type: "object",
  75795. properties: {
  75796. exceptions: {
  75797. type: "array",
  75798. items: { type: "string" },
  75799. uniqueItems: true
  75800. }
  75801. },
  75802. additionalProperties: false
  75803. }]
  75804. },
  75805. create: function create(context) {
  75806. var config = context.options[0];
  75807. var exceptions = config && config.exceptions || [];
  75808. /**
  75809. * Reports write references.
  75810. * @param {Reference} reference - A reference to check.
  75811. * @param {int} index - The index of the reference in the references.
  75812. * @param {Reference[]} references - The array that the reference belongs to.
  75813. * @returns {void}
  75814. */
  75815. function checkReference(reference, index, references) {
  75816. var identifier = reference.identifier;
  75817. if (reference.init === false && reference.isWrite() && (
  75818. /*
  75819. * Destructuring assignments can have multiple default value,
  75820. * so possibly there are multiple writeable references for the same identifier.
  75821. */
  75822. index === 0 || references[index - 1].identifier !== identifier)) {
  75823. context.report({
  75824. node: identifier,
  75825. message: "Read-only global '{{name}}' should not be modified.",
  75826. data: identifier
  75827. });
  75828. }
  75829. }
  75830. /**
  75831. * Reports write references if a given variable is read-only builtin.
  75832. * @param {Variable} variable - A variable to check.
  75833. * @returns {void}
  75834. */
  75835. function checkVariable(variable) {
  75836. if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
  75837. variable.references.forEach(checkReference);
  75838. }
  75839. }
  75840. return {
  75841. Program: function Program() {
  75842. var globalScope = context.getScope();
  75843. globalScope.variables.forEach(checkVariable);
  75844. }
  75845. };
  75846. }
  75847. };
  75848. },{}],240:[function(require,module,exports){
  75849. /**
  75850. * @fileoverview A rule to disallow the type conversions with shorter notations.
  75851. * @author Toru Nagashima
  75852. */
  75853. "use strict";
  75854. var astUtils = require("../util/ast-utils");
  75855. //------------------------------------------------------------------------------
  75856. // Helpers
  75857. //------------------------------------------------------------------------------
  75858. var INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/;
  75859. var ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
  75860. /**
  75861. * Parses and normalizes an option object.
  75862. * @param {Object} options - An option object to parse.
  75863. * @returns {Object} The parsed and normalized option object.
  75864. */
  75865. function parseOptions(options) {
  75866. return {
  75867. boolean: "boolean" in options ? Boolean(options.boolean) : true,
  75868. number: "number" in options ? Boolean(options.number) : true,
  75869. string: "string" in options ? Boolean(options.string) : true,
  75870. allow: options.allow || []
  75871. };
  75872. }
  75873. /**
  75874. * Checks whether or not a node is a double logical nigating.
  75875. * @param {ASTNode} node - An UnaryExpression node to check.
  75876. * @returns {boolean} Whether or not the node is a double logical nigating.
  75877. */
  75878. function isDoubleLogicalNegating(node) {
  75879. return node.operator === "!" && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
  75880. }
  75881. /**
  75882. * Checks whether or not a node is a binary negating of `.indexOf()` method calling.
  75883. * @param {ASTNode} node - An UnaryExpression node to check.
  75884. * @returns {boolean} Whether or not the node is a binary negating of `.indexOf()` method calling.
  75885. */
  75886. function isBinaryNegatingOfIndexOf(node) {
  75887. return node.operator === "~" && node.argument.type === "CallExpression" && node.argument.callee.type === "MemberExpression" && node.argument.callee.property.type === "Identifier" && INDEX_OF_PATTERN.test(node.argument.callee.property.name);
  75888. }
  75889. /**
  75890. * Checks whether or not a node is a multiplying by one.
  75891. * @param {BinaryExpression} node - A BinaryExpression node to check.
  75892. * @returns {boolean} Whether or not the node is a multiplying by one.
  75893. */
  75894. function isMultiplyByOne(node) {
  75895. return node.operator === "*" && (node.left.type === "Literal" && node.left.value === 1 || node.right.type === "Literal" && node.right.value === 1);
  75896. }
  75897. /**
  75898. * Checks whether the result of a node is numeric or not
  75899. * @param {ASTNode} node The node to test
  75900. * @returns {boolean} true if the node is a number literal or a `Number()`, `parseInt` or `parseFloat` call
  75901. */
  75902. function isNumeric(node) {
  75903. return node.type === "Literal" && typeof node.value === "number" || node.type === "CallExpression" && (node.callee.name === "Number" || node.callee.name === "parseInt" || node.callee.name === "parseFloat");
  75904. }
  75905. /**
  75906. * Returns the first non-numeric operand in a BinaryExpression. Designed to be
  75907. * used from bottom to up since it walks up the BinaryExpression trees using
  75908. * node.parent to find the result.
  75909. * @param {BinaryExpression} node The BinaryExpression node to be walked up on
  75910. * @returns {ASTNode|null} The first non-numeric item in the BinaryExpression tree or null
  75911. */
  75912. function getNonNumericOperand(node) {
  75913. var left = node.left,
  75914. right = node.right;
  75915. if (right.type !== "BinaryExpression" && !isNumeric(right)) {
  75916. return right;
  75917. }
  75918. if (left.type !== "BinaryExpression" && !isNumeric(left)) {
  75919. return left;
  75920. }
  75921. return null;
  75922. }
  75923. /**
  75924. * Checks whether a node is an empty string literal or not.
  75925. * @param {ASTNode} node The node to check.
  75926. * @returns {boolean} Whether or not the passed in node is an
  75927. * empty string literal or not.
  75928. */
  75929. function isEmptyString(node) {
  75930. return astUtils.isStringLiteral(node) && (node.value === "" || node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === "");
  75931. }
  75932. /**
  75933. * Checks whether or not a node is a concatenating with an empty string.
  75934. * @param {ASTNode} node - A BinaryExpression node to check.
  75935. * @returns {boolean} Whether or not the node is a concatenating with an empty string.
  75936. */
  75937. function isConcatWithEmptyString(node) {
  75938. return node.operator === "+" && (isEmptyString(node.left) && !astUtils.isStringLiteral(node.right) || isEmptyString(node.right) && !astUtils.isStringLiteral(node.left));
  75939. }
  75940. /**
  75941. * Checks whether or not a node is appended with an empty string.
  75942. * @param {ASTNode} node - An AssignmentExpression node to check.
  75943. * @returns {boolean} Whether or not the node is appended with an empty string.
  75944. */
  75945. function isAppendEmptyString(node) {
  75946. return node.operator === "+=" && isEmptyString(node.right);
  75947. }
  75948. /**
  75949. * Returns the operand that is not an empty string from a flagged BinaryExpression.
  75950. * @param {ASTNode} node - The flagged BinaryExpression node to check.
  75951. * @returns {ASTNode} The operand that is not an empty string from a flagged BinaryExpression.
  75952. */
  75953. function getNonEmptyOperand(node) {
  75954. return isEmptyString(node.left) ? node.right : node.left;
  75955. }
  75956. //------------------------------------------------------------------------------
  75957. // Rule Definition
  75958. //------------------------------------------------------------------------------
  75959. module.exports = {
  75960. meta: {
  75961. type: "suggestion",
  75962. docs: {
  75963. description: "disallow shorthand type conversions",
  75964. category: "Best Practices",
  75965. recommended: false,
  75966. url: "https://eslint.org/docs/rules/no-implicit-coercion"
  75967. },
  75968. fixable: "code",
  75969. schema: [{
  75970. type: "object",
  75971. properties: {
  75972. boolean: {
  75973. type: "boolean"
  75974. },
  75975. number: {
  75976. type: "boolean"
  75977. },
  75978. string: {
  75979. type: "boolean"
  75980. },
  75981. allow: {
  75982. type: "array",
  75983. items: {
  75984. enum: ALLOWABLE_OPERATORS
  75985. },
  75986. uniqueItems: true
  75987. }
  75988. },
  75989. additionalProperties: false
  75990. }]
  75991. },
  75992. create: function create(context) {
  75993. var options = parseOptions(context.options[0] || {});
  75994. var sourceCode = context.getSourceCode();
  75995. /**
  75996. * Reports an error and autofixes the node
  75997. * @param {ASTNode} node - An ast node to report the error on.
  75998. * @param {string} recommendation - The recommended code for the issue
  75999. * @param {bool} shouldFix - Whether this report should fix the node
  76000. * @returns {void}
  76001. */
  76002. function report(node, recommendation, shouldFix) {
  76003. context.report({
  76004. node: node,
  76005. message: "use `{{recommendation}}` instead.",
  76006. data: {
  76007. recommendation: recommendation
  76008. },
  76009. fix: function fix(fixer) {
  76010. if (!shouldFix) {
  76011. return null;
  76012. }
  76013. var tokenBefore = sourceCode.getTokenBefore(node);
  76014. if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, recommendation)) {
  76015. return fixer.replaceText(node, " " + recommendation);
  76016. }
  76017. return fixer.replaceText(node, recommendation);
  76018. }
  76019. });
  76020. }
  76021. return {
  76022. UnaryExpression: function UnaryExpression(node) {
  76023. var operatorAllowed = void 0;
  76024. // !!foo
  76025. operatorAllowed = options.allow.indexOf("!!") >= 0;
  76026. if (!operatorAllowed && options.boolean && isDoubleLogicalNegating(node)) {
  76027. var recommendation = "Boolean(" + sourceCode.getText(node.argument.argument) + ")";
  76028. report(node, recommendation, true);
  76029. }
  76030. // ~foo.indexOf(bar)
  76031. operatorAllowed = options.allow.indexOf("~") >= 0;
  76032. if (!operatorAllowed && options.boolean && isBinaryNegatingOfIndexOf(node)) {
  76033. var _recommendation = sourceCode.getText(node.argument) + " !== -1";
  76034. report(node, _recommendation, false);
  76035. }
  76036. // +foo
  76037. operatorAllowed = options.allow.indexOf("+") >= 0;
  76038. if (!operatorAllowed && options.number && node.operator === "+" && !isNumeric(node.argument)) {
  76039. var _recommendation2 = "Number(" + sourceCode.getText(node.argument) + ")";
  76040. report(node, _recommendation2, true);
  76041. }
  76042. },
  76043. // Use `:exit` to prevent double reporting
  76044. "BinaryExpression:exit": function BinaryExpressionExit(node) {
  76045. var operatorAllowed = void 0;
  76046. // 1 * foo
  76047. operatorAllowed = options.allow.indexOf("*") >= 0;
  76048. var nonNumericOperand = !operatorAllowed && options.number && isMultiplyByOne(node) && getNonNumericOperand(node);
  76049. if (nonNumericOperand) {
  76050. var recommendation = "Number(" + sourceCode.getText(nonNumericOperand) + ")";
  76051. report(node, recommendation, true);
  76052. }
  76053. // "" + foo
  76054. operatorAllowed = options.allow.indexOf("+") >= 0;
  76055. if (!operatorAllowed && options.string && isConcatWithEmptyString(node)) {
  76056. var _recommendation3 = "String(" + sourceCode.getText(getNonEmptyOperand(node)) + ")";
  76057. report(node, _recommendation3, true);
  76058. }
  76059. },
  76060. AssignmentExpression: function AssignmentExpression(node) {
  76061. // foo += ""
  76062. var operatorAllowed = options.allow.indexOf("+") >= 0;
  76063. if (!operatorAllowed && options.string && isAppendEmptyString(node)) {
  76064. var code = sourceCode.getText(getNonEmptyOperand(node));
  76065. var recommendation = code + " = String(" + code + ")";
  76066. report(node, recommendation, true);
  76067. }
  76068. }
  76069. };
  76070. }
  76071. };
  76072. },{"../util/ast-utils":405}],241:[function(require,module,exports){
  76073. /**
  76074. * @fileoverview Rule to check for implicit global variables and functions.
  76075. * @author Joshua Peek
  76076. */
  76077. "use strict";
  76078. //------------------------------------------------------------------------------
  76079. // Rule Definition
  76080. //------------------------------------------------------------------------------
  76081. module.exports = {
  76082. meta: {
  76083. type: "suggestion",
  76084. docs: {
  76085. description: "disallow variable and `function` declarations in the global scope",
  76086. category: "Best Practices",
  76087. recommended: false,
  76088. url: "https://eslint.org/docs/rules/no-implicit-globals"
  76089. },
  76090. schema: []
  76091. },
  76092. create: function create(context) {
  76093. return {
  76094. Program: function Program() {
  76095. var scope = context.getScope();
  76096. scope.variables.forEach(function (variable) {
  76097. if (variable.writeable) {
  76098. return;
  76099. }
  76100. variable.defs.forEach(function (def) {
  76101. if (def.type === "FunctionName" || def.type === "Variable" && def.parent.kind === "var") {
  76102. context.report({ node: def.node, message: "Implicit global variable, assign as global property instead." });
  76103. }
  76104. });
  76105. });
  76106. scope.implicit.variables.forEach(function (variable) {
  76107. var scopeVariable = scope.set.get(variable.name);
  76108. if (scopeVariable && scopeVariable.writeable) {
  76109. return;
  76110. }
  76111. variable.defs.forEach(function (def) {
  76112. context.report({ node: def.node, message: "Implicit global variable, assign as global property instead." });
  76113. });
  76114. });
  76115. }
  76116. };
  76117. }
  76118. };
  76119. },{}],242:[function(require,module,exports){
  76120. /**
  76121. * @fileoverview Rule to flag use of implied eval via setTimeout and setInterval
  76122. * @author James Allardice
  76123. */
  76124. "use strict";
  76125. //------------------------------------------------------------------------------
  76126. // Rule Definition
  76127. //------------------------------------------------------------------------------
  76128. module.exports = {
  76129. meta: {
  76130. type: "suggestion",
  76131. docs: {
  76132. description: "disallow the use of `eval()`-like methods",
  76133. category: "Best Practices",
  76134. recommended: false,
  76135. url: "https://eslint.org/docs/rules/no-implied-eval"
  76136. },
  76137. schema: []
  76138. },
  76139. create: function create(context) {
  76140. var CALLEE_RE = /^(setTimeout|setInterval|execScript)$/;
  76141. /*
  76142. * Figures out if we should inspect a given binary expression. Is a stack
  76143. * of stacks, where the first element in each substack is a CallExpression.
  76144. */
  76145. var impliedEvalAncestorsStack = [];
  76146. //--------------------------------------------------------------------------
  76147. // Helpers
  76148. //--------------------------------------------------------------------------
  76149. /**
  76150. * Get the last element of an array, without modifying arr, like pop(), but non-destructive.
  76151. * @param {Array} arr What to inspect
  76152. * @returns {*} The last element of arr
  76153. * @private
  76154. */
  76155. function last(arr) {
  76156. return arr ? arr[arr.length - 1] : null;
  76157. }
  76158. /**
  76159. * Checks if the given MemberExpression node is a potentially implied eval identifier on window.
  76160. * @param {ASTNode} node The MemberExpression node to check.
  76161. * @returns {boolean} Whether or not the given node is potentially an implied eval.
  76162. * @private
  76163. */
  76164. function isImpliedEvalMemberExpression(node) {
  76165. var object = node.object,
  76166. property = node.property,
  76167. hasImpliedEvalName = CALLEE_RE.test(property.name) || CALLEE_RE.test(property.value);
  76168. return object.name === "window" && hasImpliedEvalName;
  76169. }
  76170. /**
  76171. * Determines if a node represents a call to a potentially implied eval.
  76172. *
  76173. * This checks the callee name and that there's an argument, but not the type of the argument.
  76174. *
  76175. * @param {ASTNode} node The CallExpression to check.
  76176. * @returns {boolean} True if the node matches, false if not.
  76177. * @private
  76178. */
  76179. function isImpliedEvalCallExpression(node) {
  76180. var isMemberExpression = node.callee.type === "MemberExpression",
  76181. isIdentifier = node.callee.type === "Identifier",
  76182. isImpliedEvalCallee = isIdentifier && CALLEE_RE.test(node.callee.name) || isMemberExpression && isImpliedEvalMemberExpression(node.callee);
  76183. return isImpliedEvalCallee && node.arguments.length;
  76184. }
  76185. /**
  76186. * Checks that the parent is a direct descendent of an potential implied eval CallExpression, and if the parent is a CallExpression, that we're the first argument.
  76187. * @param {ASTNode} node The node to inspect the parent of.
  76188. * @returns {boolean} Was the parent a direct descendent, and is the child therefore potentially part of a dangerous argument?
  76189. * @private
  76190. */
  76191. function hasImpliedEvalParent(node) {
  76192. // make sure our parent is marked
  76193. return node.parent === last(last(impliedEvalAncestorsStack)) && (
  76194. // if our parent is a CallExpression, make sure we're the first argument
  76195. node.parent.type !== "CallExpression" || node === node.parent.arguments[0]);
  76196. }
  76197. /**
  76198. * Checks if our parent is marked as part of an implied eval argument. If
  76199. * so, collapses the top of impliedEvalAncestorsStack and reports on the
  76200. * original CallExpression.
  76201. * @param {ASTNode} node The CallExpression to check.
  76202. * @returns {boolean} True if the node matches, false if not.
  76203. * @private
  76204. */
  76205. function checkString(node) {
  76206. if (hasImpliedEvalParent(node)) {
  76207. // remove the entire substack, to avoid duplicate reports
  76208. var substack = impliedEvalAncestorsStack.pop();
  76209. context.report({ node: substack[0], message: "Implied eval. Consider passing a function instead of a string." });
  76210. }
  76211. }
  76212. //--------------------------------------------------------------------------
  76213. // Public
  76214. //--------------------------------------------------------------------------
  76215. return {
  76216. CallExpression: function CallExpression(node) {
  76217. if (isImpliedEvalCallExpression(node)) {
  76218. // call expressions create a new substack
  76219. impliedEvalAncestorsStack.push([node]);
  76220. }
  76221. },
  76222. "CallExpression:exit": function CallExpressionExit(node) {
  76223. if (node === last(last(impliedEvalAncestorsStack))) {
  76224. /*
  76225. * Destroys the entire sub-stack, rather than just using
  76226. * last(impliedEvalAncestorsStack).pop(), as a CallExpression is
  76227. * always the bottom of a impliedEvalAncestorsStack substack.
  76228. */
  76229. impliedEvalAncestorsStack.pop();
  76230. }
  76231. },
  76232. BinaryExpression: function BinaryExpression(node) {
  76233. if (node.operator === "+" && hasImpliedEvalParent(node)) {
  76234. last(impliedEvalAncestorsStack).push(node);
  76235. }
  76236. },
  76237. "BinaryExpression:exit": function BinaryExpressionExit(node) {
  76238. if (node === last(last(impliedEvalAncestorsStack))) {
  76239. last(impliedEvalAncestorsStack).pop();
  76240. }
  76241. },
  76242. Literal: function Literal(node) {
  76243. if (typeof node.value === "string") {
  76244. checkString(node);
  76245. }
  76246. },
  76247. TemplateLiteral: function TemplateLiteral(node) {
  76248. checkString(node);
  76249. }
  76250. };
  76251. }
  76252. };
  76253. },{}],243:[function(require,module,exports){
  76254. /**
  76255. * @fileoverview Enforces or disallows inline comments.
  76256. * @author Greg Cochard
  76257. */
  76258. "use strict";
  76259. var astUtils = require("../util/ast-utils");
  76260. //------------------------------------------------------------------------------
  76261. // Rule Definition
  76262. //------------------------------------------------------------------------------
  76263. module.exports = {
  76264. meta: {
  76265. type: "suggestion",
  76266. docs: {
  76267. description: "disallow inline comments after code",
  76268. category: "Stylistic Issues",
  76269. recommended: false,
  76270. url: "https://eslint.org/docs/rules/no-inline-comments"
  76271. },
  76272. schema: []
  76273. },
  76274. create: function create(context) {
  76275. var sourceCode = context.getSourceCode();
  76276. /**
  76277. * Will check that comments are not on lines starting with or ending with code
  76278. * @param {ASTNode} node The comment node to check
  76279. * @private
  76280. * @returns {void}
  76281. */
  76282. function testCodeAroundComment(node) {
  76283. // Get the whole line and cut it off at the start of the comment
  76284. var startLine = String(sourceCode.lines[node.loc.start.line - 1]);
  76285. var endLine = String(sourceCode.lines[node.loc.end.line - 1]);
  76286. var preamble = startLine.slice(0, node.loc.start.column).trim();
  76287. // Also check after the comment
  76288. var postamble = endLine.slice(node.loc.end.column).trim();
  76289. // Check that this comment isn't an ESLint directive
  76290. var isDirective = astUtils.isDirectiveComment(node);
  76291. // Should be empty if there was only whitespace around the comment
  76292. if (!isDirective && (preamble || postamble)) {
  76293. context.report({ node: node, message: "Unexpected comment inline with code." });
  76294. }
  76295. }
  76296. //--------------------------------------------------------------------------
  76297. // Public
  76298. //--------------------------------------------------------------------------
  76299. return {
  76300. Program: function Program() {
  76301. var comments = sourceCode.getAllComments();
  76302. comments.filter(function (token) {
  76303. return token.type !== "Shebang";
  76304. }).forEach(testCodeAroundComment);
  76305. }
  76306. };
  76307. }
  76308. };
  76309. },{"../util/ast-utils":405}],244:[function(require,module,exports){
  76310. /**
  76311. * @fileoverview Rule to enforce declarations in program or function body root.
  76312. * @author Brandon Mills
  76313. */
  76314. "use strict";
  76315. //------------------------------------------------------------------------------
  76316. // Rule Definition
  76317. //------------------------------------------------------------------------------
  76318. module.exports = {
  76319. meta: {
  76320. type: "problem",
  76321. docs: {
  76322. description: "disallow variable or `function` declarations in nested blocks",
  76323. category: "Possible Errors",
  76324. recommended: true,
  76325. url: "https://eslint.org/docs/rules/no-inner-declarations"
  76326. },
  76327. schema: [{
  76328. enum: ["functions", "both"]
  76329. }]
  76330. },
  76331. create: function create(context) {
  76332. /**
  76333. * Find the nearest Program or Function ancestor node.
  76334. * @returns {Object} Ancestor's type and distance from node.
  76335. */
  76336. function nearestBody() {
  76337. var ancestors = context.getAncestors();
  76338. var ancestor = ancestors.pop(),
  76339. generation = 1;
  76340. while (ancestor && ["Program", "FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"].indexOf(ancestor.type) < 0) {
  76341. generation += 1;
  76342. ancestor = ancestors.pop();
  76343. }
  76344. return {
  76345. // Type of containing ancestor
  76346. type: ancestor.type,
  76347. // Separation between ancestor and node
  76348. distance: generation
  76349. };
  76350. }
  76351. /**
  76352. * Ensure that a given node is at a program or function body's root.
  76353. * @param {ASTNode} node Declaration node to check.
  76354. * @returns {void}
  76355. */
  76356. function check(node) {
  76357. var body = nearestBody(),
  76358. valid = body.type === "Program" && body.distance === 1 || body.distance === 2;
  76359. if (!valid) {
  76360. context.report({
  76361. node: node,
  76362. message: "Move {{type}} declaration to {{body}} root.",
  76363. data: {
  76364. type: node.type === "FunctionDeclaration" ? "function" : "variable",
  76365. body: body.type === "Program" ? "program" : "function body"
  76366. }
  76367. });
  76368. }
  76369. }
  76370. return {
  76371. FunctionDeclaration: check,
  76372. VariableDeclaration: function VariableDeclaration(node) {
  76373. if (context.options[0] === "both" && node.kind === "var") {
  76374. check(node);
  76375. }
  76376. }
  76377. };
  76378. }
  76379. };
  76380. },{}],245:[function(require,module,exports){
  76381. /**
  76382. * @fileoverview Validate strings passed to the RegExp constructor
  76383. * @author Michael Ficarra
  76384. */
  76385. "use strict";
  76386. //------------------------------------------------------------------------------
  76387. // Requirements
  76388. //------------------------------------------------------------------------------
  76389. var RegExpValidator = require("regexpp").RegExpValidator;
  76390. var validator = new RegExpValidator({ ecmaVersion: 2018 });
  76391. var validFlags = /[gimuys]/g;
  76392. var undefined1 = void 0;
  76393. //------------------------------------------------------------------------------
  76394. // Rule Definition
  76395. //------------------------------------------------------------------------------
  76396. module.exports = {
  76397. meta: {
  76398. type: "problem",
  76399. docs: {
  76400. description: "disallow invalid regular expression strings in `RegExp` constructors",
  76401. category: "Possible Errors",
  76402. recommended: true,
  76403. url: "https://eslint.org/docs/rules/no-invalid-regexp"
  76404. },
  76405. schema: [{
  76406. type: "object",
  76407. properties: {
  76408. allowConstructorFlags: {
  76409. type: "array",
  76410. items: {
  76411. type: "string"
  76412. }
  76413. }
  76414. },
  76415. additionalProperties: false
  76416. }]
  76417. },
  76418. create: function create(context) {
  76419. var options = context.options[0];
  76420. var allowedFlags = null;
  76421. if (options && options.allowConstructorFlags) {
  76422. var temp = options.allowConstructorFlags.join("").replace(validFlags, "");
  76423. if (temp) {
  76424. allowedFlags = new RegExp("[" + temp + "]", "gi");
  76425. }
  76426. }
  76427. /**
  76428. * Check if node is a string
  76429. * @param {ASTNode} node node to evaluate
  76430. * @returns {boolean} True if its a string
  76431. * @private
  76432. */
  76433. function isString(node) {
  76434. return node && node.type === "Literal" && typeof node.value === "string";
  76435. }
  76436. /**
  76437. * Check syntax error in a given pattern.
  76438. * @param {string} pattern The RegExp pattern to validate.
  76439. * @param {boolean} uFlag The Unicode flag.
  76440. * @returns {string|null} The syntax error.
  76441. */
  76442. function validateRegExpPattern(pattern, uFlag) {
  76443. try {
  76444. validator.validatePattern(pattern, undefined1, undefined1, uFlag);
  76445. return null;
  76446. } catch (err) {
  76447. return err.message;
  76448. }
  76449. }
  76450. /**
  76451. * Check syntax error in a given flags.
  76452. * @param {string} flags The RegExp flags to validate.
  76453. * @returns {string|null} The syntax error.
  76454. */
  76455. function validateRegExpFlags(flags) {
  76456. try {
  76457. validator.validateFlags(flags);
  76458. return null;
  76459. } catch (err) {
  76460. return "Invalid flags supplied to RegExp constructor '" + flags + "'";
  76461. }
  76462. }
  76463. return {
  76464. "CallExpression, NewExpression": function CallExpressionNewExpression(node) {
  76465. if (node.callee.type !== "Identifier" || node.callee.name !== "RegExp" || !isString(node.arguments[0])) {
  76466. return;
  76467. }
  76468. var pattern = node.arguments[0].value;
  76469. var flags = isString(node.arguments[1]) ? node.arguments[1].value : "";
  76470. if (allowedFlags) {
  76471. flags = flags.replace(allowedFlags, "");
  76472. }
  76473. // If flags are unknown, check both are errored or not.
  76474. var message = validateRegExpFlags(flags) || (flags ? validateRegExpPattern(pattern, flags.indexOf("u") !== -1) : validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false));
  76475. if (message) {
  76476. context.report({
  76477. node: node,
  76478. message: "{{message}}.",
  76479. data: { message: message }
  76480. });
  76481. }
  76482. }
  76483. };
  76484. }
  76485. };
  76486. },{"regexpp":104}],246:[function(require,module,exports){
  76487. /**
  76488. * @fileoverview A rule to disallow `this` keywords outside of classes or class-like objects.
  76489. * @author Toru Nagashima
  76490. */
  76491. "use strict";
  76492. //------------------------------------------------------------------------------
  76493. // Requirements
  76494. //------------------------------------------------------------------------------
  76495. var astUtils = require("../util/ast-utils");
  76496. //------------------------------------------------------------------------------
  76497. // Rule Definition
  76498. //------------------------------------------------------------------------------
  76499. module.exports = {
  76500. meta: {
  76501. type: "suggestion",
  76502. docs: {
  76503. description: "disallow `this` keywords outside of classes or class-like objects",
  76504. category: "Best Practices",
  76505. recommended: false,
  76506. url: "https://eslint.org/docs/rules/no-invalid-this"
  76507. },
  76508. schema: []
  76509. },
  76510. create: function create(context) {
  76511. var stack = [],
  76512. sourceCode = context.getSourceCode();
  76513. /**
  76514. * Gets the current checking context.
  76515. *
  76516. * The return value has a flag that whether or not `this` keyword is valid.
  76517. * The flag is initialized when got at the first time.
  76518. *
  76519. * @returns {{valid: boolean}}
  76520. * an object which has a flag that whether or not `this` keyword is valid.
  76521. */
  76522. stack.getCurrent = function () {
  76523. var current = this[this.length - 1];
  76524. if (!current.init) {
  76525. current.init = true;
  76526. current.valid = !astUtils.isDefaultThisBinding(current.node, sourceCode);
  76527. }
  76528. return current;
  76529. };
  76530. /**
  76531. * Pushs new checking context into the stack.
  76532. *
  76533. * The checking context is not initialized yet.
  76534. * Because most functions don't have `this` keyword.
  76535. * When `this` keyword was found, the checking context is initialized.
  76536. *
  76537. * @param {ASTNode} node - A function node that was entered.
  76538. * @returns {void}
  76539. */
  76540. function enterFunction(node) {
  76541. // `this` can be invalid only under strict mode.
  76542. stack.push({
  76543. init: !context.getScope().isStrict,
  76544. node: node,
  76545. valid: true
  76546. });
  76547. }
  76548. /**
  76549. * Pops the current checking context from the stack.
  76550. * @returns {void}
  76551. */
  76552. function exitFunction() {
  76553. stack.pop();
  76554. }
  76555. return {
  76556. /*
  76557. * `this` is invalid only under strict mode.
  76558. * Modules is always strict mode.
  76559. */
  76560. Program: function Program(node) {
  76561. var scope = context.getScope(),
  76562. features = context.parserOptions.ecmaFeatures || {};
  76563. stack.push({
  76564. init: true,
  76565. node: node,
  76566. valid: !(scope.isStrict || node.sourceType === "module" || features.globalReturn && scope.childScopes[0].isStrict)
  76567. });
  76568. },
  76569. "Program:exit": function ProgramExit() {
  76570. stack.pop();
  76571. },
  76572. FunctionDeclaration: enterFunction,
  76573. "FunctionDeclaration:exit": exitFunction,
  76574. FunctionExpression: enterFunction,
  76575. "FunctionExpression:exit": exitFunction,
  76576. // Reports if `this` of the current context is invalid.
  76577. ThisExpression: function ThisExpression(node) {
  76578. var current = stack.getCurrent();
  76579. if (current && !current.valid) {
  76580. context.report({ node: node, message: "Unexpected 'this'." });
  76581. }
  76582. }
  76583. };
  76584. }
  76585. };
  76586. },{"../util/ast-utils":405}],247:[function(require,module,exports){
  76587. /**
  76588. * @fileoverview Rule to disalow whitespace that is not a tab or space, whitespace inside strings and comments are allowed
  76589. * @author Jonathan Kingston
  76590. * @author Christophe Porteneuve
  76591. */
  76592. "use strict";
  76593. //------------------------------------------------------------------------------
  76594. // Requirements
  76595. //------------------------------------------------------------------------------
  76596. var astUtils = require("../util/ast-utils");
  76597. //------------------------------------------------------------------------------
  76598. // Constants
  76599. //------------------------------------------------------------------------------
  76600. var ALL_IRREGULARS = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/;
  76601. var IRREGULAR_WHITESPACE = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/mg;
  76602. var IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/mg;
  76603. var LINE_BREAK = astUtils.createGlobalLinebreakMatcher();
  76604. //------------------------------------------------------------------------------
  76605. // Rule Definition
  76606. //------------------------------------------------------------------------------
  76607. module.exports = {
  76608. meta: {
  76609. type: "problem",
  76610. docs: {
  76611. description: "disallow irregular whitespace",
  76612. category: "Possible Errors",
  76613. recommended: true,
  76614. url: "https://eslint.org/docs/rules/no-irregular-whitespace"
  76615. },
  76616. schema: [{
  76617. type: "object",
  76618. properties: {
  76619. skipComments: {
  76620. type: "boolean"
  76621. },
  76622. skipStrings: {
  76623. type: "boolean"
  76624. },
  76625. skipTemplates: {
  76626. type: "boolean"
  76627. },
  76628. skipRegExps: {
  76629. type: "boolean"
  76630. }
  76631. },
  76632. additionalProperties: false
  76633. }]
  76634. },
  76635. create: function create(context) {
  76636. // Module store of errors that we have found
  76637. var errors = [];
  76638. // Lookup the `skipComments` option, which defaults to `false`.
  76639. var options = context.options[0] || {};
  76640. var skipComments = !!options.skipComments;
  76641. var skipStrings = options.skipStrings !== false;
  76642. var skipRegExps = !!options.skipRegExps;
  76643. var skipTemplates = !!options.skipTemplates;
  76644. var sourceCode = context.getSourceCode();
  76645. var commentNodes = sourceCode.getAllComments();
  76646. /**
  76647. * Removes errors that occur inside a string node
  76648. * @param {ASTNode} node to check for matching errors.
  76649. * @returns {void}
  76650. * @private
  76651. */
  76652. function removeWhitespaceError(node) {
  76653. var locStart = node.loc.start;
  76654. var locEnd = node.loc.end;
  76655. errors = errors.filter(function (_ref) {
  76656. var errorLoc = _ref.loc;
  76657. if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
  76658. if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) {
  76659. return false;
  76660. }
  76661. }
  76662. return true;
  76663. });
  76664. }
  76665. /**
  76666. * Checks identifier or literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
  76667. * @param {ASTNode} node to check for matching errors.
  76668. * @returns {void}
  76669. * @private
  76670. */
  76671. function removeInvalidNodeErrorsInIdentifierOrLiteral(node) {
  76672. var shouldCheckStrings = skipStrings && typeof node.value === "string";
  76673. var shouldCheckRegExps = skipRegExps && Boolean(node.regex);
  76674. if (shouldCheckStrings || shouldCheckRegExps) {
  76675. // If we have irregular characters remove them from the errors list
  76676. if (ALL_IRREGULARS.test(node.raw)) {
  76677. removeWhitespaceError(node);
  76678. }
  76679. }
  76680. }
  76681. /**
  76682. * Checks template string literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
  76683. * @param {ASTNode} node to check for matching errors.
  76684. * @returns {void}
  76685. * @private
  76686. */
  76687. function removeInvalidNodeErrorsInTemplateLiteral(node) {
  76688. if (typeof node.value.raw === "string") {
  76689. if (ALL_IRREGULARS.test(node.value.raw)) {
  76690. removeWhitespaceError(node);
  76691. }
  76692. }
  76693. }
  76694. /**
  76695. * Checks comment nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
  76696. * @param {ASTNode} node to check for matching errors.
  76697. * @returns {void}
  76698. * @private
  76699. */
  76700. function removeInvalidNodeErrorsInComment(node) {
  76701. if (ALL_IRREGULARS.test(node.value)) {
  76702. removeWhitespaceError(node);
  76703. }
  76704. }
  76705. /**
  76706. * Checks the program source for irregular whitespace
  76707. * @param {ASTNode} node The program node
  76708. * @returns {void}
  76709. * @private
  76710. */
  76711. function checkForIrregularWhitespace(node) {
  76712. var sourceLines = sourceCode.lines;
  76713. sourceLines.forEach(function (sourceLine, lineIndex) {
  76714. var lineNumber = lineIndex + 1;
  76715. var match = void 0;
  76716. while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
  76717. var location = {
  76718. line: lineNumber,
  76719. column: match.index
  76720. };
  76721. errors.push({ node: node, message: "Irregular whitespace not allowed.", loc: location });
  76722. }
  76723. });
  76724. }
  76725. /**
  76726. * Checks the program source for irregular line terminators
  76727. * @param {ASTNode} node The program node
  76728. * @returns {void}
  76729. * @private
  76730. */
  76731. function checkForIrregularLineTerminators(node) {
  76732. var source = sourceCode.getText(),
  76733. sourceLines = sourceCode.lines,
  76734. linebreaks = source.match(LINE_BREAK);
  76735. var lastLineIndex = -1,
  76736. match = void 0;
  76737. while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) {
  76738. var lineIndex = linebreaks.indexOf(match[0], lastLineIndex + 1) || 0;
  76739. var location = {
  76740. line: lineIndex + 1,
  76741. column: sourceLines[lineIndex].length
  76742. };
  76743. errors.push({ node: node, message: "Irregular whitespace not allowed.", loc: location });
  76744. lastLineIndex = lineIndex;
  76745. }
  76746. }
  76747. /**
  76748. * A no-op function to act as placeholder for comment accumulation when the `skipComments` option is `false`.
  76749. * @returns {void}
  76750. * @private
  76751. */
  76752. function noop() {}
  76753. var nodes = {};
  76754. if (ALL_IRREGULARS.test(sourceCode.getText())) {
  76755. nodes.Program = function (node) {
  76756. /*
  76757. * As we can easily fire warnings for all white space issues with
  76758. * all the source its simpler to fire them here.
  76759. * This means we can check all the application code without having
  76760. * to worry about issues caused in the parser tokens.
  76761. * When writing this code also evaluating per node was missing out
  76762. * connecting tokens in some cases.
  76763. * We can later filter the errors when they are found to be not an
  76764. * issue in nodes we don't care about.
  76765. */
  76766. checkForIrregularWhitespace(node);
  76767. checkForIrregularLineTerminators(node);
  76768. };
  76769. nodes.Identifier = removeInvalidNodeErrorsInIdentifierOrLiteral;
  76770. nodes.Literal = removeInvalidNodeErrorsInIdentifierOrLiteral;
  76771. nodes.TemplateElement = skipTemplates ? removeInvalidNodeErrorsInTemplateLiteral : noop;
  76772. nodes["Program:exit"] = function () {
  76773. if (skipComments) {
  76774. // First strip errors occurring in comment nodes.
  76775. commentNodes.forEach(removeInvalidNodeErrorsInComment);
  76776. }
  76777. // If we have any errors remaining report on them
  76778. errors.forEach(function (error) {
  76779. return context.report(error);
  76780. });
  76781. };
  76782. } else {
  76783. nodes.Program = noop;
  76784. }
  76785. return nodes;
  76786. }
  76787. };
  76788. },{"../util/ast-utils":405}],248:[function(require,module,exports){
  76789. /**
  76790. * @fileoverview Rule to flag usage of __iterator__ property
  76791. * @author Ian Christian Myers
  76792. */
  76793. "use strict";
  76794. //------------------------------------------------------------------------------
  76795. // Rule Definition
  76796. //------------------------------------------------------------------------------
  76797. module.exports = {
  76798. meta: {
  76799. type: "suggestion",
  76800. docs: {
  76801. description: "disallow the use of the `__iterator__` property",
  76802. category: "Best Practices",
  76803. recommended: false,
  76804. url: "https://eslint.org/docs/rules/no-iterator"
  76805. },
  76806. schema: []
  76807. },
  76808. create: function create(context) {
  76809. return {
  76810. MemberExpression: function MemberExpression(node) {
  76811. if (node.property && node.property.type === "Identifier" && node.property.name === "__iterator__" && !node.computed || node.property.type === "Literal" && node.property.value === "__iterator__") {
  76812. context.report({ node: node, message: "Reserved name '__iterator__'." });
  76813. }
  76814. }
  76815. };
  76816. }
  76817. };
  76818. },{}],249:[function(require,module,exports){
  76819. /**
  76820. * @fileoverview Rule to flag labels that are the same as an identifier
  76821. * @author Ian Christian Myers
  76822. */
  76823. "use strict";
  76824. //------------------------------------------------------------------------------
  76825. // Requirements
  76826. //------------------------------------------------------------------------------
  76827. var astUtils = require("../util/ast-utils");
  76828. //------------------------------------------------------------------------------
  76829. // Rule Definition
  76830. //------------------------------------------------------------------------------
  76831. module.exports = {
  76832. meta: {
  76833. type: "suggestion",
  76834. docs: {
  76835. description: "disallow labels that share a name with a variable",
  76836. category: "Variables",
  76837. recommended: false,
  76838. url: "https://eslint.org/docs/rules/no-label-var"
  76839. },
  76840. schema: []
  76841. },
  76842. create: function create(context) {
  76843. //--------------------------------------------------------------------------
  76844. // Helpers
  76845. //--------------------------------------------------------------------------
  76846. /**
  76847. * Check if the identifier is present inside current scope
  76848. * @param {Object} scope current scope
  76849. * @param {string} name To evaluate
  76850. * @returns {boolean} True if its present
  76851. * @private
  76852. */
  76853. function findIdentifier(scope, name) {
  76854. return astUtils.getVariableByName(scope, name) !== null;
  76855. }
  76856. //--------------------------------------------------------------------------
  76857. // Public API
  76858. //--------------------------------------------------------------------------
  76859. return {
  76860. LabeledStatement: function LabeledStatement(node) {
  76861. // Fetch the innermost scope.
  76862. var scope = context.getScope();
  76863. /*
  76864. * Recursively find the identifier walking up the scope, starting
  76865. * with the innermost scope.
  76866. */
  76867. if (findIdentifier(scope, node.label.name)) {
  76868. context.report({ node: node, message: "Found identifier with same name as label." });
  76869. }
  76870. }
  76871. };
  76872. }
  76873. };
  76874. },{"../util/ast-utils":405}],250:[function(require,module,exports){
  76875. /**
  76876. * @fileoverview Disallow Labeled Statements
  76877. * @author Nicholas C. Zakas
  76878. */
  76879. "use strict";
  76880. //------------------------------------------------------------------------------
  76881. // Requirements
  76882. //------------------------------------------------------------------------------
  76883. var astUtils = require("../util/ast-utils");
  76884. //------------------------------------------------------------------------------
  76885. // Rule Definition
  76886. //------------------------------------------------------------------------------
  76887. module.exports = {
  76888. meta: {
  76889. type: "suggestion",
  76890. docs: {
  76891. description: "disallow labeled statements",
  76892. category: "Best Practices",
  76893. recommended: false,
  76894. url: "https://eslint.org/docs/rules/no-labels"
  76895. },
  76896. schema: [{
  76897. type: "object",
  76898. properties: {
  76899. allowLoop: {
  76900. type: "boolean"
  76901. },
  76902. allowSwitch: {
  76903. type: "boolean"
  76904. }
  76905. },
  76906. additionalProperties: false
  76907. }]
  76908. },
  76909. create: function create(context) {
  76910. var options = context.options[0];
  76911. var allowLoop = Boolean(options && options.allowLoop);
  76912. var allowSwitch = Boolean(options && options.allowSwitch);
  76913. var scopeInfo = null;
  76914. /**
  76915. * Gets the kind of a given node.
  76916. *
  76917. * @param {ASTNode} node - A node to get.
  76918. * @returns {string} The kind of the node.
  76919. */
  76920. function getBodyKind(node) {
  76921. if (astUtils.isLoop(node)) {
  76922. return "loop";
  76923. }
  76924. if (node.type === "SwitchStatement") {
  76925. return "switch";
  76926. }
  76927. return "other";
  76928. }
  76929. /**
  76930. * Checks whether the label of a given kind is allowed or not.
  76931. *
  76932. * @param {string} kind - A kind to check.
  76933. * @returns {boolean} `true` if the kind is allowed.
  76934. */
  76935. function isAllowed(kind) {
  76936. switch (kind) {
  76937. case "loop":
  76938. return allowLoop;
  76939. case "switch":
  76940. return allowSwitch;
  76941. default:
  76942. return false;
  76943. }
  76944. }
  76945. /**
  76946. * Checks whether a given name is a label of a loop or not.
  76947. *
  76948. * @param {string} label - A name of a label to check.
  76949. * @returns {boolean} `true` if the name is a label of a loop.
  76950. */
  76951. function getKind(label) {
  76952. var info = scopeInfo;
  76953. while (info) {
  76954. if (info.label === label) {
  76955. return info.kind;
  76956. }
  76957. info = info.upper;
  76958. }
  76959. /* istanbul ignore next: syntax error */
  76960. return "other";
  76961. }
  76962. //--------------------------------------------------------------------------
  76963. // Public
  76964. //--------------------------------------------------------------------------
  76965. return {
  76966. LabeledStatement: function LabeledStatement(node) {
  76967. scopeInfo = {
  76968. label: node.label.name,
  76969. kind: getBodyKind(node.body),
  76970. upper: scopeInfo
  76971. };
  76972. },
  76973. "LabeledStatement:exit": function LabeledStatementExit(node) {
  76974. if (!isAllowed(scopeInfo.kind)) {
  76975. context.report({
  76976. node: node,
  76977. message: "Unexpected labeled statement."
  76978. });
  76979. }
  76980. scopeInfo = scopeInfo.upper;
  76981. },
  76982. BreakStatement: function BreakStatement(node) {
  76983. if (node.label && !isAllowed(getKind(node.label.name))) {
  76984. context.report({
  76985. node: node,
  76986. message: "Unexpected label in break statement."
  76987. });
  76988. }
  76989. },
  76990. ContinueStatement: function ContinueStatement(node) {
  76991. if (node.label && !isAllowed(getKind(node.label.name))) {
  76992. context.report({
  76993. node: node,
  76994. message: "Unexpected label in continue statement."
  76995. });
  76996. }
  76997. }
  76998. };
  76999. }
  77000. };
  77001. },{"../util/ast-utils":405}],251:[function(require,module,exports){
  77002. /**
  77003. * @fileoverview Rule to flag blocks with no reason to exist
  77004. * @author Brandon Mills
  77005. */
  77006. "use strict";
  77007. //------------------------------------------------------------------------------
  77008. // Rule Definition
  77009. //------------------------------------------------------------------------------
  77010. module.exports = {
  77011. meta: {
  77012. type: "suggestion",
  77013. docs: {
  77014. description: "disallow unnecessary nested blocks",
  77015. category: "Best Practices",
  77016. recommended: false,
  77017. url: "https://eslint.org/docs/rules/no-lone-blocks"
  77018. },
  77019. schema: []
  77020. },
  77021. create: function create(context) {
  77022. // A stack of lone blocks to be checked for block-level bindings
  77023. var loneBlocks = [];
  77024. var ruleDef = void 0;
  77025. /**
  77026. * Reports a node as invalid.
  77027. * @param {ASTNode} node - The node to be reported.
  77028. * @returns {void}
  77029. */
  77030. function report(node) {
  77031. var message = node.parent.type === "BlockStatement" ? "Nested block is redundant." : "Block is redundant.";
  77032. context.report({ node: node, message: message });
  77033. }
  77034. /**
  77035. * Checks for any ocurrence of a BlockStatement in a place where lists of statements can appear
  77036. * @param {ASTNode} node The node to check
  77037. * @returns {boolean} True if the node is a lone block.
  77038. */
  77039. function isLoneBlock(node) {
  77040. return node.parent.type === "BlockStatement" || node.parent.type === "Program" ||
  77041. // Don't report blocks in switch cases if the block is the only statement of the case.
  77042. node.parent.type === "SwitchCase" && !(node.parent.consequent[0] === node && node.parent.consequent.length === 1);
  77043. }
  77044. /**
  77045. * Checks the enclosing block of the current node for block-level bindings,
  77046. * and "marks it" as valid if any.
  77047. * @returns {void}
  77048. */
  77049. function markLoneBlock() {
  77050. if (loneBlocks.length === 0) {
  77051. return;
  77052. }
  77053. var block = context.getAncestors().pop();
  77054. if (loneBlocks[loneBlocks.length - 1] === block) {
  77055. loneBlocks.pop();
  77056. }
  77057. }
  77058. // Default rule definition: report all lone blocks
  77059. ruleDef = {
  77060. BlockStatement: function BlockStatement(node) {
  77061. if (isLoneBlock(node)) {
  77062. report(node);
  77063. }
  77064. }
  77065. };
  77066. // ES6: report blocks without block-level bindings
  77067. if (context.parserOptions.ecmaVersion >= 6) {
  77068. ruleDef = {
  77069. BlockStatement: function BlockStatement(node) {
  77070. if (isLoneBlock(node)) {
  77071. loneBlocks.push(node);
  77072. }
  77073. },
  77074. "BlockStatement:exit": function BlockStatementExit(node) {
  77075. if (loneBlocks.length > 0 && loneBlocks[loneBlocks.length - 1] === node) {
  77076. loneBlocks.pop();
  77077. report(node);
  77078. }
  77079. }
  77080. };
  77081. ruleDef.VariableDeclaration = function (node) {
  77082. if (node.kind === "let" || node.kind === "const") {
  77083. markLoneBlock();
  77084. }
  77085. };
  77086. ruleDef.FunctionDeclaration = function () {
  77087. if (context.getScope().isStrict) {
  77088. markLoneBlock();
  77089. }
  77090. };
  77091. ruleDef.ClassDeclaration = markLoneBlock;
  77092. }
  77093. return ruleDef;
  77094. }
  77095. };
  77096. },{}],252:[function(require,module,exports){
  77097. /**
  77098. * @fileoverview Rule to disallow if as the only statmenet in an else block
  77099. * @author Brandon Mills
  77100. */
  77101. "use strict";
  77102. //------------------------------------------------------------------------------
  77103. // Rule Definition
  77104. //------------------------------------------------------------------------------
  77105. module.exports = {
  77106. meta: {
  77107. type: "suggestion",
  77108. docs: {
  77109. description: "disallow `if` statements as the only statement in `else` blocks",
  77110. category: "Stylistic Issues",
  77111. recommended: false,
  77112. url: "https://eslint.org/docs/rules/no-lonely-if"
  77113. },
  77114. schema: [],
  77115. fixable: "code"
  77116. },
  77117. create: function create(context) {
  77118. var sourceCode = context.getSourceCode();
  77119. return {
  77120. IfStatement: function IfStatement(node) {
  77121. var ancestors = context.getAncestors(),
  77122. parent = ancestors.pop(),
  77123. grandparent = ancestors.pop();
  77124. if (parent && parent.type === "BlockStatement" && parent.body.length === 1 && grandparent && grandparent.type === "IfStatement" && parent === grandparent.alternate) {
  77125. context.report({
  77126. node: node,
  77127. message: "Unexpected if as the only statement in an else block.",
  77128. fix: function fix(fixer) {
  77129. var openingElseCurly = sourceCode.getFirstToken(parent);
  77130. var closingElseCurly = sourceCode.getLastToken(parent);
  77131. var elseKeyword = sourceCode.getTokenBefore(openingElseCurly);
  77132. var tokenAfterElseBlock = sourceCode.getTokenAfter(closingElseCurly);
  77133. var lastIfToken = sourceCode.getLastToken(node.consequent);
  77134. var sourceText = sourceCode.getText();
  77135. if (sourceText.slice(openingElseCurly.range[1], node.range[0]).trim() || sourceText.slice(node.range[1], closingElseCurly.range[0]).trim()) {
  77136. // Don't fix if there are any non-whitespace characters interfering (e.g. comments)
  77137. return null;
  77138. }
  77139. if (node.consequent.type !== "BlockStatement" && lastIfToken.value !== ";" && tokenAfterElseBlock && (node.consequent.loc.end.line === tokenAfterElseBlock.loc.start.line || /^[([/+`-]/.test(tokenAfterElseBlock.value) || lastIfToken.value === "++" || lastIfToken.value === "--")) {
  77140. /*
  77141. * If the `if` statement has no block, and is not followed by a semicolon, make sure that fixing
  77142. * the issue would not change semantics due to ASI. If this would happen, don't do a fix.
  77143. */
  77144. return null;
  77145. }
  77146. return fixer.replaceTextRange([openingElseCurly.range[0], closingElseCurly.range[1]], (elseKeyword.range[1] === openingElseCurly.range[0] ? " " : "") + sourceCode.getText(node));
  77147. }
  77148. });
  77149. }
  77150. }
  77151. };
  77152. }
  77153. };
  77154. },{}],253:[function(require,module,exports){
  77155. /**
  77156. * @fileoverview Rule to flag creation of function inside a loop
  77157. * @author Ilya Volodin
  77158. */
  77159. "use strict";
  77160. //------------------------------------------------------------------------------
  77161. // Helpers
  77162. //------------------------------------------------------------------------------
  77163. /**
  77164. * Gets the containing loop node of a specified node.
  77165. *
  77166. * We don't need to check nested functions, so this ignores those.
  77167. * `Scope.through` contains references of nested functions.
  77168. *
  77169. * @param {ASTNode} node - An AST node to get.
  77170. * @returns {ASTNode|null} The containing loop node of the specified node, or
  77171. * `null`.
  77172. */
  77173. function getContainingLoopNode(node) {
  77174. for (var currentNode = node; currentNode.parent; currentNode = currentNode.parent) {
  77175. var parent = currentNode.parent;
  77176. switch (parent.type) {
  77177. case "WhileStatement":
  77178. case "DoWhileStatement":
  77179. return parent;
  77180. case "ForStatement":
  77181. // `init` is outside of the loop.
  77182. if (parent.init !== currentNode) {
  77183. return parent;
  77184. }
  77185. break;
  77186. case "ForInStatement":
  77187. case "ForOfStatement":
  77188. // `right` is outside of the loop.
  77189. if (parent.right !== currentNode) {
  77190. return parent;
  77191. }
  77192. break;
  77193. case "ArrowFunctionExpression":
  77194. case "FunctionExpression":
  77195. case "FunctionDeclaration":
  77196. // We don't need to check nested functions.
  77197. return null;
  77198. default:
  77199. break;
  77200. }
  77201. }
  77202. return null;
  77203. }
  77204. /**
  77205. * Gets the containing loop node of a given node.
  77206. * If the loop was nested, this returns the most outer loop.
  77207. *
  77208. * @param {ASTNode} node - A node to get. This is a loop node.
  77209. * @param {ASTNode|null} excludedNode - A node that the result node should not
  77210. * include.
  77211. * @returns {ASTNode} The most outer loop node.
  77212. */
  77213. function getTopLoopNode(node, excludedNode) {
  77214. var border = excludedNode ? excludedNode.range[1] : 0;
  77215. var retv = node;
  77216. var containingLoopNode = node;
  77217. while (containingLoopNode && containingLoopNode.range[0] >= border) {
  77218. retv = containingLoopNode;
  77219. containingLoopNode = getContainingLoopNode(containingLoopNode);
  77220. }
  77221. return retv;
  77222. }
  77223. /**
  77224. * Checks whether a given reference which refers to an upper scope's variable is
  77225. * safe or not.
  77226. *
  77227. * @param {ASTNode} loopNode - A containing loop node.
  77228. * @param {eslint-scope.Reference} reference - A reference to check.
  77229. * @returns {boolean} `true` if the reference is safe or not.
  77230. */
  77231. function isSafe(loopNode, reference) {
  77232. var variable = reference.resolved;
  77233. var definition = variable && variable.defs[0];
  77234. var declaration = definition && definition.parent;
  77235. var kind = declaration && declaration.type === "VariableDeclaration" ? declaration.kind : "";
  77236. // Variables which are declared by `const` is safe.
  77237. if (kind === "const") {
  77238. return true;
  77239. }
  77240. /*
  77241. * Variables which are declared by `let` in the loop is safe.
  77242. * It's a different instance from the next loop step's.
  77243. */
  77244. if (kind === "let" && declaration.range[0] > loopNode.range[0] && declaration.range[1] < loopNode.range[1]) {
  77245. return true;
  77246. }
  77247. /*
  77248. * WriteReferences which exist after this border are unsafe because those
  77249. * can modify the variable.
  77250. */
  77251. var border = getTopLoopNode(loopNode, kind === "let" ? declaration : null).range[0];
  77252. /**
  77253. * Checks whether a given reference is safe or not.
  77254. * The reference is every reference of the upper scope's variable we are
  77255. * looking now.
  77256. *
  77257. * It's safeafe if the reference matches one of the following condition.
  77258. * - is readonly.
  77259. * - doesn't exist inside a local function and after the border.
  77260. *
  77261. * @param {eslint-scope.Reference} upperRef - A reference to check.
  77262. * @returns {boolean} `true` if the reference is safe.
  77263. */
  77264. function isSafeReference(upperRef) {
  77265. var id = upperRef.identifier;
  77266. return !upperRef.isWrite() || variable.scope.variableScope === upperRef.from.variableScope && id.range[0] < border;
  77267. }
  77268. return Boolean(variable) && variable.references.every(isSafeReference);
  77269. }
  77270. //------------------------------------------------------------------------------
  77271. // Rule Definition
  77272. //------------------------------------------------------------------------------
  77273. module.exports = {
  77274. meta: {
  77275. type: "suggestion",
  77276. docs: {
  77277. description: "disallow `function` declarations and expressions inside loop statements",
  77278. category: "Best Practices",
  77279. recommended: false,
  77280. url: "https://eslint.org/docs/rules/no-loop-func"
  77281. },
  77282. schema: []
  77283. },
  77284. create: function create(context) {
  77285. /**
  77286. * Reports functions which match the following condition:
  77287. *
  77288. * - has a loop node in ancestors.
  77289. * - has any references which refers to an unsafe variable.
  77290. *
  77291. * @param {ASTNode} node The AST node to check.
  77292. * @returns {boolean} Whether or not the node is within a loop.
  77293. */
  77294. function checkForLoops(node) {
  77295. var loopNode = getContainingLoopNode(node);
  77296. if (!loopNode) {
  77297. return;
  77298. }
  77299. var references = context.getScope().through;
  77300. if (references.length > 0 && !references.every(isSafe.bind(null, loopNode))) {
  77301. context.report({ node: node, message: "Don't make functions within a loop." });
  77302. }
  77303. }
  77304. return {
  77305. ArrowFunctionExpression: checkForLoops,
  77306. FunctionExpression: checkForLoops,
  77307. FunctionDeclaration: checkForLoops
  77308. };
  77309. }
  77310. };
  77311. },{}],254:[function(require,module,exports){
  77312. /**
  77313. * @fileoverview Rule to flag statements that use magic numbers (adapted from https://github.com/danielstjules/buddy.js)
  77314. * @author Vincent Lemeunier
  77315. */
  77316. "use strict";
  77317. //------------------------------------------------------------------------------
  77318. // Rule Definition
  77319. //------------------------------------------------------------------------------
  77320. module.exports = {
  77321. meta: {
  77322. type: "suggestion",
  77323. docs: {
  77324. description: "disallow magic numbers",
  77325. category: "Best Practices",
  77326. recommended: false,
  77327. url: "https://eslint.org/docs/rules/no-magic-numbers"
  77328. },
  77329. schema: [{
  77330. type: "object",
  77331. properties: {
  77332. detectObjects: {
  77333. type: "boolean"
  77334. },
  77335. enforceConst: {
  77336. type: "boolean"
  77337. },
  77338. ignore: {
  77339. type: "array",
  77340. items: {
  77341. type: "number"
  77342. },
  77343. uniqueItems: true
  77344. },
  77345. ignoreArrayIndexes: {
  77346. type: "boolean"
  77347. }
  77348. },
  77349. additionalProperties: false
  77350. }],
  77351. messages: {
  77352. useConst: "Number constants declarations must use 'const'.",
  77353. noMagic: "No magic number: {{raw}}."
  77354. }
  77355. },
  77356. create: function create(context) {
  77357. var config = context.options[0] || {},
  77358. detectObjects = !!config.detectObjects,
  77359. enforceConst = !!config.enforceConst,
  77360. ignore = config.ignore || [],
  77361. ignoreArrayIndexes = !!config.ignoreArrayIndexes;
  77362. /**
  77363. * Returns whether the node is number literal
  77364. * @param {Node} node - the node literal being evaluated
  77365. * @returns {boolean} true if the node is a number literal
  77366. */
  77367. function isNumber(node) {
  77368. return typeof node.value === "number";
  77369. }
  77370. /**
  77371. * Returns whether the number should be ignored
  77372. * @param {number} num - the number
  77373. * @returns {boolean} true if the number should be ignored
  77374. */
  77375. function shouldIgnoreNumber(num) {
  77376. return ignore.indexOf(num) !== -1;
  77377. }
  77378. /**
  77379. * Returns whether the number should be ignored when used as a radix within parseInt() or Number.parseInt()
  77380. * @param {ASTNode} parent - the non-"UnaryExpression" parent
  77381. * @param {ASTNode} node - the node literal being evaluated
  77382. * @returns {boolean} true if the number should be ignored
  77383. */
  77384. function shouldIgnoreParseInt(parent, node) {
  77385. return parent.type === "CallExpression" && node === parent.arguments[1] && (parent.callee.name === "parseInt" || parent.callee.type === "MemberExpression" && parent.callee.object.name === "Number" && parent.callee.property.name === "parseInt");
  77386. }
  77387. /**
  77388. * Returns whether the number should be ignored when used to define a JSX prop
  77389. * @param {ASTNode} parent - the non-"UnaryExpression" parent
  77390. * @returns {boolean} true if the number should be ignored
  77391. */
  77392. function shouldIgnoreJSXNumbers(parent) {
  77393. return parent.type.indexOf("JSX") === 0;
  77394. }
  77395. /**
  77396. * Returns whether the number should be ignored when used as an array index with enabled 'ignoreArrayIndexes' option.
  77397. * @param {ASTNode} parent - the non-"UnaryExpression" parent.
  77398. * @returns {boolean} true if the number should be ignored
  77399. */
  77400. function shouldIgnoreArrayIndexes(parent) {
  77401. return parent.type === "MemberExpression" && ignoreArrayIndexes;
  77402. }
  77403. return {
  77404. Literal: function Literal(node) {
  77405. var okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"];
  77406. if (!isNumber(node)) {
  77407. return;
  77408. }
  77409. var fullNumberNode = void 0;
  77410. var parent = void 0;
  77411. var value = void 0;
  77412. var raw = void 0;
  77413. // For negative magic numbers: update the value and parent node
  77414. if (node.parent.type === "UnaryExpression" && node.parent.operator === "-") {
  77415. fullNumberNode = node.parent;
  77416. parent = fullNumberNode.parent;
  77417. value = -node.value;
  77418. raw = "-" + node.raw;
  77419. } else {
  77420. fullNumberNode = node;
  77421. parent = node.parent;
  77422. value = node.value;
  77423. raw = node.raw;
  77424. }
  77425. if (shouldIgnoreNumber(value) || shouldIgnoreParseInt(parent, fullNumberNode) || shouldIgnoreArrayIndexes(parent) || shouldIgnoreJSXNumbers(parent)) {
  77426. return;
  77427. }
  77428. if (parent.type === "VariableDeclarator") {
  77429. if (enforceConst && parent.parent.kind !== "const") {
  77430. context.report({
  77431. node: fullNumberNode,
  77432. messageId: "useConst"
  77433. });
  77434. }
  77435. } else if (okTypes.indexOf(parent.type) === -1 || parent.type === "AssignmentExpression" && parent.left.type === "Identifier") {
  77436. context.report({
  77437. node: fullNumberNode,
  77438. messageId: "noMagic",
  77439. data: {
  77440. raw: raw
  77441. }
  77442. });
  77443. }
  77444. }
  77445. };
  77446. }
  77447. };
  77448. },{}],255:[function(require,module,exports){
  77449. /**
  77450. * @author Toru Nagashima <https://github.com/mysticatea>
  77451. */
  77452. "use strict";
  77453. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  77454. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  77455. var _marked = /*#__PURE__*/regeneratorRuntime.mark(iterateCharacterSequence);
  77456. var _require = require("eslint-utils"),
  77457. CALL = _require.CALL,
  77458. CONSTRUCT = _require.CONSTRUCT,
  77459. ReferenceTracker = _require.ReferenceTracker,
  77460. getStringIfConstant = _require.getStringIfConstant;
  77461. var _require2 = require("regexpp"),
  77462. RegExpParser = _require2.RegExpParser,
  77463. visitRegExpAST = _require2.visitRegExpAST;
  77464. var _require3 = require("../util/unicode"),
  77465. isCombiningCharacter = _require3.isCombiningCharacter,
  77466. isEmojiModifier = _require3.isEmojiModifier,
  77467. isRegionalIndicatorSymbol = _require3.isRegionalIndicatorSymbol,
  77468. isSurrogatePair = _require3.isSurrogatePair;
  77469. //------------------------------------------------------------------------------
  77470. // Helpers
  77471. //------------------------------------------------------------------------------
  77472. /**
  77473. * Iterate character sequences of a given nodes.
  77474. *
  77475. * CharacterClassRange syntax can steal a part of character sequence,
  77476. * so this function reverts CharacterClassRange syntax and restore the sequence.
  77477. *
  77478. * @param {regexpp.AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
  77479. * @returns {IterableIterator<number[]>} The list of character sequences.
  77480. */
  77481. function iterateCharacterSequence(nodes) {
  77482. var seq, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, node;
  77483. return regeneratorRuntime.wrap(function iterateCharacterSequence$(_context) {
  77484. while (1) {
  77485. switch (_context.prev = _context.next) {
  77486. case 0:
  77487. seq = [];
  77488. _iteratorNormalCompletion = true;
  77489. _didIteratorError = false;
  77490. _iteratorError = undefined;
  77491. _context.prev = 4;
  77492. _iterator = nodes[Symbol.iterator]();
  77493. case 6:
  77494. if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
  77495. _context.next = 26;
  77496. break;
  77497. }
  77498. node = _step.value;
  77499. _context.t0 = node.type;
  77500. _context.next = _context.t0 === "Character" ? 11 : _context.t0 === "CharacterClassRange" ? 13 : _context.t0 === "CharacterSet" ? 18 : 23;
  77501. break;
  77502. case 11:
  77503. seq.push(node.value);
  77504. return _context.abrupt("break", 23);
  77505. case 13:
  77506. seq.push(node.min.value);
  77507. _context.next = 16;
  77508. return seq;
  77509. case 16:
  77510. seq = [node.max.value];
  77511. return _context.abrupt("break", 23);
  77512. case 18:
  77513. if (!(seq.length > 0)) {
  77514. _context.next = 22;
  77515. break;
  77516. }
  77517. _context.next = 21;
  77518. return seq;
  77519. case 21:
  77520. seq = [];
  77521. case 22:
  77522. return _context.abrupt("break", 23);
  77523. case 23:
  77524. _iteratorNormalCompletion = true;
  77525. _context.next = 6;
  77526. break;
  77527. case 26:
  77528. _context.next = 32;
  77529. break;
  77530. case 28:
  77531. _context.prev = 28;
  77532. _context.t1 = _context["catch"](4);
  77533. _didIteratorError = true;
  77534. _iteratorError = _context.t1;
  77535. case 32:
  77536. _context.prev = 32;
  77537. _context.prev = 33;
  77538. if (!_iteratorNormalCompletion && _iterator.return) {
  77539. _iterator.return();
  77540. }
  77541. case 35:
  77542. _context.prev = 35;
  77543. if (!_didIteratorError) {
  77544. _context.next = 38;
  77545. break;
  77546. }
  77547. throw _iteratorError;
  77548. case 38:
  77549. return _context.finish(35);
  77550. case 39:
  77551. return _context.finish(32);
  77552. case 40:
  77553. if (!(seq.length > 0)) {
  77554. _context.next = 43;
  77555. break;
  77556. }
  77557. _context.next = 43;
  77558. return seq;
  77559. case 43:
  77560. case "end":
  77561. return _context.stop();
  77562. }
  77563. }
  77564. }, _marked, this, [[4, 28, 32, 40], [33,, 35, 39]]);
  77565. }
  77566. var hasCharacterSequence = {
  77567. surrogatePairWithoutUFlag: function surrogatePairWithoutUFlag(chars) {
  77568. return chars.some(function (c, i) {
  77569. return i !== 0 && isSurrogatePair(chars[i - 1], c);
  77570. });
  77571. },
  77572. combiningClass: function combiningClass(chars) {
  77573. return chars.some(function (c, i) {
  77574. return i !== 0 && isCombiningCharacter(c) && !isCombiningCharacter(chars[i - 1]);
  77575. });
  77576. },
  77577. emojiModifier: function emojiModifier(chars) {
  77578. return chars.some(function (c, i) {
  77579. return i !== 0 && isEmojiModifier(c) && !isEmojiModifier(chars[i - 1]);
  77580. });
  77581. },
  77582. regionalIndicatorSymbol: function regionalIndicatorSymbol(chars) {
  77583. return chars.some(function (c, i) {
  77584. return i !== 0 && isRegionalIndicatorSymbol(c) && isRegionalIndicatorSymbol(chars[i - 1]);
  77585. });
  77586. },
  77587. zwj: function zwj(chars) {
  77588. var lastIndex = chars.length - 1;
  77589. return chars.some(function (c, i) {
  77590. return i !== 0 && i !== lastIndex && c === 0x200d && chars[i - 1] !== 0x200d && chars[i + 1] !== 0x200d;
  77591. });
  77592. }
  77593. };
  77594. var kinds = Object.keys(hasCharacterSequence);
  77595. //------------------------------------------------------------------------------
  77596. // Rule Definition
  77597. //------------------------------------------------------------------------------
  77598. module.exports = {
  77599. meta: {
  77600. type: "problem",
  77601. docs: {
  77602. description: "disallow characters which are made with multiple code points in character class syntax",
  77603. category: "Possible Errors",
  77604. recommended: false,
  77605. url: "https://eslint.org/docs/rules/no-misleading-character-class"
  77606. },
  77607. schema: [],
  77608. messages: {
  77609. surrogatePairWithoutUFlag: "Unexpected surrogate pair in character class. Use 'u' flag.",
  77610. combiningClass: "Unexpected combined character in character class.",
  77611. emojiModifier: "Unexpected modified Emoji in character class.",
  77612. regionalIndicatorSymbol: "Unexpected national flag in character class.",
  77613. zwj: "Unexpected joined character sequence in character class."
  77614. }
  77615. },
  77616. create: function create(context) {
  77617. var parser = new RegExpParser();
  77618. /**
  77619. * Verify a given regular expression.
  77620. * @param {Node} node The node to report.
  77621. * @param {string} pattern The regular expression pattern to verify.
  77622. * @param {string} flags The flags of the regular expression.
  77623. * @returns {void}
  77624. */
  77625. function verify(node, pattern, flags) {
  77626. var patternNode = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
  77627. var has = {
  77628. surrogatePairWithoutUFlag: false,
  77629. combiningClass: false,
  77630. variationSelector: false,
  77631. emojiModifier: false,
  77632. regionalIndicatorSymbol: false,
  77633. zwj: false
  77634. };
  77635. visitRegExpAST(patternNode, {
  77636. onCharacterClassEnter: function onCharacterClassEnter(ccNode) {
  77637. var _iteratorNormalCompletion2 = true;
  77638. var _didIteratorError2 = false;
  77639. var _iteratorError2 = undefined;
  77640. try {
  77641. for (var _iterator2 = iterateCharacterSequence(ccNode.elements)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  77642. var chars = _step2.value;
  77643. var _iteratorNormalCompletion3 = true;
  77644. var _didIteratorError3 = false;
  77645. var _iteratorError3 = undefined;
  77646. try {
  77647. for (var _iterator3 = kinds[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  77648. var kind = _step3.value;
  77649. has[kind] = has[kind] || hasCharacterSequence[kind](chars);
  77650. }
  77651. } catch (err) {
  77652. _didIteratorError3 = true;
  77653. _iteratorError3 = err;
  77654. } finally {
  77655. try {
  77656. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  77657. _iterator3.return();
  77658. }
  77659. } finally {
  77660. if (_didIteratorError3) {
  77661. throw _iteratorError3;
  77662. }
  77663. }
  77664. }
  77665. }
  77666. } catch (err) {
  77667. _didIteratorError2 = true;
  77668. _iteratorError2 = err;
  77669. } finally {
  77670. try {
  77671. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  77672. _iterator2.return();
  77673. }
  77674. } finally {
  77675. if (_didIteratorError2) {
  77676. throw _iteratorError2;
  77677. }
  77678. }
  77679. }
  77680. }
  77681. });
  77682. var _iteratorNormalCompletion4 = true;
  77683. var _didIteratorError4 = false;
  77684. var _iteratorError4 = undefined;
  77685. try {
  77686. for (var _iterator4 = kinds[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  77687. var kind = _step4.value;
  77688. if (has[kind]) {
  77689. context.report({ node: node, messageId: kind });
  77690. }
  77691. }
  77692. } catch (err) {
  77693. _didIteratorError4 = true;
  77694. _iteratorError4 = err;
  77695. } finally {
  77696. try {
  77697. if (!_iteratorNormalCompletion4 && _iterator4.return) {
  77698. _iterator4.return();
  77699. }
  77700. } finally {
  77701. if (_didIteratorError4) {
  77702. throw _iteratorError4;
  77703. }
  77704. }
  77705. }
  77706. }
  77707. return {
  77708. "Literal[regex]": function LiteralRegex(node) {
  77709. verify(node, node.regex.pattern, node.regex.flags);
  77710. },
  77711. "Program": function Program() {
  77712. var scope = context.getScope();
  77713. var tracker = new ReferenceTracker(scope);
  77714. /*
  77715. * Iterate calls of RegExp.
  77716. * E.g., `new RegExp()`, `RegExp()`, `new window.RegExp()`,
  77717. * `const {RegExp: a} = window; new a()`, etc...
  77718. */
  77719. var _iteratorNormalCompletion5 = true;
  77720. var _didIteratorError5 = false;
  77721. var _iteratorError5 = undefined;
  77722. try {
  77723. for (var _iterator5 = tracker.iterateGlobalReferences({
  77724. RegExp: (_RegExp = {}, _defineProperty(_RegExp, CALL, true), _defineProperty(_RegExp, CONSTRUCT, true), _RegExp)
  77725. })[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  77726. var _RegExp;
  77727. var node = _step5.value.node;
  77728. var _node$arguments = _slicedToArray(node.arguments, 2),
  77729. patternNode = _node$arguments[0],
  77730. flagsNode = _node$arguments[1];
  77731. var pattern = getStringIfConstant(patternNode, scope);
  77732. var flags = getStringIfConstant(flagsNode, scope);
  77733. if (typeof pattern === "string") {
  77734. verify(node, pattern, flags || "");
  77735. }
  77736. }
  77737. } catch (err) {
  77738. _didIteratorError5 = true;
  77739. _iteratorError5 = err;
  77740. } finally {
  77741. try {
  77742. if (!_iteratorNormalCompletion5 && _iterator5.return) {
  77743. _iterator5.return();
  77744. }
  77745. } finally {
  77746. if (_didIteratorError5) {
  77747. throw _iteratorError5;
  77748. }
  77749. }
  77750. }
  77751. }
  77752. };
  77753. }
  77754. };
  77755. },{"../util/unicode":419,"eslint-utils":68,"regexpp":104}],256:[function(require,module,exports){
  77756. /**
  77757. * @fileoverview Rule to disallow mixed binary operators.
  77758. * @author Toru Nagashima
  77759. */
  77760. "use strict";
  77761. //------------------------------------------------------------------------------
  77762. // Requirements
  77763. //------------------------------------------------------------------------------
  77764. var astUtils = require("../util/ast-utils.js");
  77765. //------------------------------------------------------------------------------
  77766. // Helpers
  77767. //------------------------------------------------------------------------------
  77768. var ARITHMETIC_OPERATORS = ["+", "-", "*", "/", "%", "**"];
  77769. var BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"];
  77770. var COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="];
  77771. var LOGICAL_OPERATORS = ["&&", "||"];
  77772. var RELATIONAL_OPERATORS = ["in", "instanceof"];
  77773. var ALL_OPERATORS = [].concat(ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS);
  77774. var DEFAULT_GROUPS = [ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS];
  77775. var TARGET_NODE_TYPE = /^(?:Binary|Logical)Expression$/;
  77776. /**
  77777. * Normalizes options.
  77778. *
  77779. * @param {Object|undefined} options - A options object to normalize.
  77780. * @returns {Object} Normalized option object.
  77781. */
  77782. function normalizeOptions(options) {
  77783. var hasGroups = options && options.groups && options.groups.length > 0;
  77784. var groups = hasGroups ? options.groups : DEFAULT_GROUPS;
  77785. var allowSamePrecedence = (options && options.allowSamePrecedence) !== false;
  77786. return {
  77787. groups: groups,
  77788. allowSamePrecedence: allowSamePrecedence
  77789. };
  77790. }
  77791. /**
  77792. * Checks whether any group which includes both given operator exists or not.
  77793. *
  77794. * @param {Array.<string[]>} groups - A list of groups to check.
  77795. * @param {string} left - An operator.
  77796. * @param {string} right - Another operator.
  77797. * @returns {boolean} `true` if such group existed.
  77798. */
  77799. function includesBothInAGroup(groups, left, right) {
  77800. return groups.some(function (group) {
  77801. return group.indexOf(left) !== -1 && group.indexOf(right) !== -1;
  77802. });
  77803. }
  77804. //------------------------------------------------------------------------------
  77805. // Rule Definition
  77806. //------------------------------------------------------------------------------
  77807. module.exports = {
  77808. meta: {
  77809. type: "suggestion",
  77810. docs: {
  77811. description: "disallow mixed binary operators",
  77812. category: "Stylistic Issues",
  77813. recommended: false,
  77814. url: "https://eslint.org/docs/rules/no-mixed-operators"
  77815. },
  77816. schema: [{
  77817. type: "object",
  77818. properties: {
  77819. groups: {
  77820. type: "array",
  77821. items: {
  77822. type: "array",
  77823. items: { enum: ALL_OPERATORS },
  77824. minItems: 2,
  77825. uniqueItems: true
  77826. },
  77827. uniqueItems: true
  77828. },
  77829. allowSamePrecedence: {
  77830. type: "boolean"
  77831. }
  77832. },
  77833. additionalProperties: false
  77834. }]
  77835. },
  77836. create: function create(context) {
  77837. var sourceCode = context.getSourceCode();
  77838. var options = normalizeOptions(context.options[0]);
  77839. /**
  77840. * Checks whether a given node should be ignored by options or not.
  77841. *
  77842. * @param {ASTNode} node - A node to check. This is a BinaryExpression
  77843. * node or a LogicalExpression node. This parent node is one of
  77844. * them, too.
  77845. * @returns {boolean} `true` if the node should be ignored.
  77846. */
  77847. function shouldIgnore(node) {
  77848. var a = node;
  77849. var b = node.parent;
  77850. return !includesBothInAGroup(options.groups, a.operator, b.operator) || options.allowSamePrecedence && astUtils.getPrecedence(a) === astUtils.getPrecedence(b);
  77851. }
  77852. /**
  77853. * Checks whether the operator of a given node is mixed with parent
  77854. * node's operator or not.
  77855. *
  77856. * @param {ASTNode} node - A node to check. This is a BinaryExpression
  77857. * node or a LogicalExpression node. This parent node is one of
  77858. * them, too.
  77859. * @returns {boolean} `true` if the node was mixed.
  77860. */
  77861. function isMixedWithParent(node) {
  77862. return node.operator !== node.parent.operator && !astUtils.isParenthesised(sourceCode, node);
  77863. }
  77864. /**
  77865. * Gets the operator token of a given node.
  77866. *
  77867. * @param {ASTNode} node - A node to check. This is a BinaryExpression
  77868. * node or a LogicalExpression node.
  77869. * @returns {Token} The operator token of the node.
  77870. */
  77871. function getOperatorToken(node) {
  77872. return sourceCode.getTokenAfter(node.left, astUtils.isNotClosingParenToken);
  77873. }
  77874. /**
  77875. * Reports both the operator of a given node and the operator of the
  77876. * parent node.
  77877. *
  77878. * @param {ASTNode} node - A node to check. This is a BinaryExpression
  77879. * node or a LogicalExpression node. This parent node is one of
  77880. * them, too.
  77881. * @returns {void}
  77882. */
  77883. function reportBothOperators(node) {
  77884. var parent = node.parent;
  77885. var left = parent.left === node ? node : parent;
  77886. var right = parent.left !== node ? node : parent;
  77887. var message = "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'.";
  77888. var data = {
  77889. leftOperator: left.operator,
  77890. rightOperator: right.operator
  77891. };
  77892. context.report({
  77893. node: left,
  77894. loc: getOperatorToken(left).loc.start,
  77895. message: message,
  77896. data: data
  77897. });
  77898. context.report({
  77899. node: right,
  77900. loc: getOperatorToken(right).loc.start,
  77901. message: message,
  77902. data: data
  77903. });
  77904. }
  77905. /**
  77906. * Checks between the operator of this node and the operator of the
  77907. * parent node.
  77908. *
  77909. * @param {ASTNode} node - A node to check.
  77910. * @returns {void}
  77911. */
  77912. function check(node) {
  77913. if (TARGET_NODE_TYPE.test(node.parent.type) && isMixedWithParent(node) && !shouldIgnore(node)) {
  77914. reportBothOperators(node);
  77915. }
  77916. }
  77917. return {
  77918. BinaryExpression: check,
  77919. LogicalExpression: check
  77920. };
  77921. }
  77922. };
  77923. },{"../util/ast-utils.js":405}],257:[function(require,module,exports){
  77924. /**
  77925. * @fileoverview Rule to enforce grouped require statements for Node.JS
  77926. * @author Raphael Pigulla
  77927. */
  77928. "use strict";
  77929. //------------------------------------------------------------------------------
  77930. // Rule Definition
  77931. //------------------------------------------------------------------------------
  77932. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  77933. module.exports = {
  77934. meta: {
  77935. type: "suggestion",
  77936. docs: {
  77937. description: "disallow `require` calls to be mixed with regular variable declarations",
  77938. category: "Node.js and CommonJS",
  77939. recommended: false,
  77940. url: "https://eslint.org/docs/rules/no-mixed-requires"
  77941. },
  77942. schema: [{
  77943. oneOf: [{
  77944. type: "boolean"
  77945. }, {
  77946. type: "object",
  77947. properties: {
  77948. grouping: {
  77949. type: "boolean"
  77950. },
  77951. allowCall: {
  77952. type: "boolean"
  77953. }
  77954. },
  77955. additionalProperties: false
  77956. }]
  77957. }]
  77958. },
  77959. create: function create(context) {
  77960. var options = context.options[0];
  77961. var grouping = false,
  77962. allowCall = false;
  77963. if ((typeof options === "undefined" ? "undefined" : _typeof(options)) === "object") {
  77964. grouping = options.grouping;
  77965. allowCall = options.allowCall;
  77966. } else {
  77967. grouping = !!options;
  77968. }
  77969. /**
  77970. * Returns the list of built-in modules.
  77971. *
  77972. * @returns {string[]} An array of built-in Node.js modules.
  77973. */
  77974. function getBuiltinModules() {
  77975. /*
  77976. * This list is generated using:
  77977. * `require("repl")._builtinLibs.concat('repl').sort()`
  77978. * This particular list is as per nodejs v0.12.2 and iojs v0.7.1
  77979. */
  77980. return ["assert", "buffer", "child_process", "cluster", "crypto", "dgram", "dns", "domain", "events", "fs", "http", "https", "net", "os", "path", "punycode", "querystring", "readline", "repl", "smalloc", "stream", "string_decoder", "tls", "tty", "url", "util", "v8", "vm", "zlib"];
  77981. }
  77982. var BUILTIN_MODULES = getBuiltinModules();
  77983. var DECL_REQUIRE = "require",
  77984. DECL_UNINITIALIZED = "uninitialized",
  77985. DECL_OTHER = "other";
  77986. var REQ_CORE = "core",
  77987. REQ_FILE = "file",
  77988. REQ_MODULE = "module",
  77989. REQ_COMPUTED = "computed";
  77990. /**
  77991. * Determines the type of a declaration statement.
  77992. * @param {ASTNode} initExpression The init node of the VariableDeclarator.
  77993. * @returns {string} The type of declaration represented by the expression.
  77994. */
  77995. function getDeclarationType(initExpression) {
  77996. if (!initExpression) {
  77997. // "var x;"
  77998. return DECL_UNINITIALIZED;
  77999. }
  78000. if (initExpression.type === "CallExpression" && initExpression.callee.type === "Identifier" && initExpression.callee.name === "require") {
  78001. // "var x = require('util');"
  78002. return DECL_REQUIRE;
  78003. }
  78004. if (allowCall && initExpression.type === "CallExpression" && initExpression.callee.type === "CallExpression") {
  78005. // "var x = require('diagnose')('sub-module');"
  78006. return getDeclarationType(initExpression.callee);
  78007. }
  78008. if (initExpression.type === "MemberExpression") {
  78009. // "var x = require('glob').Glob;"
  78010. return getDeclarationType(initExpression.object);
  78011. }
  78012. // "var x = 42;"
  78013. return DECL_OTHER;
  78014. }
  78015. /**
  78016. * Determines the type of module that is loaded via require.
  78017. * @param {ASTNode} initExpression The init node of the VariableDeclarator.
  78018. * @returns {string} The module type.
  78019. */
  78020. function inferModuleType(initExpression) {
  78021. if (initExpression.type === "MemberExpression") {
  78022. // "var x = require('glob').Glob;"
  78023. return inferModuleType(initExpression.object);
  78024. }
  78025. if (initExpression.arguments.length === 0) {
  78026. // "var x = require();"
  78027. return REQ_COMPUTED;
  78028. }
  78029. var arg = initExpression.arguments[0];
  78030. if (arg.type !== "Literal" || typeof arg.value !== "string") {
  78031. // "var x = require(42);"
  78032. return REQ_COMPUTED;
  78033. }
  78034. if (BUILTIN_MODULES.indexOf(arg.value) !== -1) {
  78035. // "var fs = require('fs');"
  78036. return REQ_CORE;
  78037. }
  78038. if (/^\.{0,2}\//.test(arg.value)) {
  78039. // "var utils = require('./utils');"
  78040. return REQ_FILE;
  78041. }
  78042. // "var async = require('async');"
  78043. return REQ_MODULE;
  78044. }
  78045. /**
  78046. * Check if the list of variable declarations is mixed, i.e. whether it
  78047. * contains both require and other declarations.
  78048. * @param {ASTNode} declarations The list of VariableDeclarators.
  78049. * @returns {boolean} True if the declarations are mixed, false if not.
  78050. */
  78051. function isMixed(declarations) {
  78052. var contains = {};
  78053. declarations.forEach(function (declaration) {
  78054. var type = getDeclarationType(declaration.init);
  78055. contains[type] = true;
  78056. });
  78057. return !!(contains[DECL_REQUIRE] && (contains[DECL_UNINITIALIZED] || contains[DECL_OTHER]));
  78058. }
  78059. /**
  78060. * Check if all require declarations in the given list are of the same
  78061. * type.
  78062. * @param {ASTNode} declarations The list of VariableDeclarators.
  78063. * @returns {boolean} True if the declarations are grouped, false if not.
  78064. */
  78065. function isGrouped(declarations) {
  78066. var found = {};
  78067. declarations.forEach(function (declaration) {
  78068. if (getDeclarationType(declaration.init) === DECL_REQUIRE) {
  78069. found[inferModuleType(declaration.init)] = true;
  78070. }
  78071. });
  78072. return Object.keys(found).length <= 1;
  78073. }
  78074. return {
  78075. VariableDeclaration: function VariableDeclaration(node) {
  78076. if (isMixed(node.declarations)) {
  78077. context.report({ node: node, message: "Do not mix 'require' and other declarations." });
  78078. } else if (grouping && !isGrouped(node.declarations)) {
  78079. context.report({ node: node, message: "Do not mix core, module, file and computed requires." });
  78080. }
  78081. }
  78082. };
  78083. }
  78084. };
  78085. },{}],258:[function(require,module,exports){
  78086. /**
  78087. * @fileoverview Disallow mixed spaces and tabs for indentation
  78088. * @author Jary Niebur
  78089. */
  78090. "use strict";
  78091. //------------------------------------------------------------------------------
  78092. // Rule Definition
  78093. //------------------------------------------------------------------------------
  78094. module.exports = {
  78095. meta: {
  78096. type: "layout",
  78097. docs: {
  78098. description: "disallow mixed spaces and tabs for indentation",
  78099. category: "Stylistic Issues",
  78100. recommended: true,
  78101. url: "https://eslint.org/docs/rules/no-mixed-spaces-and-tabs"
  78102. },
  78103. schema: [{
  78104. enum: ["smart-tabs", true, false]
  78105. }]
  78106. },
  78107. create: function create(context) {
  78108. var sourceCode = context.getSourceCode();
  78109. var smartTabs = void 0;
  78110. var ignoredLocs = [];
  78111. switch (context.options[0]) {
  78112. case true: // Support old syntax, maybe add deprecation warning here
  78113. case "smart-tabs":
  78114. smartTabs = true;
  78115. break;
  78116. default:
  78117. smartTabs = false;
  78118. }
  78119. /**
  78120. * Determines if a given line and column are before a location.
  78121. * @param {Location} loc The location object from an AST node.
  78122. * @param {int} line The line to check.
  78123. * @param {int} column The column to check.
  78124. * @returns {boolean} True if the line and column are before the location, false if not.
  78125. * @private
  78126. */
  78127. function beforeLoc(loc, line, column) {
  78128. if (line < loc.start.line) {
  78129. return true;
  78130. }
  78131. return line === loc.start.line && column < loc.start.column;
  78132. }
  78133. /**
  78134. * Determines if a given line and column are after a location.
  78135. * @param {Location} loc The location object from an AST node.
  78136. * @param {int} line The line to check.
  78137. * @param {int} column The column to check.
  78138. * @returns {boolean} True if the line and column are after the location, false if not.
  78139. * @private
  78140. */
  78141. function afterLoc(loc, line, column) {
  78142. if (line > loc.end.line) {
  78143. return true;
  78144. }
  78145. return line === loc.end.line && column > loc.end.column;
  78146. }
  78147. //--------------------------------------------------------------------------
  78148. // Public
  78149. //--------------------------------------------------------------------------
  78150. return {
  78151. TemplateElement: function TemplateElement(node) {
  78152. ignoredLocs.push(node.loc);
  78153. },
  78154. "Program:exit": function ProgramExit(node) {
  78155. /*
  78156. * At least one space followed by a tab
  78157. * or the reverse before non-tab/-space
  78158. * characters begin.
  78159. */
  78160. var regex = /^(?=[\t ]*(\t | \t))/;
  78161. var lines = sourceCode.lines,
  78162. comments = sourceCode.getAllComments();
  78163. comments.forEach(function (comment) {
  78164. ignoredLocs.push(comment.loc);
  78165. });
  78166. ignoredLocs.sort(function (first, second) {
  78167. if (beforeLoc(first, second.start.line, second.start.column)) {
  78168. return 1;
  78169. }
  78170. if (beforeLoc(second, first.start.line, second.start.column)) {
  78171. return -1;
  78172. }
  78173. return 0;
  78174. });
  78175. if (smartTabs) {
  78176. /*
  78177. * At least one space followed by a tab
  78178. * before non-tab/-space characters begin.
  78179. */
  78180. regex = /^(?=[\t ]* \t)/;
  78181. }
  78182. lines.forEach(function (line, i) {
  78183. var match = regex.exec(line);
  78184. if (match) {
  78185. var lineNumber = i + 1,
  78186. column = match.index + 1;
  78187. for (var j = 0; j < ignoredLocs.length; j++) {
  78188. if (beforeLoc(ignoredLocs[j], lineNumber, column)) {
  78189. continue;
  78190. }
  78191. if (afterLoc(ignoredLocs[j], lineNumber, column)) {
  78192. continue;
  78193. }
  78194. return;
  78195. }
  78196. context.report({ node: node, loc: { line: lineNumber, column: column }, message: "Mixed spaces and tabs." });
  78197. }
  78198. });
  78199. }
  78200. };
  78201. }
  78202. };
  78203. },{}],259:[function(require,module,exports){
  78204. /**
  78205. * @fileoverview Rule to check use of chained assignment expressions
  78206. * @author Stewart Rand
  78207. */
  78208. "use strict";
  78209. //------------------------------------------------------------------------------
  78210. // Rule Definition
  78211. //------------------------------------------------------------------------------
  78212. module.exports = {
  78213. meta: {
  78214. type: "suggestion",
  78215. docs: {
  78216. description: "disallow use of chained assignment expressions",
  78217. category: "Stylistic Issues",
  78218. recommended: false,
  78219. url: "https://eslint.org/docs/rules/no-multi-assign"
  78220. },
  78221. schema: []
  78222. },
  78223. create: function create(context) {
  78224. //--------------------------------------------------------------------------
  78225. // Public
  78226. //--------------------------------------------------------------------------
  78227. return {
  78228. AssignmentExpression: function AssignmentExpression(node) {
  78229. if (["AssignmentExpression", "VariableDeclarator"].indexOf(node.parent.type) !== -1) {
  78230. context.report({
  78231. node: node,
  78232. message: "Unexpected chained assignment."
  78233. });
  78234. }
  78235. }
  78236. };
  78237. }
  78238. };
  78239. },{}],260:[function(require,module,exports){
  78240. /**
  78241. * @fileoverview Disallow use of multiple spaces.
  78242. * @author Nicholas C. Zakas
  78243. */
  78244. "use strict";
  78245. var astUtils = require("../util/ast-utils");
  78246. //------------------------------------------------------------------------------
  78247. // Rule Definition
  78248. //------------------------------------------------------------------------------
  78249. module.exports = {
  78250. meta: {
  78251. type: "layout",
  78252. docs: {
  78253. description: "disallow multiple spaces",
  78254. category: "Best Practices",
  78255. recommended: false,
  78256. url: "https://eslint.org/docs/rules/no-multi-spaces"
  78257. },
  78258. fixable: "whitespace",
  78259. schema: [{
  78260. type: "object",
  78261. properties: {
  78262. exceptions: {
  78263. type: "object",
  78264. patternProperties: {
  78265. "^([A-Z][a-z]*)+$": {
  78266. type: "boolean"
  78267. }
  78268. },
  78269. additionalProperties: false
  78270. },
  78271. ignoreEOLComments: {
  78272. type: "boolean"
  78273. }
  78274. },
  78275. additionalProperties: false
  78276. }]
  78277. },
  78278. create: function create(context) {
  78279. var sourceCode = context.getSourceCode();
  78280. var options = context.options[0] || {};
  78281. var ignoreEOLComments = options.ignoreEOLComments;
  78282. var exceptions = Object.assign({ Property: true }, options.exceptions);
  78283. var hasExceptions = Object.keys(exceptions).filter(function (key) {
  78284. return exceptions[key];
  78285. }).length > 0;
  78286. /**
  78287. * Formats value of given comment token for error message by truncating its length.
  78288. * @param {Token} token comment token
  78289. * @returns {string} formatted value
  78290. * @private
  78291. */
  78292. function formatReportedCommentValue(token) {
  78293. var valueLines = token.value.split("\n");
  78294. var value = valueLines[0];
  78295. var formattedValue = value.slice(0, 12) + "...";
  78296. return valueLines.length === 1 && value.length <= 12 ? value : formattedValue;
  78297. }
  78298. //--------------------------------------------------------------------------
  78299. // Public
  78300. //--------------------------------------------------------------------------
  78301. return {
  78302. Program: function Program() {
  78303. sourceCode.tokensAndComments.forEach(function (leftToken, leftIndex, tokensAndComments) {
  78304. if (leftIndex === tokensAndComments.length - 1) {
  78305. return;
  78306. }
  78307. var rightToken = tokensAndComments[leftIndex + 1];
  78308. // Ignore tokens that don't have 2 spaces between them or are on different lines
  78309. if (!sourceCode.text.slice(leftToken.range[1], rightToken.range[0]).includes(" ") || leftToken.loc.end.line < rightToken.loc.start.line) {
  78310. return;
  78311. }
  78312. // Ignore comments that are the last token on their line if `ignoreEOLComments` is active.
  78313. if (ignoreEOLComments && astUtils.isCommentToken(rightToken) && (leftIndex === tokensAndComments.length - 2 || rightToken.loc.end.line < tokensAndComments[leftIndex + 2].loc.start.line)) {
  78314. return;
  78315. }
  78316. // Ignore tokens that are in a node in the "exceptions" object
  78317. if (hasExceptions) {
  78318. var parentNode = sourceCode.getNodeByRangeIndex(rightToken.range[0] - 1);
  78319. if (parentNode && exceptions[parentNode.type]) {
  78320. return;
  78321. }
  78322. }
  78323. var displayValue = void 0;
  78324. if (rightToken.type === "Block") {
  78325. displayValue = "/*" + formatReportedCommentValue(rightToken) + "*/";
  78326. } else if (rightToken.type === "Line") {
  78327. displayValue = "//" + formatReportedCommentValue(rightToken);
  78328. } else {
  78329. displayValue = rightToken.value;
  78330. }
  78331. context.report({
  78332. node: rightToken,
  78333. loc: rightToken.loc.start,
  78334. message: "Multiple spaces found before '{{displayValue}}'.",
  78335. data: { displayValue: displayValue },
  78336. fix: function fix(fixer) {
  78337. return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ");
  78338. }
  78339. });
  78340. });
  78341. }
  78342. };
  78343. }
  78344. };
  78345. },{"../util/ast-utils":405}],261:[function(require,module,exports){
  78346. /**
  78347. * @fileoverview Rule to flag when using multiline strings
  78348. * @author Ilya Volodin
  78349. */
  78350. "use strict";
  78351. //------------------------------------------------------------------------------
  78352. // Requirements
  78353. //------------------------------------------------------------------------------
  78354. var astUtils = require("../util/ast-utils");
  78355. //------------------------------------------------------------------------------
  78356. // Rule Definition
  78357. //------------------------------------------------------------------------------
  78358. module.exports = {
  78359. meta: {
  78360. type: "suggestion",
  78361. docs: {
  78362. description: "disallow multiline strings",
  78363. category: "Best Practices",
  78364. recommended: false,
  78365. url: "https://eslint.org/docs/rules/no-multi-str"
  78366. },
  78367. schema: []
  78368. },
  78369. create: function create(context) {
  78370. /**
  78371. * Determines if a given node is part of JSX syntax.
  78372. * @param {ASTNode} node The node to check.
  78373. * @returns {boolean} True if the node is a JSX node, false if not.
  78374. * @private
  78375. */
  78376. function isJSXElement(node) {
  78377. return node.type.indexOf("JSX") === 0;
  78378. }
  78379. //--------------------------------------------------------------------------
  78380. // Public API
  78381. //--------------------------------------------------------------------------
  78382. return {
  78383. Literal: function Literal(node) {
  78384. if (astUtils.LINEBREAK_MATCHER.test(node.raw) && !isJSXElement(node.parent)) {
  78385. context.report({ node: node, message: "Multiline support is limited to browsers supporting ES5 only." });
  78386. }
  78387. }
  78388. };
  78389. }
  78390. };
  78391. },{"../util/ast-utils":405}],262:[function(require,module,exports){
  78392. /**
  78393. * @fileoverview Disallows multiple blank lines.
  78394. * implementation adapted from the no-trailing-spaces rule.
  78395. * @author Greg Cochard
  78396. */
  78397. "use strict";
  78398. //------------------------------------------------------------------------------
  78399. // Rule Definition
  78400. //------------------------------------------------------------------------------
  78401. module.exports = {
  78402. meta: {
  78403. type: "layout",
  78404. docs: {
  78405. description: "disallow multiple empty lines",
  78406. category: "Stylistic Issues",
  78407. recommended: false,
  78408. url: "https://eslint.org/docs/rules/no-multiple-empty-lines"
  78409. },
  78410. fixable: "whitespace",
  78411. schema: [{
  78412. type: "object",
  78413. properties: {
  78414. max: {
  78415. type: "integer",
  78416. minimum: 0
  78417. },
  78418. maxEOF: {
  78419. type: "integer",
  78420. minimum: 0
  78421. },
  78422. maxBOF: {
  78423. type: "integer",
  78424. minimum: 0
  78425. }
  78426. },
  78427. required: ["max"],
  78428. additionalProperties: false
  78429. }]
  78430. },
  78431. create: function create(context) {
  78432. // Use options.max or 2 as default
  78433. var max = 2,
  78434. maxEOF = max,
  78435. maxBOF = max;
  78436. if (context.options.length) {
  78437. max = context.options[0].max;
  78438. maxEOF = typeof context.options[0].maxEOF !== "undefined" ? context.options[0].maxEOF : max;
  78439. maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max;
  78440. }
  78441. var sourceCode = context.getSourceCode();
  78442. // Swallow the final newline, as some editors add it automatically and we don't want it to cause an issue
  78443. var allLines = sourceCode.lines[sourceCode.lines.length - 1] === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines;
  78444. var templateLiteralLines = new Set();
  78445. //--------------------------------------------------------------------------
  78446. // Public
  78447. //--------------------------------------------------------------------------
  78448. return {
  78449. TemplateLiteral: function TemplateLiteral(node) {
  78450. node.quasis.forEach(function (literalPart) {
  78451. // Empty lines have a semantic meaning if they're inside template literals. Don't count these as empty lines.
  78452. for (var ignoredLine = literalPart.loc.start.line; ignoredLine < literalPart.loc.end.line; ignoredLine++) {
  78453. templateLiteralLines.add(ignoredLine);
  78454. }
  78455. });
  78456. },
  78457. "Program:exit": function ProgramExit(node) {
  78458. return allLines
  78459. // Given a list of lines, first get a list of line numbers that are non-empty.
  78460. .reduce(function (nonEmptyLineNumbers, line, index) {
  78461. if (line.trim() || templateLiteralLines.has(index + 1)) {
  78462. nonEmptyLineNumbers.push(index + 1);
  78463. }
  78464. return nonEmptyLineNumbers;
  78465. }, [])
  78466. // Add a value at the end to allow trailing empty lines to be checked.
  78467. .concat(allLines.length + 1)
  78468. // Given two line numbers of non-empty lines, report the lines between if the difference is too large.
  78469. .reduce(function (lastLineNumber, lineNumber) {
  78470. var message = void 0,
  78471. maxAllowed = void 0;
  78472. if (lastLineNumber === 0) {
  78473. message = "Too many blank lines at the beginning of file. Max of {{max}} allowed.";
  78474. maxAllowed = maxBOF;
  78475. } else if (lineNumber === allLines.length + 1) {
  78476. message = "Too many blank lines at the end of file. Max of {{max}} allowed.";
  78477. maxAllowed = maxEOF;
  78478. } else {
  78479. message = "More than {{max}} blank {{pluralizedLines}} not allowed.";
  78480. maxAllowed = max;
  78481. }
  78482. if (lineNumber - lastLineNumber - 1 > maxAllowed) {
  78483. context.report({
  78484. node: node,
  78485. loc: { start: { line: lastLineNumber + 1, column: 0 }, end: { line: lineNumber, column: 0 } },
  78486. message: message,
  78487. data: { max: maxAllowed, pluralizedLines: maxAllowed === 1 ? "line" : "lines" },
  78488. fix: function fix(fixer) {
  78489. var rangeStart = sourceCode.getIndexFromLoc({ line: lastLineNumber + 1, column: 0 });
  78490. /*
  78491. * The end of the removal range is usually the start index of the next line.
  78492. * However, at the end of the file there is no next line, so the end of the
  78493. * range is just the length of the text.
  78494. */
  78495. var lineNumberAfterRemovedLines = lineNumber - maxAllowed;
  78496. var rangeEnd = lineNumberAfterRemovedLines <= allLines.length ? sourceCode.getIndexFromLoc({ line: lineNumberAfterRemovedLines, column: 0 }) : sourceCode.text.length;
  78497. return fixer.removeRange([rangeStart, rangeEnd]);
  78498. }
  78499. });
  78500. }
  78501. return lineNumber;
  78502. }, 0);
  78503. }
  78504. };
  78505. }
  78506. };
  78507. },{}],263:[function(require,module,exports){
  78508. /**
  78509. * @fileoverview Rule to disallow assignments to native objects or read-only global variables
  78510. * @author Ilya Volodin
  78511. * @deprecated in ESLint v3.3.0
  78512. */
  78513. "use strict";
  78514. //------------------------------------------------------------------------------
  78515. // Rule Definition
  78516. //------------------------------------------------------------------------------
  78517. module.exports = {
  78518. meta: {
  78519. type: "suggestion",
  78520. docs: {
  78521. description: "disallow assignments to native objects or read-only global variables",
  78522. category: "Best Practices",
  78523. recommended: false,
  78524. url: "https://eslint.org/docs/rules/no-native-reassign"
  78525. },
  78526. deprecated: true,
  78527. replacedBy: ["no-global-assign"],
  78528. schema: [{
  78529. type: "object",
  78530. properties: {
  78531. exceptions: {
  78532. type: "array",
  78533. items: { type: "string" },
  78534. uniqueItems: true
  78535. }
  78536. },
  78537. additionalProperties: false
  78538. }]
  78539. },
  78540. create: function create(context) {
  78541. var config = context.options[0];
  78542. var exceptions = config && config.exceptions || [];
  78543. /**
  78544. * Reports write references.
  78545. * @param {Reference} reference - A reference to check.
  78546. * @param {int} index - The index of the reference in the references.
  78547. * @param {Reference[]} references - The array that the reference belongs to.
  78548. * @returns {void}
  78549. */
  78550. function checkReference(reference, index, references) {
  78551. var identifier = reference.identifier;
  78552. if (reference.init === false && reference.isWrite() && (
  78553. /*
  78554. * Destructuring assignments can have multiple default value,
  78555. * so possibly there are multiple writeable references for the same identifier.
  78556. */
  78557. index === 0 || references[index - 1].identifier !== identifier)) {
  78558. context.report({
  78559. node: identifier,
  78560. message: "Read-only global '{{name}}' should not be modified.",
  78561. data: identifier
  78562. });
  78563. }
  78564. }
  78565. /**
  78566. * Reports write references if a given variable is read-only builtin.
  78567. * @param {Variable} variable - A variable to check.
  78568. * @returns {void}
  78569. */
  78570. function checkVariable(variable) {
  78571. if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
  78572. variable.references.forEach(checkReference);
  78573. }
  78574. }
  78575. return {
  78576. Program: function Program() {
  78577. var globalScope = context.getScope();
  78578. globalScope.variables.forEach(checkVariable);
  78579. }
  78580. };
  78581. }
  78582. };
  78583. },{}],264:[function(require,module,exports){
  78584. /**
  78585. * @fileoverview Rule to disallow a negated condition
  78586. * @author Alberto Rodríguez
  78587. */
  78588. "use strict";
  78589. //------------------------------------------------------------------------------
  78590. // Rule Definition
  78591. //------------------------------------------------------------------------------
  78592. module.exports = {
  78593. meta: {
  78594. type: "suggestion",
  78595. docs: {
  78596. description: "disallow negated conditions",
  78597. category: "Stylistic Issues",
  78598. recommended: false,
  78599. url: "https://eslint.org/docs/rules/no-negated-condition"
  78600. },
  78601. schema: []
  78602. },
  78603. create: function create(context) {
  78604. /**
  78605. * Determines if a given node is an if-else without a condition on the else
  78606. * @param {ASTNode} node The node to check.
  78607. * @returns {boolean} True if the node has an else without an if.
  78608. * @private
  78609. */
  78610. function hasElseWithoutCondition(node) {
  78611. return node.alternate && node.alternate.type !== "IfStatement";
  78612. }
  78613. /**
  78614. * Determines if a given node is a negated unary expression
  78615. * @param {Object} test The test object to check.
  78616. * @returns {boolean} True if the node is a negated unary expression.
  78617. * @private
  78618. */
  78619. function isNegatedUnaryExpression(test) {
  78620. return test.type === "UnaryExpression" && test.operator === "!";
  78621. }
  78622. /**
  78623. * Determines if a given node is a negated binary expression
  78624. * @param {Test} test The test to check.
  78625. * @returns {boolean} True if the node is a negated binary expression.
  78626. * @private
  78627. */
  78628. function isNegatedBinaryExpression(test) {
  78629. return test.type === "BinaryExpression" && (test.operator === "!=" || test.operator === "!==");
  78630. }
  78631. /**
  78632. * Determines if a given node has a negated if expression
  78633. * @param {ASTNode} node The node to check.
  78634. * @returns {boolean} True if the node has a negated if expression.
  78635. * @private
  78636. */
  78637. function isNegatedIf(node) {
  78638. return isNegatedUnaryExpression(node.test) || isNegatedBinaryExpression(node.test);
  78639. }
  78640. return {
  78641. IfStatement: function IfStatement(node) {
  78642. if (!hasElseWithoutCondition(node)) {
  78643. return;
  78644. }
  78645. if (isNegatedIf(node)) {
  78646. context.report({ node: node, message: "Unexpected negated condition." });
  78647. }
  78648. },
  78649. ConditionalExpression: function ConditionalExpression(node) {
  78650. if (isNegatedIf(node)) {
  78651. context.report({ node: node, message: "Unexpected negated condition." });
  78652. }
  78653. }
  78654. };
  78655. }
  78656. };
  78657. },{}],265:[function(require,module,exports){
  78658. /**
  78659. * @fileoverview A rule to disallow negated left operands of the `in` operator
  78660. * @author Michael Ficarra
  78661. * @deprecated in ESLint v3.3.0
  78662. */
  78663. "use strict";
  78664. //------------------------------------------------------------------------------
  78665. // Rule Definition
  78666. //------------------------------------------------------------------------------
  78667. module.exports = {
  78668. meta: {
  78669. type: "problem",
  78670. docs: {
  78671. description: "disallow negating the left operand in `in` expressions",
  78672. category: "Possible Errors",
  78673. recommended: false,
  78674. url: "https://eslint.org/docs/rules/no-negated-in-lhs"
  78675. },
  78676. replacedBy: ["no-unsafe-negation"],
  78677. deprecated: true,
  78678. schema: []
  78679. },
  78680. create: function create(context) {
  78681. return {
  78682. BinaryExpression: function BinaryExpression(node) {
  78683. if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") {
  78684. context.report({ node: node, message: "The 'in' expression's left operand is negated." });
  78685. }
  78686. }
  78687. };
  78688. }
  78689. };
  78690. },{}],266:[function(require,module,exports){
  78691. /**
  78692. * @fileoverview Rule to flag nested ternary expressions
  78693. * @author Ian Christian Myers
  78694. */
  78695. "use strict";
  78696. //------------------------------------------------------------------------------
  78697. // Rule Definition
  78698. //------------------------------------------------------------------------------
  78699. module.exports = {
  78700. meta: {
  78701. type: "suggestion",
  78702. docs: {
  78703. description: "disallow nested ternary expressions",
  78704. category: "Stylistic Issues",
  78705. recommended: false,
  78706. url: "https://eslint.org/docs/rules/no-nested-ternary"
  78707. },
  78708. schema: []
  78709. },
  78710. create: function create(context) {
  78711. return {
  78712. ConditionalExpression: function ConditionalExpression(node) {
  78713. if (node.alternate.type === "ConditionalExpression" || node.consequent.type === "ConditionalExpression") {
  78714. context.report({ node: node, message: "Do not nest ternary expressions." });
  78715. }
  78716. }
  78717. };
  78718. }
  78719. };
  78720. },{}],267:[function(require,module,exports){
  78721. /**
  78722. * @fileoverview Rule to flag when using new Function
  78723. * @author Ilya Volodin
  78724. */
  78725. "use strict";
  78726. //------------------------------------------------------------------------------
  78727. // Rule Definition
  78728. //------------------------------------------------------------------------------
  78729. module.exports = {
  78730. meta: {
  78731. type: "suggestion",
  78732. docs: {
  78733. description: "disallow `new` operators with the `Function` object",
  78734. category: "Best Practices",
  78735. recommended: false,
  78736. url: "https://eslint.org/docs/rules/no-new-func"
  78737. },
  78738. schema: []
  78739. },
  78740. create: function create(context) {
  78741. //--------------------------------------------------------------------------
  78742. // Helpers
  78743. //--------------------------------------------------------------------------
  78744. /**
  78745. * Reports a node.
  78746. * @param {ASTNode} node The node to report
  78747. * @returns {void}
  78748. * @private
  78749. */
  78750. function report(node) {
  78751. context.report({ node: node, message: "The Function constructor is eval." });
  78752. }
  78753. return {
  78754. "NewExpression[callee.name = 'Function']": report,
  78755. "CallExpression[callee.name = 'Function']": report
  78756. };
  78757. }
  78758. };
  78759. },{}],268:[function(require,module,exports){
  78760. /**
  78761. * @fileoverview A rule to disallow calls to the Object constructor
  78762. * @author Matt DuVall <http://www.mattduvall.com/>
  78763. */
  78764. "use strict";
  78765. //------------------------------------------------------------------------------
  78766. // Rule Definition
  78767. //------------------------------------------------------------------------------
  78768. module.exports = {
  78769. meta: {
  78770. type: "suggestion",
  78771. docs: {
  78772. description: "disallow `Object` constructors",
  78773. category: "Stylistic Issues",
  78774. recommended: false,
  78775. url: "https://eslint.org/docs/rules/no-new-object"
  78776. },
  78777. schema: []
  78778. },
  78779. create: function create(context) {
  78780. return {
  78781. NewExpression: function NewExpression(node) {
  78782. if (node.callee.name === "Object") {
  78783. context.report({ node: node, message: "The object literal notation {} is preferrable." });
  78784. }
  78785. }
  78786. };
  78787. }
  78788. };
  78789. },{}],269:[function(require,module,exports){
  78790. /**
  78791. * @fileoverview Rule to disallow use of new operator with the `require` function
  78792. * @author Wil Moore III
  78793. */
  78794. "use strict";
  78795. //------------------------------------------------------------------------------
  78796. // Rule Definition
  78797. //------------------------------------------------------------------------------
  78798. module.exports = {
  78799. meta: {
  78800. type: "suggestion",
  78801. docs: {
  78802. description: "disallow `new` operators with calls to `require`",
  78803. category: "Node.js and CommonJS",
  78804. recommended: false,
  78805. url: "https://eslint.org/docs/rules/no-new-require"
  78806. },
  78807. schema: []
  78808. },
  78809. create: function create(context) {
  78810. return {
  78811. NewExpression: function NewExpression(node) {
  78812. if (node.callee.type === "Identifier" && node.callee.name === "require") {
  78813. context.report({ node: node, message: "Unexpected use of new with require." });
  78814. }
  78815. }
  78816. };
  78817. }
  78818. };
  78819. },{}],270:[function(require,module,exports){
  78820. /**
  78821. * @fileoverview Rule to disallow use of the new operator with the `Symbol` object
  78822. * @author Alberto Rodríguez
  78823. */
  78824. "use strict";
  78825. //------------------------------------------------------------------------------
  78826. // Rule Definition
  78827. //------------------------------------------------------------------------------
  78828. module.exports = {
  78829. meta: {
  78830. type: "problem",
  78831. docs: {
  78832. description: "disallow `new` operators with the `Symbol` object",
  78833. category: "ECMAScript 6",
  78834. recommended: true,
  78835. url: "https://eslint.org/docs/rules/no-new-symbol"
  78836. },
  78837. schema: []
  78838. },
  78839. create: function create(context) {
  78840. return {
  78841. "Program:exit": function ProgramExit() {
  78842. var globalScope = context.getScope();
  78843. var variable = globalScope.set.get("Symbol");
  78844. if (variable && variable.defs.length === 0) {
  78845. variable.references.forEach(function (ref) {
  78846. var node = ref.identifier;
  78847. if (node.parent && node.parent.type === "NewExpression") {
  78848. context.report({ node: node, message: "`Symbol` cannot be called as a constructor." });
  78849. }
  78850. });
  78851. }
  78852. }
  78853. };
  78854. }
  78855. };
  78856. },{}],271:[function(require,module,exports){
  78857. /**
  78858. * @fileoverview Rule to flag when using constructor for wrapper objects
  78859. * @author Ilya Volodin
  78860. */
  78861. "use strict";
  78862. //------------------------------------------------------------------------------
  78863. // Rule Definition
  78864. //------------------------------------------------------------------------------
  78865. module.exports = {
  78866. meta: {
  78867. type: "suggestion",
  78868. docs: {
  78869. description: "disallow `new` operators with the `String`, `Number`, and `Boolean` objects",
  78870. category: "Best Practices",
  78871. recommended: false,
  78872. url: "https://eslint.org/docs/rules/no-new-wrappers"
  78873. },
  78874. schema: []
  78875. },
  78876. create: function create(context) {
  78877. return {
  78878. NewExpression: function NewExpression(node) {
  78879. var wrapperObjects = ["String", "Number", "Boolean", "Math", "JSON"];
  78880. if (wrapperObjects.indexOf(node.callee.name) > -1) {
  78881. context.report({ node: node, message: "Do not use {{fn}} as a constructor.", data: { fn: node.callee.name } });
  78882. }
  78883. }
  78884. };
  78885. }
  78886. };
  78887. },{}],272:[function(require,module,exports){
  78888. /**
  78889. * @fileoverview Rule to flag statements with function invocation preceded by
  78890. * "new" and not part of assignment
  78891. * @author Ilya Volodin
  78892. */
  78893. "use strict";
  78894. //------------------------------------------------------------------------------
  78895. // Rule Definition
  78896. //------------------------------------------------------------------------------
  78897. module.exports = {
  78898. meta: {
  78899. type: "suggestion",
  78900. docs: {
  78901. description: "disallow `new` operators outside of assignments or comparisons",
  78902. category: "Best Practices",
  78903. recommended: false,
  78904. url: "https://eslint.org/docs/rules/no-new"
  78905. },
  78906. schema: []
  78907. },
  78908. create: function create(context) {
  78909. return {
  78910. "ExpressionStatement > NewExpression": function ExpressionStatementNewExpression(node) {
  78911. context.report({ node: node.parent, message: "Do not use 'new' for side effects." });
  78912. }
  78913. };
  78914. }
  78915. };
  78916. },{}],273:[function(require,module,exports){
  78917. /**
  78918. * @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function
  78919. * @author James Allardice
  78920. */
  78921. "use strict";
  78922. //------------------------------------------------------------------------------
  78923. // Rule Definition
  78924. //------------------------------------------------------------------------------
  78925. module.exports = {
  78926. meta: {
  78927. type: "problem",
  78928. docs: {
  78929. description: "disallow calling global object properties as functions",
  78930. category: "Possible Errors",
  78931. recommended: true,
  78932. url: "https://eslint.org/docs/rules/no-obj-calls"
  78933. },
  78934. schema: []
  78935. },
  78936. create: function create(context) {
  78937. return {
  78938. CallExpression: function CallExpression(node) {
  78939. if (node.callee.type === "Identifier") {
  78940. var name = node.callee.name;
  78941. if (name === "Math" || name === "JSON" || name === "Reflect") {
  78942. context.report({ node: node, message: "'{{name}}' is not a function.", data: { name: name } });
  78943. }
  78944. }
  78945. }
  78946. };
  78947. }
  78948. };
  78949. },{}],274:[function(require,module,exports){
  78950. /**
  78951. * @fileoverview Rule to flag octal escape sequences in string literals.
  78952. * @author Ian Christian Myers
  78953. */
  78954. "use strict";
  78955. //------------------------------------------------------------------------------
  78956. // Rule Definition
  78957. //------------------------------------------------------------------------------
  78958. module.exports = {
  78959. meta: {
  78960. type: "suggestion",
  78961. docs: {
  78962. description: "disallow octal escape sequences in string literals",
  78963. category: "Best Practices",
  78964. recommended: false,
  78965. url: "https://eslint.org/docs/rules/no-octal-escape"
  78966. },
  78967. schema: []
  78968. },
  78969. create: function create(context) {
  78970. return {
  78971. Literal: function Literal(node) {
  78972. if (typeof node.value !== "string") {
  78973. return;
  78974. }
  78975. var match = node.raw.match(/^([^\\]|\\[^0-7])*\\([0-3][0-7]{1,2}|[4-7][0-7]|[0-7])/);
  78976. if (match) {
  78977. var octalDigit = match[2];
  78978. // \0 is actually not considered an octal
  78979. if (match[2] !== "0" || typeof match[3] !== "undefined") {
  78980. context.report({ node: node, message: "Don't use octal: '\\{{octalDigit}}'. Use '\\u....' instead.", data: { octalDigit: octalDigit } });
  78981. }
  78982. }
  78983. }
  78984. };
  78985. }
  78986. };
  78987. },{}],275:[function(require,module,exports){
  78988. /**
  78989. * @fileoverview Rule to flag when initializing octal literal
  78990. * @author Ilya Volodin
  78991. */
  78992. "use strict";
  78993. //------------------------------------------------------------------------------
  78994. // Rule Definition
  78995. //------------------------------------------------------------------------------
  78996. module.exports = {
  78997. meta: {
  78998. type: "suggestion",
  78999. docs: {
  79000. description: "disallow octal literals",
  79001. category: "Best Practices",
  79002. recommended: true,
  79003. url: "https://eslint.org/docs/rules/no-octal"
  79004. },
  79005. schema: []
  79006. },
  79007. create: function create(context) {
  79008. return {
  79009. Literal: function Literal(node) {
  79010. if (typeof node.value === "number" && /^0[0-7]/.test(node.raw)) {
  79011. context.report({ node: node, message: "Octal literals should not be used." });
  79012. }
  79013. }
  79014. };
  79015. }
  79016. };
  79017. },{}],276:[function(require,module,exports){
  79018. /**
  79019. * @fileoverview Disallow reassignment of function parameters.
  79020. * @author Nat Burns
  79021. */
  79022. "use strict";
  79023. //------------------------------------------------------------------------------
  79024. // Rule Definition
  79025. //------------------------------------------------------------------------------
  79026. var stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Program)$/;
  79027. module.exports = {
  79028. meta: {
  79029. type: "suggestion",
  79030. docs: {
  79031. description: "disallow reassigning `function` parameters",
  79032. category: "Best Practices",
  79033. recommended: false,
  79034. url: "https://eslint.org/docs/rules/no-param-reassign"
  79035. },
  79036. schema: [{
  79037. oneOf: [{
  79038. type: "object",
  79039. properties: {
  79040. props: {
  79041. enum: [false]
  79042. }
  79043. },
  79044. additionalProperties: false
  79045. }, {
  79046. type: "object",
  79047. properties: {
  79048. props: {
  79049. enum: [true]
  79050. },
  79051. ignorePropertyModificationsFor: {
  79052. type: "array",
  79053. items: {
  79054. type: "string"
  79055. },
  79056. uniqueItems: true
  79057. }
  79058. },
  79059. additionalProperties: false
  79060. }]
  79061. }]
  79062. },
  79063. create: function create(context) {
  79064. var props = context.options[0] && Boolean(context.options[0].props);
  79065. var ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [];
  79066. /**
  79067. * Checks whether or not the reference modifies properties of its variable.
  79068. * @param {Reference} reference - A reference to check.
  79069. * @returns {boolean} Whether or not the reference modifies properties of its variable.
  79070. */
  79071. function isModifyingProp(reference) {
  79072. var node = reference.identifier;
  79073. var parent = node.parent;
  79074. while (parent && !stopNodePattern.test(parent.type)) {
  79075. switch (parent.type) {
  79076. // e.g. foo.a = 0;
  79077. case "AssignmentExpression":
  79078. return parent.left === node;
  79079. // e.g. ++foo.a;
  79080. case "UpdateExpression":
  79081. return true;
  79082. // e.g. delete foo.a;
  79083. case "UnaryExpression":
  79084. if (parent.operator === "delete") {
  79085. return true;
  79086. }
  79087. break;
  79088. // EXCLUDES: e.g. cache.get(foo.a).b = 0;
  79089. case "CallExpression":
  79090. if (parent.callee !== node) {
  79091. return false;
  79092. }
  79093. break;
  79094. // EXCLUDES: e.g. cache[foo.a] = 0;
  79095. case "MemberExpression":
  79096. if (parent.property === node) {
  79097. return false;
  79098. }
  79099. break;
  79100. // EXCLUDES: e.g. ({ [foo]: a }) = bar;
  79101. case "Property":
  79102. if (parent.key === node) {
  79103. return false;
  79104. }
  79105. break;
  79106. // no default
  79107. }
  79108. node = parent;
  79109. parent = node.parent;
  79110. }
  79111. return false;
  79112. }
  79113. /**
  79114. * Reports a reference if is non initializer and writable.
  79115. * @param {Reference} reference - A reference to check.
  79116. * @param {int} index - The index of the reference in the references.
  79117. * @param {Reference[]} references - The array that the reference belongs to.
  79118. * @returns {void}
  79119. */
  79120. function checkReference(reference, index, references) {
  79121. var identifier = reference.identifier;
  79122. if (identifier && !reference.init && (
  79123. /*
  79124. * Destructuring assignments can have multiple default value,
  79125. * so possibly there are multiple writeable references for the same identifier.
  79126. */
  79127. index === 0 || references[index - 1].identifier !== identifier)) {
  79128. if (reference.isWrite()) {
  79129. context.report({ node: identifier, message: "Assignment to function parameter '{{name}}'.", data: { name: identifier.name } });
  79130. } else if (props && isModifyingProp(reference) && ignoredPropertyAssignmentsFor.indexOf(identifier.name) === -1) {
  79131. context.report({ node: identifier, message: "Assignment to property of function parameter '{{name}}'.", data: { name: identifier.name } });
  79132. }
  79133. }
  79134. }
  79135. /**
  79136. * Finds and reports references that are non initializer and writable.
  79137. * @param {Variable} variable - A variable to check.
  79138. * @returns {void}
  79139. */
  79140. function checkVariable(variable) {
  79141. if (variable.defs[0].type === "Parameter") {
  79142. variable.references.forEach(checkReference);
  79143. }
  79144. }
  79145. /**
  79146. * Checks parameters of a given function node.
  79147. * @param {ASTNode} node - A function node to check.
  79148. * @returns {void}
  79149. */
  79150. function checkForFunction(node) {
  79151. context.getDeclaredVariables(node).forEach(checkVariable);
  79152. }
  79153. return {
  79154. // `:exit` is needed for the `node.parent` property of identifier nodes.
  79155. "FunctionDeclaration:exit": checkForFunction,
  79156. "FunctionExpression:exit": checkForFunction,
  79157. "ArrowFunctionExpression:exit": checkForFunction
  79158. };
  79159. }
  79160. };
  79161. },{}],277:[function(require,module,exports){
  79162. /**
  79163. * @fileoverview Disallow string concatenation when using __dirname and __filename
  79164. * @author Nicholas C. Zakas
  79165. */
  79166. "use strict";
  79167. //------------------------------------------------------------------------------
  79168. // Rule Definition
  79169. //------------------------------------------------------------------------------
  79170. module.exports = {
  79171. meta: {
  79172. type: "suggestion",
  79173. docs: {
  79174. description: "disallow string concatenation with `__dirname` and `__filename`",
  79175. category: "Node.js and CommonJS",
  79176. recommended: false,
  79177. url: "https://eslint.org/docs/rules/no-path-concat"
  79178. },
  79179. schema: []
  79180. },
  79181. create: function create(context) {
  79182. var MATCHER = /^__(?:dir|file)name$/;
  79183. //--------------------------------------------------------------------------
  79184. // Public
  79185. //--------------------------------------------------------------------------
  79186. return {
  79187. BinaryExpression: function BinaryExpression(node) {
  79188. var left = node.left,
  79189. right = node.right;
  79190. if (node.operator === "+" && (left.type === "Identifier" && MATCHER.test(left.name) || right.type === "Identifier" && MATCHER.test(right.name))) {
  79191. context.report({ node: node, message: "Use path.join() or path.resolve() instead of + to create paths." });
  79192. }
  79193. }
  79194. };
  79195. }
  79196. };
  79197. },{}],278:[function(require,module,exports){
  79198. /**
  79199. * @fileoverview Rule to flag use of unary increment and decrement operators.
  79200. * @author Ian Christian Myers
  79201. * @author Brody McKee (github.com/mrmckeb)
  79202. */
  79203. "use strict";
  79204. //------------------------------------------------------------------------------
  79205. // Rule Definition
  79206. //------------------------------------------------------------------------------
  79207. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  79208. module.exports = {
  79209. meta: {
  79210. type: "suggestion",
  79211. docs: {
  79212. description: "disallow the unary operators `++` and `--`",
  79213. category: "Stylistic Issues",
  79214. recommended: false,
  79215. url: "https://eslint.org/docs/rules/no-plusplus"
  79216. },
  79217. schema: [{
  79218. type: "object",
  79219. properties: {
  79220. allowForLoopAfterthoughts: {
  79221. type: "boolean"
  79222. }
  79223. },
  79224. additionalProperties: false
  79225. }]
  79226. },
  79227. create: function create(context) {
  79228. var config = context.options[0];
  79229. var allowInForAfterthought = false;
  79230. if ((typeof config === "undefined" ? "undefined" : _typeof(config)) === "object") {
  79231. allowInForAfterthought = config.allowForLoopAfterthoughts === true;
  79232. }
  79233. return {
  79234. UpdateExpression: function UpdateExpression(node) {
  79235. if (allowInForAfterthought && node.parent.type === "ForStatement") {
  79236. return;
  79237. }
  79238. context.report({
  79239. node: node,
  79240. message: "Unary operator '{{operator}}' used.",
  79241. data: {
  79242. operator: node.operator
  79243. }
  79244. });
  79245. }
  79246. };
  79247. }
  79248. };
  79249. },{}],279:[function(require,module,exports){
  79250. /**
  79251. * @fileoverview Disallow the use of process.env()
  79252. * @author Vignesh Anand
  79253. */
  79254. "use strict";
  79255. //------------------------------------------------------------------------------
  79256. // Rule Definition
  79257. //------------------------------------------------------------------------------
  79258. module.exports = {
  79259. meta: {
  79260. type: "suggestion",
  79261. docs: {
  79262. description: "disallow the use of `process.env`",
  79263. category: "Node.js and CommonJS",
  79264. recommended: false,
  79265. url: "https://eslint.org/docs/rules/no-process-env"
  79266. },
  79267. schema: []
  79268. },
  79269. create: function create(context) {
  79270. return {
  79271. MemberExpression: function MemberExpression(node) {
  79272. var objectName = node.object.name,
  79273. propertyName = node.property.name;
  79274. if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
  79275. context.report({ node: node, message: "Unexpected use of process.env." });
  79276. }
  79277. }
  79278. };
  79279. }
  79280. };
  79281. },{}],280:[function(require,module,exports){
  79282. /**
  79283. * @fileoverview Disallow the use of process.exit()
  79284. * @author Nicholas C. Zakas
  79285. */
  79286. "use strict";
  79287. //------------------------------------------------------------------------------
  79288. // Rule Definition
  79289. //------------------------------------------------------------------------------
  79290. module.exports = {
  79291. meta: {
  79292. type: "suggestion",
  79293. docs: {
  79294. description: "disallow the use of `process.exit()`",
  79295. category: "Node.js and CommonJS",
  79296. recommended: false,
  79297. url: "https://eslint.org/docs/rules/no-process-exit"
  79298. },
  79299. schema: []
  79300. },
  79301. create: function create(context) {
  79302. //--------------------------------------------------------------------------
  79303. // Public
  79304. //--------------------------------------------------------------------------
  79305. return {
  79306. "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']": function CallExpressionMemberExpressionCalleeObjectNameProcessPropertyNameExit(node) {
  79307. context.report({ node: node.parent, message: "Don't use process.exit(); throw an error instead." });
  79308. }
  79309. };
  79310. }
  79311. };
  79312. },{}],281:[function(require,module,exports){
  79313. /**
  79314. * @fileoverview Rule to flag usage of __proto__ property
  79315. * @author Ilya Volodin
  79316. */
  79317. "use strict";
  79318. //------------------------------------------------------------------------------
  79319. // Rule Definition
  79320. //------------------------------------------------------------------------------
  79321. module.exports = {
  79322. meta: {
  79323. type: "suggestion",
  79324. docs: {
  79325. description: "disallow the use of the `__proto__` property",
  79326. category: "Best Practices",
  79327. recommended: false,
  79328. url: "https://eslint.org/docs/rules/no-proto"
  79329. },
  79330. schema: []
  79331. },
  79332. create: function create(context) {
  79333. return {
  79334. MemberExpression: function MemberExpression(node) {
  79335. if (node.property && node.property.type === "Identifier" && node.property.name === "__proto__" && !node.computed || node.property.type === "Literal" && node.property.value === "__proto__") {
  79336. context.report({ node: node, message: "The '__proto__' property is deprecated." });
  79337. }
  79338. }
  79339. };
  79340. }
  79341. };
  79342. },{}],282:[function(require,module,exports){
  79343. /**
  79344. * @fileoverview Rule to disallow use of Object.prototype builtins on objects
  79345. * @author Andrew Levine
  79346. */
  79347. "use strict";
  79348. //------------------------------------------------------------------------------
  79349. // Rule Definition
  79350. //------------------------------------------------------------------------------
  79351. module.exports = {
  79352. meta: {
  79353. type: "problem",
  79354. docs: {
  79355. description: "disallow calling some `Object.prototype` methods directly on objects",
  79356. category: "Possible Errors",
  79357. recommended: false,
  79358. url: "https://eslint.org/docs/rules/no-prototype-builtins"
  79359. },
  79360. schema: []
  79361. },
  79362. create: function create(context) {
  79363. var DISALLOWED_PROPS = ["hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"];
  79364. /**
  79365. * Reports if a disallowed property is used in a CallExpression
  79366. * @param {ASTNode} node The CallExpression node.
  79367. * @returns {void}
  79368. */
  79369. function disallowBuiltIns(node) {
  79370. if (node.callee.type !== "MemberExpression" || node.callee.computed) {
  79371. return;
  79372. }
  79373. var propName = node.callee.property.name;
  79374. if (DISALLOWED_PROPS.indexOf(propName) > -1) {
  79375. context.report({
  79376. message: "Do not access Object.prototype method '{{prop}}' from target object.",
  79377. loc: node.callee.property.loc.start,
  79378. data: { prop: propName },
  79379. node: node
  79380. });
  79381. }
  79382. }
  79383. return {
  79384. CallExpression: disallowBuiltIns
  79385. };
  79386. }
  79387. };
  79388. },{}],283:[function(require,module,exports){
  79389. /**
  79390. * @fileoverview Rule to flag when the same variable is declared more then once.
  79391. * @author Ilya Volodin
  79392. */
  79393. "use strict";
  79394. //------------------------------------------------------------------------------
  79395. // Rule Definition
  79396. //------------------------------------------------------------------------------
  79397. module.exports = {
  79398. meta: {
  79399. type: "suggestion",
  79400. docs: {
  79401. description: "disallow variable redeclaration",
  79402. category: "Best Practices",
  79403. recommended: true,
  79404. url: "https://eslint.org/docs/rules/no-redeclare"
  79405. },
  79406. schema: [{
  79407. type: "object",
  79408. properties: {
  79409. builtinGlobals: { type: "boolean" }
  79410. },
  79411. additionalProperties: false
  79412. }]
  79413. },
  79414. create: function create(context) {
  79415. var options = {
  79416. builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals)
  79417. };
  79418. /**
  79419. * Find variables in a given scope and flag redeclared ones.
  79420. * @param {Scope} scope - An eslint-scope scope object.
  79421. * @returns {void}
  79422. * @private
  79423. */
  79424. function findVariablesInScope(scope) {
  79425. scope.variables.forEach(function (variable) {
  79426. var hasBuiltin = options.builtinGlobals && "writeable" in variable;
  79427. var count = (hasBuiltin ? 1 : 0) + variable.identifiers.length;
  79428. if (count >= 2) {
  79429. variable.identifiers.sort(function (a, b) {
  79430. return a.range[1] - b.range[1];
  79431. });
  79432. for (var i = hasBuiltin ? 0 : 1, l = variable.identifiers.length; i < l; i++) {
  79433. context.report({ node: variable.identifiers[i], message: "'{{a}}' is already defined.", data: { a: variable.name } });
  79434. }
  79435. }
  79436. });
  79437. }
  79438. /**
  79439. * Find variables in the current scope.
  79440. * @param {ASTNode} node - The Program node.
  79441. * @returns {void}
  79442. * @private
  79443. */
  79444. function checkForGlobal(node) {
  79445. var scope = context.getScope(),
  79446. parserOptions = context.parserOptions,
  79447. ecmaFeatures = parserOptions.ecmaFeatures || {};
  79448. // Nodejs env or modules has a special scope.
  79449. if (ecmaFeatures.globalReturn || node.sourceType === "module") {
  79450. findVariablesInScope(scope.childScopes[0]);
  79451. } else {
  79452. findVariablesInScope(scope);
  79453. }
  79454. }
  79455. /**
  79456. * Find variables in the current scope.
  79457. * @returns {void}
  79458. * @private
  79459. */
  79460. function checkForBlock() {
  79461. findVariablesInScope(context.getScope());
  79462. }
  79463. if (context.parserOptions.ecmaVersion >= 6) {
  79464. return {
  79465. Program: checkForGlobal,
  79466. BlockStatement: checkForBlock,
  79467. SwitchStatement: checkForBlock
  79468. };
  79469. }
  79470. return {
  79471. Program: checkForGlobal,
  79472. FunctionDeclaration: checkForBlock,
  79473. FunctionExpression: checkForBlock,
  79474. ArrowFunctionExpression: checkForBlock
  79475. };
  79476. }
  79477. };
  79478. },{}],284:[function(require,module,exports){
  79479. /**
  79480. * @fileoverview Rule to count multiple spaces in regular expressions
  79481. * @author Matt DuVall <http://www.mattduvall.com/>
  79482. */
  79483. "use strict";
  79484. var astUtils = require("../util/ast-utils");
  79485. //------------------------------------------------------------------------------
  79486. // Rule Definition
  79487. //------------------------------------------------------------------------------
  79488. module.exports = {
  79489. meta: {
  79490. type: "suggestion",
  79491. docs: {
  79492. description: "disallow multiple spaces in regular expressions",
  79493. category: "Possible Errors",
  79494. recommended: true,
  79495. url: "https://eslint.org/docs/rules/no-regex-spaces"
  79496. },
  79497. schema: [],
  79498. fixable: "code"
  79499. },
  79500. create: function create(context) {
  79501. var sourceCode = context.getSourceCode();
  79502. /**
  79503. * Validate regular expressions
  79504. * @param {ASTNode} node node to validate
  79505. * @param {string} value regular expression to validate
  79506. * @param {number} valueStart The start location of the regex/string literal. It will always be the case that
  79507. * `sourceCode.getText().slice(valueStart, valueStart + value.length) === value`
  79508. * @returns {void}
  79509. * @private
  79510. */
  79511. function checkRegex(node, value, valueStart) {
  79512. var multipleSpacesRegex = /( {2,})( [+*{?]|[^+*{?]|$)/,
  79513. regexResults = multipleSpacesRegex.exec(value);
  79514. if (regexResults !== null) {
  79515. var count = regexResults[1].length;
  79516. context.report({
  79517. node: node,
  79518. message: "Spaces are hard to count. Use {{{count}}}.",
  79519. data: { count: count },
  79520. fix: function fix(fixer) {
  79521. return fixer.replaceTextRange([valueStart + regexResults.index, valueStart + regexResults.index + count], " {" + count + "}");
  79522. }
  79523. });
  79524. /*
  79525. * TODO: (platinumazure) Fix message to use rule message
  79526. * substitution when api.report is fixed in lib/eslint.js.
  79527. */
  79528. }
  79529. }
  79530. /**
  79531. * Validate regular expression literals
  79532. * @param {ASTNode} node node to validate
  79533. * @returns {void}
  79534. * @private
  79535. */
  79536. function checkLiteral(node) {
  79537. var token = sourceCode.getFirstToken(node),
  79538. nodeType = token.type,
  79539. nodeValue = token.value;
  79540. if (nodeType === "RegularExpression") {
  79541. checkRegex(node, nodeValue, token.range[0]);
  79542. }
  79543. }
  79544. /**
  79545. * Check if node is a string
  79546. * @param {ASTNode} node node to evaluate
  79547. * @returns {boolean} True if its a string
  79548. * @private
  79549. */
  79550. function isString(node) {
  79551. return node && node.type === "Literal" && typeof node.value === "string";
  79552. }
  79553. /**
  79554. * Validate strings passed to the RegExp constructor
  79555. * @param {ASTNode} node node to validate
  79556. * @returns {void}
  79557. * @private
  79558. */
  79559. function checkFunction(node) {
  79560. var scope = context.getScope();
  79561. var regExpVar = astUtils.getVariableByName(scope, "RegExp");
  79562. var shadowed = regExpVar && regExpVar.defs.length > 0;
  79563. if (node.callee.type === "Identifier" && node.callee.name === "RegExp" && isString(node.arguments[0]) && !shadowed) {
  79564. checkRegex(node, node.arguments[0].value, node.arguments[0].range[0] + 1);
  79565. }
  79566. }
  79567. return {
  79568. Literal: checkLiteral,
  79569. CallExpression: checkFunction,
  79570. NewExpression: checkFunction
  79571. };
  79572. }
  79573. };
  79574. },{"../util/ast-utils":405}],285:[function(require,module,exports){
  79575. /**
  79576. * @fileoverview Restrict usage of specified globals.
  79577. * @author Benoît Zugmeyer
  79578. */
  79579. "use strict";
  79580. //------------------------------------------------------------------------------
  79581. // Helpers
  79582. //------------------------------------------------------------------------------
  79583. var DEFAULT_MESSAGE_TEMPLATE = "Unexpected use of '{{name}}'.",
  79584. CUSTOM_MESSAGE_TEMPLATE = "Unexpected use of '{{name}}'. {{customMessage}}";
  79585. //------------------------------------------------------------------------------
  79586. // Rule Definition
  79587. //------------------------------------------------------------------------------
  79588. module.exports = {
  79589. meta: {
  79590. type: "suggestion",
  79591. docs: {
  79592. description: "disallow specified global variables",
  79593. category: "Variables",
  79594. recommended: false,
  79595. url: "https://eslint.org/docs/rules/no-restricted-globals"
  79596. },
  79597. schema: {
  79598. type: "array",
  79599. items: {
  79600. oneOf: [{
  79601. type: "string"
  79602. }, {
  79603. type: "object",
  79604. properties: {
  79605. name: { type: "string" },
  79606. message: { type: "string" }
  79607. },
  79608. required: ["name"],
  79609. additionalProperties: false
  79610. }]
  79611. },
  79612. uniqueItems: true,
  79613. minItems: 0
  79614. }
  79615. },
  79616. create: function create(context) {
  79617. // If no globals are restricted, we don't need to do anything
  79618. if (context.options.length === 0) {
  79619. return {};
  79620. }
  79621. var restrictedGlobalMessages = context.options.reduce(function (memo, option) {
  79622. if (typeof option === "string") {
  79623. memo[option] = null;
  79624. } else {
  79625. memo[option.name] = option.message;
  79626. }
  79627. return memo;
  79628. }, {});
  79629. /**
  79630. * Report a variable to be used as a restricted global.
  79631. * @param {Reference} reference the variable reference
  79632. * @returns {void}
  79633. * @private
  79634. */
  79635. function reportReference(reference) {
  79636. var name = reference.identifier.name,
  79637. customMessage = restrictedGlobalMessages[name],
  79638. message = customMessage ? CUSTOM_MESSAGE_TEMPLATE : DEFAULT_MESSAGE_TEMPLATE;
  79639. context.report({
  79640. node: reference.identifier,
  79641. message: message,
  79642. data: {
  79643. name: name,
  79644. customMessage: customMessage
  79645. }
  79646. });
  79647. }
  79648. /**
  79649. * Check if the given name is a restricted global name.
  79650. * @param {string} name name of a variable
  79651. * @returns {boolean} whether the variable is a restricted global or not
  79652. * @private
  79653. */
  79654. function isRestricted(name) {
  79655. return Object.prototype.hasOwnProperty.call(restrictedGlobalMessages, name);
  79656. }
  79657. return {
  79658. Program: function Program() {
  79659. var scope = context.getScope();
  79660. // Report variables declared elsewhere (ex: variables defined as "global" by eslint)
  79661. scope.variables.forEach(function (variable) {
  79662. if (!variable.defs.length && isRestricted(variable.name)) {
  79663. variable.references.forEach(reportReference);
  79664. }
  79665. });
  79666. // Report variables not declared at all
  79667. scope.through.forEach(function (reference) {
  79668. if (isRestricted(reference.identifier.name)) {
  79669. reportReference(reference);
  79670. }
  79671. });
  79672. }
  79673. };
  79674. }
  79675. };
  79676. },{}],286:[function(require,module,exports){
  79677. /**
  79678. * @fileoverview Restrict usage of specified node imports.
  79679. * @author Guy Ellis
  79680. */
  79681. "use strict";
  79682. //------------------------------------------------------------------------------
  79683. // Helpers
  79684. //------------------------------------------------------------------------------
  79685. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  79686. var DEFAULT_MESSAGE_TEMPLATE = "'{{importSource}}' import is restricted from being used.";
  79687. var CUSTOM_MESSAGE_TEMPLATE = "'{{importSource}}' import is restricted from being used. {{customMessage}}";
  79688. //------------------------------------------------------------------------------
  79689. // Rule Definition
  79690. //------------------------------------------------------------------------------
  79691. var ignore = require("ignore");
  79692. var arrayOfStrings = {
  79693. type: "array",
  79694. items: { type: "string" },
  79695. uniqueItems: true
  79696. };
  79697. var arrayOfStringsOrObjects = {
  79698. type: "array",
  79699. items: {
  79700. anyOf: [{ type: "string" }, {
  79701. type: "object",
  79702. properties: {
  79703. name: { type: "string" },
  79704. message: {
  79705. type: "string",
  79706. minLength: 1
  79707. },
  79708. importNames: {
  79709. type: "array",
  79710. items: {
  79711. type: "string"
  79712. }
  79713. }
  79714. },
  79715. additionalProperties: false,
  79716. required: ["name"]
  79717. }]
  79718. },
  79719. uniqueItems: true
  79720. };
  79721. module.exports = {
  79722. meta: {
  79723. type: "suggestion",
  79724. docs: {
  79725. description: "disallow specified modules when loaded by `import`",
  79726. category: "ECMAScript 6",
  79727. recommended: false,
  79728. url: "https://eslint.org/docs/rules/no-restricted-imports"
  79729. },
  79730. schema: {
  79731. anyOf: [arrayOfStringsOrObjects, {
  79732. type: "array",
  79733. items: {
  79734. type: "object",
  79735. properties: {
  79736. paths: arrayOfStringsOrObjects,
  79737. patterns: arrayOfStrings
  79738. },
  79739. additionalProperties: false
  79740. },
  79741. additionalItems: false
  79742. }]
  79743. }
  79744. },
  79745. create: function create(context) {
  79746. var options = Array.isArray(context.options) ? context.options : [];
  79747. var isPathAndPatternsObject = _typeof(options[0]) === "object" && (Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
  79748. var restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
  79749. var restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];
  79750. var restrictedPathMessages = restrictedPaths.reduce(function (memo, importSource) {
  79751. if (typeof importSource === "string") {
  79752. memo[importSource] = { message: null };
  79753. } else {
  79754. memo[importSource.name] = {
  79755. message: importSource.message,
  79756. importNames: importSource.importNames
  79757. };
  79758. }
  79759. return memo;
  79760. }, {});
  79761. // if no imports are restricted we don"t need to check
  79762. if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) {
  79763. return {};
  79764. }
  79765. var restrictedPatternsMatcher = ignore().add(restrictedPatterns);
  79766. /**
  79767. * Checks to see if "*" is being used to import everything.
  79768. * @param {Set.<string>} importNames - Set of import names that are being imported
  79769. * @returns {boolean} whether everything is imported or not
  79770. */
  79771. function isEverythingImported(importNames) {
  79772. return importNames.has("*");
  79773. }
  79774. /**
  79775. * Report a restricted path.
  79776. * @param {node} node representing the restricted path reference
  79777. * @returns {void}
  79778. * @private
  79779. */
  79780. function reportPath(node) {
  79781. var importSource = node.source.value.trim();
  79782. var customMessage = restrictedPathMessages[importSource] && restrictedPathMessages[importSource].message;
  79783. var message = customMessage ? CUSTOM_MESSAGE_TEMPLATE : DEFAULT_MESSAGE_TEMPLATE;
  79784. context.report({
  79785. node: node,
  79786. message: message,
  79787. data: {
  79788. importSource: importSource,
  79789. customMessage: customMessage
  79790. }
  79791. });
  79792. }
  79793. /**
  79794. * Report a restricted path specifically for patterns.
  79795. * @param {node} node - representing the restricted path reference
  79796. * @returns {void}
  79797. * @private
  79798. */
  79799. function reportPathForPatterns(node) {
  79800. var importSource = node.source.value.trim();
  79801. context.report({
  79802. node: node,
  79803. message: "'{{importSource}}' import is restricted from being used by a pattern.",
  79804. data: {
  79805. importSource: importSource
  79806. }
  79807. });
  79808. }
  79809. /**
  79810. * Report a restricted path specifically when using the '*' import.
  79811. * @param {string} importSource - path of the import
  79812. * @param {node} node - representing the restricted path reference
  79813. * @returns {void}
  79814. * @private
  79815. */
  79816. function reportPathForEverythingImported(importSource, node) {
  79817. var importNames = restrictedPathMessages[importSource].importNames;
  79818. context.report({
  79819. node: node,
  79820. message: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.",
  79821. data: {
  79822. importSource: importSource,
  79823. importNames: importNames
  79824. }
  79825. });
  79826. }
  79827. /**
  79828. * Check if the given importSource is restricted because '*' is being imported.
  79829. * @param {string} importSource - path of the import
  79830. * @param {Set.<string>} importNames - Set of import names that are being imported
  79831. * @returns {boolean} whether the path is restricted
  79832. * @private
  79833. */
  79834. function isRestrictedForEverythingImported(importSource, importNames) {
  79835. return Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource) && restrictedPathMessages[importSource].importNames && isEverythingImported(importNames);
  79836. }
  79837. /**
  79838. * Check if the given importNames are restricted given a list of restrictedImportNames.
  79839. * @param {Set.<string>} importNames - Set of import names that are being imported
  79840. * @param {string[]} restrictedImportNames - array of import names that are restricted for this import
  79841. * @returns {boolean} whether the objectName is restricted
  79842. * @private
  79843. */
  79844. function isRestrictedObject(importNames, restrictedImportNames) {
  79845. return restrictedImportNames.some(function (restrictedObjectName) {
  79846. return importNames.has(restrictedObjectName);
  79847. });
  79848. }
  79849. /**
  79850. * Check if the given importSource is a restricted path.
  79851. * @param {string} importSource - path of the import
  79852. * @param {Set.<string>} importNames - Set of import names that are being imported
  79853. * @returns {boolean} whether the variable is a restricted path or not
  79854. * @private
  79855. */
  79856. function isRestrictedPath(importSource, importNames) {
  79857. var isRestricted = false;
  79858. if (Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource)) {
  79859. if (restrictedPathMessages[importSource].importNames) {
  79860. isRestricted = isRestrictedObject(importNames, restrictedPathMessages[importSource].importNames);
  79861. } else {
  79862. isRestricted = true;
  79863. }
  79864. }
  79865. return isRestricted;
  79866. }
  79867. /**
  79868. * Check if the given importSource is restricted by a pattern.
  79869. * @param {string} importSource - path of the import
  79870. * @returns {boolean} whether the variable is a restricted pattern or not
  79871. * @private
  79872. */
  79873. function isRestrictedPattern(importSource) {
  79874. return restrictedPatterns.length > 0 && restrictedPatternsMatcher.ignores(importSource);
  79875. }
  79876. /**
  79877. * Checks a node to see if any problems should be reported.
  79878. * @param {ASTNode} node The node to check.
  79879. * @returns {void}
  79880. * @private
  79881. */
  79882. function checkNode(node) {
  79883. var importSource = node.source.value.trim();
  79884. var importNames = node.specifiers ? node.specifiers.reduce(function (set, specifier) {
  79885. if (specifier.type === "ImportDefaultSpecifier") {
  79886. set.add("default");
  79887. } else if (specifier.type === "ImportNamespaceSpecifier") {
  79888. set.add("*");
  79889. } else if (specifier.imported) {
  79890. set.add(specifier.imported.name);
  79891. } else if (specifier.local) {
  79892. set.add(specifier.local.name);
  79893. }
  79894. return set;
  79895. }, new Set()) : new Set();
  79896. if (isRestrictedForEverythingImported(importSource, importNames)) {
  79897. reportPathForEverythingImported(importSource, node);
  79898. }
  79899. if (isRestrictedPath(importSource, importNames)) {
  79900. reportPath(node);
  79901. }
  79902. if (isRestrictedPattern(importSource)) {
  79903. reportPathForPatterns(node);
  79904. }
  79905. }
  79906. return {
  79907. ImportDeclaration: checkNode,
  79908. ExportNamedDeclaration: function ExportNamedDeclaration(node) {
  79909. if (node.source) {
  79910. checkNode(node);
  79911. }
  79912. },
  79913. ExportAllDeclaration: checkNode
  79914. };
  79915. }
  79916. };
  79917. },{"ignore":86}],287:[function(require,module,exports){
  79918. /**
  79919. * @fileoverview Restrict usage of specified node modules.
  79920. * @author Christian Schulz
  79921. */
  79922. "use strict";
  79923. //------------------------------------------------------------------------------
  79924. // Helpers
  79925. //------------------------------------------------------------------------------
  79926. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  79927. var DEFAULT_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used.";
  79928. var CUSTOM_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used. {{customMessage}}";
  79929. //------------------------------------------------------------------------------
  79930. // Rule Definition
  79931. //------------------------------------------------------------------------------
  79932. var ignore = require("ignore");
  79933. var arrayOfStrings = {
  79934. type: "array",
  79935. items: { type: "string" },
  79936. uniqueItems: true
  79937. };
  79938. var arrayOfStringsOrObjects = {
  79939. type: "array",
  79940. items: {
  79941. anyOf: [{ type: "string" }, {
  79942. type: "object",
  79943. properties: {
  79944. name: { type: "string" },
  79945. message: {
  79946. type: "string",
  79947. minLength: 1
  79948. }
  79949. },
  79950. additionalProperties: false,
  79951. required: ["name"]
  79952. }]
  79953. },
  79954. uniqueItems: true
  79955. };
  79956. module.exports = {
  79957. meta: {
  79958. type: "suggestion",
  79959. docs: {
  79960. description: "disallow specified modules when loaded by `require`",
  79961. category: "Node.js and CommonJS",
  79962. recommended: false,
  79963. url: "https://eslint.org/docs/rules/no-restricted-modules"
  79964. },
  79965. schema: {
  79966. anyOf: [arrayOfStringsOrObjects, {
  79967. type: "array",
  79968. items: {
  79969. type: "object",
  79970. properties: {
  79971. paths: arrayOfStringsOrObjects,
  79972. patterns: arrayOfStrings
  79973. },
  79974. additionalProperties: false
  79975. },
  79976. additionalItems: false
  79977. }]
  79978. }
  79979. },
  79980. create: function create(context) {
  79981. var options = Array.isArray(context.options) ? context.options : [];
  79982. var isPathAndPatternsObject = _typeof(options[0]) === "object" && (Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
  79983. var restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
  79984. var restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];
  79985. var restrictedPathMessages = restrictedPaths.reduce(function (memo, importName) {
  79986. if (typeof importName === "string") {
  79987. memo[importName] = null;
  79988. } else {
  79989. memo[importName.name] = importName.message;
  79990. }
  79991. return memo;
  79992. }, {});
  79993. // if no imports are restricted we don"t need to check
  79994. if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) {
  79995. return {};
  79996. }
  79997. var ig = ignore().add(restrictedPatterns);
  79998. /**
  79999. * Function to check if a node is a string literal.
  80000. * @param {ASTNode} node The node to check.
  80001. * @returns {boolean} If the node is a string literal.
  80002. */
  80003. function isString(node) {
  80004. return node && node.type === "Literal" && typeof node.value === "string";
  80005. }
  80006. /**
  80007. * Function to check if a node is a require call.
  80008. * @param {ASTNode} node The node to check.
  80009. * @returns {boolean} If the node is a require call.
  80010. */
  80011. function isRequireCall(node) {
  80012. return node.callee.type === "Identifier" && node.callee.name === "require";
  80013. }
  80014. /**
  80015. * Report a restricted path.
  80016. * @param {node} node representing the restricted path reference
  80017. * @returns {void}
  80018. * @private
  80019. */
  80020. function reportPath(node) {
  80021. var moduleName = node.arguments[0].value.trim();
  80022. var customMessage = restrictedPathMessages[moduleName];
  80023. var message = customMessage ? CUSTOM_MESSAGE_TEMPLATE : DEFAULT_MESSAGE_TEMPLATE;
  80024. context.report({
  80025. node: node,
  80026. message: message,
  80027. data: {
  80028. moduleName: moduleName,
  80029. customMessage: customMessage
  80030. }
  80031. });
  80032. }
  80033. /**
  80034. * Check if the given name is a restricted path name
  80035. * @param {string} name name of a variable
  80036. * @returns {boolean} whether the variable is a restricted path or not
  80037. * @private
  80038. */
  80039. function isRestrictedPath(name) {
  80040. return Object.prototype.hasOwnProperty.call(restrictedPathMessages, name);
  80041. }
  80042. return {
  80043. CallExpression: function CallExpression(node) {
  80044. if (isRequireCall(node)) {
  80045. // node has arguments and first argument is string
  80046. if (node.arguments.length && isString(node.arguments[0])) {
  80047. var moduleName = node.arguments[0].value.trim();
  80048. // check if argument value is in restricted modules array
  80049. if (isRestrictedPath(moduleName)) {
  80050. reportPath(node);
  80051. }
  80052. if (restrictedPatterns.length > 0 && ig.ignores(moduleName)) {
  80053. context.report({
  80054. node: node,
  80055. message: "'{{moduleName}}' module is restricted from being used by a pattern.",
  80056. data: { moduleName: moduleName }
  80057. });
  80058. }
  80059. }
  80060. }
  80061. }
  80062. };
  80063. }
  80064. };
  80065. },{"ignore":86}],288:[function(require,module,exports){
  80066. /**
  80067. * @fileoverview Rule to disallow certain object properties
  80068. * @author Will Klein & Eli White
  80069. */
  80070. "use strict";
  80071. var astUtils = require("../util/ast-utils");
  80072. //------------------------------------------------------------------------------
  80073. // Rule Definition
  80074. //------------------------------------------------------------------------------
  80075. module.exports = {
  80076. meta: {
  80077. type: "suggestion",
  80078. docs: {
  80079. description: "disallow certain properties on certain objects",
  80080. category: "Best Practices",
  80081. recommended: false,
  80082. url: "https://eslint.org/docs/rules/no-restricted-properties"
  80083. },
  80084. schema: {
  80085. type: "array",
  80086. items: {
  80087. anyOf: [// `object` and `property` are both optional, but at least one of them must be provided.
  80088. {
  80089. type: "object",
  80090. properties: {
  80091. object: {
  80092. type: "string"
  80093. },
  80094. property: {
  80095. type: "string"
  80096. },
  80097. message: {
  80098. type: "string"
  80099. }
  80100. },
  80101. additionalProperties: false,
  80102. required: ["object"]
  80103. }, {
  80104. type: "object",
  80105. properties: {
  80106. object: {
  80107. type: "string"
  80108. },
  80109. property: {
  80110. type: "string"
  80111. },
  80112. message: {
  80113. type: "string"
  80114. }
  80115. },
  80116. additionalProperties: false,
  80117. required: ["property"]
  80118. }]
  80119. },
  80120. uniqueItems: true
  80121. }
  80122. },
  80123. create: function create(context) {
  80124. var restrictedCalls = context.options;
  80125. if (restrictedCalls.length === 0) {
  80126. return {};
  80127. }
  80128. var restrictedProperties = new Map();
  80129. var globallyRestrictedObjects = new Map();
  80130. var globallyRestrictedProperties = new Map();
  80131. restrictedCalls.forEach(function (option) {
  80132. var objectName = option.object;
  80133. var propertyName = option.property;
  80134. if (typeof objectName === "undefined") {
  80135. globallyRestrictedProperties.set(propertyName, { message: option.message });
  80136. } else if (typeof propertyName === "undefined") {
  80137. globallyRestrictedObjects.set(objectName, { message: option.message });
  80138. } else {
  80139. if (!restrictedProperties.has(objectName)) {
  80140. restrictedProperties.set(objectName, new Map());
  80141. }
  80142. restrictedProperties.get(objectName).set(propertyName, {
  80143. message: option.message
  80144. });
  80145. }
  80146. });
  80147. /**
  80148. * Checks to see whether a property access is restricted, and reports it if so.
  80149. * @param {ASTNode} node The node to report
  80150. * @param {string} objectName The name of the object
  80151. * @param {string} propertyName The name of the property
  80152. * @returns {undefined}
  80153. */
  80154. function checkPropertyAccess(node, objectName, propertyName) {
  80155. if (propertyName === null) {
  80156. return;
  80157. }
  80158. var matchedObject = restrictedProperties.get(objectName);
  80159. var matchedObjectProperty = matchedObject ? matchedObject.get(propertyName) : globallyRestrictedObjects.get(objectName);
  80160. var globalMatchedProperty = globallyRestrictedProperties.get(propertyName);
  80161. if (matchedObjectProperty) {
  80162. var message = matchedObjectProperty.message ? " " + matchedObjectProperty.message : "";
  80163. context.report({
  80164. node: node,
  80165. // eslint-disable-next-line eslint-plugin/report-message-format
  80166. message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}",
  80167. data: {
  80168. objectName: objectName,
  80169. propertyName: propertyName,
  80170. message: message
  80171. }
  80172. });
  80173. } else if (globalMatchedProperty) {
  80174. var _message = globalMatchedProperty.message ? " " + globalMatchedProperty.message : "";
  80175. context.report({
  80176. node: node,
  80177. // eslint-disable-next-line eslint-plugin/report-message-format
  80178. message: "'{{propertyName}}' is restricted from being used.{{message}}",
  80179. data: {
  80180. propertyName: propertyName,
  80181. message: _message
  80182. }
  80183. });
  80184. }
  80185. }
  80186. /**
  80187. * Checks property accesses in a destructuring assignment expression, e.g. `var foo; ({foo} = bar);`
  80188. * @param {ASTNode} node An AssignmentExpression or AssignmentPattern node
  80189. * @returns {undefined}
  80190. */
  80191. function checkDestructuringAssignment(node) {
  80192. if (node.right.type === "Identifier") {
  80193. var objectName = node.right.name;
  80194. if (node.left.type === "ObjectPattern") {
  80195. node.left.properties.forEach(function (property) {
  80196. checkPropertyAccess(node.left, objectName, astUtils.getStaticPropertyName(property));
  80197. });
  80198. }
  80199. }
  80200. }
  80201. return {
  80202. MemberExpression: function MemberExpression(node) {
  80203. checkPropertyAccess(node, node.object && node.object.name, astUtils.getStaticPropertyName(node));
  80204. },
  80205. VariableDeclarator: function VariableDeclarator(node) {
  80206. if (node.init && node.init.type === "Identifier") {
  80207. var objectName = node.init.name;
  80208. if (node.id.type === "ObjectPattern") {
  80209. node.id.properties.forEach(function (property) {
  80210. checkPropertyAccess(node.id, objectName, astUtils.getStaticPropertyName(property));
  80211. });
  80212. }
  80213. }
  80214. },
  80215. AssignmentExpression: checkDestructuringAssignment,
  80216. AssignmentPattern: checkDestructuringAssignment
  80217. };
  80218. }
  80219. };
  80220. },{"../util/ast-utils":405}],289:[function(require,module,exports){
  80221. /**
  80222. * @fileoverview Rule to flag use of certain node types
  80223. * @author Burak Yigit Kaya
  80224. */
  80225. "use strict";
  80226. //------------------------------------------------------------------------------
  80227. // Rule Definition
  80228. //------------------------------------------------------------------------------
  80229. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  80230. module.exports = {
  80231. meta: {
  80232. type: "suggestion",
  80233. docs: {
  80234. description: "disallow specified syntax",
  80235. category: "Stylistic Issues",
  80236. recommended: false,
  80237. url: "https://eslint.org/docs/rules/no-restricted-syntax"
  80238. },
  80239. schema: {
  80240. type: "array",
  80241. items: [{
  80242. oneOf: [{
  80243. type: "string"
  80244. }, {
  80245. type: "object",
  80246. properties: {
  80247. selector: { type: "string" },
  80248. message: { type: "string" }
  80249. },
  80250. required: ["selector"],
  80251. additionalProperties: false
  80252. }]
  80253. }],
  80254. uniqueItems: true,
  80255. minItems: 0
  80256. }
  80257. },
  80258. create: function create(context) {
  80259. return context.options.reduce(function (result, selectorOrObject) {
  80260. var isStringFormat = typeof selectorOrObject === "string";
  80261. var hasCustomMessage = !isStringFormat && Boolean(selectorOrObject.message);
  80262. var selector = isStringFormat ? selectorOrObject : selectorOrObject.selector;
  80263. var message = hasCustomMessage ? selectorOrObject.message : "Using '{{selector}}' is not allowed.";
  80264. return Object.assign(result, _defineProperty({}, selector, function (node) {
  80265. context.report({
  80266. node: node,
  80267. message: message,
  80268. data: hasCustomMessage ? {} : { selector: selector }
  80269. });
  80270. }));
  80271. }, {});
  80272. }
  80273. };
  80274. },{}],290:[function(require,module,exports){
  80275. /**
  80276. * @fileoverview Rule to flag when return statement contains assignment
  80277. * @author Ilya Volodin
  80278. */
  80279. "use strict";
  80280. //------------------------------------------------------------------------------
  80281. // Requirements
  80282. //------------------------------------------------------------------------------
  80283. var astUtils = require("../util/ast-utils");
  80284. //------------------------------------------------------------------------------
  80285. // Helpers
  80286. //------------------------------------------------------------------------------
  80287. var SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)$/;
  80288. //------------------------------------------------------------------------------
  80289. // Rule Definition
  80290. //------------------------------------------------------------------------------
  80291. module.exports = {
  80292. meta: {
  80293. type: "suggestion",
  80294. docs: {
  80295. description: "disallow assignment operators in `return` statements",
  80296. category: "Best Practices",
  80297. recommended: false,
  80298. url: "https://eslint.org/docs/rules/no-return-assign"
  80299. },
  80300. schema: [{
  80301. enum: ["except-parens", "always"]
  80302. }]
  80303. },
  80304. create: function create(context) {
  80305. var always = (context.options[0] || "except-parens") !== "except-parens";
  80306. var sourceCode = context.getSourceCode();
  80307. return {
  80308. AssignmentExpression: function AssignmentExpression(node) {
  80309. if (!always && astUtils.isParenthesised(sourceCode, node)) {
  80310. return;
  80311. }
  80312. var currentChild = node;
  80313. var parent = currentChild.parent;
  80314. // Find ReturnStatement or ArrowFunctionExpression in ancestors.
  80315. while (parent && !SENTINEL_TYPE.test(parent.type)) {
  80316. currentChild = parent;
  80317. parent = parent.parent;
  80318. }
  80319. // Reports.
  80320. if (parent && parent.type === "ReturnStatement") {
  80321. context.report({
  80322. node: parent,
  80323. message: "Return statement should not contain assignment."
  80324. });
  80325. } else if (parent && parent.type === "ArrowFunctionExpression" && parent.body === currentChild) {
  80326. context.report({
  80327. node: parent,
  80328. message: "Arrow function should not return assignment."
  80329. });
  80330. }
  80331. }
  80332. };
  80333. }
  80334. };
  80335. },{"../util/ast-utils":405}],291:[function(require,module,exports){
  80336. /**
  80337. * @fileoverview Disallows unnecessary `return await`
  80338. * @author Jordan Harband
  80339. */
  80340. "use strict";
  80341. var astUtils = require("../util/ast-utils");
  80342. //------------------------------------------------------------------------------
  80343. // Rule Definition
  80344. //------------------------------------------------------------------------------
  80345. var message = "Redundant use of `await` on a return value.";
  80346. module.exports = {
  80347. meta: {
  80348. type: "suggestion",
  80349. docs: {
  80350. description: "disallow unnecessary `return await`",
  80351. category: "Best Practices",
  80352. recommended: false,
  80353. url: "https://eslint.org/docs/rules/no-return-await"
  80354. },
  80355. fixable: null,
  80356. schema: []
  80357. },
  80358. create: function create(context) {
  80359. /**
  80360. * Reports a found unnecessary `await` expression.
  80361. * @param {ASTNode} node The node representing the `await` expression to report
  80362. * @returns {void}
  80363. */
  80364. function reportUnnecessaryAwait(node) {
  80365. context.report({
  80366. node: context.getSourceCode().getFirstToken(node),
  80367. loc: node.loc,
  80368. message: message
  80369. });
  80370. }
  80371. /**
  80372. * Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting
  80373. * this function. For example, a statement in a `try` block will always have an error handler. A statement in
  80374. * a `catch` block will only have an error handler if there is also a `finally` block.
  80375. * @param {ASTNode} node A node representing a location where an could be thrown
  80376. * @returns {boolean} `true` if a thrown error will be caught/handled in this function
  80377. */
  80378. function hasErrorHandler(node) {
  80379. var ancestor = node;
  80380. while (!astUtils.isFunction(ancestor) && ancestor.type !== "Program") {
  80381. if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) {
  80382. return true;
  80383. }
  80384. ancestor = ancestor.parent;
  80385. }
  80386. return false;
  80387. }
  80388. /**
  80389. * Checks if a node is placed in tail call position. Once `return` arguments (or arrow function expressions) can be a complex expression,
  80390. * an `await` expression could or could not be unnecessary by the definition of this rule. So we're looking for `await` expressions that are in tail position.
  80391. * @param {ASTNode} node A node representing the `await` expression to check
  80392. * @returns {boolean} The checking result
  80393. */
  80394. function isInTailCallPosition(node) {
  80395. if (node.parent.type === "ArrowFunctionExpression") {
  80396. return true;
  80397. }
  80398. if (node.parent.type === "ReturnStatement") {
  80399. return !hasErrorHandler(node.parent);
  80400. }
  80401. if (node.parent.type === "ConditionalExpression" && (node === node.parent.consequent || node === node.parent.alternate)) {
  80402. return isInTailCallPosition(node.parent);
  80403. }
  80404. if (node.parent.type === "LogicalExpression" && node === node.parent.right) {
  80405. return isInTailCallPosition(node.parent);
  80406. }
  80407. if (node.parent.type === "SequenceExpression" && node === node.parent.expressions[node.parent.expressions.length - 1]) {
  80408. return isInTailCallPosition(node.parent);
  80409. }
  80410. return false;
  80411. }
  80412. return {
  80413. AwaitExpression: function AwaitExpression(node) {
  80414. if (isInTailCallPosition(node) && !hasErrorHandler(node)) {
  80415. reportUnnecessaryAwait(node);
  80416. }
  80417. }
  80418. };
  80419. }
  80420. };
  80421. },{"../util/ast-utils":405}],292:[function(require,module,exports){
  80422. /**
  80423. * @fileoverview Rule to flag when using javascript: urls
  80424. * @author Ilya Volodin
  80425. */
  80426. /* jshint scripturl: true */
  80427. /* eslint no-script-url: 0 */
  80428. "use strict";
  80429. //------------------------------------------------------------------------------
  80430. // Rule Definition
  80431. //------------------------------------------------------------------------------
  80432. module.exports = {
  80433. meta: {
  80434. type: "suggestion",
  80435. docs: {
  80436. description: "disallow `javascript:` urls",
  80437. category: "Best Practices",
  80438. recommended: false,
  80439. url: "https://eslint.org/docs/rules/no-script-url"
  80440. },
  80441. schema: []
  80442. },
  80443. create: function create(context) {
  80444. return {
  80445. Literal: function Literal(node) {
  80446. if (node.value && typeof node.value === "string") {
  80447. var value = node.value.toLowerCase();
  80448. if (value.indexOf("javascript:") === 0) {
  80449. context.report({ node: node, message: "Script URL is a form of eval." });
  80450. }
  80451. }
  80452. }
  80453. };
  80454. }
  80455. };
  80456. },{}],293:[function(require,module,exports){
  80457. /**
  80458. * @fileoverview Rule to disallow assignments where both sides are exactly the same
  80459. * @author Toru Nagashima
  80460. */
  80461. "use strict";
  80462. //------------------------------------------------------------------------------
  80463. // Requirements
  80464. //------------------------------------------------------------------------------
  80465. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  80466. var astUtils = require("../util/ast-utils");
  80467. //------------------------------------------------------------------------------
  80468. // Helpers
  80469. //------------------------------------------------------------------------------
  80470. var SPACES = /\s+/g;
  80471. /**
  80472. * Checks whether the property of 2 given member expression nodes are the same
  80473. * property or not.
  80474. *
  80475. * @param {ASTNode} left - A member expression node to check.
  80476. * @param {ASTNode} right - Another member expression node to check.
  80477. * @returns {boolean} `true` if the member expressions have the same property.
  80478. */
  80479. function isSameProperty(left, right) {
  80480. if (left.property.type === "Identifier" && left.property.type === right.property.type && left.property.name === right.property.name && left.computed === right.computed) {
  80481. return true;
  80482. }
  80483. var lname = astUtils.getStaticPropertyName(left);
  80484. var rname = astUtils.getStaticPropertyName(right);
  80485. return lname !== null && lname === rname;
  80486. }
  80487. /**
  80488. * Checks whether 2 given member expression nodes are the reference to the same
  80489. * property or not.
  80490. *
  80491. * @param {ASTNode} left - A member expression node to check.
  80492. * @param {ASTNode} right - Another member expression node to check.
  80493. * @returns {boolean} `true` if the member expressions are the reference to the
  80494. * same property or not.
  80495. */
  80496. function isSameMember(left, right) {
  80497. if (!isSameProperty(left, right)) {
  80498. return false;
  80499. }
  80500. var lobj = left.object;
  80501. var robj = right.object;
  80502. if (lobj.type !== robj.type) {
  80503. return false;
  80504. }
  80505. if (lobj.type === "MemberExpression") {
  80506. return isSameMember(lobj, robj);
  80507. }
  80508. return lobj.type === "Identifier" && lobj.name === robj.name;
  80509. }
  80510. /**
  80511. * Traverses 2 Pattern nodes in parallel, then reports self-assignments.
  80512. *
  80513. * @param {ASTNode|null} left - A left node to traverse. This is a Pattern or
  80514. * a Property.
  80515. * @param {ASTNode|null} right - A right node to traverse. This is a Pattern or
  80516. * a Property.
  80517. * @param {boolean} props - The flag to check member expressions as well.
  80518. * @param {Function} report - A callback function to report.
  80519. * @returns {void}
  80520. */
  80521. function eachSelfAssignment(left, right, props, report) {
  80522. if (!left || !right) {
  80523. // do nothing
  80524. } else if (left.type === "Identifier" && right.type === "Identifier" && left.name === right.name) {
  80525. report(right);
  80526. } else if (left.type === "ArrayPattern" && right.type === "ArrayExpression") {
  80527. var end = Math.min(left.elements.length, right.elements.length);
  80528. for (var i = 0; i < end; ++i) {
  80529. var rightElement = right.elements[i];
  80530. eachSelfAssignment(left.elements[i], rightElement, props, report);
  80531. // After a spread element, those indices are unknown.
  80532. if (rightElement && rightElement.type === "SpreadElement") {
  80533. break;
  80534. }
  80535. }
  80536. } else if (left.type === "RestElement" && right.type === "SpreadElement") {
  80537. eachSelfAssignment(left.argument, right.argument, props, report);
  80538. } else if (left.type === "ObjectPattern" && right.type === "ObjectExpression" && right.properties.length >= 1) {
  80539. /*
  80540. * Gets the index of the last spread property.
  80541. * It's possible to overwrite properties followed by it.
  80542. */
  80543. var startJ = 0;
  80544. for (var _i = right.properties.length - 1; _i >= 0; --_i) {
  80545. var propType = right.properties[_i].type;
  80546. if (propType === "SpreadElement" || propType === "ExperimentalSpreadProperty") {
  80547. startJ = _i + 1;
  80548. break;
  80549. }
  80550. }
  80551. for (var _i2 = 0; _i2 < left.properties.length; ++_i2) {
  80552. for (var j = startJ; j < right.properties.length; ++j) {
  80553. eachSelfAssignment(left.properties[_i2], right.properties[j], props, report);
  80554. }
  80555. }
  80556. } else if (left.type === "Property" && right.type === "Property" && !left.computed && !right.computed && right.kind === "init" && !right.method && left.key.name === right.key.name) {
  80557. eachSelfAssignment(left.value, right.value, props, report);
  80558. } else if (props && left.type === "MemberExpression" && right.type === "MemberExpression" && isSameMember(left, right)) {
  80559. report(right);
  80560. }
  80561. }
  80562. //------------------------------------------------------------------------------
  80563. // Rule Definition
  80564. //------------------------------------------------------------------------------
  80565. module.exports = {
  80566. meta: {
  80567. type: "problem",
  80568. docs: {
  80569. description: "disallow assignments where both sides are exactly the same",
  80570. category: "Best Practices",
  80571. recommended: true,
  80572. url: "https://eslint.org/docs/rules/no-self-assign"
  80573. },
  80574. schema: [{
  80575. type: "object",
  80576. properties: {
  80577. props: {
  80578. type: "boolean"
  80579. }
  80580. },
  80581. additionalProperties: false
  80582. }]
  80583. },
  80584. create: function create(context) {
  80585. var sourceCode = context.getSourceCode();
  80586. var _context$options = _slicedToArray(context.options, 1),
  80587. _context$options$ = _context$options[0];
  80588. _context$options$ = _context$options$ === undefined ? {} : _context$options$;
  80589. var _context$options$$pro = _context$options$.props,
  80590. props = _context$options$$pro === undefined ? true : _context$options$$pro;
  80591. /**
  80592. * Reports a given node as self assignments.
  80593. *
  80594. * @param {ASTNode} node - A node to report. This is an Identifier node.
  80595. * @returns {void}
  80596. */
  80597. function report(node) {
  80598. context.report({
  80599. node: node,
  80600. message: "'{{name}}' is assigned to itself.",
  80601. data: {
  80602. name: sourceCode.getText(node).replace(SPACES, "")
  80603. }
  80604. });
  80605. }
  80606. return {
  80607. AssignmentExpression: function AssignmentExpression(node) {
  80608. if (node.operator === "=") {
  80609. eachSelfAssignment(node.left, node.right, props, report);
  80610. }
  80611. }
  80612. };
  80613. }
  80614. };
  80615. },{"../util/ast-utils":405}],294:[function(require,module,exports){
  80616. /**
  80617. * @fileoverview Rule to flag comparison where left part is the same as the right
  80618. * part.
  80619. * @author Ilya Volodin
  80620. */
  80621. "use strict";
  80622. //------------------------------------------------------------------------------
  80623. // Rule Definition
  80624. //------------------------------------------------------------------------------
  80625. module.exports = {
  80626. meta: {
  80627. type: "problem",
  80628. docs: {
  80629. description: "disallow comparisons where both sides are exactly the same",
  80630. category: "Best Practices",
  80631. recommended: false,
  80632. url: "https://eslint.org/docs/rules/no-self-compare"
  80633. },
  80634. schema: []
  80635. },
  80636. create: function create(context) {
  80637. var sourceCode = context.getSourceCode();
  80638. /**
  80639. * Determines whether two nodes are composed of the same tokens.
  80640. * @param {ASTNode} nodeA The first node
  80641. * @param {ASTNode} nodeB The second node
  80642. * @returns {boolean} true if the nodes have identical token representations
  80643. */
  80644. function hasSameTokens(nodeA, nodeB) {
  80645. var tokensA = sourceCode.getTokens(nodeA);
  80646. var tokensB = sourceCode.getTokens(nodeB);
  80647. return tokensA.length === tokensB.length && tokensA.every(function (token, index) {
  80648. return token.type === tokensB[index].type && token.value === tokensB[index].value;
  80649. });
  80650. }
  80651. return {
  80652. BinaryExpression: function BinaryExpression(node) {
  80653. var operators = new Set(["===", "==", "!==", "!=", ">", "<", ">=", "<="]);
  80654. if (operators.has(node.operator) && hasSameTokens(node.left, node.right)) {
  80655. context.report({ node: node, message: "Comparing to itself is potentially pointless." });
  80656. }
  80657. }
  80658. };
  80659. }
  80660. };
  80661. },{}],295:[function(require,module,exports){
  80662. /**
  80663. * @fileoverview Rule to flag use of comma operator
  80664. * @author Brandon Mills
  80665. */
  80666. "use strict";
  80667. //------------------------------------------------------------------------------
  80668. // Requirements
  80669. //------------------------------------------------------------------------------
  80670. var astUtils = require("../util/ast-utils");
  80671. //------------------------------------------------------------------------------
  80672. // Rule Definition
  80673. //------------------------------------------------------------------------------
  80674. module.exports = {
  80675. meta: {
  80676. type: "suggestion",
  80677. docs: {
  80678. description: "disallow comma operators",
  80679. category: "Best Practices",
  80680. recommended: false,
  80681. url: "https://eslint.org/docs/rules/no-sequences"
  80682. },
  80683. schema: []
  80684. },
  80685. create: function create(context) {
  80686. var sourceCode = context.getSourceCode();
  80687. /**
  80688. * Parts of the grammar that are required to have parens.
  80689. */
  80690. var parenthesized = {
  80691. DoWhileStatement: "test",
  80692. IfStatement: "test",
  80693. SwitchStatement: "discriminant",
  80694. WhileStatement: "test",
  80695. WithStatement: "object",
  80696. ArrowFunctionExpression: "body"
  80697. /*
  80698. * Omitting CallExpression - commas are parsed as argument separators
  80699. * Omitting NewExpression - commas are parsed as argument separators
  80700. * Omitting ForInStatement - parts aren't individually parenthesised
  80701. * Omitting ForStatement - parts aren't individually parenthesised
  80702. */
  80703. };
  80704. /**
  80705. * Determines whether a node is required by the grammar to be wrapped in
  80706. * parens, e.g. the test of an if statement.
  80707. * @param {ASTNode} node - The AST node
  80708. * @returns {boolean} True if parens around node belong to parent node.
  80709. */
  80710. function requiresExtraParens(node) {
  80711. return node.parent && parenthesized[node.parent.type] && node === node.parent[parenthesized[node.parent.type]];
  80712. }
  80713. /**
  80714. * Check if a node is wrapped in parens.
  80715. * @param {ASTNode} node - The AST node
  80716. * @returns {boolean} True if the node has a paren on each side.
  80717. */
  80718. function isParenthesised(node) {
  80719. return astUtils.isParenthesised(sourceCode, node);
  80720. }
  80721. /**
  80722. * Check if a node is wrapped in two levels of parens.
  80723. * @param {ASTNode} node - The AST node
  80724. * @returns {boolean} True if two parens surround the node on each side.
  80725. */
  80726. function isParenthesisedTwice(node) {
  80727. var previousToken = sourceCode.getTokenBefore(node, 1),
  80728. nextToken = sourceCode.getTokenAfter(node, 1);
  80729. return isParenthesised(node) && previousToken && nextToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
  80730. }
  80731. return {
  80732. SequenceExpression: function SequenceExpression(node) {
  80733. // Always allow sequences in for statement update
  80734. if (node.parent.type === "ForStatement" && (node === node.parent.init || node === node.parent.update)) {
  80735. return;
  80736. }
  80737. // Wrapping a sequence in extra parens indicates intent
  80738. if (requiresExtraParens(node)) {
  80739. if (isParenthesisedTwice(node)) {
  80740. return;
  80741. }
  80742. } else {
  80743. if (isParenthesised(node)) {
  80744. return;
  80745. }
  80746. }
  80747. var child = sourceCode.getTokenAfter(node.expressions[0]);
  80748. context.report({ node: node, loc: child.loc.start, message: "Unexpected use of comma operator." });
  80749. }
  80750. };
  80751. }
  80752. };
  80753. },{"../util/ast-utils":405}],296:[function(require,module,exports){
  80754. /**
  80755. * @fileoverview Disallow shadowing of NaN, undefined, and Infinity (ES5 section 15.1.1)
  80756. * @author Michael Ficarra
  80757. */
  80758. "use strict";
  80759. //------------------------------------------------------------------------------
  80760. // Rule Definition
  80761. //------------------------------------------------------------------------------
  80762. module.exports = {
  80763. meta: {
  80764. type: "suggestion",
  80765. docs: {
  80766. description: "disallow identifiers from shadowing restricted names",
  80767. category: "Variables",
  80768. recommended: false,
  80769. url: "https://eslint.org/docs/rules/no-shadow-restricted-names"
  80770. },
  80771. schema: []
  80772. },
  80773. create: function create(context) {
  80774. var RESTRICTED = ["undefined", "NaN", "Infinity", "arguments", "eval"];
  80775. return {
  80776. "VariableDeclaration, :function, CatchClause": function VariableDeclarationFunctionCatchClause(node) {
  80777. var _iteratorNormalCompletion = true;
  80778. var _didIteratorError = false;
  80779. var _iteratorError = undefined;
  80780. try {
  80781. for (var _iterator = context.getDeclaredVariables(node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  80782. var variable = _step.value;
  80783. if (variable.defs.length > 0 && RESTRICTED.includes(variable.name)) {
  80784. context.report({
  80785. node: variable.defs[0].name,
  80786. message: "Shadowing of global property '{{idName}}'.",
  80787. data: {
  80788. idName: variable.name
  80789. }
  80790. });
  80791. }
  80792. }
  80793. } catch (err) {
  80794. _didIteratorError = true;
  80795. _iteratorError = err;
  80796. } finally {
  80797. try {
  80798. if (!_iteratorNormalCompletion && _iterator.return) {
  80799. _iterator.return();
  80800. }
  80801. } finally {
  80802. if (_didIteratorError) {
  80803. throw _iteratorError;
  80804. }
  80805. }
  80806. }
  80807. }
  80808. };
  80809. }
  80810. };
  80811. },{}],297:[function(require,module,exports){
  80812. /**
  80813. * @fileoverview Rule to flag on declaring variables already declared in the outer scope
  80814. * @author Ilya Volodin
  80815. */
  80816. "use strict";
  80817. //------------------------------------------------------------------------------
  80818. // Requirements
  80819. //------------------------------------------------------------------------------
  80820. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  80821. var astUtils = require("../util/ast-utils");
  80822. //------------------------------------------------------------------------------
  80823. // Rule Definition
  80824. //------------------------------------------------------------------------------
  80825. module.exports = {
  80826. meta: {
  80827. type: "suggestion",
  80828. docs: {
  80829. description: "disallow variable declarations from shadowing variables declared in the outer scope",
  80830. category: "Variables",
  80831. recommended: false,
  80832. url: "https://eslint.org/docs/rules/no-shadow"
  80833. },
  80834. schema: [{
  80835. type: "object",
  80836. properties: {
  80837. builtinGlobals: { type: "boolean" },
  80838. hoist: { enum: ["all", "functions", "never"] },
  80839. allow: {
  80840. type: "array",
  80841. items: {
  80842. type: "string"
  80843. }
  80844. }
  80845. },
  80846. additionalProperties: false
  80847. }]
  80848. },
  80849. create: function create(context) {
  80850. var options = {
  80851. builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals),
  80852. hoist: context.options[0] && context.options[0].hoist || "functions",
  80853. allow: context.options[0] && context.options[0].allow || []
  80854. };
  80855. /**
  80856. * Check if variable name is allowed.
  80857. *
  80858. * @param {ASTNode} variable The variable to check.
  80859. * @returns {boolean} Whether or not the variable name is allowed.
  80860. */
  80861. function isAllowed(variable) {
  80862. return options.allow.indexOf(variable.name) !== -1;
  80863. }
  80864. /**
  80865. * Checks if a variable of the class name in the class scope of ClassDeclaration.
  80866. *
  80867. * ClassDeclaration creates two variables of its name into its outer scope and its class scope.
  80868. * So we should ignore the variable in the class scope.
  80869. *
  80870. * @param {Object} variable The variable to check.
  80871. * @returns {boolean} Whether or not the variable of the class name in the class scope of ClassDeclaration.
  80872. */
  80873. function isDuplicatedClassNameVariable(variable) {
  80874. var block = variable.scope.block;
  80875. return block.type === "ClassDeclaration" && block.id === variable.identifiers[0];
  80876. }
  80877. /**
  80878. * Checks if a variable is inside the initializer of scopeVar.
  80879. *
  80880. * To avoid reporting at declarations such as `var a = function a() {};`.
  80881. * But it should report `var a = function(a) {};` or `var a = function() { function a() {} };`.
  80882. *
  80883. * @param {Object} variable The variable to check.
  80884. * @param {Object} scopeVar The scope variable to look for.
  80885. * @returns {boolean} Whether or not the variable is inside initializer of scopeVar.
  80886. */
  80887. function isOnInitializer(variable, scopeVar) {
  80888. var outerScope = scopeVar.scope;
  80889. var outerDef = scopeVar.defs[0];
  80890. var outer = outerDef && outerDef.parent && outerDef.parent.range;
  80891. var innerScope = variable.scope;
  80892. var innerDef = variable.defs[0];
  80893. var inner = innerDef && innerDef.name.range;
  80894. return outer && inner && outer[0] < inner[0] && inner[1] < outer[1] && (innerDef.type === "FunctionName" && innerDef.node.type === "FunctionExpression" || innerDef.node.type === "ClassExpression") && outerScope === innerScope.upper;
  80895. }
  80896. /**
  80897. * Get a range of a variable's identifier node.
  80898. * @param {Object} variable The variable to get.
  80899. * @returns {Array|undefined} The range of the variable's identifier node.
  80900. */
  80901. function getNameRange(variable) {
  80902. var def = variable.defs[0];
  80903. return def && def.name.range;
  80904. }
  80905. /**
  80906. * Checks if a variable is in TDZ of scopeVar.
  80907. * @param {Object} variable The variable to check.
  80908. * @param {Object} scopeVar The variable of TDZ.
  80909. * @returns {boolean} Whether or not the variable is in TDZ of scopeVar.
  80910. */
  80911. function isInTdz(variable, scopeVar) {
  80912. var outerDef = scopeVar.defs[0];
  80913. var inner = getNameRange(variable);
  80914. var outer = getNameRange(scopeVar);
  80915. return inner && outer && inner[1] < outer[0] && (
  80916. // Excepts FunctionDeclaration if is {"hoist":"function"}.
  80917. options.hoist !== "functions" || !outerDef || outerDef.node.type !== "FunctionDeclaration");
  80918. }
  80919. /**
  80920. * Checks the current context for shadowed variables.
  80921. * @param {Scope} scope - Fixme
  80922. * @returns {void}
  80923. */
  80924. function checkForShadows(scope) {
  80925. var variables = scope.variables;
  80926. for (var i = 0; i < variables.length; ++i) {
  80927. var variable = variables[i];
  80928. // Skips "arguments" or variables of a class name in the class scope of ClassDeclaration.
  80929. if (variable.identifiers.length === 0 || isDuplicatedClassNameVariable(variable) || isAllowed(variable)) {
  80930. continue;
  80931. }
  80932. // Gets shadowed variable.
  80933. var shadowed = astUtils.getVariableByName(scope.upper, variable.name);
  80934. if (shadowed && (shadowed.identifiers.length > 0 || options.builtinGlobals && "writeable" in shadowed) && !isOnInitializer(variable, shadowed) && !(options.hoist !== "all" && isInTdz(variable, shadowed))) {
  80935. context.report({
  80936. node: variable.identifiers[0],
  80937. message: "'{{name}}' is already declared in the upper scope.",
  80938. data: variable
  80939. });
  80940. }
  80941. }
  80942. }
  80943. return {
  80944. "Program:exit": function ProgramExit() {
  80945. var globalScope = context.getScope();
  80946. var stack = globalScope.childScopes.slice();
  80947. while (stack.length) {
  80948. var scope = stack.pop();
  80949. stack.push.apply(stack, _toConsumableArray(scope.childScopes));
  80950. checkForShadows(scope);
  80951. }
  80952. }
  80953. };
  80954. }
  80955. };
  80956. },{"../util/ast-utils":405}],298:[function(require,module,exports){
  80957. /**
  80958. * @fileoverview Rule to check that spaced function application
  80959. * @author Matt DuVall <http://www.mattduvall.com>
  80960. * @deprecated in ESLint v3.3.0
  80961. */
  80962. "use strict";
  80963. //------------------------------------------------------------------------------
  80964. // Rule Definition
  80965. //------------------------------------------------------------------------------
  80966. module.exports = {
  80967. meta: {
  80968. type: "layout",
  80969. docs: {
  80970. description: "disallow spacing between function identifiers and their applications (deprecated)",
  80971. category: "Stylistic Issues",
  80972. recommended: false,
  80973. url: "https://eslint.org/docs/rules/no-spaced-func"
  80974. },
  80975. deprecated: true,
  80976. replacedBy: ["func-call-spacing"],
  80977. fixable: "whitespace",
  80978. schema: []
  80979. },
  80980. create: function create(context) {
  80981. var sourceCode = context.getSourceCode();
  80982. /**
  80983. * Check if open space is present in a function name
  80984. * @param {ASTNode} node node to evaluate
  80985. * @returns {void}
  80986. * @private
  80987. */
  80988. function detectOpenSpaces(node) {
  80989. var lastCalleeToken = sourceCode.getLastToken(node.callee);
  80990. var prevToken = lastCalleeToken,
  80991. parenToken = sourceCode.getTokenAfter(lastCalleeToken);
  80992. // advances to an open parenthesis.
  80993. while (parenToken && parenToken.range[1] < node.range[1] && parenToken.value !== "(") {
  80994. prevToken = parenToken;
  80995. parenToken = sourceCode.getTokenAfter(parenToken);
  80996. }
  80997. // look for a space between the callee and the open paren
  80998. if (parenToken && parenToken.range[1] < node.range[1] && sourceCode.isSpaceBetweenTokens(prevToken, parenToken)) {
  80999. context.report({
  81000. node: node,
  81001. loc: lastCalleeToken.loc.start,
  81002. message: "Unexpected space between function name and paren.",
  81003. fix: function fix(fixer) {
  81004. return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
  81005. }
  81006. });
  81007. }
  81008. }
  81009. return {
  81010. CallExpression: detectOpenSpaces,
  81011. NewExpression: detectOpenSpaces
  81012. };
  81013. }
  81014. };
  81015. },{}],299:[function(require,module,exports){
  81016. /**
  81017. * @fileoverview Disallow sparse arrays
  81018. * @author Nicholas C. Zakas
  81019. */
  81020. "use strict";
  81021. //------------------------------------------------------------------------------
  81022. // Rule Definition
  81023. //------------------------------------------------------------------------------
  81024. module.exports = {
  81025. meta: {
  81026. type: "problem",
  81027. docs: {
  81028. description: "disallow sparse arrays",
  81029. category: "Possible Errors",
  81030. recommended: true,
  81031. url: "https://eslint.org/docs/rules/no-sparse-arrays"
  81032. },
  81033. schema: []
  81034. },
  81035. create: function create(context) {
  81036. //--------------------------------------------------------------------------
  81037. // Public
  81038. //--------------------------------------------------------------------------
  81039. return {
  81040. ArrayExpression: function ArrayExpression(node) {
  81041. var emptySpot = node.elements.indexOf(null) > -1;
  81042. if (emptySpot) {
  81043. context.report({ node: node, message: "Unexpected comma in middle of array." });
  81044. }
  81045. }
  81046. };
  81047. }
  81048. };
  81049. },{}],300:[function(require,module,exports){
  81050. /**
  81051. * @fileoverview Rule to check for properties whose identifier ends with the string Sync
  81052. * @author Matt DuVall<http://mattduvall.com/>
  81053. */
  81054. /* jshint node:true */
  81055. "use strict";
  81056. //------------------------------------------------------------------------------
  81057. // Rule Definition
  81058. //------------------------------------------------------------------------------
  81059. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  81060. module.exports = {
  81061. meta: {
  81062. type: "suggestion",
  81063. docs: {
  81064. description: "disallow synchronous methods",
  81065. category: "Node.js and CommonJS",
  81066. recommended: false,
  81067. url: "https://eslint.org/docs/rules/no-sync"
  81068. },
  81069. schema: [{
  81070. type: "object",
  81071. properties: {
  81072. allowAtRootLevel: {
  81073. type: "boolean"
  81074. }
  81075. },
  81076. additionalProperties: false
  81077. }]
  81078. },
  81079. create: function create(context) {
  81080. var selector = context.options[0] && context.options[0].allowAtRootLevel ? ":function MemberExpression[property.name=/.*Sync$/]" : "MemberExpression[property.name=/.*Sync$/]";
  81081. return _defineProperty({}, selector, function (node) {
  81082. context.report({
  81083. node: node,
  81084. message: "Unexpected sync method: '{{propertyName}}'.",
  81085. data: {
  81086. propertyName: node.property.name
  81087. }
  81088. });
  81089. });
  81090. }
  81091. };
  81092. },{}],301:[function(require,module,exports){
  81093. /**
  81094. * @fileoverview Rule to check for tabs inside a file
  81095. * @author Gyandeep Singh
  81096. */
  81097. "use strict";
  81098. //------------------------------------------------------------------------------
  81099. // Helpers
  81100. //------------------------------------------------------------------------------
  81101. var tabRegex = /\t+/g;
  81102. var anyNonWhitespaceRegex = /\S/;
  81103. //------------------------------------------------------------------------------
  81104. // Public Interface
  81105. //------------------------------------------------------------------------------
  81106. module.exports = {
  81107. meta: {
  81108. type: "layout",
  81109. docs: {
  81110. description: "disallow all tabs",
  81111. category: "Stylistic Issues",
  81112. recommended: false,
  81113. url: "https://eslint.org/docs/rules/no-tabs"
  81114. },
  81115. schema: [{
  81116. type: "object",
  81117. properties: {
  81118. allowIndentationTabs: {
  81119. type: "boolean"
  81120. }
  81121. },
  81122. additionalProperties: false
  81123. }]
  81124. },
  81125. create: function create(context) {
  81126. var sourceCode = context.getSourceCode();
  81127. var allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs;
  81128. return {
  81129. Program: function Program(node) {
  81130. sourceCode.getLines().forEach(function (line, index) {
  81131. var match = void 0;
  81132. while ((match = tabRegex.exec(line)) !== null) {
  81133. if (allowIndentationTabs && !anyNonWhitespaceRegex.test(line.slice(0, match.index))) {
  81134. continue;
  81135. }
  81136. context.report({
  81137. node: node,
  81138. loc: {
  81139. line: index + 1,
  81140. column: match.index
  81141. },
  81142. message: "Unexpected tab character."
  81143. });
  81144. }
  81145. });
  81146. }
  81147. };
  81148. }
  81149. };
  81150. },{}],302:[function(require,module,exports){
  81151. /**
  81152. * @fileoverview Warn when using template string syntax in regular strings
  81153. * @author Jeroen Engels
  81154. */
  81155. "use strict";
  81156. //------------------------------------------------------------------------------
  81157. // Rule Definition
  81158. //------------------------------------------------------------------------------
  81159. module.exports = {
  81160. meta: {
  81161. type: "problem",
  81162. docs: {
  81163. description: "disallow template literal placeholder syntax in regular strings",
  81164. category: "Possible Errors",
  81165. recommended: false,
  81166. url: "https://eslint.org/docs/rules/no-template-curly-in-string"
  81167. },
  81168. schema: []
  81169. },
  81170. create: function create(context) {
  81171. var regex = /\$\{[^}]+\}/;
  81172. return {
  81173. Literal: function Literal(node) {
  81174. if (typeof node.value === "string" && regex.test(node.value)) {
  81175. context.report({
  81176. node: node,
  81177. message: "Unexpected template string expression."
  81178. });
  81179. }
  81180. }
  81181. };
  81182. }
  81183. };
  81184. },{}],303:[function(require,module,exports){
  81185. /**
  81186. * @fileoverview Rule to flag use of ternary operators.
  81187. * @author Ian Christian Myers
  81188. */
  81189. "use strict";
  81190. //------------------------------------------------------------------------------
  81191. // Rule Definition
  81192. //------------------------------------------------------------------------------
  81193. module.exports = {
  81194. meta: {
  81195. type: "suggestion",
  81196. docs: {
  81197. description: "disallow ternary operators",
  81198. category: "Stylistic Issues",
  81199. recommended: false,
  81200. url: "https://eslint.org/docs/rules/no-ternary"
  81201. },
  81202. schema: []
  81203. },
  81204. create: function create(context) {
  81205. return {
  81206. ConditionalExpression: function ConditionalExpression(node) {
  81207. context.report({ node: node, message: "Ternary operator used." });
  81208. }
  81209. };
  81210. }
  81211. };
  81212. },{}],304:[function(require,module,exports){
  81213. /**
  81214. * @fileoverview A rule to disallow using `this`/`super` before `super()`.
  81215. * @author Toru Nagashima
  81216. */
  81217. "use strict";
  81218. //------------------------------------------------------------------------------
  81219. // Requirements
  81220. //------------------------------------------------------------------------------
  81221. var astUtils = require("../util/ast-utils");
  81222. //------------------------------------------------------------------------------
  81223. // Helpers
  81224. //------------------------------------------------------------------------------
  81225. /**
  81226. * Checks whether or not a given node is a constructor.
  81227. * @param {ASTNode} node - A node to check. This node type is one of
  81228. * `Program`, `FunctionDeclaration`, `FunctionExpression`, and
  81229. * `ArrowFunctionExpression`.
  81230. * @returns {boolean} `true` if the node is a constructor.
  81231. */
  81232. function isConstructorFunction(node) {
  81233. return node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
  81234. }
  81235. //------------------------------------------------------------------------------
  81236. // Rule Definition
  81237. //------------------------------------------------------------------------------
  81238. module.exports = {
  81239. meta: {
  81240. type: "problem",
  81241. docs: {
  81242. description: "disallow `this`/`super` before calling `super()` in constructors",
  81243. category: "ECMAScript 6",
  81244. recommended: true,
  81245. url: "https://eslint.org/docs/rules/no-this-before-super"
  81246. },
  81247. schema: []
  81248. },
  81249. create: function create(context) {
  81250. /*
  81251. * Information for each constructor.
  81252. * - upper: Information of the upper constructor.
  81253. * - hasExtends: A flag which shows whether the owner class has a valid
  81254. * `extends` part.
  81255. * - scope: The scope of the owner class.
  81256. * - codePath: The code path of this constructor.
  81257. */
  81258. var funcInfo = null;
  81259. /*
  81260. * Information for each code path segment.
  81261. * Each key is the id of a code path segment.
  81262. * Each value is an object:
  81263. * - superCalled: The flag which shows `super()` called in all code paths.
  81264. * - invalidNodes: The array of invalid ThisExpression and Super nodes.
  81265. */
  81266. var segInfoMap = Object.create(null);
  81267. /**
  81268. * Gets whether or not `super()` is called in a given code path segment.
  81269. * @param {CodePathSegment} segment - A code path segment to get.
  81270. * @returns {boolean} `true` if `super()` is called.
  81271. */
  81272. function isCalled(segment) {
  81273. return !segment.reachable || segInfoMap[segment.id].superCalled;
  81274. }
  81275. /**
  81276. * Checks whether or not this is in a constructor.
  81277. * @returns {boolean} `true` if this is in a constructor.
  81278. */
  81279. function isInConstructorOfDerivedClass() {
  81280. return Boolean(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends);
  81281. }
  81282. /**
  81283. * Checks whether or not this is before `super()` is called.
  81284. * @returns {boolean} `true` if this is before `super()` is called.
  81285. */
  81286. function isBeforeCallOfSuper() {
  81287. return isInConstructorOfDerivedClass() && !funcInfo.codePath.currentSegments.every(isCalled);
  81288. }
  81289. /**
  81290. * Sets a given node as invalid.
  81291. * @param {ASTNode} node - A node to set as invalid. This is one of
  81292. * a ThisExpression and a Super.
  81293. * @returns {void}
  81294. */
  81295. function setInvalid(node) {
  81296. var segments = funcInfo.codePath.currentSegments;
  81297. for (var i = 0; i < segments.length; ++i) {
  81298. var segment = segments[i];
  81299. if (segment.reachable) {
  81300. segInfoMap[segment.id].invalidNodes.push(node);
  81301. }
  81302. }
  81303. }
  81304. /**
  81305. * Sets the current segment as `super` was called.
  81306. * @returns {void}
  81307. */
  81308. function setSuperCalled() {
  81309. var segments = funcInfo.codePath.currentSegments;
  81310. for (var i = 0; i < segments.length; ++i) {
  81311. var segment = segments[i];
  81312. if (segment.reachable) {
  81313. segInfoMap[segment.id].superCalled = true;
  81314. }
  81315. }
  81316. }
  81317. return {
  81318. /**
  81319. * Adds information of a constructor into the stack.
  81320. * @param {CodePath} codePath - A code path which was started.
  81321. * @param {ASTNode} node - The current node.
  81322. * @returns {void}
  81323. */
  81324. onCodePathStart: function onCodePathStart(codePath, node) {
  81325. if (isConstructorFunction(node)) {
  81326. // Class > ClassBody > MethodDefinition > FunctionExpression
  81327. var classNode = node.parent.parent.parent;
  81328. funcInfo = {
  81329. upper: funcInfo,
  81330. isConstructor: true,
  81331. hasExtends: Boolean(classNode.superClass && !astUtils.isNullOrUndefined(classNode.superClass)),
  81332. codePath: codePath
  81333. };
  81334. } else {
  81335. funcInfo = {
  81336. upper: funcInfo,
  81337. isConstructor: false,
  81338. hasExtends: false,
  81339. codePath: codePath
  81340. };
  81341. }
  81342. },
  81343. /**
  81344. * Removes the top of stack item.
  81345. *
  81346. * And this treverses all segments of this code path then reports every
  81347. * invalid node.
  81348. *
  81349. * @param {CodePath} codePath - A code path which was ended.
  81350. * @returns {void}
  81351. */
  81352. onCodePathEnd: function onCodePathEnd(codePath) {
  81353. var isDerivedClass = funcInfo.hasExtends;
  81354. funcInfo = funcInfo.upper;
  81355. if (!isDerivedClass) {
  81356. return;
  81357. }
  81358. codePath.traverseSegments(function (segment, controller) {
  81359. var info = segInfoMap[segment.id];
  81360. for (var i = 0; i < info.invalidNodes.length; ++i) {
  81361. var invalidNode = info.invalidNodes[i];
  81362. context.report({
  81363. message: "'{{kind}}' is not allowed before 'super()'.",
  81364. node: invalidNode,
  81365. data: {
  81366. kind: invalidNode.type === "Super" ? "super" : "this"
  81367. }
  81368. });
  81369. }
  81370. if (info.superCalled) {
  81371. controller.skip();
  81372. }
  81373. });
  81374. },
  81375. /**
  81376. * Initialize information of a given code path segment.
  81377. * @param {CodePathSegment} segment - A code path segment to initialize.
  81378. * @returns {void}
  81379. */
  81380. onCodePathSegmentStart: function onCodePathSegmentStart(segment) {
  81381. if (!isInConstructorOfDerivedClass()) {
  81382. return;
  81383. }
  81384. // Initialize info.
  81385. segInfoMap[segment.id] = {
  81386. superCalled: segment.prevSegments.length > 0 && segment.prevSegments.every(isCalled),
  81387. invalidNodes: []
  81388. };
  81389. },
  81390. /**
  81391. * Update information of the code path segment when a code path was
  81392. * looped.
  81393. * @param {CodePathSegment} fromSegment - The code path segment of the
  81394. * end of a loop.
  81395. * @param {CodePathSegment} toSegment - A code path segment of the head
  81396. * of a loop.
  81397. * @returns {void}
  81398. */
  81399. onCodePathSegmentLoop: function onCodePathSegmentLoop(fromSegment, toSegment) {
  81400. if (!isInConstructorOfDerivedClass()) {
  81401. return;
  81402. }
  81403. // Update information inside of the loop.
  81404. funcInfo.codePath.traverseSegments({ first: toSegment, last: fromSegment }, function (segment, controller) {
  81405. var info = segInfoMap[segment.id];
  81406. if (info.superCalled) {
  81407. info.invalidNodes = [];
  81408. controller.skip();
  81409. } else if (segment.prevSegments.length > 0 && segment.prevSegments.every(isCalled)) {
  81410. info.superCalled = true;
  81411. info.invalidNodes = [];
  81412. }
  81413. });
  81414. },
  81415. /**
  81416. * Reports if this is before `super()`.
  81417. * @param {ASTNode} node - A target node.
  81418. * @returns {void}
  81419. */
  81420. ThisExpression: function ThisExpression(node) {
  81421. if (isBeforeCallOfSuper()) {
  81422. setInvalid(node);
  81423. }
  81424. },
  81425. /**
  81426. * Reports if this is before `super()`.
  81427. * @param {ASTNode} node - A target node.
  81428. * @returns {void}
  81429. */
  81430. Super: function Super(node) {
  81431. if (!astUtils.isCallee(node) && isBeforeCallOfSuper()) {
  81432. setInvalid(node);
  81433. }
  81434. },
  81435. /**
  81436. * Marks `super()` called.
  81437. * @param {ASTNode} node - A target node.
  81438. * @returns {void}
  81439. */
  81440. "CallExpression:exit": function CallExpressionExit(node) {
  81441. if (node.callee.type === "Super" && isBeforeCallOfSuper()) {
  81442. setSuperCalled();
  81443. }
  81444. },
  81445. /**
  81446. * Resets state.
  81447. * @returns {void}
  81448. */
  81449. "Program:exit": function ProgramExit() {
  81450. segInfoMap = Object.create(null);
  81451. }
  81452. };
  81453. }
  81454. };
  81455. },{"../util/ast-utils":405}],305:[function(require,module,exports){
  81456. /**
  81457. * @fileoverview Rule to restrict what can be thrown as an exception.
  81458. * @author Dieter Oberkofler
  81459. */
  81460. "use strict";
  81461. var astUtils = require("../util/ast-utils");
  81462. //------------------------------------------------------------------------------
  81463. // Rule Definition
  81464. //------------------------------------------------------------------------------
  81465. module.exports = {
  81466. meta: {
  81467. type: "suggestion",
  81468. docs: {
  81469. description: "disallow throwing literals as exceptions",
  81470. category: "Best Practices",
  81471. recommended: false,
  81472. url: "https://eslint.org/docs/rules/no-throw-literal"
  81473. },
  81474. schema: []
  81475. },
  81476. create: function create(context) {
  81477. return {
  81478. ThrowStatement: function ThrowStatement(node) {
  81479. if (!astUtils.couldBeError(node.argument)) {
  81480. context.report({ node: node, message: "Expected an object to be thrown." });
  81481. } else if (node.argument.type === "Identifier") {
  81482. if (node.argument.name === "undefined") {
  81483. context.report({ node: node, message: "Do not throw undefined." });
  81484. }
  81485. }
  81486. }
  81487. };
  81488. }
  81489. };
  81490. },{"../util/ast-utils":405}],306:[function(require,module,exports){
  81491. /**
  81492. * @fileoverview Disallow trailing spaces at the end of lines.
  81493. * @author Nodeca Team <https://github.com/nodeca>
  81494. */
  81495. "use strict";
  81496. //------------------------------------------------------------------------------
  81497. // Requirements
  81498. //------------------------------------------------------------------------------
  81499. var astUtils = require("../util/ast-utils");
  81500. //------------------------------------------------------------------------------
  81501. // Rule Definition
  81502. //------------------------------------------------------------------------------
  81503. module.exports = {
  81504. meta: {
  81505. type: "layout",
  81506. docs: {
  81507. description: "disallow trailing whitespace at the end of lines",
  81508. category: "Stylistic Issues",
  81509. recommended: false,
  81510. url: "https://eslint.org/docs/rules/no-trailing-spaces"
  81511. },
  81512. fixable: "whitespace",
  81513. schema: [{
  81514. type: "object",
  81515. properties: {
  81516. skipBlankLines: {
  81517. type: "boolean"
  81518. },
  81519. ignoreComments: {
  81520. type: "boolean"
  81521. }
  81522. },
  81523. additionalProperties: false
  81524. }]
  81525. },
  81526. create: function create(context) {
  81527. var sourceCode = context.getSourceCode();
  81528. var BLANK_CLASS = "[ \t\xA0\u2000-\u200B\u3000]",
  81529. SKIP_BLANK = "^" + BLANK_CLASS + "*$",
  81530. NONBLANK = BLANK_CLASS + "+$";
  81531. var options = context.options[0] || {},
  81532. skipBlankLines = options.skipBlankLines || false,
  81533. ignoreComments = typeof options.ignoreComments === "boolean" && options.ignoreComments;
  81534. /**
  81535. * Report the error message
  81536. * @param {ASTNode} node node to report
  81537. * @param {int[]} location range information
  81538. * @param {int[]} fixRange Range based on the whole program
  81539. * @returns {void}
  81540. */
  81541. function report(node, location, fixRange) {
  81542. /*
  81543. * Passing node is a bit dirty, because message data will contain big
  81544. * text in `source`. But... who cares :) ?
  81545. * One more kludge will not make worse the bloody wizardry of this
  81546. * plugin.
  81547. */
  81548. context.report({
  81549. node: node,
  81550. loc: location,
  81551. message: "Trailing spaces not allowed.",
  81552. fix: function fix(fixer) {
  81553. return fixer.removeRange(fixRange);
  81554. }
  81555. });
  81556. }
  81557. /**
  81558. * Given a list of comment nodes, return the line numbers for those comments.
  81559. * @param {Array} comments An array of comment nodes.
  81560. * @returns {number[]} An array of line numbers containing comments.
  81561. */
  81562. function getCommentLineNumbers(comments) {
  81563. var lines = new Set();
  81564. comments.forEach(function (comment) {
  81565. for (var i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
  81566. lines.add(i);
  81567. }
  81568. });
  81569. return lines;
  81570. }
  81571. //--------------------------------------------------------------------------
  81572. // Public
  81573. //--------------------------------------------------------------------------
  81574. return {
  81575. Program: function checkTrailingSpaces(node) {
  81576. /*
  81577. * Let's hack. Since Espree does not return whitespace nodes,
  81578. * fetch the source code and do matching via regexps.
  81579. */
  81580. var re = new RegExp(NONBLANK),
  81581. skipMatch = new RegExp(SKIP_BLANK),
  81582. lines = sourceCode.lines,
  81583. linebreaks = sourceCode.getText().match(astUtils.createGlobalLinebreakMatcher()),
  81584. comments = sourceCode.getAllComments(),
  81585. commentLineNumbers = getCommentLineNumbers(comments);
  81586. var totalLength = 0,
  81587. fixRange = [];
  81588. for (var i = 0, ii = lines.length; i < ii; i++) {
  81589. var matches = re.exec(lines[i]);
  81590. /*
  81591. * Always add linebreak length to line length to accommodate for line break (\n or \r\n)
  81592. * Because during the fix time they also reserve one spot in the array.
  81593. * Usually linebreak length is 2 for \r\n (CRLF) and 1 for \n (LF)
  81594. */
  81595. var linebreakLength = linebreaks && linebreaks[i] ? linebreaks[i].length : 1;
  81596. var lineLength = lines[i].length + linebreakLength;
  81597. if (matches) {
  81598. var location = {
  81599. line: i + 1,
  81600. column: matches.index
  81601. };
  81602. var rangeStart = totalLength + location.column;
  81603. var rangeEnd = totalLength + lineLength - linebreakLength;
  81604. var containingNode = sourceCode.getNodeByRangeIndex(rangeStart);
  81605. if (containingNode && containingNode.type === "TemplateElement" && rangeStart > containingNode.parent.range[0] && rangeEnd < containingNode.parent.range[1]) {
  81606. totalLength += lineLength;
  81607. continue;
  81608. }
  81609. /*
  81610. * If the line has only whitespace, and skipBlankLines
  81611. * is true, don't report it
  81612. */
  81613. if (skipBlankLines && skipMatch.test(lines[i])) {
  81614. totalLength += lineLength;
  81615. continue;
  81616. }
  81617. fixRange = [rangeStart, rangeEnd];
  81618. if (!ignoreComments || !commentLineNumbers.has(location.line)) {
  81619. report(node, location, fixRange);
  81620. }
  81621. }
  81622. totalLength += lineLength;
  81623. }
  81624. }
  81625. };
  81626. }
  81627. };
  81628. },{"../util/ast-utils":405}],307:[function(require,module,exports){
  81629. /**
  81630. * @fileoverview Rule to flag when initializing to undefined
  81631. * @author Ilya Volodin
  81632. */
  81633. "use strict";
  81634. var astUtils = require("../util/ast-utils");
  81635. //------------------------------------------------------------------------------
  81636. // Rule Definition
  81637. //------------------------------------------------------------------------------
  81638. module.exports = {
  81639. meta: {
  81640. type: "suggestion",
  81641. docs: {
  81642. description: "disallow initializing variables to `undefined`",
  81643. category: "Variables",
  81644. recommended: false,
  81645. url: "https://eslint.org/docs/rules/no-undef-init"
  81646. },
  81647. schema: [],
  81648. fixable: "code"
  81649. },
  81650. create: function create(context) {
  81651. var sourceCode = context.getSourceCode();
  81652. return {
  81653. VariableDeclarator: function VariableDeclarator(node) {
  81654. var name = sourceCode.getText(node.id),
  81655. init = node.init && node.init.name,
  81656. scope = context.getScope(),
  81657. undefinedVar = astUtils.getVariableByName(scope, "undefined"),
  81658. shadowed = undefinedVar && undefinedVar.defs.length > 0;
  81659. if (init === "undefined" && node.parent.kind !== "const" && !shadowed) {
  81660. context.report({
  81661. node: node,
  81662. message: "It's not necessary to initialize '{{name}}' to undefined.",
  81663. data: { name: name },
  81664. fix: function fix(fixer) {
  81665. if (node.parent.kind === "var") {
  81666. return null;
  81667. }
  81668. if (node.id.type === "ArrayPattern" || node.id.type === "ObjectPattern") {
  81669. // Don't fix destructuring assignment to `undefined`.
  81670. return null;
  81671. }
  81672. return fixer.removeRange([node.id.range[1], node.range[1]]);
  81673. }
  81674. });
  81675. }
  81676. }
  81677. };
  81678. }
  81679. };
  81680. },{"../util/ast-utils":405}],308:[function(require,module,exports){
  81681. /**
  81682. * @fileoverview Rule to flag references to undeclared variables.
  81683. * @author Mark Macdonald
  81684. */
  81685. "use strict";
  81686. //------------------------------------------------------------------------------
  81687. // Helpers
  81688. //------------------------------------------------------------------------------
  81689. /**
  81690. * Checks if the given node is the argument of a typeof operator.
  81691. * @param {ASTNode} node The AST node being checked.
  81692. * @returns {boolean} Whether or not the node is the argument of a typeof operator.
  81693. */
  81694. function hasTypeOfOperator(node) {
  81695. var parent = node.parent;
  81696. return parent.type === "UnaryExpression" && parent.operator === "typeof";
  81697. }
  81698. //------------------------------------------------------------------------------
  81699. // Rule Definition
  81700. //------------------------------------------------------------------------------
  81701. module.exports = {
  81702. meta: {
  81703. type: "problem",
  81704. docs: {
  81705. description: "disallow the use of undeclared variables unless mentioned in `/*global */` comments",
  81706. category: "Variables",
  81707. recommended: true,
  81708. url: "https://eslint.org/docs/rules/no-undef"
  81709. },
  81710. schema: [{
  81711. type: "object",
  81712. properties: {
  81713. typeof: {
  81714. type: "boolean"
  81715. }
  81716. },
  81717. additionalProperties: false
  81718. }]
  81719. },
  81720. create: function create(context) {
  81721. var options = context.options[0];
  81722. var considerTypeOf = options && options.typeof === true || false;
  81723. return {
  81724. "Program:exit": function ProgramExit() /* node */{
  81725. var globalScope = context.getScope();
  81726. globalScope.through.forEach(function (ref) {
  81727. var identifier = ref.identifier;
  81728. if (!considerTypeOf && hasTypeOfOperator(identifier)) {
  81729. return;
  81730. }
  81731. context.report({
  81732. node: identifier,
  81733. message: "'{{name}}' is not defined.",
  81734. data: identifier
  81735. });
  81736. });
  81737. }
  81738. };
  81739. }
  81740. };
  81741. },{}],309:[function(require,module,exports){
  81742. /**
  81743. * @fileoverview Rule to flag references to the undefined variable.
  81744. * @author Michael Ficarra
  81745. */
  81746. "use strict";
  81747. //------------------------------------------------------------------------------
  81748. // Rule Definition
  81749. //------------------------------------------------------------------------------
  81750. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  81751. module.exports = {
  81752. meta: {
  81753. type: "suggestion",
  81754. docs: {
  81755. description: "disallow the use of `undefined` as an identifier",
  81756. category: "Variables",
  81757. recommended: false,
  81758. url: "https://eslint.org/docs/rules/no-undefined"
  81759. },
  81760. schema: []
  81761. },
  81762. create: function create(context) {
  81763. /**
  81764. * Report an invalid "undefined" identifier node.
  81765. * @param {ASTNode} node The node to report.
  81766. * @returns {void}
  81767. */
  81768. function report(node) {
  81769. context.report({
  81770. node: node,
  81771. message: "Unexpected use of undefined."
  81772. });
  81773. }
  81774. /**
  81775. * Checks the given scope for references to `undefined` and reports
  81776. * all references found.
  81777. * @param {eslint-scope.Scope} scope The scope to check.
  81778. * @returns {void}
  81779. */
  81780. function checkScope(scope) {
  81781. var undefinedVar = scope.set.get("undefined");
  81782. if (!undefinedVar) {
  81783. return;
  81784. }
  81785. var references = undefinedVar.references;
  81786. var defs = undefinedVar.defs;
  81787. // Report non-initializing references (those are covered in defs below)
  81788. references.filter(function (ref) {
  81789. return !ref.init;
  81790. }).forEach(function (ref) {
  81791. return report(ref.identifier);
  81792. });
  81793. defs.forEach(function (def) {
  81794. return report(def.name);
  81795. });
  81796. }
  81797. return {
  81798. "Program:exit": function ProgramExit() {
  81799. var globalScope = context.getScope();
  81800. var stack = [globalScope];
  81801. while (stack.length) {
  81802. var scope = stack.pop();
  81803. stack.push.apply(stack, _toConsumableArray(scope.childScopes));
  81804. checkScope(scope);
  81805. }
  81806. }
  81807. };
  81808. }
  81809. };
  81810. },{}],310:[function(require,module,exports){
  81811. /**
  81812. * @fileoverview Rule to flag trailing underscores in variable declarations.
  81813. * @author Matt DuVall <http://www.mattduvall.com>
  81814. */
  81815. "use strict";
  81816. //------------------------------------------------------------------------------
  81817. // Rule Definition
  81818. //------------------------------------------------------------------------------
  81819. module.exports = {
  81820. meta: {
  81821. type: "suggestion",
  81822. docs: {
  81823. description: "disallow dangling underscores in identifiers",
  81824. category: "Stylistic Issues",
  81825. recommended: false,
  81826. url: "https://eslint.org/docs/rules/no-underscore-dangle"
  81827. },
  81828. schema: [{
  81829. type: "object",
  81830. properties: {
  81831. allow: {
  81832. type: "array",
  81833. items: {
  81834. type: "string"
  81835. }
  81836. },
  81837. allowAfterThis: {
  81838. type: "boolean"
  81839. },
  81840. allowAfterSuper: {
  81841. type: "boolean"
  81842. },
  81843. enforceInMethodNames: {
  81844. type: "boolean"
  81845. }
  81846. },
  81847. additionalProperties: false
  81848. }]
  81849. },
  81850. create: function create(context) {
  81851. var options = context.options[0] || {};
  81852. var ALLOWED_VARIABLES = options.allow ? options.allow : [];
  81853. var allowAfterThis = typeof options.allowAfterThis !== "undefined" ? options.allowAfterThis : false;
  81854. var allowAfterSuper = typeof options.allowAfterSuper !== "undefined" ? options.allowAfterSuper : false;
  81855. var enforceInMethodNames = typeof options.enforceInMethodNames !== "undefined" ? options.enforceInMethodNames : false;
  81856. //-------------------------------------------------------------------------
  81857. // Helpers
  81858. //-------------------------------------------------------------------------
  81859. /**
  81860. * Check if identifier is present inside the allowed option
  81861. * @param {string} identifier name of the node
  81862. * @returns {boolean} true if its is present
  81863. * @private
  81864. */
  81865. function isAllowed(identifier) {
  81866. return ALLOWED_VARIABLES.some(function (ident) {
  81867. return ident === identifier;
  81868. });
  81869. }
  81870. /**
  81871. * Check if identifier has a underscore at the end
  81872. * @param {ASTNode} identifier node to evaluate
  81873. * @returns {boolean} true if its is present
  81874. * @private
  81875. */
  81876. function hasTrailingUnderscore(identifier) {
  81877. var len = identifier.length;
  81878. return identifier !== "_" && (identifier[0] === "_" || identifier[len - 1] === "_");
  81879. }
  81880. /**
  81881. * Check if identifier is a special case member expression
  81882. * @param {ASTNode} identifier node to evaluate
  81883. * @returns {boolean} true if its is a special case
  81884. * @private
  81885. */
  81886. function isSpecialCaseIdentifierForMemberExpression(identifier) {
  81887. return identifier === "__proto__";
  81888. }
  81889. /**
  81890. * Check if identifier is a special case variable expression
  81891. * @param {ASTNode} identifier node to evaluate
  81892. * @returns {boolean} true if its is a special case
  81893. * @private
  81894. */
  81895. function isSpecialCaseIdentifierInVariableExpression(identifier) {
  81896. // Checks for the underscore library usage here
  81897. return identifier === "_";
  81898. }
  81899. /**
  81900. * Check if function has a underscore at the end
  81901. * @param {ASTNode} node node to evaluate
  81902. * @returns {void}
  81903. * @private
  81904. */
  81905. function checkForTrailingUnderscoreInFunctionDeclaration(node) {
  81906. if (node.id) {
  81907. var identifier = node.id.name;
  81908. if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !isAllowed(identifier)) {
  81909. context.report({
  81910. node: node,
  81911. message: "Unexpected dangling '_' in '{{identifier}}'.",
  81912. data: {
  81913. identifier: identifier
  81914. }
  81915. });
  81916. }
  81917. }
  81918. }
  81919. /**
  81920. * Check if variable expression has a underscore at the end
  81921. * @param {ASTNode} node node to evaluate
  81922. * @returns {void}
  81923. * @private
  81924. */
  81925. function checkForTrailingUnderscoreInVariableExpression(node) {
  81926. var identifier = node.id.name;
  81927. if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !isSpecialCaseIdentifierInVariableExpression(identifier) && !isAllowed(identifier)) {
  81928. context.report({
  81929. node: node,
  81930. message: "Unexpected dangling '_' in '{{identifier}}'.",
  81931. data: {
  81932. identifier: identifier
  81933. }
  81934. });
  81935. }
  81936. }
  81937. /**
  81938. * Check if member expression has a underscore at the end
  81939. * @param {ASTNode} node node to evaluate
  81940. * @returns {void}
  81941. * @private
  81942. */
  81943. function checkForTrailingUnderscoreInMemberExpression(node) {
  81944. var identifier = node.property.name,
  81945. isMemberOfThis = node.object.type === "ThisExpression",
  81946. isMemberOfSuper = node.object.type === "Super";
  81947. if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !(isMemberOfThis && allowAfterThis) && !(isMemberOfSuper && allowAfterSuper) && !isSpecialCaseIdentifierForMemberExpression(identifier) && !isAllowed(identifier)) {
  81948. context.report({
  81949. node: node,
  81950. message: "Unexpected dangling '_' in '{{identifier}}'.",
  81951. data: {
  81952. identifier: identifier
  81953. }
  81954. });
  81955. }
  81956. }
  81957. /**
  81958. * Check if method declaration or method property has a underscore at the end
  81959. * @param {ASTNode} node node to evaluate
  81960. * @returns {void}
  81961. * @private
  81962. */
  81963. function checkForTrailingUnderscoreInMethod(node) {
  81964. var identifier = node.key.name;
  81965. var isMethod = node.type === "MethodDefinition" || node.type === "Property" && node.method;
  81966. if (typeof identifier !== "undefined" && enforceInMethodNames && isMethod && hasTrailingUnderscore(identifier)) {
  81967. context.report({
  81968. node: node,
  81969. message: "Unexpected dangling '_' in '{{identifier}}'.",
  81970. data: {
  81971. identifier: identifier
  81972. }
  81973. });
  81974. }
  81975. }
  81976. //--------------------------------------------------------------------------
  81977. // Public API
  81978. //--------------------------------------------------------------------------
  81979. return {
  81980. FunctionDeclaration: checkForTrailingUnderscoreInFunctionDeclaration,
  81981. VariableDeclarator: checkForTrailingUnderscoreInVariableExpression,
  81982. MemberExpression: checkForTrailingUnderscoreInMemberExpression,
  81983. MethodDefinition: checkForTrailingUnderscoreInMethod,
  81984. Property: checkForTrailingUnderscoreInMethod
  81985. };
  81986. }
  81987. };
  81988. },{}],311:[function(require,module,exports){
  81989. /**
  81990. * @fileoverview Rule to spot scenarios where a newline looks like it is ending a statement, but is not.
  81991. * @author Glen Mailer
  81992. */
  81993. "use strict";
  81994. //------------------------------------------------------------------------------
  81995. // Requirements
  81996. //------------------------------------------------------------------------------
  81997. var astUtils = require("../util/ast-utils");
  81998. //------------------------------------------------------------------------------
  81999. // Rule Definition
  82000. //------------------------------------------------------------------------------
  82001. module.exports = {
  82002. meta: {
  82003. type: "problem",
  82004. docs: {
  82005. description: "disallow confusing multiline expressions",
  82006. category: "Possible Errors",
  82007. recommended: true,
  82008. url: "https://eslint.org/docs/rules/no-unexpected-multiline"
  82009. },
  82010. schema: []
  82011. },
  82012. create: function create(context) {
  82013. var FUNCTION_MESSAGE = "Unexpected newline between function and ( of function call.";
  82014. var PROPERTY_MESSAGE = "Unexpected newline between object and [ of property access.";
  82015. var TAGGED_TEMPLATE_MESSAGE = "Unexpected newline between template tag and template literal.";
  82016. var DIVISION_MESSAGE = "Unexpected newline between numerator and division operator.";
  82017. var REGEX_FLAG_MATCHER = /^[gimsuy]+$/;
  82018. var sourceCode = context.getSourceCode();
  82019. /**
  82020. * Check to see if there is a newline between the node and the following open bracket
  82021. * line's expression
  82022. * @param {ASTNode} node The node to check.
  82023. * @param {string} msg The error message to use.
  82024. * @returns {void}
  82025. * @private
  82026. */
  82027. function checkForBreakAfter(node, msg) {
  82028. var openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken);
  82029. var nodeExpressionEnd = sourceCode.getTokenBefore(openParen);
  82030. if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) {
  82031. context.report({ node: node, loc: openParen.loc.start, message: msg, data: { char: openParen.value } });
  82032. }
  82033. }
  82034. //--------------------------------------------------------------------------
  82035. // Public API
  82036. //--------------------------------------------------------------------------
  82037. return {
  82038. MemberExpression: function MemberExpression(node) {
  82039. if (!node.computed) {
  82040. return;
  82041. }
  82042. checkForBreakAfter(node.object, PROPERTY_MESSAGE);
  82043. },
  82044. TaggedTemplateExpression: function TaggedTemplateExpression(node) {
  82045. if (node.tag.loc.end.line === node.quasi.loc.start.line) {
  82046. return;
  82047. }
  82048. context.report({ node: node, loc: node.loc.start, message: TAGGED_TEMPLATE_MESSAGE });
  82049. },
  82050. CallExpression: function CallExpression(node) {
  82051. if (node.arguments.length === 0) {
  82052. return;
  82053. }
  82054. checkForBreakAfter(node.callee, FUNCTION_MESSAGE);
  82055. },
  82056. "BinaryExpression[operator='/'] > BinaryExpression[operator='/'].left": function BinaryExpressionOperatorBinaryExpressionOperatorLeft(node) {
  82057. var secondSlash = sourceCode.getTokenAfter(node, function (token) {
  82058. return token.value === "/";
  82059. });
  82060. var tokenAfterOperator = sourceCode.getTokenAfter(secondSlash);
  82061. if (tokenAfterOperator.type === "Identifier" && REGEX_FLAG_MATCHER.test(tokenAfterOperator.value) && secondSlash.range[1] === tokenAfterOperator.range[0]) {
  82062. checkForBreakAfter(node.left, DIVISION_MESSAGE);
  82063. }
  82064. }
  82065. };
  82066. }
  82067. };
  82068. },{"../util/ast-utils":405}],312:[function(require,module,exports){
  82069. /**
  82070. * @fileoverview Rule to disallow use of unmodified expressions in loop conditions
  82071. * @author Toru Nagashima
  82072. */
  82073. "use strict";
  82074. //------------------------------------------------------------------------------
  82075. // Requirements
  82076. //------------------------------------------------------------------------------
  82077. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  82078. var Traverser = require("../util/traverser"),
  82079. astUtils = require("../util/ast-utils");
  82080. //------------------------------------------------------------------------------
  82081. // Helpers
  82082. //------------------------------------------------------------------------------
  82083. var SENTINEL_PATTERN = /(?:(?:Call|Class|Function|Member|New|Yield)Expression|Statement|Declaration)$/;
  82084. var LOOP_PATTERN = /^(?:DoWhile|For|While)Statement$/; // for-in/of statements don't have `test` property.
  82085. var GROUP_PATTERN = /^(?:BinaryExpression|ConditionalExpression)$/;
  82086. var SKIP_PATTERN = /^(?:ArrowFunction|Class|Function)Expression$/;
  82087. var DYNAMIC_PATTERN = /^(?:Call|Member|New|TaggedTemplate|Yield)Expression$/;
  82088. /**
  82089. * @typedef {Object} LoopConditionInfo
  82090. * @property {eslint-scope.Reference} reference - The reference.
  82091. * @property {ASTNode} group - BinaryExpression or ConditionalExpression nodes
  82092. * that the reference is belonging to.
  82093. * @property {Function} isInLoop - The predicate which checks a given reference
  82094. * is in this loop.
  82095. * @property {boolean} modified - The flag that the reference is modified in
  82096. * this loop.
  82097. */
  82098. /**
  82099. * Checks whether or not a given reference is a write reference.
  82100. *
  82101. * @param {eslint-scope.Reference} reference - A reference to check.
  82102. * @returns {boolean} `true` if the reference is a write reference.
  82103. */
  82104. function isWriteReference(reference) {
  82105. if (reference.init) {
  82106. var def = reference.resolved && reference.resolved.defs[0];
  82107. if (!def || def.type !== "Variable" || def.parent.kind !== "var") {
  82108. return false;
  82109. }
  82110. }
  82111. return reference.isWrite();
  82112. }
  82113. /**
  82114. * Checks whether or not a given loop condition info does not have the modified
  82115. * flag.
  82116. *
  82117. * @param {LoopConditionInfo} condition - A loop condition info to check.
  82118. * @returns {boolean} `true` if the loop condition info is "unmodified".
  82119. */
  82120. function isUnmodified(condition) {
  82121. return !condition.modified;
  82122. }
  82123. /**
  82124. * Checks whether or not a given loop condition info does not have the modified
  82125. * flag and does not have the group this condition belongs to.
  82126. *
  82127. * @param {LoopConditionInfo} condition - A loop condition info to check.
  82128. * @returns {boolean} `true` if the loop condition info is "unmodified".
  82129. */
  82130. function isUnmodifiedAndNotBelongToGroup(condition) {
  82131. return !(condition.modified || condition.group);
  82132. }
  82133. /**
  82134. * Checks whether or not a given reference is inside of a given node.
  82135. *
  82136. * @param {ASTNode} node - A node to check.
  82137. * @param {eslint-scope.Reference} reference - A reference to check.
  82138. * @returns {boolean} `true` if the reference is inside of the node.
  82139. */
  82140. function isInRange(node, reference) {
  82141. var or = node.range;
  82142. var ir = reference.identifier.range;
  82143. return or[0] <= ir[0] && ir[1] <= or[1];
  82144. }
  82145. /**
  82146. * Checks whether or not a given reference is inside of a loop node's condition.
  82147. *
  82148. * @param {ASTNode} node - A node to check.
  82149. * @param {eslint-scope.Reference} reference - A reference to check.
  82150. * @returns {boolean} `true` if the reference is inside of the loop node's
  82151. * condition.
  82152. */
  82153. var isInLoop = {
  82154. WhileStatement: isInRange,
  82155. DoWhileStatement: isInRange,
  82156. ForStatement: function ForStatement(node, reference) {
  82157. return isInRange(node, reference) && !(node.init && isInRange(node.init, reference));
  82158. }
  82159. };
  82160. /**
  82161. * Gets the function which encloses a given reference.
  82162. * This supports only FunctionDeclaration.
  82163. *
  82164. * @param {eslint-scope.Reference} reference - A reference to get.
  82165. * @returns {ASTNode|null} The function node or null.
  82166. */
  82167. function getEncloseFunctionDeclaration(reference) {
  82168. var node = reference.identifier;
  82169. while (node) {
  82170. if (node.type === "FunctionDeclaration") {
  82171. return node.id ? node : null;
  82172. }
  82173. node = node.parent;
  82174. }
  82175. return null;
  82176. }
  82177. /**
  82178. * Updates the "modified" flags of given loop conditions with given modifiers.
  82179. *
  82180. * @param {LoopConditionInfo[]} conditions - The loop conditions to be updated.
  82181. * @param {eslint-scope.Reference[]} modifiers - The references to update.
  82182. * @returns {void}
  82183. */
  82184. function updateModifiedFlag(conditions, modifiers) {
  82185. for (var i = 0; i < conditions.length; ++i) {
  82186. var condition = conditions[i];
  82187. for (var j = 0; !condition.modified && j < modifiers.length; ++j) {
  82188. var modifier = modifiers[j];
  82189. var funcNode = void 0,
  82190. funcVar = void 0;
  82191. /*
  82192. * Besides checking for the condition being in the loop, we want to
  82193. * check the function that this modifier is belonging to is called
  82194. * in the loop.
  82195. * FIXME: This should probably be extracted to a function.
  82196. */
  82197. var inLoop = condition.isInLoop(modifier) || Boolean((funcNode = getEncloseFunctionDeclaration(modifier)) && (funcVar = astUtils.getVariableByName(modifier.from.upper, funcNode.id.name)) && funcVar.references.some(condition.isInLoop));
  82198. condition.modified = inLoop;
  82199. }
  82200. }
  82201. }
  82202. //------------------------------------------------------------------------------
  82203. // Rule Definition
  82204. //------------------------------------------------------------------------------
  82205. module.exports = {
  82206. meta: {
  82207. type: "problem",
  82208. docs: {
  82209. description: "disallow unmodified loop conditions",
  82210. category: "Best Practices",
  82211. recommended: false,
  82212. url: "https://eslint.org/docs/rules/no-unmodified-loop-condition"
  82213. },
  82214. schema: []
  82215. },
  82216. create: function create(context) {
  82217. var sourceCode = context.getSourceCode();
  82218. var groupMap = null;
  82219. /**
  82220. * Reports a given condition info.
  82221. *
  82222. * @param {LoopConditionInfo} condition - A loop condition info to report.
  82223. * @returns {void}
  82224. */
  82225. function report(condition) {
  82226. var node = condition.reference.identifier;
  82227. context.report({
  82228. node: node,
  82229. message: "'{{name}}' is not modified in this loop.",
  82230. data: node
  82231. });
  82232. }
  82233. /**
  82234. * Registers given conditions to the group the condition belongs to.
  82235. *
  82236. * @param {LoopConditionInfo[]} conditions - A loop condition info to
  82237. * register.
  82238. * @returns {void}
  82239. */
  82240. function registerConditionsToGroup(conditions) {
  82241. for (var i = 0; i < conditions.length; ++i) {
  82242. var condition = conditions[i];
  82243. if (condition.group) {
  82244. var group = groupMap.get(condition.group);
  82245. if (!group) {
  82246. group = [];
  82247. groupMap.set(condition.group, group);
  82248. }
  82249. group.push(condition);
  82250. }
  82251. }
  82252. }
  82253. /**
  82254. * Reports references which are inside of unmodified groups.
  82255. *
  82256. * @param {LoopConditionInfo[]} conditions - A loop condition info to report.
  82257. * @returns {void}
  82258. */
  82259. function checkConditionsInGroup(conditions) {
  82260. if (conditions.every(isUnmodified)) {
  82261. conditions.forEach(report);
  82262. }
  82263. }
  82264. /**
  82265. * Checks whether or not a given group node has any dynamic elements.
  82266. *
  82267. * @param {ASTNode} root - A node to check.
  82268. * This node is one of BinaryExpression or ConditionalExpression.
  82269. * @returns {boolean} `true` if the node is dynamic.
  82270. */
  82271. function hasDynamicExpressions(root) {
  82272. var retv = false;
  82273. Traverser.traverse(root, {
  82274. visitorKeys: sourceCode.visitorKeys,
  82275. enter: function enter(node) {
  82276. if (DYNAMIC_PATTERN.test(node.type)) {
  82277. retv = true;
  82278. this.break();
  82279. } else if (SKIP_PATTERN.test(node.type)) {
  82280. this.skip();
  82281. }
  82282. }
  82283. });
  82284. return retv;
  82285. }
  82286. /**
  82287. * Creates the loop condition information from a given reference.
  82288. *
  82289. * @param {eslint-scope.Reference} reference - A reference to create.
  82290. * @returns {LoopConditionInfo|null} Created loop condition info, or null.
  82291. */
  82292. function toLoopCondition(reference) {
  82293. if (reference.init) {
  82294. return null;
  82295. }
  82296. var group = null;
  82297. var child = reference.identifier;
  82298. var node = child.parent;
  82299. while (node) {
  82300. if (SENTINEL_PATTERN.test(node.type)) {
  82301. if (LOOP_PATTERN.test(node.type) && node.test === child) {
  82302. // This reference is inside of a loop condition.
  82303. return {
  82304. reference: reference,
  82305. group: group,
  82306. isInLoop: isInLoop[node.type].bind(null, node),
  82307. modified: false
  82308. };
  82309. }
  82310. // This reference is outside of a loop condition.
  82311. break;
  82312. }
  82313. /*
  82314. * If it's inside of a group, OK if either operand is modified.
  82315. * So stores the group this reference belongs to.
  82316. */
  82317. if (GROUP_PATTERN.test(node.type)) {
  82318. // If this expression is dynamic, no need to check.
  82319. if (hasDynamicExpressions(node)) {
  82320. break;
  82321. } else {
  82322. group = node;
  82323. }
  82324. }
  82325. child = node;
  82326. node = node.parent;
  82327. }
  82328. return null;
  82329. }
  82330. /**
  82331. * Finds unmodified references which are inside of a loop condition.
  82332. * Then reports the references which are outside of groups.
  82333. *
  82334. * @param {eslint-scope.Variable} variable - A variable to report.
  82335. * @returns {void}
  82336. */
  82337. function checkReferences(variable) {
  82338. // Gets references that exist in loop conditions.
  82339. var conditions = variable.references.map(toLoopCondition).filter(Boolean);
  82340. if (conditions.length === 0) {
  82341. return;
  82342. }
  82343. // Registers the conditions to belonging groups.
  82344. registerConditionsToGroup(conditions);
  82345. // Check the conditions are modified.
  82346. var modifiers = variable.references.filter(isWriteReference);
  82347. if (modifiers.length > 0) {
  82348. updateModifiedFlag(conditions, modifiers);
  82349. }
  82350. /*
  82351. * Reports the conditions which are not belonging to groups.
  82352. * Others will be reported after all variables are done.
  82353. */
  82354. conditions.filter(isUnmodifiedAndNotBelongToGroup).forEach(report);
  82355. }
  82356. return {
  82357. "Program:exit": function ProgramExit() {
  82358. var queue = [context.getScope()];
  82359. groupMap = new Map();
  82360. var scope = void 0;
  82361. while (scope = queue.pop()) {
  82362. queue.push.apply(queue, _toConsumableArray(scope.childScopes));
  82363. scope.variables.forEach(checkReferences);
  82364. }
  82365. groupMap.forEach(checkConditionsInGroup);
  82366. groupMap = null;
  82367. }
  82368. };
  82369. }
  82370. };
  82371. },{"../util/ast-utils":405,"../util/traverser":418}],313:[function(require,module,exports){
  82372. /**
  82373. * @fileoverview Rule to flag no-unneeded-ternary
  82374. * @author Gyandeep Singh
  82375. */
  82376. "use strict";
  82377. var astUtils = require("../util/ast-utils");
  82378. // Operators that always result in a boolean value
  82379. var BOOLEAN_OPERATORS = new Set(["==", "===", "!=", "!==", ">", ">=", "<", "<=", "in", "instanceof"]);
  82380. var OPERATOR_INVERSES = {
  82381. "==": "!=",
  82382. "!=": "==",
  82383. "===": "!==",
  82384. "!==": "==="
  82385. // Operators like < and >= are not true inverses, since both will return false with NaN.
  82386. };
  82387. //------------------------------------------------------------------------------
  82388. // Rule Definition
  82389. //------------------------------------------------------------------------------
  82390. module.exports = {
  82391. meta: {
  82392. type: "suggestion",
  82393. docs: {
  82394. description: "disallow ternary operators when simpler alternatives exist",
  82395. category: "Stylistic Issues",
  82396. recommended: false,
  82397. url: "https://eslint.org/docs/rules/no-unneeded-ternary"
  82398. },
  82399. schema: [{
  82400. type: "object",
  82401. properties: {
  82402. defaultAssignment: {
  82403. type: "boolean"
  82404. }
  82405. },
  82406. additionalProperties: false
  82407. }],
  82408. fixable: "code"
  82409. },
  82410. create: function create(context) {
  82411. var options = context.options[0] || {};
  82412. var defaultAssignment = options.defaultAssignment !== false;
  82413. var sourceCode = context.getSourceCode();
  82414. /**
  82415. * Test if the node is a boolean literal
  82416. * @param {ASTNode} node - The node to report.
  82417. * @returns {boolean} True if the its a boolean literal
  82418. * @private
  82419. */
  82420. function isBooleanLiteral(node) {
  82421. return node.type === "Literal" && typeof node.value === "boolean";
  82422. }
  82423. /**
  82424. * Creates an expression that represents the boolean inverse of the expression represented by the original node
  82425. * @param {ASTNode} node A node representing an expression
  82426. * @returns {string} A string representing an inverted expression
  82427. */
  82428. function invertExpression(node) {
  82429. if (node.type === "BinaryExpression" && Object.prototype.hasOwnProperty.call(OPERATOR_INVERSES, node.operator)) {
  82430. var operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, function (token) {
  82431. return token.value === node.operator;
  82432. });
  82433. var text = sourceCode.getText();
  82434. return text.slice(node.range[0], operatorToken.range[0]) + OPERATOR_INVERSES[node.operator] + text.slice(operatorToken.range[1], node.range[1]);
  82435. }
  82436. if (astUtils.getPrecedence(node) < astUtils.getPrecedence({ type: "UnaryExpression" })) {
  82437. return "!(" + astUtils.getParenthesisedText(sourceCode, node) + ")";
  82438. }
  82439. return "!" + astUtils.getParenthesisedText(sourceCode, node);
  82440. }
  82441. /**
  82442. * Tests if a given node always evaluates to a boolean value
  82443. * @param {ASTNode} node - An expression node
  82444. * @returns {boolean} True if it is determined that the node will always evaluate to a boolean value
  82445. */
  82446. function isBooleanExpression(node) {
  82447. return node.type === "BinaryExpression" && BOOLEAN_OPERATORS.has(node.operator) || node.type === "UnaryExpression" && node.operator === "!";
  82448. }
  82449. /**
  82450. * Test if the node matches the pattern id ? id : expression
  82451. * @param {ASTNode} node - The ConditionalExpression to check.
  82452. * @returns {boolean} True if the pattern is matched, and false otherwise
  82453. * @private
  82454. */
  82455. function matchesDefaultAssignment(node) {
  82456. return node.test.type === "Identifier" && node.consequent.type === "Identifier" && node.test.name === node.consequent.name;
  82457. }
  82458. return {
  82459. ConditionalExpression: function ConditionalExpression(node) {
  82460. if (isBooleanLiteral(node.alternate) && isBooleanLiteral(node.consequent)) {
  82461. context.report({
  82462. node: node,
  82463. loc: node.consequent.loc.start,
  82464. message: "Unnecessary use of boolean literals in conditional expression.",
  82465. fix: function fix(fixer) {
  82466. if (node.consequent.value === node.alternate.value) {
  82467. // Replace `foo ? true : true` with just `true`, but don't replace `foo() ? true : true`
  82468. return node.test.type === "Identifier" ? fixer.replaceText(node, node.consequent.value.toString()) : null;
  82469. }
  82470. if (node.alternate.value) {
  82471. // Replace `foo() ? false : true` with `!(foo())`
  82472. return fixer.replaceText(node, invertExpression(node.test));
  82473. }
  82474. // Replace `foo ? true : false` with `foo` if `foo` is guaranteed to be a boolean, or `!!foo` otherwise.
  82475. return fixer.replaceText(node, isBooleanExpression(node.test) ? astUtils.getParenthesisedText(sourceCode, node.test) : "!" + invertExpression(node.test));
  82476. }
  82477. });
  82478. } else if (!defaultAssignment && matchesDefaultAssignment(node)) {
  82479. context.report({
  82480. node: node,
  82481. loc: node.consequent.loc.start,
  82482. message: "Unnecessary use of conditional expression for default assignment.",
  82483. fix: function fix(fixer) {
  82484. var nodeAlternate = astUtils.getParenthesisedText(sourceCode, node.alternate);
  82485. if (node.alternate.type === "ConditionalExpression" || node.alternate.type === "YieldExpression") {
  82486. var isAlternateParenthesised = astUtils.isParenthesised(sourceCode, node.alternate);
  82487. nodeAlternate = isAlternateParenthesised ? nodeAlternate : "(" + nodeAlternate + ")";
  82488. }
  82489. return fixer.replaceText(node, astUtils.getParenthesisedText(sourceCode, node.test) + " || " + nodeAlternate);
  82490. }
  82491. });
  82492. }
  82493. }
  82494. };
  82495. }
  82496. };
  82497. },{"../util/ast-utils":405}],314:[function(require,module,exports){
  82498. /**
  82499. * @fileoverview Checks for unreachable code due to return, throws, break, and continue.
  82500. * @author Joel Feenstra
  82501. */
  82502. "use strict";
  82503. //------------------------------------------------------------------------------
  82504. // Helpers
  82505. //------------------------------------------------------------------------------
  82506. /**
  82507. * Checks whether or not a given variable declarator has the initializer.
  82508. * @param {ASTNode} node - A VariableDeclarator node to check.
  82509. * @returns {boolean} `true` if the node has the initializer.
  82510. */
  82511. 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; }; }();
  82512. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  82513. function isInitialized(node) {
  82514. return Boolean(node.init);
  82515. }
  82516. /**
  82517. * Checks whether or not a given code path segment is unreachable.
  82518. * @param {CodePathSegment} segment - A CodePathSegment to check.
  82519. * @returns {boolean} `true` if the segment is unreachable.
  82520. */
  82521. function isUnreachable(segment) {
  82522. return !segment.reachable;
  82523. }
  82524. /**
  82525. * The class to distinguish consecutive unreachable statements.
  82526. */
  82527. var ConsecutiveRange = function () {
  82528. function ConsecutiveRange(sourceCode) {
  82529. _classCallCheck(this, ConsecutiveRange);
  82530. this.sourceCode = sourceCode;
  82531. this.startNode = null;
  82532. this.endNode = null;
  82533. }
  82534. /**
  82535. * The location object of this range.
  82536. * @type {Object}
  82537. */
  82538. _createClass(ConsecutiveRange, [{
  82539. key: "contains",
  82540. /**
  82541. * Checks whether the given node is inside of this range.
  82542. * @param {ASTNode|Token} node - The node to check.
  82543. * @returns {boolean} `true` if the node is inside of this range.
  82544. */
  82545. value: function contains(node) {
  82546. return node.range[0] >= this.startNode.range[0] && node.range[1] <= this.endNode.range[1];
  82547. }
  82548. /**
  82549. * Checks whether the given node is consecutive to this range.
  82550. * @param {ASTNode} node - The node to check.
  82551. * @returns {boolean} `true` if the node is consecutive to this range.
  82552. */
  82553. }, {
  82554. key: "isConsecutive",
  82555. value: function isConsecutive(node) {
  82556. return this.contains(this.sourceCode.getTokenBefore(node));
  82557. }
  82558. /**
  82559. * Merges the given node to this range.
  82560. * @param {ASTNode} node - The node to merge.
  82561. * @returns {void}
  82562. */
  82563. }, {
  82564. key: "merge",
  82565. value: function merge(node) {
  82566. this.endNode = node;
  82567. }
  82568. /**
  82569. * Resets this range by the given node or null.
  82570. * @param {ASTNode|null} node - The node to reset, or null.
  82571. * @returns {void}
  82572. */
  82573. }, {
  82574. key: "reset",
  82575. value: function reset(node) {
  82576. this.startNode = this.endNode = node;
  82577. }
  82578. }, {
  82579. key: "location",
  82580. get: function get() {
  82581. return {
  82582. start: this.startNode.loc.start,
  82583. end: this.endNode.loc.end
  82584. };
  82585. }
  82586. /**
  82587. * `true` if this range is empty.
  82588. * @type {boolean}
  82589. */
  82590. }, {
  82591. key: "isEmpty",
  82592. get: function get() {
  82593. return !(this.startNode && this.endNode);
  82594. }
  82595. }]);
  82596. return ConsecutiveRange;
  82597. }();
  82598. //------------------------------------------------------------------------------
  82599. // Rule Definition
  82600. //------------------------------------------------------------------------------
  82601. module.exports = {
  82602. meta: {
  82603. type: "problem",
  82604. docs: {
  82605. description: "disallow unreachable code after `return`, `throw`, `continue`, and `break` statements",
  82606. category: "Possible Errors",
  82607. recommended: true,
  82608. url: "https://eslint.org/docs/rules/no-unreachable"
  82609. },
  82610. schema: []
  82611. },
  82612. create: function create(context) {
  82613. var currentCodePath = null;
  82614. var range = new ConsecutiveRange(context.getSourceCode());
  82615. /**
  82616. * Reports a given node if it's unreachable.
  82617. * @param {ASTNode} node - A statement node to report.
  82618. * @returns {void}
  82619. */
  82620. function reportIfUnreachable(node) {
  82621. var nextNode = null;
  82622. if (node && currentCodePath.currentSegments.every(isUnreachable)) {
  82623. // Store this statement to distinguish consecutive statements.
  82624. if (range.isEmpty) {
  82625. range.reset(node);
  82626. return;
  82627. }
  82628. // Skip if this statement is inside of the current range.
  82629. if (range.contains(node)) {
  82630. return;
  82631. }
  82632. // Merge if this statement is consecutive to the current range.
  82633. if (range.isConsecutive(node)) {
  82634. range.merge(node);
  82635. return;
  82636. }
  82637. nextNode = node;
  82638. }
  82639. /*
  82640. * Report the current range since this statement is reachable or is
  82641. * not consecutive to the current range.
  82642. */
  82643. if (!range.isEmpty) {
  82644. context.report({
  82645. message: "Unreachable code.",
  82646. loc: range.location,
  82647. node: range.startNode
  82648. });
  82649. }
  82650. // Update the current range.
  82651. range.reset(nextNode);
  82652. }
  82653. return {
  82654. // Manages the current code path.
  82655. onCodePathStart: function onCodePathStart(codePath) {
  82656. currentCodePath = codePath;
  82657. },
  82658. onCodePathEnd: function onCodePathEnd() {
  82659. currentCodePath = currentCodePath.upper;
  82660. },
  82661. // Registers for all statement nodes (excludes FunctionDeclaration).
  82662. BlockStatement: reportIfUnreachable,
  82663. BreakStatement: reportIfUnreachable,
  82664. ClassDeclaration: reportIfUnreachable,
  82665. ContinueStatement: reportIfUnreachable,
  82666. DebuggerStatement: reportIfUnreachable,
  82667. DoWhileStatement: reportIfUnreachable,
  82668. ExpressionStatement: reportIfUnreachable,
  82669. ForInStatement: reportIfUnreachable,
  82670. ForOfStatement: reportIfUnreachable,
  82671. ForStatement: reportIfUnreachable,
  82672. IfStatement: reportIfUnreachable,
  82673. ImportDeclaration: reportIfUnreachable,
  82674. LabeledStatement: reportIfUnreachable,
  82675. ReturnStatement: reportIfUnreachable,
  82676. SwitchStatement: reportIfUnreachable,
  82677. ThrowStatement: reportIfUnreachable,
  82678. TryStatement: reportIfUnreachable,
  82679. VariableDeclaration: function VariableDeclaration(node) {
  82680. if (node.kind !== "var" || node.declarations.some(isInitialized)) {
  82681. reportIfUnreachable(node);
  82682. }
  82683. },
  82684. WhileStatement: reportIfUnreachable,
  82685. WithStatement: reportIfUnreachable,
  82686. ExportNamedDeclaration: reportIfUnreachable,
  82687. ExportDefaultDeclaration: reportIfUnreachable,
  82688. ExportAllDeclaration: reportIfUnreachable,
  82689. "Program:exit": function ProgramExit() {
  82690. reportIfUnreachable();
  82691. }
  82692. };
  82693. }
  82694. };
  82695. },{}],315:[function(require,module,exports){
  82696. /**
  82697. * @fileoverview Rule to flag unsafe statements in finally block
  82698. * @author Onur Temizkan
  82699. */
  82700. "use strict";
  82701. //------------------------------------------------------------------------------
  82702. // Helpers
  82703. //------------------------------------------------------------------------------
  82704. var SENTINEL_NODE_TYPE_RETURN_THROW = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression)$/;
  82705. var SENTINEL_NODE_TYPE_BREAK = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement|SwitchStatement)$/;
  82706. var SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement)$/;
  82707. //------------------------------------------------------------------------------
  82708. // Rule Definition
  82709. //------------------------------------------------------------------------------
  82710. module.exports = {
  82711. meta: {
  82712. type: "problem",
  82713. docs: {
  82714. description: "disallow control flow statements in `finally` blocks",
  82715. category: "Possible Errors",
  82716. recommended: true,
  82717. url: "https://eslint.org/docs/rules/no-unsafe-finally"
  82718. },
  82719. schema: []
  82720. },
  82721. create: function create(context) {
  82722. /**
  82723. * Checks if the node is the finalizer of a TryStatement
  82724. *
  82725. * @param {ASTNode} node - node to check.
  82726. * @returns {boolean} - true if the node is the finalizer of a TryStatement
  82727. */
  82728. function isFinallyBlock(node) {
  82729. return node.parent.type === "TryStatement" && node.parent.finalizer === node;
  82730. }
  82731. /**
  82732. * Climbs up the tree if the node is not a sentinel node
  82733. *
  82734. * @param {ASTNode} node - node to check.
  82735. * @param {string} label - label of the break or continue statement
  82736. * @returns {boolean} - return whether the node is a finally block or a sentinel node
  82737. */
  82738. function isInFinallyBlock(node, label) {
  82739. var labelInside = false;
  82740. var sentinelNodeType = void 0;
  82741. if (node.type === "BreakStatement" && !node.label) {
  82742. sentinelNodeType = SENTINEL_NODE_TYPE_BREAK;
  82743. } else if (node.type === "ContinueStatement") {
  82744. sentinelNodeType = SENTINEL_NODE_TYPE_CONTINUE;
  82745. } else {
  82746. sentinelNodeType = SENTINEL_NODE_TYPE_RETURN_THROW;
  82747. }
  82748. for (var currentNode = node; currentNode && !sentinelNodeType.test(currentNode.type); currentNode = currentNode.parent) {
  82749. if (currentNode.parent.label && label && currentNode.parent.label.name === label.name) {
  82750. labelInside = true;
  82751. }
  82752. if (isFinallyBlock(currentNode)) {
  82753. if (label && labelInside) {
  82754. return false;
  82755. }
  82756. return true;
  82757. }
  82758. }
  82759. return false;
  82760. }
  82761. /**
  82762. * Checks whether the possibly-unsafe statement is inside a finally block.
  82763. *
  82764. * @param {ASTNode} node - node to check.
  82765. * @returns {void}
  82766. */
  82767. function check(node) {
  82768. if (isInFinallyBlock(node, node.label)) {
  82769. context.report({
  82770. message: "Unsafe usage of {{nodeType}}.",
  82771. data: {
  82772. nodeType: node.type
  82773. },
  82774. node: node,
  82775. line: node.loc.line,
  82776. column: node.loc.column
  82777. });
  82778. }
  82779. }
  82780. return {
  82781. ReturnStatement: check,
  82782. ThrowStatement: check,
  82783. BreakStatement: check,
  82784. ContinueStatement: check
  82785. };
  82786. }
  82787. };
  82788. },{}],316:[function(require,module,exports){
  82789. /**
  82790. * @fileoverview Rule to disallow negating the left operand of relational operators
  82791. * @author Toru Nagashima
  82792. */
  82793. "use strict";
  82794. //------------------------------------------------------------------------------
  82795. // Requirements
  82796. //------------------------------------------------------------------------------
  82797. var astUtils = require("../util/ast-utils");
  82798. //------------------------------------------------------------------------------
  82799. // Helpers
  82800. //------------------------------------------------------------------------------
  82801. /**
  82802. * Checks whether the given operator is a relational operator or not.
  82803. *
  82804. * @param {string} op - The operator type to check.
  82805. * @returns {boolean} `true` if the operator is a relational operator.
  82806. */
  82807. function isRelationalOperator(op) {
  82808. return op === "in" || op === "instanceof";
  82809. }
  82810. /**
  82811. * Checks whether the given node is a logical negation expression or not.
  82812. *
  82813. * @param {ASTNode} node - The node to check.
  82814. * @returns {boolean} `true` if the node is a logical negation expression.
  82815. */
  82816. function isNegation(node) {
  82817. return node.type === "UnaryExpression" && node.operator === "!";
  82818. }
  82819. //------------------------------------------------------------------------------
  82820. // Rule Definition
  82821. //------------------------------------------------------------------------------
  82822. module.exports = {
  82823. meta: {
  82824. type: "problem",
  82825. docs: {
  82826. description: "disallow negating the left operand of relational operators",
  82827. category: "Possible Errors",
  82828. recommended: true,
  82829. url: "https://eslint.org/docs/rules/no-unsafe-negation"
  82830. },
  82831. schema: [],
  82832. fixable: "code"
  82833. },
  82834. create: function create(context) {
  82835. var sourceCode = context.getSourceCode();
  82836. return {
  82837. BinaryExpression: function BinaryExpression(node) {
  82838. if (isRelationalOperator(node.operator) && isNegation(node.left) && !astUtils.isParenthesised(sourceCode, node.left)) {
  82839. context.report({
  82840. node: node,
  82841. loc: node.left.loc,
  82842. message: "Unexpected negating the left operand of '{{operator}}' operator.",
  82843. data: node,
  82844. fix: function fix(fixer) {
  82845. var negationToken = sourceCode.getFirstToken(node.left);
  82846. var fixRange = [negationToken.range[1], node.range[1]];
  82847. var text = sourceCode.text.slice(fixRange[0], fixRange[1]);
  82848. return fixer.replaceTextRange(fixRange, "(" + text + ")");
  82849. }
  82850. });
  82851. }
  82852. }
  82853. };
  82854. }
  82855. };
  82856. },{"../util/ast-utils":405}],317:[function(require,module,exports){
  82857. /**
  82858. * @fileoverview Flag expressions in statement position that do not side effect
  82859. * @author Michael Ficarra
  82860. */
  82861. "use strict";
  82862. //------------------------------------------------------------------------------
  82863. // Rule Definition
  82864. //------------------------------------------------------------------------------
  82865. module.exports = {
  82866. meta: {
  82867. type: "suggestion",
  82868. docs: {
  82869. description: "disallow unused expressions",
  82870. category: "Best Practices",
  82871. recommended: false,
  82872. url: "https://eslint.org/docs/rules/no-unused-expressions"
  82873. },
  82874. schema: [{
  82875. type: "object",
  82876. properties: {
  82877. allowShortCircuit: {
  82878. type: "boolean"
  82879. },
  82880. allowTernary: {
  82881. type: "boolean"
  82882. },
  82883. allowTaggedTemplates: {
  82884. type: "boolean"
  82885. }
  82886. },
  82887. additionalProperties: false
  82888. }]
  82889. },
  82890. create: function create(context) {
  82891. var config = context.options[0] || {},
  82892. allowShortCircuit = config.allowShortCircuit || false,
  82893. allowTernary = config.allowTernary || false,
  82894. allowTaggedTemplates = config.allowTaggedTemplates || false;
  82895. /**
  82896. * @param {ASTNode} node - any node
  82897. * @returns {boolean} whether the given node structurally represents a directive
  82898. */
  82899. function looksLikeDirective(node) {
  82900. return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
  82901. }
  82902. /**
  82903. * @param {Function} predicate - ([a] -> Boolean) the function used to make the determination
  82904. * @param {a[]} list - the input list
  82905. * @returns {a[]} the leading sequence of members in the given list that pass the given predicate
  82906. */
  82907. function takeWhile(predicate, list) {
  82908. for (var i = 0; i < list.length; ++i) {
  82909. if (!predicate(list[i])) {
  82910. return list.slice(0, i);
  82911. }
  82912. }
  82913. return list.slice();
  82914. }
  82915. /**
  82916. * @param {ASTNode} node - a Program or BlockStatement node
  82917. * @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
  82918. */
  82919. function directives(node) {
  82920. return takeWhile(looksLikeDirective, node.body);
  82921. }
  82922. /**
  82923. * @param {ASTNode} node - any node
  82924. * @param {ASTNode[]} ancestors - the given node's ancestors
  82925. * @returns {boolean} whether the given node is considered a directive in its current position
  82926. */
  82927. function isDirective(node, ancestors) {
  82928. var parent = ancestors[ancestors.length - 1],
  82929. grandparent = ancestors[ancestors.length - 2];
  82930. return (parent.type === "Program" || parent.type === "BlockStatement" && /Function/.test(grandparent.type)) && directives(parent).indexOf(node) >= 0;
  82931. }
  82932. /**
  82933. * Determines whether or not a given node is a valid expression. Recurses on short circuit eval and ternary nodes if enabled by flags.
  82934. * @param {ASTNode} node - any node
  82935. * @returns {boolean} whether the given node is a valid expression
  82936. */
  82937. function isValidExpression(node) {
  82938. if (allowTernary) {
  82939. // Recursive check for ternary and logical expressions
  82940. if (node.type === "ConditionalExpression") {
  82941. return isValidExpression(node.consequent) && isValidExpression(node.alternate);
  82942. }
  82943. }
  82944. if (allowShortCircuit) {
  82945. if (node.type === "LogicalExpression") {
  82946. return isValidExpression(node.right);
  82947. }
  82948. }
  82949. if (allowTaggedTemplates && node.type === "TaggedTemplateExpression") {
  82950. return true;
  82951. }
  82952. return (/^(?:Assignment|Call|New|Update|Yield|Await)Expression$/.test(node.type) || node.type === "UnaryExpression" && ["delete", "void"].indexOf(node.operator) >= 0
  82953. );
  82954. }
  82955. return {
  82956. ExpressionStatement: function ExpressionStatement(node) {
  82957. if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) {
  82958. context.report({ node: node, message: "Expected an assignment or function call and instead saw an expression." });
  82959. }
  82960. }
  82961. };
  82962. }
  82963. };
  82964. },{}],318:[function(require,module,exports){
  82965. /**
  82966. * @fileoverview Rule to disallow unused labels.
  82967. * @author Toru Nagashima
  82968. */
  82969. "use strict";
  82970. //------------------------------------------------------------------------------
  82971. // Rule Definition
  82972. //------------------------------------------------------------------------------
  82973. module.exports = {
  82974. meta: {
  82975. type: "suggestion",
  82976. docs: {
  82977. description: "disallow unused labels",
  82978. category: "Best Practices",
  82979. recommended: true,
  82980. url: "https://eslint.org/docs/rules/no-unused-labels"
  82981. },
  82982. schema: [],
  82983. fixable: "code"
  82984. },
  82985. create: function create(context) {
  82986. var sourceCode = context.getSourceCode();
  82987. var scopeInfo = null;
  82988. /**
  82989. * Adds a scope info to the stack.
  82990. *
  82991. * @param {ASTNode} node - A node to add. This is a LabeledStatement.
  82992. * @returns {void}
  82993. */
  82994. function enterLabeledScope(node) {
  82995. scopeInfo = {
  82996. label: node.label.name,
  82997. used: false,
  82998. upper: scopeInfo
  82999. };
  83000. }
  83001. /**
  83002. * Removes the top of the stack.
  83003. * At the same time, this reports the label if it's never used.
  83004. *
  83005. * @param {ASTNode} node - A node to report. This is a LabeledStatement.
  83006. * @returns {void}
  83007. */
  83008. function exitLabeledScope(node) {
  83009. if (!scopeInfo.used) {
  83010. context.report({
  83011. node: node.label,
  83012. message: "'{{name}}:' is defined but never used.",
  83013. data: node.label,
  83014. fix: function fix(fixer) {
  83015. /*
  83016. * Only perform a fix if there are no comments between the label and the body. This will be the case
  83017. * when there is exactly one token/comment (the ":") between the label and the body.
  83018. */
  83019. if (sourceCode.getTokenAfter(node.label, { includeComments: true }) === sourceCode.getTokenBefore(node.body, { includeComments: true })) {
  83020. return fixer.removeRange([node.range[0], node.body.range[0]]);
  83021. }
  83022. return null;
  83023. }
  83024. });
  83025. }
  83026. scopeInfo = scopeInfo.upper;
  83027. }
  83028. /**
  83029. * Marks the label of a given node as used.
  83030. *
  83031. * @param {ASTNode} node - A node to mark. This is a BreakStatement or
  83032. * ContinueStatement.
  83033. * @returns {void}
  83034. */
  83035. function markAsUsed(node) {
  83036. if (!node.label) {
  83037. return;
  83038. }
  83039. var label = node.label.name;
  83040. var info = scopeInfo;
  83041. while (info) {
  83042. if (info.label === label) {
  83043. info.used = true;
  83044. break;
  83045. }
  83046. info = info.upper;
  83047. }
  83048. }
  83049. return {
  83050. LabeledStatement: enterLabeledScope,
  83051. "LabeledStatement:exit": exitLabeledScope,
  83052. BreakStatement: markAsUsed,
  83053. ContinueStatement: markAsUsed
  83054. };
  83055. }
  83056. };
  83057. },{}],319:[function(require,module,exports){
  83058. /**
  83059. * @fileoverview Rule to flag declared but unused variables
  83060. * @author Ilya Volodin
  83061. */
  83062. "use strict";
  83063. //------------------------------------------------------------------------------
  83064. // Requirements
  83065. //------------------------------------------------------------------------------
  83066. var lodash = require("lodash");
  83067. var astUtils = require("../util/ast-utils");
  83068. //------------------------------------------------------------------------------
  83069. // Rule Definition
  83070. //------------------------------------------------------------------------------
  83071. module.exports = {
  83072. meta: {
  83073. type: "problem",
  83074. docs: {
  83075. description: "disallow unused variables",
  83076. category: "Variables",
  83077. recommended: true,
  83078. url: "https://eslint.org/docs/rules/no-unused-vars"
  83079. },
  83080. schema: [{
  83081. oneOf: [{
  83082. enum: ["all", "local"]
  83083. }, {
  83084. type: "object",
  83085. properties: {
  83086. vars: {
  83087. enum: ["all", "local"]
  83088. },
  83089. varsIgnorePattern: {
  83090. type: "string"
  83091. },
  83092. args: {
  83093. enum: ["all", "after-used", "none"]
  83094. },
  83095. ignoreRestSiblings: {
  83096. type: "boolean"
  83097. },
  83098. argsIgnorePattern: {
  83099. type: "string"
  83100. },
  83101. caughtErrors: {
  83102. enum: ["all", "none"]
  83103. },
  83104. caughtErrorsIgnorePattern: {
  83105. type: "string"
  83106. }
  83107. }
  83108. }]
  83109. }]
  83110. },
  83111. create: function create(context) {
  83112. var sourceCode = context.getSourceCode();
  83113. var REST_PROPERTY_TYPE = /^(?:RestElement|(?:Experimental)?RestProperty)$/;
  83114. var config = {
  83115. vars: "all",
  83116. args: "after-used",
  83117. ignoreRestSiblings: false,
  83118. caughtErrors: "none"
  83119. };
  83120. var firstOption = context.options[0];
  83121. if (firstOption) {
  83122. if (typeof firstOption === "string") {
  83123. config.vars = firstOption;
  83124. } else {
  83125. config.vars = firstOption.vars || config.vars;
  83126. config.args = firstOption.args || config.args;
  83127. config.ignoreRestSiblings = firstOption.ignoreRestSiblings || config.ignoreRestSiblings;
  83128. config.caughtErrors = firstOption.caughtErrors || config.caughtErrors;
  83129. if (firstOption.varsIgnorePattern) {
  83130. config.varsIgnorePattern = new RegExp(firstOption.varsIgnorePattern);
  83131. }
  83132. if (firstOption.argsIgnorePattern) {
  83133. config.argsIgnorePattern = new RegExp(firstOption.argsIgnorePattern);
  83134. }
  83135. if (firstOption.caughtErrorsIgnorePattern) {
  83136. config.caughtErrorsIgnorePattern = new RegExp(firstOption.caughtErrorsIgnorePattern);
  83137. }
  83138. }
  83139. }
  83140. /**
  83141. * Generate the warning message about the variable being
  83142. * defined and unused, including the ignore pattern if configured.
  83143. * @param {Variable} unusedVar - eslint-scope variable object.
  83144. * @returns {string} The warning message to be used with this unused variable.
  83145. */
  83146. function getDefinedMessage(unusedVar) {
  83147. var defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type;
  83148. var type = void 0;
  83149. var pattern = void 0;
  83150. if (defType === "CatchClause" && config.caughtErrorsIgnorePattern) {
  83151. type = "args";
  83152. pattern = config.caughtErrorsIgnorePattern.toString();
  83153. } else if (defType === "Parameter" && config.argsIgnorePattern) {
  83154. type = "args";
  83155. pattern = config.argsIgnorePattern.toString();
  83156. } else if (defType !== "Parameter" && config.varsIgnorePattern) {
  83157. type = "vars";
  83158. pattern = config.varsIgnorePattern.toString();
  83159. }
  83160. var additional = type ? " Allowed unused " + type + " must match " + pattern + "." : "";
  83161. return "'{{name}}' is defined but never used." + additional;
  83162. }
  83163. /**
  83164. * Generate the warning message about the variable being
  83165. * assigned and unused, including the ignore pattern if configured.
  83166. * @returns {string} The warning message to be used with this unused variable.
  83167. */
  83168. function getAssignedMessage() {
  83169. var additional = config.varsIgnorePattern ? " Allowed unused vars must match " + config.varsIgnorePattern.toString() + "." : "";
  83170. return "'{{name}}' is assigned a value but never used." + additional;
  83171. }
  83172. //--------------------------------------------------------------------------
  83173. // Helpers
  83174. //--------------------------------------------------------------------------
  83175. var STATEMENT_TYPE = /(?:Statement|Declaration)$/;
  83176. /**
  83177. * Determines if a given variable is being exported from a module.
  83178. * @param {Variable} variable - eslint-scope variable object.
  83179. * @returns {boolean} True if the variable is exported, false if not.
  83180. * @private
  83181. */
  83182. function isExported(variable) {
  83183. var definition = variable.defs[0];
  83184. if (definition) {
  83185. var node = definition.node;
  83186. if (node.type === "VariableDeclarator") {
  83187. node = node.parent;
  83188. } else if (definition.type === "Parameter") {
  83189. return false;
  83190. }
  83191. return node.parent.type.indexOf("Export") === 0;
  83192. }
  83193. return false;
  83194. }
  83195. /**
  83196. * Determines if a variable has a sibling rest property
  83197. * @param {Variable} variable - eslint-scope variable object.
  83198. * @returns {boolean} True if the variable is exported, false if not.
  83199. * @private
  83200. */
  83201. function hasRestSpreadSibling(variable) {
  83202. if (config.ignoreRestSiblings) {
  83203. return variable.defs.some(function (def) {
  83204. var propertyNode = def.name.parent;
  83205. var patternNode = propertyNode.parent;
  83206. return propertyNode.type === "Property" && patternNode.type === "ObjectPattern" && REST_PROPERTY_TYPE.test(patternNode.properties[patternNode.properties.length - 1].type);
  83207. });
  83208. }
  83209. return false;
  83210. }
  83211. /**
  83212. * Determines if a reference is a read operation.
  83213. * @param {Reference} ref - An eslint-scope Reference
  83214. * @returns {boolean} whether the given reference represents a read operation
  83215. * @private
  83216. */
  83217. function isReadRef(ref) {
  83218. return ref.isRead();
  83219. }
  83220. /**
  83221. * Determine if an identifier is referencing an enclosing function name.
  83222. * @param {Reference} ref - The reference to check.
  83223. * @param {ASTNode[]} nodes - The candidate function nodes.
  83224. * @returns {boolean} True if it's a self-reference, false if not.
  83225. * @private
  83226. */
  83227. function isSelfReference(ref, nodes) {
  83228. var scope = ref.from;
  83229. while (scope) {
  83230. if (nodes.indexOf(scope.block) >= 0) {
  83231. return true;
  83232. }
  83233. scope = scope.upper;
  83234. }
  83235. return false;
  83236. }
  83237. /**
  83238. * Gets a list of function definitions for a specified variable.
  83239. * @param {Variable} variable - eslint-scope variable object.
  83240. * @returns {ASTNode[]} Function nodes.
  83241. * @private
  83242. */
  83243. function getFunctionDefinitions(variable) {
  83244. var functionDefinitions = [];
  83245. variable.defs.forEach(function (def) {
  83246. var type = def.type,
  83247. node = def.node;
  83248. // FunctionDeclarations
  83249. if (type === "FunctionName") {
  83250. functionDefinitions.push(node);
  83251. }
  83252. // FunctionExpressions
  83253. if (type === "Variable" && node.init && (node.init.type === "FunctionExpression" || node.init.type === "ArrowFunctionExpression")) {
  83254. functionDefinitions.push(node.init);
  83255. }
  83256. });
  83257. return functionDefinitions;
  83258. }
  83259. /**
  83260. * Checks the position of given nodes.
  83261. *
  83262. * @param {ASTNode} inner - A node which is expected as inside.
  83263. * @param {ASTNode} outer - A node which is expected as outside.
  83264. * @returns {boolean} `true` if the `inner` node exists in the `outer` node.
  83265. * @private
  83266. */
  83267. function isInside(inner, outer) {
  83268. return inner.range[0] >= outer.range[0] && inner.range[1] <= outer.range[1];
  83269. }
  83270. /**
  83271. * If a given reference is left-hand side of an assignment, this gets
  83272. * the right-hand side node of the assignment.
  83273. *
  83274. * In the following cases, this returns null.
  83275. *
  83276. * - The reference is not the LHS of an assignment expression.
  83277. * - The reference is inside of a loop.
  83278. * - The reference is inside of a function scope which is different from
  83279. * the declaration.
  83280. *
  83281. * @param {eslint-scope.Reference} ref - A reference to check.
  83282. * @param {ASTNode} prevRhsNode - The previous RHS node.
  83283. * @returns {ASTNode|null} The RHS node or null.
  83284. * @private
  83285. */
  83286. function getRhsNode(ref, prevRhsNode) {
  83287. var id = ref.identifier;
  83288. var parent = id.parent;
  83289. var granpa = parent.parent;
  83290. var refScope = ref.from.variableScope;
  83291. var varScope = ref.resolved.scope.variableScope;
  83292. var canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id);
  83293. /*
  83294. * Inherits the previous node if this reference is in the node.
  83295. * This is for `a = a + a`-like code.
  83296. */
  83297. if (prevRhsNode && isInside(id, prevRhsNode)) {
  83298. return prevRhsNode;
  83299. }
  83300. if (parent.type === "AssignmentExpression" && granpa.type === "ExpressionStatement" && id === parent.left && !canBeUsedLater) {
  83301. return parent.right;
  83302. }
  83303. return null;
  83304. }
  83305. /**
  83306. * Checks whether a given function node is stored to somewhere or not.
  83307. * If the function node is stored, the function can be used later.
  83308. *
  83309. * @param {ASTNode} funcNode - A function node to check.
  83310. * @param {ASTNode} rhsNode - The RHS node of the previous assignment.
  83311. * @returns {boolean} `true` if under the following conditions:
  83312. * - the funcNode is assigned to a variable.
  83313. * - the funcNode is bound as an argument of a function call.
  83314. * - the function is bound to a property and the object satisfies above conditions.
  83315. * @private
  83316. */
  83317. function isStorableFunction(funcNode, rhsNode) {
  83318. var node = funcNode;
  83319. var parent = funcNode.parent;
  83320. while (parent && isInside(parent, rhsNode)) {
  83321. switch (parent.type) {
  83322. case "SequenceExpression":
  83323. if (parent.expressions[parent.expressions.length - 1] !== node) {
  83324. return false;
  83325. }
  83326. break;
  83327. case "CallExpression":
  83328. case "NewExpression":
  83329. return parent.callee !== node;
  83330. case "AssignmentExpression":
  83331. case "TaggedTemplateExpression":
  83332. case "YieldExpression":
  83333. return true;
  83334. default:
  83335. if (STATEMENT_TYPE.test(parent.type)) {
  83336. /*
  83337. * If it encountered statements, this is a complex pattern.
  83338. * Since analyzeing complex patterns is hard, this returns `true` to avoid false positive.
  83339. */
  83340. return true;
  83341. }
  83342. }
  83343. node = parent;
  83344. parent = parent.parent;
  83345. }
  83346. return false;
  83347. }
  83348. /**
  83349. * Checks whether a given Identifier node exists inside of a function node which can be used later.
  83350. *
  83351. * "can be used later" means:
  83352. * - the function is assigned to a variable.
  83353. * - the function is bound to a property and the object can be used later.
  83354. * - the function is bound as an argument of a function call.
  83355. *
  83356. * If a reference exists in a function which can be used later, the reference is read when the function is called.
  83357. *
  83358. * @param {ASTNode} id - An Identifier node to check.
  83359. * @param {ASTNode} rhsNode - The RHS node of the previous assignment.
  83360. * @returns {boolean} `true` if the `id` node exists inside of a function node which can be used later.
  83361. * @private
  83362. */
  83363. function isInsideOfStorableFunction(id, rhsNode) {
  83364. var funcNode = astUtils.getUpperFunction(id);
  83365. return funcNode && isInside(funcNode, rhsNode) && isStorableFunction(funcNode, rhsNode);
  83366. }
  83367. /**
  83368. * Checks whether a given reference is a read to update itself or not.
  83369. *
  83370. * @param {eslint-scope.Reference} ref - A reference to check.
  83371. * @param {ASTNode} rhsNode - The RHS node of the previous assignment.
  83372. * @returns {boolean} The reference is a read to update itself.
  83373. * @private
  83374. */
  83375. function isReadForItself(ref, rhsNode) {
  83376. var id = ref.identifier;
  83377. var parent = id.parent;
  83378. var granpa = parent.parent;
  83379. return ref.isRead() && (
  83380. // self update. e.g. `a += 1`, `a++`
  83381. // in RHS of an assignment for itself. e.g. `a = a + 1`
  83382. parent.type === "AssignmentExpression" && granpa.type === "ExpressionStatement" && parent.left === id || parent.type === "UpdateExpression" && granpa.type === "ExpressionStatement" || rhsNode && isInside(id, rhsNode) && !isInsideOfStorableFunction(id, rhsNode));
  83383. }
  83384. /**
  83385. * Determine if an identifier is used either in for-in loops.
  83386. *
  83387. * @param {Reference} ref - The reference to check.
  83388. * @returns {boolean} whether reference is used in the for-in loops
  83389. * @private
  83390. */
  83391. function isForInRef(ref) {
  83392. var target = ref.identifier.parent;
  83393. // "for (var ...) { return; }"
  83394. if (target.type === "VariableDeclarator") {
  83395. target = target.parent.parent;
  83396. }
  83397. if (target.type !== "ForInStatement") {
  83398. return false;
  83399. }
  83400. // "for (...) { return; }"
  83401. if (target.body.type === "BlockStatement") {
  83402. target = target.body.body[0];
  83403. // "for (...) return;"
  83404. } else {
  83405. target = target.body;
  83406. }
  83407. // For empty loop body
  83408. if (!target) {
  83409. return false;
  83410. }
  83411. return target.type === "ReturnStatement";
  83412. }
  83413. /**
  83414. * Determines if the variable is used.
  83415. * @param {Variable} variable - The variable to check.
  83416. * @returns {boolean} True if the variable is used
  83417. * @private
  83418. */
  83419. function isUsedVariable(variable) {
  83420. var functionNodes = getFunctionDefinitions(variable),
  83421. isFunctionDefinition = functionNodes.length > 0;
  83422. var rhsNode = null;
  83423. return variable.references.some(function (ref) {
  83424. if (isForInRef(ref)) {
  83425. return true;
  83426. }
  83427. var forItself = isReadForItself(ref, rhsNode);
  83428. rhsNode = getRhsNode(ref, rhsNode);
  83429. return isReadRef(ref) && !forItself && !(isFunctionDefinition && isSelfReference(ref, functionNodes));
  83430. });
  83431. }
  83432. /**
  83433. * Checks whether the given variable is after the last used parameter.
  83434. *
  83435. * @param {eslint-scope.Variable} variable - The variable to check.
  83436. * @returns {boolean} `true` if the variable is defined after the last
  83437. * used parameter.
  83438. */
  83439. function isAfterLastUsedArg(variable) {
  83440. var def = variable.defs[0];
  83441. var params = context.getDeclaredVariables(def.node);
  83442. var posteriorParams = params.slice(params.indexOf(variable) + 1);
  83443. // If any used parameters occur after this parameter, do not report.
  83444. return !posteriorParams.some(function (v) {
  83445. return v.references.length > 0 || v.eslintUsed;
  83446. });
  83447. }
  83448. /**
  83449. * Gets an array of variables without read references.
  83450. * @param {Scope} scope - an eslint-scope Scope object.
  83451. * @param {Variable[]} unusedVars - an array that saving result.
  83452. * @returns {Variable[]} unused variables of the scope and descendant scopes.
  83453. * @private
  83454. */
  83455. function collectUnusedVariables(scope, unusedVars) {
  83456. var variables = scope.variables;
  83457. var childScopes = scope.childScopes;
  83458. var i = void 0,
  83459. l = void 0;
  83460. if (scope.type !== "TDZ" && (scope.type !== "global" || config.vars === "all")) {
  83461. for (i = 0, l = variables.length; i < l; ++i) {
  83462. var variable = variables[i];
  83463. // skip a variable of class itself name in the class scope
  83464. if (scope.type === "class" && scope.block.id === variable.identifiers[0]) {
  83465. continue;
  83466. }
  83467. // skip function expression names and variables marked with markVariableAsUsed()
  83468. if (scope.functionExpressionScope || variable.eslintUsed) {
  83469. continue;
  83470. }
  83471. // skip implicit "arguments" variable
  83472. if (scope.type === "function" && variable.name === "arguments" && variable.identifiers.length === 0) {
  83473. continue;
  83474. }
  83475. // explicit global variables don't have definitions.
  83476. var def = variable.defs[0];
  83477. if (def) {
  83478. var type = def.type;
  83479. // skip catch variables
  83480. if (type === "CatchClause") {
  83481. if (config.caughtErrors === "none") {
  83482. continue;
  83483. }
  83484. // skip ignored parameters
  83485. if (config.caughtErrorsIgnorePattern && config.caughtErrorsIgnorePattern.test(def.name.name)) {
  83486. continue;
  83487. }
  83488. }
  83489. if (type === "Parameter") {
  83490. // skip any setter argument
  83491. if ((def.node.parent.type === "Property" || def.node.parent.type === "MethodDefinition") && def.node.parent.kind === "set") {
  83492. continue;
  83493. }
  83494. // if "args" option is "none", skip any parameter
  83495. if (config.args === "none") {
  83496. continue;
  83497. }
  83498. // skip ignored parameters
  83499. if (config.argsIgnorePattern && config.argsIgnorePattern.test(def.name.name)) {
  83500. continue;
  83501. }
  83502. // if "args" option is "after-used", skip used variables
  83503. if (config.args === "after-used" && astUtils.isFunction(def.name.parent) && !isAfterLastUsedArg(variable)) {
  83504. continue;
  83505. }
  83506. } else {
  83507. // skip ignored variables
  83508. if (config.varsIgnorePattern && config.varsIgnorePattern.test(def.name.name)) {
  83509. continue;
  83510. }
  83511. }
  83512. }
  83513. if (!isUsedVariable(variable) && !isExported(variable) && !hasRestSpreadSibling(variable)) {
  83514. unusedVars.push(variable);
  83515. }
  83516. }
  83517. }
  83518. for (i = 0, l = childScopes.length; i < l; ++i) {
  83519. collectUnusedVariables(childScopes[i], unusedVars);
  83520. }
  83521. return unusedVars;
  83522. }
  83523. /**
  83524. * Gets the index of a given variable name in a given comment.
  83525. * @param {eslint-scope.Variable} variable - A variable to get.
  83526. * @param {ASTNode} comment - A comment node which includes the variable name.
  83527. * @returns {number} The index of the variable name's location.
  83528. * @private
  83529. */
  83530. function getColumnInComment(variable, comment) {
  83531. var namePattern = new RegExp("[\\s,]" + lodash.escapeRegExp(variable.name) + "(?:$|[\\s,:])", "g");
  83532. // To ignore the first text "global".
  83533. namePattern.lastIndex = comment.value.indexOf("global") + 6;
  83534. // Search a given variable name.
  83535. var match = namePattern.exec(comment.value);
  83536. return match ? match.index + 1 : 0;
  83537. }
  83538. /**
  83539. * Creates the correct location of a given variables.
  83540. * The location is at its name string in a `/*global` comment.
  83541. *
  83542. * @param {eslint-scope.Variable} variable - A variable to get its location.
  83543. * @returns {{line: number, column: number}} The location object for the variable.
  83544. * @private
  83545. */
  83546. function getLocation(variable) {
  83547. var comment = variable.eslintExplicitGlobalComment;
  83548. return sourceCode.getLocFromIndex(comment.range[0] + 2 + getColumnInComment(variable, comment));
  83549. }
  83550. //--------------------------------------------------------------------------
  83551. // Public
  83552. //--------------------------------------------------------------------------
  83553. return {
  83554. "Program:exit": function ProgramExit(programNode) {
  83555. var unusedVars = collectUnusedVariables(context.getScope(), []);
  83556. for (var i = 0, l = unusedVars.length; i < l; ++i) {
  83557. var unusedVar = unusedVars[i];
  83558. if (unusedVar.eslintExplicitGlobal) {
  83559. context.report({
  83560. node: programNode,
  83561. loc: getLocation(unusedVar),
  83562. message: getDefinedMessage(unusedVar),
  83563. data: unusedVar
  83564. });
  83565. } else if (unusedVar.defs.length > 0) {
  83566. context.report({
  83567. node: unusedVar.identifiers[0],
  83568. message: unusedVar.references.some(function (ref) {
  83569. return ref.isWrite();
  83570. }) ? getAssignedMessage() : getDefinedMessage(unusedVar),
  83571. data: unusedVar
  83572. });
  83573. }
  83574. }
  83575. }
  83576. };
  83577. }
  83578. };
  83579. },{"../util/ast-utils":405,"lodash":92}],320:[function(require,module,exports){
  83580. /**
  83581. * @fileoverview Rule to flag use of variables before they are defined
  83582. * @author Ilya Volodin
  83583. */
  83584. "use strict";
  83585. //------------------------------------------------------------------------------
  83586. // Helpers
  83587. //------------------------------------------------------------------------------
  83588. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  83589. var SENTINEL_TYPE = /^(?:(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|CatchClause|ImportDeclaration|ExportNamedDeclaration)$/;
  83590. var FOR_IN_OF_TYPE = /^For(?:In|Of)Statement$/;
  83591. /**
  83592. * Parses a given value as options.
  83593. *
  83594. * @param {any} options - A value to parse.
  83595. * @returns {Object} The parsed options.
  83596. */
  83597. function parseOptions(options) {
  83598. var functions = true;
  83599. var classes = true;
  83600. var variables = true;
  83601. if (typeof options === "string") {
  83602. functions = options !== "nofunc";
  83603. } else if ((typeof options === "undefined" ? "undefined" : _typeof(options)) === "object" && options !== null) {
  83604. functions = options.functions !== false;
  83605. classes = options.classes !== false;
  83606. variables = options.variables !== false;
  83607. }
  83608. return { functions: functions, classes: classes, variables: variables };
  83609. }
  83610. /**
  83611. * Checks whether or not a given variable is a function declaration.
  83612. *
  83613. * @param {eslint-scope.Variable} variable - A variable to check.
  83614. * @returns {boolean} `true` if the variable is a function declaration.
  83615. */
  83616. function isFunction(variable) {
  83617. return variable.defs[0].type === "FunctionName";
  83618. }
  83619. /**
  83620. * Checks whether or not a given variable is a class declaration in an upper function scope.
  83621. *
  83622. * @param {eslint-scope.Variable} variable - A variable to check.
  83623. * @param {eslint-scope.Reference} reference - A reference to check.
  83624. * @returns {boolean} `true` if the variable is a class declaration.
  83625. */
  83626. function isOuterClass(variable, reference) {
  83627. return variable.defs[0].type === "ClassName" && variable.scope.variableScope !== reference.from.variableScope;
  83628. }
  83629. /**
  83630. * Checks whether or not a given variable is a variable declaration in an upper function scope.
  83631. * @param {eslint-scope.Variable} variable - A variable to check.
  83632. * @param {eslint-scope.Reference} reference - A reference to check.
  83633. * @returns {boolean} `true` if the variable is a variable declaration.
  83634. */
  83635. function isOuterVariable(variable, reference) {
  83636. return variable.defs[0].type === "Variable" && variable.scope.variableScope !== reference.from.variableScope;
  83637. }
  83638. /**
  83639. * Checks whether or not a given location is inside of the range of a given node.
  83640. *
  83641. * @param {ASTNode} node - An node to check.
  83642. * @param {number} location - A location to check.
  83643. * @returns {boolean} `true` if the location is inside of the range of the node.
  83644. */
  83645. function isInRange(node, location) {
  83646. return node && node.range[0] <= location && location <= node.range[1];
  83647. }
  83648. /**
  83649. * Checks whether or not a given reference is inside of the initializers of a given variable.
  83650. *
  83651. * This returns `true` in the following cases:
  83652. *
  83653. * var a = a
  83654. * var [a = a] = list
  83655. * var {a = a} = obj
  83656. * for (var a in a) {}
  83657. * for (var a of a) {}
  83658. *
  83659. * @param {Variable} variable - A variable to check.
  83660. * @param {Reference} reference - A reference to check.
  83661. * @returns {boolean} `true` if the reference is inside of the initializers.
  83662. */
  83663. function isInInitializer(variable, reference) {
  83664. if (variable.scope !== reference.from) {
  83665. return false;
  83666. }
  83667. var node = variable.identifiers[0].parent;
  83668. var location = reference.identifier.range[1];
  83669. while (node) {
  83670. if (node.type === "VariableDeclarator") {
  83671. if (isInRange(node.init, location)) {
  83672. return true;
  83673. }
  83674. if (FOR_IN_OF_TYPE.test(node.parent.parent.type) && isInRange(node.parent.parent.right, location)) {
  83675. return true;
  83676. }
  83677. break;
  83678. } else if (node.type === "AssignmentPattern") {
  83679. if (isInRange(node.right, location)) {
  83680. return true;
  83681. }
  83682. } else if (SENTINEL_TYPE.test(node.type)) {
  83683. break;
  83684. }
  83685. node = node.parent;
  83686. }
  83687. return false;
  83688. }
  83689. //------------------------------------------------------------------------------
  83690. // Rule Definition
  83691. //------------------------------------------------------------------------------
  83692. module.exports = {
  83693. meta: {
  83694. type: "problem",
  83695. docs: {
  83696. description: "disallow the use of variables before they are defined",
  83697. category: "Variables",
  83698. recommended: false,
  83699. url: "https://eslint.org/docs/rules/no-use-before-define"
  83700. },
  83701. schema: [{
  83702. oneOf: [{
  83703. enum: ["nofunc"]
  83704. }, {
  83705. type: "object",
  83706. properties: {
  83707. functions: { type: "boolean" },
  83708. classes: { type: "boolean" },
  83709. variables: { type: "boolean" }
  83710. },
  83711. additionalProperties: false
  83712. }]
  83713. }]
  83714. },
  83715. create: function create(context) {
  83716. var options = parseOptions(context.options[0]);
  83717. /**
  83718. * Determines whether a given use-before-define case should be reported according to the options.
  83719. * @param {eslint-scope.Variable} variable The variable that gets used before being defined
  83720. * @param {eslint-scope.Reference} reference The reference to the variable
  83721. * @returns {boolean} `true` if the usage should be reported
  83722. */
  83723. function isForbidden(variable, reference) {
  83724. if (isFunction(variable)) {
  83725. return options.functions;
  83726. }
  83727. if (isOuterClass(variable, reference)) {
  83728. return options.classes;
  83729. }
  83730. if (isOuterVariable(variable, reference)) {
  83731. return options.variables;
  83732. }
  83733. return true;
  83734. }
  83735. /**
  83736. * Finds and validates all variables in a given scope.
  83737. * @param {Scope} scope The scope object.
  83738. * @returns {void}
  83739. * @private
  83740. */
  83741. function findVariablesInScope(scope) {
  83742. scope.references.forEach(function (reference) {
  83743. var variable = reference.resolved;
  83744. /*
  83745. * Skips when the reference is:
  83746. * - initialization's.
  83747. * - referring to an undefined variable.
  83748. * - referring to a global environment variable (there're no identifiers).
  83749. * - located preceded by the variable (except in initializers).
  83750. * - allowed by options.
  83751. */
  83752. if (reference.init || !variable || variable.identifiers.length === 0 || variable.identifiers[0].range[1] < reference.identifier.range[1] && !isInInitializer(variable, reference) || !isForbidden(variable, reference)) {
  83753. return;
  83754. }
  83755. // Reports.
  83756. context.report({
  83757. node: reference.identifier,
  83758. message: "'{{name}}' was used before it was defined.",
  83759. data: reference.identifier
  83760. });
  83761. });
  83762. scope.childScopes.forEach(findVariablesInScope);
  83763. }
  83764. return {
  83765. Program: function Program() {
  83766. findVariablesInScope(context.getScope());
  83767. }
  83768. };
  83769. }
  83770. };
  83771. },{}],321:[function(require,module,exports){
  83772. /**
  83773. * @fileoverview A rule to disallow unnecessary `.call()` and `.apply()`.
  83774. * @author Toru Nagashima
  83775. */
  83776. "use strict";
  83777. var astUtils = require("../util/ast-utils");
  83778. //------------------------------------------------------------------------------
  83779. // Helpers
  83780. //------------------------------------------------------------------------------
  83781. /**
  83782. * Checks whether or not a node is a `.call()`/`.apply()`.
  83783. * @param {ASTNode} node - A CallExpression node to check.
  83784. * @returns {boolean} Whether or not the node is a `.call()`/`.apply()`.
  83785. */
  83786. function isCallOrNonVariadicApply(node) {
  83787. return node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && node.callee.computed === false && (node.callee.property.name === "call" && node.arguments.length >= 1 || node.callee.property.name === "apply" && node.arguments.length === 2 && node.arguments[1].type === "ArrayExpression");
  83788. }
  83789. /**
  83790. * Checks whether or not `thisArg` is not changed by `.call()`/`.apply()`.
  83791. * @param {ASTNode|null} expectedThis - The node that is the owner of the applied function.
  83792. * @param {ASTNode} thisArg - The node that is given to the first argument of the `.call()`/`.apply()`.
  83793. * @param {SourceCode} sourceCode - The ESLint source code object.
  83794. * @returns {boolean} Whether or not `thisArg` is not changed by `.call()`/`.apply()`.
  83795. */
  83796. function isValidThisArg(expectedThis, thisArg, sourceCode) {
  83797. if (!expectedThis) {
  83798. return astUtils.isNullOrUndefined(thisArg);
  83799. }
  83800. return astUtils.equalTokens(expectedThis, thisArg, sourceCode);
  83801. }
  83802. //------------------------------------------------------------------------------
  83803. // Rule Definition
  83804. //------------------------------------------------------------------------------
  83805. module.exports = {
  83806. meta: {
  83807. type: "suggestion",
  83808. docs: {
  83809. description: "disallow unnecessary calls to `.call()` and `.apply()`",
  83810. category: "Best Practices",
  83811. recommended: false,
  83812. url: "https://eslint.org/docs/rules/no-useless-call"
  83813. },
  83814. schema: []
  83815. },
  83816. create: function create(context) {
  83817. var sourceCode = context.getSourceCode();
  83818. return {
  83819. CallExpression: function CallExpression(node) {
  83820. if (!isCallOrNonVariadicApply(node)) {
  83821. return;
  83822. }
  83823. var applied = node.callee.object;
  83824. var expectedThis = applied.type === "MemberExpression" ? applied.object : null;
  83825. var thisArg = node.arguments[0];
  83826. if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
  83827. context.report({ node: node, message: "unnecessary '.{{name}}()'.", data: { name: node.callee.property.name } });
  83828. }
  83829. }
  83830. };
  83831. }
  83832. };
  83833. },{"../util/ast-utils":405}],322:[function(require,module,exports){
  83834. /**
  83835. * @fileoverview Reports useless `catch` clauses that just rethrow their error.
  83836. * @author Teddy Katz
  83837. */
  83838. "use strict";
  83839. //------------------------------------------------------------------------------
  83840. // Rule Definition
  83841. //------------------------------------------------------------------------------
  83842. module.exports = {
  83843. meta: {
  83844. type: "suggestion",
  83845. docs: {
  83846. description: "disallow unnecessary `catch` clauses",
  83847. category: "Best Practices",
  83848. recommended: false,
  83849. url: "https://eslint.org/docs/rules/no-useless-catch"
  83850. },
  83851. schema: []
  83852. },
  83853. create: function create(context) {
  83854. return {
  83855. CatchClause: function CatchClause(node) {
  83856. if (node.param && node.param.type === "Identifier" && node.body.body.length && node.body.body[0].type === "ThrowStatement" && node.body.body[0].argument.type === "Identifier" && node.body.body[0].argument.name === node.param.name) {
  83857. if (node.parent.finalizer) {
  83858. context.report({
  83859. node: node,
  83860. message: "Unnecessary catch clause."
  83861. });
  83862. } else {
  83863. context.report({
  83864. node: node.parent,
  83865. message: "Unnecessary try/catch wrapper."
  83866. });
  83867. }
  83868. }
  83869. }
  83870. };
  83871. }
  83872. };
  83873. },{}],323:[function(require,module,exports){
  83874. /**
  83875. * @fileoverview Rule to disallow unnecessary computed property keys in object literals
  83876. * @author Burak Yigit Kaya
  83877. */
  83878. "use strict";
  83879. //------------------------------------------------------------------------------
  83880. // Requirements
  83881. //------------------------------------------------------------------------------
  83882. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  83883. var astUtils = require("../util/ast-utils");
  83884. //------------------------------------------------------------------------------
  83885. // Rule Definition
  83886. //------------------------------------------------------------------------------
  83887. var MESSAGE_UNNECESSARY_COMPUTED = "Unnecessarily computed property [{{property}}] found.";
  83888. module.exports = {
  83889. meta: {
  83890. type: "suggestion",
  83891. docs: {
  83892. description: "disallow unnecessary computed property keys in object literals",
  83893. category: "ECMAScript 6",
  83894. recommended: false,
  83895. url: "https://eslint.org/docs/rules/no-useless-computed-key"
  83896. },
  83897. schema: [],
  83898. fixable: "code"
  83899. },
  83900. create: function create(context) {
  83901. var sourceCode = context.getSourceCode();
  83902. return {
  83903. Property: function Property(node) {
  83904. if (!node.computed) {
  83905. return;
  83906. }
  83907. var key = node.key,
  83908. nodeType = _typeof(key.value);
  83909. if (key.type === "Literal" && (nodeType === "string" || nodeType === "number") && key.value !== "__proto__") {
  83910. context.report({
  83911. node: node,
  83912. message: MESSAGE_UNNECESSARY_COMPUTED,
  83913. data: { property: sourceCode.getText(key) },
  83914. fix: function fix(fixer) {
  83915. var leftSquareBracket = sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken);
  83916. var rightSquareBracket = sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken);
  83917. var tokensBetween = sourceCode.getTokensBetween(leftSquareBracket, rightSquareBracket, 1);
  83918. if (tokensBetween.slice(0, -1).some(function (token, index) {
  83919. return sourceCode.getText().slice(token.range[1], tokensBetween[index + 1].range[0]).trim();
  83920. })) {
  83921. // If there are comments between the brackets and the property name, don't do a fix.
  83922. return null;
  83923. }
  83924. var tokenBeforeLeftBracket = sourceCode.getTokenBefore(leftSquareBracket);
  83925. // Insert a space before the key to avoid changing identifiers, e.g. ({ get[2]() {} }) to ({ get2() {} })
  83926. var needsSpaceBeforeKey = tokenBeforeLeftBracket.range[1] === leftSquareBracket.range[0] && !astUtils.canTokensBeAdjacent(tokenBeforeLeftBracket, sourceCode.getFirstToken(key));
  83927. var replacementKey = (needsSpaceBeforeKey ? " " : "") + key.raw;
  83928. return fixer.replaceTextRange([leftSquareBracket.range[0], rightSquareBracket.range[1]], replacementKey);
  83929. }
  83930. });
  83931. }
  83932. }
  83933. };
  83934. }
  83935. };
  83936. },{"../util/ast-utils":405}],324:[function(require,module,exports){
  83937. /**
  83938. * @fileoverview disallow unncessary concatenation of template strings
  83939. * @author Henry Zhu
  83940. */
  83941. "use strict";
  83942. //------------------------------------------------------------------------------
  83943. // Requirements
  83944. //------------------------------------------------------------------------------
  83945. var astUtils = require("../util/ast-utils");
  83946. //------------------------------------------------------------------------------
  83947. // Helpers
  83948. //------------------------------------------------------------------------------
  83949. /**
  83950. * Checks whether or not a given node is a concatenation.
  83951. * @param {ASTNode} node - A node to check.
  83952. * @returns {boolean} `true` if the node is a concatenation.
  83953. */
  83954. function isConcatenation(node) {
  83955. return node.type === "BinaryExpression" && node.operator === "+";
  83956. }
  83957. /**
  83958. * Checks if the given token is a `+` token or not.
  83959. * @param {Token} token - The token to check.
  83960. * @returns {boolean} `true` if the token is a `+` token.
  83961. */
  83962. function isConcatOperatorToken(token) {
  83963. return token.value === "+" && token.type === "Punctuator";
  83964. }
  83965. /**
  83966. * Get's the right most node on the left side of a BinaryExpression with + operator.
  83967. * @param {ASTNode} node - A BinaryExpression node to check.
  83968. * @returns {ASTNode} node
  83969. */
  83970. function getLeft(node) {
  83971. var left = node.left;
  83972. while (isConcatenation(left)) {
  83973. left = left.right;
  83974. }
  83975. return left;
  83976. }
  83977. /**
  83978. * Get's the left most node on the right side of a BinaryExpression with + operator.
  83979. * @param {ASTNode} node - A BinaryExpression node to check.
  83980. * @returns {ASTNode} node
  83981. */
  83982. function getRight(node) {
  83983. var right = node.right;
  83984. while (isConcatenation(right)) {
  83985. right = right.left;
  83986. }
  83987. return right;
  83988. }
  83989. //------------------------------------------------------------------------------
  83990. // Rule Definition
  83991. //------------------------------------------------------------------------------
  83992. module.exports = {
  83993. meta: {
  83994. type: "suggestion",
  83995. docs: {
  83996. description: "disallow unnecessary concatenation of literals or template literals",
  83997. category: "Best Practices",
  83998. recommended: false,
  83999. url: "https://eslint.org/docs/rules/no-useless-concat"
  84000. },
  84001. schema: []
  84002. },
  84003. create: function create(context) {
  84004. var sourceCode = context.getSourceCode();
  84005. return {
  84006. BinaryExpression: function BinaryExpression(node) {
  84007. // check if not concatenation
  84008. if (node.operator !== "+") {
  84009. return;
  84010. }
  84011. // account for the `foo + "a" + "b"` case
  84012. var left = getLeft(node);
  84013. var right = getRight(node);
  84014. if (astUtils.isStringLiteral(left) && astUtils.isStringLiteral(right) && astUtils.isTokenOnSameLine(left, right)) {
  84015. var operatorToken = sourceCode.getFirstTokenBetween(left, right, isConcatOperatorToken);
  84016. context.report({
  84017. node: node,
  84018. loc: operatorToken.loc.start,
  84019. message: "Unexpected string concatenation of literals."
  84020. });
  84021. }
  84022. }
  84023. };
  84024. }
  84025. };
  84026. },{"../util/ast-utils":405}],325:[function(require,module,exports){
  84027. /**
  84028. * @fileoverview Rule to flag the use of redundant constructors in classes.
  84029. * @author Alberto Rodríguez
  84030. */
  84031. "use strict";
  84032. //------------------------------------------------------------------------------
  84033. // Helpers
  84034. //------------------------------------------------------------------------------
  84035. /**
  84036. * Checks whether a given array of statements is a single call of `super`.
  84037. *
  84038. * @param {ASTNode[]} body - An array of statements to check.
  84039. * @returns {boolean} `true` if the body is a single call of `super`.
  84040. */
  84041. function isSingleSuperCall(body) {
  84042. return body.length === 1 && body[0].type === "ExpressionStatement" && body[0].expression.type === "CallExpression" && body[0].expression.callee.type === "Super";
  84043. }
  84044. /**
  84045. * Checks whether a given node is a pattern which doesn't have any side effects.
  84046. * Default parameters and Destructuring parameters can have side effects.
  84047. *
  84048. * @param {ASTNode} node - A pattern node.
  84049. * @returns {boolean} `true` if the node doesn't have any side effects.
  84050. */
  84051. function isSimple(node) {
  84052. return node.type === "Identifier" || node.type === "RestElement";
  84053. }
  84054. /**
  84055. * Checks whether a given array of expressions is `...arguments` or not.
  84056. * `super(...arguments)` passes all arguments through.
  84057. *
  84058. * @param {ASTNode[]} superArgs - An array of expressions to check.
  84059. * @returns {boolean} `true` if the superArgs is `...arguments`.
  84060. */
  84061. function isSpreadArguments(superArgs) {
  84062. return superArgs.length === 1 && superArgs[0].type === "SpreadElement" && superArgs[0].argument.type === "Identifier" && superArgs[0].argument.name === "arguments";
  84063. }
  84064. /**
  84065. * Checks whether given 2 nodes are identifiers which have the same name or not.
  84066. *
  84067. * @param {ASTNode} ctorParam - A node to check.
  84068. * @param {ASTNode} superArg - A node to check.
  84069. * @returns {boolean} `true` if the nodes are identifiers which have the same
  84070. * name.
  84071. */
  84072. function isValidIdentifierPair(ctorParam, superArg) {
  84073. return ctorParam.type === "Identifier" && superArg.type === "Identifier" && ctorParam.name === superArg.name;
  84074. }
  84075. /**
  84076. * Checks whether given 2 nodes are a rest/spread pair which has the same values.
  84077. *
  84078. * @param {ASTNode} ctorParam - A node to check.
  84079. * @param {ASTNode} superArg - A node to check.
  84080. * @returns {boolean} `true` if the nodes are a rest/spread pair which has the
  84081. * same values.
  84082. */
  84083. function isValidRestSpreadPair(ctorParam, superArg) {
  84084. return ctorParam.type === "RestElement" && superArg.type === "SpreadElement" && isValidIdentifierPair(ctorParam.argument, superArg.argument);
  84085. }
  84086. /**
  84087. * Checks whether given 2 nodes have the same value or not.
  84088. *
  84089. * @param {ASTNode} ctorParam - A node to check.
  84090. * @param {ASTNode} superArg - A node to check.
  84091. * @returns {boolean} `true` if the nodes have the same value or not.
  84092. */
  84093. function isValidPair(ctorParam, superArg) {
  84094. return isValidIdentifierPair(ctorParam, superArg) || isValidRestSpreadPair(ctorParam, superArg);
  84095. }
  84096. /**
  84097. * Checks whether the parameters of a constructor and the arguments of `super()`
  84098. * have the same values or not.
  84099. *
  84100. * @param {ASTNode} ctorParams - The parameters of a constructor to check.
  84101. * @param {ASTNode} superArgs - The arguments of `super()` to check.
  84102. * @returns {boolean} `true` if those have the same values.
  84103. */
  84104. function isPassingThrough(ctorParams, superArgs) {
  84105. if (ctorParams.length !== superArgs.length) {
  84106. return false;
  84107. }
  84108. for (var i = 0; i < ctorParams.length; ++i) {
  84109. if (!isValidPair(ctorParams[i], superArgs[i])) {
  84110. return false;
  84111. }
  84112. }
  84113. return true;
  84114. }
  84115. /**
  84116. * Checks whether the constructor body is a redundant super call.
  84117. *
  84118. * @param {Array} body - constructor body content.
  84119. * @param {Array} ctorParams - The params to check against super call.
  84120. * @returns {boolean} true if the construtor body is redundant
  84121. */
  84122. function isRedundantSuperCall(body, ctorParams) {
  84123. return isSingleSuperCall(body) && ctorParams.every(isSimple) && (isSpreadArguments(body[0].expression.arguments) || isPassingThrough(ctorParams, body[0].expression.arguments));
  84124. }
  84125. //------------------------------------------------------------------------------
  84126. // Rule Definition
  84127. //------------------------------------------------------------------------------
  84128. module.exports = {
  84129. meta: {
  84130. type: "suggestion",
  84131. docs: {
  84132. description: "disallow unnecessary constructors",
  84133. category: "ECMAScript 6",
  84134. recommended: false,
  84135. url: "https://eslint.org/docs/rules/no-useless-constructor"
  84136. },
  84137. schema: []
  84138. },
  84139. create: function create(context) {
  84140. /**
  84141. * Checks whether a node is a redundant constructor
  84142. * @param {ASTNode} node - node to check
  84143. * @returns {void}
  84144. */
  84145. function checkForConstructor(node) {
  84146. if (node.kind !== "constructor") {
  84147. return;
  84148. }
  84149. var body = node.value.body.body;
  84150. var ctorParams = node.value.params;
  84151. var superClass = node.parent.parent.superClass;
  84152. if (superClass ? isRedundantSuperCall(body, ctorParams) : body.length === 0) {
  84153. context.report({
  84154. node: node,
  84155. message: "Useless constructor."
  84156. });
  84157. }
  84158. }
  84159. return {
  84160. MethodDefinition: checkForConstructor
  84161. };
  84162. }
  84163. };
  84164. },{}],326:[function(require,module,exports){
  84165. /**
  84166. * @fileoverview Look for useless escapes in strings and regexes
  84167. * @author Onur Temizkan
  84168. */
  84169. "use strict";
  84170. var astUtils = require("../util/ast-utils");
  84171. //------------------------------------------------------------------------------
  84172. // Rule Definition
  84173. //------------------------------------------------------------------------------
  84174. /**
  84175. * Returns the union of two sets.
  84176. * @param {Set} setA The first set
  84177. * @param {Set} setB The second set
  84178. * @returns {Set} The union of the two sets
  84179. */
  84180. function union(setA, setB) {
  84181. return new Set( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
  84182. return regeneratorRuntime.wrap(function _callee$(_context) {
  84183. while (1) {
  84184. switch (_context.prev = _context.next) {
  84185. case 0:
  84186. return _context.delegateYield(setA, "t0", 1);
  84187. case 1:
  84188. return _context.delegateYield(setB, "t1", 2);
  84189. case 2:
  84190. case "end":
  84191. return _context.stop();
  84192. }
  84193. }
  84194. }, _callee, this);
  84195. })());
  84196. }
  84197. var VALID_STRING_ESCAPES = union(new Set("\\nrvtbfux"), astUtils.LINEBREAKS);
  84198. var REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnpPrsStvwWxu0123456789]");
  84199. var REGEX_NON_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("^/.$*+?[{}|()Bk"));
  84200. /**
  84201. * Parses a regular expression into a list of characters with character class info.
  84202. * @param {string} regExpText The raw text used to create the regular expression
  84203. * @returns {Object[]} A list of characters, each with info on escaping and whether they're in a character class.
  84204. * @example
  84205. *
  84206. * parseRegExp('a\\b[cd-]')
  84207. *
  84208. * returns:
  84209. * [
  84210. * {text: 'a', index: 0, escaped: false, inCharClass: false, startsCharClass: false, endsCharClass: false},
  84211. * {text: 'b', index: 2, escaped: true, inCharClass: false, startsCharClass: false, endsCharClass: false},
  84212. * {text: 'c', index: 4, escaped: false, inCharClass: true, startsCharClass: true, endsCharClass: false},
  84213. * {text: 'd', index: 5, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false},
  84214. * {text: '-', index: 6, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false}
  84215. * ]
  84216. */
  84217. function parseRegExp(regExpText) {
  84218. var charList = [];
  84219. regExpText.split("").reduce(function (state, char, index) {
  84220. if (!state.escapeNextChar) {
  84221. if (char === "\\") {
  84222. return Object.assign(state, { escapeNextChar: true });
  84223. }
  84224. if (char === "[" && !state.inCharClass) {
  84225. return Object.assign(state, { inCharClass: true, startingCharClass: true });
  84226. }
  84227. if (char === "]" && state.inCharClass) {
  84228. if (charList.length && charList[charList.length - 1].inCharClass) {
  84229. charList[charList.length - 1].endsCharClass = true;
  84230. }
  84231. return Object.assign(state, { inCharClass: false, startingCharClass: false });
  84232. }
  84233. }
  84234. charList.push({
  84235. text: char,
  84236. index: index,
  84237. escaped: state.escapeNextChar,
  84238. inCharClass: state.inCharClass,
  84239. startsCharClass: state.startingCharClass,
  84240. endsCharClass: false
  84241. });
  84242. return Object.assign(state, { escapeNextChar: false, startingCharClass: false });
  84243. }, { escapeNextChar: false, inCharClass: false, startingCharClass: false });
  84244. return charList;
  84245. }
  84246. module.exports = {
  84247. meta: {
  84248. type: "suggestion",
  84249. docs: {
  84250. description: "disallow unnecessary escape characters",
  84251. category: "Best Practices",
  84252. recommended: true,
  84253. url: "https://eslint.org/docs/rules/no-useless-escape"
  84254. },
  84255. schema: []
  84256. },
  84257. create: function create(context) {
  84258. var sourceCode = context.getSourceCode();
  84259. /**
  84260. * Reports a node
  84261. * @param {ASTNode} node The node to report
  84262. * @param {number} startOffset The backslash's offset from the start of the node
  84263. * @param {string} character The uselessly escaped character (not including the backslash)
  84264. * @returns {void}
  84265. */
  84266. function report(node, startOffset, character) {
  84267. context.report({
  84268. node: node,
  84269. loc: sourceCode.getLocFromIndex(sourceCode.getIndexFromLoc(node.loc.start) + startOffset),
  84270. message: "Unnecessary escape character: \\{{character}}.",
  84271. data: { character: character }
  84272. });
  84273. }
  84274. /**
  84275. * Checks if the escape character in given string slice is unnecessary.
  84276. *
  84277. * @private
  84278. * @param {ASTNode} node - node to validate.
  84279. * @param {string} match - string slice to validate.
  84280. * @returns {void}
  84281. */
  84282. function validateString(node, match) {
  84283. var isTemplateElement = node.type === "TemplateElement";
  84284. var escapedChar = match[0][1];
  84285. var isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
  84286. var isQuoteEscape = void 0;
  84287. if (isTemplateElement) {
  84288. isQuoteEscape = escapedChar === "`";
  84289. if (escapedChar === "$") {
  84290. // Warn if `\$` is not followed by `{`
  84291. isUnnecessaryEscape = match.input[match.index + 2] !== "{";
  84292. } else if (escapedChar === "{") {
  84293. /*
  84294. * Warn if `\{` is not preceded by `$`. If preceded by `$`, escaping
  84295. * is necessary and the rule should not warn. If preceded by `/$`, the rule
  84296. * will warn for the `/$` instead, as it is the first unnecessarily escaped character.
  84297. */
  84298. isUnnecessaryEscape = match.input[match.index - 1] !== "$";
  84299. }
  84300. } else {
  84301. isQuoteEscape = escapedChar === node.raw[0];
  84302. }
  84303. if (isUnnecessaryEscape && !isQuoteEscape) {
  84304. report(node, match.index + 1, match[0].slice(1));
  84305. }
  84306. }
  84307. /**
  84308. * Checks if a node has an escape.
  84309. *
  84310. * @param {ASTNode} node - node to check.
  84311. * @returns {void}
  84312. */
  84313. function check(node) {
  84314. var isTemplateElement = node.type === "TemplateElement";
  84315. if (isTemplateElement && node.parent && node.parent.parent && node.parent.parent.type === "TaggedTemplateExpression" && node.parent === node.parent.parent.quasi) {
  84316. // Don't report tagged template literals, because the backslash character is accessible to the tag function.
  84317. return;
  84318. }
  84319. if (typeof node.value === "string" || isTemplateElement) {
  84320. /*
  84321. * JSXAttribute doesn't have any escape sequence: https://facebook.github.io/jsx/.
  84322. * In addition, backticks are not supported by JSX yet: https://github.com/facebook/jsx/issues/25.
  84323. */
  84324. if (node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment") {
  84325. return;
  84326. }
  84327. var value = isTemplateElement ? node.value.raw : node.raw.slice(1, -1);
  84328. var pattern = /\\[^\d]/g;
  84329. var match = void 0;
  84330. while (match = pattern.exec(value)) {
  84331. validateString(node, match);
  84332. }
  84333. } else if (node.regex) {
  84334. parseRegExp(node.regex.pattern)
  84335. /*
  84336. * The '-' character is a special case, because it's only valid to escape it if it's in a character
  84337. * class, and is not at either edge of the character class. To account for this, don't consider '-'
  84338. * characters to be valid in general, and filter out '-' characters that appear in the middle of a
  84339. * character class.
  84340. */
  84341. .filter(function (charInfo) {
  84342. return !(charInfo.text === "-" && charInfo.inCharClass && !charInfo.startsCharClass && !charInfo.endsCharClass);
  84343. })
  84344. /*
  84345. * The '^' character is also a special case; it must always be escaped outside of character classes, but
  84346. * it only needs to be escaped in character classes if it's at the beginning of the character class. To
  84347. * account for this, consider it to be a valid escape character outside of character classes, and filter
  84348. * out '^' characters that appear at the start of a character class.
  84349. */
  84350. .filter(function (charInfo) {
  84351. return !(charInfo.text === "^" && charInfo.startsCharClass);
  84352. })
  84353. // Filter out characters that aren't escaped.
  84354. .filter(function (charInfo) {
  84355. return charInfo.escaped;
  84356. })
  84357. // Filter out characters that are valid to escape, based on their position in the regular expression.
  84358. .filter(function (charInfo) {
  84359. return !(charInfo.inCharClass ? REGEX_GENERAL_ESCAPES : REGEX_NON_CHARCLASS_ESCAPES).has(charInfo.text);
  84360. })
  84361. // Report all the remaining characters.
  84362. .forEach(function (charInfo) {
  84363. return report(node, charInfo.index, charInfo.text);
  84364. });
  84365. }
  84366. }
  84367. return {
  84368. Literal: check,
  84369. TemplateElement: check
  84370. };
  84371. }
  84372. };
  84373. },{"../util/ast-utils":405}],327:[function(require,module,exports){
  84374. /**
  84375. * @fileoverview Disallow renaming import, export, and destructured assignments to the same name.
  84376. * @author Kai Cataldo
  84377. */
  84378. "use strict";
  84379. //------------------------------------------------------------------------------
  84380. // Rule Definition
  84381. //------------------------------------------------------------------------------
  84382. module.exports = {
  84383. meta: {
  84384. type: "suggestion",
  84385. docs: {
  84386. description: "disallow renaming import, export, and destructured assignments to the same name",
  84387. category: "ECMAScript 6",
  84388. recommended: false,
  84389. url: "https://eslint.org/docs/rules/no-useless-rename"
  84390. },
  84391. fixable: "code",
  84392. schema: [{
  84393. type: "object",
  84394. properties: {
  84395. ignoreDestructuring: { type: "boolean" },
  84396. ignoreImport: { type: "boolean" },
  84397. ignoreExport: { type: "boolean" }
  84398. },
  84399. additionalProperties: false
  84400. }]
  84401. },
  84402. create: function create(context) {
  84403. var options = context.options[0] || {},
  84404. ignoreDestructuring = options.ignoreDestructuring === true,
  84405. ignoreImport = options.ignoreImport === true,
  84406. ignoreExport = options.ignoreExport === true;
  84407. //--------------------------------------------------------------------------
  84408. // Helpers
  84409. //--------------------------------------------------------------------------
  84410. /**
  84411. * Reports error for unnecessarily renamed assignments
  84412. * @param {ASTNode} node - node to report
  84413. * @param {ASTNode} initial - node with initial name value
  84414. * @param {ASTNode} result - node with new name value
  84415. * @param {string} type - the type of the offending node
  84416. * @returns {void}
  84417. */
  84418. function reportError(node, initial, result, type) {
  84419. var name = initial.type === "Identifier" ? initial.name : initial.value;
  84420. return context.report({
  84421. node: node,
  84422. message: "{{type}} {{name}} unnecessarily renamed.",
  84423. data: {
  84424. name: name,
  84425. type: type
  84426. },
  84427. fix: function fix(fixer) {
  84428. return fixer.replaceTextRange([initial.range[0], result.range[1]], name);
  84429. }
  84430. });
  84431. }
  84432. /**
  84433. * Checks whether a destructured assignment is unnecessarily renamed
  84434. * @param {ASTNode} node - node to check
  84435. * @returns {void}
  84436. */
  84437. function checkDestructured(node) {
  84438. if (ignoreDestructuring) {
  84439. return;
  84440. }
  84441. var properties = node.properties;
  84442. for (var i = 0; i < properties.length; i++) {
  84443. if (properties[i].shorthand) {
  84444. continue;
  84445. }
  84446. /**
  84447. * If an ObjectPattern property is computed, we have no idea
  84448. * if a rename is useless or not. If an ObjectPattern property
  84449. * lacks a key, it is likely an ExperimentalRestProperty and
  84450. * so there is no "renaming" occurring here.
  84451. */
  84452. if (properties[i].computed || !properties[i].key) {
  84453. continue;
  84454. }
  84455. if (properties[i].key.type === "Identifier" && properties[i].key.name === properties[i].value.name || properties[i].key.type === "Literal" && properties[i].key.value === properties[i].value.name) {
  84456. reportError(properties[i], properties[i].key, properties[i].value, "Destructuring assignment");
  84457. }
  84458. }
  84459. }
  84460. /**
  84461. * Checks whether an import is unnecessarily renamed
  84462. * @param {ASTNode} node - node to check
  84463. * @returns {void}
  84464. */
  84465. function checkImport(node) {
  84466. if (ignoreImport) {
  84467. return;
  84468. }
  84469. if (node.imported.name === node.local.name && node.imported.range[0] !== node.local.range[0]) {
  84470. reportError(node, node.imported, node.local, "Import");
  84471. }
  84472. }
  84473. /**
  84474. * Checks whether an export is unnecessarily renamed
  84475. * @param {ASTNode} node - node to check
  84476. * @returns {void}
  84477. */
  84478. function checkExport(node) {
  84479. if (ignoreExport) {
  84480. return;
  84481. }
  84482. if (node.local.name === node.exported.name && node.local.range[0] !== node.exported.range[0]) {
  84483. reportError(node, node.local, node.exported, "Export");
  84484. }
  84485. }
  84486. //--------------------------------------------------------------------------
  84487. // Public
  84488. //--------------------------------------------------------------------------
  84489. return {
  84490. ObjectPattern: checkDestructured,
  84491. ImportSpecifier: checkImport,
  84492. ExportSpecifier: checkExport
  84493. };
  84494. }
  84495. };
  84496. },{}],328:[function(require,module,exports){
  84497. /**
  84498. * @fileoverview Disallow redundant return statements
  84499. * @author Teddy Katz
  84500. */
  84501. "use strict";
  84502. //------------------------------------------------------------------------------
  84503. // Requirements
  84504. //------------------------------------------------------------------------------
  84505. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  84506. var astUtils = require("../util/ast-utils"),
  84507. FixTracker = require("../util/fix-tracker");
  84508. //------------------------------------------------------------------------------
  84509. // Helpers
  84510. //------------------------------------------------------------------------------
  84511. /**
  84512. * Removes the given element from the array.
  84513. *
  84514. * @param {Array} array - The source array to remove.
  84515. * @param {any} element - The target item to remove.
  84516. * @returns {void}
  84517. */
  84518. function remove(array, element) {
  84519. var index = array.indexOf(element);
  84520. if (index !== -1) {
  84521. array.splice(index, 1);
  84522. }
  84523. }
  84524. /**
  84525. * Checks whether it can remove the given return statement or not.
  84526. *
  84527. * @param {ASTNode} node - The return statement node to check.
  84528. * @returns {boolean} `true` if the node is removeable.
  84529. */
  84530. function isRemovable(node) {
  84531. return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type);
  84532. }
  84533. /**
  84534. * Checks whether the given return statement is in a `finally` block or not.
  84535. *
  84536. * @param {ASTNode} node - The return statement node to check.
  84537. * @returns {boolean} `true` if the node is in a `finally` block.
  84538. */
  84539. function isInFinally(node) {
  84540. for (var currentNode = node; currentNode && currentNode.parent && !astUtils.isFunction(currentNode); currentNode = currentNode.parent) {
  84541. if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) {
  84542. return true;
  84543. }
  84544. }
  84545. return false;
  84546. }
  84547. //------------------------------------------------------------------------------
  84548. // Rule Definition
  84549. //------------------------------------------------------------------------------
  84550. module.exports = {
  84551. meta: {
  84552. type: "suggestion",
  84553. docs: {
  84554. description: "disallow redundant return statements",
  84555. category: "Best Practices",
  84556. recommended: false,
  84557. url: "https://eslint.org/docs/rules/no-useless-return"
  84558. },
  84559. fixable: "code",
  84560. schema: []
  84561. },
  84562. create: function create(context) {
  84563. var segmentInfoMap = new WeakMap();
  84564. var usedUnreachableSegments = new WeakSet();
  84565. var scopeInfo = null;
  84566. /**
  84567. * Checks whether the given segment is terminated by a return statement or not.
  84568. *
  84569. * @param {CodePathSegment} segment - The segment to check.
  84570. * @returns {boolean} `true` if the segment is terminated by a return statement, or if it's still a part of unreachable.
  84571. */
  84572. function isReturned(segment) {
  84573. var info = segmentInfoMap.get(segment);
  84574. return !info || info.returned;
  84575. }
  84576. /**
  84577. * Collects useless return statements from the given previous segments.
  84578. *
  84579. * A previous segment may be an unreachable segment.
  84580. * In that case, the information object of the unreachable segment is not
  84581. * initialized because `onCodePathSegmentStart` event is not notified for
  84582. * unreachable segments.
  84583. * This goes to the previous segments of the unreachable segment recursively
  84584. * if the unreachable segment was generated by a return statement. Otherwise,
  84585. * this ignores the unreachable segment.
  84586. *
  84587. * This behavior would simulate code paths for the case that the return
  84588. * statement does not exist.
  84589. *
  84590. * @param {ASTNode[]} uselessReturns - The collected return statements.
  84591. * @param {CodePathSegment[]} prevSegments - The previous segments to traverse.
  84592. * @param {WeakSet<CodePathSegment>} [providedTraversedSegments] A set of segments that have already been traversed in this call
  84593. * @returns {ASTNode[]} `uselessReturns`.
  84594. */
  84595. function getUselessReturns(uselessReturns, prevSegments, providedTraversedSegments) {
  84596. var traversedSegments = providedTraversedSegments || new WeakSet();
  84597. var _iteratorNormalCompletion = true;
  84598. var _didIteratorError = false;
  84599. var _iteratorError = undefined;
  84600. try {
  84601. for (var _iterator = prevSegments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  84602. var segment = _step.value;
  84603. if (!segment.reachable) {
  84604. if (!traversedSegments.has(segment)) {
  84605. traversedSegments.add(segment);
  84606. getUselessReturns(uselessReturns, segment.allPrevSegments.filter(isReturned), traversedSegments);
  84607. }
  84608. continue;
  84609. }
  84610. uselessReturns.push.apply(uselessReturns, _toConsumableArray(segmentInfoMap.get(segment).uselessReturns));
  84611. }
  84612. } catch (err) {
  84613. _didIteratorError = true;
  84614. _iteratorError = err;
  84615. } finally {
  84616. try {
  84617. if (!_iteratorNormalCompletion && _iterator.return) {
  84618. _iterator.return();
  84619. }
  84620. } finally {
  84621. if (_didIteratorError) {
  84622. throw _iteratorError;
  84623. }
  84624. }
  84625. }
  84626. return uselessReturns;
  84627. }
  84628. /**
  84629. * Removes the return statements on the given segment from the useless return
  84630. * statement list.
  84631. *
  84632. * This segment may be an unreachable segment.
  84633. * In that case, the information object of the unreachable segment is not
  84634. * initialized because `onCodePathSegmentStart` event is not notified for
  84635. * unreachable segments.
  84636. * This goes to the previous segments of the unreachable segment recursively
  84637. * if the unreachable segment was generated by a return statement. Otherwise,
  84638. * this ignores the unreachable segment.
  84639. *
  84640. * This behavior would simulate code paths for the case that the return
  84641. * statement does not exist.
  84642. *
  84643. * @param {CodePathSegment} segment - The segment to get return statements.
  84644. * @returns {void}
  84645. */
  84646. function markReturnStatementsOnSegmentAsUsed(segment) {
  84647. if (!segment.reachable) {
  84648. usedUnreachableSegments.add(segment);
  84649. segment.allPrevSegments.filter(isReturned).filter(function (prevSegment) {
  84650. return !usedUnreachableSegments.has(prevSegment);
  84651. }).forEach(markReturnStatementsOnSegmentAsUsed);
  84652. return;
  84653. }
  84654. var info = segmentInfoMap.get(segment);
  84655. var _iteratorNormalCompletion2 = true;
  84656. var _didIteratorError2 = false;
  84657. var _iteratorError2 = undefined;
  84658. try {
  84659. for (var _iterator2 = info.uselessReturns[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  84660. var node = _step2.value;
  84661. remove(scopeInfo.uselessReturns, node);
  84662. }
  84663. } catch (err) {
  84664. _didIteratorError2 = true;
  84665. _iteratorError2 = err;
  84666. } finally {
  84667. try {
  84668. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  84669. _iterator2.return();
  84670. }
  84671. } finally {
  84672. if (_didIteratorError2) {
  84673. throw _iteratorError2;
  84674. }
  84675. }
  84676. }
  84677. info.uselessReturns = [];
  84678. }
  84679. /**
  84680. * Removes the return statements on the current segments from the useless
  84681. * return statement list.
  84682. *
  84683. * This function will be called at every statement except FunctionDeclaration,
  84684. * BlockStatement, and BreakStatement.
  84685. *
  84686. * - FunctionDeclarations are always executed whether it's returned or not.
  84687. * - BlockStatements do nothing.
  84688. * - BreakStatements go the next merely.
  84689. *
  84690. * @returns {void}
  84691. */
  84692. function markReturnStatementsOnCurrentSegmentsAsUsed() {
  84693. scopeInfo.codePath.currentSegments.forEach(markReturnStatementsOnSegmentAsUsed);
  84694. }
  84695. //----------------------------------------------------------------------
  84696. // Public
  84697. //----------------------------------------------------------------------
  84698. return {
  84699. // Makes and pushs a new scope information.
  84700. onCodePathStart: function onCodePathStart(codePath) {
  84701. scopeInfo = {
  84702. upper: scopeInfo,
  84703. uselessReturns: [],
  84704. codePath: codePath
  84705. };
  84706. },
  84707. // Reports useless return statements if exist.
  84708. onCodePathEnd: function onCodePathEnd() {
  84709. var _iteratorNormalCompletion3 = true;
  84710. var _didIteratorError3 = false;
  84711. var _iteratorError3 = undefined;
  84712. try {
  84713. var _loop = function _loop() {
  84714. var node = _step3.value;
  84715. context.report({
  84716. node: node,
  84717. loc: node.loc,
  84718. message: "Unnecessary return statement.",
  84719. fix: function fix(fixer) {
  84720. if (isRemovable(node)) {
  84721. /*
  84722. * Extend the replacement range to include the
  84723. * entire function to avoid conflicting with
  84724. * no-else-return.
  84725. * https://github.com/eslint/eslint/issues/8026
  84726. */
  84727. return new FixTracker(fixer, context.getSourceCode()).retainEnclosingFunction(node).remove(node);
  84728. }
  84729. return null;
  84730. }
  84731. });
  84732. };
  84733. for (var _iterator3 = scopeInfo.uselessReturns[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  84734. _loop();
  84735. }
  84736. } catch (err) {
  84737. _didIteratorError3 = true;
  84738. _iteratorError3 = err;
  84739. } finally {
  84740. try {
  84741. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  84742. _iterator3.return();
  84743. }
  84744. } finally {
  84745. if (_didIteratorError3) {
  84746. throw _iteratorError3;
  84747. }
  84748. }
  84749. }
  84750. scopeInfo = scopeInfo.upper;
  84751. },
  84752. /*
  84753. * Initializes segments.
  84754. * NOTE: This event is notified for only reachable segments.
  84755. */
  84756. onCodePathSegmentStart: function onCodePathSegmentStart(segment) {
  84757. var info = {
  84758. uselessReturns: getUselessReturns([], segment.allPrevSegments),
  84759. returned: false
  84760. };
  84761. // Stores the info.
  84762. segmentInfoMap.set(segment, info);
  84763. },
  84764. // Adds ReturnStatement node to check whether it's useless or not.
  84765. ReturnStatement: function ReturnStatement(node) {
  84766. if (node.argument) {
  84767. markReturnStatementsOnCurrentSegmentsAsUsed();
  84768. }
  84769. if (node.argument || astUtils.isInLoop(node) || isInFinally(node)) {
  84770. return;
  84771. }
  84772. var _iteratorNormalCompletion4 = true;
  84773. var _didIteratorError4 = false;
  84774. var _iteratorError4 = undefined;
  84775. try {
  84776. for (var _iterator4 = scopeInfo.codePath.currentSegments[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  84777. var segment = _step4.value;
  84778. var info = segmentInfoMap.get(segment);
  84779. if (info) {
  84780. info.uselessReturns.push(node);
  84781. info.returned = true;
  84782. }
  84783. }
  84784. } catch (err) {
  84785. _didIteratorError4 = true;
  84786. _iteratorError4 = err;
  84787. } finally {
  84788. try {
  84789. if (!_iteratorNormalCompletion4 && _iterator4.return) {
  84790. _iterator4.return();
  84791. }
  84792. } finally {
  84793. if (_didIteratorError4) {
  84794. throw _iteratorError4;
  84795. }
  84796. }
  84797. }
  84798. scopeInfo.uselessReturns.push(node);
  84799. },
  84800. /*
  84801. * Registers for all statement nodes except FunctionDeclaration, BlockStatement, BreakStatement.
  84802. * Removes return statements of the current segments from the useless return statement list.
  84803. */
  84804. ClassDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
  84805. ContinueStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84806. DebuggerStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84807. DoWhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84808. EmptyStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84809. ExpressionStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84810. ForInStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84811. ForOfStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84812. ForStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84813. IfStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84814. ImportDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
  84815. LabeledStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84816. SwitchStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84817. ThrowStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84818. TryStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84819. VariableDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
  84820. WhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84821. WithStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
  84822. ExportNamedDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
  84823. ExportDefaultDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
  84824. ExportAllDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed
  84825. };
  84826. }
  84827. };
  84828. },{"../util/ast-utils":405,"../util/fix-tracker":407}],329:[function(require,module,exports){
  84829. /**
  84830. * @fileoverview Rule to check for the usage of var.
  84831. * @author Jamund Ferguson
  84832. */
  84833. "use strict";
  84834. //------------------------------------------------------------------------------
  84835. // Requirements
  84836. //------------------------------------------------------------------------------
  84837. var astUtils = require("../util/ast-utils");
  84838. //------------------------------------------------------------------------------
  84839. // Helpers
  84840. //------------------------------------------------------------------------------
  84841. /**
  84842. * Check whether a given variable is a global variable or not.
  84843. * @param {eslint-scope.Variable} variable The variable to check.
  84844. * @returns {boolean} `true` if the variable is a global variable.
  84845. */
  84846. function isGlobal(variable) {
  84847. return Boolean(variable.scope) && variable.scope.type === "global";
  84848. }
  84849. /**
  84850. * Finds the nearest function scope or global scope walking up the scope
  84851. * hierarchy.
  84852. *
  84853. * @param {eslint-scope.Scope} scope - The scope to traverse.
  84854. * @returns {eslint-scope.Scope} a function scope or global scope containing the given
  84855. * scope.
  84856. */
  84857. function getEnclosingFunctionScope(scope) {
  84858. var currentScope = scope;
  84859. while (currentScope.type !== "function" && currentScope.type !== "global") {
  84860. currentScope = currentScope.upper;
  84861. }
  84862. return currentScope;
  84863. }
  84864. /**
  84865. * Checks whether the given variable has any references from a more specific
  84866. * function expression (i.e. a closure).
  84867. *
  84868. * @param {eslint-scope.Variable} variable - A variable to check.
  84869. * @returns {boolean} `true` if the variable is used from a closure.
  84870. */
  84871. function isReferencedInClosure(variable) {
  84872. var enclosingFunctionScope = getEnclosingFunctionScope(variable.scope);
  84873. return variable.references.some(function (reference) {
  84874. return getEnclosingFunctionScope(reference.from) !== enclosingFunctionScope;
  84875. });
  84876. }
  84877. /**
  84878. * Checks whether the given node is the assignee of a loop.
  84879. *
  84880. * @param {ASTNode} node - A VariableDeclaration node to check.
  84881. * @returns {boolean} `true` if the declaration is assigned as part of loop
  84882. * iteration.
  84883. */
  84884. function isLoopAssignee(node) {
  84885. return (node.parent.type === "ForOfStatement" || node.parent.type === "ForInStatement") && node === node.parent.left;
  84886. }
  84887. /**
  84888. * Checks whether the given variable declaration is immediately initialized.
  84889. *
  84890. * @param {ASTNode} node - A VariableDeclaration node to check.
  84891. * @returns {boolean} `true` if the declaration has an initializer.
  84892. */
  84893. function isDeclarationInitialized(node) {
  84894. return node.declarations.every(function (declarator) {
  84895. return declarator.init !== null;
  84896. });
  84897. }
  84898. var SCOPE_NODE_TYPE = /^(?:Program|BlockStatement|SwitchStatement|ForStatement|ForInStatement|ForOfStatement)$/;
  84899. /**
  84900. * Gets the scope node which directly contains a given node.
  84901. *
  84902. * @param {ASTNode} node - A node to get. This is a `VariableDeclaration` or
  84903. * an `Identifier`.
  84904. * @returns {ASTNode} A scope node. This is one of `Program`, `BlockStatement`,
  84905. * `SwitchStatement`, `ForStatement`, `ForInStatement`, and
  84906. * `ForOfStatement`.
  84907. */
  84908. function getScopeNode(node) {
  84909. for (var currentNode = node; currentNode; currentNode = currentNode.parent) {
  84910. if (SCOPE_NODE_TYPE.test(currentNode.type)) {
  84911. return currentNode;
  84912. }
  84913. }
  84914. /* istanbul ignore next : unreachable */
  84915. return null;
  84916. }
  84917. /**
  84918. * Checks whether a given variable is redeclared or not.
  84919. *
  84920. * @param {eslint-scope.Variable} variable - A variable to check.
  84921. * @returns {boolean} `true` if the variable is redeclared.
  84922. */
  84923. function isRedeclared(variable) {
  84924. return variable.defs.length >= 2;
  84925. }
  84926. /**
  84927. * Checks whether a given variable is used from outside of the specified scope.
  84928. *
  84929. * @param {ASTNode} scopeNode - A scope node to check.
  84930. * @returns {Function} The predicate function which checks whether a given
  84931. * variable is used from outside of the specified scope.
  84932. */
  84933. function isUsedFromOutsideOf(scopeNode) {
  84934. /**
  84935. * Checks whether a given reference is inside of the specified scope or not.
  84936. *
  84937. * @param {eslint-scope.Reference} reference - A reference to check.
  84938. * @returns {boolean} `true` if the reference is inside of the specified
  84939. * scope.
  84940. */
  84941. function isOutsideOfScope(reference) {
  84942. var scope = scopeNode.range;
  84943. var id = reference.identifier.range;
  84944. return id[0] < scope[0] || id[1] > scope[1];
  84945. }
  84946. return function (variable) {
  84947. return variable.references.some(isOutsideOfScope);
  84948. };
  84949. }
  84950. /**
  84951. * Creates the predicate function which checks whether a variable has their references in TDZ.
  84952. *
  84953. * The predicate function would return `true`:
  84954. *
  84955. * - if a reference is before the declarator. E.g. (var a = b, b = 1;)(var {a = b, b} = {};)
  84956. * - if a reference is in the expression of their default value. E.g. (var {a = a} = {};)
  84957. * - if a reference is in the expression of their initializer. E.g. (var a = a;)
  84958. *
  84959. * @param {ASTNode} node - The initializer node of VariableDeclarator.
  84960. * @returns {Function} The predicate function.
  84961. * @private
  84962. */
  84963. function hasReferenceInTDZ(node) {
  84964. var initStart = node.range[0];
  84965. var initEnd = node.range[1];
  84966. return function (variable) {
  84967. var id = variable.defs[0].name;
  84968. var idStart = id.range[0];
  84969. var defaultValue = id.parent.type === "AssignmentPattern" ? id.parent.right : null;
  84970. var defaultStart = defaultValue && defaultValue.range[0];
  84971. var defaultEnd = defaultValue && defaultValue.range[1];
  84972. return variable.references.some(function (reference) {
  84973. var start = reference.identifier.range[0];
  84974. var end = reference.identifier.range[1];
  84975. return !reference.init && (start < idStart || defaultValue !== null && start >= defaultStart && end <= defaultEnd || start >= initStart && end <= initEnd);
  84976. });
  84977. };
  84978. }
  84979. //------------------------------------------------------------------------------
  84980. // Rule Definition
  84981. //------------------------------------------------------------------------------
  84982. module.exports = {
  84983. meta: {
  84984. type: "suggestion",
  84985. docs: {
  84986. description: "require `let` or `const` instead of `var`",
  84987. category: "ECMAScript 6",
  84988. recommended: false,
  84989. url: "https://eslint.org/docs/rules/no-var"
  84990. },
  84991. schema: [],
  84992. fixable: "code"
  84993. },
  84994. create: function create(context) {
  84995. var sourceCode = context.getSourceCode();
  84996. /**
  84997. * Checks whether the variables which are defined by the given declarator node have their references in TDZ.
  84998. *
  84999. * @param {ASTNode} declarator - The VariableDeclarator node to check.
  85000. * @returns {boolean} `true` if one of the variables which are defined by the given declarator node have their references in TDZ.
  85001. */
  85002. function hasSelfReferenceInTDZ(declarator) {
  85003. if (!declarator.init) {
  85004. return false;
  85005. }
  85006. var variables = context.getDeclaredVariables(declarator);
  85007. return variables.some(hasReferenceInTDZ(declarator.init));
  85008. }
  85009. /**
  85010. * Checks whether it can fix a given variable declaration or not.
  85011. * It cannot fix if the following cases:
  85012. *
  85013. * - A variable is a global variable.
  85014. * - A variable is declared on a SwitchCase node.
  85015. * - A variable is redeclared.
  85016. * - A variable is used from outside the scope.
  85017. * - A variable is used from a closure within a loop.
  85018. * - A variable might be used before it is assigned within a loop.
  85019. * - A variable might be used in TDZ.
  85020. * - A variable is declared in statement position (e.g. a single-line `IfStatement`)
  85021. *
  85022. * ## A variable is declared on a SwitchCase node.
  85023. *
  85024. * If this rule modifies 'var' declarations on a SwitchCase node, it
  85025. * would generate the warnings of 'no-case-declarations' rule. And the
  85026. * 'eslint:recommended' preset includes 'no-case-declarations' rule, so
  85027. * this rule doesn't modify those declarations.
  85028. *
  85029. * ## A variable is redeclared.
  85030. *
  85031. * The language spec disallows redeclarations of `let` declarations.
  85032. * Those variables would cause syntax errors.
  85033. *
  85034. * ## A variable is used from outside the scope.
  85035. *
  85036. * The language spec disallows accesses from outside of the scope for
  85037. * `let` declarations. Those variables would cause reference errors.
  85038. *
  85039. * ## A variable is used from a closure within a loop.
  85040. *
  85041. * A `var` declaration within a loop shares the same variable instance
  85042. * across all loop iterations, while a `let` declaration creates a new
  85043. * instance for each iteration. This means if a variable in a loop is
  85044. * referenced by any closure, changing it from `var` to `let` would
  85045. * change the behavior in a way that is generally unsafe.
  85046. *
  85047. * ## A variable might be used before it is assigned within a loop.
  85048. *
  85049. * Within a loop, a `let` declaration without an initializer will be
  85050. * initialized to null, while a `var` declaration will retain its value
  85051. * from the previous iteration, so it is only safe to change `var` to
  85052. * `let` if we can statically determine that the variable is always
  85053. * assigned a value before its first access in the loop body. To keep
  85054. * the implementation simple, we only convert `var` to `let` within
  85055. * loops when the variable is a loop assignee or the declaration has an
  85056. * initializer.
  85057. *
  85058. * @param {ASTNode} node - A variable declaration node to check.
  85059. * @returns {boolean} `true` if it can fix the node.
  85060. */
  85061. function canFix(node) {
  85062. var variables = context.getDeclaredVariables(node);
  85063. var scopeNode = getScopeNode(node);
  85064. if (node.parent.type === "SwitchCase" || node.declarations.some(hasSelfReferenceInTDZ) || variables.some(isGlobal) || variables.some(isRedeclared) || variables.some(isUsedFromOutsideOf(scopeNode))) {
  85065. return false;
  85066. }
  85067. if (astUtils.isInLoop(node)) {
  85068. if (variables.some(isReferencedInClosure)) {
  85069. return false;
  85070. }
  85071. if (!isLoopAssignee(node) && !isDeclarationInitialized(node)) {
  85072. return false;
  85073. }
  85074. }
  85075. if (!isLoopAssignee(node) && !(node.parent.type === "ForStatement" && node.parent.init === node) && !astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
  85076. // If the declaration is not in a block, e.g. `if (foo) var bar = 1;`, then it can't be fixed.
  85077. return false;
  85078. }
  85079. return true;
  85080. }
  85081. /**
  85082. * Reports a given variable declaration node.
  85083. *
  85084. * @param {ASTNode} node - A variable declaration node to report.
  85085. * @returns {void}
  85086. */
  85087. function report(node) {
  85088. var varToken = sourceCode.getFirstToken(node);
  85089. context.report({
  85090. node: node,
  85091. message: "Unexpected var, use let or const instead.",
  85092. fix: function fix(fixer) {
  85093. if (canFix(node)) {
  85094. return fixer.replaceText(varToken, "let");
  85095. }
  85096. return null;
  85097. }
  85098. });
  85099. }
  85100. return {
  85101. "VariableDeclaration:exit": function VariableDeclarationExit(node) {
  85102. if (node.kind === "var") {
  85103. report(node);
  85104. }
  85105. }
  85106. };
  85107. }
  85108. };
  85109. },{"../util/ast-utils":405}],330:[function(require,module,exports){
  85110. /**
  85111. * @fileoverview Rule to disallow use of void operator.
  85112. * @author Mike Sidorov
  85113. */
  85114. "use strict";
  85115. //------------------------------------------------------------------------------
  85116. // Rule Definition
  85117. //------------------------------------------------------------------------------
  85118. module.exports = {
  85119. meta: {
  85120. type: "suggestion",
  85121. docs: {
  85122. description: "disallow `void` operators",
  85123. category: "Best Practices",
  85124. recommended: false,
  85125. url: "https://eslint.org/docs/rules/no-void"
  85126. },
  85127. schema: []
  85128. },
  85129. create: function create(context) {
  85130. //--------------------------------------------------------------------------
  85131. // Public
  85132. //--------------------------------------------------------------------------
  85133. return {
  85134. UnaryExpression: function UnaryExpression(node) {
  85135. if (node.operator === "void") {
  85136. context.report({ node: node, message: "Expected 'undefined' and instead saw 'void'." });
  85137. }
  85138. }
  85139. };
  85140. }
  85141. };
  85142. },{}],331:[function(require,module,exports){
  85143. /**
  85144. * @fileoverview Rule that warns about used warning comments
  85145. * @author Alexander Schmidt <https://github.com/lxanders>
  85146. */
  85147. "use strict";
  85148. var astUtils = require("../util/ast-utils");
  85149. //------------------------------------------------------------------------------
  85150. // Rule Definition
  85151. //------------------------------------------------------------------------------
  85152. module.exports = {
  85153. meta: {
  85154. type: "suggestion",
  85155. docs: {
  85156. description: "disallow specified warning terms in comments",
  85157. category: "Best Practices",
  85158. recommended: false,
  85159. url: "https://eslint.org/docs/rules/no-warning-comments"
  85160. },
  85161. schema: [{
  85162. type: "object",
  85163. properties: {
  85164. terms: {
  85165. type: "array",
  85166. items: {
  85167. type: "string"
  85168. }
  85169. },
  85170. location: {
  85171. enum: ["start", "anywhere"]
  85172. }
  85173. },
  85174. additionalProperties: false
  85175. }]
  85176. },
  85177. create: function create(context) {
  85178. var sourceCode = context.getSourceCode(),
  85179. configuration = context.options[0] || {},
  85180. warningTerms = configuration.terms || ["todo", "fixme", "xxx"],
  85181. location = configuration.location || "start",
  85182. selfConfigRegEx = /\bno-warning-comments\b/;
  85183. /**
  85184. * Convert a warning term into a RegExp which will match a comment containing that whole word in the specified
  85185. * location ("start" or "anywhere"). If the term starts or ends with non word characters, then the match will not
  85186. * require word boundaries on that side.
  85187. *
  85188. * @param {string} term A term to convert to a RegExp
  85189. * @returns {RegExp} The term converted to a RegExp
  85190. */
  85191. function convertToRegExp(term) {
  85192. var escaped = term.replace(/[-/\\$^*+?.()|[\]{}]/g, "\\$&");
  85193. var wordBoundary = "\\b";
  85194. var eitherOrWordBoundary = "|" + wordBoundary;
  85195. var prefix = void 0;
  85196. /*
  85197. * If the term ends in a word character (a-z0-9_), ensure a word
  85198. * boundary at the end, so that substrings do not get falsely
  85199. * matched. eg "todo" in a string such as "mastodon".
  85200. * If the term ends in a non-word character, then \b won't match on
  85201. * the boundary to the next non-word character, which would likely
  85202. * be a space. For example `/\bFIX!\b/.test('FIX! blah') === false`.
  85203. * In these cases, use no bounding match. Same applies for the
  85204. * prefix, handled below.
  85205. */
  85206. var suffix = /\w$/.test(term) ? "\\b" : "";
  85207. if (location === "start") {
  85208. /*
  85209. * When matching at the start, ignore leading whitespace, and
  85210. * there's no need to worry about word boundaries.
  85211. */
  85212. prefix = "^\\s*";
  85213. } else if (/^\w/.test(term)) {
  85214. prefix = wordBoundary;
  85215. } else {
  85216. prefix = "";
  85217. }
  85218. if (location === "start") {
  85219. /*
  85220. * For location "start" the regex should be
  85221. * ^\s*TERM\b. This checks the word boundary
  85222. * at the beginning of the comment.
  85223. */
  85224. return new RegExp(prefix + escaped + suffix, "i");
  85225. }
  85226. /*
  85227. * For location "anywhere" the regex should be
  85228. * \bTERM\b|\bTERM\b, this checks the entire comment
  85229. * for the term.
  85230. */
  85231. return new RegExp(prefix + escaped + suffix + eitherOrWordBoundary + term + wordBoundary, "i");
  85232. }
  85233. var warningRegExps = warningTerms.map(convertToRegExp);
  85234. /**
  85235. * Checks the specified comment for matches of the configured warning terms and returns the matches.
  85236. * @param {string} comment The comment which is checked.
  85237. * @returns {Array} All matched warning terms for this comment.
  85238. */
  85239. function commentContainsWarningTerm(comment) {
  85240. var matches = [];
  85241. warningRegExps.forEach(function (regex, index) {
  85242. if (regex.test(comment)) {
  85243. matches.push(warningTerms[index]);
  85244. }
  85245. });
  85246. return matches;
  85247. }
  85248. /**
  85249. * Checks the specified node for matching warning comments and reports them.
  85250. * @param {ASTNode} node The AST node being checked.
  85251. * @returns {void} undefined.
  85252. */
  85253. function checkComment(node) {
  85254. if (astUtils.isDirectiveComment(node) && selfConfigRegEx.test(node.value)) {
  85255. return;
  85256. }
  85257. var matches = commentContainsWarningTerm(node.value);
  85258. matches.forEach(function (matchedTerm) {
  85259. context.report({
  85260. node: node,
  85261. message: "Unexpected '{{matchedTerm}}' comment.",
  85262. data: {
  85263. matchedTerm: matchedTerm
  85264. }
  85265. });
  85266. });
  85267. }
  85268. return {
  85269. Program: function Program() {
  85270. var comments = sourceCode.getAllComments();
  85271. comments.filter(function (token) {
  85272. return token.type !== "Shebang";
  85273. }).forEach(checkComment);
  85274. }
  85275. };
  85276. }
  85277. };
  85278. },{"../util/ast-utils":405}],332:[function(require,module,exports){
  85279. /**
  85280. * @fileoverview Rule to disallow whitespace before properties
  85281. * @author Kai Cataldo
  85282. */
  85283. "use strict";
  85284. //------------------------------------------------------------------------------
  85285. // Requirements
  85286. //------------------------------------------------------------------------------
  85287. var astUtils = require("../util/ast-utils");
  85288. //------------------------------------------------------------------------------
  85289. // Rule Definition
  85290. //------------------------------------------------------------------------------
  85291. module.exports = {
  85292. meta: {
  85293. type: "layout",
  85294. docs: {
  85295. description: "disallow whitespace before properties",
  85296. category: "Stylistic Issues",
  85297. recommended: false,
  85298. url: "https://eslint.org/docs/rules/no-whitespace-before-property"
  85299. },
  85300. fixable: "whitespace",
  85301. schema: []
  85302. },
  85303. create: function create(context) {
  85304. var sourceCode = context.getSourceCode();
  85305. //--------------------------------------------------------------------------
  85306. // Helpers
  85307. //--------------------------------------------------------------------------
  85308. /**
  85309. * Reports whitespace before property token
  85310. * @param {ASTNode} node - the node to report in the event of an error
  85311. * @param {Token} leftToken - the left token
  85312. * @param {Token} rightToken - the right token
  85313. * @returns {void}
  85314. * @private
  85315. */
  85316. function reportError(node, leftToken, rightToken) {
  85317. var replacementText = node.computed ? "" : ".";
  85318. context.report({
  85319. node: node,
  85320. message: "Unexpected whitespace before property {{propName}}.",
  85321. data: {
  85322. propName: sourceCode.getText(node.property)
  85323. },
  85324. fix: function fix(fixer) {
  85325. if (!node.computed && astUtils.isDecimalInteger(node.object)) {
  85326. /*
  85327. * If the object is a number literal, fixing it to something like 5.toString() would cause a SyntaxError.
  85328. * Don't fix this case.
  85329. */
  85330. return null;
  85331. }
  85332. return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], replacementText);
  85333. }
  85334. });
  85335. }
  85336. //--------------------------------------------------------------------------
  85337. // Public
  85338. //--------------------------------------------------------------------------
  85339. return {
  85340. MemberExpression: function MemberExpression(node) {
  85341. var rightToken = void 0;
  85342. var leftToken = void 0;
  85343. if (!astUtils.isTokenOnSameLine(node.object, node.property)) {
  85344. return;
  85345. }
  85346. if (node.computed) {
  85347. rightToken = sourceCode.getTokenBefore(node.property, astUtils.isOpeningBracketToken);
  85348. leftToken = sourceCode.getTokenBefore(rightToken);
  85349. } else {
  85350. rightToken = sourceCode.getFirstToken(node.property);
  85351. leftToken = sourceCode.getTokenBefore(rightToken, 1);
  85352. }
  85353. if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken)) {
  85354. reportError(node, leftToken, rightToken);
  85355. }
  85356. }
  85357. };
  85358. }
  85359. };
  85360. },{"../util/ast-utils":405}],333:[function(require,module,exports){
  85361. /**
  85362. * @fileoverview Rule to flag use of with statement
  85363. * @author Nicholas C. Zakas
  85364. */
  85365. "use strict";
  85366. //------------------------------------------------------------------------------
  85367. // Rule Definition
  85368. //------------------------------------------------------------------------------
  85369. module.exports = {
  85370. meta: {
  85371. type: "suggestion",
  85372. docs: {
  85373. description: "disallow `with` statements",
  85374. category: "Best Practices",
  85375. recommended: false,
  85376. url: "https://eslint.org/docs/rules/no-with"
  85377. },
  85378. schema: []
  85379. },
  85380. create: function create(context) {
  85381. return {
  85382. WithStatement: function WithStatement(node) {
  85383. context.report({ node: node, message: "Unexpected use of 'with' statement." });
  85384. }
  85385. };
  85386. }
  85387. };
  85388. },{}],334:[function(require,module,exports){
  85389. /**
  85390. * @fileoverview enforce the location of single-line statements
  85391. * @author Teddy Katz
  85392. */
  85393. "use strict";
  85394. //------------------------------------------------------------------------------
  85395. // Rule Definition
  85396. //------------------------------------------------------------------------------
  85397. var POSITION_SCHEMA = { enum: ["beside", "below", "any"] };
  85398. module.exports = {
  85399. meta: {
  85400. type: "layout",
  85401. docs: {
  85402. description: "enforce the location of single-line statements",
  85403. category: "Stylistic Issues",
  85404. recommended: false,
  85405. url: "https://eslint.org/docs/rules/nonblock-statement-body-position"
  85406. },
  85407. fixable: "whitespace",
  85408. schema: [POSITION_SCHEMA, {
  85409. properties: {
  85410. overrides: {
  85411. properties: {
  85412. if: POSITION_SCHEMA,
  85413. else: POSITION_SCHEMA,
  85414. while: POSITION_SCHEMA,
  85415. do: POSITION_SCHEMA,
  85416. for: POSITION_SCHEMA
  85417. },
  85418. additionalProperties: false
  85419. }
  85420. },
  85421. additionalProperties: false
  85422. }]
  85423. },
  85424. create: function create(context) {
  85425. var sourceCode = context.getSourceCode();
  85426. //----------------------------------------------------------------------
  85427. // Helpers
  85428. //----------------------------------------------------------------------
  85429. /**
  85430. * Gets the applicable preference for a particular keyword
  85431. * @param {string} keywordName The name of a keyword, e.g. 'if'
  85432. * @returns {string} The applicable option for the keyword, e.g. 'beside'
  85433. */
  85434. function getOption(keywordName) {
  85435. return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] || context.options[0] || "beside";
  85436. }
  85437. /**
  85438. * Validates the location of a single-line statement
  85439. * @param {ASTNode} node The single-line statement
  85440. * @param {string} keywordName The applicable keyword name for the single-line statement
  85441. * @returns {void}
  85442. */
  85443. function validateStatement(node, keywordName) {
  85444. var option = getOption(keywordName);
  85445. if (node.type === "BlockStatement" || option === "any") {
  85446. return;
  85447. }
  85448. var tokenBefore = sourceCode.getTokenBefore(node);
  85449. if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") {
  85450. context.report({
  85451. node: node,
  85452. message: "Expected a linebreak before this statement.",
  85453. fix: function fix(fixer) {
  85454. return fixer.insertTextBefore(node, "\n");
  85455. }
  85456. });
  85457. } else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") {
  85458. context.report({
  85459. node: node,
  85460. message: "Expected no linebreak before this statement.",
  85461. fix: function fix(fixer) {
  85462. if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim()) {
  85463. return null;
  85464. }
  85465. return fixer.replaceTextRange([tokenBefore.range[1], node.range[0]], " ");
  85466. }
  85467. });
  85468. }
  85469. }
  85470. //----------------------------------------------------------------------
  85471. // Public
  85472. //----------------------------------------------------------------------
  85473. return {
  85474. IfStatement: function IfStatement(node) {
  85475. validateStatement(node.consequent, "if");
  85476. // Check the `else` node, but don't check 'else if' statements.
  85477. if (node.alternate && node.alternate.type !== "IfStatement") {
  85478. validateStatement(node.alternate, "else");
  85479. }
  85480. },
  85481. WhileStatement: function WhileStatement(node) {
  85482. return validateStatement(node.body, "while");
  85483. },
  85484. DoWhileStatement: function DoWhileStatement(node) {
  85485. return validateStatement(node.body, "do");
  85486. },
  85487. ForStatement: function ForStatement(node) {
  85488. return validateStatement(node.body, "for");
  85489. },
  85490. ForInStatement: function ForInStatement(node) {
  85491. return validateStatement(node.body, "for");
  85492. },
  85493. ForOfStatement: function ForOfStatement(node) {
  85494. return validateStatement(node.body, "for");
  85495. }
  85496. };
  85497. }
  85498. };
  85499. },{}],335:[function(require,module,exports){
  85500. /**
  85501. * @fileoverview Rule to require or disallow line breaks inside braces.
  85502. * @author Toru Nagashima
  85503. */
  85504. "use strict";
  85505. //------------------------------------------------------------------------------
  85506. // Requirements
  85507. //------------------------------------------------------------------------------
  85508. var astUtils = require("../util/ast-utils");
  85509. var lodash = require("lodash");
  85510. //------------------------------------------------------------------------------
  85511. // Helpers
  85512. //------------------------------------------------------------------------------
  85513. // Schema objects.
  85514. var OPTION_VALUE = {
  85515. oneOf: [{
  85516. enum: ["always", "never"]
  85517. }, {
  85518. type: "object",
  85519. properties: {
  85520. multiline: {
  85521. type: "boolean"
  85522. },
  85523. minProperties: {
  85524. type: "integer",
  85525. minimum: 0
  85526. },
  85527. consistent: {
  85528. type: "boolean"
  85529. }
  85530. },
  85531. additionalProperties: false,
  85532. minProperties: 1
  85533. }]
  85534. };
  85535. /**
  85536. * Normalizes a given option value.
  85537. *
  85538. * @param {string|Object|undefined} value - An option value to parse.
  85539. * @returns {{multiline: boolean, minProperties: number, consistent: boolean}} Normalized option object.
  85540. */
  85541. function normalizeOptionValue(value) {
  85542. var multiline = false;
  85543. var minProperties = Number.POSITIVE_INFINITY;
  85544. var consistent = false;
  85545. if (value) {
  85546. if (value === "always") {
  85547. minProperties = 0;
  85548. } else if (value === "never") {
  85549. minProperties = Number.POSITIVE_INFINITY;
  85550. } else {
  85551. multiline = Boolean(value.multiline);
  85552. minProperties = value.minProperties || Number.POSITIVE_INFINITY;
  85553. consistent = Boolean(value.consistent);
  85554. }
  85555. } else {
  85556. consistent = true;
  85557. }
  85558. return { multiline: multiline, minProperties: minProperties, consistent: consistent };
  85559. }
  85560. /**
  85561. * Normalizes a given option value.
  85562. *
  85563. * @param {string|Object|undefined} options - An option value to parse.
  85564. * @returns {{
  85565. * ObjectExpression: {multiline: boolean, minProperties: number, consistent: boolean},
  85566. * ObjectPattern: {multiline: boolean, minProperties: number, consistent: boolean},
  85567. * ImportDeclaration: {multiline: boolean, minProperties: number, consistent: boolean},
  85568. * ExportNamedDeclaration : {multiline: boolean, minProperties: number, consistent: boolean}
  85569. * }} Normalized option object.
  85570. */
  85571. function normalizeOptions(options) {
  85572. var isNodeSpecificOption = lodash.overSome([lodash.isPlainObject, lodash.isString]);
  85573. if (lodash.isPlainObject(options) && lodash.some(options, isNodeSpecificOption)) {
  85574. return {
  85575. ObjectExpression: normalizeOptionValue(options.ObjectExpression),
  85576. ObjectPattern: normalizeOptionValue(options.ObjectPattern),
  85577. ImportDeclaration: normalizeOptionValue(options.ImportDeclaration),
  85578. ExportNamedDeclaration: normalizeOptionValue(options.ExportDeclaration)
  85579. };
  85580. }
  85581. var value = normalizeOptionValue(options);
  85582. return { ObjectExpression: value, ObjectPattern: value, ImportDeclaration: value, ExportNamedDeclaration: value };
  85583. }
  85584. /**
  85585. * Determines if ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration
  85586. * node needs to be checked for missing line breaks
  85587. *
  85588. * @param {ASTNode} node - Node under inspection
  85589. * @param {Object} options - option specific to node type
  85590. * @param {Token} first - First object property
  85591. * @param {Token} last - Last object property
  85592. * @returns {boolean} `true` if node needs to be checked for missing line breaks
  85593. */
  85594. function areLineBreaksRequired(node, options, first, last) {
  85595. var objectProperties = void 0;
  85596. if (node.type === "ObjectExpression" || node.type === "ObjectPattern") {
  85597. objectProperties = node.properties;
  85598. } else {
  85599. // is ImportDeclaration or ExportNamedDeclaration
  85600. objectProperties = node.specifiers.filter(function (s) {
  85601. return s.type === "ImportSpecifier" || s.type === "ExportSpecifier";
  85602. });
  85603. }
  85604. return objectProperties.length >= options.minProperties || options.multiline && objectProperties.length > 0 && first.loc.start.line !== last.loc.end.line;
  85605. }
  85606. //------------------------------------------------------------------------------
  85607. // Rule Definition
  85608. //------------------------------------------------------------------------------
  85609. module.exports = {
  85610. meta: {
  85611. type: "layout",
  85612. docs: {
  85613. description: "enforce consistent line breaks inside braces",
  85614. category: "Stylistic Issues",
  85615. recommended: false,
  85616. url: "https://eslint.org/docs/rules/object-curly-newline"
  85617. },
  85618. fixable: "whitespace",
  85619. schema: [{
  85620. oneOf: [OPTION_VALUE, {
  85621. type: "object",
  85622. properties: {
  85623. ObjectExpression: OPTION_VALUE,
  85624. ObjectPattern: OPTION_VALUE,
  85625. ImportDeclaration: OPTION_VALUE,
  85626. ExportDeclaration: OPTION_VALUE
  85627. },
  85628. additionalProperties: false,
  85629. minProperties: 1
  85630. }]
  85631. }]
  85632. },
  85633. create: function create(context) {
  85634. var sourceCode = context.getSourceCode();
  85635. var normalizedOptions = normalizeOptions(context.options[0]);
  85636. /**
  85637. * Reports a given node if it violated this rule.
  85638. * @param {ASTNode} node - A node to check. This is an ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration node.
  85639. * @returns {void}
  85640. */
  85641. function check(node) {
  85642. var options = normalizedOptions[node.type];
  85643. if (node.type === "ImportDeclaration" && !node.specifiers.some(function (specifier) {
  85644. return specifier.type === "ImportSpecifier";
  85645. }) || node.type === "ExportNamedDeclaration" && !node.specifiers.some(function (specifier) {
  85646. return specifier.type === "ExportSpecifier";
  85647. })) {
  85648. return;
  85649. }
  85650. var openBrace = sourceCode.getFirstToken(node, function (token) {
  85651. return token.value === "{";
  85652. });
  85653. var closeBrace = void 0;
  85654. if (node.typeAnnotation) {
  85655. closeBrace = sourceCode.getTokenBefore(node.typeAnnotation);
  85656. } else {
  85657. closeBrace = sourceCode.getLastToken(node, function (token) {
  85658. return token.value === "}";
  85659. });
  85660. }
  85661. var first = sourceCode.getTokenAfter(openBrace, { includeComments: true });
  85662. var last = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
  85663. var needsLineBreaks = areLineBreaksRequired(node, options, first, last);
  85664. var hasCommentsFirstToken = astUtils.isCommentToken(first);
  85665. var hasCommentsLastToken = astUtils.isCommentToken(last);
  85666. /*
  85667. * Use tokens or comments to check multiline or not.
  85668. * But use only tokens to check whether line breaks are needed.
  85669. * This allows:
  85670. * var obj = { // eslint-disable-line foo
  85671. * a: 1
  85672. * }
  85673. */
  85674. first = sourceCode.getTokenAfter(openBrace);
  85675. last = sourceCode.getTokenBefore(closeBrace);
  85676. if (needsLineBreaks) {
  85677. if (astUtils.isTokenOnSameLine(openBrace, first)) {
  85678. context.report({
  85679. message: "Expected a line break after this opening brace.",
  85680. node: node,
  85681. loc: openBrace.loc.start,
  85682. fix: function fix(fixer) {
  85683. if (hasCommentsFirstToken) {
  85684. return null;
  85685. }
  85686. return fixer.insertTextAfter(openBrace, "\n");
  85687. }
  85688. });
  85689. }
  85690. if (astUtils.isTokenOnSameLine(last, closeBrace)) {
  85691. context.report({
  85692. message: "Expected a line break before this closing brace.",
  85693. node: node,
  85694. loc: closeBrace.loc.start,
  85695. fix: function fix(fixer) {
  85696. if (hasCommentsLastToken) {
  85697. return null;
  85698. }
  85699. return fixer.insertTextBefore(closeBrace, "\n");
  85700. }
  85701. });
  85702. }
  85703. } else {
  85704. var consistent = options.consistent;
  85705. var hasLineBreakBetweenOpenBraceAndFirst = !astUtils.isTokenOnSameLine(openBrace, first);
  85706. var hasLineBreakBetweenCloseBraceAndLast = !astUtils.isTokenOnSameLine(last, closeBrace);
  85707. if (!consistent && hasLineBreakBetweenOpenBraceAndFirst || consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) {
  85708. context.report({
  85709. message: "Unexpected line break after this opening brace.",
  85710. node: node,
  85711. loc: openBrace.loc.start,
  85712. fix: function fix(fixer) {
  85713. if (hasCommentsFirstToken) {
  85714. return null;
  85715. }
  85716. return fixer.removeRange([openBrace.range[1], first.range[0]]);
  85717. }
  85718. });
  85719. }
  85720. if (!consistent && hasLineBreakBetweenCloseBraceAndLast || consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) {
  85721. context.report({
  85722. message: "Unexpected line break before this closing brace.",
  85723. node: node,
  85724. loc: closeBrace.loc.start,
  85725. fix: function fix(fixer) {
  85726. if (hasCommentsLastToken) {
  85727. return null;
  85728. }
  85729. return fixer.removeRange([last.range[1], closeBrace.range[0]]);
  85730. }
  85731. });
  85732. }
  85733. }
  85734. }
  85735. return {
  85736. ObjectExpression: check,
  85737. ObjectPattern: check,
  85738. ImportDeclaration: check,
  85739. ExportNamedDeclaration: check
  85740. };
  85741. }
  85742. };
  85743. },{"../util/ast-utils":405,"lodash":92}],336:[function(require,module,exports){
  85744. /**
  85745. * @fileoverview Disallows or enforces spaces inside of object literals.
  85746. * @author Jamund Ferguson
  85747. */
  85748. "use strict";
  85749. var astUtils = require("../util/ast-utils");
  85750. //------------------------------------------------------------------------------
  85751. // Rule Definition
  85752. //------------------------------------------------------------------------------
  85753. module.exports = {
  85754. meta: {
  85755. type: "layout",
  85756. docs: {
  85757. description: "enforce consistent spacing inside braces",
  85758. category: "Stylistic Issues",
  85759. recommended: false,
  85760. url: "https://eslint.org/docs/rules/object-curly-spacing"
  85761. },
  85762. fixable: "whitespace",
  85763. schema: [{
  85764. enum: ["always", "never"]
  85765. }, {
  85766. type: "object",
  85767. properties: {
  85768. arraysInObjects: {
  85769. type: "boolean"
  85770. },
  85771. objectsInObjects: {
  85772. type: "boolean"
  85773. }
  85774. },
  85775. additionalProperties: false
  85776. }]
  85777. },
  85778. create: function create(context) {
  85779. var spaced = context.options[0] === "always",
  85780. sourceCode = context.getSourceCode();
  85781. /**
  85782. * Determines whether an option is set, relative to the spacing option.
  85783. * If spaced is "always", then check whether option is set to false.
  85784. * If spaced is "never", then check whether option is set to true.
  85785. * @param {Object} option - The option to exclude.
  85786. * @returns {boolean} Whether or not the property is excluded.
  85787. */
  85788. function isOptionSet(option) {
  85789. return context.options[1] ? context.options[1][option] === !spaced : false;
  85790. }
  85791. var options = {
  85792. spaced: spaced,
  85793. arraysInObjectsException: isOptionSet("arraysInObjects"),
  85794. objectsInObjectsException: isOptionSet("objectsInObjects")
  85795. };
  85796. //--------------------------------------------------------------------------
  85797. // Helpers
  85798. //--------------------------------------------------------------------------
  85799. /**
  85800. * Reports that there shouldn't be a space after the first token
  85801. * @param {ASTNode} node - The node to report in the event of an error.
  85802. * @param {Token} token - The token to use for the report.
  85803. * @returns {void}
  85804. */
  85805. function reportNoBeginningSpace(node, token) {
  85806. context.report({
  85807. node: node,
  85808. loc: token.loc.start,
  85809. message: "There should be no space after '{{token}}'.",
  85810. data: {
  85811. token: token.value
  85812. },
  85813. fix: function fix(fixer) {
  85814. var nextToken = context.getSourceCode().getTokenAfter(token);
  85815. return fixer.removeRange([token.range[1], nextToken.range[0]]);
  85816. }
  85817. });
  85818. }
  85819. /**
  85820. * Reports that there shouldn't be a space before the last token
  85821. * @param {ASTNode} node - The node to report in the event of an error.
  85822. * @param {Token} token - The token to use for the report.
  85823. * @returns {void}
  85824. */
  85825. function reportNoEndingSpace(node, token) {
  85826. context.report({
  85827. node: node,
  85828. loc: token.loc.start,
  85829. message: "There should be no space before '{{token}}'.",
  85830. data: {
  85831. token: token.value
  85832. },
  85833. fix: function fix(fixer) {
  85834. var previousToken = context.getSourceCode().getTokenBefore(token);
  85835. return fixer.removeRange([previousToken.range[1], token.range[0]]);
  85836. }
  85837. });
  85838. }
  85839. /**
  85840. * Reports that there should be a space after the first token
  85841. * @param {ASTNode} node - The node to report in the event of an error.
  85842. * @param {Token} token - The token to use for the report.
  85843. * @returns {void}
  85844. */
  85845. function reportRequiredBeginningSpace(node, token) {
  85846. context.report({
  85847. node: node,
  85848. loc: token.loc.start,
  85849. message: "A space is required after '{{token}}'.",
  85850. data: {
  85851. token: token.value
  85852. },
  85853. fix: function fix(fixer) {
  85854. return fixer.insertTextAfter(token, " ");
  85855. }
  85856. });
  85857. }
  85858. /**
  85859. * Reports that there should be a space before the last token
  85860. * @param {ASTNode} node - The node to report in the event of an error.
  85861. * @param {Token} token - The token to use for the report.
  85862. * @returns {void}
  85863. */
  85864. function reportRequiredEndingSpace(node, token) {
  85865. context.report({
  85866. node: node,
  85867. loc: token.loc.start,
  85868. message: "A space is required before '{{token}}'.",
  85869. data: {
  85870. token: token.value
  85871. },
  85872. fix: function fix(fixer) {
  85873. return fixer.insertTextBefore(token, " ");
  85874. }
  85875. });
  85876. }
  85877. /**
  85878. * Determines if spacing in curly braces is valid.
  85879. * @param {ASTNode} node The AST node to check.
  85880. * @param {Token} first The first token to check (should be the opening brace)
  85881. * @param {Token} second The second token to check (should be first after the opening brace)
  85882. * @param {Token} penultimate The penultimate token to check (should be last before closing brace)
  85883. * @param {Token} last The last token to check (should be closing brace)
  85884. * @returns {void}
  85885. */
  85886. function validateBraceSpacing(node, first, second, penultimate, last) {
  85887. if (astUtils.isTokenOnSameLine(first, second)) {
  85888. var firstSpaced = sourceCode.isSpaceBetweenTokens(first, second);
  85889. if (options.spaced && !firstSpaced) {
  85890. reportRequiredBeginningSpace(node, first);
  85891. }
  85892. if (!options.spaced && firstSpaced) {
  85893. reportNoBeginningSpace(node, first);
  85894. }
  85895. }
  85896. if (astUtils.isTokenOnSameLine(penultimate, last)) {
  85897. var shouldCheckPenultimate = options.arraysInObjectsException && astUtils.isClosingBracketToken(penultimate) || options.objectsInObjectsException && astUtils.isClosingBraceToken(penultimate);
  85898. var penultimateType = shouldCheckPenultimate && sourceCode.getNodeByRangeIndex(penultimate.range[0]).type;
  85899. var closingCurlyBraceMustBeSpaced = options.arraysInObjectsException && penultimateType === "ArrayExpression" || options.objectsInObjectsException && (penultimateType === "ObjectExpression" || penultimateType === "ObjectPattern") ? !options.spaced : options.spaced;
  85900. var lastSpaced = sourceCode.isSpaceBetweenTokens(penultimate, last);
  85901. if (closingCurlyBraceMustBeSpaced && !lastSpaced) {
  85902. reportRequiredEndingSpace(node, last);
  85903. }
  85904. if (!closingCurlyBraceMustBeSpaced && lastSpaced) {
  85905. reportNoEndingSpace(node, last);
  85906. }
  85907. }
  85908. }
  85909. /**
  85910. * Gets '}' token of an object node.
  85911. *
  85912. * Because the last token of object patterns might be a type annotation,
  85913. * this traverses tokens preceded by the last property, then returns the
  85914. * first '}' token.
  85915. *
  85916. * @param {ASTNode} node - The node to get. This node is an
  85917. * ObjectExpression or an ObjectPattern. And this node has one or
  85918. * more properties.
  85919. * @returns {Token} '}' token.
  85920. */
  85921. function getClosingBraceOfObject(node) {
  85922. var lastProperty = node.properties[node.properties.length - 1];
  85923. return sourceCode.getTokenAfter(lastProperty, astUtils.isClosingBraceToken);
  85924. }
  85925. /**
  85926. * Reports a given object node if spacing in curly braces is invalid.
  85927. * @param {ASTNode} node - An ObjectExpression or ObjectPattern node to check.
  85928. * @returns {void}
  85929. */
  85930. function checkForObject(node) {
  85931. if (node.properties.length === 0) {
  85932. return;
  85933. }
  85934. var first = sourceCode.getFirstToken(node),
  85935. last = getClosingBraceOfObject(node),
  85936. second = sourceCode.getTokenAfter(first),
  85937. penultimate = sourceCode.getTokenBefore(last);
  85938. validateBraceSpacing(node, first, second, penultimate, last);
  85939. }
  85940. /**
  85941. * Reports a given import node if spacing in curly braces is invalid.
  85942. * @param {ASTNode} node - An ImportDeclaration node to check.
  85943. * @returns {void}
  85944. */
  85945. function checkForImport(node) {
  85946. if (node.specifiers.length === 0) {
  85947. return;
  85948. }
  85949. var firstSpecifier = node.specifiers[0];
  85950. var lastSpecifier = node.specifiers[node.specifiers.length - 1];
  85951. if (lastSpecifier.type !== "ImportSpecifier") {
  85952. return;
  85953. }
  85954. if (firstSpecifier.type !== "ImportSpecifier") {
  85955. firstSpecifier = node.specifiers[1];
  85956. }
  85957. var first = sourceCode.getTokenBefore(firstSpecifier),
  85958. last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken),
  85959. second = sourceCode.getTokenAfter(first),
  85960. penultimate = sourceCode.getTokenBefore(last);
  85961. validateBraceSpacing(node, first, second, penultimate, last);
  85962. }
  85963. /**
  85964. * Reports a given export node if spacing in curly braces is invalid.
  85965. * @param {ASTNode} node - An ExportNamedDeclaration node to check.
  85966. * @returns {void}
  85967. */
  85968. function checkForExport(node) {
  85969. if (node.specifiers.length === 0) {
  85970. return;
  85971. }
  85972. var firstSpecifier = node.specifiers[0],
  85973. lastSpecifier = node.specifiers[node.specifiers.length - 1],
  85974. first = sourceCode.getTokenBefore(firstSpecifier),
  85975. last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken),
  85976. second = sourceCode.getTokenAfter(first),
  85977. penultimate = sourceCode.getTokenBefore(last);
  85978. validateBraceSpacing(node, first, second, penultimate, last);
  85979. }
  85980. //--------------------------------------------------------------------------
  85981. // Public
  85982. //--------------------------------------------------------------------------
  85983. return {
  85984. // var {x} = y;
  85985. ObjectPattern: checkForObject,
  85986. // var y = {x: 'y'}
  85987. ObjectExpression: checkForObject,
  85988. // import {y} from 'x';
  85989. ImportDeclaration: checkForImport,
  85990. // export {name} from 'yo';
  85991. ExportNamedDeclaration: checkForExport
  85992. };
  85993. }
  85994. };
  85995. },{"../util/ast-utils":405}],337:[function(require,module,exports){
  85996. /**
  85997. * @fileoverview Rule to enforce placing object properties on separate lines.
  85998. * @author Vitor Balocco
  85999. */
  86000. "use strict";
  86001. //------------------------------------------------------------------------------
  86002. // Rule Definition
  86003. //------------------------------------------------------------------------------
  86004. module.exports = {
  86005. meta: {
  86006. type: "layout",
  86007. docs: {
  86008. description: "enforce placing object properties on separate lines",
  86009. category: "Stylistic Issues",
  86010. recommended: false,
  86011. url: "https://eslint.org/docs/rules/object-property-newline"
  86012. },
  86013. schema: [{
  86014. type: "object",
  86015. properties: {
  86016. allowAllPropertiesOnSameLine: {
  86017. type: "boolean"
  86018. },
  86019. allowMultiplePropertiesPerLine: { // Deprecated
  86020. type: "boolean"
  86021. }
  86022. },
  86023. additionalProperties: false
  86024. }],
  86025. fixable: "whitespace"
  86026. },
  86027. create: function create(context) {
  86028. var allowSameLine = context.options[0] && (Boolean(context.options[0].allowAllPropertiesOnSameLine) || Boolean(context.options[0].allowMultiplePropertiesPerLine));
  86029. var errorMessage = allowSameLine ? "Object properties must go on a new line if they aren't all on the same line." : "Object properties must go on a new line.";
  86030. var sourceCode = context.getSourceCode();
  86031. return {
  86032. ObjectExpression: function ObjectExpression(node) {
  86033. if (allowSameLine) {
  86034. if (node.properties.length > 1) {
  86035. var firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]);
  86036. var lastTokenOfLastProperty = sourceCode.getLastToken(node.properties[node.properties.length - 1]);
  86037. if (firstTokenOfFirstProperty.loc.end.line === lastTokenOfLastProperty.loc.start.line) {
  86038. // All keys and values are on the same line
  86039. return;
  86040. }
  86041. }
  86042. }
  86043. var _loop = function _loop(i) {
  86044. var lastTokenOfPreviousProperty = sourceCode.getLastToken(node.properties[i - 1]);
  86045. var firstTokenOfCurrentProperty = sourceCode.getFirstToken(node.properties[i]);
  86046. if (lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line) {
  86047. context.report({
  86048. node: node,
  86049. loc: firstTokenOfCurrentProperty.loc.start,
  86050. message: errorMessage,
  86051. fix: function fix(fixer) {
  86052. var comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty);
  86053. var rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]];
  86054. // Don't perform a fix if there are any comments between the comma and the next property.
  86055. if (sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim()) {
  86056. return null;
  86057. }
  86058. return fixer.replaceTextRange(rangeAfterComma, "\n");
  86059. }
  86060. });
  86061. }
  86062. };
  86063. for (var i = 1; i < node.properties.length; i++) {
  86064. _loop(i);
  86065. }
  86066. }
  86067. };
  86068. }
  86069. };
  86070. },{}],338:[function(require,module,exports){
  86071. /**
  86072. * @fileoverview Rule to enforce concise object methods and properties.
  86073. * @author Jamund Ferguson
  86074. */
  86075. "use strict";
  86076. var OPTIONS = {
  86077. always: "always",
  86078. never: "never",
  86079. methods: "methods",
  86080. properties: "properties",
  86081. consistent: "consistent",
  86082. consistentAsNeeded: "consistent-as-needed"
  86083. };
  86084. //------------------------------------------------------------------------------
  86085. // Requirements
  86086. //------------------------------------------------------------------------------
  86087. var astUtils = require("../util/ast-utils");
  86088. //------------------------------------------------------------------------------
  86089. // Rule Definition
  86090. //------------------------------------------------------------------------------
  86091. module.exports = {
  86092. meta: {
  86093. type: "suggestion",
  86094. docs: {
  86095. description: "require or disallow method and property shorthand syntax for object literals",
  86096. category: "ECMAScript 6",
  86097. recommended: false,
  86098. url: "https://eslint.org/docs/rules/object-shorthand"
  86099. },
  86100. fixable: "code",
  86101. schema: {
  86102. anyOf: [{
  86103. type: "array",
  86104. items: [{
  86105. enum: ["always", "methods", "properties", "never", "consistent", "consistent-as-needed"]
  86106. }],
  86107. minItems: 0,
  86108. maxItems: 1
  86109. }, {
  86110. type: "array",
  86111. items: [{
  86112. enum: ["always", "methods", "properties"]
  86113. }, {
  86114. type: "object",
  86115. properties: {
  86116. avoidQuotes: {
  86117. type: "boolean"
  86118. }
  86119. },
  86120. additionalProperties: false
  86121. }],
  86122. minItems: 0,
  86123. maxItems: 2
  86124. }, {
  86125. type: "array",
  86126. items: [{
  86127. enum: ["always", "methods"]
  86128. }, {
  86129. type: "object",
  86130. properties: {
  86131. ignoreConstructors: {
  86132. type: "boolean"
  86133. },
  86134. avoidQuotes: {
  86135. type: "boolean"
  86136. },
  86137. avoidExplicitReturnArrows: {
  86138. type: "boolean"
  86139. }
  86140. },
  86141. additionalProperties: false
  86142. }],
  86143. minItems: 0,
  86144. maxItems: 2
  86145. }]
  86146. }
  86147. },
  86148. create: function create(context) {
  86149. var APPLY = context.options[0] || OPTIONS.always;
  86150. var APPLY_TO_METHODS = APPLY === OPTIONS.methods || APPLY === OPTIONS.always;
  86151. var APPLY_TO_PROPS = APPLY === OPTIONS.properties || APPLY === OPTIONS.always;
  86152. var APPLY_NEVER = APPLY === OPTIONS.never;
  86153. var APPLY_CONSISTENT = APPLY === OPTIONS.consistent;
  86154. var APPLY_CONSISTENT_AS_NEEDED = APPLY === OPTIONS.consistentAsNeeded;
  86155. var PARAMS = context.options[1] || {};
  86156. var IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors;
  86157. var AVOID_QUOTES = PARAMS.avoidQuotes;
  86158. var AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows;
  86159. var sourceCode = context.getSourceCode();
  86160. //--------------------------------------------------------------------------
  86161. // Helpers
  86162. //--------------------------------------------------------------------------
  86163. /**
  86164. * Determines if the first character of the name is a capital letter.
  86165. * @param {string} name The name of the node to evaluate.
  86166. * @returns {boolean} True if the first character of the property name is a capital letter, false if not.
  86167. * @private
  86168. */
  86169. function isConstructor(name) {
  86170. var firstChar = name.charAt(0);
  86171. return firstChar === firstChar.toUpperCase();
  86172. }
  86173. /**
  86174. * Determines if the property can have a shorthand form.
  86175. * @param {ASTNode} property Property AST node
  86176. * @returns {boolean} True if the property can have a shorthand form
  86177. * @private
  86178. *
  86179. */
  86180. function canHaveShorthand(property) {
  86181. return property.kind !== "set" && property.kind !== "get" && property.type !== "SpreadElement" && property.type !== "SpreadProperty" && property.type !== "ExperimentalSpreadProperty";
  86182. }
  86183. /**
  86184. * Checks whether a node is a string literal.
  86185. * @param {ASTNode} node - Any AST node.
  86186. * @returns {boolean} `true` if it is a string literal.
  86187. */
  86188. function isStringLiteral(node) {
  86189. return node.type === "Literal" && typeof node.value === "string";
  86190. }
  86191. /**
  86192. * Determines if the property is a shorthand or not.
  86193. * @param {ASTNode} property Property AST node
  86194. * @returns {boolean} True if the property is considered shorthand, false if not.
  86195. * @private
  86196. *
  86197. */
  86198. function isShorthand(property) {
  86199. // property.method is true when `{a(){}}`.
  86200. return property.shorthand || property.method;
  86201. }
  86202. /**
  86203. * Determines if the property's key and method or value are named equally.
  86204. * @param {ASTNode} property Property AST node
  86205. * @returns {boolean} True if the key and value are named equally, false if not.
  86206. * @private
  86207. *
  86208. */
  86209. function isRedundant(property) {
  86210. var value = property.value;
  86211. if (value.type === "FunctionExpression") {
  86212. return !value.id; // Only anonymous should be shorthand method.
  86213. }
  86214. if (value.type === "Identifier") {
  86215. return astUtils.getStaticPropertyName(property) === value.name;
  86216. }
  86217. return false;
  86218. }
  86219. /**
  86220. * Ensures that an object's properties are consistently shorthand, or not shorthand at all.
  86221. * @param {ASTNode} node Property AST node
  86222. * @param {boolean} checkRedundancy Whether to check longform redundancy
  86223. * @returns {void}
  86224. *
  86225. */
  86226. function checkConsistency(node, checkRedundancy) {
  86227. // We are excluding getters/setters and spread properties as they are considered neither longform nor shorthand.
  86228. var properties = node.properties.filter(canHaveShorthand);
  86229. // Do we still have properties left after filtering the getters and setters?
  86230. if (properties.length > 0) {
  86231. var shorthandProperties = properties.filter(isShorthand);
  86232. /*
  86233. * If we do not have an equal number of longform properties as
  86234. * shorthand properties, we are using the annotations inconsistently
  86235. */
  86236. if (shorthandProperties.length !== properties.length) {
  86237. // We have at least 1 shorthand property
  86238. if (shorthandProperties.length > 0) {
  86239. context.report({ node: node, message: "Unexpected mix of shorthand and non-shorthand properties." });
  86240. } else if (checkRedundancy) {
  86241. /*
  86242. * If all properties of the object contain a method or value with a name matching it's key,
  86243. * all the keys are redundant.
  86244. */
  86245. var canAlwaysUseShorthand = properties.every(isRedundant);
  86246. if (canAlwaysUseShorthand) {
  86247. context.report({ node: node, message: "Expected shorthand for all properties." });
  86248. }
  86249. }
  86250. }
  86251. }
  86252. }
  86253. /**
  86254. * Fixes a FunctionExpression node by making it into a shorthand property.
  86255. * @param {SourceCodeFixer} fixer The fixer object
  86256. * @param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value
  86257. * @returns {Object} A fix for this node
  86258. */
  86259. function makeFunctionShorthand(fixer, node) {
  86260. var firstKeyToken = node.computed ? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken) : sourceCode.getFirstToken(node.key);
  86261. var lastKeyToken = node.computed ? sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken) : sourceCode.getLastToken(node.key);
  86262. var keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
  86263. var keyPrefix = "";
  86264. if (sourceCode.commentsExistBetween(lastKeyToken, node.value)) {
  86265. return null;
  86266. }
  86267. if (node.value.async) {
  86268. keyPrefix += "async ";
  86269. }
  86270. if (node.value.generator) {
  86271. keyPrefix += "*";
  86272. }
  86273. if (node.value.type === "FunctionExpression") {
  86274. var functionToken = sourceCode.getTokens(node.value).find(function (token) {
  86275. return token.type === "Keyword" && token.value === "function";
  86276. });
  86277. var tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken;
  86278. return fixer.replaceTextRange([firstKeyToken.range[0], node.range[1]], keyPrefix + keyText + sourceCode.text.slice(tokenBeforeParams.range[1], node.value.range[1]));
  86279. }
  86280. var arrowToken = sourceCode.getTokens(node.value).find(function (token) {
  86281. return token.value === "=>";
  86282. });
  86283. var tokenBeforeArrow = sourceCode.getTokenBefore(arrowToken);
  86284. var hasParensAroundParameters = tokenBeforeArrow.type === "Punctuator" && tokenBeforeArrow.value === ")";
  86285. var oldParamText = sourceCode.text.slice(sourceCode.getFirstToken(node.value, node.value.async ? 1 : 0).range[0], tokenBeforeArrow.range[1]);
  86286. var newParamText = hasParensAroundParameters ? oldParamText : "(" + oldParamText + ")";
  86287. return fixer.replaceTextRange([firstKeyToken.range[0], node.range[1]], keyPrefix + keyText + newParamText + sourceCode.text.slice(arrowToken.range[1], node.value.range[1]));
  86288. }
  86289. /**
  86290. * Fixes a FunctionExpression node by making it into a longform property.
  86291. * @param {SourceCodeFixer} fixer The fixer object
  86292. * @param {ASTNode} node A `Property` node that has a `FunctionExpression` as its value
  86293. * @returns {Object} A fix for this node
  86294. */
  86295. function makeFunctionLongform(fixer, node) {
  86296. var firstKeyToken = node.computed ? sourceCode.getTokens(node).find(function (token) {
  86297. return token.value === "[";
  86298. }) : sourceCode.getFirstToken(node.key);
  86299. var lastKeyToken = node.computed ? sourceCode.getTokensBetween(node.key, node.value).find(function (token) {
  86300. return token.value === "]";
  86301. }) : sourceCode.getLastToken(node.key);
  86302. var keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
  86303. var functionHeader = "function";
  86304. if (node.value.async) {
  86305. functionHeader = "async " + functionHeader;
  86306. }
  86307. if (node.value.generator) {
  86308. functionHeader = functionHeader + "*";
  86309. }
  86310. return fixer.replaceTextRange([node.range[0], lastKeyToken.range[1]], keyText + ": " + functionHeader);
  86311. }
  86312. /*
  86313. * To determine whether a given arrow function has a lexical identifier (`this`, `arguments`, `super`, or `new.target`),
  86314. * create a stack of functions that define these identifiers (i.e. all functions except arrow functions) as the AST is
  86315. * traversed. Whenever a new function is encountered, create a new entry on the stack (corresponding to a different lexical
  86316. * scope of `this`), and whenever a function is exited, pop that entry off the stack. When an arrow function is entered,
  86317. * keep a reference to it on the current stack entry, and remove that reference when the arrow function is exited.
  86318. * When a lexical identifier is encountered, mark all the arrow functions on the current stack entry by adding them
  86319. * to an `arrowsWithLexicalIdentifiers` set. Any arrow function in that set will not be reported by this rule,
  86320. * because converting it into a method would change the value of one of the lexical identifiers.
  86321. */
  86322. var lexicalScopeStack = [];
  86323. var arrowsWithLexicalIdentifiers = new WeakSet();
  86324. var argumentsIdentifiers = new WeakSet();
  86325. /**
  86326. * Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack.
  86327. * Also, this marks all `arguments` identifiers so that they can be detected later.
  86328. * @returns {void}
  86329. */
  86330. function enterFunction() {
  86331. lexicalScopeStack.unshift(new Set());
  86332. context.getScope().variables.filter(function (variable) {
  86333. return variable.name === "arguments";
  86334. }).forEach(function (variable) {
  86335. variable.references.map(function (ref) {
  86336. return ref.identifier;
  86337. }).forEach(function (identifier) {
  86338. return argumentsIdentifiers.add(identifier);
  86339. });
  86340. });
  86341. }
  86342. /**
  86343. * Exits a function. This pops the current set of arrow functions off the lexical scope stack.
  86344. * @returns {void}
  86345. */
  86346. function exitFunction() {
  86347. lexicalScopeStack.shift();
  86348. }
  86349. /**
  86350. * Marks the current function as having a lexical keyword. This implies that all arrow functions
  86351. * in the current lexical scope contain a reference to this lexical keyword.
  86352. * @returns {void}
  86353. */
  86354. function reportLexicalIdentifier() {
  86355. lexicalScopeStack[0].forEach(function (arrowFunction) {
  86356. return arrowsWithLexicalIdentifiers.add(arrowFunction);
  86357. });
  86358. }
  86359. //--------------------------------------------------------------------------
  86360. // Public
  86361. //--------------------------------------------------------------------------
  86362. return {
  86363. Program: enterFunction,
  86364. FunctionDeclaration: enterFunction,
  86365. FunctionExpression: enterFunction,
  86366. "Program:exit": exitFunction,
  86367. "FunctionDeclaration:exit": exitFunction,
  86368. "FunctionExpression:exit": exitFunction,
  86369. ArrowFunctionExpression: function ArrowFunctionExpression(node) {
  86370. lexicalScopeStack[0].add(node);
  86371. },
  86372. "ArrowFunctionExpression:exit": function ArrowFunctionExpressionExit(node) {
  86373. lexicalScopeStack[0].delete(node);
  86374. },
  86375. ThisExpression: reportLexicalIdentifier,
  86376. Super: reportLexicalIdentifier,
  86377. MetaProperty: function MetaProperty(node) {
  86378. if (node.meta.name === "new" && node.property.name === "target") {
  86379. reportLexicalIdentifier();
  86380. }
  86381. },
  86382. Identifier: function Identifier(node) {
  86383. if (argumentsIdentifiers.has(node)) {
  86384. reportLexicalIdentifier();
  86385. }
  86386. },
  86387. ObjectExpression: function ObjectExpression(node) {
  86388. if (APPLY_CONSISTENT) {
  86389. checkConsistency(node, false);
  86390. } else if (APPLY_CONSISTENT_AS_NEEDED) {
  86391. checkConsistency(node, true);
  86392. }
  86393. },
  86394. "Property:exit": function PropertyExit(node) {
  86395. var isConciseProperty = node.method || node.shorthand;
  86396. // Ignore destructuring assignment
  86397. if (node.parent.type === "ObjectPattern") {
  86398. return;
  86399. }
  86400. // getters and setters are ignored
  86401. if (node.kind === "get" || node.kind === "set") {
  86402. return;
  86403. }
  86404. // only computed methods can fail the following checks
  86405. if (node.computed && node.value.type !== "FunctionExpression" && node.value.type !== "ArrowFunctionExpression") {
  86406. return;
  86407. }
  86408. //--------------------------------------------------------------
  86409. // Checks for property/method shorthand.
  86410. if (isConciseProperty) {
  86411. if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) {
  86412. var message = APPLY_NEVER ? "Expected longform method syntax." : "Expected longform method syntax for string literal keys.";
  86413. // { x() {} } should be written as { x: function() {} }
  86414. context.report({
  86415. node: node,
  86416. message: message,
  86417. fix: function fix(fixer) {
  86418. return makeFunctionLongform(fixer, node);
  86419. }
  86420. });
  86421. } else if (APPLY_NEVER) {
  86422. // { x } should be written as { x: x }
  86423. context.report({
  86424. node: node,
  86425. message: "Expected longform property syntax.",
  86426. fix: function fix(fixer) {
  86427. return fixer.insertTextAfter(node.key, ": " + node.key.name);
  86428. }
  86429. });
  86430. }
  86431. } else if (APPLY_TO_METHODS && !node.value.id && (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression")) {
  86432. if (IGNORE_CONSTRUCTORS && node.key.type === "Identifier" && isConstructor(node.key.name)) {
  86433. return;
  86434. }
  86435. if (AVOID_QUOTES && isStringLiteral(node.key)) {
  86436. return;
  86437. }
  86438. // {[x]: function(){}} should be written as {[x]() {}}
  86439. if (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression" && node.value.body.type === "BlockStatement" && AVOID_EXPLICIT_RETURN_ARROWS && !arrowsWithLexicalIdentifiers.has(node.value)) {
  86440. context.report({
  86441. node: node,
  86442. message: "Expected method shorthand.",
  86443. fix: function fix(fixer) {
  86444. return makeFunctionShorthand(fixer, node);
  86445. }
  86446. });
  86447. }
  86448. } else if (node.value.type === "Identifier" && node.key.name === node.value.name && APPLY_TO_PROPS) {
  86449. // {x: x} should be written as {x}
  86450. context.report({
  86451. node: node,
  86452. message: "Expected property shorthand.",
  86453. fix: function fix(fixer) {
  86454. return fixer.replaceText(node, node.value.name);
  86455. }
  86456. });
  86457. } else if (node.value.type === "Identifier" && node.key.type === "Literal" && node.key.value === node.value.name && APPLY_TO_PROPS) {
  86458. if (AVOID_QUOTES) {
  86459. return;
  86460. }
  86461. // {"x": x} should be written as {x}
  86462. context.report({
  86463. node: node,
  86464. message: "Expected property shorthand.",
  86465. fix: function fix(fixer) {
  86466. return fixer.replaceText(node, node.value.name);
  86467. }
  86468. });
  86469. }
  86470. }
  86471. };
  86472. }
  86473. };
  86474. },{"../util/ast-utils":405}],339:[function(require,module,exports){
  86475. /**
  86476. * @fileoverview Rule to check multiple var declarations per line
  86477. * @author Alberto Rodríguez
  86478. */
  86479. "use strict";
  86480. //------------------------------------------------------------------------------
  86481. // Rule Definition
  86482. //------------------------------------------------------------------------------
  86483. module.exports = {
  86484. meta: {
  86485. type: "suggestion",
  86486. docs: {
  86487. description: "require or disallow newlines around variable declarations",
  86488. category: "Stylistic Issues",
  86489. recommended: false,
  86490. url: "https://eslint.org/docs/rules/one-var-declaration-per-line"
  86491. },
  86492. schema: [{
  86493. enum: ["always", "initializations"]
  86494. }],
  86495. fixable: "whitespace"
  86496. },
  86497. create: function create(context) {
  86498. var ERROR_MESSAGE = "Expected variable declaration to be on a new line.";
  86499. var always = context.options[0] === "always";
  86500. //--------------------------------------------------------------------------
  86501. // Helpers
  86502. //--------------------------------------------------------------------------
  86503. /**
  86504. * Determine if provided keyword is a variant of for specifiers
  86505. * @private
  86506. * @param {string} keyword - keyword to test
  86507. * @returns {boolean} True if `keyword` is a variant of for specifier
  86508. */
  86509. function isForTypeSpecifier(keyword) {
  86510. return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
  86511. }
  86512. /**
  86513. * Checks newlines around variable declarations.
  86514. * @private
  86515. * @param {ASTNode} node - `VariableDeclaration` node to test
  86516. * @returns {void}
  86517. */
  86518. function checkForNewLine(node) {
  86519. if (isForTypeSpecifier(node.parent.type)) {
  86520. return;
  86521. }
  86522. var declarations = node.declarations;
  86523. var prev = void 0;
  86524. declarations.forEach(function (current) {
  86525. if (prev && prev.loc.end.line === current.loc.start.line) {
  86526. if (always || prev.init || current.init) {
  86527. context.report({
  86528. node: node,
  86529. message: ERROR_MESSAGE,
  86530. loc: current.loc.start,
  86531. fix: function fix(fixer) {
  86532. return fixer.insertTextBefore(current, "\n");
  86533. }
  86534. });
  86535. }
  86536. }
  86537. prev = current;
  86538. });
  86539. }
  86540. //--------------------------------------------------------------------------
  86541. // Public
  86542. //--------------------------------------------------------------------------
  86543. return {
  86544. VariableDeclaration: checkForNewLine
  86545. };
  86546. }
  86547. };
  86548. },{}],340:[function(require,module,exports){
  86549. /**
  86550. * @fileoverview A rule to control the use of single variable declarations.
  86551. * @author Ian Christian Myers
  86552. */
  86553. "use strict";
  86554. //------------------------------------------------------------------------------
  86555. // Rule Definition
  86556. //------------------------------------------------------------------------------
  86557. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  86558. module.exports = {
  86559. meta: {
  86560. type: "suggestion",
  86561. docs: {
  86562. description: "enforce variables to be declared either together or separately in functions",
  86563. category: "Stylistic Issues",
  86564. recommended: false,
  86565. url: "https://eslint.org/docs/rules/one-var"
  86566. },
  86567. fixable: "code",
  86568. schema: [{
  86569. oneOf: [{
  86570. enum: ["always", "never", "consecutive"]
  86571. }, {
  86572. type: "object",
  86573. properties: {
  86574. separateRequires: {
  86575. type: "boolean"
  86576. },
  86577. var: {
  86578. enum: ["always", "never", "consecutive"]
  86579. },
  86580. let: {
  86581. enum: ["always", "never", "consecutive"]
  86582. },
  86583. const: {
  86584. enum: ["always", "never", "consecutive"]
  86585. }
  86586. },
  86587. additionalProperties: false
  86588. }, {
  86589. type: "object",
  86590. properties: {
  86591. initialized: {
  86592. enum: ["always", "never", "consecutive"]
  86593. },
  86594. uninitialized: {
  86595. enum: ["always", "never", "consecutive"]
  86596. }
  86597. },
  86598. additionalProperties: false
  86599. }]
  86600. }]
  86601. },
  86602. create: function create(context) {
  86603. var MODE_ALWAYS = "always";
  86604. var MODE_NEVER = "never";
  86605. var MODE_CONSECUTIVE = "consecutive";
  86606. var mode = context.options[0] || MODE_ALWAYS;
  86607. var options = {};
  86608. if (typeof mode === "string") {
  86609. // simple options configuration with just a string
  86610. options.var = { uninitialized: mode, initialized: mode };
  86611. options.let = { uninitialized: mode, initialized: mode };
  86612. options.const = { uninitialized: mode, initialized: mode };
  86613. } else if ((typeof mode === "undefined" ? "undefined" : _typeof(mode)) === "object") {
  86614. // options configuration is an object
  86615. if (Object.prototype.hasOwnProperty.call(mode, "separateRequires")) {
  86616. options.separateRequires = !!mode.separateRequires;
  86617. }
  86618. if (Object.prototype.hasOwnProperty.call(mode, "var")) {
  86619. options.var = { uninitialized: mode.var, initialized: mode.var };
  86620. }
  86621. if (Object.prototype.hasOwnProperty.call(mode, "let")) {
  86622. options.let = { uninitialized: mode.let, initialized: mode.let };
  86623. }
  86624. if (Object.prototype.hasOwnProperty.call(mode, "const")) {
  86625. options.const = { uninitialized: mode.const, initialized: mode.const };
  86626. }
  86627. if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) {
  86628. if (!options.var) {
  86629. options.var = {};
  86630. }
  86631. if (!options.let) {
  86632. options.let = {};
  86633. }
  86634. if (!options.const) {
  86635. options.const = {};
  86636. }
  86637. options.var.uninitialized = mode.uninitialized;
  86638. options.let.uninitialized = mode.uninitialized;
  86639. options.const.uninitialized = mode.uninitialized;
  86640. }
  86641. if (Object.prototype.hasOwnProperty.call(mode, "initialized")) {
  86642. if (!options.var) {
  86643. options.var = {};
  86644. }
  86645. if (!options.let) {
  86646. options.let = {};
  86647. }
  86648. if (!options.const) {
  86649. options.const = {};
  86650. }
  86651. options.var.initialized = mode.initialized;
  86652. options.let.initialized = mode.initialized;
  86653. options.const.initialized = mode.initialized;
  86654. }
  86655. }
  86656. var sourceCode = context.getSourceCode();
  86657. //--------------------------------------------------------------------------
  86658. // Helpers
  86659. //--------------------------------------------------------------------------
  86660. var functionStack = [];
  86661. var blockStack = [];
  86662. /**
  86663. * Increments the blockStack counter.
  86664. * @returns {void}
  86665. * @private
  86666. */
  86667. function startBlock() {
  86668. blockStack.push({
  86669. let: { initialized: false, uninitialized: false },
  86670. const: { initialized: false, uninitialized: false }
  86671. });
  86672. }
  86673. /**
  86674. * Increments the functionStack counter.
  86675. * @returns {void}
  86676. * @private
  86677. */
  86678. function startFunction() {
  86679. functionStack.push({ initialized: false, uninitialized: false });
  86680. startBlock();
  86681. }
  86682. /**
  86683. * Decrements the blockStack counter.
  86684. * @returns {void}
  86685. * @private
  86686. */
  86687. function endBlock() {
  86688. blockStack.pop();
  86689. }
  86690. /**
  86691. * Decrements the functionStack counter.
  86692. * @returns {void}
  86693. * @private
  86694. */
  86695. function endFunction() {
  86696. functionStack.pop();
  86697. endBlock();
  86698. }
  86699. /**
  86700. * Check if a variable declaration is a require.
  86701. * @param {ASTNode} decl variable declaration Node
  86702. * @returns {bool} if decl is a require, return true; else return false.
  86703. * @private
  86704. */
  86705. function isRequire(decl) {
  86706. return decl.init && decl.init.type === "CallExpression" && decl.init.callee.name === "require";
  86707. }
  86708. /**
  86709. * Records whether initialized/uninitialized/required variables are defined in current scope.
  86710. * @param {string} statementType node.kind, one of: "var", "let", or "const"
  86711. * @param {ASTNode[]} declarations List of declarations
  86712. * @param {Object} currentScope The scope being investigated
  86713. * @returns {void}
  86714. * @private
  86715. */
  86716. function recordTypes(statementType, declarations, currentScope) {
  86717. for (var i = 0; i < declarations.length; i++) {
  86718. if (declarations[i].init === null) {
  86719. if (options[statementType] && options[statementType].uninitialized === MODE_ALWAYS) {
  86720. currentScope.uninitialized = true;
  86721. }
  86722. } else {
  86723. if (options[statementType] && options[statementType].initialized === MODE_ALWAYS) {
  86724. if (options.separateRequires && isRequire(declarations[i])) {
  86725. currentScope.required = true;
  86726. } else {
  86727. currentScope.initialized = true;
  86728. }
  86729. }
  86730. }
  86731. }
  86732. }
  86733. /**
  86734. * Determines the current scope (function or block)
  86735. * @param {string} statementType node.kind, one of: "var", "let", or "const"
  86736. * @returns {Object} The scope associated with statementType
  86737. */
  86738. function getCurrentScope(statementType) {
  86739. var currentScope = void 0;
  86740. if (statementType === "var") {
  86741. currentScope = functionStack[functionStack.length - 1];
  86742. } else if (statementType === "let") {
  86743. currentScope = blockStack[blockStack.length - 1].let;
  86744. } else if (statementType === "const") {
  86745. currentScope = blockStack[blockStack.length - 1].const;
  86746. }
  86747. return currentScope;
  86748. }
  86749. /**
  86750. * Counts the number of initialized and uninitialized declarations in a list of declarations
  86751. * @param {ASTNode[]} declarations List of declarations
  86752. * @returns {Object} Counts of 'uninitialized' and 'initialized' declarations
  86753. * @private
  86754. */
  86755. function countDeclarations(declarations) {
  86756. var counts = { uninitialized: 0, initialized: 0 };
  86757. for (var i = 0; i < declarations.length; i++) {
  86758. if (declarations[i].init === null) {
  86759. counts.uninitialized++;
  86760. } else {
  86761. counts.initialized++;
  86762. }
  86763. }
  86764. return counts;
  86765. }
  86766. /**
  86767. * Determines if there is more than one var statement in the current scope.
  86768. * @param {string} statementType node.kind, one of: "var", "let", or "const"
  86769. * @param {ASTNode[]} declarations List of declarations
  86770. * @returns {boolean} Returns true if it is the first var declaration, false if not.
  86771. * @private
  86772. */
  86773. function hasOnlyOneStatement(statementType, declarations) {
  86774. var declarationCounts = countDeclarations(declarations);
  86775. var currentOptions = options[statementType] || {};
  86776. var currentScope = getCurrentScope(statementType);
  86777. var hasRequires = declarations.some(isRequire);
  86778. if (currentOptions.uninitialized === MODE_ALWAYS && currentOptions.initialized === MODE_ALWAYS) {
  86779. if (currentScope.uninitialized || currentScope.initialized) {
  86780. return false;
  86781. }
  86782. }
  86783. if (declarationCounts.uninitialized > 0) {
  86784. if (currentOptions.uninitialized === MODE_ALWAYS && currentScope.uninitialized) {
  86785. return false;
  86786. }
  86787. }
  86788. if (declarationCounts.initialized > 0) {
  86789. if (currentOptions.initialized === MODE_ALWAYS && currentScope.initialized) {
  86790. return false;
  86791. }
  86792. }
  86793. if (currentScope.required && hasRequires) {
  86794. return false;
  86795. }
  86796. recordTypes(statementType, declarations, currentScope);
  86797. return true;
  86798. }
  86799. /**
  86800. * Fixer to join VariableDeclaration's into a single declaration
  86801. * @param {VariableDeclarator[]} declarations The `VariableDeclaration` to join
  86802. * @returns {Function} The fixer function
  86803. */
  86804. function joinDeclarations(declarations) {
  86805. var declaration = declarations[0];
  86806. var body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : [];
  86807. var currentIndex = body.findIndex(function (node) {
  86808. return node.range[0] === declaration.parent.range[0];
  86809. });
  86810. var previousNode = body[currentIndex - 1];
  86811. return function (fixer) {
  86812. var type = sourceCode.getTokenBefore(declaration);
  86813. var prevSemi = sourceCode.getTokenBefore(type);
  86814. var res = [];
  86815. if (previousNode && previousNode.kind === sourceCode.getText(type)) {
  86816. if (prevSemi.value === ";") {
  86817. res.push(fixer.replaceText(prevSemi, ","));
  86818. } else {
  86819. res.push(fixer.insertTextAfter(prevSemi, ","));
  86820. }
  86821. res.push(fixer.replaceText(type, ""));
  86822. }
  86823. return res;
  86824. };
  86825. }
  86826. /**
  86827. * Fixer to split a VariableDeclaration into individual declarations
  86828. * @param {VariableDeclaration} declaration The `VariableDeclaration` to split
  86829. * @returns {Function} The fixer function
  86830. */
  86831. function splitDeclarations(declaration) {
  86832. return function (fixer) {
  86833. return declaration.declarations.map(function (declarator) {
  86834. var tokenAfterDeclarator = sourceCode.getTokenAfter(declarator);
  86835. if (tokenAfterDeclarator === null) {
  86836. return null;
  86837. }
  86838. var afterComma = sourceCode.getTokenAfter(tokenAfterDeclarator, { includeComments: true });
  86839. if (tokenAfterDeclarator.value !== ",") {
  86840. return null;
  86841. }
  86842. /*
  86843. * `var x,y`
  86844. * tokenAfterDeclarator ^^ afterComma
  86845. */
  86846. if (afterComma.range[0] === tokenAfterDeclarator.range[1]) {
  86847. return fixer.replaceText(tokenAfterDeclarator, "; " + declaration.kind + " ");
  86848. }
  86849. /*
  86850. * `var x,
  86851. * tokenAfterDeclarator ^
  86852. * y`
  86853. * ^ afterComma
  86854. */
  86855. if (afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line || afterComma.type === "Line" || afterComma.type === "Block") {
  86856. var lastComment = afterComma;
  86857. while (lastComment.type === "Line" || lastComment.type === "Block") {
  86858. lastComment = sourceCode.getTokenAfter(lastComment, { includeComments: true });
  86859. }
  86860. return fixer.replaceTextRange([tokenAfterDeclarator.range[0], lastComment.range[0]], ";\n" + sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0]) + "\n" + declaration.kind + " ");
  86861. }
  86862. return fixer.replaceText(tokenAfterDeclarator, "; " + declaration.kind);
  86863. }).filter(function (x) {
  86864. return x;
  86865. });
  86866. };
  86867. }
  86868. /**
  86869. * Checks a given VariableDeclaration node for errors.
  86870. * @param {ASTNode} node The VariableDeclaration node to check
  86871. * @returns {void}
  86872. * @private
  86873. */
  86874. function checkVariableDeclaration(node) {
  86875. var parent = node.parent;
  86876. var type = node.kind;
  86877. if (!options[type]) {
  86878. return;
  86879. }
  86880. var declarations = node.declarations;
  86881. var declarationCounts = countDeclarations(declarations);
  86882. var mixedRequires = declarations.some(isRequire) && !declarations.every(isRequire);
  86883. if (options[type].initialized === MODE_ALWAYS) {
  86884. if (options.separateRequires && mixedRequires) {
  86885. context.report({
  86886. node: node,
  86887. message: "Split requires to be separated into a single block."
  86888. });
  86889. }
  86890. }
  86891. // consecutive
  86892. var nodeIndex = parent.body && parent.body.length > 0 && parent.body.indexOf(node) || 0;
  86893. if (nodeIndex > 0) {
  86894. var previousNode = parent.body[nodeIndex - 1];
  86895. var isPreviousNodeDeclaration = previousNode.type === "VariableDeclaration";
  86896. var declarationsWithPrevious = declarations.concat(previousNode.declarations || []);
  86897. if (isPreviousNodeDeclaration && previousNode.kind === type && !(declarationsWithPrevious.some(isRequire) && !declarationsWithPrevious.every(isRequire))) {
  86898. var previousDeclCounts = countDeclarations(previousNode.declarations);
  86899. if (options[type].initialized === MODE_CONSECUTIVE && options[type].uninitialized === MODE_CONSECUTIVE) {
  86900. context.report({
  86901. node: node,
  86902. message: "Combine this with the previous '{{type}}' statement.",
  86903. data: {
  86904. type: type
  86905. },
  86906. fix: joinDeclarations(declarations)
  86907. });
  86908. } else if (options[type].initialized === MODE_CONSECUTIVE && declarationCounts.initialized > 0 && previousDeclCounts.initialized > 0) {
  86909. context.report({
  86910. node: node,
  86911. message: "Combine this with the previous '{{type}}' statement with initialized variables.",
  86912. data: {
  86913. type: type
  86914. },
  86915. fix: joinDeclarations(declarations)
  86916. });
  86917. } else if (options[type].uninitialized === MODE_CONSECUTIVE && declarationCounts.uninitialized > 0 && previousDeclCounts.uninitialized > 0) {
  86918. context.report({
  86919. node: node,
  86920. message: "Combine this with the previous '{{type}}' statement with uninitialized variables.",
  86921. data: {
  86922. type: type
  86923. },
  86924. fix: joinDeclarations(declarations)
  86925. });
  86926. }
  86927. }
  86928. }
  86929. // always
  86930. if (!hasOnlyOneStatement(type, declarations)) {
  86931. if (options[type].initialized === MODE_ALWAYS && options[type].uninitialized === MODE_ALWAYS) {
  86932. context.report({
  86933. node: node,
  86934. message: "Combine this with the previous '{{type}}' statement.",
  86935. data: {
  86936. type: type
  86937. },
  86938. fix: joinDeclarations(declarations)
  86939. });
  86940. } else {
  86941. if (options[type].initialized === MODE_ALWAYS && declarationCounts.initialized > 0) {
  86942. context.report({
  86943. node: node,
  86944. message: "Combine this with the previous '{{type}}' statement with initialized variables.",
  86945. data: {
  86946. type: type
  86947. },
  86948. fix: joinDeclarations(declarations)
  86949. });
  86950. }
  86951. if (options[type].uninitialized === MODE_ALWAYS && declarationCounts.uninitialized > 0) {
  86952. if (node.parent.left === node && (node.parent.type === "ForInStatement" || node.parent.type === "ForOfStatement")) {
  86953. return;
  86954. }
  86955. context.report({
  86956. node: node,
  86957. message: "Combine this with the previous '{{type}}' statement with uninitialized variables.",
  86958. data: {
  86959. type: type
  86960. },
  86961. fix: joinDeclarations(declarations)
  86962. });
  86963. }
  86964. }
  86965. }
  86966. // never
  86967. if (parent.type !== "ForStatement" || parent.init !== node) {
  86968. var totalDeclarations = declarationCounts.uninitialized + declarationCounts.initialized;
  86969. if (totalDeclarations > 1) {
  86970. if (options[type].initialized === MODE_NEVER && options[type].uninitialized === MODE_NEVER) {
  86971. // both initialized and uninitialized
  86972. context.report({
  86973. node: node,
  86974. message: "Split '{{type}}' declarations into multiple statements.",
  86975. data: {
  86976. type: type
  86977. },
  86978. fix: splitDeclarations(node)
  86979. });
  86980. } else if (options[type].initialized === MODE_NEVER && declarationCounts.initialized > 0) {
  86981. // initialized
  86982. context.report({
  86983. node: node,
  86984. message: "Split initialized '{{type}}' declarations into multiple statements.",
  86985. data: {
  86986. type: type
  86987. },
  86988. fix: splitDeclarations(node)
  86989. });
  86990. } else if (options[type].uninitialized === MODE_NEVER && declarationCounts.uninitialized > 0) {
  86991. // uninitialized
  86992. context.report({
  86993. node: node,
  86994. message: "Split uninitialized '{{type}}' declarations into multiple statements.",
  86995. data: {
  86996. type: type
  86997. },
  86998. fix: splitDeclarations(node)
  86999. });
  87000. }
  87001. }
  87002. }
  87003. }
  87004. //--------------------------------------------------------------------------
  87005. // Public API
  87006. //--------------------------------------------------------------------------
  87007. return {
  87008. Program: startFunction,
  87009. FunctionDeclaration: startFunction,
  87010. FunctionExpression: startFunction,
  87011. ArrowFunctionExpression: startFunction,
  87012. BlockStatement: startBlock,
  87013. ForStatement: startBlock,
  87014. ForInStatement: startBlock,
  87015. ForOfStatement: startBlock,
  87016. SwitchStatement: startBlock,
  87017. VariableDeclaration: checkVariableDeclaration,
  87018. "ForStatement:exit": endBlock,
  87019. "ForOfStatement:exit": endBlock,
  87020. "ForInStatement:exit": endBlock,
  87021. "SwitchStatement:exit": endBlock,
  87022. "BlockStatement:exit": endBlock,
  87023. "Program:exit": endFunction,
  87024. "FunctionDeclaration:exit": endFunction,
  87025. "FunctionExpression:exit": endFunction,
  87026. "ArrowFunctionExpression:exit": endFunction
  87027. };
  87028. }
  87029. };
  87030. },{}],341:[function(require,module,exports){
  87031. /**
  87032. * @fileoverview Rule to replace assignment expressions with operator assignment
  87033. * @author Brandon Mills
  87034. */
  87035. "use strict";
  87036. //------------------------------------------------------------------------------
  87037. // Requirements
  87038. //------------------------------------------------------------------------------
  87039. var astUtils = require("../util/ast-utils");
  87040. //------------------------------------------------------------------------------
  87041. // Helpers
  87042. //------------------------------------------------------------------------------
  87043. /**
  87044. * Checks whether an operator is commutative and has an operator assignment
  87045. * shorthand form.
  87046. * @param {string} operator Operator to check.
  87047. * @returns {boolean} True if the operator is commutative and has a
  87048. * shorthand form.
  87049. */
  87050. function isCommutativeOperatorWithShorthand(operator) {
  87051. return ["*", "&", "^", "|"].indexOf(operator) >= 0;
  87052. }
  87053. /**
  87054. * Checks whether an operator is not commuatative and has an operator assignment
  87055. * shorthand form.
  87056. * @param {string} operator Operator to check.
  87057. * @returns {boolean} True if the operator is not commuatative and has
  87058. * a shorthand form.
  87059. */
  87060. function isNonCommutativeOperatorWithShorthand(operator) {
  87061. return ["+", "-", "/", "%", "<<", ">>", ">>>", "**"].indexOf(operator) >= 0;
  87062. }
  87063. //------------------------------------------------------------------------------
  87064. // Rule Definition
  87065. //------------------------------------------------------------------------------
  87066. /**
  87067. * Checks whether two expressions reference the same value. For example:
  87068. * a = a
  87069. * a.b = a.b
  87070. * a[0] = a[0]
  87071. * a['b'] = a['b']
  87072. * @param {ASTNode} a Left side of the comparison.
  87073. * @param {ASTNode} b Right side of the comparison.
  87074. * @returns {boolean} True if both sides match and reference the same value.
  87075. */
  87076. function same(a, b) {
  87077. if (a.type !== b.type) {
  87078. return false;
  87079. }
  87080. switch (a.type) {
  87081. case "Identifier":
  87082. return a.name === b.name;
  87083. case "Literal":
  87084. return a.value === b.value;
  87085. case "MemberExpression":
  87086. /*
  87087. * x[0] = x[0]
  87088. * x[y] = x[y]
  87089. * x.y = x.y
  87090. */
  87091. return same(a.object, b.object) && same(a.property, b.property);
  87092. default:
  87093. return false;
  87094. }
  87095. }
  87096. /**
  87097. * Determines if the left side of a node can be safely fixed (i.e. if it activates the same getters/setters and)
  87098. * toString calls regardless of whether assignment shorthand is used)
  87099. * @param {ASTNode} node The node on the left side of the expression
  87100. * @returns {boolean} `true` if the node can be fixed
  87101. */
  87102. function canBeFixed(node) {
  87103. return node.type === "Identifier" || node.type === "MemberExpression" && node.object.type === "Identifier" && (!node.computed || node.property.type === "Literal");
  87104. }
  87105. module.exports = {
  87106. meta: {
  87107. type: "suggestion",
  87108. docs: {
  87109. description: "require or disallow assignment operator shorthand where possible",
  87110. category: "Stylistic Issues",
  87111. recommended: false,
  87112. url: "https://eslint.org/docs/rules/operator-assignment"
  87113. },
  87114. schema: [{
  87115. enum: ["always", "never"]
  87116. }],
  87117. fixable: "code"
  87118. },
  87119. create: function create(context) {
  87120. var sourceCode = context.getSourceCode();
  87121. /**
  87122. * Returns the operator token of an AssignmentExpression or BinaryExpression
  87123. * @param {ASTNode} node An AssignmentExpression or BinaryExpression node
  87124. * @returns {Token} The operator token in the node
  87125. */
  87126. function getOperatorToken(node) {
  87127. return sourceCode.getFirstTokenBetween(node.left, node.right, function (token) {
  87128. return token.value === node.operator;
  87129. });
  87130. }
  87131. /**
  87132. * Ensures that an assignment uses the shorthand form where possible.
  87133. * @param {ASTNode} node An AssignmentExpression node.
  87134. * @returns {void}
  87135. */
  87136. function verify(node) {
  87137. if (node.operator !== "=" || node.right.type !== "BinaryExpression") {
  87138. return;
  87139. }
  87140. var left = node.left;
  87141. var expr = node.right;
  87142. var operator = expr.operator;
  87143. if (isCommutativeOperatorWithShorthand(operator) || isNonCommutativeOperatorWithShorthand(operator)) {
  87144. if (same(left, expr.left)) {
  87145. context.report({
  87146. node: node,
  87147. message: "Assignment can be replaced with operator assignment.",
  87148. fix: function fix(fixer) {
  87149. if (canBeFixed(left)) {
  87150. var equalsToken = getOperatorToken(node);
  87151. var operatorToken = getOperatorToken(expr);
  87152. var leftText = sourceCode.getText().slice(node.range[0], equalsToken.range[0]);
  87153. var rightText = sourceCode.getText().slice(operatorToken.range[1], node.right.range[1]);
  87154. return fixer.replaceText(node, "" + leftText + expr.operator + "=" + rightText);
  87155. }
  87156. return null;
  87157. }
  87158. });
  87159. } else if (same(left, expr.right) && isCommutativeOperatorWithShorthand(operator)) {
  87160. /*
  87161. * This case can't be fixed safely.
  87162. * If `a` and `b` both have custom valueOf() behavior, then fixing `a = b * a` to `a *= b` would
  87163. * change the execution order of the valueOf() functions.
  87164. */
  87165. context.report({
  87166. node: node,
  87167. message: "Assignment can be replaced with operator assignment."
  87168. });
  87169. }
  87170. }
  87171. }
  87172. /**
  87173. * Warns if an assignment expression uses operator assignment shorthand.
  87174. * @param {ASTNode} node An AssignmentExpression node.
  87175. * @returns {void}
  87176. */
  87177. function prohibit(node) {
  87178. if (node.operator !== "=") {
  87179. context.report({
  87180. node: node,
  87181. message: "Unexpected operator assignment shorthand.",
  87182. fix: function fix(fixer) {
  87183. if (canBeFixed(node.left)) {
  87184. var operatorToken = getOperatorToken(node);
  87185. var leftText = sourceCode.getText().slice(node.range[0], operatorToken.range[0]);
  87186. var newOperator = node.operator.slice(0, -1);
  87187. var rightText = void 0;
  87188. // If this change would modify precedence (e.g. `foo *= bar + 1` => `foo = foo * (bar + 1)`), parenthesize the right side.
  87189. if (astUtils.getPrecedence(node.right) <= astUtils.getPrecedence({ type: "BinaryExpression", operator: newOperator }) && !astUtils.isParenthesised(sourceCode, node.right)) {
  87190. rightText = sourceCode.text.slice(operatorToken.range[1], node.right.range[0]) + "(" + sourceCode.getText(node.right) + ")";
  87191. } else {
  87192. rightText = sourceCode.text.slice(operatorToken.range[1], node.range[1]);
  87193. }
  87194. return fixer.replaceText(node, leftText + "= " + leftText + newOperator + rightText);
  87195. }
  87196. return null;
  87197. }
  87198. });
  87199. }
  87200. }
  87201. return {
  87202. AssignmentExpression: context.options[0] !== "never" ? verify : prohibit
  87203. };
  87204. }
  87205. };
  87206. },{"../util/ast-utils":405}],342:[function(require,module,exports){
  87207. /**
  87208. * @fileoverview Operator linebreak - enforces operator linebreak style of two types: after and before
  87209. * @author Benoît Zugmeyer
  87210. */
  87211. "use strict";
  87212. //------------------------------------------------------------------------------
  87213. // Requirements
  87214. //------------------------------------------------------------------------------
  87215. var astUtils = require("../util/ast-utils");
  87216. //------------------------------------------------------------------------------
  87217. // Rule Definition
  87218. //------------------------------------------------------------------------------
  87219. module.exports = {
  87220. meta: {
  87221. type: "layout",
  87222. docs: {
  87223. description: "enforce consistent linebreak style for operators",
  87224. category: "Stylistic Issues",
  87225. recommended: false,
  87226. url: "https://eslint.org/docs/rules/operator-linebreak"
  87227. },
  87228. schema: [{
  87229. enum: ["after", "before", "none", null]
  87230. }, {
  87231. type: "object",
  87232. properties: {
  87233. overrides: {
  87234. type: "object",
  87235. properties: {
  87236. anyOf: {
  87237. type: "string",
  87238. enum: ["after", "before", "none", "ignore"]
  87239. }
  87240. }
  87241. }
  87242. },
  87243. additionalProperties: false
  87244. }],
  87245. fixable: "code"
  87246. },
  87247. create: function create(context) {
  87248. var usedDefaultGlobal = !context.options[0];
  87249. var globalStyle = context.options[0] || "after";
  87250. var options = context.options[1] || {};
  87251. var styleOverrides = options.overrides ? Object.assign({}, options.overrides) : {};
  87252. if (usedDefaultGlobal && !styleOverrides["?"]) {
  87253. styleOverrides["?"] = "before";
  87254. }
  87255. if (usedDefaultGlobal && !styleOverrides[":"]) {
  87256. styleOverrides[":"] = "before";
  87257. }
  87258. var sourceCode = context.getSourceCode();
  87259. //--------------------------------------------------------------------------
  87260. // Helpers
  87261. //--------------------------------------------------------------------------
  87262. /**
  87263. * Gets a fixer function to fix rule issues
  87264. * @param {Token} operatorToken The operator token of an expression
  87265. * @param {string} desiredStyle The style for the rule. One of 'before', 'after', 'none'
  87266. * @returns {Function} A fixer function
  87267. */
  87268. function getFixer(operatorToken, desiredStyle) {
  87269. return function (fixer) {
  87270. var tokenBefore = sourceCode.getTokenBefore(operatorToken);
  87271. var tokenAfter = sourceCode.getTokenAfter(operatorToken);
  87272. var textBefore = sourceCode.text.slice(tokenBefore.range[1], operatorToken.range[0]);
  87273. var textAfter = sourceCode.text.slice(operatorToken.range[1], tokenAfter.range[0]);
  87274. var hasLinebreakBefore = !astUtils.isTokenOnSameLine(tokenBefore, operatorToken);
  87275. var hasLinebreakAfter = !astUtils.isTokenOnSameLine(operatorToken, tokenAfter);
  87276. var newTextBefore = void 0,
  87277. newTextAfter = void 0;
  87278. if (hasLinebreakBefore !== hasLinebreakAfter && desiredStyle !== "none") {
  87279. // If there is a comment before and after the operator, don't do a fix.
  87280. if (sourceCode.getTokenBefore(operatorToken, { includeComments: true }) !== tokenBefore && sourceCode.getTokenAfter(operatorToken, { includeComments: true }) !== tokenAfter) {
  87281. return null;
  87282. }
  87283. /*
  87284. * If there is only one linebreak and it's on the wrong side of the operator, swap the text before and after the operator.
  87285. * foo &&
  87286. * bar
  87287. * would get fixed to
  87288. * foo
  87289. * && bar
  87290. */
  87291. newTextBefore = textAfter;
  87292. newTextAfter = textBefore;
  87293. } else {
  87294. var LINEBREAK_REGEX = astUtils.createGlobalLinebreakMatcher();
  87295. // Otherwise, if no linebreak is desired and no comments interfere, replace the linebreaks with empty strings.
  87296. newTextBefore = desiredStyle === "before" || textBefore.trim() ? textBefore : textBefore.replace(LINEBREAK_REGEX, "");
  87297. newTextAfter = desiredStyle === "after" || textAfter.trim() ? textAfter : textAfter.replace(LINEBREAK_REGEX, "");
  87298. // If there was no change (due to interfering comments), don't output a fix.
  87299. if (newTextBefore === textBefore && newTextAfter === textAfter) {
  87300. return null;
  87301. }
  87302. }
  87303. if (newTextAfter === "" && tokenAfter.type === "Punctuator" && "+-".includes(operatorToken.value) && tokenAfter.value === operatorToken.value) {
  87304. // To avoid accidentally creating a ++ or -- operator, insert a space if the operator is a +/- and the following token is a unary +/-.
  87305. newTextAfter += " ";
  87306. }
  87307. return fixer.replaceTextRange([tokenBefore.range[1], tokenAfter.range[0]], newTextBefore + operatorToken.value + newTextAfter);
  87308. };
  87309. }
  87310. /**
  87311. * Checks the operator placement
  87312. * @param {ASTNode} node The node to check
  87313. * @param {ASTNode} leftSide The node that comes before the operator in `node`
  87314. * @private
  87315. * @returns {void}
  87316. */
  87317. function validateNode(node, leftSide) {
  87318. /*
  87319. * When the left part of a binary expression is a single expression wrapped in
  87320. * parentheses (ex: `(a) + b`), leftToken will be the last token of the expression
  87321. * and operatorToken will be the closing parenthesis.
  87322. * The leftToken should be the last closing parenthesis, and the operatorToken
  87323. * should be the token right after that.
  87324. */
  87325. var operatorToken = sourceCode.getTokenAfter(leftSide, astUtils.isNotClosingParenToken);
  87326. var leftToken = sourceCode.getTokenBefore(operatorToken);
  87327. var rightToken = sourceCode.getTokenAfter(operatorToken);
  87328. var operator = operatorToken.value;
  87329. var operatorStyleOverride = styleOverrides[operator];
  87330. var style = operatorStyleOverride || globalStyle;
  87331. var fix = getFixer(operatorToken, style);
  87332. // if single line
  87333. if (astUtils.isTokenOnSameLine(leftToken, operatorToken) && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
  87334. // do nothing.
  87335. } else if (operatorStyleOverride !== "ignore" && !astUtils.isTokenOnSameLine(leftToken, operatorToken) && !astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
  87336. // lone operator
  87337. context.report({
  87338. node: node,
  87339. loc: {
  87340. line: operatorToken.loc.end.line,
  87341. column: operatorToken.loc.end.column
  87342. },
  87343. message: "Bad line breaking before and after '{{operator}}'.",
  87344. data: {
  87345. operator: operator
  87346. },
  87347. fix: fix
  87348. });
  87349. } else if (style === "before" && astUtils.isTokenOnSameLine(leftToken, operatorToken)) {
  87350. context.report({
  87351. node: node,
  87352. loc: {
  87353. line: operatorToken.loc.end.line,
  87354. column: operatorToken.loc.end.column
  87355. },
  87356. message: "'{{operator}}' should be placed at the beginning of the line.",
  87357. data: {
  87358. operator: operator
  87359. },
  87360. fix: fix
  87361. });
  87362. } else if (style === "after" && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
  87363. context.report({
  87364. node: node,
  87365. loc: {
  87366. line: operatorToken.loc.end.line,
  87367. column: operatorToken.loc.end.column
  87368. },
  87369. message: "'{{operator}}' should be placed at the end of the line.",
  87370. data: {
  87371. operator: operator
  87372. },
  87373. fix: fix
  87374. });
  87375. } else if (style === "none") {
  87376. context.report({
  87377. node: node,
  87378. loc: {
  87379. line: operatorToken.loc.end.line,
  87380. column: operatorToken.loc.end.column
  87381. },
  87382. message: "There should be no line break before or after '{{operator}}'.",
  87383. data: {
  87384. operator: operator
  87385. },
  87386. fix: fix
  87387. });
  87388. }
  87389. }
  87390. /**
  87391. * Validates a binary expression using `validateNode`
  87392. * @param {BinaryExpression|LogicalExpression|AssignmentExpression} node node to be validated
  87393. * @returns {void}
  87394. */
  87395. function validateBinaryExpression(node) {
  87396. validateNode(node, node.left);
  87397. }
  87398. //--------------------------------------------------------------------------
  87399. // Public
  87400. //--------------------------------------------------------------------------
  87401. return {
  87402. BinaryExpression: validateBinaryExpression,
  87403. LogicalExpression: validateBinaryExpression,
  87404. AssignmentExpression: validateBinaryExpression,
  87405. VariableDeclarator: function VariableDeclarator(node) {
  87406. if (node.init) {
  87407. validateNode(node, node.id);
  87408. }
  87409. },
  87410. ConditionalExpression: function ConditionalExpression(node) {
  87411. validateNode(node, node.test);
  87412. validateNode(node, node.consequent);
  87413. }
  87414. };
  87415. }
  87416. };
  87417. },{"../util/ast-utils":405}],343:[function(require,module,exports){
  87418. /**
  87419. * @fileoverview A rule to ensure blank lines within blocks.
  87420. * @author Mathias Schreck <https://github.com/lo1tuma>
  87421. */
  87422. "use strict";
  87423. //------------------------------------------------------------------------------
  87424. // Rule Definition
  87425. //------------------------------------------------------------------------------
  87426. module.exports = {
  87427. meta: {
  87428. type: "layout",
  87429. docs: {
  87430. description: "require or disallow padding within blocks",
  87431. category: "Stylistic Issues",
  87432. recommended: false,
  87433. url: "https://eslint.org/docs/rules/padded-blocks"
  87434. },
  87435. fixable: "whitespace",
  87436. schema: [{
  87437. oneOf: [{
  87438. enum: ["always", "never"]
  87439. }, {
  87440. type: "object",
  87441. properties: {
  87442. blocks: {
  87443. enum: ["always", "never"]
  87444. },
  87445. switches: {
  87446. enum: ["always", "never"]
  87447. },
  87448. classes: {
  87449. enum: ["always", "never"]
  87450. }
  87451. },
  87452. additionalProperties: false,
  87453. minProperties: 1
  87454. }]
  87455. }]
  87456. },
  87457. create: function create(context) {
  87458. var options = {};
  87459. var config = context.options[0] || "always";
  87460. if (typeof config === "string") {
  87461. var shouldHavePadding = config === "always";
  87462. options.blocks = shouldHavePadding;
  87463. options.switches = shouldHavePadding;
  87464. options.classes = shouldHavePadding;
  87465. } else {
  87466. if (Object.prototype.hasOwnProperty.call(config, "blocks")) {
  87467. options.blocks = config.blocks === "always";
  87468. }
  87469. if (Object.prototype.hasOwnProperty.call(config, "switches")) {
  87470. options.switches = config.switches === "always";
  87471. }
  87472. if (Object.prototype.hasOwnProperty.call(config, "classes")) {
  87473. options.classes = config.classes === "always";
  87474. }
  87475. }
  87476. var ALWAYS_MESSAGE = "Block must be padded by blank lines.",
  87477. NEVER_MESSAGE = "Block must not be padded by blank lines.";
  87478. var sourceCode = context.getSourceCode();
  87479. /**
  87480. * Gets the open brace token from a given node.
  87481. * @param {ASTNode} node - A BlockStatement or SwitchStatement node from which to get the open brace.
  87482. * @returns {Token} The token of the open brace.
  87483. */
  87484. function getOpenBrace(node) {
  87485. if (node.type === "SwitchStatement") {
  87486. return sourceCode.getTokenBefore(node.cases[0]);
  87487. }
  87488. return sourceCode.getFirstToken(node);
  87489. }
  87490. /**
  87491. * Checks if the given parameter is a comment node
  87492. * @param {ASTNode|Token} node An AST node or token
  87493. * @returns {boolean} True if node is a comment
  87494. */
  87495. function isComment(node) {
  87496. return node.type === "Line" || node.type === "Block";
  87497. }
  87498. /**
  87499. * Checks if there is padding between two tokens
  87500. * @param {Token} first The first token
  87501. * @param {Token} second The second token
  87502. * @returns {boolean} True if there is at least a line between the tokens
  87503. */
  87504. function isPaddingBetweenTokens(first, second) {
  87505. return second.loc.start.line - first.loc.end.line >= 2;
  87506. }
  87507. /**
  87508. * Checks if the given token has a blank line after it.
  87509. * @param {Token} token The token to check.
  87510. * @returns {boolean} Whether or not the token is followed by a blank line.
  87511. */
  87512. function getFirstBlockToken(token) {
  87513. var prev = void 0,
  87514. first = token;
  87515. do {
  87516. prev = first;
  87517. first = sourceCode.getTokenAfter(first, { includeComments: true });
  87518. } while (isComment(first) && first.loc.start.line === prev.loc.end.line);
  87519. return first;
  87520. }
  87521. /**
  87522. * Checks if the given token is preceeded by a blank line.
  87523. * @param {Token} token The token to check
  87524. * @returns {boolean} Whether or not the token is preceeded by a blank line
  87525. */
  87526. function getLastBlockToken(token) {
  87527. var last = token,
  87528. next = void 0;
  87529. do {
  87530. next = last;
  87531. last = sourceCode.getTokenBefore(last, { includeComments: true });
  87532. } while (isComment(last) && last.loc.end.line === next.loc.start.line);
  87533. return last;
  87534. }
  87535. /**
  87536. * Checks if a node should be padded, according to the rule config.
  87537. * @param {ASTNode} node The AST node to check.
  87538. * @returns {boolean} True if the node should be padded, false otherwise.
  87539. */
  87540. function requirePaddingFor(node) {
  87541. switch (node.type) {
  87542. case "BlockStatement":
  87543. return options.blocks;
  87544. case "SwitchStatement":
  87545. return options.switches;
  87546. case "ClassBody":
  87547. return options.classes;
  87548. /* istanbul ignore next */
  87549. default:
  87550. throw new Error("unreachable");
  87551. }
  87552. }
  87553. /**
  87554. * Checks the given BlockStatement node to be padded if the block is not empty.
  87555. * @param {ASTNode} node The AST node of a BlockStatement.
  87556. * @returns {void} undefined.
  87557. */
  87558. function checkPadding(node) {
  87559. var openBrace = getOpenBrace(node),
  87560. firstBlockToken = getFirstBlockToken(openBrace),
  87561. tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, { includeComments: true }),
  87562. closeBrace = sourceCode.getLastToken(node),
  87563. lastBlockToken = getLastBlockToken(closeBrace),
  87564. tokenAfterLast = sourceCode.getTokenAfter(lastBlockToken, { includeComments: true }),
  87565. blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken),
  87566. blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast);
  87567. if (requirePaddingFor(node)) {
  87568. if (!blockHasTopPadding) {
  87569. context.report({
  87570. node: node,
  87571. loc: { line: tokenBeforeFirst.loc.start.line, column: tokenBeforeFirst.loc.start.column },
  87572. fix: function fix(fixer) {
  87573. return fixer.insertTextAfter(tokenBeforeFirst, "\n");
  87574. },
  87575. message: ALWAYS_MESSAGE
  87576. });
  87577. }
  87578. if (!blockHasBottomPadding) {
  87579. context.report({
  87580. node: node,
  87581. loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 },
  87582. fix: function fix(fixer) {
  87583. return fixer.insertTextBefore(tokenAfterLast, "\n");
  87584. },
  87585. message: ALWAYS_MESSAGE
  87586. });
  87587. }
  87588. } else {
  87589. if (blockHasTopPadding) {
  87590. context.report({
  87591. node: node,
  87592. loc: { line: tokenBeforeFirst.loc.start.line, column: tokenBeforeFirst.loc.start.column },
  87593. fix: function fix(fixer) {
  87594. return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n");
  87595. },
  87596. message: NEVER_MESSAGE
  87597. });
  87598. }
  87599. if (blockHasBottomPadding) {
  87600. context.report({
  87601. node: node,
  87602. loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 },
  87603. message: NEVER_MESSAGE,
  87604. fix: function fix(fixer) {
  87605. return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n");
  87606. }
  87607. });
  87608. }
  87609. }
  87610. }
  87611. var rule = {};
  87612. if (Object.prototype.hasOwnProperty.call(options, "switches")) {
  87613. rule.SwitchStatement = function (node) {
  87614. if (node.cases.length === 0) {
  87615. return;
  87616. }
  87617. checkPadding(node);
  87618. };
  87619. }
  87620. if (Object.prototype.hasOwnProperty.call(options, "blocks")) {
  87621. rule.BlockStatement = function (node) {
  87622. if (node.body.length === 0) {
  87623. return;
  87624. }
  87625. checkPadding(node);
  87626. };
  87627. }
  87628. if (Object.prototype.hasOwnProperty.call(options, "classes")) {
  87629. rule.ClassBody = function (node) {
  87630. if (node.body.length === 0) {
  87631. return;
  87632. }
  87633. checkPadding(node);
  87634. };
  87635. }
  87636. return rule;
  87637. }
  87638. };
  87639. },{}],344:[function(require,module,exports){
  87640. /**
  87641. * @fileoverview Rule to require or disallow newlines between statements
  87642. * @author Toru Nagashima
  87643. */
  87644. "use strict";
  87645. //------------------------------------------------------------------------------
  87646. // Requirements
  87647. //------------------------------------------------------------------------------
  87648. var _templateObject = _taggedTemplateLiteral(["^(s*?", ")s*", "(s*;?)$"], ["^(\\s*?", ")\\s*", "(\\s*;?)$"]);
  87649. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  87650. var astUtils = require("../util/ast-utils");
  87651. //------------------------------------------------------------------------------
  87652. // Helpers
  87653. //------------------------------------------------------------------------------
  87654. var LT = "[" + Array.from(astUtils.LINEBREAKS).join("") + "]";
  87655. var PADDING_LINE_SEQUENCE = new RegExp(String.raw(_templateObject, LT, LT));
  87656. var CJS_EXPORT = /^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/;
  87657. var CJS_IMPORT = /^require\(/;
  87658. /**
  87659. * Creates tester which check if a node starts with specific keyword.
  87660. *
  87661. * @param {string} keyword The keyword to test.
  87662. * @returns {Object} the created tester.
  87663. * @private
  87664. */
  87665. function newKeywordTester(keyword) {
  87666. return {
  87667. test: function test(node, sourceCode) {
  87668. return sourceCode.getFirstToken(node).value === keyword;
  87669. }
  87670. };
  87671. }
  87672. /**
  87673. * Creates tester which check if a node starts with specific keyword and spans a single line.
  87674. *
  87675. * @param {string} keyword The keyword to test.
  87676. * @returns {Object} the created tester.
  87677. * @private
  87678. */
  87679. function newSinglelineKeywordTester(keyword) {
  87680. return {
  87681. test: function test(node, sourceCode) {
  87682. return node.loc.start.line === node.loc.end.line && sourceCode.getFirstToken(node).value === keyword;
  87683. }
  87684. };
  87685. }
  87686. /**
  87687. * Creates tester which check if a node starts with specific keyword and spans multiple lines.
  87688. *
  87689. * @param {string} keyword The keyword to test.
  87690. * @returns {Object} the created tester.
  87691. * @private
  87692. */
  87693. function newMultilineKeywordTester(keyword) {
  87694. return {
  87695. test: function test(node, sourceCode) {
  87696. return node.loc.start.line !== node.loc.end.line && sourceCode.getFirstToken(node).value === keyword;
  87697. }
  87698. };
  87699. }
  87700. /**
  87701. * Creates tester which check if a node is specific type.
  87702. *
  87703. * @param {string} type The node type to test.
  87704. * @returns {Object} the created tester.
  87705. * @private
  87706. */
  87707. function newNodeTypeTester(type) {
  87708. return {
  87709. test: function test(node) {
  87710. return node.type === type;
  87711. }
  87712. };
  87713. }
  87714. /**
  87715. * Checks the given node is an expression statement of IIFE.
  87716. *
  87717. * @param {ASTNode} node The node to check.
  87718. * @returns {boolean} `true` if the node is an expression statement of IIFE.
  87719. * @private
  87720. */
  87721. function isIIFEStatement(node) {
  87722. if (node.type === "ExpressionStatement") {
  87723. var call = node.expression;
  87724. if (call.type === "UnaryExpression") {
  87725. call = call.argument;
  87726. }
  87727. return call.type === "CallExpression" && astUtils.isFunction(call.callee);
  87728. }
  87729. return false;
  87730. }
  87731. /**
  87732. * Checks whether the given node is a block-like statement.
  87733. * This checks the last token of the node is the closing brace of a block.
  87734. *
  87735. * @param {SourceCode} sourceCode The source code to get tokens.
  87736. * @param {ASTNode} node The node to check.
  87737. * @returns {boolean} `true` if the node is a block-like statement.
  87738. * @private
  87739. */
  87740. function isBlockLikeStatement(sourceCode, node) {
  87741. // do-while with a block is a block-like statement.
  87742. if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") {
  87743. return true;
  87744. }
  87745. /*
  87746. * IIFE is a block-like statement specially from
  87747. * JSCS#disallowPaddingNewLinesAfterBlocks.
  87748. */
  87749. if (isIIFEStatement(node)) {
  87750. return true;
  87751. }
  87752. // Checks the last token is a closing brace of blocks.
  87753. var lastToken = sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
  87754. var belongingNode = lastToken && astUtils.isClosingBraceToken(lastToken) ? sourceCode.getNodeByRangeIndex(lastToken.range[0]) : null;
  87755. return Boolean(belongingNode) && (belongingNode.type === "BlockStatement" || belongingNode.type === "SwitchStatement");
  87756. }
  87757. /**
  87758. * Check whether the given node is a directive or not.
  87759. * @param {ASTNode} node The node to check.
  87760. * @param {SourceCode} sourceCode The source code object to get tokens.
  87761. * @returns {boolean} `true` if the node is a directive.
  87762. */
  87763. function isDirective(node, sourceCode) {
  87764. return node.type === "ExpressionStatement" && (node.parent.type === "Program" || node.parent.type === "BlockStatement" && astUtils.isFunction(node.parent.parent)) && node.expression.type === "Literal" && typeof node.expression.value === "string" && !astUtils.isParenthesised(sourceCode, node.expression);
  87765. }
  87766. /**
  87767. * Check whether the given node is a part of directive prologue or not.
  87768. * @param {ASTNode} node The node to check.
  87769. * @param {SourceCode} sourceCode The source code object to get tokens.
  87770. * @returns {boolean} `true` if the node is a part of directive prologue.
  87771. */
  87772. function isDirectivePrologue(node, sourceCode) {
  87773. if (isDirective(node, sourceCode)) {
  87774. var _iteratorNormalCompletion = true;
  87775. var _didIteratorError = false;
  87776. var _iteratorError = undefined;
  87777. try {
  87778. for (var _iterator = node.parent.body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  87779. var sibling = _step.value;
  87780. if (sibling === node) {
  87781. break;
  87782. }
  87783. if (!isDirective(sibling, sourceCode)) {
  87784. return false;
  87785. }
  87786. }
  87787. } catch (err) {
  87788. _didIteratorError = true;
  87789. _iteratorError = err;
  87790. } finally {
  87791. try {
  87792. if (!_iteratorNormalCompletion && _iterator.return) {
  87793. _iterator.return();
  87794. }
  87795. } finally {
  87796. if (_didIteratorError) {
  87797. throw _iteratorError;
  87798. }
  87799. }
  87800. }
  87801. return true;
  87802. }
  87803. return false;
  87804. }
  87805. /**
  87806. * Gets the actual last token.
  87807. *
  87808. * If a semicolon is semicolon-less style's semicolon, this ignores it.
  87809. * For example:
  87810. *
  87811. * foo()
  87812. * ;[1, 2, 3].forEach(bar)
  87813. *
  87814. * @param {SourceCode} sourceCode The source code to get tokens.
  87815. * @param {ASTNode} node The node to get.
  87816. * @returns {Token} The actual last token.
  87817. * @private
  87818. */
  87819. function getActualLastToken(sourceCode, node) {
  87820. var semiToken = sourceCode.getLastToken(node);
  87821. var prevToken = sourceCode.getTokenBefore(semiToken);
  87822. var nextToken = sourceCode.getTokenAfter(semiToken);
  87823. var isSemicolonLessStyle = Boolean(prevToken && nextToken && prevToken.range[0] >= node.range[0] && astUtils.isSemicolonToken(semiToken) && semiToken.loc.start.line !== prevToken.loc.end.line && semiToken.loc.end.line === nextToken.loc.start.line);
  87824. return isSemicolonLessStyle ? prevToken : semiToken;
  87825. }
  87826. /**
  87827. * This returns the concatenation of the first 2 captured strings.
  87828. * @param {string} _ Unused. Whole matched string.
  87829. * @param {string} trailingSpaces The trailing spaces of the first line.
  87830. * @param {string} indentSpaces The indentation spaces of the last line.
  87831. * @returns {string} The concatenation of trailingSpaces and indentSpaces.
  87832. * @private
  87833. */
  87834. function replacerToRemovePaddingLines(_, trailingSpaces, indentSpaces) {
  87835. return trailingSpaces + indentSpaces;
  87836. }
  87837. /**
  87838. * Check and report statements for `any` configuration.
  87839. * It does nothing.
  87840. *
  87841. * @returns {void}
  87842. * @private
  87843. */
  87844. function verifyForAny() {}
  87845. /**
  87846. * Check and report statements for `never` configuration.
  87847. * This autofix removes blank lines between the given 2 statements.
  87848. * However, if comments exist between 2 blank lines, it does not remove those
  87849. * blank lines automatically.
  87850. *
  87851. * @param {RuleContext} context The rule context to report.
  87852. * @param {ASTNode} _ Unused. The previous node to check.
  87853. * @param {ASTNode} nextNode The next node to check.
  87854. * @param {Array<Token[]>} paddingLines The array of token pairs that blank
  87855. * lines exist between the pair.
  87856. * @returns {void}
  87857. * @private
  87858. */
  87859. function verifyForNever(context, _, nextNode, paddingLines) {
  87860. if (paddingLines.length === 0) {
  87861. return;
  87862. }
  87863. context.report({
  87864. node: nextNode,
  87865. message: "Unexpected blank line before this statement.",
  87866. fix: function fix(fixer) {
  87867. if (paddingLines.length >= 2) {
  87868. return null;
  87869. }
  87870. var prevToken = paddingLines[0][0];
  87871. var nextToken = paddingLines[0][1];
  87872. var start = prevToken.range[1];
  87873. var end = nextToken.range[0];
  87874. var text = context.getSourceCode().text.slice(start, end).replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines);
  87875. return fixer.replaceTextRange([start, end], text);
  87876. }
  87877. });
  87878. }
  87879. /**
  87880. * Check and report statements for `always` configuration.
  87881. * This autofix inserts a blank line between the given 2 statements.
  87882. * If the `prevNode` has trailing comments, it inserts a blank line after the
  87883. * trailing comments.
  87884. *
  87885. * @param {RuleContext} context The rule context to report.
  87886. * @param {ASTNode} prevNode The previous node to check.
  87887. * @param {ASTNode} nextNode The next node to check.
  87888. * @param {Array<Token[]>} paddingLines The array of token pairs that blank
  87889. * lines exist between the pair.
  87890. * @returns {void}
  87891. * @private
  87892. */
  87893. function verifyForAlways(context, prevNode, nextNode, paddingLines) {
  87894. if (paddingLines.length > 0) {
  87895. return;
  87896. }
  87897. context.report({
  87898. node: nextNode,
  87899. message: "Expected blank line before this statement.",
  87900. fix: function fix(fixer) {
  87901. var sourceCode = context.getSourceCode();
  87902. var prevToken = getActualLastToken(sourceCode, prevNode);
  87903. var nextToken = sourceCode.getFirstTokenBetween(prevToken, nextNode, {
  87904. includeComments: true,
  87905. /**
  87906. * Skip the trailing comments of the previous node.
  87907. * This inserts a blank line after the last trailing comment.
  87908. *
  87909. * For example:
  87910. *
  87911. * foo(); // trailing comment.
  87912. * // comment.
  87913. * bar();
  87914. *
  87915. * Get fixed to:
  87916. *
  87917. * foo(); // trailing comment.
  87918. *
  87919. * // comment.
  87920. * bar();
  87921. *
  87922. * @param {Token} token The token to check.
  87923. * @returns {boolean} `true` if the token is not a trailing comment.
  87924. * @private
  87925. */
  87926. filter: function filter(token) {
  87927. if (astUtils.isTokenOnSameLine(prevToken, token)) {
  87928. prevToken = token;
  87929. return false;
  87930. }
  87931. return true;
  87932. }
  87933. }) || nextNode;
  87934. var insertText = astUtils.isTokenOnSameLine(prevToken, nextToken) ? "\n\n" : "\n";
  87935. return fixer.insertTextAfter(prevToken, insertText);
  87936. }
  87937. });
  87938. }
  87939. /**
  87940. * Types of blank lines.
  87941. * `any`, `never`, and `always` are defined.
  87942. * Those have `verify` method to check and report statements.
  87943. * @private
  87944. */
  87945. var PaddingTypes = {
  87946. any: { verify: verifyForAny },
  87947. never: { verify: verifyForNever },
  87948. always: { verify: verifyForAlways }
  87949. };
  87950. /**
  87951. * Types of statements.
  87952. * Those have `test` method to check it matches to the given statement.
  87953. * @private
  87954. */
  87955. var StatementTypes = {
  87956. "*": { test: function test() {
  87957. return true;
  87958. } },
  87959. "block-like": {
  87960. test: function test(node, sourceCode) {
  87961. return isBlockLikeStatement(sourceCode, node);
  87962. }
  87963. },
  87964. "cjs-export": {
  87965. test: function test(node, sourceCode) {
  87966. return node.type === "ExpressionStatement" && node.expression.type === "AssignmentExpression" && CJS_EXPORT.test(sourceCode.getText(node.expression.left));
  87967. }
  87968. },
  87969. "cjs-import": {
  87970. test: function test(node, sourceCode) {
  87971. return node.type === "VariableDeclaration" && node.declarations.length > 0 && Boolean(node.declarations[0].init) && CJS_IMPORT.test(sourceCode.getText(node.declarations[0].init));
  87972. }
  87973. },
  87974. directive: {
  87975. test: isDirectivePrologue
  87976. },
  87977. expression: {
  87978. test: function test(node, sourceCode) {
  87979. return node.type === "ExpressionStatement" && !isDirectivePrologue(node, sourceCode);
  87980. }
  87981. },
  87982. iife: {
  87983. test: isIIFEStatement
  87984. },
  87985. "multiline-block-like": {
  87986. test: function test(node, sourceCode) {
  87987. return node.loc.start.line !== node.loc.end.line && isBlockLikeStatement(sourceCode, node);
  87988. }
  87989. },
  87990. "multiline-expression": {
  87991. test: function test(node, sourceCode) {
  87992. return node.loc.start.line !== node.loc.end.line && node.type === "ExpressionStatement" && !isDirectivePrologue(node, sourceCode);
  87993. }
  87994. },
  87995. "multiline-const": newMultilineKeywordTester("const"),
  87996. "multiline-let": newMultilineKeywordTester("let"),
  87997. "multiline-var": newMultilineKeywordTester("var"),
  87998. "singleline-const": newSinglelineKeywordTester("const"),
  87999. "singleline-let": newSinglelineKeywordTester("let"),
  88000. "singleline-var": newSinglelineKeywordTester("var"),
  88001. block: newNodeTypeTester("BlockStatement"),
  88002. empty: newNodeTypeTester("EmptyStatement"),
  88003. function: newNodeTypeTester("FunctionDeclaration"),
  88004. break: newKeywordTester("break"),
  88005. case: newKeywordTester("case"),
  88006. class: newKeywordTester("class"),
  88007. const: newKeywordTester("const"),
  88008. continue: newKeywordTester("continue"),
  88009. debugger: newKeywordTester("debugger"),
  88010. default: newKeywordTester("default"),
  88011. do: newKeywordTester("do"),
  88012. export: newKeywordTester("export"),
  88013. for: newKeywordTester("for"),
  88014. if: newKeywordTester("if"),
  88015. import: newKeywordTester("import"),
  88016. let: newKeywordTester("let"),
  88017. return: newKeywordTester("return"),
  88018. switch: newKeywordTester("switch"),
  88019. throw: newKeywordTester("throw"),
  88020. try: newKeywordTester("try"),
  88021. var: newKeywordTester("var"),
  88022. while: newKeywordTester("while"),
  88023. with: newKeywordTester("with")
  88024. };
  88025. //------------------------------------------------------------------------------
  88026. // Rule Definition
  88027. //------------------------------------------------------------------------------
  88028. module.exports = {
  88029. meta: {
  88030. type: "layout",
  88031. docs: {
  88032. description: "require or disallow padding lines between statements",
  88033. category: "Stylistic Issues",
  88034. recommended: false,
  88035. url: "https://eslint.org/docs/rules/padding-line-between-statements"
  88036. },
  88037. fixable: "whitespace",
  88038. schema: {
  88039. definitions: {
  88040. paddingType: {
  88041. enum: Object.keys(PaddingTypes)
  88042. },
  88043. statementType: {
  88044. anyOf: [{ enum: Object.keys(StatementTypes) }, {
  88045. type: "array",
  88046. items: { enum: Object.keys(StatementTypes) },
  88047. minItems: 1,
  88048. uniqueItems: true,
  88049. additionalItems: false
  88050. }]
  88051. }
  88052. },
  88053. type: "array",
  88054. items: {
  88055. type: "object",
  88056. properties: {
  88057. blankLine: { $ref: "#/definitions/paddingType" },
  88058. prev: { $ref: "#/definitions/statementType" },
  88059. next: { $ref: "#/definitions/statementType" }
  88060. },
  88061. additionalProperties: false,
  88062. required: ["blankLine", "prev", "next"]
  88063. },
  88064. additionalItems: false
  88065. }
  88066. },
  88067. create: function create(context) {
  88068. var sourceCode = context.getSourceCode();
  88069. var configureList = context.options || [];
  88070. var scopeInfo = null;
  88071. /**
  88072. * Processes to enter to new scope.
  88073. * This manages the current previous statement.
  88074. * @returns {void}
  88075. * @private
  88076. */
  88077. function enterScope() {
  88078. scopeInfo = {
  88079. upper: scopeInfo,
  88080. prevNode: null
  88081. };
  88082. }
  88083. /**
  88084. * Processes to exit from the current scope.
  88085. * @returns {void}
  88086. * @private
  88087. */
  88088. function exitScope() {
  88089. scopeInfo = scopeInfo.upper;
  88090. }
  88091. /**
  88092. * Checks whether the given node matches the given type.
  88093. *
  88094. * @param {ASTNode} node The statement node to check.
  88095. * @param {string|string[]} type The statement type to check.
  88096. * @returns {boolean} `true` if the statement node matched the type.
  88097. * @private
  88098. */
  88099. function match(node, type) {
  88100. var innerStatementNode = node;
  88101. while (innerStatementNode.type === "LabeledStatement") {
  88102. innerStatementNode = innerStatementNode.body;
  88103. }
  88104. if (Array.isArray(type)) {
  88105. return type.some(match.bind(null, innerStatementNode));
  88106. }
  88107. return StatementTypes[type].test(innerStatementNode, sourceCode);
  88108. }
  88109. /**
  88110. * Finds the last matched configure from configureList.
  88111. *
  88112. * @param {ASTNode} prevNode The previous statement to match.
  88113. * @param {ASTNode} nextNode The current statement to match.
  88114. * @returns {Object} The tester of the last matched configure.
  88115. * @private
  88116. */
  88117. function getPaddingType(prevNode, nextNode) {
  88118. for (var i = configureList.length - 1; i >= 0; --i) {
  88119. var configure = configureList[i];
  88120. var matched = match(prevNode, configure.prev) && match(nextNode, configure.next);
  88121. if (matched) {
  88122. return PaddingTypes[configure.blankLine];
  88123. }
  88124. }
  88125. return PaddingTypes.any;
  88126. }
  88127. /**
  88128. * Gets padding line sequences between the given 2 statements.
  88129. * Comments are separators of the padding line sequences.
  88130. *
  88131. * @param {ASTNode} prevNode The previous statement to count.
  88132. * @param {ASTNode} nextNode The current statement to count.
  88133. * @returns {Array<Token[]>} The array of token pairs.
  88134. * @private
  88135. */
  88136. function getPaddingLineSequences(prevNode, nextNode) {
  88137. var pairs = [];
  88138. var prevToken = getActualLastToken(sourceCode, prevNode);
  88139. if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
  88140. do {
  88141. var token = sourceCode.getTokenAfter(prevToken, { includeComments: true });
  88142. if (token.loc.start.line - prevToken.loc.end.line >= 2) {
  88143. pairs.push([prevToken, token]);
  88144. }
  88145. prevToken = token;
  88146. } while (prevToken.range[0] < nextNode.range[0]);
  88147. }
  88148. return pairs;
  88149. }
  88150. /**
  88151. * Verify padding lines between the given node and the previous node.
  88152. *
  88153. * @param {ASTNode} node The node to verify.
  88154. * @returns {void}
  88155. * @private
  88156. */
  88157. function verify(node) {
  88158. var parentType = node.parent.type;
  88159. var validParent = astUtils.STATEMENT_LIST_PARENTS.has(parentType) || parentType === "SwitchStatement";
  88160. if (!validParent) {
  88161. return;
  88162. }
  88163. // Save this node as the current previous statement.
  88164. var prevNode = scopeInfo.prevNode;
  88165. // Verify.
  88166. if (prevNode) {
  88167. var type = getPaddingType(prevNode, node);
  88168. var paddingLines = getPaddingLineSequences(prevNode, node);
  88169. type.verify(context, prevNode, node, paddingLines);
  88170. }
  88171. scopeInfo.prevNode = node;
  88172. }
  88173. /**
  88174. * Verify padding lines between the given node and the previous node.
  88175. * Then process to enter to new scope.
  88176. *
  88177. * @param {ASTNode} node The node to verify.
  88178. * @returns {void}
  88179. * @private
  88180. */
  88181. function verifyThenEnterScope(node) {
  88182. verify(node);
  88183. enterScope();
  88184. }
  88185. return {
  88186. Program: enterScope,
  88187. BlockStatement: enterScope,
  88188. SwitchStatement: enterScope,
  88189. "Program:exit": exitScope,
  88190. "BlockStatement:exit": exitScope,
  88191. "SwitchStatement:exit": exitScope,
  88192. ":statement": verify,
  88193. SwitchCase: verifyThenEnterScope,
  88194. "SwitchCase:exit": exitScope
  88195. };
  88196. }
  88197. };
  88198. },{"../util/ast-utils":405}],345:[function(require,module,exports){
  88199. /**
  88200. * @fileoverview A rule to suggest using arrow functions as callbacks.
  88201. * @author Toru Nagashima
  88202. */
  88203. "use strict";
  88204. //------------------------------------------------------------------------------
  88205. // Helpers
  88206. //------------------------------------------------------------------------------
  88207. /**
  88208. * Checks whether or not a given variable is a function name.
  88209. * @param {eslint-scope.Variable} variable - A variable to check.
  88210. * @returns {boolean} `true` if the variable is a function name.
  88211. */
  88212. function isFunctionName(variable) {
  88213. return variable && variable.defs[0].type === "FunctionName";
  88214. }
  88215. /**
  88216. * Checks whether or not a given MetaProperty node equals to a given value.
  88217. * @param {ASTNode} node - A MetaProperty node to check.
  88218. * @param {string} metaName - The name of `MetaProperty.meta`.
  88219. * @param {string} propertyName - The name of `MetaProperty.property`.
  88220. * @returns {boolean} `true` if the node is the specific value.
  88221. */
  88222. function checkMetaProperty(node, metaName, propertyName) {
  88223. return node.meta.name === metaName && node.property.name === propertyName;
  88224. }
  88225. /**
  88226. * Gets the variable object of `arguments` which is defined implicitly.
  88227. * @param {eslint-scope.Scope} scope - A scope to get.
  88228. * @returns {eslint-scope.Variable} The found variable object.
  88229. */
  88230. function getVariableOfArguments(scope) {
  88231. var variables = scope.variables;
  88232. for (var i = 0; i < variables.length; ++i) {
  88233. var variable = variables[i];
  88234. if (variable.name === "arguments") {
  88235. /*
  88236. * If there was a parameter which is named "arguments", the
  88237. * implicit "arguments" is not defined.
  88238. * So does fast return with null.
  88239. */
  88240. return variable.identifiers.length === 0 ? variable : null;
  88241. }
  88242. }
  88243. /* istanbul ignore next */
  88244. return null;
  88245. }
  88246. /**
  88247. * Checkes whether or not a given node is a callback.
  88248. * @param {ASTNode} node - A node to check.
  88249. * @returns {Object}
  88250. * {boolean} retv.isCallback - `true` if the node is a callback.
  88251. * {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`.
  88252. */
  88253. function getCallbackInfo(node) {
  88254. var retv = { isCallback: false, isLexicalThis: false };
  88255. var currentNode = node;
  88256. var parent = node.parent;
  88257. while (currentNode) {
  88258. switch (parent.type) {
  88259. // Checks parents recursively.
  88260. case "LogicalExpression":
  88261. case "ConditionalExpression":
  88262. break;
  88263. // Checks whether the parent node is `.bind(this)` call.
  88264. case "MemberExpression":
  88265. if (parent.object === currentNode && !parent.property.computed && parent.property.type === "Identifier" && parent.property.name === "bind" && parent.parent.type === "CallExpression" && parent.parent.callee === parent) {
  88266. retv.isLexicalThis = parent.parent.arguments.length === 1 && parent.parent.arguments[0].type === "ThisExpression";
  88267. parent = parent.parent;
  88268. } else {
  88269. return retv;
  88270. }
  88271. break;
  88272. // Checks whether the node is a callback.
  88273. case "CallExpression":
  88274. case "NewExpression":
  88275. if (parent.callee !== currentNode) {
  88276. retv.isCallback = true;
  88277. }
  88278. return retv;
  88279. default:
  88280. return retv;
  88281. }
  88282. currentNode = parent;
  88283. parent = parent.parent;
  88284. }
  88285. /* istanbul ignore next */
  88286. throw new Error("unreachable");
  88287. }
  88288. /**
  88289. * Checks whether a simple list of parameters contains any duplicates. This does not handle complex
  88290. * parameter lists (e.g. with destructuring), since complex parameter lists are a SyntaxError with duplicate
  88291. * parameter names anyway. Instead, it always returns `false` for complex parameter lists.
  88292. * @param {ASTNode[]} paramsList The list of parameters for a function
  88293. * @returns {boolean} `true` if the list of parameters contains any duplicates
  88294. */
  88295. function hasDuplicateParams(paramsList) {
  88296. return paramsList.every(function (param) {
  88297. return param.type === "Identifier";
  88298. }) && paramsList.length !== new Set(paramsList.map(function (param) {
  88299. return param.name;
  88300. })).size;
  88301. }
  88302. //------------------------------------------------------------------------------
  88303. // Rule Definition
  88304. //------------------------------------------------------------------------------
  88305. module.exports = {
  88306. meta: {
  88307. type: "suggestion",
  88308. docs: {
  88309. description: "require using arrow functions for callbacks",
  88310. category: "ECMAScript 6",
  88311. recommended: false,
  88312. url: "https://eslint.org/docs/rules/prefer-arrow-callback"
  88313. },
  88314. schema: [{
  88315. type: "object",
  88316. properties: {
  88317. allowNamedFunctions: {
  88318. type: "boolean"
  88319. },
  88320. allowUnboundThis: {
  88321. type: "boolean"
  88322. }
  88323. },
  88324. additionalProperties: false
  88325. }],
  88326. fixable: "code"
  88327. },
  88328. create: function create(context) {
  88329. var options = context.options[0] || {};
  88330. var allowUnboundThis = options.allowUnboundThis !== false; // default to true
  88331. var allowNamedFunctions = options.allowNamedFunctions;
  88332. var sourceCode = context.getSourceCode();
  88333. /*
  88334. * {Array<{this: boolean, super: boolean, meta: boolean}>}
  88335. * - this - A flag which shows there are one or more ThisExpression.
  88336. * - super - A flag which shows there are one or more Super.
  88337. * - meta - A flag which shows there are one or more MethProperty.
  88338. */
  88339. var stack = [];
  88340. /**
  88341. * Pushes new function scope with all `false` flags.
  88342. * @returns {void}
  88343. */
  88344. function enterScope() {
  88345. stack.push({ this: false, super: false, meta: false });
  88346. }
  88347. /**
  88348. * Pops a function scope from the stack.
  88349. * @returns {{this: boolean, super: boolean, meta: boolean}} The information of the last scope.
  88350. */
  88351. function exitScope() {
  88352. return stack.pop();
  88353. }
  88354. return {
  88355. // Reset internal state.
  88356. Program: function Program() {
  88357. stack = [];
  88358. },
  88359. // If there are below, it cannot replace with arrow functions merely.
  88360. ThisExpression: function ThisExpression() {
  88361. var info = stack[stack.length - 1];
  88362. if (info) {
  88363. info.this = true;
  88364. }
  88365. },
  88366. Super: function Super() {
  88367. var info = stack[stack.length - 1];
  88368. if (info) {
  88369. info.super = true;
  88370. }
  88371. },
  88372. MetaProperty: function MetaProperty(node) {
  88373. var info = stack[stack.length - 1];
  88374. if (info && checkMetaProperty(node, "new", "target")) {
  88375. info.meta = true;
  88376. }
  88377. },
  88378. // To skip nested scopes.
  88379. FunctionDeclaration: enterScope,
  88380. "FunctionDeclaration:exit": exitScope,
  88381. // Main.
  88382. FunctionExpression: enterScope,
  88383. "FunctionExpression:exit": function FunctionExpressionExit(node) {
  88384. var scopeInfo = exitScope();
  88385. // Skip named function expressions
  88386. if (allowNamedFunctions && node.id && node.id.name) {
  88387. return;
  88388. }
  88389. // Skip generators.
  88390. if (node.generator) {
  88391. return;
  88392. }
  88393. // Skip recursive functions.
  88394. var nameVar = context.getDeclaredVariables(node)[0];
  88395. if (isFunctionName(nameVar) && nameVar.references.length > 0) {
  88396. return;
  88397. }
  88398. // Skip if it's using arguments.
  88399. var variable = getVariableOfArguments(context.getScope());
  88400. if (variable && variable.references.length > 0) {
  88401. return;
  88402. }
  88403. // Reports if it's a callback which can replace with arrows.
  88404. var callbackInfo = getCallbackInfo(node);
  88405. if (callbackInfo.isCallback && (!allowUnboundThis || !scopeInfo.this || callbackInfo.isLexicalThis) && !scopeInfo.super && !scopeInfo.meta) {
  88406. context.report({
  88407. node: node,
  88408. message: "Unexpected function expression.",
  88409. fix: function fix(fixer) {
  88410. if (!callbackInfo.isLexicalThis && scopeInfo.this || hasDuplicateParams(node.params)) {
  88411. /*
  88412. * If the callback function does not have .bind(this) and contains a reference to `this`, there
  88413. * is no way to determine what `this` should be, so don't perform any fixes.
  88414. * If the callback function has duplicates in its list of parameters (possible in sloppy mode),
  88415. * don't replace it with an arrow function, because this is a SyntaxError with arrow functions.
  88416. */
  88417. return null;
  88418. }
  88419. var paramsLeftParen = node.params.length ? sourceCode.getTokenBefore(node.params[0]) : sourceCode.getTokenBefore(node.body, 1);
  88420. var paramsRightParen = sourceCode.getTokenBefore(node.body);
  88421. var asyncKeyword = node.async ? "async " : "";
  88422. var paramsFullText = sourceCode.text.slice(paramsLeftParen.range[0], paramsRightParen.range[1]);
  88423. var arrowFunctionText = "" + asyncKeyword + paramsFullText + " => " + sourceCode.getText(node.body);
  88424. /*
  88425. * If the callback function has `.bind(this)`, replace it with an arrow function and remove the binding.
  88426. * Otherwise, just replace the arrow function itself.
  88427. */
  88428. var replacedNode = callbackInfo.isLexicalThis ? node.parent.parent : node;
  88429. /*
  88430. * If the replaced node is part of a BinaryExpression, LogicalExpression, or MemberExpression, then
  88431. * the arrow function needs to be parenthesized, because `foo || () => {}` is invalid syntax even
  88432. * though `foo || function() {}` is valid.
  88433. */
  88434. var needsParens = replacedNode.parent.type !== "CallExpression" && replacedNode.parent.type !== "ConditionalExpression";
  88435. var replacementText = needsParens ? "(" + arrowFunctionText + ")" : arrowFunctionText;
  88436. return fixer.replaceText(replacedNode, replacementText);
  88437. }
  88438. });
  88439. }
  88440. }
  88441. };
  88442. }
  88443. };
  88444. },{}],346:[function(require,module,exports){
  88445. /**
  88446. * @fileoverview A rule to suggest using of const declaration for variables that are never reassigned after declared.
  88447. * @author Toru Nagashima
  88448. */
  88449. "use strict";
  88450. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  88451. var astUtils = require("../util/ast-utils");
  88452. //------------------------------------------------------------------------------
  88453. // Helpers
  88454. //------------------------------------------------------------------------------
  88455. var PATTERN_TYPE = /^(?:.+?Pattern|RestElement|SpreadProperty|ExperimentalRestProperty|Property)$/;
  88456. var DECLARATION_HOST_TYPE = /^(?:Program|BlockStatement|SwitchCase)$/;
  88457. var DESTRUCTURING_HOST_TYPE = /^(?:VariableDeclarator|AssignmentExpression)$/;
  88458. /**
  88459. * Checks whether a given node is located at `ForStatement.init` or not.
  88460. *
  88461. * @param {ASTNode} node - A node to check.
  88462. * @returns {boolean} `true` if the node is located at `ForStatement.init`.
  88463. */
  88464. function isInitOfForStatement(node) {
  88465. return node.parent.type === "ForStatement" && node.parent.init === node;
  88466. }
  88467. /**
  88468. * Checks whether a given Identifier node becomes a VariableDeclaration or not.
  88469. *
  88470. * @param {ASTNode} identifier - An Identifier node to check.
  88471. * @returns {boolean} `true` if the node can become a VariableDeclaration.
  88472. */
  88473. function canBecomeVariableDeclaration(identifier) {
  88474. var node = identifier.parent;
  88475. while (PATTERN_TYPE.test(node.type)) {
  88476. node = node.parent;
  88477. }
  88478. return node.type === "VariableDeclarator" || node.type === "AssignmentExpression" && node.parent.type === "ExpressionStatement" && DECLARATION_HOST_TYPE.test(node.parent.parent.type);
  88479. }
  88480. /**
  88481. * Checks if an property or element is from outer scope or function parameters
  88482. * in destructing pattern.
  88483. *
  88484. * @param {string} name - A variable name to be checked.
  88485. * @param {eslint-scope.Scope} initScope - A scope to start find.
  88486. * @returns {boolean} Indicates if the variable is from outer scope or function parameters.
  88487. */
  88488. function isOuterVariableInDestructing(name, initScope) {
  88489. if (initScope.through.find(function (ref) {
  88490. return ref.resolved && ref.resolved.name === name;
  88491. })) {
  88492. return true;
  88493. }
  88494. var variable = astUtils.getVariableByName(initScope, name);
  88495. if (variable !== null) {
  88496. return variable.defs.some(function (def) {
  88497. return def.type === "Parameter";
  88498. });
  88499. }
  88500. return false;
  88501. }
  88502. /**
  88503. * Gets the VariableDeclarator/AssignmentExpression node that a given reference
  88504. * belongs to.
  88505. * This is used to detect a mix of reassigned and never reassigned in a
  88506. * destructuring.
  88507. *
  88508. * @param {eslint-scope.Reference} reference - A reference to get.
  88509. * @returns {ASTNode|null} A VariableDeclarator/AssignmentExpression node or
  88510. * null.
  88511. */
  88512. function getDestructuringHost(reference) {
  88513. if (!reference.isWrite()) {
  88514. return null;
  88515. }
  88516. var node = reference.identifier.parent;
  88517. while (PATTERN_TYPE.test(node.type)) {
  88518. node = node.parent;
  88519. }
  88520. if (!DESTRUCTURING_HOST_TYPE.test(node.type)) {
  88521. return null;
  88522. }
  88523. return node;
  88524. }
  88525. /**
  88526. * Determines if a destructuring assignment node contains
  88527. * any MemberExpression nodes. This is used to determine if a
  88528. * variable that is only written once using destructuring can be
  88529. * safely converted into a const declaration.
  88530. * @param {ASTNode} node The ObjectPattern or ArrayPattern node to check.
  88531. * @returns {boolean} True if the destructuring pattern contains
  88532. * a MemberExpression, false if not.
  88533. */
  88534. function hasMemberExpressionAssignment(node) {
  88535. switch (node.type) {
  88536. case "ObjectPattern":
  88537. return node.properties.some(function (prop) {
  88538. if (prop) {
  88539. /*
  88540. * Spread elements have an argument property while
  88541. * others have a value property. Because different
  88542. * parsers use different node types for spread elements,
  88543. * we just check if there is an argument property.
  88544. */
  88545. return hasMemberExpressionAssignment(prop.argument || prop.value);
  88546. }
  88547. return false;
  88548. });
  88549. case "ArrayPattern":
  88550. return node.elements.some(function (element) {
  88551. if (element) {
  88552. return hasMemberExpressionAssignment(element);
  88553. }
  88554. return false;
  88555. });
  88556. case "AssignmentPattern":
  88557. return hasMemberExpressionAssignment(node.left);
  88558. case "MemberExpression":
  88559. return true;
  88560. // no default
  88561. }
  88562. return false;
  88563. }
  88564. /**
  88565. * Gets an identifier node of a given variable.
  88566. *
  88567. * If the initialization exists or one or more reading references exist before
  88568. * the first assignment, the identifier node is the node of the declaration.
  88569. * Otherwise, the identifier node is the node of the first assignment.
  88570. *
  88571. * If the variable should not change to const, this function returns null.
  88572. * - If the variable is reassigned.
  88573. * - If the variable is never initialized nor assigned.
  88574. * - If the variable is initialized in a different scope from the declaration.
  88575. * - If the unique assignment of the variable cannot change to a declaration.
  88576. * e.g. `if (a) b = 1` / `return (b = 1)`
  88577. * - If the variable is declared in the global scope and `eslintUsed` is `true`.
  88578. * `/*exported foo` directive comment makes such variables. This rule does not
  88579. * warn such variables because this rule cannot distinguish whether the
  88580. * exported variables are reassigned or not.
  88581. *
  88582. * @param {eslint-scope.Variable} variable - A variable to get.
  88583. * @param {boolean} ignoreReadBeforeAssign -
  88584. * The value of `ignoreReadBeforeAssign` option.
  88585. * @returns {ASTNode|null}
  88586. * An Identifier node if the variable should change to const.
  88587. * Otherwise, null.
  88588. */
  88589. function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) {
  88590. if (variable.eslintUsed && variable.scope.type === "global") {
  88591. return null;
  88592. }
  88593. // Finds the unique WriteReference.
  88594. var writer = null;
  88595. var isReadBeforeInit = false;
  88596. var references = variable.references;
  88597. for (var i = 0; i < references.length; ++i) {
  88598. var reference = references[i];
  88599. if (reference.isWrite()) {
  88600. var isReassigned = writer !== null && writer.identifier !== reference.identifier;
  88601. if (isReassigned) {
  88602. return null;
  88603. }
  88604. var destructuringHost = getDestructuringHost(reference);
  88605. if (destructuringHost !== null && destructuringHost.left !== void 0) {
  88606. var leftNode = destructuringHost.left;
  88607. var hasOuterVariables = false,
  88608. hasNonIdentifiers = false;
  88609. if (leftNode.type === "ObjectPattern") {
  88610. var properties = leftNode.properties;
  88611. hasOuterVariables = properties.filter(function (prop) {
  88612. return prop.value;
  88613. }).map(function (prop) {
  88614. return prop.value.name;
  88615. }).some(function (name) {
  88616. return isOuterVariableInDestructing(name, variable.scope);
  88617. });
  88618. hasNonIdentifiers = hasMemberExpressionAssignment(leftNode);
  88619. } else if (leftNode.type === "ArrayPattern") {
  88620. var elements = leftNode.elements;
  88621. hasOuterVariables = elements.map(function (element) {
  88622. return element && element.name;
  88623. }).some(function (name) {
  88624. return isOuterVariableInDestructing(name, variable.scope);
  88625. });
  88626. hasNonIdentifiers = hasMemberExpressionAssignment(leftNode);
  88627. }
  88628. if (hasOuterVariables || hasNonIdentifiers) {
  88629. return null;
  88630. }
  88631. }
  88632. writer = reference;
  88633. } else if (reference.isRead() && writer === null) {
  88634. if (ignoreReadBeforeAssign) {
  88635. return null;
  88636. }
  88637. isReadBeforeInit = true;
  88638. }
  88639. }
  88640. /*
  88641. * If the assignment is from a different scope, ignore it.
  88642. * If the assignment cannot change to a declaration, ignore it.
  88643. */
  88644. var shouldBeConst = writer !== null && writer.from === variable.scope && canBecomeVariableDeclaration(writer.identifier);
  88645. if (!shouldBeConst) {
  88646. return null;
  88647. }
  88648. if (isReadBeforeInit) {
  88649. return variable.defs[0].name;
  88650. }
  88651. return writer.identifier;
  88652. }
  88653. /**
  88654. * Groups by the VariableDeclarator/AssignmentExpression node that each
  88655. * reference of given variables belongs to.
  88656. * This is used to detect a mix of reassigned and never reassigned in a
  88657. * destructuring.
  88658. *
  88659. * @param {eslint-scope.Variable[]} variables - Variables to group by destructuring.
  88660. * @param {boolean} ignoreReadBeforeAssign -
  88661. * The value of `ignoreReadBeforeAssign` option.
  88662. * @returns {Map<ASTNode, ASTNode[]>} Grouped identifier nodes.
  88663. */
  88664. function groupByDestructuring(variables, ignoreReadBeforeAssign) {
  88665. var identifierMap = new Map();
  88666. for (var i = 0; i < variables.length; ++i) {
  88667. var variable = variables[i];
  88668. var references = variable.references;
  88669. var identifier = getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign);
  88670. var prevId = null;
  88671. for (var j = 0; j < references.length; ++j) {
  88672. var reference = references[j];
  88673. var id = reference.identifier;
  88674. /*
  88675. * Avoid counting a reference twice or more for default values of
  88676. * destructuring.
  88677. */
  88678. if (id === prevId) {
  88679. continue;
  88680. }
  88681. prevId = id;
  88682. // Add the identifier node into the destructuring group.
  88683. var group = getDestructuringHost(reference);
  88684. if (group) {
  88685. if (identifierMap.has(group)) {
  88686. identifierMap.get(group).push(identifier);
  88687. } else {
  88688. identifierMap.set(group, [identifier]);
  88689. }
  88690. }
  88691. }
  88692. }
  88693. return identifierMap;
  88694. }
  88695. /**
  88696. * Finds the nearest parent of node with a given type.
  88697. *
  88698. * @param {ASTNode} node – The node to search from.
  88699. * @param {string} type – The type field of the parent node.
  88700. * @param {Function} shouldStop – a predicate that returns true if the traversal should stop, and false otherwise.
  88701. * @returns {ASTNode} The closest ancestor with the specified type; null if no such ancestor exists.
  88702. */
  88703. function findUp(node, type, shouldStop) {
  88704. if (!node || shouldStop(node)) {
  88705. return null;
  88706. }
  88707. if (node.type === type) {
  88708. return node;
  88709. }
  88710. return findUp(node.parent, type, shouldStop);
  88711. }
  88712. //------------------------------------------------------------------------------
  88713. // Rule Definition
  88714. //------------------------------------------------------------------------------
  88715. module.exports = {
  88716. meta: {
  88717. type: "suggestion",
  88718. docs: {
  88719. description: "require `const` declarations for variables that are never reassigned after declared",
  88720. category: "ECMAScript 6",
  88721. recommended: false,
  88722. url: "https://eslint.org/docs/rules/prefer-const"
  88723. },
  88724. fixable: "code",
  88725. schema: [{
  88726. type: "object",
  88727. properties: {
  88728. destructuring: { enum: ["any", "all"] },
  88729. ignoreReadBeforeAssign: { type: "boolean" }
  88730. },
  88731. additionalProperties: false
  88732. }]
  88733. },
  88734. create: function create(context) {
  88735. var options = context.options[0] || {};
  88736. var sourceCode = context.getSourceCode();
  88737. var shouldMatchAnyDestructuredVariable = options.destructuring !== "all";
  88738. var ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true;
  88739. var variables = [];
  88740. var reportCount = 0;
  88741. var name = "";
  88742. /**
  88743. * Reports given identifier nodes if all of the nodes should be declared
  88744. * as const.
  88745. *
  88746. * The argument 'nodes' is an array of Identifier nodes.
  88747. * This node is the result of 'getIdentifierIfShouldBeConst()', so it's
  88748. * nullable. In simple declaration or assignment cases, the length of
  88749. * the array is 1. In destructuring cases, the length of the array can
  88750. * be 2 or more.
  88751. *
  88752. * @param {(eslint-scope.Reference|null)[]} nodes -
  88753. * References which are grouped by destructuring to report.
  88754. * @returns {void}
  88755. */
  88756. function checkGroup(nodes) {
  88757. var nodesToReport = nodes.filter(Boolean);
  88758. if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) {
  88759. var varDeclParent = findUp(nodes[0], "VariableDeclaration", function (parentNode) {
  88760. return parentNode.type.endsWith("Statement");
  88761. });
  88762. var isVarDecParentNull = varDeclParent === null;
  88763. if (!isVarDecParentNull && varDeclParent.declarations.length > 0) {
  88764. var firstDeclaration = varDeclParent.declarations[0];
  88765. if (firstDeclaration.init) {
  88766. var firstDecParent = firstDeclaration.init.parent;
  88767. /*
  88768. * First we check the declaration type and then depending on
  88769. * if the type is a "VariableDeclarator" or its an "ObjectPattern"
  88770. * we compare the name from the first identifier, if the names are different
  88771. * we assign the new name and reset the count of reportCount and nodeCount in
  88772. * order to check each block for the number of reported errors and base our fix
  88773. * based on comparing nodes.length and nodesToReport.length.
  88774. */
  88775. if (firstDecParent.type === "VariableDeclarator") {
  88776. if (firstDecParent.id.name !== name) {
  88777. name = firstDecParent.id.name;
  88778. reportCount = 0;
  88779. }
  88780. if (firstDecParent.id.type === "ObjectPattern") {
  88781. if (firstDecParent.init.name !== name) {
  88782. name = firstDecParent.init.name;
  88783. reportCount = 0;
  88784. }
  88785. }
  88786. }
  88787. }
  88788. }
  88789. var shouldFix = varDeclParent && (
  88790. // Don't do a fix unless the variable is initialized (or it's in a for-in or for-of loop)
  88791. varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" || varDeclParent.declarations[0].init) &&
  88792. /*
  88793. * If options.destructuring is "all", then this warning will not occur unless
  88794. * every assignment in the destructuring should be const. In that case, it's safe
  88795. * to apply the fix.
  88796. */
  88797. nodesToReport.length === nodes.length;
  88798. if (!isVarDecParentNull && varDeclParent.declarations && varDeclParent.declarations.length !== 1) {
  88799. if (varDeclParent && varDeclParent.declarations && varDeclParent.declarations.length >= 1) {
  88800. /*
  88801. * Add nodesToReport.length to a count, then comparing the count to the length
  88802. * of the declarations in the current block.
  88803. */
  88804. reportCount += nodesToReport.length;
  88805. shouldFix = shouldFix && reportCount === varDeclParent.declarations.length;
  88806. }
  88807. }
  88808. nodesToReport.forEach(function (node) {
  88809. context.report({
  88810. node: node,
  88811. message: "'{{name}}' is never reassigned. Use 'const' instead.",
  88812. data: node,
  88813. fix: shouldFix ? function (fixer) {
  88814. return fixer.replaceText(sourceCode.getFirstToken(varDeclParent), "const");
  88815. } : null
  88816. });
  88817. });
  88818. }
  88819. }
  88820. return {
  88821. "Program:exit": function ProgramExit() {
  88822. groupByDestructuring(variables, ignoreReadBeforeAssign).forEach(checkGroup);
  88823. },
  88824. VariableDeclaration: function VariableDeclaration(node) {
  88825. if (node.kind === "let" && !isInitOfForStatement(node)) {
  88826. variables.push.apply(variables, _toConsumableArray(context.getDeclaredVariables(node)));
  88827. }
  88828. }
  88829. };
  88830. }
  88831. };
  88832. },{"../util/ast-utils":405}],347:[function(require,module,exports){
  88833. /**
  88834. * @fileoverview Prefer destructuring from arrays and objects
  88835. * @author Alex LaFroscia
  88836. */
  88837. "use strict";
  88838. //------------------------------------------------------------------------------
  88839. // Rule Definition
  88840. //------------------------------------------------------------------------------
  88841. module.exports = {
  88842. meta: {
  88843. type: "suggestion",
  88844. docs: {
  88845. description: "require destructuring from arrays and/or objects",
  88846. category: "ECMAScript 6",
  88847. recommended: false,
  88848. url: "https://eslint.org/docs/rules/prefer-destructuring"
  88849. },
  88850. schema: [{
  88851. /*
  88852. * old support {array: Boolean, object: Boolean}
  88853. * new support {VariableDeclarator: {}, AssignmentExpression: {}}
  88854. */
  88855. oneOf: [{
  88856. type: "object",
  88857. properties: {
  88858. VariableDeclarator: {
  88859. type: "object",
  88860. properties: {
  88861. array: {
  88862. type: "boolean"
  88863. },
  88864. object: {
  88865. type: "boolean"
  88866. }
  88867. },
  88868. additionalProperties: false
  88869. },
  88870. AssignmentExpression: {
  88871. type: "object",
  88872. properties: {
  88873. array: {
  88874. type: "boolean"
  88875. },
  88876. object: {
  88877. type: "boolean"
  88878. }
  88879. },
  88880. additionalProperties: false
  88881. }
  88882. },
  88883. additionalProperties: false
  88884. }, {
  88885. type: "object",
  88886. properties: {
  88887. array: {
  88888. type: "boolean"
  88889. },
  88890. object: {
  88891. type: "boolean"
  88892. }
  88893. },
  88894. additionalProperties: false
  88895. }]
  88896. }, {
  88897. type: "object",
  88898. properties: {
  88899. enforceForRenamedProperties: {
  88900. type: "boolean"
  88901. }
  88902. },
  88903. additionalProperties: false
  88904. }]
  88905. },
  88906. create: function create(context) {
  88907. var enabledTypes = context.options[0];
  88908. var enforceForRenamedProperties = context.options[1] && context.options[1].enforceForRenamedProperties;
  88909. var normalizedOptions = {
  88910. VariableDeclarator: { array: true, object: true },
  88911. AssignmentExpression: { array: true, object: true }
  88912. };
  88913. if (enabledTypes) {
  88914. normalizedOptions = typeof enabledTypes.array !== "undefined" || typeof enabledTypes.object !== "undefined" ? { VariableDeclarator: enabledTypes, AssignmentExpression: enabledTypes } : enabledTypes;
  88915. }
  88916. //--------------------------------------------------------------------------
  88917. // Helpers
  88918. //--------------------------------------------------------------------------
  88919. /**
  88920. * @param {string} nodeType "AssignmentExpression" or "VariableDeclarator"
  88921. * @param {string} destructuringType "array" or "object"
  88922. * @returns {boolean} `true` if the destructuring type should be checked for the given node
  88923. */
  88924. function shouldCheck(nodeType, destructuringType) {
  88925. return normalizedOptions && normalizedOptions[nodeType] && normalizedOptions[nodeType][destructuringType];
  88926. }
  88927. /**
  88928. * Determines if the given node is accessing an array index
  88929. *
  88930. * This is used to differentiate array index access from object property
  88931. * access.
  88932. *
  88933. * @param {ASTNode} node the node to evaluate
  88934. * @returns {boolean} whether or not the node is an integer
  88935. */
  88936. function isArrayIndexAccess(node) {
  88937. return Number.isInteger(node.property.value);
  88938. }
  88939. /**
  88940. * Report that the given node should use destructuring
  88941. *
  88942. * @param {ASTNode} reportNode the node to report
  88943. * @param {string} type the type of destructuring that should have been done
  88944. * @returns {void}
  88945. */
  88946. function report(reportNode, type) {
  88947. context.report({ node: reportNode, message: "Use {{type}} destructuring.", data: { type: type } });
  88948. }
  88949. /**
  88950. * Check that the `prefer-destructuring` rules are followed based on the
  88951. * given left- and right-hand side of the assignment.
  88952. *
  88953. * Pulled out into a separate method so that VariableDeclarators and
  88954. * AssignmentExpressions can share the same verification logic.
  88955. *
  88956. * @param {ASTNode} leftNode the left-hand side of the assignment
  88957. * @param {ASTNode} rightNode the right-hand side of the assignment
  88958. * @param {ASTNode} reportNode the node to report the error on
  88959. * @returns {void}
  88960. */
  88961. function performCheck(leftNode, rightNode, reportNode) {
  88962. if (rightNode.type !== "MemberExpression" || rightNode.object.type === "Super") {
  88963. return;
  88964. }
  88965. if (isArrayIndexAccess(rightNode)) {
  88966. if (shouldCheck(reportNode.type, "array")) {
  88967. report(reportNode, "array");
  88968. }
  88969. return;
  88970. }
  88971. if (shouldCheck(reportNode.type, "object") && enforceForRenamedProperties) {
  88972. report(reportNode, "object");
  88973. return;
  88974. }
  88975. if (shouldCheck(reportNode.type, "object")) {
  88976. var property = rightNode.property;
  88977. if (property.type === "Literal" && leftNode.name === property.value || property.type === "Identifier" && leftNode.name === property.name && !rightNode.computed) {
  88978. report(reportNode, "object");
  88979. }
  88980. }
  88981. }
  88982. /**
  88983. * Check if a given variable declarator is coming from an property access
  88984. * that should be using destructuring instead
  88985. *
  88986. * @param {ASTNode} node the variable declarator to check
  88987. * @returns {void}
  88988. */
  88989. function checkVariableDeclarator(node) {
  88990. // Skip if variable is declared without assignment
  88991. if (!node.init) {
  88992. return;
  88993. }
  88994. // We only care about member expressions past this point
  88995. if (node.init.type !== "MemberExpression") {
  88996. return;
  88997. }
  88998. performCheck(node.id, node.init, node);
  88999. }
  89000. /**
  89001. * Run the `prefer-destructuring` check on an AssignmentExpression
  89002. *
  89003. * @param {ASTNode} node the AssignmentExpression node
  89004. * @returns {void}
  89005. */
  89006. function checkAssigmentExpression(node) {
  89007. if (node.operator === "=") {
  89008. performCheck(node.left, node.right, node);
  89009. }
  89010. }
  89011. //--------------------------------------------------------------------------
  89012. // Public
  89013. //--------------------------------------------------------------------------
  89014. return {
  89015. VariableDeclarator: checkVariableDeclarator,
  89016. AssignmentExpression: checkAssigmentExpression
  89017. };
  89018. }
  89019. };
  89020. },{}],348:[function(require,module,exports){
  89021. /**
  89022. * @fileoverview Rule to disallow `parseInt()` in favor of binary, octal, and hexadecimal literals
  89023. * @author Annie Zhang, Henry Zhu
  89024. */
  89025. "use strict";
  89026. //------------------------------------------------------------------------------
  89027. // Helpers
  89028. //------------------------------------------------------------------------------
  89029. /**
  89030. * Checks to see if a CallExpression's callee node is `parseInt` or
  89031. * `Number.parseInt`.
  89032. * @param {ASTNode} calleeNode The callee node to evaluate.
  89033. * @returns {boolean} True if the callee is `parseInt` or `Number.parseInt`,
  89034. * false otherwise.
  89035. */
  89036. function isParseInt(calleeNode) {
  89037. switch (calleeNode.type) {
  89038. case "Identifier":
  89039. return calleeNode.name === "parseInt";
  89040. case "MemberExpression":
  89041. return calleeNode.object.type === "Identifier" && calleeNode.object.name === "Number" && calleeNode.property.type === "Identifier" && calleeNode.property.name === "parseInt";
  89042. // no default
  89043. }
  89044. return false;
  89045. }
  89046. //------------------------------------------------------------------------------
  89047. // Rule Definition
  89048. //------------------------------------------------------------------------------
  89049. module.exports = {
  89050. meta: {
  89051. type: "suggestion",
  89052. docs: {
  89053. description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals",
  89054. category: "ECMAScript 6",
  89055. recommended: false,
  89056. url: "https://eslint.org/docs/rules/prefer-numeric-literals"
  89057. },
  89058. schema: [],
  89059. fixable: "code"
  89060. },
  89061. create: function create(context) {
  89062. var sourceCode = context.getSourceCode();
  89063. var radixMap = {
  89064. 2: "binary",
  89065. 8: "octal",
  89066. 16: "hexadecimal"
  89067. };
  89068. var prefixMap = {
  89069. 2: "0b",
  89070. 8: "0o",
  89071. 16: "0x"
  89072. };
  89073. //----------------------------------------------------------------------
  89074. // Public
  89075. //----------------------------------------------------------------------
  89076. return {
  89077. CallExpression: function CallExpression(node) {
  89078. // doesn't check parseInt() if it doesn't have a radix argument
  89079. if (node.arguments.length !== 2) {
  89080. return;
  89081. }
  89082. // only error if the radix is 2, 8, or 16
  89083. var radixName = radixMap[node.arguments[1].value];
  89084. if (isParseInt(node.callee) && radixName && node.arguments[0].type === "Literal") {
  89085. context.report({
  89086. node: node,
  89087. message: "Use {{radixName}} literals instead of {{functionName}}().",
  89088. data: {
  89089. radixName: radixName,
  89090. functionName: sourceCode.getText(node.callee)
  89091. },
  89092. fix: function fix(fixer) {
  89093. var newPrefix = prefixMap[node.arguments[1].value];
  89094. if (+(newPrefix + node.arguments[0].value) !== parseInt(node.arguments[0].value, node.arguments[1].value)) {
  89095. /*
  89096. * If the newly-produced literal would be invalid, (e.g. 0b1234),
  89097. * or it would yield an incorrect parseInt result for some other reason, don't make a fix.
  89098. */
  89099. return null;
  89100. }
  89101. return fixer.replaceText(node, prefixMap[node.arguments[1].value] + node.arguments[0].value);
  89102. }
  89103. });
  89104. }
  89105. }
  89106. };
  89107. }
  89108. };
  89109. },{}],349:[function(require,module,exports){
  89110. /**
  89111. * @fileoverview Prefers object spread property over Object.assign
  89112. * @author Sharmila Jesupaul
  89113. * See LICENSE file in root directory for full license.
  89114. */
  89115. "use strict";
  89116. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  89117. var _require = require("eslint-utils"),
  89118. CALL = _require.CALL,
  89119. ReferenceTracker = _require.ReferenceTracker;
  89120. var _require2 = require("../util/ast-utils"),
  89121. isCommaToken = _require2.isCommaToken,
  89122. isOpeningParenToken = _require2.isOpeningParenToken,
  89123. isClosingParenToken = _require2.isClosingParenToken,
  89124. isParenthesised = _require2.isParenthesised;
  89125. var ANY_SPACE = /\s/;
  89126. /**
  89127. * Helper that checks if the Object.assign call has array spread
  89128. * @param {ASTNode} node - The node that the rule warns on
  89129. * @returns {boolean} - Returns true if the Object.assign call has array spread
  89130. */
  89131. function hasArraySpread(node) {
  89132. return node.arguments.some(function (arg) {
  89133. return arg.type === "SpreadElement";
  89134. });
  89135. }
  89136. /**
  89137. * Helper that checks if the node needs parentheses to be valid JS.
  89138. * The default is to wrap the node in parentheses to avoid parsing errors.
  89139. * @param {ASTNode} node - The node that the rule warns on
  89140. * @param {Object} sourceCode - in context sourcecode object
  89141. * @returns {boolean} - Returns true if the node needs parentheses
  89142. */
  89143. function needsParens(node, sourceCode) {
  89144. var parent = node.parent;
  89145. switch (parent.type) {
  89146. case "VariableDeclarator":
  89147. case "ArrayExpression":
  89148. case "ReturnStatement":
  89149. case "CallExpression":
  89150. case "Property":
  89151. return false;
  89152. case "AssignmentExpression":
  89153. return parent.left === node && !isParenthesised(sourceCode, node);
  89154. default:
  89155. return !isParenthesised(sourceCode, node);
  89156. }
  89157. }
  89158. /**
  89159. * Determines if an argument needs parentheses. The default is to not add parens.
  89160. * @param {ASTNode} node - The node to be checked.
  89161. * @param {Object} sourceCode - in context sourcecode object
  89162. * @returns {boolean} True if the node needs parentheses
  89163. */
  89164. function argNeedsParens(node, sourceCode) {
  89165. switch (node.type) {
  89166. case "AssignmentExpression":
  89167. case "ArrowFunctionExpression":
  89168. case "ConditionalExpression":
  89169. return !isParenthesised(sourceCode, node);
  89170. default:
  89171. return false;
  89172. }
  89173. }
  89174. /**
  89175. * Get the parenthesis tokens of a given ObjectExpression node.
  89176. * This incldues the braces of the object literal and enclosing parentheses.
  89177. * @param {ASTNode} node The node to get.
  89178. * @param {Token} leftArgumentListParen The opening paren token of the argument list.
  89179. * @param {SourceCode} sourceCode The source code object to get tokens.
  89180. * @returns {Token[]} The parenthesis tokens of the node. This is sorted by the location.
  89181. */
  89182. function getParenTokens(node, leftArgumentListParen, sourceCode) {
  89183. var parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)];
  89184. var leftNext = sourceCode.getTokenBefore(node);
  89185. var rightNext = sourceCode.getTokenAfter(node);
  89186. // Note: don't include the parens of the argument list.
  89187. while (leftNext && rightNext && leftNext.range[0] > leftArgumentListParen.range[0] && isOpeningParenToken(leftNext) && isClosingParenToken(rightNext)) {
  89188. parens.push(leftNext, rightNext);
  89189. leftNext = sourceCode.getTokenBefore(leftNext);
  89190. rightNext = sourceCode.getTokenAfter(rightNext);
  89191. }
  89192. return parens.sort(function (a, b) {
  89193. return a.range[0] - b.range[0];
  89194. });
  89195. }
  89196. /**
  89197. * Get the range of a given token and around whitespaces.
  89198. * @param {Token} token The token to get range.
  89199. * @param {SourceCode} sourceCode The source code object to get tokens.
  89200. * @returns {number} The end of the range of the token and around whitespaces.
  89201. */
  89202. function getStartWithSpaces(token, sourceCode) {
  89203. var text = sourceCode.text;
  89204. var start = token.range[0];
  89205. // If the previous token is a line comment then skip this step to avoid commenting this token out.
  89206. {
  89207. var prevToken = sourceCode.getTokenBefore(token, { includeComments: true });
  89208. if (prevToken && prevToken.type === "Line") {
  89209. return start;
  89210. }
  89211. }
  89212. // Detect spaces before the token.
  89213. while (ANY_SPACE.test(text[start - 1] || "")) {
  89214. start -= 1;
  89215. }
  89216. return start;
  89217. }
  89218. /**
  89219. * Get the range of a given token and around whitespaces.
  89220. * @param {Token} token The token to get range.
  89221. * @param {SourceCode} sourceCode The source code object to get tokens.
  89222. * @returns {number} The start of the range of the token and around whitespaces.
  89223. */
  89224. function getEndWithSpaces(token, sourceCode) {
  89225. var text = sourceCode.text;
  89226. var end = token.range[1];
  89227. // Detect spaces after the token.
  89228. while (ANY_SPACE.test(text[end] || "")) {
  89229. end += 1;
  89230. }
  89231. return end;
  89232. }
  89233. /**
  89234. * Autofixes the Object.assign call to use an object spread instead.
  89235. * @param {ASTNode|null} node - The node that the rule warns on, i.e. the Object.assign call
  89236. * @param {string} sourceCode - sourceCode of the Object.assign call
  89237. * @returns {Function} autofixer - replaces the Object.assign with a spread object.
  89238. */
  89239. function defineFixer(node, sourceCode) {
  89240. return (/*#__PURE__*/regeneratorRuntime.mark(function _callee(fixer) {
  89241. var leftParen, rightParen, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, argNode, innerParens, left, right, maybeTrailingComma, maybeArgumentComma, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, innerParen, leftRange, rightRange;
  89242. return regeneratorRuntime.wrap(function _callee$(_context) {
  89243. while (1) {
  89244. switch (_context.prev = _context.next) {
  89245. case 0:
  89246. leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
  89247. rightParen = sourceCode.getLastToken(node);
  89248. // Remove the callee `Object.assign`
  89249. _context.next = 4;
  89250. return fixer.remove(node.callee);
  89251. case 4:
  89252. if (!needsParens(node, sourceCode)) {
  89253. _context.next = 11;
  89254. break;
  89255. }
  89256. _context.next = 7;
  89257. return fixer.replaceText(leftParen, "({");
  89258. case 7:
  89259. _context.next = 9;
  89260. return fixer.replaceText(rightParen, "})");
  89261. case 9:
  89262. _context.next = 15;
  89263. break;
  89264. case 11:
  89265. _context.next = 13;
  89266. return fixer.replaceText(leftParen, "{");
  89267. case 13:
  89268. _context.next = 15;
  89269. return fixer.replaceText(rightParen, "}");
  89270. case 15:
  89271. // Process arguments.
  89272. _iteratorNormalCompletion = true;
  89273. _didIteratorError = false;
  89274. _iteratorError = undefined;
  89275. _context.prev = 18;
  89276. _iterator = node.arguments[Symbol.iterator]();
  89277. case 20:
  89278. if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
  89279. _context.next = 77;
  89280. break;
  89281. }
  89282. argNode = _step.value;
  89283. innerParens = getParenTokens(argNode, leftParen, sourceCode);
  89284. left = innerParens.shift();
  89285. right = innerParens.pop();
  89286. if (!(argNode.type === "ObjectExpression")) {
  89287. _context.next = 65;
  89288. break;
  89289. }
  89290. maybeTrailingComma = sourceCode.getLastToken(argNode, 1);
  89291. maybeArgumentComma = sourceCode.getTokenAfter(right);
  89292. /*
  89293. * Make bare this object literal.
  89294. * And remove spaces inside of the braces for better formatting.
  89295. */
  89296. _iteratorNormalCompletion2 = true;
  89297. _didIteratorError2 = false;
  89298. _iteratorError2 = undefined;
  89299. _context.prev = 31;
  89300. _iterator2 = innerParens[Symbol.iterator]();
  89301. case 33:
  89302. if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) {
  89303. _context.next = 40;
  89304. break;
  89305. }
  89306. innerParen = _step2.value;
  89307. _context.next = 37;
  89308. return fixer.remove(innerParen);
  89309. case 37:
  89310. _iteratorNormalCompletion2 = true;
  89311. _context.next = 33;
  89312. break;
  89313. case 40:
  89314. _context.next = 46;
  89315. break;
  89316. case 42:
  89317. _context.prev = 42;
  89318. _context.t0 = _context["catch"](31);
  89319. _didIteratorError2 = true;
  89320. _iteratorError2 = _context.t0;
  89321. case 46:
  89322. _context.prev = 46;
  89323. _context.prev = 47;
  89324. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  89325. _iterator2.return();
  89326. }
  89327. case 49:
  89328. _context.prev = 49;
  89329. if (!_didIteratorError2) {
  89330. _context.next = 52;
  89331. break;
  89332. }
  89333. throw _iteratorError2;
  89334. case 52:
  89335. return _context.finish(49);
  89336. case 53:
  89337. return _context.finish(46);
  89338. case 54:
  89339. leftRange = [left.range[0], getEndWithSpaces(left, sourceCode)];
  89340. rightRange = [Math.max(getStartWithSpaces(right, sourceCode), leftRange[1]), // Ensure ranges don't overlap
  89341. right.range[1]];
  89342. _context.next = 58;
  89343. return fixer.removeRange(leftRange);
  89344. case 58:
  89345. _context.next = 60;
  89346. return fixer.removeRange(rightRange);
  89347. case 60:
  89348. if (!((argNode.properties.length === 0 || isCommaToken(maybeTrailingComma)) && isCommaToken(maybeArgumentComma))) {
  89349. _context.next = 63;
  89350. break;
  89351. }
  89352. _context.next = 63;
  89353. return fixer.remove(maybeArgumentComma);
  89354. case 63:
  89355. _context.next = 74;
  89356. break;
  89357. case 65:
  89358. if (!argNeedsParens(argNode, sourceCode)) {
  89359. _context.next = 72;
  89360. break;
  89361. }
  89362. _context.next = 68;
  89363. return fixer.insertTextBefore(left, "...(");
  89364. case 68:
  89365. _context.next = 70;
  89366. return fixer.insertTextAfter(right, ")");
  89367. case 70:
  89368. _context.next = 74;
  89369. break;
  89370. case 72:
  89371. _context.next = 74;
  89372. return fixer.insertTextBefore(left, "...");
  89373. case 74:
  89374. _iteratorNormalCompletion = true;
  89375. _context.next = 20;
  89376. break;
  89377. case 77:
  89378. _context.next = 83;
  89379. break;
  89380. case 79:
  89381. _context.prev = 79;
  89382. _context.t1 = _context["catch"](18);
  89383. _didIteratorError = true;
  89384. _iteratorError = _context.t1;
  89385. case 83:
  89386. _context.prev = 83;
  89387. _context.prev = 84;
  89388. if (!_iteratorNormalCompletion && _iterator.return) {
  89389. _iterator.return();
  89390. }
  89391. case 86:
  89392. _context.prev = 86;
  89393. if (!_didIteratorError) {
  89394. _context.next = 89;
  89395. break;
  89396. }
  89397. throw _iteratorError;
  89398. case 89:
  89399. return _context.finish(86);
  89400. case 90:
  89401. return _context.finish(83);
  89402. case 91:
  89403. case "end":
  89404. return _context.stop();
  89405. }
  89406. }
  89407. }, _callee, this, [[18, 79, 83, 91], [31, 42, 46, 54], [47,, 49, 53], [84,, 86, 90]]);
  89408. })
  89409. );
  89410. }
  89411. module.exports = {
  89412. meta: {
  89413. type: "suggestion",
  89414. docs: {
  89415. description: "disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.",
  89416. category: "Stylistic Issues",
  89417. recommended: false,
  89418. url: "https://eslint.org/docs/rules/prefer-object-spread"
  89419. },
  89420. schema: [],
  89421. fixable: "code",
  89422. messages: {
  89423. useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`",
  89424. useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`"
  89425. }
  89426. },
  89427. create: function create(context) {
  89428. var sourceCode = context.getSourceCode();
  89429. return {
  89430. Program: function Program() {
  89431. var scope = context.getScope();
  89432. var tracker = new ReferenceTracker(scope);
  89433. var trackMap = {
  89434. Object: {
  89435. assign: _defineProperty({}, CALL, true)
  89436. }
  89437. };
  89438. // Iterate all calls of `Object.assign` (only of the global variable `Object`).
  89439. var _iteratorNormalCompletion3 = true;
  89440. var _didIteratorError3 = false;
  89441. var _iteratorError3 = undefined;
  89442. try {
  89443. for (var _iterator3 = tracker.iterateGlobalReferences(trackMap)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  89444. var node = _step3.value.node;
  89445. if (node.arguments.length >= 1 && node.arguments[0].type === "ObjectExpression" && !hasArraySpread(node)) {
  89446. var messageId = node.arguments.length === 1 ? "useLiteralMessage" : "useSpreadMessage";
  89447. var fix = defineFixer(node, sourceCode);
  89448. context.report({ node: node, messageId: messageId, fix: fix });
  89449. }
  89450. }
  89451. } catch (err) {
  89452. _didIteratorError3 = true;
  89453. _iteratorError3 = err;
  89454. } finally {
  89455. try {
  89456. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  89457. _iterator3.return();
  89458. }
  89459. } finally {
  89460. if (_didIteratorError3) {
  89461. throw _iteratorError3;
  89462. }
  89463. }
  89464. }
  89465. }
  89466. };
  89467. }
  89468. };
  89469. },{"../util/ast-utils":405,"eslint-utils":68}],350:[function(require,module,exports){
  89470. /**
  89471. * @fileoverview restrict values that can be used as Promise rejection reasons
  89472. * @author Teddy Katz
  89473. */
  89474. "use strict";
  89475. var astUtils = require("../util/ast-utils");
  89476. //------------------------------------------------------------------------------
  89477. // Rule Definition
  89478. //------------------------------------------------------------------------------
  89479. module.exports = {
  89480. meta: {
  89481. type: "suggestion",
  89482. docs: {
  89483. description: "require using Error objects as Promise rejection reasons",
  89484. category: "Best Practices",
  89485. recommended: false,
  89486. url: "https://eslint.org/docs/rules/prefer-promise-reject-errors"
  89487. },
  89488. fixable: null,
  89489. schema: [{
  89490. type: "object",
  89491. properties: {
  89492. allowEmptyReject: { type: "boolean" }
  89493. },
  89494. additionalProperties: false
  89495. }]
  89496. },
  89497. create: function create(context) {
  89498. var ALLOW_EMPTY_REJECT = context.options.length && context.options[0].allowEmptyReject;
  89499. //----------------------------------------------------------------------
  89500. // Helpers
  89501. //----------------------------------------------------------------------
  89502. /**
  89503. * Checks the argument of a reject() or Promise.reject() CallExpression, and reports it if it can't be an Error
  89504. * @param {ASTNode} callExpression A CallExpression node which is used to reject a Promise
  89505. * @returns {void}
  89506. */
  89507. function checkRejectCall(callExpression) {
  89508. if (!callExpression.arguments.length && ALLOW_EMPTY_REJECT) {
  89509. return;
  89510. }
  89511. if (!callExpression.arguments.length || !astUtils.couldBeError(callExpression.arguments[0]) || callExpression.arguments[0].type === "Identifier" && callExpression.arguments[0].name === "undefined") {
  89512. context.report({
  89513. node: callExpression,
  89514. message: "Expected the Promise rejection reason to be an Error."
  89515. });
  89516. }
  89517. }
  89518. /**
  89519. * Determines whether a function call is a Promise.reject() call
  89520. * @param {ASTNode} node A CallExpression node
  89521. * @returns {boolean} `true` if the call is a Promise.reject() call
  89522. */
  89523. function isPromiseRejectCall(node) {
  89524. return node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "Promise" && node.callee.property.type === "Identifier" && node.callee.property.name === "reject";
  89525. }
  89526. //----------------------------------------------------------------------
  89527. // Public
  89528. //----------------------------------------------------------------------
  89529. return {
  89530. // Check `Promise.reject(value)` calls.
  89531. CallExpression: function CallExpression(node) {
  89532. if (isPromiseRejectCall(node)) {
  89533. checkRejectCall(node);
  89534. }
  89535. },
  89536. /*
  89537. * Check for `new Promise((resolve, reject) => {})`, and check for reject() calls.
  89538. * This function is run on "NewExpression:exit" instead of "NewExpression" to ensure that
  89539. * the nodes in the expression already have the `parent` property.
  89540. */
  89541. "NewExpression:exit": function NewExpressionExit(node) {
  89542. if (node.callee.type === "Identifier" && node.callee.name === "Promise" && node.arguments.length && astUtils.isFunction(node.arguments[0]) && node.arguments[0].params.length > 1 && node.arguments[0].params[1].type === "Identifier") {
  89543. context.getDeclaredVariables(node.arguments[0])
  89544. /*
  89545. * Find the first variable that matches the second parameter's name.
  89546. * If the first parameter has the same name as the second parameter, then the variable will actually
  89547. * be "declared" when the first parameter is evaluated, but then it will be immediately overwritten
  89548. * by the second parameter. It's not possible for an expression with the variable to be evaluated before
  89549. * the variable is overwritten, because functions with duplicate parameters cannot have destructuring or
  89550. * default assignments in their parameter lists. Therefore, it's not necessary to explicitly account for
  89551. * this case.
  89552. */
  89553. .find(function (variable) {
  89554. return variable.name === node.arguments[0].params[1].name;
  89555. })
  89556. // Get the references to that variable.
  89557. .references
  89558. // Only check the references that read the parameter's value.
  89559. .filter(function (ref) {
  89560. return ref.isRead();
  89561. })
  89562. // Only check the references that are used as the callee in a function call, e.g. `reject(foo)`.
  89563. .filter(function (ref) {
  89564. return ref.identifier.parent.type === "CallExpression" && ref.identifier === ref.identifier.parent.callee;
  89565. })
  89566. // Check the argument of the function call to determine whether it's an Error.
  89567. .forEach(function (ref) {
  89568. return checkRejectCall(ref.identifier.parent);
  89569. });
  89570. }
  89571. }
  89572. };
  89573. }
  89574. };
  89575. },{"../util/ast-utils":405}],351:[function(require,module,exports){
  89576. /**
  89577. * @fileoverview Rule to suggest using "Reflect" api over Function/Object methods
  89578. * @author Keith Cirkel <http://keithcirkel.co.uk>
  89579. * @deprecated in ESLint v3.9.0
  89580. */
  89581. "use strict";
  89582. //------------------------------------------------------------------------------
  89583. // Rule Definition
  89584. //------------------------------------------------------------------------------
  89585. module.exports = {
  89586. meta: {
  89587. type: "suggestion",
  89588. docs: {
  89589. description: "require `Reflect` methods where applicable",
  89590. category: "ECMAScript 6",
  89591. recommended: false,
  89592. url: "https://eslint.org/docs/rules/prefer-reflect"
  89593. },
  89594. deprecated: true,
  89595. replacedBy: [],
  89596. schema: [{
  89597. type: "object",
  89598. properties: {
  89599. exceptions: {
  89600. type: "array",
  89601. items: {
  89602. enum: ["apply", "call", "delete", "defineProperty", "getOwnPropertyDescriptor", "getPrototypeOf", "setPrototypeOf", "isExtensible", "getOwnPropertyNames", "preventExtensions"]
  89603. },
  89604. uniqueItems: true
  89605. }
  89606. },
  89607. additionalProperties: false
  89608. }]
  89609. },
  89610. create: function create(context) {
  89611. var existingNames = {
  89612. apply: "Function.prototype.apply",
  89613. call: "Function.prototype.call",
  89614. defineProperty: "Object.defineProperty",
  89615. getOwnPropertyDescriptor: "Object.getOwnPropertyDescriptor",
  89616. getPrototypeOf: "Object.getPrototypeOf",
  89617. setPrototypeOf: "Object.setPrototypeOf",
  89618. isExtensible: "Object.isExtensible",
  89619. getOwnPropertyNames: "Object.getOwnPropertyNames",
  89620. preventExtensions: "Object.preventExtensions"
  89621. };
  89622. var reflectSubsitutes = {
  89623. apply: "Reflect.apply",
  89624. call: "Reflect.apply",
  89625. defineProperty: "Reflect.defineProperty",
  89626. getOwnPropertyDescriptor: "Reflect.getOwnPropertyDescriptor",
  89627. getPrototypeOf: "Reflect.getPrototypeOf",
  89628. setPrototypeOf: "Reflect.setPrototypeOf",
  89629. isExtensible: "Reflect.isExtensible",
  89630. getOwnPropertyNames: "Reflect.getOwnPropertyNames",
  89631. preventExtensions: "Reflect.preventExtensions"
  89632. };
  89633. var exceptions = (context.options[0] || {}).exceptions || [];
  89634. /**
  89635. * Reports the Reflect violation based on the `existing` and `substitute`
  89636. * @param {Object} node The node that violates the rule.
  89637. * @param {string} existing The existing method name that has been used.
  89638. * @param {string} substitute The Reflect substitute that should be used.
  89639. * @returns {void}
  89640. */
  89641. function report(node, existing, substitute) {
  89642. context.report({
  89643. node: node,
  89644. message: "Avoid using {{existing}}, instead use {{substitute}}.",
  89645. data: {
  89646. existing: existing,
  89647. substitute: substitute
  89648. }
  89649. });
  89650. }
  89651. return {
  89652. CallExpression: function CallExpression(node) {
  89653. var methodName = (node.callee.property || {}).name;
  89654. var isReflectCall = (node.callee.object || {}).name === "Reflect";
  89655. var hasReflectSubsitute = Object.prototype.hasOwnProperty.call(reflectSubsitutes, methodName);
  89656. var userConfiguredException = exceptions.indexOf(methodName) !== -1;
  89657. if (hasReflectSubsitute && !isReflectCall && !userConfiguredException) {
  89658. report(node, existingNames[methodName], reflectSubsitutes[methodName]);
  89659. }
  89660. },
  89661. UnaryExpression: function UnaryExpression(node) {
  89662. var isDeleteOperator = node.operator === "delete";
  89663. var targetsIdentifier = node.argument.type === "Identifier";
  89664. var userConfiguredException = exceptions.indexOf("delete") !== -1;
  89665. if (isDeleteOperator && !targetsIdentifier && !userConfiguredException) {
  89666. report(node, "the delete keyword", "Reflect.deleteProperty");
  89667. }
  89668. }
  89669. };
  89670. }
  89671. };
  89672. },{}],352:[function(require,module,exports){
  89673. /**
  89674. * @fileoverview Rule to
  89675. * @author Toru Nagashima
  89676. */
  89677. "use strict";
  89678. //------------------------------------------------------------------------------
  89679. // Helpers
  89680. //------------------------------------------------------------------------------
  89681. /**
  89682. * Gets the variable object of `arguments` which is defined implicitly.
  89683. * @param {eslint-scope.Scope} scope - A scope to get.
  89684. * @returns {eslint-scope.Variable} The found variable object.
  89685. */
  89686. function getVariableOfArguments(scope) {
  89687. var variables = scope.variables;
  89688. for (var i = 0; i < variables.length; ++i) {
  89689. var variable = variables[i];
  89690. if (variable.name === "arguments") {
  89691. /*
  89692. * If there was a parameter which is named "arguments", the implicit "arguments" is not defined.
  89693. * So does fast return with null.
  89694. */
  89695. return variable.identifiers.length === 0 ? variable : null;
  89696. }
  89697. }
  89698. /* istanbul ignore next : unreachable */
  89699. return null;
  89700. }
  89701. /**
  89702. * Checks if the given reference is not normal member access.
  89703. *
  89704. * - arguments .... true // not member access
  89705. * - arguments[i] .... true // computed member access
  89706. * - arguments[0] .... true // computed member access
  89707. * - arguments.length .... false // normal member access
  89708. *
  89709. * @param {eslint-scope.Reference} reference - The reference to check.
  89710. * @returns {boolean} `true` if the reference is not normal member access.
  89711. */
  89712. function isNotNormalMemberAccess(reference) {
  89713. var id = reference.identifier;
  89714. var parent = id.parent;
  89715. return !(parent.type === "MemberExpression" && parent.object === id && !parent.computed);
  89716. }
  89717. //------------------------------------------------------------------------------
  89718. // Rule Definition
  89719. //------------------------------------------------------------------------------
  89720. module.exports = {
  89721. meta: {
  89722. type: "suggestion",
  89723. docs: {
  89724. description: "require rest parameters instead of `arguments`",
  89725. category: "ECMAScript 6",
  89726. recommended: false,
  89727. url: "https://eslint.org/docs/rules/prefer-rest-params"
  89728. },
  89729. schema: []
  89730. },
  89731. create: function create(context) {
  89732. /**
  89733. * Reports a given reference.
  89734. *
  89735. * @param {eslint-scope.Reference} reference - A reference to report.
  89736. * @returns {void}
  89737. */
  89738. function report(reference) {
  89739. context.report({
  89740. node: reference.identifier,
  89741. loc: reference.identifier.loc,
  89742. message: "Use the rest parameters instead of 'arguments'."
  89743. });
  89744. }
  89745. /**
  89746. * Reports references of the implicit `arguments` variable if exist.
  89747. *
  89748. * @returns {void}
  89749. */
  89750. function checkForArguments() {
  89751. var argumentsVar = getVariableOfArguments(context.getScope());
  89752. if (argumentsVar) {
  89753. argumentsVar.references.filter(isNotNormalMemberAccess).forEach(report);
  89754. }
  89755. }
  89756. return {
  89757. "FunctionDeclaration:exit": checkForArguments,
  89758. "FunctionExpression:exit": checkForArguments
  89759. };
  89760. }
  89761. };
  89762. },{}],353:[function(require,module,exports){
  89763. /**
  89764. * @fileoverview A rule to suggest using of the spread operator instead of `.apply()`.
  89765. * @author Toru Nagashima
  89766. */
  89767. "use strict";
  89768. var astUtils = require("../util/ast-utils");
  89769. //------------------------------------------------------------------------------
  89770. // Helpers
  89771. //------------------------------------------------------------------------------
  89772. /**
  89773. * Checks whether or not a node is a `.apply()` for variadic.
  89774. * @param {ASTNode} node - A CallExpression node to check.
  89775. * @returns {boolean} Whether or not the node is a `.apply()` for variadic.
  89776. */
  89777. function isVariadicApplyCalling(node) {
  89778. return node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && node.callee.property.name === "apply" && node.callee.computed === false && node.arguments.length === 2 && node.arguments[1].type !== "ArrayExpression" && node.arguments[1].type !== "SpreadElement";
  89779. }
  89780. /**
  89781. * Checks whether or not `thisArg` is not changed by `.apply()`.
  89782. * @param {ASTNode|null} expectedThis - The node that is the owner of the applied function.
  89783. * @param {ASTNode} thisArg - The node that is given to the first argument of the `.apply()`.
  89784. * @param {RuleContext} context - The ESLint rule context object.
  89785. * @returns {boolean} Whether or not `thisArg` is not changed by `.apply()`.
  89786. */
  89787. function isValidThisArg(expectedThis, thisArg, context) {
  89788. if (!expectedThis) {
  89789. return astUtils.isNullOrUndefined(thisArg);
  89790. }
  89791. return astUtils.equalTokens(expectedThis, thisArg, context);
  89792. }
  89793. //------------------------------------------------------------------------------
  89794. // Rule Definition
  89795. //------------------------------------------------------------------------------
  89796. module.exports = {
  89797. meta: {
  89798. type: "suggestion",
  89799. docs: {
  89800. description: "require spread operators instead of `.apply()`",
  89801. category: "ECMAScript 6",
  89802. recommended: false,
  89803. url: "https://eslint.org/docs/rules/prefer-spread"
  89804. },
  89805. schema: [],
  89806. fixable: "code"
  89807. },
  89808. create: function create(context) {
  89809. var sourceCode = context.getSourceCode();
  89810. return {
  89811. CallExpression: function CallExpression(node) {
  89812. if (!isVariadicApplyCalling(node)) {
  89813. return;
  89814. }
  89815. var applied = node.callee.object;
  89816. var expectedThis = applied.type === "MemberExpression" ? applied.object : null;
  89817. var thisArg = node.arguments[0];
  89818. if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
  89819. context.report({
  89820. node: node,
  89821. message: "Use the spread operator instead of '.apply()'.",
  89822. fix: function fix(fixer) {
  89823. if (expectedThis && expectedThis.type !== "Identifier") {
  89824. // Don't fix cases where the `this` value could be a computed expression.
  89825. return null;
  89826. }
  89827. var propertyDot = sourceCode.getFirstTokenBetween(applied, node.callee.property, function (token) {
  89828. return token.value === ".";
  89829. });
  89830. return fixer.replaceTextRange([propertyDot.range[0], node.range[1]], "(..." + sourceCode.getText(node.arguments[1]) + ")");
  89831. }
  89832. });
  89833. }
  89834. }
  89835. };
  89836. }
  89837. };
  89838. },{"../util/ast-utils":405}],354:[function(require,module,exports){
  89839. /**
  89840. * @fileoverview A rule to suggest using template literals instead of string concatenation.
  89841. * @author Toru Nagashima
  89842. */
  89843. "use strict";
  89844. //------------------------------------------------------------------------------
  89845. // Requirements
  89846. //------------------------------------------------------------------------------
  89847. var astUtils = require("../util/ast-utils");
  89848. //------------------------------------------------------------------------------
  89849. // Helpers
  89850. //------------------------------------------------------------------------------
  89851. /**
  89852. * Checks whether or not a given node is a concatenation.
  89853. * @param {ASTNode} node - A node to check.
  89854. * @returns {boolean} `true` if the node is a concatenation.
  89855. */
  89856. function isConcatenation(node) {
  89857. return node.type === "BinaryExpression" && node.operator === "+";
  89858. }
  89859. /**
  89860. * Gets the top binary expression node for concatenation in parents of a given node.
  89861. * @param {ASTNode} node - A node to get.
  89862. * @returns {ASTNode} the top binary expression node in parents of a given node.
  89863. */
  89864. function getTopConcatBinaryExpression(node) {
  89865. var currentNode = node;
  89866. while (isConcatenation(currentNode.parent)) {
  89867. currentNode = currentNode.parent;
  89868. }
  89869. return currentNode;
  89870. }
  89871. /**
  89872. * Determines whether a given node is a octal escape sequence
  89873. * @param {ASTNode} node A node to check
  89874. * @returns {boolean} `true` if the node is an octal escape sequence
  89875. */
  89876. function isOctalEscapeSequence(node) {
  89877. // No need to check TemplateLiterals – would throw error with octal escape
  89878. var isStringLiteral = node.type === "Literal" && typeof node.value === "string";
  89879. if (!isStringLiteral) {
  89880. return false;
  89881. }
  89882. var match = node.raw.match(/^([^\\]|\\[^0-7])*\\([0-7]{1,3})/);
  89883. if (match) {
  89884. // \0 is actually not considered an octal
  89885. if (match[2] !== "0" || typeof match[3] !== "undefined") {
  89886. return true;
  89887. }
  89888. }
  89889. return false;
  89890. }
  89891. /**
  89892. * Checks whether or not a node contains a octal escape sequence
  89893. * @param {ASTNode} node A node to check
  89894. * @returns {boolean} `true` if the node contains an octal escape sequence
  89895. */
  89896. function hasOctalEscapeSequence(node) {
  89897. if (isConcatenation(node)) {
  89898. return hasOctalEscapeSequence(node.left) || hasOctalEscapeSequence(node.right);
  89899. }
  89900. return isOctalEscapeSequence(node);
  89901. }
  89902. /**
  89903. * Checks whether or not a given binary expression has string literals.
  89904. * @param {ASTNode} node - A node to check.
  89905. * @returns {boolean} `true` if the node has string literals.
  89906. */
  89907. function hasStringLiteral(node) {
  89908. if (isConcatenation(node)) {
  89909. // `left` is deeper than `right` normally.
  89910. return hasStringLiteral(node.right) || hasStringLiteral(node.left);
  89911. }
  89912. return astUtils.isStringLiteral(node);
  89913. }
  89914. /**
  89915. * Checks whether or not a given binary expression has non string literals.
  89916. * @param {ASTNode} node - A node to check.
  89917. * @returns {boolean} `true` if the node has non string literals.
  89918. */
  89919. function hasNonStringLiteral(node) {
  89920. if (isConcatenation(node)) {
  89921. // `left` is deeper than `right` normally.
  89922. return hasNonStringLiteral(node.right) || hasNonStringLiteral(node.left);
  89923. }
  89924. return !astUtils.isStringLiteral(node);
  89925. }
  89926. /**
  89927. * Determines whether a given node will start with a template curly expression (`${}`) when being converted to a template literal.
  89928. * @param {ASTNode} node The node that will be fixed to a template literal
  89929. * @returns {boolean} `true` if the node will start with a template curly.
  89930. */
  89931. function startsWithTemplateCurly(node) {
  89932. if (node.type === "BinaryExpression") {
  89933. return startsWithTemplateCurly(node.left);
  89934. }
  89935. if (node.type === "TemplateLiteral") {
  89936. return node.expressions.length && node.quasis.length && node.quasis[0].range[0] === node.quasis[0].range[1];
  89937. }
  89938. return node.type !== "Literal" || typeof node.value !== "string";
  89939. }
  89940. /**
  89941. * Determines whether a given node end with a template curly expression (`${}`) when being converted to a template literal.
  89942. * @param {ASTNode} node The node that will be fixed to a template literal
  89943. * @returns {boolean} `true` if the node will end with a template curly.
  89944. */
  89945. function endsWithTemplateCurly(node) {
  89946. if (node.type === "BinaryExpression") {
  89947. return startsWithTemplateCurly(node.right);
  89948. }
  89949. if (node.type === "TemplateLiteral") {
  89950. return node.expressions.length && node.quasis.length && node.quasis[node.quasis.length - 1].range[0] === node.quasis[node.quasis.length - 1].range[1];
  89951. }
  89952. return node.type !== "Literal" || typeof node.value !== "string";
  89953. }
  89954. //------------------------------------------------------------------------------
  89955. // Rule Definition
  89956. //------------------------------------------------------------------------------
  89957. module.exports = {
  89958. meta: {
  89959. type: "suggestion",
  89960. docs: {
  89961. description: "require template literals instead of string concatenation",
  89962. category: "ECMAScript 6",
  89963. recommended: false,
  89964. url: "https://eslint.org/docs/rules/prefer-template"
  89965. },
  89966. schema: [],
  89967. fixable: "code"
  89968. },
  89969. create: function create(context) {
  89970. var sourceCode = context.getSourceCode();
  89971. var done = Object.create(null);
  89972. /**
  89973. * Gets the non-token text between two nodes, ignoring any other tokens that appear between the two tokens.
  89974. * @param {ASTNode} node1 The first node
  89975. * @param {ASTNode} node2 The second node
  89976. * @returns {string} The text between the nodes, excluding other tokens
  89977. */
  89978. function getTextBetween(node1, node2) {
  89979. var allTokens = [node1].concat(sourceCode.getTokensBetween(node1, node2)).concat(node2);
  89980. var sourceText = sourceCode.getText();
  89981. return allTokens.slice(0, -1).reduce(function (accumulator, token, index) {
  89982. return accumulator + sourceText.slice(token.range[1], allTokens[index + 1].range[0]);
  89983. }, "");
  89984. }
  89985. /**
  89986. * Returns a template literal form of the given node.
  89987. * @param {ASTNode} currentNode A node that should be converted to a template literal
  89988. * @param {string} textBeforeNode Text that should appear before the node
  89989. * @param {string} textAfterNode Text that should appear after the node
  89990. * @returns {string} A string form of this node, represented as a template literal
  89991. */
  89992. function getTemplateLiteral(currentNode, textBeforeNode, textAfterNode) {
  89993. if (currentNode.type === "Literal" && typeof currentNode.value === "string") {
  89994. /*
  89995. * If the current node is a string literal, escape any instances of ${ or ` to prevent them from being interpreted
  89996. * as a template placeholder. However, if the code already contains a backslash before the ${ or `
  89997. * for some reason, don't add another backslash, because that would change the meaning of the code (it would cause
  89998. * an actual backslash character to appear before the dollar sign).
  89999. */
  90000. return "`" + currentNode.raw.slice(1, -1).replace(/\\*(\${|`)/g, function (matched) {
  90001. if (matched.lastIndexOf("\\") % 2) {
  90002. return "\\" + matched;
  90003. }
  90004. return matched;
  90005. // Unescape any quotes that appear in the original Literal that no longer need to be escaped.
  90006. }).replace(new RegExp("\\\\" + currentNode.raw[0], "g"), currentNode.raw[0]) + "`";
  90007. }
  90008. if (currentNode.type === "TemplateLiteral") {
  90009. return sourceCode.getText(currentNode);
  90010. }
  90011. if (isConcatenation(currentNode) && hasStringLiteral(currentNode) && hasNonStringLiteral(currentNode)) {
  90012. var plusSign = sourceCode.getFirstTokenBetween(currentNode.left, currentNode.right, function (token) {
  90013. return token.value === "+";
  90014. });
  90015. var textBeforePlus = getTextBetween(currentNode.left, plusSign);
  90016. var textAfterPlus = getTextBetween(plusSign, currentNode.right);
  90017. var leftEndsWithCurly = endsWithTemplateCurly(currentNode.left);
  90018. var rightStartsWithCurly = startsWithTemplateCurly(currentNode.right);
  90019. if (leftEndsWithCurly) {
  90020. // If the left side of the expression ends with a template curly, add the extra text to the end of the curly bracket.
  90021. // `foo${bar}` /* comment */ + 'baz' --> `foo${bar /* comment */ }${baz}`
  90022. return getTemplateLiteral(currentNode.left, textBeforeNode, textBeforePlus + textAfterPlus).slice(0, -1) + getTemplateLiteral(currentNode.right, null, textAfterNode).slice(1);
  90023. }
  90024. if (rightStartsWithCurly) {
  90025. // Otherwise, if the right side of the expression starts with a template curly, add the text there.
  90026. // 'foo' /* comment */ + `${bar}baz` --> `foo${ /* comment */ bar}baz`
  90027. return getTemplateLiteral(currentNode.left, textBeforeNode, null).slice(0, -1) + getTemplateLiteral(currentNode.right, textBeforePlus + textAfterPlus, textAfterNode).slice(1);
  90028. }
  90029. /*
  90030. * Otherwise, these nodes should not be combined into a template curly, since there is nowhere to put
  90031. * the text between them.
  90032. */
  90033. return "" + getTemplateLiteral(currentNode.left, textBeforeNode, null) + textBeforePlus + "+" + textAfterPlus + getTemplateLiteral(currentNode.right, textAfterNode, null);
  90034. }
  90035. return "`${" + (textBeforeNode || "") + sourceCode.getText(currentNode) + (textAfterNode || "") + "}`";
  90036. }
  90037. /**
  90038. * Returns a fixer object that converts a non-string binary expression to a template literal
  90039. * @param {SourceCodeFixer} fixer The fixer object
  90040. * @param {ASTNode} node A node that should be converted to a template literal
  90041. * @returns {Object} A fix for this binary expression
  90042. */
  90043. function fixNonStringBinaryExpression(fixer, node) {
  90044. var topBinaryExpr = getTopConcatBinaryExpression(node.parent);
  90045. if (hasOctalEscapeSequence(topBinaryExpr)) {
  90046. return null;
  90047. }
  90048. return fixer.replaceText(topBinaryExpr, getTemplateLiteral(topBinaryExpr, null, null));
  90049. }
  90050. /**
  90051. * Reports if a given node is string concatenation with non string literals.
  90052. *
  90053. * @param {ASTNode} node - A node to check.
  90054. * @returns {void}
  90055. */
  90056. function checkForStringConcat(node) {
  90057. if (!astUtils.isStringLiteral(node) || !isConcatenation(node.parent)) {
  90058. return;
  90059. }
  90060. var topBinaryExpr = getTopConcatBinaryExpression(node.parent);
  90061. // Checks whether or not this node had been checked already.
  90062. if (done[topBinaryExpr.range[0]]) {
  90063. return;
  90064. }
  90065. done[topBinaryExpr.range[0]] = true;
  90066. if (hasNonStringLiteral(topBinaryExpr)) {
  90067. context.report({
  90068. node: topBinaryExpr,
  90069. message: "Unexpected string concatenation.",
  90070. fix: function fix(fixer) {
  90071. return fixNonStringBinaryExpression(fixer, node);
  90072. }
  90073. });
  90074. }
  90075. }
  90076. return {
  90077. Program: function Program() {
  90078. done = Object.create(null);
  90079. },
  90080. Literal: checkForStringConcat,
  90081. TemplateLiteral: checkForStringConcat
  90082. };
  90083. }
  90084. };
  90085. },{"../util/ast-utils":405}],355:[function(require,module,exports){
  90086. /**
  90087. * @fileoverview Rule to flag non-quoted property names in object literals.
  90088. * @author Mathias Bynens <http://mathiasbynens.be/>
  90089. */
  90090. "use strict";
  90091. //------------------------------------------------------------------------------
  90092. // Requirements
  90093. //------------------------------------------------------------------------------
  90094. var espree = require("espree"),
  90095. keywords = require("../util/keywords");
  90096. //------------------------------------------------------------------------------
  90097. // Rule Definition
  90098. //------------------------------------------------------------------------------
  90099. module.exports = {
  90100. meta: {
  90101. type: "suggestion",
  90102. docs: {
  90103. description: "require quotes around object literal property names",
  90104. category: "Stylistic Issues",
  90105. recommended: false,
  90106. url: "https://eslint.org/docs/rules/quote-props"
  90107. },
  90108. schema: {
  90109. anyOf: [{
  90110. type: "array",
  90111. items: [{
  90112. enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
  90113. }],
  90114. minItems: 0,
  90115. maxItems: 1
  90116. }, {
  90117. type: "array",
  90118. items: [{
  90119. enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
  90120. }, {
  90121. type: "object",
  90122. properties: {
  90123. keywords: {
  90124. type: "boolean"
  90125. },
  90126. unnecessary: {
  90127. type: "boolean"
  90128. },
  90129. numbers: {
  90130. type: "boolean"
  90131. }
  90132. },
  90133. additionalProperties: false
  90134. }],
  90135. minItems: 0,
  90136. maxItems: 2
  90137. }]
  90138. },
  90139. fixable: "code"
  90140. },
  90141. create: function create(context) {
  90142. var MODE = context.options[0],
  90143. KEYWORDS = context.options[1] && context.options[1].keywords,
  90144. CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false,
  90145. NUMBERS = context.options[1] && context.options[1].numbers,
  90146. MESSAGE_UNNECESSARY = "Unnecessarily quoted property '{{property}}' found.",
  90147. MESSAGE_UNQUOTED = "Unquoted property '{{property}}' found.",
  90148. MESSAGE_NUMERIC = "Unquoted number literal '{{property}}' used as key.",
  90149. MESSAGE_RESERVED = "Unquoted reserved word '{{property}}' used as key.",
  90150. sourceCode = context.getSourceCode();
  90151. /**
  90152. * Checks whether a certain string constitutes an ES3 token
  90153. * @param {string} tokenStr - The string to be checked.
  90154. * @returns {boolean} `true` if it is an ES3 token.
  90155. */
  90156. function isKeyword(tokenStr) {
  90157. return keywords.indexOf(tokenStr) >= 0;
  90158. }
  90159. /**
  90160. * Checks if an espree-tokenized key has redundant quotes (i.e. whether quotes are unnecessary)
  90161. * @param {string} rawKey The raw key value from the source
  90162. * @param {espreeTokens} tokens The espree-tokenized node key
  90163. * @param {boolean} [skipNumberLiterals=false] Indicates whether number literals should be checked
  90164. * @returns {boolean} Whether or not a key has redundant quotes.
  90165. * @private
  90166. */
  90167. function areQuotesRedundant(rawKey, tokens, skipNumberLiterals) {
  90168. return tokens.length === 1 && tokens[0].start === 0 && tokens[0].end === rawKey.length && (["Identifier", "Keyword", "Null", "Boolean"].indexOf(tokens[0].type) >= 0 || tokens[0].type === "Numeric" && !skipNumberLiterals && String(+tokens[0].value) === tokens[0].value);
  90169. }
  90170. /**
  90171. * Returns a string representation of a property node with quotes removed
  90172. * @param {ASTNode} key Key AST Node, which may or may not be quoted
  90173. * @returns {string} A replacement string for this property
  90174. */
  90175. function getUnquotedKey(key) {
  90176. return key.type === "Identifier" ? key.name : key.value;
  90177. }
  90178. /**
  90179. * Returns a string representation of a property node with quotes added
  90180. * @param {ASTNode} key Key AST Node, which may or may not be quoted
  90181. * @returns {string} A replacement string for this property
  90182. */
  90183. function getQuotedKey(key) {
  90184. if (key.type === "Literal" && typeof key.value === "string") {
  90185. // If the key is already a string literal, don't replace the quotes with double quotes.
  90186. return sourceCode.getText(key);
  90187. }
  90188. // Otherwise, the key is either an identifier or a number literal.
  90189. return "\"" + (key.type === "Identifier" ? key.name : key.value) + "\"";
  90190. }
  90191. /**
  90192. * Ensures that a property's key is quoted only when necessary
  90193. * @param {ASTNode} node Property AST node
  90194. * @returns {void}
  90195. */
  90196. function checkUnnecessaryQuotes(node) {
  90197. var key = node.key;
  90198. if (node.method || node.computed || node.shorthand) {
  90199. return;
  90200. }
  90201. if (key.type === "Literal" && typeof key.value === "string") {
  90202. var tokens = void 0;
  90203. try {
  90204. tokens = espree.tokenize(key.value);
  90205. } catch (e) {
  90206. return;
  90207. }
  90208. if (tokens.length !== 1) {
  90209. return;
  90210. }
  90211. var isKeywordToken = isKeyword(tokens[0].value);
  90212. if (isKeywordToken && KEYWORDS) {
  90213. return;
  90214. }
  90215. if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) {
  90216. context.report({
  90217. node: node,
  90218. message: MESSAGE_UNNECESSARY,
  90219. data: { property: key.value },
  90220. fix: function fix(fixer) {
  90221. return fixer.replaceText(key, getUnquotedKey(key));
  90222. }
  90223. });
  90224. }
  90225. } else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) {
  90226. context.report({
  90227. node: node,
  90228. message: MESSAGE_RESERVED,
  90229. data: { property: key.name },
  90230. fix: function fix(fixer) {
  90231. return fixer.replaceText(key, getQuotedKey(key));
  90232. }
  90233. });
  90234. } else if (NUMBERS && key.type === "Literal" && typeof key.value === "number") {
  90235. context.report({
  90236. node: node,
  90237. message: MESSAGE_NUMERIC,
  90238. data: { property: key.value },
  90239. fix: function fix(fixer) {
  90240. return fixer.replaceText(key, getQuotedKey(key));
  90241. }
  90242. });
  90243. }
  90244. }
  90245. /**
  90246. * Ensures that a property's key is quoted
  90247. * @param {ASTNode} node Property AST node
  90248. * @returns {void}
  90249. */
  90250. function checkOmittedQuotes(node) {
  90251. var key = node.key;
  90252. if (!node.method && !node.computed && !node.shorthand && !(key.type === "Literal" && typeof key.value === "string")) {
  90253. context.report({
  90254. node: node,
  90255. message: MESSAGE_UNQUOTED,
  90256. data: { property: key.name || key.value },
  90257. fix: function fix(fixer) {
  90258. return fixer.replaceText(key, getQuotedKey(key));
  90259. }
  90260. });
  90261. }
  90262. }
  90263. /**
  90264. * Ensures that an object's keys are consistently quoted, optionally checks for redundancy of quotes
  90265. * @param {ASTNode} node Property AST node
  90266. * @param {boolean} checkQuotesRedundancy Whether to check quotes' redundancy
  90267. * @returns {void}
  90268. */
  90269. function checkConsistency(node, checkQuotesRedundancy) {
  90270. var quotedProps = [],
  90271. unquotedProps = [];
  90272. var keywordKeyName = null,
  90273. necessaryQuotes = false;
  90274. node.properties.forEach(function (property) {
  90275. var key = property.key;
  90276. if (!key || property.method || property.computed || property.shorthand) {
  90277. return;
  90278. }
  90279. if (key.type === "Literal" && typeof key.value === "string") {
  90280. quotedProps.push(property);
  90281. if (checkQuotesRedundancy) {
  90282. var tokens = void 0;
  90283. try {
  90284. tokens = espree.tokenize(key.value);
  90285. } catch (e) {
  90286. necessaryQuotes = true;
  90287. return;
  90288. }
  90289. necessaryQuotes = necessaryQuotes || !areQuotesRedundant(key.value, tokens) || KEYWORDS && isKeyword(tokens[0].value);
  90290. }
  90291. } else if (KEYWORDS && checkQuotesRedundancy && key.type === "Identifier" && isKeyword(key.name)) {
  90292. unquotedProps.push(property);
  90293. necessaryQuotes = true;
  90294. keywordKeyName = key.name;
  90295. } else {
  90296. unquotedProps.push(property);
  90297. }
  90298. });
  90299. if (checkQuotesRedundancy && quotedProps.length && !necessaryQuotes) {
  90300. quotedProps.forEach(function (property) {
  90301. context.report({
  90302. node: property,
  90303. message: "Properties shouldn't be quoted as all quotes are redundant.",
  90304. fix: function fix(fixer) {
  90305. return fixer.replaceText(property.key, getUnquotedKey(property.key));
  90306. }
  90307. });
  90308. });
  90309. } else if (unquotedProps.length && keywordKeyName) {
  90310. unquotedProps.forEach(function (property) {
  90311. context.report({
  90312. node: property,
  90313. message: "Properties should be quoted as '{{property}}' is a reserved word.",
  90314. data: { property: keywordKeyName },
  90315. fix: function fix(fixer) {
  90316. return fixer.replaceText(property.key, getQuotedKey(property.key));
  90317. }
  90318. });
  90319. });
  90320. } else if (quotedProps.length && unquotedProps.length) {
  90321. unquotedProps.forEach(function (property) {
  90322. context.report({
  90323. node: property,
  90324. message: "Inconsistently quoted property '{{key}}' found.",
  90325. data: { key: property.key.name || property.key.value },
  90326. fix: function fix(fixer) {
  90327. return fixer.replaceText(property.key, getQuotedKey(property.key));
  90328. }
  90329. });
  90330. });
  90331. }
  90332. }
  90333. return {
  90334. Property: function Property(node) {
  90335. if (MODE === "always" || !MODE) {
  90336. checkOmittedQuotes(node);
  90337. }
  90338. if (MODE === "as-needed") {
  90339. checkUnnecessaryQuotes(node);
  90340. }
  90341. },
  90342. ObjectExpression: function ObjectExpression(node) {
  90343. if (MODE === "consistent") {
  90344. checkConsistency(node, false);
  90345. }
  90346. if (MODE === "consistent-as-needed") {
  90347. checkConsistency(node, true);
  90348. }
  90349. }
  90350. };
  90351. }
  90352. };
  90353. },{"../util/keywords":409,"espree":"espree"}],356:[function(require,module,exports){
  90354. /**
  90355. * @fileoverview A rule to choose between single and double quote marks
  90356. * @author Matt DuVall <http://www.mattduvall.com/>, Brandon Payton
  90357. */
  90358. "use strict";
  90359. //------------------------------------------------------------------------------
  90360. // Requirements
  90361. //------------------------------------------------------------------------------
  90362. var _templateObject = _taggedTemplateLiteral(["(^|[^\\])(\\\\)*[", "]"], ["(^|[^\\\\])(\\\\\\\\)*[", "]"]);
  90363. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  90364. var astUtils = require("../util/ast-utils");
  90365. //------------------------------------------------------------------------------
  90366. // Constants
  90367. //------------------------------------------------------------------------------
  90368. var QUOTE_SETTINGS = {
  90369. double: {
  90370. quote: "\"",
  90371. alternateQuote: "'",
  90372. description: "doublequote"
  90373. },
  90374. single: {
  90375. quote: "'",
  90376. alternateQuote: "\"",
  90377. description: "singlequote"
  90378. },
  90379. backtick: {
  90380. quote: "`",
  90381. alternateQuote: "\"",
  90382. description: "backtick"
  90383. }
  90384. };
  90385. // An unescaped newline is a newline preceded by an even number of backslashes.
  90386. var UNESCAPED_LINEBREAK_PATTERN = new RegExp(String.raw(_templateObject, Array.from(astUtils.LINEBREAKS).join("")));
  90387. /**
  90388. * Switches quoting of javascript string between ' " and `
  90389. * escaping and unescaping as necessary.
  90390. * Only escaping of the minimal set of characters is changed.
  90391. * Note: escaping of newlines when switching from backtick to other quotes is not handled.
  90392. * @param {string} str - A string to convert.
  90393. * @returns {string} The string with changed quotes.
  90394. * @private
  90395. */
  90396. QUOTE_SETTINGS.double.convert = QUOTE_SETTINGS.single.convert = QUOTE_SETTINGS.backtick.convert = function (str) {
  90397. var newQuote = this.quote;
  90398. var oldQuote = str[0];
  90399. if (newQuote === oldQuote) {
  90400. return str;
  90401. }
  90402. return newQuote + str.slice(1, -1).replace(/\\(\${|\r\n?|\n|.)|["'`]|\${|(\r\n?|\n)/g, function (match, escaped, newline) {
  90403. if (escaped === oldQuote || oldQuote === "`" && escaped === "${") {
  90404. return escaped; // unescape
  90405. }
  90406. if (match === newQuote || newQuote === "`" && match === "${") {
  90407. return "\\" + match; // escape
  90408. }
  90409. if (newline && oldQuote === "`") {
  90410. return "\\n"; // escape newlines
  90411. }
  90412. return match;
  90413. }) + newQuote;
  90414. };
  90415. var AVOID_ESCAPE = "avoid-escape";
  90416. //------------------------------------------------------------------------------
  90417. // Rule Definition
  90418. //------------------------------------------------------------------------------
  90419. module.exports = {
  90420. meta: {
  90421. type: "layout",
  90422. docs: {
  90423. description: "enforce the consistent use of either backticks, double, or single quotes",
  90424. category: "Stylistic Issues",
  90425. recommended: false,
  90426. url: "https://eslint.org/docs/rules/quotes"
  90427. },
  90428. fixable: "code",
  90429. schema: [{
  90430. enum: ["single", "double", "backtick"]
  90431. }, {
  90432. anyOf: [{
  90433. enum: ["avoid-escape"]
  90434. }, {
  90435. type: "object",
  90436. properties: {
  90437. avoidEscape: {
  90438. type: "boolean"
  90439. },
  90440. allowTemplateLiterals: {
  90441. type: "boolean"
  90442. }
  90443. },
  90444. additionalProperties: false
  90445. }]
  90446. }]
  90447. },
  90448. create: function create(context) {
  90449. var quoteOption = context.options[0],
  90450. settings = QUOTE_SETTINGS[quoteOption || "double"],
  90451. options = context.options[1],
  90452. allowTemplateLiterals = options && options.allowTemplateLiterals === true,
  90453. sourceCode = context.getSourceCode();
  90454. var avoidEscape = options && options.avoidEscape === true;
  90455. // deprecated
  90456. if (options === AVOID_ESCAPE) {
  90457. avoidEscape = true;
  90458. }
  90459. /**
  90460. * Determines if a given node is part of JSX syntax.
  90461. *
  90462. * This function returns `true` in the following cases:
  90463. *
  90464. * - `<div className="foo"></div>` ... If the literal is an attribute value, the parent of the literal is `JSXAttribute`.
  90465. * - `<div>foo</div>` ... If the literal is a text content, the parent of the literal is `JSXElement`.
  90466. * - `<>foo</>` ... If the literal is a text content, the parent of the literal is `JSXFragment`.
  90467. *
  90468. * In particular, this function returns `false` in the following cases:
  90469. *
  90470. * - `<div className={"foo"}></div>`
  90471. * - `<div>{"foo"}</div>`
  90472. *
  90473. * In both cases, inside of the braces is handled as normal JavaScript.
  90474. * The braces are `JSXExpressionContainer` nodes.
  90475. *
  90476. * @param {ASTNode} node The Literal node to check.
  90477. * @returns {boolean} True if the node is a part of JSX, false if not.
  90478. * @private
  90479. */
  90480. function isJSXLiteral(node) {
  90481. return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment";
  90482. }
  90483. /**
  90484. * Checks whether or not a given node is a directive.
  90485. * The directive is a `ExpressionStatement` which has only a string literal.
  90486. * @param {ASTNode} node - A node to check.
  90487. * @returns {boolean} Whether or not the node is a directive.
  90488. * @private
  90489. */
  90490. function isDirective(node) {
  90491. return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
  90492. }
  90493. /**
  90494. * Checks whether or not a given node is a part of directive prologues.
  90495. * See also: http://www.ecma-international.org/ecma-262/6.0/#sec-directive-prologues-and-the-use-strict-directive
  90496. * @param {ASTNode} node - A node to check.
  90497. * @returns {boolean} Whether or not the node is a part of directive prologues.
  90498. * @private
  90499. */
  90500. function isPartOfDirectivePrologue(node) {
  90501. var block = node.parent.parent;
  90502. if (block.type !== "Program" && (block.type !== "BlockStatement" || !astUtils.isFunction(block.parent))) {
  90503. return false;
  90504. }
  90505. // Check the node is at a prologue.
  90506. for (var i = 0; i < block.body.length; ++i) {
  90507. var statement = block.body[i];
  90508. if (statement === node.parent) {
  90509. return true;
  90510. }
  90511. if (!isDirective(statement)) {
  90512. break;
  90513. }
  90514. }
  90515. return false;
  90516. }
  90517. /**
  90518. * Checks whether or not a given node is allowed as non backtick.
  90519. * @param {ASTNode} node - A node to check.
  90520. * @returns {boolean} Whether or not the node is allowed as non backtick.
  90521. * @private
  90522. */
  90523. function isAllowedAsNonBacktick(node) {
  90524. var parent = node.parent;
  90525. switch (parent.type) {
  90526. // Directive Prologues.
  90527. case "ExpressionStatement":
  90528. return isPartOfDirectivePrologue(node);
  90529. // LiteralPropertyName.
  90530. case "Property":
  90531. case "MethodDefinition":
  90532. return parent.key === node && !parent.computed;
  90533. // ModuleSpecifier.
  90534. case "ImportDeclaration":
  90535. case "ExportNamedDeclaration":
  90536. case "ExportAllDeclaration":
  90537. return parent.source === node;
  90538. // Others don't allow.
  90539. default:
  90540. return false;
  90541. }
  90542. }
  90543. /**
  90544. * Checks whether or not a given TemplateLiteral node is actually using any of the special features provided by template literal strings.
  90545. * @param {ASTNode} node - A TemplateLiteral node to check.
  90546. * @returns {boolean} Whether or not the TemplateLiteral node is using any of the special features provided by template literal strings.
  90547. * @private
  90548. */
  90549. function isUsingFeatureOfTemplateLiteral(node) {
  90550. var hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi;
  90551. if (hasTag) {
  90552. return true;
  90553. }
  90554. var hasStringInterpolation = node.expressions.length > 0;
  90555. if (hasStringInterpolation) {
  90556. return true;
  90557. }
  90558. var isMultilineString = node.quasis.length >= 1 && UNESCAPED_LINEBREAK_PATTERN.test(node.quasis[0].value.raw);
  90559. if (isMultilineString) {
  90560. return true;
  90561. }
  90562. return false;
  90563. }
  90564. return {
  90565. Literal: function Literal(node) {
  90566. var val = node.value,
  90567. rawVal = node.raw;
  90568. if (settings && typeof val === "string") {
  90569. var isValid = quoteOption === "backtick" && isAllowedAsNonBacktick(node) || isJSXLiteral(node) || astUtils.isSurroundedBy(rawVal, settings.quote);
  90570. if (!isValid && avoidEscape) {
  90571. isValid = astUtils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.indexOf(settings.quote) >= 0;
  90572. }
  90573. if (!isValid) {
  90574. context.report({
  90575. node: node,
  90576. message: "Strings must use {{description}}.",
  90577. data: {
  90578. description: settings.description
  90579. },
  90580. fix: function fix(fixer) {
  90581. return fixer.replaceText(node, settings.convert(node.raw));
  90582. }
  90583. });
  90584. }
  90585. }
  90586. },
  90587. TemplateLiteral: function TemplateLiteral(node) {
  90588. // Don't throw an error if backticks are expected or a template literal feature is in use.
  90589. if (allowTemplateLiterals || quoteOption === "backtick" || isUsingFeatureOfTemplateLiteral(node)) {
  90590. return;
  90591. }
  90592. context.report({
  90593. node: node,
  90594. message: "Strings must use {{description}}.",
  90595. data: {
  90596. description: settings.description
  90597. },
  90598. fix: function fix(fixer) {
  90599. if (isPartOfDirectivePrologue(node)) {
  90600. /*
  90601. * TemplateLiterals in a directive prologue aren't actually directives, but if they're
  90602. * in the directive prologue, then fixing them might turn them into directives and change
  90603. * the behavior of the code.
  90604. */
  90605. return null;
  90606. }
  90607. return fixer.replaceText(node, settings.convert(sourceCode.getText(node)));
  90608. }
  90609. });
  90610. }
  90611. };
  90612. }
  90613. };
  90614. },{"../util/ast-utils":405}],357:[function(require,module,exports){
  90615. /**
  90616. * @fileoverview Rule to flag use of parseInt without a radix argument
  90617. * @author James Allardice
  90618. */
  90619. "use strict";
  90620. //------------------------------------------------------------------------------
  90621. // Requirements
  90622. //------------------------------------------------------------------------------
  90623. var astUtils = require("../util/ast-utils");
  90624. //------------------------------------------------------------------------------
  90625. // Helpers
  90626. //------------------------------------------------------------------------------
  90627. var MODE_ALWAYS = "always",
  90628. MODE_AS_NEEDED = "as-needed";
  90629. /**
  90630. * Checks whether a given variable is shadowed or not.
  90631. *
  90632. * @param {eslint-scope.Variable} variable - A variable to check.
  90633. * @returns {boolean} `true` if the variable is shadowed.
  90634. */
  90635. function isShadowed(variable) {
  90636. return variable.defs.length >= 1;
  90637. }
  90638. /**
  90639. * Checks whether a given node is a MemberExpression of `parseInt` method or not.
  90640. *
  90641. * @param {ASTNode} node - A node to check.
  90642. * @returns {boolean} `true` if the node is a MemberExpression of `parseInt`
  90643. * method.
  90644. */
  90645. function isParseIntMethod(node) {
  90646. return node.type === "MemberExpression" && !node.computed && node.property.type === "Identifier" && node.property.name === "parseInt";
  90647. }
  90648. /**
  90649. * Checks whether a given node is a valid value of radix or not.
  90650. *
  90651. * The following values are invalid.
  90652. *
  90653. * - A literal except numbers.
  90654. * - undefined.
  90655. *
  90656. * @param {ASTNode} radix - A node of radix to check.
  90657. * @returns {boolean} `true` if the node is valid.
  90658. */
  90659. function isValidRadix(radix) {
  90660. return !(radix.type === "Literal" && typeof radix.value !== "number" || radix.type === "Identifier" && radix.name === "undefined");
  90661. }
  90662. /**
  90663. * Checks whether a given node is a default value of radix or not.
  90664. *
  90665. * @param {ASTNode} radix - A node of radix to check.
  90666. * @returns {boolean} `true` if the node is the literal node of `10`.
  90667. */
  90668. function isDefaultRadix(radix) {
  90669. return radix.type === "Literal" && radix.value === 10;
  90670. }
  90671. //------------------------------------------------------------------------------
  90672. // Rule Definition
  90673. //------------------------------------------------------------------------------
  90674. module.exports = {
  90675. meta: {
  90676. type: "suggestion",
  90677. docs: {
  90678. description: "enforce the consistent use of the radix argument when using `parseInt()`",
  90679. category: "Best Practices",
  90680. recommended: false,
  90681. url: "https://eslint.org/docs/rules/radix"
  90682. },
  90683. schema: [{
  90684. enum: ["always", "as-needed"]
  90685. }]
  90686. },
  90687. create: function create(context) {
  90688. var mode = context.options[0] || MODE_ALWAYS;
  90689. /**
  90690. * Checks the arguments of a given CallExpression node and reports it if it
  90691. * offends this rule.
  90692. *
  90693. * @param {ASTNode} node - A CallExpression node to check.
  90694. * @returns {void}
  90695. */
  90696. function checkArguments(node) {
  90697. var args = node.arguments;
  90698. switch (args.length) {
  90699. case 0:
  90700. context.report({
  90701. node: node,
  90702. message: "Missing parameters."
  90703. });
  90704. break;
  90705. case 1:
  90706. if (mode === MODE_ALWAYS) {
  90707. context.report({
  90708. node: node,
  90709. message: "Missing radix parameter."
  90710. });
  90711. }
  90712. break;
  90713. default:
  90714. if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) {
  90715. context.report({
  90716. node: node,
  90717. message: "Redundant radix parameter."
  90718. });
  90719. } else if (!isValidRadix(args[1])) {
  90720. context.report({
  90721. node: node,
  90722. message: "Invalid radix parameter."
  90723. });
  90724. }
  90725. break;
  90726. }
  90727. }
  90728. return {
  90729. "Program:exit": function ProgramExit() {
  90730. var scope = context.getScope();
  90731. var variable = void 0;
  90732. // Check `parseInt()`
  90733. variable = astUtils.getVariableByName(scope, "parseInt");
  90734. if (!isShadowed(variable)) {
  90735. variable.references.forEach(function (reference) {
  90736. var node = reference.identifier;
  90737. if (astUtils.isCallee(node)) {
  90738. checkArguments(node.parent);
  90739. }
  90740. });
  90741. }
  90742. // Check `Number.parseInt()`
  90743. variable = astUtils.getVariableByName(scope, "Number");
  90744. if (!isShadowed(variable)) {
  90745. variable.references.forEach(function (reference) {
  90746. var node = reference.identifier.parent;
  90747. if (isParseIntMethod(node) && astUtils.isCallee(node)) {
  90748. checkArguments(node.parent);
  90749. }
  90750. });
  90751. }
  90752. }
  90753. };
  90754. }
  90755. };
  90756. },{"../util/ast-utils":405}],358:[function(require,module,exports){
  90757. /**
  90758. * @fileoverview disallow assignments that can lead to race conditions due to usage of `await` or `yield`
  90759. * @author Teddy Katz
  90760. */
  90761. "use strict";
  90762. 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; }; }();
  90763. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  90764. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  90765. var astUtils = require("../util/ast-utils");
  90766. //------------------------------------------------------------------------------
  90767. // Rule Definition
  90768. //------------------------------------------------------------------------------
  90769. module.exports = {
  90770. meta: {
  90771. type: "problem",
  90772. docs: {
  90773. description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
  90774. category: "Possible Errors",
  90775. recommended: false,
  90776. url: "https://eslint.org/docs/rules/require-atomic-updates"
  90777. },
  90778. fixable: null,
  90779. schema: [],
  90780. messages: {
  90781. nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`."
  90782. }
  90783. },
  90784. create: function create(context) {
  90785. var sourceCode = context.getSourceCode();
  90786. var identifierToSurroundingFunctionMap = new WeakMap();
  90787. var expressionsByCodePathSegment = new Map();
  90788. //----------------------------------------------------------------------
  90789. // Helpers
  90790. //----------------------------------------------------------------------
  90791. var resolvedVariableCache = new WeakMap();
  90792. /**
  90793. * Gets the variable scope around this variable reference
  90794. * @param {ASTNode} identifier An `Identifier` AST node
  90795. * @returns {Scope|null} An escope Scope
  90796. */
  90797. function getScope(identifier) {
  90798. for (var currentNode = identifier; currentNode; currentNode = currentNode.parent) {
  90799. var scope = sourceCode.scopeManager.acquire(currentNode, true);
  90800. if (scope) {
  90801. return scope;
  90802. }
  90803. }
  90804. return null;
  90805. }
  90806. /**
  90807. * Resolves a given identifier to a given scope
  90808. * @param {ASTNode} identifier An `Identifier` AST node
  90809. * @param {Scope} scope An escope Scope
  90810. * @returns {Variable|null} An escope Variable corresponding to the given identifier
  90811. */
  90812. function resolveVariableInScope(identifier, scope) {
  90813. return scope.variables.find(function (variable) {
  90814. return variable.name === identifier.name;
  90815. }) || (scope.upper ? resolveVariableInScope(identifier, scope.upper) : null);
  90816. }
  90817. /**
  90818. * Resolves an identifier to a variable
  90819. * @param {ASTNode} identifier An identifier node
  90820. * @returns {Variable|null} The escope Variable that uses this identifier
  90821. */
  90822. function resolveVariable(identifier) {
  90823. if (!resolvedVariableCache.has(identifier)) {
  90824. var surroundingScope = getScope(identifier);
  90825. if (surroundingScope) {
  90826. resolvedVariableCache.set(identifier, resolveVariableInScope(identifier, surroundingScope));
  90827. } else {
  90828. resolvedVariableCache.set(identifier, null);
  90829. }
  90830. }
  90831. return resolvedVariableCache.get(identifier);
  90832. }
  90833. /**
  90834. * Checks if an expression is a variable that can only be observed within the given function.
  90835. * @param {ASTNode} expression The expression to check
  90836. * @param {ASTNode} surroundingFunction The function node
  90837. * @returns {boolean} `true` if the expression is a variable which is local to the given function, and is never
  90838. * referenced in a closure.
  90839. */
  90840. function isLocalVariableWithoutEscape(expression, surroundingFunction) {
  90841. if (expression.type !== "Identifier") {
  90842. return false;
  90843. }
  90844. var variable = resolveVariable(expression);
  90845. if (!variable) {
  90846. return false;
  90847. }
  90848. return variable.references.every(function (reference) {
  90849. return identifierToSurroundingFunctionMap.get(reference.identifier) === surroundingFunction;
  90850. }) && variable.defs.every(function (def) {
  90851. return identifierToSurroundingFunctionMap.get(def.name) === surroundingFunction;
  90852. });
  90853. }
  90854. /**
  90855. * Reports an AssignmentExpression node that has a non-atomic update
  90856. * @param {ASTNode} assignmentExpression The assignment that is potentially unsafe
  90857. * @returns {void}
  90858. */
  90859. function reportAssignment(assignmentExpression) {
  90860. context.report({
  90861. node: assignmentExpression,
  90862. messageId: "nonAtomicUpdate",
  90863. data: {
  90864. value: sourceCode.getText(assignmentExpression.left)
  90865. }
  90866. });
  90867. }
  90868. var alreadyReportedAssignments = new WeakSet();
  90869. var AssignmentTrackerState = function () {
  90870. function AssignmentTrackerState() {
  90871. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  90872. _ref$openAssignmentsW = _ref.openAssignmentsWithoutReads,
  90873. openAssignmentsWithoutReads = _ref$openAssignmentsW === undefined ? new Set() : _ref$openAssignmentsW,
  90874. _ref$openAssignmentsW2 = _ref.openAssignmentsWithReads,
  90875. openAssignmentsWithReads = _ref$openAssignmentsW2 === undefined ? new Set() : _ref$openAssignmentsW2;
  90876. _classCallCheck(this, AssignmentTrackerState);
  90877. this.openAssignmentsWithoutReads = openAssignmentsWithoutReads;
  90878. this.openAssignmentsWithReads = openAssignmentsWithReads;
  90879. }
  90880. _createClass(AssignmentTrackerState, [{
  90881. key: "copy",
  90882. value: function copy() {
  90883. return new AssignmentTrackerState({
  90884. openAssignmentsWithoutReads: new Set(this.openAssignmentsWithoutReads),
  90885. openAssignmentsWithReads: new Set(this.openAssignmentsWithReads)
  90886. });
  90887. }
  90888. }, {
  90889. key: "merge",
  90890. value: function merge(other) {
  90891. var _this = this;
  90892. var initialAssignmentsWithoutReadsCount = this.openAssignmentsWithoutReads.size;
  90893. var initialAssignmentsWithReadsCount = this.openAssignmentsWithReads.size;
  90894. other.openAssignmentsWithoutReads.forEach(function (assignment) {
  90895. return _this.openAssignmentsWithoutReads.add(assignment);
  90896. });
  90897. other.openAssignmentsWithReads.forEach(function (assignment) {
  90898. return _this.openAssignmentsWithReads.add(assignment);
  90899. });
  90900. return this.openAssignmentsWithoutReads.size > initialAssignmentsWithoutReadsCount || this.openAssignmentsWithReads.size > initialAssignmentsWithReadsCount;
  90901. }
  90902. }, {
  90903. key: "enterAssignment",
  90904. value: function enterAssignment(assignmentExpression) {
  90905. (assignmentExpression.operator === "=" ? this.openAssignmentsWithoutReads : this.openAssignmentsWithReads).add(assignmentExpression);
  90906. }
  90907. }, {
  90908. key: "exitAssignment",
  90909. value: function exitAssignment(assignmentExpression) {
  90910. this.openAssignmentsWithoutReads.delete(assignmentExpression);
  90911. this.openAssignmentsWithReads.delete(assignmentExpression);
  90912. }
  90913. }, {
  90914. key: "exitAwaitOrYield",
  90915. value: function exitAwaitOrYield(node, surroundingFunction) {
  90916. return [].concat(_toConsumableArray(this.openAssignmentsWithReads)).filter(function (assignment) {
  90917. return !isLocalVariableWithoutEscape(assignment.left, surroundingFunction);
  90918. }).forEach(function (assignment) {
  90919. if (!alreadyReportedAssignments.has(assignment)) {
  90920. reportAssignment(assignment);
  90921. alreadyReportedAssignments.add(assignment);
  90922. }
  90923. });
  90924. }
  90925. }, {
  90926. key: "exitIdentifierOrMemberExpression",
  90927. value: function exitIdentifierOrMemberExpression(node) {
  90928. var _this2 = this;
  90929. [].concat(_toConsumableArray(this.openAssignmentsWithoutReads)).filter(function (assignment) {
  90930. return assignment.left !== node && assignment.left.type === node.type && astUtils.equalTokens(assignment.left, node, sourceCode);
  90931. }).forEach(function (assignment) {
  90932. _this2.openAssignmentsWithoutReads.delete(assignment);
  90933. _this2.openAssignmentsWithReads.add(assignment);
  90934. });
  90935. }
  90936. }]);
  90937. return AssignmentTrackerState;
  90938. }();
  90939. /**
  90940. * If the control flow graph of a function enters an assignment expression, then does the
  90941. * both of the following steps in order (possibly with other steps in between) before exiting the
  90942. * assignment expression, then the assignment might be using an outdated value.
  90943. * 1. Enters a read of the variable or property assigned in the expression (not necessary if operator assignment is used)
  90944. * 2. Exits an `await` or `yield` expression
  90945. *
  90946. * This function checks for the outdated values and reports them.
  90947. * @param {CodePathSegment} codePathSegment The current code path segment to traverse
  90948. * @param {ASTNode} surroundingFunction The function node containing the code path segment
  90949. * @returns {void}
  90950. */
  90951. function findOutdatedReads(codePathSegment, surroundingFunction) {
  90952. var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  90953. _ref2$stateBySegmentS = _ref2.stateBySegmentStart,
  90954. stateBySegmentStart = _ref2$stateBySegmentS === undefined ? new WeakMap() : _ref2$stateBySegmentS,
  90955. _ref2$stateBySegmentE = _ref2.stateBySegmentEnd,
  90956. stateBySegmentEnd = _ref2$stateBySegmentE === undefined ? new WeakMap() : _ref2$stateBySegmentE;
  90957. if (!stateBySegmentStart.has(codePathSegment)) {
  90958. stateBySegmentStart.set(codePathSegment, new AssignmentTrackerState());
  90959. }
  90960. var currentState = stateBySegmentStart.get(codePathSegment).copy();
  90961. expressionsByCodePathSegment.get(codePathSegment).forEach(function (_ref3) {
  90962. var entering = _ref3.entering,
  90963. node = _ref3.node;
  90964. if (node.type === "AssignmentExpression") {
  90965. if (entering) {
  90966. currentState.enterAssignment(node);
  90967. } else {
  90968. currentState.exitAssignment(node);
  90969. }
  90970. } else if (!entering && (node.type === "AwaitExpression" || node.type === "YieldExpression")) {
  90971. currentState.exitAwaitOrYield(node, surroundingFunction);
  90972. } else if (!entering && (node.type === "Identifier" || node.type === "MemberExpression")) {
  90973. currentState.exitIdentifierOrMemberExpression(node);
  90974. }
  90975. });
  90976. stateBySegmentEnd.set(codePathSegment, currentState);
  90977. codePathSegment.nextSegments.forEach(function (nextSegment) {
  90978. if (stateBySegmentStart.has(nextSegment)) {
  90979. if (!stateBySegmentStart.get(nextSegment).merge(currentState)) {
  90980. /*
  90981. * This segment has already been processed with the given set of inputs;
  90982. * no need to do it again. After no new state is available to process
  90983. * for any control flow segment in the graph, the analysis reaches a fixpoint and
  90984. * traversal stops.
  90985. */
  90986. return;
  90987. }
  90988. } else {
  90989. stateBySegmentStart.set(nextSegment, currentState.copy());
  90990. }
  90991. findOutdatedReads(nextSegment, surroundingFunction, { stateBySegmentStart: stateBySegmentStart, stateBySegmentEnd: stateBySegmentEnd });
  90992. });
  90993. }
  90994. //----------------------------------------------------------------------
  90995. // Public
  90996. //----------------------------------------------------------------------
  90997. var currentCodePathSegmentStack = [];
  90998. var currentCodePathSegment = null;
  90999. var functionStack = [];
  91000. return {
  91001. onCodePathStart: function onCodePathStart() {
  91002. currentCodePathSegmentStack.push(currentCodePathSegment);
  91003. },
  91004. onCodePathEnd: function onCodePathEnd(codePath, node) {
  91005. currentCodePathSegment = currentCodePathSegmentStack.pop();
  91006. if (astUtils.isFunction(node) && (node.async || node.generator)) {
  91007. findOutdatedReads(codePath.initialSegment, node);
  91008. }
  91009. },
  91010. onCodePathSegmentStart: function onCodePathSegmentStart(segment) {
  91011. currentCodePathSegment = segment;
  91012. expressionsByCodePathSegment.set(segment, []);
  91013. },
  91014. "AssignmentExpression, Identifier, MemberExpression, AwaitExpression, YieldExpression": function AssignmentExpressionIdentifierMemberExpressionAwaitExpressionYieldExpression(node) {
  91015. expressionsByCodePathSegment.get(currentCodePathSegment).push({ entering: true, node: node });
  91016. },
  91017. "AssignmentExpression, Identifier, MemberExpression, AwaitExpression, YieldExpression:exit": function AssignmentExpressionIdentifierMemberExpressionAwaitExpressionYieldExpressionExit(node) {
  91018. expressionsByCodePathSegment.get(currentCodePathSegment).push({ entering: false, node: node });
  91019. },
  91020. ":function": function _function(node) {
  91021. functionStack.push(node);
  91022. },
  91023. ":function:exit": function functionExit() {
  91024. functionStack.pop();
  91025. },
  91026. Identifier: function Identifier(node) {
  91027. if (functionStack.length) {
  91028. identifierToSurroundingFunctionMap.set(node, functionStack[functionStack.length - 1]);
  91029. }
  91030. }
  91031. };
  91032. }
  91033. };
  91034. },{"../util/ast-utils":405}],359:[function(require,module,exports){
  91035. /**
  91036. * @fileoverview Rule to disallow async functions which have no `await` expression.
  91037. * @author Toru Nagashima
  91038. */
  91039. "use strict";
  91040. //------------------------------------------------------------------------------
  91041. // Requirements
  91042. //------------------------------------------------------------------------------
  91043. var astUtils = require("../util/ast-utils");
  91044. //------------------------------------------------------------------------------
  91045. // Helpers
  91046. //------------------------------------------------------------------------------
  91047. /**
  91048. * Capitalize the 1st letter of the given text.
  91049. *
  91050. * @param {string} text - The text to capitalize.
  91051. * @returns {string} The text that the 1st letter was capitalized.
  91052. */
  91053. function capitalizeFirstLetter(text) {
  91054. return text[0].toUpperCase() + text.slice(1);
  91055. }
  91056. //------------------------------------------------------------------------------
  91057. // Rule Definition
  91058. //------------------------------------------------------------------------------
  91059. module.exports = {
  91060. meta: {
  91061. type: "suggestion",
  91062. docs: {
  91063. description: "disallow async functions which have no `await` expression",
  91064. category: "Best Practices",
  91065. recommended: false,
  91066. url: "https://eslint.org/docs/rules/require-await"
  91067. },
  91068. schema: []
  91069. },
  91070. create: function create(context) {
  91071. var sourceCode = context.getSourceCode();
  91072. var scopeInfo = null;
  91073. /**
  91074. * Push the scope info object to the stack.
  91075. *
  91076. * @returns {void}
  91077. */
  91078. function enterFunction() {
  91079. scopeInfo = {
  91080. upper: scopeInfo,
  91081. hasAwait: false
  91082. };
  91083. }
  91084. /**
  91085. * Pop the top scope info object from the stack.
  91086. * Also, it reports the function if needed.
  91087. *
  91088. * @param {ASTNode} node - The node to report.
  91089. * @returns {void}
  91090. */
  91091. function exitFunction(node) {
  91092. if (node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) {
  91093. context.report({
  91094. node: node,
  91095. loc: astUtils.getFunctionHeadLoc(node, sourceCode),
  91096. message: "{{name}} has no 'await' expression.",
  91097. data: {
  91098. name: capitalizeFirstLetter(astUtils.getFunctionNameWithKind(node))
  91099. }
  91100. });
  91101. }
  91102. scopeInfo = scopeInfo.upper;
  91103. }
  91104. return {
  91105. FunctionDeclaration: enterFunction,
  91106. FunctionExpression: enterFunction,
  91107. ArrowFunctionExpression: enterFunction,
  91108. "FunctionDeclaration:exit": exitFunction,
  91109. "FunctionExpression:exit": exitFunction,
  91110. "ArrowFunctionExpression:exit": exitFunction,
  91111. AwaitExpression: function AwaitExpression() {
  91112. scopeInfo.hasAwait = true;
  91113. },
  91114. ForOfStatement: function ForOfStatement(node) {
  91115. if (node.await) {
  91116. scopeInfo.hasAwait = true;
  91117. }
  91118. }
  91119. };
  91120. }
  91121. };
  91122. },{"../util/ast-utils":405}],360:[function(require,module,exports){
  91123. /**
  91124. * @fileoverview Rule to check for jsdoc presence.
  91125. * @author Gyandeep Singh
  91126. */
  91127. "use strict";
  91128. module.exports = {
  91129. meta: {
  91130. type: "suggestion",
  91131. docs: {
  91132. description: "require JSDoc comments",
  91133. category: "Stylistic Issues",
  91134. recommended: false,
  91135. url: "https://eslint.org/docs/rules/require-jsdoc"
  91136. },
  91137. schema: [{
  91138. type: "object",
  91139. properties: {
  91140. require: {
  91141. type: "object",
  91142. properties: {
  91143. ClassDeclaration: {
  91144. type: "boolean"
  91145. },
  91146. MethodDefinition: {
  91147. type: "boolean"
  91148. },
  91149. FunctionDeclaration: {
  91150. type: "boolean"
  91151. },
  91152. ArrowFunctionExpression: {
  91153. type: "boolean"
  91154. },
  91155. FunctionExpression: {
  91156. type: "boolean"
  91157. }
  91158. },
  91159. additionalProperties: false
  91160. }
  91161. },
  91162. additionalProperties: false
  91163. }],
  91164. deprecated: true,
  91165. replacedBy: []
  91166. },
  91167. create: function create(context) {
  91168. var source = context.getSourceCode();
  91169. var DEFAULT_OPTIONS = {
  91170. FunctionDeclaration: true,
  91171. MethodDefinition: false,
  91172. ClassDeclaration: false,
  91173. ArrowFunctionExpression: false,
  91174. FunctionExpression: false
  91175. };
  91176. var options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require || {});
  91177. /**
  91178. * Report the error message
  91179. * @param {ASTNode} node node to report
  91180. * @returns {void}
  91181. */
  91182. function report(node) {
  91183. context.report({ node: node, message: "Missing JSDoc comment." });
  91184. }
  91185. /**
  91186. * Check if the jsdoc comment is present or not.
  91187. * @param {ASTNode} node node to examine
  91188. * @returns {void}
  91189. */
  91190. function checkJsDoc(node) {
  91191. var jsdocComment = source.getJSDocComment(node);
  91192. if (!jsdocComment) {
  91193. report(node);
  91194. }
  91195. }
  91196. return {
  91197. FunctionDeclaration: function FunctionDeclaration(node) {
  91198. if (options.FunctionDeclaration) {
  91199. checkJsDoc(node);
  91200. }
  91201. },
  91202. FunctionExpression: function FunctionExpression(node) {
  91203. if (options.MethodDefinition && node.parent.type === "MethodDefinition" || options.FunctionExpression && (node.parent.type === "VariableDeclarator" || node.parent.type === "Property" && node === node.parent.value)) {
  91204. checkJsDoc(node);
  91205. }
  91206. },
  91207. ClassDeclaration: function ClassDeclaration(node) {
  91208. if (options.ClassDeclaration) {
  91209. checkJsDoc(node);
  91210. }
  91211. },
  91212. ArrowFunctionExpression: function ArrowFunctionExpression(node) {
  91213. if (options.ArrowFunctionExpression && node.parent.type === "VariableDeclarator") {
  91214. checkJsDoc(node);
  91215. }
  91216. }
  91217. };
  91218. }
  91219. };
  91220. },{}],361:[function(require,module,exports){
  91221. /**
  91222. * @fileoverview Rule to enforce the use of `u` flag on RegExp.
  91223. * @author Toru Nagashima
  91224. */
  91225. "use strict";
  91226. //------------------------------------------------------------------------------
  91227. // Requirements
  91228. //------------------------------------------------------------------------------
  91229. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  91230. var _require = require("eslint-utils"),
  91231. CALL = _require.CALL,
  91232. CONSTRUCT = _require.CONSTRUCT,
  91233. ReferenceTracker = _require.ReferenceTracker,
  91234. getStringIfConstant = _require.getStringIfConstant;
  91235. //------------------------------------------------------------------------------
  91236. // Rule Definition
  91237. //------------------------------------------------------------------------------
  91238. module.exports = {
  91239. meta: {
  91240. type: "suggestion",
  91241. docs: {
  91242. description: "enforce the use of `u` flag on RegExp",
  91243. category: "Best Practices",
  91244. recommended: false,
  91245. url: "https://eslint.org/docs/rules/require-unicode-regexp"
  91246. },
  91247. messages: {
  91248. requireUFlag: "Use the 'u' flag."
  91249. },
  91250. schema: []
  91251. },
  91252. create: function create(context) {
  91253. return {
  91254. "Literal[regex]": function LiteralRegex(node) {
  91255. var flags = node.regex.flags || "";
  91256. if (!flags.includes("u")) {
  91257. context.report({ node: node, messageId: "requireUFlag" });
  91258. }
  91259. },
  91260. Program: function Program() {
  91261. var _RegExp;
  91262. var scope = context.getScope();
  91263. var tracker = new ReferenceTracker(scope);
  91264. var trackMap = {
  91265. RegExp: (_RegExp = {}, _defineProperty(_RegExp, CALL, true), _defineProperty(_RegExp, CONSTRUCT, true), _RegExp)
  91266. };
  91267. var _iteratorNormalCompletion = true;
  91268. var _didIteratorError = false;
  91269. var _iteratorError = undefined;
  91270. try {
  91271. for (var _iterator = tracker.iterateGlobalReferences(trackMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  91272. var node = _step.value.node;
  91273. var flagsNode = node.arguments[1];
  91274. var flags = getStringIfConstant(flagsNode, scope);
  91275. if (!flagsNode || typeof flags === "string" && !flags.includes("u")) {
  91276. context.report({ node: node, messageId: "requireUFlag" });
  91277. }
  91278. }
  91279. } catch (err) {
  91280. _didIteratorError = true;
  91281. _iteratorError = err;
  91282. } finally {
  91283. try {
  91284. if (!_iteratorNormalCompletion && _iterator.return) {
  91285. _iterator.return();
  91286. }
  91287. } finally {
  91288. if (_didIteratorError) {
  91289. throw _iteratorError;
  91290. }
  91291. }
  91292. }
  91293. }
  91294. };
  91295. }
  91296. };
  91297. },{"eslint-utils":68}],362:[function(require,module,exports){
  91298. /**
  91299. * @fileoverview Rule to flag the generator functions that does not have yield.
  91300. * @author Toru Nagashima
  91301. */
  91302. "use strict";
  91303. //------------------------------------------------------------------------------
  91304. // Rule Definition
  91305. //------------------------------------------------------------------------------
  91306. module.exports = {
  91307. meta: {
  91308. type: "suggestion",
  91309. docs: {
  91310. description: "require generator functions to contain `yield`",
  91311. category: "ECMAScript 6",
  91312. recommended: true,
  91313. url: "https://eslint.org/docs/rules/require-yield"
  91314. },
  91315. schema: []
  91316. },
  91317. create: function create(context) {
  91318. var stack = [];
  91319. /**
  91320. * If the node is a generator function, start counting `yield` keywords.
  91321. * @param {Node} node - A function node to check.
  91322. * @returns {void}
  91323. */
  91324. function beginChecking(node) {
  91325. if (node.generator) {
  91326. stack.push(0);
  91327. }
  91328. }
  91329. /**
  91330. * If the node is a generator function, end counting `yield` keywords, then
  91331. * reports result.
  91332. * @param {Node} node - A function node to check.
  91333. * @returns {void}
  91334. */
  91335. function endChecking(node) {
  91336. if (!node.generator) {
  91337. return;
  91338. }
  91339. var countYield = stack.pop();
  91340. if (countYield === 0 && node.body.body.length > 0) {
  91341. context.report({ node: node, message: "This generator function does not have 'yield'." });
  91342. }
  91343. }
  91344. return {
  91345. FunctionDeclaration: beginChecking,
  91346. "FunctionDeclaration:exit": endChecking,
  91347. FunctionExpression: beginChecking,
  91348. "FunctionExpression:exit": endChecking,
  91349. // Increases the count of `yield` keyword.
  91350. YieldExpression: function YieldExpression() {
  91351. /* istanbul ignore else */
  91352. if (stack.length > 0) {
  91353. stack[stack.length - 1] += 1;
  91354. }
  91355. }
  91356. };
  91357. }
  91358. };
  91359. },{}],363:[function(require,module,exports){
  91360. /**
  91361. * @fileoverview Enforce spacing between rest and spread operators and their expressions.
  91362. * @author Kai Cataldo
  91363. */
  91364. "use strict";
  91365. //------------------------------------------------------------------------------
  91366. // Rule Definition
  91367. //------------------------------------------------------------------------------
  91368. module.exports = {
  91369. meta: {
  91370. type: "layout",
  91371. docs: {
  91372. description: "enforce spacing between rest and spread operators and their expressions",
  91373. category: "ECMAScript 6",
  91374. recommended: false,
  91375. url: "https://eslint.org/docs/rules/rest-spread-spacing"
  91376. },
  91377. fixable: "whitespace",
  91378. schema: [{
  91379. enum: ["always", "never"]
  91380. }]
  91381. },
  91382. create: function create(context) {
  91383. var sourceCode = context.getSourceCode(),
  91384. alwaysSpace = context.options[0] === "always";
  91385. //--------------------------------------------------------------------------
  91386. // Helpers
  91387. //--------------------------------------------------------------------------
  91388. /**
  91389. * Checks whitespace between rest/spread operators and their expressions
  91390. * @param {ASTNode} node - The node to check
  91391. * @returns {void}
  91392. */
  91393. function checkWhiteSpace(node) {
  91394. var operator = sourceCode.getFirstToken(node),
  91395. nextToken = sourceCode.getTokenAfter(operator),
  91396. hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken);
  91397. var type = void 0;
  91398. switch (node.type) {
  91399. case "SpreadElement":
  91400. type = "spread";
  91401. if (node.parent.type === "ObjectExpression") {
  91402. type += " property";
  91403. }
  91404. break;
  91405. case "RestElement":
  91406. type = "rest";
  91407. if (node.parent.type === "ObjectPattern") {
  91408. type += " property";
  91409. }
  91410. break;
  91411. case "ExperimentalSpreadProperty":
  91412. type = "spread property";
  91413. break;
  91414. case "ExperimentalRestProperty":
  91415. type = "rest property";
  91416. break;
  91417. default:
  91418. return;
  91419. }
  91420. if (alwaysSpace && !hasWhitespace) {
  91421. context.report({
  91422. node: node,
  91423. loc: {
  91424. line: operator.loc.end.line,
  91425. column: operator.loc.end.column
  91426. },
  91427. message: "Expected whitespace after {{type}} operator.",
  91428. data: {
  91429. type: type
  91430. },
  91431. fix: function fix(fixer) {
  91432. return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " ");
  91433. }
  91434. });
  91435. } else if (!alwaysSpace && hasWhitespace) {
  91436. context.report({
  91437. node: node,
  91438. loc: {
  91439. line: operator.loc.end.line,
  91440. column: operator.loc.end.column
  91441. },
  91442. message: "Unexpected whitespace after {{type}} operator.",
  91443. data: {
  91444. type: type
  91445. },
  91446. fix: function fix(fixer) {
  91447. return fixer.removeRange([operator.range[1], nextToken.range[0]]);
  91448. }
  91449. });
  91450. }
  91451. }
  91452. //--------------------------------------------------------------------------
  91453. // Public
  91454. //--------------------------------------------------------------------------
  91455. return {
  91456. SpreadElement: checkWhiteSpace,
  91457. RestElement: checkWhiteSpace,
  91458. ExperimentalSpreadProperty: checkWhiteSpace,
  91459. ExperimentalRestProperty: checkWhiteSpace
  91460. };
  91461. }
  91462. };
  91463. },{}],364:[function(require,module,exports){
  91464. /**
  91465. * @fileoverview Validates spacing before and after semicolon
  91466. * @author Mathias Schreck
  91467. */
  91468. "use strict";
  91469. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  91470. var astUtils = require("../util/ast-utils");
  91471. //------------------------------------------------------------------------------
  91472. // Rule Definition
  91473. //------------------------------------------------------------------------------
  91474. module.exports = {
  91475. meta: {
  91476. type: "layout",
  91477. docs: {
  91478. description: "enforce consistent spacing before and after semicolons",
  91479. category: "Stylistic Issues",
  91480. recommended: false,
  91481. url: "https://eslint.org/docs/rules/semi-spacing"
  91482. },
  91483. fixable: "whitespace",
  91484. schema: [{
  91485. type: "object",
  91486. properties: {
  91487. before: {
  91488. type: "boolean"
  91489. },
  91490. after: {
  91491. type: "boolean"
  91492. }
  91493. },
  91494. additionalProperties: false
  91495. }]
  91496. },
  91497. create: function create(context) {
  91498. var config = context.options[0],
  91499. sourceCode = context.getSourceCode();
  91500. var requireSpaceBefore = false,
  91501. requireSpaceAfter = true;
  91502. if ((typeof config === "undefined" ? "undefined" : _typeof(config)) === "object") {
  91503. if (Object.prototype.hasOwnProperty.call(config, "before")) {
  91504. requireSpaceBefore = config.before;
  91505. }
  91506. if (Object.prototype.hasOwnProperty.call(config, "after")) {
  91507. requireSpaceAfter = config.after;
  91508. }
  91509. }
  91510. /**
  91511. * Checks if a given token has leading whitespace.
  91512. * @param {Object} token The token to check.
  91513. * @returns {boolean} True if the given token has leading space, false if not.
  91514. */
  91515. function hasLeadingSpace(token) {
  91516. var tokenBefore = sourceCode.getTokenBefore(token);
  91517. return tokenBefore && astUtils.isTokenOnSameLine(tokenBefore, token) && sourceCode.isSpaceBetweenTokens(tokenBefore, token);
  91518. }
  91519. /**
  91520. * Checks if a given token has trailing whitespace.
  91521. * @param {Object} token The token to check.
  91522. * @returns {boolean} True if the given token has trailing space, false if not.
  91523. */
  91524. function hasTrailingSpace(token) {
  91525. var tokenAfter = sourceCode.getTokenAfter(token);
  91526. return tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter) && sourceCode.isSpaceBetweenTokens(token, tokenAfter);
  91527. }
  91528. /**
  91529. * Checks if the given token is the last token in its line.
  91530. * @param {Token} token The token to check.
  91531. * @returns {boolean} Whether or not the token is the last in its line.
  91532. */
  91533. function isLastTokenInCurrentLine(token) {
  91534. var tokenAfter = sourceCode.getTokenAfter(token);
  91535. return !(tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter));
  91536. }
  91537. /**
  91538. * Checks if the given token is the first token in its line
  91539. * @param {Token} token The token to check.
  91540. * @returns {boolean} Whether or not the token is the first in its line.
  91541. */
  91542. function isFirstTokenInCurrentLine(token) {
  91543. var tokenBefore = sourceCode.getTokenBefore(token);
  91544. return !(tokenBefore && astUtils.isTokenOnSameLine(token, tokenBefore));
  91545. }
  91546. /**
  91547. * Checks if the next token of a given token is a closing parenthesis.
  91548. * @param {Token} token The token to check.
  91549. * @returns {boolean} Whether or not the next token of a given token is a closing parenthesis.
  91550. */
  91551. function isBeforeClosingParen(token) {
  91552. var nextToken = sourceCode.getTokenAfter(token);
  91553. return nextToken && astUtils.isClosingBraceToken(nextToken) || astUtils.isClosingParenToken(nextToken);
  91554. }
  91555. /**
  91556. * Reports if the given token has invalid spacing.
  91557. * @param {Token} token The semicolon token to check.
  91558. * @param {ASTNode} node The corresponding node of the token.
  91559. * @returns {void}
  91560. */
  91561. function checkSemicolonSpacing(token, node) {
  91562. if (astUtils.isSemicolonToken(token)) {
  91563. var location = token.loc.start;
  91564. if (hasLeadingSpace(token)) {
  91565. if (!requireSpaceBefore) {
  91566. context.report({
  91567. node: node,
  91568. loc: location,
  91569. message: "Unexpected whitespace before semicolon.",
  91570. fix: function fix(fixer) {
  91571. var tokenBefore = sourceCode.getTokenBefore(token);
  91572. return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
  91573. }
  91574. });
  91575. }
  91576. } else {
  91577. if (requireSpaceBefore) {
  91578. context.report({
  91579. node: node,
  91580. loc: location,
  91581. message: "Missing whitespace before semicolon.",
  91582. fix: function fix(fixer) {
  91583. return fixer.insertTextBefore(token, " ");
  91584. }
  91585. });
  91586. }
  91587. }
  91588. if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) {
  91589. if (hasTrailingSpace(token)) {
  91590. if (!requireSpaceAfter) {
  91591. context.report({
  91592. node: node,
  91593. loc: location,
  91594. message: "Unexpected whitespace after semicolon.",
  91595. fix: function fix(fixer) {
  91596. var tokenAfter = sourceCode.getTokenAfter(token);
  91597. return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
  91598. }
  91599. });
  91600. }
  91601. } else {
  91602. if (requireSpaceAfter) {
  91603. context.report({
  91604. node: node,
  91605. loc: location,
  91606. message: "Missing whitespace after semicolon.",
  91607. fix: function fix(fixer) {
  91608. return fixer.insertTextAfter(token, " ");
  91609. }
  91610. });
  91611. }
  91612. }
  91613. }
  91614. }
  91615. }
  91616. /**
  91617. * Checks the spacing of the semicolon with the assumption that the last token is the semicolon.
  91618. * @param {ASTNode} node The node to check.
  91619. * @returns {void}
  91620. */
  91621. function checkNode(node) {
  91622. var token = sourceCode.getLastToken(node);
  91623. checkSemicolonSpacing(token, node);
  91624. }
  91625. return {
  91626. VariableDeclaration: checkNode,
  91627. ExpressionStatement: checkNode,
  91628. BreakStatement: checkNode,
  91629. ContinueStatement: checkNode,
  91630. DebuggerStatement: checkNode,
  91631. ReturnStatement: checkNode,
  91632. ThrowStatement: checkNode,
  91633. ImportDeclaration: checkNode,
  91634. ExportNamedDeclaration: checkNode,
  91635. ExportAllDeclaration: checkNode,
  91636. ExportDefaultDeclaration: checkNode,
  91637. ForStatement: function ForStatement(node) {
  91638. if (node.init) {
  91639. checkSemicolonSpacing(sourceCode.getTokenAfter(node.init), node);
  91640. }
  91641. if (node.test) {
  91642. checkSemicolonSpacing(sourceCode.getTokenAfter(node.test), node);
  91643. }
  91644. }
  91645. };
  91646. }
  91647. };
  91648. },{"../util/ast-utils":405}],365:[function(require,module,exports){
  91649. /**
  91650. * @fileoverview Rule to enforce location of semicolons.
  91651. * @author Toru Nagashima
  91652. */
  91653. "use strict";
  91654. //------------------------------------------------------------------------------
  91655. // Requirements
  91656. //------------------------------------------------------------------------------
  91657. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  91658. var astUtils = require("../util/ast-utils");
  91659. //------------------------------------------------------------------------------
  91660. // Rule Definition
  91661. //------------------------------------------------------------------------------
  91662. var SELECTOR = ":matches(" + ["BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "ExportAllDeclaration", "ExportDefaultDeclaration", "ExportNamedDeclaration", "ExpressionStatement", "ImportDeclaration", "ReturnStatement", "ThrowStatement", "VariableDeclaration"].join(",") + ")";
  91663. /**
  91664. * Get the child node list of a given node.
  91665. * This returns `Program#body`, `BlockStatement#body`, or `SwitchCase#consequent`.
  91666. * This is used to check whether a node is the first/last child.
  91667. * @param {Node} node A node to get child node list.
  91668. * @returns {Node[]|null} The child node list.
  91669. */
  91670. function getChildren(node) {
  91671. var t = node.type;
  91672. if (t === "BlockStatement" || t === "Program") {
  91673. return node.body;
  91674. }
  91675. if (t === "SwitchCase") {
  91676. return node.consequent;
  91677. }
  91678. return null;
  91679. }
  91680. /**
  91681. * Check whether a given node is the last statement in the parent block.
  91682. * @param {Node} node A node to check.
  91683. * @returns {boolean} `true` if the node is the last statement in the parent block.
  91684. */
  91685. function isLastChild(node) {
  91686. var t = node.parent.type;
  91687. if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) {
  91688. // before `else` keyword.
  91689. return true;
  91690. }
  91691. if (t === "DoWhileStatement") {
  91692. // before `while` keyword.
  91693. return true;
  91694. }
  91695. var nodeList = getChildren(node.parent);
  91696. return nodeList !== null && nodeList[nodeList.length - 1] === node; // before `}` or etc.
  91697. }
  91698. module.exports = {
  91699. meta: {
  91700. type: "layout",
  91701. docs: {
  91702. description: "enforce location of semicolons",
  91703. category: "Stylistic Issues",
  91704. recommended: false,
  91705. url: "https://eslint.org/docs/rules/semi-style"
  91706. },
  91707. schema: [{ enum: ["last", "first"] }],
  91708. fixable: "whitespace"
  91709. },
  91710. create: function create(context) {
  91711. var _ref;
  91712. var sourceCode = context.getSourceCode();
  91713. var option = context.options[0] || "last";
  91714. /**
  91715. * Check the given semicolon token.
  91716. * @param {Token} semiToken The semicolon token to check.
  91717. * @param {"first"|"last"} expected The expected location to check.
  91718. * @returns {void}
  91719. */
  91720. function check(semiToken, expected) {
  91721. var prevToken = sourceCode.getTokenBefore(semiToken);
  91722. var nextToken = sourceCode.getTokenAfter(semiToken);
  91723. var prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
  91724. var nextIsSameLine = !nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken);
  91725. if (expected === "last" && !prevIsSameLine || expected === "first" && !nextIsSameLine) {
  91726. context.report({
  91727. loc: semiToken.loc,
  91728. message: "Expected this semicolon to be at {{pos}}.",
  91729. data: {
  91730. pos: expected === "last" ? "the end of the previous line" : "the beginning of the next line"
  91731. },
  91732. fix: function fix(fixer) {
  91733. if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) {
  91734. return null;
  91735. }
  91736. var start = prevToken ? prevToken.range[1] : semiToken.range[0];
  91737. var end = nextToken ? nextToken.range[0] : semiToken.range[1];
  91738. var text = expected === "last" ? ";\n" : "\n;";
  91739. return fixer.replaceTextRange([start, end], text);
  91740. }
  91741. });
  91742. }
  91743. }
  91744. return _ref = {}, _defineProperty(_ref, SELECTOR, function (node) {
  91745. if (option === "first" && isLastChild(node)) {
  91746. return;
  91747. }
  91748. var lastToken = sourceCode.getLastToken(node);
  91749. if (astUtils.isSemicolonToken(lastToken)) {
  91750. check(lastToken, option);
  91751. }
  91752. }), _defineProperty(_ref, "ForStatement", function ForStatement(node) {
  91753. var firstSemi = node.init && sourceCode.getTokenAfter(node.init, astUtils.isSemicolonToken);
  91754. var secondSemi = node.test && sourceCode.getTokenAfter(node.test, astUtils.isSemicolonToken);
  91755. if (firstSemi) {
  91756. check(firstSemi, "last");
  91757. }
  91758. if (secondSemi) {
  91759. check(secondSemi, "last");
  91760. }
  91761. }), _ref;
  91762. }
  91763. };
  91764. },{"../util/ast-utils":405}],366:[function(require,module,exports){
  91765. /**
  91766. * @fileoverview Rule to flag missing semicolons.
  91767. * @author Nicholas C. Zakas
  91768. */
  91769. "use strict";
  91770. //------------------------------------------------------------------------------
  91771. // Requirements
  91772. //------------------------------------------------------------------------------
  91773. var FixTracker = require("../util/fix-tracker");
  91774. var astUtils = require("../util/ast-utils");
  91775. //------------------------------------------------------------------------------
  91776. // Rule Definition
  91777. //------------------------------------------------------------------------------
  91778. module.exports = {
  91779. meta: {
  91780. type: "layout",
  91781. docs: {
  91782. description: "require or disallow semicolons instead of ASI",
  91783. category: "Stylistic Issues",
  91784. recommended: false,
  91785. url: "https://eslint.org/docs/rules/semi"
  91786. },
  91787. fixable: "code",
  91788. schema: {
  91789. anyOf: [{
  91790. type: "array",
  91791. items: [{
  91792. enum: ["never"]
  91793. }, {
  91794. type: "object",
  91795. properties: {
  91796. beforeStatementContinuationChars: {
  91797. enum: ["always", "any", "never"]
  91798. }
  91799. },
  91800. additionalProperties: false
  91801. }],
  91802. minItems: 0,
  91803. maxItems: 2
  91804. }, {
  91805. type: "array",
  91806. items: [{
  91807. enum: ["always"]
  91808. }, {
  91809. type: "object",
  91810. properties: {
  91811. omitLastInOneLineBlock: { type: "boolean" }
  91812. },
  91813. additionalProperties: false
  91814. }],
  91815. minItems: 0,
  91816. maxItems: 2
  91817. }]
  91818. }
  91819. },
  91820. create: function create(context) {
  91821. var OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-`
  91822. var options = context.options[1];
  91823. var never = context.options[0] === "never";
  91824. var exceptOneLine = Boolean(options && options.omitLastInOneLineBlock);
  91825. var beforeStatementContinuationChars = options && options.beforeStatementContinuationChars || "any";
  91826. var sourceCode = context.getSourceCode();
  91827. //--------------------------------------------------------------------------
  91828. // Helpers
  91829. //--------------------------------------------------------------------------
  91830. /**
  91831. * Reports a semicolon error with appropriate location and message.
  91832. * @param {ASTNode} node The node with an extra or missing semicolon.
  91833. * @param {boolean} missing True if the semicolon is missing.
  91834. * @returns {void}
  91835. */
  91836. function report(node, missing) {
  91837. var lastToken = sourceCode.getLastToken(node);
  91838. var message = void 0,
  91839. fix = void 0,
  91840. loc = lastToken.loc;
  91841. if (!missing) {
  91842. message = "Missing semicolon.";
  91843. loc = loc.end;
  91844. fix = function fix(fixer) {
  91845. return fixer.insertTextAfter(lastToken, ";");
  91846. };
  91847. } else {
  91848. message = "Extra semicolon.";
  91849. loc = loc.start;
  91850. fix = function fix(fixer) {
  91851. /*
  91852. * Expand the replacement range to include the surrounding
  91853. * tokens to avoid conflicting with no-extra-semi.
  91854. * https://github.com/eslint/eslint/issues/7928
  91855. */
  91856. return new FixTracker(fixer, sourceCode).retainSurroundingTokens(lastToken).remove(lastToken);
  91857. };
  91858. }
  91859. context.report({
  91860. node: node,
  91861. loc: loc,
  91862. message: message,
  91863. fix: fix
  91864. });
  91865. }
  91866. /**
  91867. * Check whether a given semicolon token is redandant.
  91868. * @param {Token} semiToken A semicolon token to check.
  91869. * @returns {boolean} `true` if the next token is `;` or `}`.
  91870. */
  91871. function isRedundantSemi(semiToken) {
  91872. var nextToken = sourceCode.getTokenAfter(semiToken);
  91873. return !nextToken || astUtils.isClosingBraceToken(nextToken) || astUtils.isSemicolonToken(nextToken);
  91874. }
  91875. /**
  91876. * Check whether a given token is the closing brace of an arrow function.
  91877. * @param {Token} lastToken A token to check.
  91878. * @returns {boolean} `true` if the token is the closing brace of an arrow function.
  91879. */
  91880. function isEndOfArrowBlock(lastToken) {
  91881. if (!astUtils.isClosingBraceToken(lastToken)) {
  91882. return false;
  91883. }
  91884. var node = sourceCode.getNodeByRangeIndex(lastToken.range[0]);
  91885. return node.type === "BlockStatement" && node.parent.type === "ArrowFunctionExpression";
  91886. }
  91887. /**
  91888. * Check whether a given node is on the same line with the next token.
  91889. * @param {Node} node A statement node to check.
  91890. * @returns {boolean} `true` if the node is on the same line with the next token.
  91891. */
  91892. function isOnSameLineWithNextToken(node) {
  91893. var prevToken = sourceCode.getLastToken(node, 1);
  91894. var nextToken = sourceCode.getTokenAfter(node);
  91895. return !!nextToken && astUtils.isTokenOnSameLine(prevToken, nextToken);
  91896. }
  91897. /**
  91898. * Check whether a given node can connect the next line if the next line is unreliable.
  91899. * @param {Node} node A statement node to check.
  91900. * @returns {boolean} `true` if the node can connect the next line.
  91901. */
  91902. function maybeAsiHazardAfter(node) {
  91903. var t = node.type;
  91904. if (t === "DoWhileStatement" || t === "BreakStatement" || t === "ContinueStatement" || t === "DebuggerStatement" || t === "ImportDeclaration" || t === "ExportAllDeclaration") {
  91905. return false;
  91906. }
  91907. if (t === "ReturnStatement") {
  91908. return Boolean(node.argument);
  91909. }
  91910. if (t === "ExportNamedDeclaration") {
  91911. return Boolean(node.declaration);
  91912. }
  91913. if (isEndOfArrowBlock(sourceCode.getLastToken(node, 1))) {
  91914. return false;
  91915. }
  91916. return true;
  91917. }
  91918. /**
  91919. * Check whether a given token can connect the previous statement.
  91920. * @param {Token} token A token to check.
  91921. * @returns {boolean} `true` if the token is one of `[`, `(`, `/`, `+`, `-`, ```, `++`, and `--`.
  91922. */
  91923. function maybeAsiHazardBefore(token) {
  91924. return Boolean(token) && OPT_OUT_PATTERN.test(token.value) && token.value !== "++" && token.value !== "--";
  91925. }
  91926. /**
  91927. * Check if the semicolon of a given node is unnecessary, only true if:
  91928. * - next token is a valid statement divider (`;` or `}`).
  91929. * - next token is on a new line and the node is not connectable to the new line.
  91930. * @param {Node} node A statement node to check.
  91931. * @returns {boolean} whether the semicolon is unnecessary.
  91932. */
  91933. function canRemoveSemicolon(node) {
  91934. if (isRedundantSemi(sourceCode.getLastToken(node))) {
  91935. return true; // `;;` or `;}`
  91936. }
  91937. if (isOnSameLineWithNextToken(node)) {
  91938. return false; // One liner.
  91939. }
  91940. if (beforeStatementContinuationChars === "never" && !maybeAsiHazardAfter(node)) {
  91941. return true; // ASI works. This statement doesn't connect to the next.
  91942. }
  91943. if (!maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
  91944. return true; // ASI works. The next token doesn't connect to this statement.
  91945. }
  91946. return false;
  91947. }
  91948. /**
  91949. * Checks a node to see if it's in a one-liner block statement.
  91950. * @param {ASTNode} node The node to check.
  91951. * @returns {boolean} whether the node is in a one-liner block statement.
  91952. */
  91953. function isOneLinerBlock(node) {
  91954. var parent = node.parent;
  91955. var nextToken = sourceCode.getTokenAfter(node);
  91956. if (!nextToken || nextToken.value !== "}") {
  91957. return false;
  91958. }
  91959. return !!parent && parent.type === "BlockStatement" && parent.loc.start.line === parent.loc.end.line;
  91960. }
  91961. /**
  91962. * Checks a node to see if it's followed by a semicolon.
  91963. * @param {ASTNode} node The node to check.
  91964. * @returns {void}
  91965. */
  91966. function checkForSemicolon(node) {
  91967. var isSemi = astUtils.isSemicolonToken(sourceCode.getLastToken(node));
  91968. if (never) {
  91969. if (isSemi && canRemoveSemicolon(node)) {
  91970. report(node, true);
  91971. } else if (!isSemi && beforeStatementContinuationChars === "always" && maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
  91972. report(node);
  91973. }
  91974. } else {
  91975. var oneLinerBlock = exceptOneLine && isOneLinerBlock(node);
  91976. if (isSemi && oneLinerBlock) {
  91977. report(node, true);
  91978. } else if (!isSemi && !oneLinerBlock) {
  91979. report(node);
  91980. }
  91981. }
  91982. }
  91983. /**
  91984. * Checks to see if there's a semicolon after a variable declaration.
  91985. * @param {ASTNode} node The node to check.
  91986. * @returns {void}
  91987. */
  91988. function checkForSemicolonForVariableDeclaration(node) {
  91989. var parent = node.parent;
  91990. if ((parent.type !== "ForStatement" || parent.init !== node) && (!/^For(?:In|Of)Statement/.test(parent.type) || parent.left !== node)) {
  91991. checkForSemicolon(node);
  91992. }
  91993. }
  91994. //--------------------------------------------------------------------------
  91995. // Public API
  91996. //--------------------------------------------------------------------------
  91997. return {
  91998. VariableDeclaration: checkForSemicolonForVariableDeclaration,
  91999. ExpressionStatement: checkForSemicolon,
  92000. ReturnStatement: checkForSemicolon,
  92001. ThrowStatement: checkForSemicolon,
  92002. DoWhileStatement: checkForSemicolon,
  92003. DebuggerStatement: checkForSemicolon,
  92004. BreakStatement: checkForSemicolon,
  92005. ContinueStatement: checkForSemicolon,
  92006. ImportDeclaration: checkForSemicolon,
  92007. ExportAllDeclaration: checkForSemicolon,
  92008. ExportNamedDeclaration: function ExportNamedDeclaration(node) {
  92009. if (!node.declaration) {
  92010. checkForSemicolon(node);
  92011. }
  92012. },
  92013. ExportDefaultDeclaration: function ExportDefaultDeclaration(node) {
  92014. if (!/(?:Class|Function)Declaration/.test(node.declaration.type)) {
  92015. checkForSemicolon(node);
  92016. }
  92017. }
  92018. };
  92019. }
  92020. };
  92021. },{"../util/ast-utils":405,"../util/fix-tracker":407}],367:[function(require,module,exports){
  92022. /**
  92023. * @fileoverview Rule to require sorting of import declarations
  92024. * @author Christian Schuller
  92025. */
  92026. "use strict";
  92027. //------------------------------------------------------------------------------
  92028. // Rule Definition
  92029. //------------------------------------------------------------------------------
  92030. module.exports = {
  92031. meta: {
  92032. type: "suggestion",
  92033. docs: {
  92034. description: "enforce sorted import declarations within modules",
  92035. category: "ECMAScript 6",
  92036. recommended: false,
  92037. url: "https://eslint.org/docs/rules/sort-imports"
  92038. },
  92039. schema: [{
  92040. type: "object",
  92041. properties: {
  92042. ignoreCase: {
  92043. type: "boolean"
  92044. },
  92045. memberSyntaxSortOrder: {
  92046. type: "array",
  92047. items: {
  92048. enum: ["none", "all", "multiple", "single"]
  92049. },
  92050. uniqueItems: true,
  92051. minItems: 4,
  92052. maxItems: 4
  92053. },
  92054. ignoreMemberSort: {
  92055. type: "boolean"
  92056. }
  92057. },
  92058. additionalProperties: false
  92059. }],
  92060. fixable: "code"
  92061. },
  92062. create: function create(context) {
  92063. var configuration = context.options[0] || {},
  92064. ignoreCase = configuration.ignoreCase || false,
  92065. ignoreMemberSort = configuration.ignoreMemberSort || false,
  92066. memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"],
  92067. sourceCode = context.getSourceCode();
  92068. var previousDeclaration = null;
  92069. /**
  92070. * Gets the used member syntax style.
  92071. *
  92072. * import "my-module.js" --> none
  92073. * import * as myModule from "my-module.js" --> all
  92074. * import {myMember} from "my-module.js" --> single
  92075. * import {foo, bar} from "my-module.js" --> multiple
  92076. *
  92077. * @param {ASTNode} node - the ImportDeclaration node.
  92078. * @returns {string} used member parameter style, ["all", "multiple", "single"]
  92079. */
  92080. function usedMemberSyntax(node) {
  92081. if (node.specifiers.length === 0) {
  92082. return "none";
  92083. }
  92084. if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
  92085. return "all";
  92086. }
  92087. if (node.specifiers.length === 1) {
  92088. return "single";
  92089. }
  92090. return "multiple";
  92091. }
  92092. /**
  92093. * Gets the group by member parameter index for given declaration.
  92094. * @param {ASTNode} node - the ImportDeclaration node.
  92095. * @returns {number} the declaration group by member index.
  92096. */
  92097. function getMemberParameterGroupIndex(node) {
  92098. return memberSyntaxSortOrder.indexOf(usedMemberSyntax(node));
  92099. }
  92100. /**
  92101. * Gets the local name of the first imported module.
  92102. * @param {ASTNode} node - the ImportDeclaration node.
  92103. * @returns {?string} the local name of the first imported module.
  92104. */
  92105. function getFirstLocalMemberName(node) {
  92106. if (node.specifiers[0]) {
  92107. return node.specifiers[0].local.name;
  92108. }
  92109. return null;
  92110. }
  92111. return {
  92112. ImportDeclaration: function ImportDeclaration(node) {
  92113. if (previousDeclaration) {
  92114. var currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node),
  92115. previousMemberSyntaxGroupIndex = getMemberParameterGroupIndex(previousDeclaration);
  92116. var currentLocalMemberName = getFirstLocalMemberName(node),
  92117. previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
  92118. if (ignoreCase) {
  92119. previousLocalMemberName = previousLocalMemberName && previousLocalMemberName.toLowerCase();
  92120. currentLocalMemberName = currentLocalMemberName && currentLocalMemberName.toLowerCase();
  92121. }
  92122. /*
  92123. * When the current declaration uses a different member syntax,
  92124. * then check if the ordering is correct.
  92125. * Otherwise, make a default string compare (like rule sort-vars to be consistent) of the first used local member name.
  92126. */
  92127. if (currentMemberSyntaxGroupIndex !== previousMemberSyntaxGroupIndex) {
  92128. if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) {
  92129. context.report({
  92130. node: node,
  92131. message: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax.",
  92132. data: {
  92133. syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex],
  92134. syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex]
  92135. }
  92136. });
  92137. }
  92138. } else {
  92139. if (previousLocalMemberName && currentLocalMemberName && currentLocalMemberName < previousLocalMemberName) {
  92140. context.report({
  92141. node: node,
  92142. message: "Imports should be sorted alphabetically."
  92143. });
  92144. }
  92145. }
  92146. }
  92147. if (!ignoreMemberSort) {
  92148. var importSpecifiers = node.specifiers.filter(function (specifier) {
  92149. return specifier.type === "ImportSpecifier";
  92150. });
  92151. var getSortableName = ignoreCase ? function (specifier) {
  92152. return specifier.local.name.toLowerCase();
  92153. } : function (specifier) {
  92154. return specifier.local.name;
  92155. };
  92156. var firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex(function (name, index, array) {
  92157. return array[index - 1] > name;
  92158. });
  92159. if (firstUnsortedIndex !== -1) {
  92160. context.report({
  92161. node: importSpecifiers[firstUnsortedIndex],
  92162. message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.",
  92163. data: { memberName: importSpecifiers[firstUnsortedIndex].local.name },
  92164. fix: function fix(fixer) {
  92165. if (importSpecifiers.some(function (specifier) {
  92166. return sourceCode.getCommentsBefore(specifier).length || sourceCode.getCommentsAfter(specifier).length;
  92167. })) {
  92168. // If there are comments in the ImportSpecifier list, don't rearrange the specifiers.
  92169. return null;
  92170. }
  92171. return fixer.replaceTextRange([importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]], importSpecifiers
  92172. // Clone the importSpecifiers array to avoid mutating it
  92173. .slice()
  92174. // Sort the array into the desired order
  92175. .sort(function (specifierA, specifierB) {
  92176. var aName = getSortableName(specifierA);
  92177. var bName = getSortableName(specifierB);
  92178. return aName > bName ? 1 : -1;
  92179. })
  92180. // Build a string out of the sorted list of import specifiers and the text between the originals
  92181. .reduce(function (sourceText, specifier, index) {
  92182. var textAfterSpecifier = index === importSpecifiers.length - 1 ? "" : sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]);
  92183. return sourceText + sourceCode.getText(specifier) + textAfterSpecifier;
  92184. }, ""));
  92185. }
  92186. });
  92187. }
  92188. }
  92189. previousDeclaration = node;
  92190. }
  92191. };
  92192. }
  92193. };
  92194. },{}],368:[function(require,module,exports){
  92195. /**
  92196. * @fileoverview Rule to require object keys to be sorted
  92197. * @author Toru Nagashima
  92198. */
  92199. "use strict";
  92200. //------------------------------------------------------------------------------
  92201. // Requirements
  92202. //------------------------------------------------------------------------------
  92203. var astUtils = require("../util/ast-utils"),
  92204. naturalCompare = require("natural-compare");
  92205. //------------------------------------------------------------------------------
  92206. // Helpers
  92207. //------------------------------------------------------------------------------
  92208. /**
  92209. * Gets the property name of the given `Property` node.
  92210. *
  92211. * - If the property's key is an `Identifier` node, this returns the key's name
  92212. * whether it's a computed property or not.
  92213. * - If the property has a static name, this returns the static name.
  92214. * - Otherwise, this returns null.
  92215. *
  92216. * @param {ASTNode} node - The `Property` node to get.
  92217. * @returns {string|null} The property name or null.
  92218. * @private
  92219. */
  92220. function getPropertyName(node) {
  92221. return astUtils.getStaticPropertyName(node) || node.key.name || null;
  92222. }
  92223. /**
  92224. * Functions which check that the given 2 names are in specific order.
  92225. *
  92226. * Postfix `I` is meant insensitive.
  92227. * Postfix `N` is meant natual.
  92228. *
  92229. * @private
  92230. */
  92231. var isValidOrders = {
  92232. asc: function asc(a, b) {
  92233. return a <= b;
  92234. },
  92235. ascI: function ascI(a, b) {
  92236. return a.toLowerCase() <= b.toLowerCase();
  92237. },
  92238. ascN: function ascN(a, b) {
  92239. return naturalCompare(a, b) <= 0;
  92240. },
  92241. ascIN: function ascIN(a, b) {
  92242. return naturalCompare(a.toLowerCase(), b.toLowerCase()) <= 0;
  92243. },
  92244. desc: function desc(a, b) {
  92245. return isValidOrders.asc(b, a);
  92246. },
  92247. descI: function descI(a, b) {
  92248. return isValidOrders.ascI(b, a);
  92249. },
  92250. descN: function descN(a, b) {
  92251. return isValidOrders.ascN(b, a);
  92252. },
  92253. descIN: function descIN(a, b) {
  92254. return isValidOrders.ascIN(b, a);
  92255. }
  92256. };
  92257. //------------------------------------------------------------------------------
  92258. // Rule Definition
  92259. //------------------------------------------------------------------------------
  92260. module.exports = {
  92261. meta: {
  92262. type: "suggestion",
  92263. docs: {
  92264. description: "require object keys to be sorted",
  92265. category: "Stylistic Issues",
  92266. recommended: false,
  92267. url: "https://eslint.org/docs/rules/sort-keys"
  92268. },
  92269. schema: [{
  92270. enum: ["asc", "desc"]
  92271. }, {
  92272. type: "object",
  92273. properties: {
  92274. caseSensitive: {
  92275. type: "boolean"
  92276. },
  92277. natural: {
  92278. type: "boolean"
  92279. }
  92280. },
  92281. additionalProperties: false
  92282. }]
  92283. },
  92284. create: function create(context) {
  92285. // Parse options.
  92286. var order = context.options[0] || "asc";
  92287. var options = context.options[1];
  92288. var insensitive = (options && options.caseSensitive) === false;
  92289. var natual = Boolean(options && options.natural);
  92290. var isValidOrder = isValidOrders[order + (insensitive ? "I" : "") + (natual ? "N" : "")];
  92291. // The stack to save the previous property's name for each object literals.
  92292. var stack = null;
  92293. return {
  92294. ObjectExpression: function ObjectExpression() {
  92295. stack = {
  92296. upper: stack,
  92297. prevName: null
  92298. };
  92299. },
  92300. "ObjectExpression:exit": function ObjectExpressionExit() {
  92301. stack = stack.upper;
  92302. },
  92303. Property: function Property(node) {
  92304. if (node.parent.type === "ObjectPattern" || node.parent.properties.some(function (n) {
  92305. return n.type === "SpreadElement";
  92306. })) {
  92307. return;
  92308. }
  92309. var prevName = stack.prevName;
  92310. var thisName = getPropertyName(node);
  92311. stack.prevName = thisName || prevName;
  92312. if (!prevName || !thisName) {
  92313. return;
  92314. }
  92315. if (!isValidOrder(prevName, thisName)) {
  92316. context.report({
  92317. node: node,
  92318. loc: node.key.loc,
  92319. message: "Expected object keys to be in {{natual}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'.",
  92320. data: {
  92321. thisName: thisName,
  92322. prevName: prevName,
  92323. order: order,
  92324. insensitive: insensitive ? "insensitive " : "",
  92325. natual: natual ? "natural " : ""
  92326. }
  92327. });
  92328. }
  92329. }
  92330. };
  92331. }
  92332. };
  92333. },{"../util/ast-utils":405,"natural-compare":95}],369:[function(require,module,exports){
  92334. /**
  92335. * @fileoverview Rule to require sorting of variables within a single Variable Declaration block
  92336. * @author Ilya Volodin
  92337. */
  92338. "use strict";
  92339. //------------------------------------------------------------------------------
  92340. // Rule Definition
  92341. //------------------------------------------------------------------------------
  92342. module.exports = {
  92343. meta: {
  92344. type: "suggestion",
  92345. docs: {
  92346. description: "require variables within the same declaration block to be sorted",
  92347. category: "Stylistic Issues",
  92348. recommended: false,
  92349. url: "https://eslint.org/docs/rules/sort-vars"
  92350. },
  92351. schema: [{
  92352. type: "object",
  92353. properties: {
  92354. ignoreCase: {
  92355. type: "boolean"
  92356. }
  92357. },
  92358. additionalProperties: false
  92359. }],
  92360. fixable: "code"
  92361. },
  92362. create: function create(context) {
  92363. var configuration = context.options[0] || {},
  92364. ignoreCase = configuration.ignoreCase || false,
  92365. sourceCode = context.getSourceCode();
  92366. return {
  92367. VariableDeclaration: function VariableDeclaration(node) {
  92368. var idDeclarations = node.declarations.filter(function (decl) {
  92369. return decl.id.type === "Identifier";
  92370. });
  92371. var getSortableName = ignoreCase ? function (decl) {
  92372. return decl.id.name.toLowerCase();
  92373. } : function (decl) {
  92374. return decl.id.name;
  92375. };
  92376. var unfixable = idDeclarations.some(function (decl) {
  92377. return decl.init !== null && decl.init.type !== "Literal";
  92378. });
  92379. var fixed = false;
  92380. idDeclarations.slice(1).reduce(function (memo, decl) {
  92381. var lastVariableName = getSortableName(memo),
  92382. currentVariableName = getSortableName(decl);
  92383. if (currentVariableName < lastVariableName) {
  92384. context.report({
  92385. node: decl,
  92386. message: "Variables within the same declaration block should be sorted alphabetically.",
  92387. fix: function fix(fixer) {
  92388. if (unfixable || fixed) {
  92389. return null;
  92390. }
  92391. return fixer.replaceTextRange([idDeclarations[0].range[0], idDeclarations[idDeclarations.length - 1].range[1]], idDeclarations
  92392. // Clone the idDeclarations array to avoid mutating it
  92393. .slice()
  92394. // Sort the array into the desired order
  92395. .sort(function (declA, declB) {
  92396. var aName = getSortableName(declA);
  92397. var bName = getSortableName(declB);
  92398. return aName > bName ? 1 : -1;
  92399. })
  92400. // Build a string out of the sorted list of identifier declarations and the text between the originals
  92401. .reduce(function (sourceText, identifier, index) {
  92402. var textAfterIdentifier = index === idDeclarations.length - 1 ? "" : sourceCode.getText().slice(idDeclarations[index].range[1], idDeclarations[index + 1].range[0]);
  92403. return sourceText + sourceCode.getText(identifier) + textAfterIdentifier;
  92404. }, ""));
  92405. }
  92406. });
  92407. fixed = true;
  92408. return memo;
  92409. }
  92410. return decl;
  92411. }, idDeclarations[0]);
  92412. }
  92413. };
  92414. }
  92415. };
  92416. },{}],370:[function(require,module,exports){
  92417. /**
  92418. * @fileoverview A rule to ensure whitespace before blocks.
  92419. * @author Mathias Schreck <https://github.com/lo1tuma>
  92420. */
  92421. "use strict";
  92422. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  92423. var astUtils = require("../util/ast-utils");
  92424. //------------------------------------------------------------------------------
  92425. // Rule Definition
  92426. //------------------------------------------------------------------------------
  92427. module.exports = {
  92428. meta: {
  92429. type: "layout",
  92430. docs: {
  92431. description: "enforce consistent spacing before blocks",
  92432. category: "Stylistic Issues",
  92433. recommended: false,
  92434. url: "https://eslint.org/docs/rules/space-before-blocks"
  92435. },
  92436. fixable: "whitespace",
  92437. schema: [{
  92438. oneOf: [{
  92439. enum: ["always", "never"]
  92440. }, {
  92441. type: "object",
  92442. properties: {
  92443. keywords: {
  92444. enum: ["always", "never", "off"]
  92445. },
  92446. functions: {
  92447. enum: ["always", "never", "off"]
  92448. },
  92449. classes: {
  92450. enum: ["always", "never", "off"]
  92451. }
  92452. },
  92453. additionalProperties: false
  92454. }]
  92455. }]
  92456. },
  92457. create: function create(context) {
  92458. var config = context.options[0],
  92459. sourceCode = context.getSourceCode();
  92460. var alwaysFunctions = true,
  92461. alwaysKeywords = true,
  92462. alwaysClasses = true,
  92463. neverFunctions = false,
  92464. neverKeywords = false,
  92465. neverClasses = false;
  92466. if ((typeof config === "undefined" ? "undefined" : _typeof(config)) === "object") {
  92467. alwaysFunctions = config.functions === "always";
  92468. alwaysKeywords = config.keywords === "always";
  92469. alwaysClasses = config.classes === "always";
  92470. neverFunctions = config.functions === "never";
  92471. neverKeywords = config.keywords === "never";
  92472. neverClasses = config.classes === "never";
  92473. } else if (config === "never") {
  92474. alwaysFunctions = false;
  92475. alwaysKeywords = false;
  92476. alwaysClasses = false;
  92477. neverFunctions = true;
  92478. neverKeywords = true;
  92479. neverClasses = true;
  92480. }
  92481. /**
  92482. * Checks whether or not a given token is an arrow operator (=>) or a keyword
  92483. * in order to avoid to conflict with `arrow-spacing` and `keyword-spacing`.
  92484. *
  92485. * @param {Token} token - A token to check.
  92486. * @returns {boolean} `true` if the token is an arrow operator.
  92487. */
  92488. function isConflicted(token) {
  92489. return token.type === "Punctuator" && token.value === "=>" || token.type === "Keyword";
  92490. }
  92491. /**
  92492. * Checks the given BlockStatement node has a preceding space if it doesn’t start on a new line.
  92493. * @param {ASTNode|Token} node The AST node of a BlockStatement.
  92494. * @returns {void} undefined.
  92495. */
  92496. function checkPrecedingSpace(node) {
  92497. var precedingToken = sourceCode.getTokenBefore(node);
  92498. if (precedingToken && !isConflicted(precedingToken) && astUtils.isTokenOnSameLine(precedingToken, node)) {
  92499. var hasSpace = sourceCode.isSpaceBetweenTokens(precedingToken, node);
  92500. var parent = context.getAncestors().pop();
  92501. var requireSpace = void 0;
  92502. var requireNoSpace = void 0;
  92503. if (parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration") {
  92504. requireSpace = alwaysFunctions;
  92505. requireNoSpace = neverFunctions;
  92506. } else if (node.type === "ClassBody") {
  92507. requireSpace = alwaysClasses;
  92508. requireNoSpace = neverClasses;
  92509. } else {
  92510. requireSpace = alwaysKeywords;
  92511. requireNoSpace = neverKeywords;
  92512. }
  92513. if (requireSpace && !hasSpace) {
  92514. context.report({
  92515. node: node,
  92516. message: "Missing space before opening brace.",
  92517. fix: function fix(fixer) {
  92518. return fixer.insertTextBefore(node, " ");
  92519. }
  92520. });
  92521. } else if (requireNoSpace && hasSpace) {
  92522. context.report({
  92523. node: node,
  92524. message: "Unexpected space before opening brace.",
  92525. fix: function fix(fixer) {
  92526. return fixer.removeRange([precedingToken.range[1], node.range[0]]);
  92527. }
  92528. });
  92529. }
  92530. }
  92531. }
  92532. /**
  92533. * Checks if the CaseBlock of an given SwitchStatement node has a preceding space.
  92534. * @param {ASTNode} node The node of a SwitchStatement.
  92535. * @returns {void} undefined.
  92536. */
  92537. function checkSpaceBeforeCaseBlock(node) {
  92538. var cases = node.cases;
  92539. var openingBrace = void 0;
  92540. if (cases.length > 0) {
  92541. openingBrace = sourceCode.getTokenBefore(cases[0]);
  92542. } else {
  92543. openingBrace = sourceCode.getLastToken(node, 1);
  92544. }
  92545. checkPrecedingSpace(openingBrace);
  92546. }
  92547. return {
  92548. BlockStatement: checkPrecedingSpace,
  92549. ClassBody: checkPrecedingSpace,
  92550. SwitchStatement: checkSpaceBeforeCaseBlock
  92551. };
  92552. }
  92553. };
  92554. },{"../util/ast-utils":405}],371:[function(require,module,exports){
  92555. /**
  92556. * @fileoverview Rule to validate spacing before function paren.
  92557. * @author Mathias Schreck <https://github.com/lo1tuma>
  92558. */
  92559. "use strict";
  92560. //------------------------------------------------------------------------------
  92561. // Requirements
  92562. //------------------------------------------------------------------------------
  92563. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  92564. var astUtils = require("../util/ast-utils");
  92565. //------------------------------------------------------------------------------
  92566. // Rule Definition
  92567. //------------------------------------------------------------------------------
  92568. module.exports = {
  92569. meta: {
  92570. type: "layout",
  92571. docs: {
  92572. description: "enforce consistent spacing before `function` definition opening parenthesis",
  92573. category: "Stylistic Issues",
  92574. recommended: false,
  92575. url: "https://eslint.org/docs/rules/space-before-function-paren"
  92576. },
  92577. fixable: "whitespace",
  92578. schema: [{
  92579. oneOf: [{
  92580. enum: ["always", "never"]
  92581. }, {
  92582. type: "object",
  92583. properties: {
  92584. anonymous: {
  92585. enum: ["always", "never", "ignore"]
  92586. },
  92587. named: {
  92588. enum: ["always", "never", "ignore"]
  92589. },
  92590. asyncArrow: {
  92591. enum: ["always", "never", "ignore"]
  92592. }
  92593. },
  92594. additionalProperties: false
  92595. }]
  92596. }]
  92597. },
  92598. create: function create(context) {
  92599. var sourceCode = context.getSourceCode();
  92600. var baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always";
  92601. var overrideConfig = _typeof(context.options[0]) === "object" ? context.options[0] : {};
  92602. /**
  92603. * Determines whether a function has a name.
  92604. * @param {ASTNode} node The function node.
  92605. * @returns {boolean} Whether the function has a name.
  92606. */
  92607. function isNamedFunction(node) {
  92608. if (node.id) {
  92609. return true;
  92610. }
  92611. var parent = node.parent;
  92612. return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.kind === "get" || parent.kind === "set" || parent.method);
  92613. }
  92614. /**
  92615. * Gets the config for a given function
  92616. * @param {ASTNode} node The function node
  92617. * @returns {string} "always", "never", or "ignore"
  92618. */
  92619. function getConfigForFunction(node) {
  92620. if (node.type === "ArrowFunctionExpression") {
  92621. // Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar
  92622. if (node.async && astUtils.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) {
  92623. return overrideConfig.asyncArrow || baseConfig;
  92624. }
  92625. } else if (isNamedFunction(node)) {
  92626. return overrideConfig.named || baseConfig;
  92627. // `generator-star-spacing` should warn anonymous generators. E.g. `function* () {}`
  92628. } else if (!node.generator) {
  92629. return overrideConfig.anonymous || baseConfig;
  92630. }
  92631. return "ignore";
  92632. }
  92633. /**
  92634. * Checks the parens of a function node
  92635. * @param {ASTNode} node A function node
  92636. * @returns {void}
  92637. */
  92638. function checkFunction(node) {
  92639. var functionConfig = getConfigForFunction(node);
  92640. if (functionConfig === "ignore") {
  92641. return;
  92642. }
  92643. var rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
  92644. var leftToken = sourceCode.getTokenBefore(rightToken);
  92645. var hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken);
  92646. if (hasSpacing && functionConfig === "never") {
  92647. context.report({
  92648. node: node,
  92649. loc: leftToken.loc.end,
  92650. message: "Unexpected space before function parentheses.",
  92651. fix: function fix(fixer) {
  92652. return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
  92653. }
  92654. });
  92655. } else if (!hasSpacing && functionConfig === "always") {
  92656. context.report({
  92657. node: node,
  92658. loc: leftToken.loc.end,
  92659. message: "Missing space before function parentheses.",
  92660. fix: function fix(fixer) {
  92661. return fixer.insertTextAfter(leftToken, " ");
  92662. }
  92663. });
  92664. }
  92665. }
  92666. return {
  92667. ArrowFunctionExpression: checkFunction,
  92668. FunctionDeclaration: checkFunction,
  92669. FunctionExpression: checkFunction
  92670. };
  92671. }
  92672. };
  92673. },{"../util/ast-utils":405}],372:[function(require,module,exports){
  92674. /**
  92675. * @fileoverview Disallows or enforces spaces inside of parentheses.
  92676. * @author Jonathan Rajavuori
  92677. */
  92678. "use strict";
  92679. var astUtils = require("../util/ast-utils");
  92680. //------------------------------------------------------------------------------
  92681. // Rule Definition
  92682. //------------------------------------------------------------------------------
  92683. module.exports = {
  92684. meta: {
  92685. type: "layout",
  92686. docs: {
  92687. description: "enforce consistent spacing inside parentheses",
  92688. category: "Stylistic Issues",
  92689. recommended: false,
  92690. url: "https://eslint.org/docs/rules/space-in-parens"
  92691. },
  92692. fixable: "whitespace",
  92693. schema: [{
  92694. enum: ["always", "never"]
  92695. }, {
  92696. type: "object",
  92697. properties: {
  92698. exceptions: {
  92699. type: "array",
  92700. items: {
  92701. enum: ["{}", "[]", "()", "empty"]
  92702. },
  92703. uniqueItems: true
  92704. }
  92705. },
  92706. additionalProperties: false
  92707. }]
  92708. },
  92709. create: function create(context) {
  92710. var MISSING_SPACE_MESSAGE = "There must be a space inside this paren.",
  92711. REJECTED_SPACE_MESSAGE = "There should be no spaces inside this paren.",
  92712. ALWAYS = context.options[0] === "always",
  92713. exceptionsArrayOptions = context.options[1] && context.options[1].exceptions || [],
  92714. options = {};
  92715. var exceptions = void 0;
  92716. if (exceptionsArrayOptions.length) {
  92717. options.braceException = exceptionsArrayOptions.indexOf("{}") !== -1;
  92718. options.bracketException = exceptionsArrayOptions.indexOf("[]") !== -1;
  92719. options.parenException = exceptionsArrayOptions.indexOf("()") !== -1;
  92720. options.empty = exceptionsArrayOptions.indexOf("empty") !== -1;
  92721. }
  92722. /**
  92723. * Produces an object with the opener and closer exception values
  92724. * @returns {Object} `openers` and `closers` exception values
  92725. * @private
  92726. */
  92727. function getExceptions() {
  92728. var openers = [],
  92729. closers = [];
  92730. if (options.braceException) {
  92731. openers.push("{");
  92732. closers.push("}");
  92733. }
  92734. if (options.bracketException) {
  92735. openers.push("[");
  92736. closers.push("]");
  92737. }
  92738. if (options.parenException) {
  92739. openers.push("(");
  92740. closers.push(")");
  92741. }
  92742. if (options.empty) {
  92743. openers.push(")");
  92744. closers.push("(");
  92745. }
  92746. return {
  92747. openers: openers,
  92748. closers: closers
  92749. };
  92750. }
  92751. //--------------------------------------------------------------------------
  92752. // Helpers
  92753. //--------------------------------------------------------------------------
  92754. var sourceCode = context.getSourceCode();
  92755. /**
  92756. * Determines if a token is one of the exceptions for the opener paren
  92757. * @param {Object} token The token to check
  92758. * @returns {boolean} True if the token is one of the exceptions for the opener paren
  92759. */
  92760. function isOpenerException(token) {
  92761. return token.type === "Punctuator" && exceptions.openers.indexOf(token.value) >= 0;
  92762. }
  92763. /**
  92764. * Determines if a token is one of the exceptions for the closer paren
  92765. * @param {Object} token The token to check
  92766. * @returns {boolean} True if the token is one of the exceptions for the closer paren
  92767. */
  92768. function isCloserException(token) {
  92769. return token.type === "Punctuator" && exceptions.closers.indexOf(token.value) >= 0;
  92770. }
  92771. /**
  92772. * Determines if an opener paren should have a missing space after it
  92773. * @param {Object} left The paren token
  92774. * @param {Object} right The token after it
  92775. * @returns {boolean} True if the paren should have a space
  92776. */
  92777. function shouldOpenerHaveSpace(left, right) {
  92778. if (sourceCode.isSpaceBetweenTokens(left, right)) {
  92779. return false;
  92780. }
  92781. if (ALWAYS) {
  92782. if (astUtils.isClosingParenToken(right)) {
  92783. return false;
  92784. }
  92785. return !isOpenerException(right);
  92786. }
  92787. return isOpenerException(right);
  92788. }
  92789. /**
  92790. * Determines if an closer paren should have a missing space after it
  92791. * @param {Object} left The token before the paren
  92792. * @param {Object} right The paren token
  92793. * @returns {boolean} True if the paren should have a space
  92794. */
  92795. function shouldCloserHaveSpace(left, right) {
  92796. if (astUtils.isOpeningParenToken(left)) {
  92797. return false;
  92798. }
  92799. if (sourceCode.isSpaceBetweenTokens(left, right)) {
  92800. return false;
  92801. }
  92802. if (ALWAYS) {
  92803. return !isCloserException(left);
  92804. }
  92805. return isCloserException(left);
  92806. }
  92807. /**
  92808. * Determines if an opener paren should not have an existing space after it
  92809. * @param {Object} left The paren token
  92810. * @param {Object} right The token after it
  92811. * @returns {boolean} True if the paren should reject the space
  92812. */
  92813. function shouldOpenerRejectSpace(left, right) {
  92814. if (right.type === "Line") {
  92815. return false;
  92816. }
  92817. if (!astUtils.isTokenOnSameLine(left, right)) {
  92818. return false;
  92819. }
  92820. if (!sourceCode.isSpaceBetweenTokens(left, right)) {
  92821. return false;
  92822. }
  92823. if (ALWAYS) {
  92824. return isOpenerException(right);
  92825. }
  92826. return !isOpenerException(right);
  92827. }
  92828. /**
  92829. * Determines if an closer paren should not have an existing space after it
  92830. * @param {Object} left The token before the paren
  92831. * @param {Object} right The paren token
  92832. * @returns {boolean} True if the paren should reject the space
  92833. */
  92834. function shouldCloserRejectSpace(left, right) {
  92835. if (astUtils.isOpeningParenToken(left)) {
  92836. return false;
  92837. }
  92838. if (!astUtils.isTokenOnSameLine(left, right)) {
  92839. return false;
  92840. }
  92841. if (!sourceCode.isSpaceBetweenTokens(left, right)) {
  92842. return false;
  92843. }
  92844. if (ALWAYS) {
  92845. return isCloserException(left);
  92846. }
  92847. return !isCloserException(left);
  92848. }
  92849. //--------------------------------------------------------------------------
  92850. // Public
  92851. //--------------------------------------------------------------------------
  92852. return {
  92853. Program: function checkParenSpaces(node) {
  92854. exceptions = getExceptions();
  92855. var tokens = sourceCode.tokensAndComments;
  92856. tokens.forEach(function (token, i) {
  92857. var prevToken = tokens[i - 1];
  92858. var nextToken = tokens[i + 1];
  92859. if (!astUtils.isOpeningParenToken(token) && !astUtils.isClosingParenToken(token)) {
  92860. return;
  92861. }
  92862. if (token.value === "(" && shouldOpenerHaveSpace(token, nextToken)) {
  92863. context.report({
  92864. node: node,
  92865. loc: token.loc.start,
  92866. message: MISSING_SPACE_MESSAGE,
  92867. fix: function fix(fixer) {
  92868. return fixer.insertTextAfter(token, " ");
  92869. }
  92870. });
  92871. } else if (token.value === "(" && shouldOpenerRejectSpace(token, nextToken)) {
  92872. context.report({
  92873. node: node,
  92874. loc: token.loc.start,
  92875. message: REJECTED_SPACE_MESSAGE,
  92876. fix: function fix(fixer) {
  92877. return fixer.removeRange([token.range[1], nextToken.range[0]]);
  92878. }
  92879. });
  92880. } else if (token.value === ")" && shouldCloserHaveSpace(prevToken, token)) {
  92881. // context.report(node, token.loc.start, MISSING_SPACE_MESSAGE);
  92882. context.report({
  92883. node: node,
  92884. loc: token.loc.start,
  92885. message: MISSING_SPACE_MESSAGE,
  92886. fix: function fix(fixer) {
  92887. return fixer.insertTextBefore(token, " ");
  92888. }
  92889. });
  92890. } else if (token.value === ")" && shouldCloserRejectSpace(prevToken, token)) {
  92891. context.report({
  92892. node: node,
  92893. loc: token.loc.start,
  92894. message: REJECTED_SPACE_MESSAGE,
  92895. fix: function fix(fixer) {
  92896. return fixer.removeRange([prevToken.range[1], token.range[0]]);
  92897. }
  92898. });
  92899. }
  92900. });
  92901. }
  92902. };
  92903. }
  92904. };
  92905. },{"../util/ast-utils":405}],373:[function(require,module,exports){
  92906. /**
  92907. * @fileoverview Require spaces around infix operators
  92908. * @author Michael Ficarra
  92909. */
  92910. "use strict";
  92911. //------------------------------------------------------------------------------
  92912. // Rule Definition
  92913. //------------------------------------------------------------------------------
  92914. module.exports = {
  92915. meta: {
  92916. type: "layout",
  92917. docs: {
  92918. description: "require spacing around infix operators",
  92919. category: "Stylistic Issues",
  92920. recommended: false,
  92921. url: "https://eslint.org/docs/rules/space-infix-ops"
  92922. },
  92923. fixable: "whitespace",
  92924. schema: [{
  92925. type: "object",
  92926. properties: {
  92927. int32Hint: {
  92928. type: "boolean"
  92929. }
  92930. },
  92931. additionalProperties: false
  92932. }]
  92933. },
  92934. create: function create(context) {
  92935. var int32Hint = context.options[0] ? context.options[0].int32Hint === true : false;
  92936. var sourceCode = context.getSourceCode();
  92937. /**
  92938. * Returns the first token which violates the rule
  92939. * @param {ASTNode} left - The left node of the main node
  92940. * @param {ASTNode} right - The right node of the main node
  92941. * @param {string} op - The operator of the main node
  92942. * @returns {Object} The violator token or null
  92943. * @private
  92944. */
  92945. function getFirstNonSpacedToken(left, right, op) {
  92946. var operator = sourceCode.getFirstTokenBetween(left, right, function (token) {
  92947. return token.value === op;
  92948. });
  92949. var prev = sourceCode.getTokenBefore(operator);
  92950. var next = sourceCode.getTokenAfter(operator);
  92951. if (!sourceCode.isSpaceBetweenTokens(prev, operator) || !sourceCode.isSpaceBetweenTokens(operator, next)) {
  92952. return operator;
  92953. }
  92954. return null;
  92955. }
  92956. /**
  92957. * Reports an AST node as a rule violation
  92958. * @param {ASTNode} mainNode - The node to report
  92959. * @param {Object} culpritToken - The token which has a problem
  92960. * @returns {void}
  92961. * @private
  92962. */
  92963. function report(mainNode, culpritToken) {
  92964. context.report({
  92965. node: mainNode,
  92966. loc: culpritToken.loc.start,
  92967. message: "Operator '{{operator}}' must be spaced.",
  92968. data: {
  92969. operator: culpritToken.value
  92970. },
  92971. fix: function fix(fixer) {
  92972. var previousToken = sourceCode.getTokenBefore(culpritToken);
  92973. var afterToken = sourceCode.getTokenAfter(culpritToken);
  92974. var fixString = "";
  92975. if (culpritToken.range[0] - previousToken.range[1] === 0) {
  92976. fixString = " ";
  92977. }
  92978. fixString += culpritToken.value;
  92979. if (afterToken.range[0] - culpritToken.range[1] === 0) {
  92980. fixString += " ";
  92981. }
  92982. return fixer.replaceText(culpritToken, fixString);
  92983. }
  92984. });
  92985. }
  92986. /**
  92987. * Check if the node is binary then report
  92988. * @param {ASTNode} node node to evaluate
  92989. * @returns {void}
  92990. * @private
  92991. */
  92992. function checkBinary(node) {
  92993. var leftNode = node.left.typeAnnotation ? node.left.typeAnnotation : node.left;
  92994. var rightNode = node.right;
  92995. // search for = in AssignmentPattern nodes
  92996. var operator = node.operator || "=";
  92997. var nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, operator);
  92998. if (nonSpacedNode) {
  92999. if (!(int32Hint && sourceCode.getText(node).endsWith("|0"))) {
  93000. report(node, nonSpacedNode);
  93001. }
  93002. }
  93003. }
  93004. /**
  93005. * Check if the node is conditional
  93006. * @param {ASTNode} node node to evaluate
  93007. * @returns {void}
  93008. * @private
  93009. */
  93010. function checkConditional(node) {
  93011. var nonSpacedConsequesntNode = getFirstNonSpacedToken(node.test, node.consequent, "?");
  93012. var nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":");
  93013. if (nonSpacedConsequesntNode) {
  93014. report(node, nonSpacedConsequesntNode);
  93015. } else if (nonSpacedAlternateNode) {
  93016. report(node, nonSpacedAlternateNode);
  93017. }
  93018. }
  93019. /**
  93020. * Check if the node is a variable
  93021. * @param {ASTNode} node node to evaluate
  93022. * @returns {void}
  93023. * @private
  93024. */
  93025. function checkVar(node) {
  93026. var leftNode = node.id.typeAnnotation ? node.id.typeAnnotation : node.id;
  93027. var rightNode = node.init;
  93028. if (rightNode) {
  93029. var nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
  93030. if (nonSpacedNode) {
  93031. report(node, nonSpacedNode);
  93032. }
  93033. }
  93034. }
  93035. return {
  93036. AssignmentExpression: checkBinary,
  93037. AssignmentPattern: checkBinary,
  93038. BinaryExpression: checkBinary,
  93039. LogicalExpression: checkBinary,
  93040. ConditionalExpression: checkConditional,
  93041. VariableDeclarator: checkVar
  93042. };
  93043. }
  93044. };
  93045. },{}],374:[function(require,module,exports){
  93046. /**
  93047. * @fileoverview This rule shoud require or disallow spaces before or after unary operations.
  93048. * @author Marcin Kumorek
  93049. */
  93050. "use strict";
  93051. //------------------------------------------------------------------------------
  93052. // Requirements
  93053. //------------------------------------------------------------------------------
  93054. var astUtils = require("../util/ast-utils");
  93055. //------------------------------------------------------------------------------
  93056. // Rule Definition
  93057. //------------------------------------------------------------------------------
  93058. module.exports = {
  93059. meta: {
  93060. type: "layout",
  93061. docs: {
  93062. description: "enforce consistent spacing before or after unary operators",
  93063. category: "Stylistic Issues",
  93064. recommended: false,
  93065. url: "https://eslint.org/docs/rules/space-unary-ops"
  93066. },
  93067. fixable: "whitespace",
  93068. schema: [{
  93069. type: "object",
  93070. properties: {
  93071. words: {
  93072. type: "boolean"
  93073. },
  93074. nonwords: {
  93075. type: "boolean"
  93076. },
  93077. overrides: {
  93078. type: "object",
  93079. additionalProperties: {
  93080. type: "boolean"
  93081. }
  93082. }
  93083. },
  93084. additionalProperties: false
  93085. }]
  93086. },
  93087. create: function create(context) {
  93088. var options = context.options && Array.isArray(context.options) && context.options[0] || { words: true, nonwords: false };
  93089. var sourceCode = context.getSourceCode();
  93090. //--------------------------------------------------------------------------
  93091. // Helpers
  93092. //--------------------------------------------------------------------------
  93093. /**
  93094. * Check if the node is the first "!" in a "!!" convert to Boolean expression
  93095. * @param {ASTnode} node AST node
  93096. * @returns {boolean} Whether or not the node is first "!" in "!!"
  93097. */
  93098. function isFirstBangInBangBangExpression(node) {
  93099. return node && node.type === "UnaryExpression" && node.argument.operator === "!" && node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
  93100. }
  93101. /**
  93102. * Checks if an override exists for a given operator.
  93103. * @param {string} operator Operator
  93104. * @returns {boolean} Whether or not an override has been provided for the operator
  93105. */
  93106. function overrideExistsForOperator(operator) {
  93107. return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
  93108. }
  93109. /**
  93110. * Gets the value that the override was set to for this operator
  93111. * @param {string} operator Operator
  93112. * @returns {boolean} Whether or not an override enforces a space with this operator
  93113. */
  93114. function overrideEnforcesSpaces(operator) {
  93115. return options.overrides[operator];
  93116. }
  93117. /**
  93118. * Verify Unary Word Operator has spaces after the word operator
  93119. * @param {ASTnode} node AST node
  93120. * @param {Object} firstToken first token from the AST node
  93121. * @param {Object} secondToken second token from the AST node
  93122. * @param {string} word The word to be used for reporting
  93123. * @returns {void}
  93124. */
  93125. function verifyWordHasSpaces(node, firstToken, secondToken, word) {
  93126. if (secondToken.range[0] === firstToken.range[1]) {
  93127. context.report({
  93128. node: node,
  93129. message: "Unary word operator '{{word}}' must be followed by whitespace.",
  93130. data: {
  93131. word: word
  93132. },
  93133. fix: function fix(fixer) {
  93134. return fixer.insertTextAfter(firstToken, " ");
  93135. }
  93136. });
  93137. }
  93138. }
  93139. /**
  93140. * Verify Unary Word Operator doesn't have spaces after the word operator
  93141. * @param {ASTnode} node AST node
  93142. * @param {Object} firstToken first token from the AST node
  93143. * @param {Object} secondToken second token from the AST node
  93144. * @param {string} word The word to be used for reporting
  93145. * @returns {void}
  93146. */
  93147. function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) {
  93148. if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
  93149. if (secondToken.range[0] > firstToken.range[1]) {
  93150. context.report({
  93151. node: node,
  93152. message: "Unexpected space after unary word operator '{{word}}'.",
  93153. data: {
  93154. word: word
  93155. },
  93156. fix: function fix(fixer) {
  93157. return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
  93158. }
  93159. });
  93160. }
  93161. }
  93162. }
  93163. /**
  93164. * Check Unary Word Operators for spaces after the word operator
  93165. * @param {ASTnode} node AST node
  93166. * @param {Object} firstToken first token from the AST node
  93167. * @param {Object} secondToken second token from the AST node
  93168. * @param {string} word The word to be used for reporting
  93169. * @returns {void}
  93170. */
  93171. function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) {
  93172. if (overrideExistsForOperator(word)) {
  93173. if (overrideEnforcesSpaces(word)) {
  93174. verifyWordHasSpaces(node, firstToken, secondToken, word);
  93175. } else {
  93176. verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
  93177. }
  93178. } else if (options.words) {
  93179. verifyWordHasSpaces(node, firstToken, secondToken, word);
  93180. } else {
  93181. verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
  93182. }
  93183. }
  93184. /**
  93185. * Verifies YieldExpressions satisfy spacing requirements
  93186. * @param {ASTnode} node AST node
  93187. * @returns {void}
  93188. */
  93189. function checkForSpacesAfterYield(node) {
  93190. var tokens = sourceCode.getFirstTokens(node, 3),
  93191. word = "yield";
  93192. if (!node.argument || node.delegate) {
  93193. return;
  93194. }
  93195. checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word);
  93196. }
  93197. /**
  93198. * Verifies AwaitExpressions satisfy spacing requirements
  93199. * @param {ASTNode} node AwaitExpression AST node
  93200. * @returns {void}
  93201. */
  93202. function checkForSpacesAfterAwait(node) {
  93203. var tokens = sourceCode.getFirstTokens(node, 3);
  93204. checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await");
  93205. }
  93206. /**
  93207. * Verifies UnaryExpression, UpdateExpression and NewExpression have spaces before or after the operator
  93208. * @param {ASTnode} node AST node
  93209. * @param {Object} firstToken First token in the expression
  93210. * @param {Object} secondToken Second token in the expression
  93211. * @returns {void}
  93212. */
  93213. function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
  93214. if (node.prefix) {
  93215. if (isFirstBangInBangBangExpression(node)) {
  93216. return;
  93217. }
  93218. if (firstToken.range[1] === secondToken.range[0]) {
  93219. context.report({
  93220. node: node,
  93221. message: "Unary operator '{{operator}}' must be followed by whitespace.",
  93222. data: {
  93223. operator: firstToken.value
  93224. },
  93225. fix: function fix(fixer) {
  93226. return fixer.insertTextAfter(firstToken, " ");
  93227. }
  93228. });
  93229. }
  93230. } else {
  93231. if (firstToken.range[1] === secondToken.range[0]) {
  93232. context.report({
  93233. node: node,
  93234. message: "Space is required before unary expressions '{{token}}'.",
  93235. data: {
  93236. token: secondToken.value
  93237. },
  93238. fix: function fix(fixer) {
  93239. return fixer.insertTextBefore(secondToken, " ");
  93240. }
  93241. });
  93242. }
  93243. }
  93244. }
  93245. /**
  93246. * Verifies UnaryExpression, UpdateExpression and NewExpression don't have spaces before or after the operator
  93247. * @param {ASTnode} node AST node
  93248. * @param {Object} firstToken First token in the expression
  93249. * @param {Object} secondToken Second token in the expression
  93250. * @returns {void}
  93251. */
  93252. function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) {
  93253. if (node.prefix) {
  93254. if (secondToken.range[0] > firstToken.range[1]) {
  93255. context.report({
  93256. node: node,
  93257. message: "Unexpected space after unary operator '{{operator}}'.",
  93258. data: {
  93259. operator: firstToken.value
  93260. },
  93261. fix: function fix(fixer) {
  93262. if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
  93263. return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
  93264. }
  93265. return null;
  93266. }
  93267. });
  93268. }
  93269. } else {
  93270. if (secondToken.range[0] > firstToken.range[1]) {
  93271. context.report({
  93272. node: node,
  93273. message: "Unexpected space before unary operator '{{operator}}'.",
  93274. data: {
  93275. operator: secondToken.value
  93276. },
  93277. fix: function fix(fixer) {
  93278. return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
  93279. }
  93280. });
  93281. }
  93282. }
  93283. }
  93284. /**
  93285. * Verifies UnaryExpression, UpdateExpression and NewExpression satisfy spacing requirements
  93286. * @param {ASTnode} node AST node
  93287. * @returns {void}
  93288. */
  93289. function checkForSpaces(node) {
  93290. var tokens = node.type === "UpdateExpression" && !node.prefix ? sourceCode.getLastTokens(node, 2) : sourceCode.getFirstTokens(node, 2);
  93291. var firstToken = tokens[0];
  93292. var secondToken = tokens[1];
  93293. if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") {
  93294. checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value);
  93295. return;
  93296. }
  93297. var operator = node.prefix ? tokens[0].value : tokens[1].value;
  93298. if (overrideExistsForOperator(operator)) {
  93299. if (overrideEnforcesSpaces(operator)) {
  93300. verifyNonWordsHaveSpaces(node, firstToken, secondToken);
  93301. } else {
  93302. verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
  93303. }
  93304. } else if (options.nonwords) {
  93305. verifyNonWordsHaveSpaces(node, firstToken, secondToken);
  93306. } else {
  93307. verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
  93308. }
  93309. }
  93310. //--------------------------------------------------------------------------
  93311. // Public
  93312. //--------------------------------------------------------------------------
  93313. return {
  93314. UnaryExpression: checkForSpaces,
  93315. UpdateExpression: checkForSpaces,
  93316. NewExpression: checkForSpaces,
  93317. YieldExpression: checkForSpacesAfterYield,
  93318. AwaitExpression: checkForSpacesAfterAwait
  93319. };
  93320. }
  93321. };
  93322. },{"../util/ast-utils":405}],375:[function(require,module,exports){
  93323. /**
  93324. * @fileoverview Source code for spaced-comments rule
  93325. * @author Gyandeep Singh
  93326. */
  93327. "use strict";
  93328. var lodash = require("lodash");
  93329. var astUtils = require("../util/ast-utils");
  93330. //------------------------------------------------------------------------------
  93331. // Helpers
  93332. //------------------------------------------------------------------------------
  93333. /**
  93334. * Escapes the control characters of a given string.
  93335. * @param {string} s - A string to escape.
  93336. * @returns {string} An escaped string.
  93337. */
  93338. function escape(s) {
  93339. return "(?:" + lodash.escapeRegExp(s) + ")";
  93340. }
  93341. /**
  93342. * Escapes the control characters of a given string.
  93343. * And adds a repeat flag.
  93344. * @param {string} s - A string to escape.
  93345. * @returns {string} An escaped string.
  93346. */
  93347. function escapeAndRepeat(s) {
  93348. return escape(s) + "+";
  93349. }
  93350. /**
  93351. * Parses `markers` option.
  93352. * If markers don't include `"*"`, this adds `"*"` to allow JSDoc comments.
  93353. * @param {string[]} [markers] - A marker list.
  93354. * @returns {string[]} A marker list.
  93355. */
  93356. function parseMarkersOption(markers) {
  93357. // `*` is a marker for JSDoc comments.
  93358. if (markers.indexOf("*") === -1) {
  93359. return markers.concat("*");
  93360. }
  93361. return markers;
  93362. }
  93363. /**
  93364. * Creates string pattern for exceptions.
  93365. * Generated pattern:
  93366. *
  93367. * 1. A space or an exception pattern sequence.
  93368. *
  93369. * @param {string[]} exceptions - An exception pattern list.
  93370. * @returns {string} A regular expression string for exceptions.
  93371. */
  93372. function createExceptionsPattern(exceptions) {
  93373. var pattern = "";
  93374. /*
  93375. * A space or an exception pattern sequence.
  93376. * [] ==> "\s"
  93377. * ["-"] ==> "(?:\s|\-+$)"
  93378. * ["-", "="] ==> "(?:\s|(?:\-+|=+)$)"
  93379. * ["-", "=", "--=="] ==> "(?:\s|(?:\-+|=+|(?:\-\-==)+)$)" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5Cs%7C(%3F%3A%5C-%2B%7C%3D%2B%7C(%3F%3A%5C-%5C-%3D%3D)%2B)%24)
  93380. */
  93381. if (exceptions.length === 0) {
  93382. // a space.
  93383. pattern += "\\s";
  93384. } else {
  93385. // a space or...
  93386. pattern += "(?:\\s|";
  93387. if (exceptions.length === 1) {
  93388. // a sequence of the exception pattern.
  93389. pattern += escapeAndRepeat(exceptions[0]);
  93390. } else {
  93391. // a sequence of one of the exception patterns.
  93392. pattern += "(?:";
  93393. pattern += exceptions.map(escapeAndRepeat).join("|");
  93394. pattern += ")";
  93395. }
  93396. pattern += "(?:$|[" + Array.from(astUtils.LINEBREAKS).join("") + "]))";
  93397. }
  93398. return pattern;
  93399. }
  93400. /**
  93401. * Creates RegExp object for `always` mode.
  93402. * Generated pattern for beginning of comment:
  93403. *
  93404. * 1. First, a marker or nothing.
  93405. * 2. Next, a space or an exception pattern sequence.
  93406. *
  93407. * @param {string[]} markers - A marker list.
  93408. * @param {string[]} exceptions - An exception pattern list.
  93409. * @returns {RegExp} A RegExp object for the beginning of a comment in `always` mode.
  93410. */
  93411. function createAlwaysStylePattern(markers, exceptions) {
  93412. var pattern = "^";
  93413. /*
  93414. * A marker or nothing.
  93415. * ["*"] ==> "\*?"
  93416. * ["*", "!"] ==> "(?:\*|!)?"
  93417. * ["*", "/", "!<"] ==> "(?:\*|\/|(?:!<))?" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5C*%7C%5C%2F%7C(%3F%3A!%3C))%3F
  93418. */
  93419. if (markers.length === 1) {
  93420. // the marker.
  93421. pattern += escape(markers[0]);
  93422. } else {
  93423. // one of markers.
  93424. pattern += "(?:";
  93425. pattern += markers.map(escape).join("|");
  93426. pattern += ")";
  93427. }
  93428. pattern += "?"; // or nothing.
  93429. pattern += createExceptionsPattern(exceptions);
  93430. return new RegExp(pattern);
  93431. }
  93432. /**
  93433. * Creates RegExp object for `never` mode.
  93434. * Generated pattern for beginning of comment:
  93435. *
  93436. * 1. First, a marker or nothing (captured).
  93437. * 2. Next, a space or a tab.
  93438. *
  93439. * @param {string[]} markers - A marker list.
  93440. * @returns {RegExp} A RegExp object for `never` mode.
  93441. */
  93442. function createNeverStylePattern(markers) {
  93443. var pattern = "^(" + markers.map(escape).join("|") + ")?[ \t]+";
  93444. return new RegExp(pattern);
  93445. }
  93446. //------------------------------------------------------------------------------
  93447. // Rule Definition
  93448. //------------------------------------------------------------------------------
  93449. module.exports = {
  93450. meta: {
  93451. type: "suggestion",
  93452. docs: {
  93453. description: "enforce consistent spacing after the `//` or `/*` in a comment",
  93454. category: "Stylistic Issues",
  93455. recommended: false,
  93456. url: "https://eslint.org/docs/rules/spaced-comment"
  93457. },
  93458. fixable: "whitespace",
  93459. schema: [{
  93460. enum: ["always", "never"]
  93461. }, {
  93462. type: "object",
  93463. properties: {
  93464. exceptions: {
  93465. type: "array",
  93466. items: {
  93467. type: "string"
  93468. }
  93469. },
  93470. markers: {
  93471. type: "array",
  93472. items: {
  93473. type: "string"
  93474. }
  93475. },
  93476. line: {
  93477. type: "object",
  93478. properties: {
  93479. exceptions: {
  93480. type: "array",
  93481. items: {
  93482. type: "string"
  93483. }
  93484. },
  93485. markers: {
  93486. type: "array",
  93487. items: {
  93488. type: "string"
  93489. }
  93490. }
  93491. },
  93492. additionalProperties: false
  93493. },
  93494. block: {
  93495. type: "object",
  93496. properties: {
  93497. exceptions: {
  93498. type: "array",
  93499. items: {
  93500. type: "string"
  93501. }
  93502. },
  93503. markers: {
  93504. type: "array",
  93505. items: {
  93506. type: "string"
  93507. }
  93508. },
  93509. balanced: {
  93510. type: "boolean"
  93511. }
  93512. },
  93513. additionalProperties: false
  93514. }
  93515. },
  93516. additionalProperties: false
  93517. }]
  93518. },
  93519. create: function create(context) {
  93520. var sourceCode = context.getSourceCode();
  93521. // Unless the first option is never, require a space
  93522. var requireSpace = context.options[0] !== "never";
  93523. /*
  93524. * Parse the second options.
  93525. * If markers don't include `"*"`, it's added automatically for JSDoc
  93526. * comments.
  93527. */
  93528. var config = context.options[1] || {};
  93529. var balanced = config.block && config.block.balanced;
  93530. var styleRules = ["block", "line"].reduce(function (rule, type) {
  93531. var markers = parseMarkersOption(config[type] && config[type].markers || config.markers || []);
  93532. var exceptions = config[type] && config[type].exceptions || config.exceptions || [];
  93533. var endNeverPattern = "[ \t]+$";
  93534. // Create RegExp object for valid patterns.
  93535. rule[type] = {
  93536. beginRegex: requireSpace ? createAlwaysStylePattern(markers, exceptions) : createNeverStylePattern(markers),
  93537. endRegex: balanced && requireSpace ? new RegExp(createExceptionsPattern(exceptions) + "$") : new RegExp(endNeverPattern),
  93538. hasExceptions: exceptions.length > 0,
  93539. markers: new RegExp("^(" + markers.map(escape).join("|") + ")")
  93540. };
  93541. return rule;
  93542. }, {});
  93543. /**
  93544. * Reports a beginning spacing error with an appropriate message.
  93545. * @param {ASTNode} node - A comment node to check.
  93546. * @param {string} message - An error message to report.
  93547. * @param {Array} match - An array of match results for markers.
  93548. * @param {string} refChar - Character used for reference in the error message.
  93549. * @returns {void}
  93550. */
  93551. function reportBegin(node, message, match, refChar) {
  93552. var type = node.type.toLowerCase(),
  93553. commentIdentifier = type === "block" ? "/*" : "//";
  93554. context.report({
  93555. node: node,
  93556. fix: function fix(fixer) {
  93557. var start = node.range[0];
  93558. var end = start + 2;
  93559. if (requireSpace) {
  93560. if (match) {
  93561. end += match[0].length;
  93562. }
  93563. return fixer.insertTextAfterRange([start, end], " ");
  93564. }
  93565. end += match[0].length;
  93566. return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : ""));
  93567. },
  93568. message: message,
  93569. data: { refChar: refChar }
  93570. });
  93571. }
  93572. /**
  93573. * Reports an ending spacing error with an appropriate message.
  93574. * @param {ASTNode} node - A comment node to check.
  93575. * @param {string} message - An error message to report.
  93576. * @param {string} match - An array of the matched whitespace characters.
  93577. * @returns {void}
  93578. */
  93579. function reportEnd(node, message, match) {
  93580. context.report({
  93581. node: node,
  93582. fix: function fix(fixer) {
  93583. if (requireSpace) {
  93584. return fixer.insertTextAfterRange([node.range[0], node.range[1] - 2], " ");
  93585. }
  93586. var end = node.range[1] - 2,
  93587. start = end - match[0].length;
  93588. return fixer.replaceTextRange([start, end], "");
  93589. },
  93590. message: message
  93591. });
  93592. }
  93593. /**
  93594. * Reports a given comment if it's invalid.
  93595. * @param {ASTNode} node - a comment node to check.
  93596. * @returns {void}
  93597. */
  93598. function checkCommentForSpace(node) {
  93599. var type = node.type.toLowerCase(),
  93600. rule = styleRules[type],
  93601. commentIdentifier = type === "block" ? "/*" : "//";
  93602. // Ignores empty comments.
  93603. if (node.value.length === 0) {
  93604. return;
  93605. }
  93606. var beginMatch = rule.beginRegex.exec(node.value);
  93607. var endMatch = rule.endRegex.exec(node.value);
  93608. // Checks.
  93609. if (requireSpace) {
  93610. if (!beginMatch) {
  93611. var hasMarker = rule.markers.exec(node.value);
  93612. var marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier;
  93613. if (rule.hasExceptions) {
  93614. reportBegin(node, "Expected exception block, space or tab after '{{refChar}}' in comment.", hasMarker, marker);
  93615. } else {
  93616. reportBegin(node, "Expected space or tab after '{{refChar}}' in comment.", hasMarker, marker);
  93617. }
  93618. }
  93619. if (balanced && type === "block" && !endMatch) {
  93620. reportEnd(node, "Expected space or tab before '*/' in comment.");
  93621. }
  93622. } else {
  93623. if (beginMatch) {
  93624. if (!beginMatch[1]) {
  93625. reportBegin(node, "Unexpected space or tab after '{{refChar}}' in comment.", beginMatch, commentIdentifier);
  93626. } else {
  93627. reportBegin(node, "Unexpected space or tab after marker ({{refChar}}) in comment.", beginMatch, beginMatch[1]);
  93628. }
  93629. }
  93630. if (balanced && type === "block" && endMatch) {
  93631. reportEnd(node, "Unexpected space or tab before '*/' in comment.", endMatch);
  93632. }
  93633. }
  93634. }
  93635. return {
  93636. Program: function Program() {
  93637. var comments = sourceCode.getAllComments();
  93638. comments.filter(function (token) {
  93639. return token.type !== "Shebang";
  93640. }).forEach(checkCommentForSpace);
  93641. }
  93642. };
  93643. }
  93644. };
  93645. },{"../util/ast-utils":405,"lodash":92}],376:[function(require,module,exports){
  93646. /**
  93647. * @fileoverview Rule to control usage of strict mode directives.
  93648. * @author Brandon Mills
  93649. */
  93650. "use strict";
  93651. //------------------------------------------------------------------------------
  93652. // Requirements
  93653. //------------------------------------------------------------------------------
  93654. var astUtils = require("../util/ast-utils");
  93655. //------------------------------------------------------------------------------
  93656. // Helpers
  93657. //------------------------------------------------------------------------------
  93658. var messages = {
  93659. function: "Use the function form of 'use strict'.",
  93660. global: "Use the global form of 'use strict'.",
  93661. multiple: "Multiple 'use strict' directives.",
  93662. never: "Strict mode is not permitted.",
  93663. unnecessary: "Unnecessary 'use strict' directive.",
  93664. module: "'use strict' is unnecessary inside of modules.",
  93665. implied: "'use strict' is unnecessary when implied strict mode is enabled.",
  93666. unnecessaryInClasses: "'use strict' is unnecessary inside of classes.",
  93667. nonSimpleParameterList: "'use strict' directive inside a function with non-simple parameter list throws a syntax error since ES2016.",
  93668. wrap: "Wrap {{name}} in a function with 'use strict' directive."
  93669. };
  93670. /**
  93671. * Gets all of the Use Strict Directives in the Directive Prologue of a group of
  93672. * statements.
  93673. * @param {ASTNode[]} statements Statements in the program or function body.
  93674. * @returns {ASTNode[]} All of the Use Strict Directives.
  93675. */
  93676. function getUseStrictDirectives(statements) {
  93677. var directives = [];
  93678. for (var i = 0; i < statements.length; i++) {
  93679. var statement = statements[i];
  93680. if (statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && statement.expression.value === "use strict") {
  93681. directives[i] = statement;
  93682. } else {
  93683. break;
  93684. }
  93685. }
  93686. return directives;
  93687. }
  93688. /**
  93689. * Checks whether a given parameter is a simple parameter.
  93690. *
  93691. * @param {ASTNode} node - A pattern node to check.
  93692. * @returns {boolean} `true` if the node is an Identifier node.
  93693. */
  93694. function isSimpleParameter(node) {
  93695. return node.type === "Identifier";
  93696. }
  93697. /**
  93698. * Checks whether a given parameter list is a simple parameter list.
  93699. *
  93700. * @param {ASTNode[]} params - A parameter list to check.
  93701. * @returns {boolean} `true` if the every parameter is an Identifier node.
  93702. */
  93703. function isSimpleParameterList(params) {
  93704. return params.every(isSimpleParameter);
  93705. }
  93706. //------------------------------------------------------------------------------
  93707. // Rule Definition
  93708. //------------------------------------------------------------------------------
  93709. module.exports = {
  93710. meta: {
  93711. type: "suggestion",
  93712. docs: {
  93713. description: "require or disallow strict mode directives",
  93714. category: "Strict Mode",
  93715. recommended: false,
  93716. url: "https://eslint.org/docs/rules/strict"
  93717. },
  93718. schema: [{
  93719. enum: ["never", "global", "function", "safe"]
  93720. }],
  93721. fixable: "code"
  93722. },
  93723. create: function create(context) {
  93724. var ecmaFeatures = context.parserOptions.ecmaFeatures || {},
  93725. scopes = [],
  93726. classScopes = [];
  93727. var mode = context.options[0] || "safe";
  93728. if (ecmaFeatures.impliedStrict) {
  93729. mode = "implied";
  93730. } else if (mode === "safe") {
  93731. mode = ecmaFeatures.globalReturn ? "global" : "function";
  93732. }
  93733. /**
  93734. * Determines whether a reported error should be fixed, depending on the error type.
  93735. * @param {string} errorType The type of error
  93736. * @returns {boolean} `true` if the reported error should be fixed
  93737. */
  93738. function shouldFix(errorType) {
  93739. return errorType === "multiple" || errorType === "unnecessary" || errorType === "module" || errorType === "implied" || errorType === "unnecessaryInClasses";
  93740. }
  93741. /**
  93742. * Gets a fixer function to remove a given 'use strict' directive.
  93743. * @param {ASTNode} node The directive that should be removed
  93744. * @returns {Function} A fixer function
  93745. */
  93746. function getFixFunction(node) {
  93747. return function (fixer) {
  93748. return fixer.remove(node);
  93749. };
  93750. }
  93751. /**
  93752. * Report a slice of an array of nodes with a given message.
  93753. * @param {ASTNode[]} nodes Nodes.
  93754. * @param {string} start Index to start from.
  93755. * @param {string} end Index to end before.
  93756. * @param {string} message Message to display.
  93757. * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
  93758. * @returns {void}
  93759. */
  93760. function reportSlice(nodes, start, end, message, fix) {
  93761. nodes.slice(start, end).forEach(function (node) {
  93762. context.report({ node: node, message: message, fix: fix ? getFixFunction(node) : null });
  93763. });
  93764. }
  93765. /**
  93766. * Report all nodes in an array with a given message.
  93767. * @param {ASTNode[]} nodes Nodes.
  93768. * @param {string} message Message to display.
  93769. * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
  93770. * @returns {void}
  93771. */
  93772. function reportAll(nodes, message, fix) {
  93773. reportSlice(nodes, 0, nodes.length, message, fix);
  93774. }
  93775. /**
  93776. * Report all nodes in an array, except the first, with a given message.
  93777. * @param {ASTNode[]} nodes Nodes.
  93778. * @param {string} message Message to display.
  93779. * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
  93780. * @returns {void}
  93781. */
  93782. function reportAllExceptFirst(nodes, message, fix) {
  93783. reportSlice(nodes, 1, nodes.length, message, fix);
  93784. }
  93785. /**
  93786. * Entering a function in 'function' mode pushes a new nested scope onto the
  93787. * stack. The new scope is true if the nested function is strict mode code.
  93788. * @param {ASTNode} node The function declaration or expression.
  93789. * @param {ASTNode[]} useStrictDirectives The Use Strict Directives of the node.
  93790. * @returns {void}
  93791. */
  93792. function enterFunctionInFunctionMode(node, useStrictDirectives) {
  93793. var isInClass = classScopes.length > 0,
  93794. isParentGlobal = scopes.length === 0 && classScopes.length === 0,
  93795. isParentStrict = scopes.length > 0 && scopes[scopes.length - 1],
  93796. isStrict = useStrictDirectives.length > 0;
  93797. if (isStrict) {
  93798. if (!isSimpleParameterList(node.params)) {
  93799. context.report({ node: useStrictDirectives[0], message: messages.nonSimpleParameterList });
  93800. } else if (isParentStrict) {
  93801. context.report({ node: useStrictDirectives[0], message: messages.unnecessary, fix: getFixFunction(useStrictDirectives[0]) });
  93802. } else if (isInClass) {
  93803. context.report({ node: useStrictDirectives[0], message: messages.unnecessaryInClasses, fix: getFixFunction(useStrictDirectives[0]) });
  93804. }
  93805. reportAllExceptFirst(useStrictDirectives, messages.multiple, true);
  93806. } else if (isParentGlobal) {
  93807. if (isSimpleParameterList(node.params)) {
  93808. context.report({ node: node, message: messages.function });
  93809. } else {
  93810. context.report({
  93811. node: node,
  93812. message: messages.wrap,
  93813. data: { name: astUtils.getFunctionNameWithKind(node) }
  93814. });
  93815. }
  93816. }
  93817. scopes.push(isParentStrict || isStrict);
  93818. }
  93819. /**
  93820. * Exiting a function in 'function' mode pops its scope off the stack.
  93821. * @returns {void}
  93822. */
  93823. function exitFunctionInFunctionMode() {
  93824. scopes.pop();
  93825. }
  93826. /**
  93827. * Enter a function and either:
  93828. * - Push a new nested scope onto the stack (in 'function' mode).
  93829. * - Report all the Use Strict Directives (in the other modes).
  93830. * @param {ASTNode} node The function declaration or expression.
  93831. * @returns {void}
  93832. */
  93833. function enterFunction(node) {
  93834. var isBlock = node.body.type === "BlockStatement",
  93835. useStrictDirectives = isBlock ? getUseStrictDirectives(node.body.body) : [];
  93836. if (mode === "function") {
  93837. enterFunctionInFunctionMode(node, useStrictDirectives);
  93838. } else if (useStrictDirectives.length > 0) {
  93839. if (isSimpleParameterList(node.params)) {
  93840. reportAll(useStrictDirectives, messages[mode], shouldFix(mode));
  93841. } else {
  93842. context.report({ node: useStrictDirectives[0], message: messages.nonSimpleParameterList });
  93843. reportAllExceptFirst(useStrictDirectives, messages.multiple, true);
  93844. }
  93845. }
  93846. }
  93847. var rule = {
  93848. Program: function Program(node) {
  93849. var useStrictDirectives = getUseStrictDirectives(node.body);
  93850. if (node.sourceType === "module") {
  93851. mode = "module";
  93852. }
  93853. if (mode === "global") {
  93854. if (node.body.length > 0 && useStrictDirectives.length === 0) {
  93855. context.report({ node: node, message: messages.global });
  93856. }
  93857. reportAllExceptFirst(useStrictDirectives, messages.multiple, true);
  93858. } else {
  93859. reportAll(useStrictDirectives, messages[mode], shouldFix(mode));
  93860. }
  93861. },
  93862. FunctionDeclaration: enterFunction,
  93863. FunctionExpression: enterFunction,
  93864. ArrowFunctionExpression: enterFunction
  93865. };
  93866. if (mode === "function") {
  93867. Object.assign(rule, {
  93868. // Inside of class bodies are always strict mode.
  93869. ClassBody: function ClassBody() {
  93870. classScopes.push(true);
  93871. },
  93872. "ClassBody:exit": function ClassBodyExit() {
  93873. classScopes.pop();
  93874. },
  93875. "FunctionDeclaration:exit": exitFunctionInFunctionMode,
  93876. "FunctionExpression:exit": exitFunctionInFunctionMode,
  93877. "ArrowFunctionExpression:exit": exitFunctionInFunctionMode
  93878. });
  93879. }
  93880. return rule;
  93881. }
  93882. };
  93883. },{"../util/ast-utils":405}],377:[function(require,module,exports){
  93884. /**
  93885. * @fileoverview Rule to enforce spacing around colons of switch statements.
  93886. * @author Toru Nagashima
  93887. */
  93888. "use strict";
  93889. //------------------------------------------------------------------------------
  93890. // Requirements
  93891. //------------------------------------------------------------------------------
  93892. var astUtils = require("../util/ast-utils");
  93893. //------------------------------------------------------------------------------
  93894. // Rule Definition
  93895. //------------------------------------------------------------------------------
  93896. module.exports = {
  93897. meta: {
  93898. type: "layout",
  93899. docs: {
  93900. description: "enforce spacing around colons of switch statements",
  93901. category: "Stylistic Issues",
  93902. recommended: false,
  93903. url: "https://eslint.org/docs/rules/switch-colon-spacing"
  93904. },
  93905. schema: [{
  93906. type: "object",
  93907. properties: {
  93908. before: { type: "boolean" },
  93909. after: { type: "boolean" }
  93910. },
  93911. additionalProperties: false
  93912. }],
  93913. fixable: "whitespace"
  93914. },
  93915. create: function create(context) {
  93916. var sourceCode = context.getSourceCode();
  93917. var options = context.options[0] || {};
  93918. var beforeSpacing = options.before === true; // false by default
  93919. var afterSpacing = options.after !== false; // true by default
  93920. /**
  93921. * Get the colon token of the given SwitchCase node.
  93922. * @param {ASTNode} node The SwitchCase node to get.
  93923. * @returns {Token} The colon token of the node.
  93924. */
  93925. function getColonToken(node) {
  93926. if (node.test) {
  93927. return sourceCode.getTokenAfter(node.test, astUtils.isColonToken);
  93928. }
  93929. return sourceCode.getFirstToken(node, 1);
  93930. }
  93931. /**
  93932. * Check whether the spacing between the given 2 tokens is valid or not.
  93933. * @param {Token} left The left token to check.
  93934. * @param {Token} right The right token to check.
  93935. * @param {boolean} expected The expected spacing to check. `true` if there should be a space.
  93936. * @returns {boolean} `true` if the spacing between the tokens is valid.
  93937. */
  93938. function isValidSpacing(left, right, expected) {
  93939. return astUtils.isClosingBraceToken(right) || !astUtils.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === expected;
  93940. }
  93941. /**
  93942. * Check whether comments exist between the given 2 tokens.
  93943. * @param {Token} left The left token to check.
  93944. * @param {Token} right The right token to check.
  93945. * @returns {boolean} `true` if comments exist between the given 2 tokens.
  93946. */
  93947. function commentsExistBetween(left, right) {
  93948. return sourceCode.getFirstTokenBetween(left, right, {
  93949. includeComments: true,
  93950. filter: astUtils.isCommentToken
  93951. }) !== null;
  93952. }
  93953. /**
  93954. * Fix the spacing between the given 2 tokens.
  93955. * @param {RuleFixer} fixer The fixer to fix.
  93956. * @param {Token} left The left token of fix range.
  93957. * @param {Token} right The right token of fix range.
  93958. * @param {boolean} spacing The spacing style. `true` if there should be a space.
  93959. * @returns {Fix|null} The fix object.
  93960. */
  93961. function _fix(fixer, left, right, spacing) {
  93962. if (commentsExistBetween(left, right)) {
  93963. return null;
  93964. }
  93965. if (spacing) {
  93966. return fixer.insertTextAfter(left, " ");
  93967. }
  93968. return fixer.removeRange([left.range[1], right.range[0]]);
  93969. }
  93970. return {
  93971. SwitchCase: function SwitchCase(node) {
  93972. var colonToken = getColonToken(node);
  93973. var beforeToken = sourceCode.getTokenBefore(colonToken);
  93974. var afterToken = sourceCode.getTokenAfter(colonToken);
  93975. if (!isValidSpacing(beforeToken, colonToken, beforeSpacing)) {
  93976. context.report({
  93977. node: node,
  93978. loc: colonToken.loc,
  93979. message: "{{verb}} space(s) before this colon.",
  93980. data: { verb: beforeSpacing ? "Expected" : "Unexpected" },
  93981. fix: function fix(fixer) {
  93982. return _fix(fixer, beforeToken, colonToken, beforeSpacing);
  93983. }
  93984. });
  93985. }
  93986. if (!isValidSpacing(colonToken, afterToken, afterSpacing)) {
  93987. context.report({
  93988. node: node,
  93989. loc: colonToken.loc,
  93990. message: "{{verb}} space(s) after this colon.",
  93991. data: { verb: afterSpacing ? "Expected" : "Unexpected" },
  93992. fix: function fix(fixer) {
  93993. return _fix(fixer, colonToken, afterToken, afterSpacing);
  93994. }
  93995. });
  93996. }
  93997. }
  93998. };
  93999. }
  94000. };
  94001. },{"../util/ast-utils":405}],378:[function(require,module,exports){
  94002. /**
  94003. * @fileoverview Rule to enforce description with the `Symbol` object
  94004. * @author Jarek Rencz
  94005. */
  94006. "use strict";
  94007. //------------------------------------------------------------------------------
  94008. // Requirements
  94009. //------------------------------------------------------------------------------
  94010. var astUtils = require("../util/ast-utils");
  94011. //------------------------------------------------------------------------------
  94012. // Rule Definition
  94013. //------------------------------------------------------------------------------
  94014. module.exports = {
  94015. meta: {
  94016. type: "suggestion",
  94017. docs: {
  94018. description: "require symbol descriptions",
  94019. category: "ECMAScript 6",
  94020. recommended: false,
  94021. url: "https://eslint.org/docs/rules/symbol-description"
  94022. },
  94023. schema: []
  94024. },
  94025. create: function create(context) {
  94026. /**
  94027. * Reports if node does not conform the rule in case rule is set to
  94028. * report missing description
  94029. *
  94030. * @param {ASTNode} node - A CallExpression node to check.
  94031. * @returns {void}
  94032. */
  94033. function checkArgument(node) {
  94034. if (node.arguments.length === 0) {
  94035. context.report({
  94036. node: node,
  94037. message: "Expected Symbol to have a description."
  94038. });
  94039. }
  94040. }
  94041. return {
  94042. "Program:exit": function ProgramExit() {
  94043. var scope = context.getScope();
  94044. var variable = astUtils.getVariableByName(scope, "Symbol");
  94045. if (variable && variable.defs.length === 0) {
  94046. variable.references.forEach(function (reference) {
  94047. var node = reference.identifier;
  94048. if (astUtils.isCallee(node)) {
  94049. checkArgument(node.parent);
  94050. }
  94051. });
  94052. }
  94053. }
  94054. };
  94055. }
  94056. };
  94057. },{"../util/ast-utils":405}],379:[function(require,module,exports){
  94058. /**
  94059. * @fileoverview Rule to enforce spacing around embedded expressions of template strings
  94060. * @author Toru Nagashima
  94061. */
  94062. "use strict";
  94063. //------------------------------------------------------------------------------
  94064. // Requirements
  94065. //------------------------------------------------------------------------------
  94066. var astUtils = require("../util/ast-utils");
  94067. //------------------------------------------------------------------------------
  94068. // Helpers
  94069. //------------------------------------------------------------------------------
  94070. var OPEN_PAREN = /\$\{$/;
  94071. var CLOSE_PAREN = /^\}/;
  94072. //------------------------------------------------------------------------------
  94073. // Rule Definition
  94074. //------------------------------------------------------------------------------
  94075. module.exports = {
  94076. meta: {
  94077. type: "layout",
  94078. docs: {
  94079. description: "require or disallow spacing around embedded expressions of template strings",
  94080. category: "ECMAScript 6",
  94081. recommended: false,
  94082. url: "https://eslint.org/docs/rules/template-curly-spacing"
  94083. },
  94084. fixable: "whitespace",
  94085. schema: [{ enum: ["always", "never"] }]
  94086. },
  94087. create: function create(context) {
  94088. var sourceCode = context.getSourceCode();
  94089. var always = context.options[0] === "always";
  94090. var prefix = always ? "Expected" : "Unexpected";
  94091. /**
  94092. * Checks spacing before `}` of a given token.
  94093. * @param {Token} token - A token to check. This is a Template token.
  94094. * @returns {void}
  94095. */
  94096. function checkSpacingBefore(token) {
  94097. var prevToken = sourceCode.getTokenBefore(token);
  94098. if (prevToken && CLOSE_PAREN.test(token.value) && astUtils.isTokenOnSameLine(prevToken, token) && sourceCode.isSpaceBetweenTokens(prevToken, token) !== always) {
  94099. context.report({
  94100. loc: token.loc.start,
  94101. message: "{{prefix}} space(s) before '}'.",
  94102. data: {
  94103. prefix: prefix
  94104. },
  94105. fix: function fix(fixer) {
  94106. if (always) {
  94107. return fixer.insertTextBefore(token, " ");
  94108. }
  94109. return fixer.removeRange([prevToken.range[1], token.range[0]]);
  94110. }
  94111. });
  94112. }
  94113. }
  94114. /**
  94115. * Checks spacing after `${` of a given token.
  94116. * @param {Token} token - A token to check. This is a Template token.
  94117. * @returns {void}
  94118. */
  94119. function checkSpacingAfter(token) {
  94120. var nextToken = sourceCode.getTokenAfter(token);
  94121. if (nextToken && OPEN_PAREN.test(token.value) && astUtils.isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetweenTokens(token, nextToken) !== always) {
  94122. context.report({
  94123. loc: {
  94124. line: token.loc.end.line,
  94125. column: token.loc.end.column - 2
  94126. },
  94127. message: "{{prefix}} space(s) after '${'.",
  94128. data: {
  94129. prefix: prefix
  94130. },
  94131. fix: function fix(fixer) {
  94132. if (always) {
  94133. return fixer.insertTextAfter(token, " ");
  94134. }
  94135. return fixer.removeRange([token.range[1], nextToken.range[0]]);
  94136. }
  94137. });
  94138. }
  94139. }
  94140. return {
  94141. TemplateElement: function TemplateElement(node) {
  94142. var token = sourceCode.getFirstToken(node);
  94143. checkSpacingBefore(token);
  94144. checkSpacingAfter(token);
  94145. }
  94146. };
  94147. }
  94148. };
  94149. },{"../util/ast-utils":405}],380:[function(require,module,exports){
  94150. /**
  94151. * @fileoverview Rule to check spacing between template tags and their literals
  94152. * @author Jonathan Wilsson
  94153. */
  94154. "use strict";
  94155. //------------------------------------------------------------------------------
  94156. // Rule Definition
  94157. //------------------------------------------------------------------------------
  94158. module.exports = {
  94159. meta: {
  94160. type: "layout",
  94161. docs: {
  94162. description: "require or disallow spacing between template tags and their literals",
  94163. category: "Stylistic Issues",
  94164. recommended: false,
  94165. url: "https://eslint.org/docs/rules/template-tag-spacing"
  94166. },
  94167. fixable: "whitespace",
  94168. schema: [{ enum: ["always", "never"] }]
  94169. },
  94170. create: function create(context) {
  94171. var never = context.options[0] !== "always";
  94172. var sourceCode = context.getSourceCode();
  94173. /**
  94174. * Check if a space is present between a template tag and its literal
  94175. * @param {ASTNode} node node to evaluate
  94176. * @returns {void}
  94177. * @private
  94178. */
  94179. function checkSpacing(node) {
  94180. var tagToken = sourceCode.getTokenBefore(node.quasi);
  94181. var literalToken = sourceCode.getFirstToken(node.quasi);
  94182. var hasWhitespace = sourceCode.isSpaceBetweenTokens(tagToken, literalToken);
  94183. if (never && hasWhitespace) {
  94184. context.report({
  94185. node: node,
  94186. loc: tagToken.loc.start,
  94187. message: "Unexpected space between template tag and template literal.",
  94188. fix: function fix(fixer) {
  94189. var comments = sourceCode.getCommentsBefore(node.quasi);
  94190. // Don't fix anything if there's a single line comment after the template tag
  94191. if (comments.some(function (comment) {
  94192. return comment.type === "Line";
  94193. })) {
  94194. return null;
  94195. }
  94196. return fixer.replaceTextRange([tagToken.range[1], literalToken.range[0]], comments.reduce(function (text, comment) {
  94197. return text + sourceCode.getText(comment);
  94198. }, ""));
  94199. }
  94200. });
  94201. } else if (!never && !hasWhitespace) {
  94202. context.report({
  94203. node: node,
  94204. loc: tagToken.loc.start,
  94205. message: "Missing space between template tag and template literal.",
  94206. fix: function fix(fixer) {
  94207. return fixer.insertTextAfter(tagToken, " ");
  94208. }
  94209. });
  94210. }
  94211. }
  94212. return {
  94213. TaggedTemplateExpression: checkSpacing
  94214. };
  94215. }
  94216. };
  94217. },{}],381:[function(require,module,exports){
  94218. /**
  94219. * @fileoverview Require or disallow Unicode BOM
  94220. * @author Andrew Johnston <https://github.com/ehjay>
  94221. */
  94222. "use strict";
  94223. //------------------------------------------------------------------------------
  94224. // Rule Definition
  94225. //------------------------------------------------------------------------------
  94226. module.exports = {
  94227. meta: {
  94228. type: "layout",
  94229. docs: {
  94230. description: "require or disallow Unicode byte order mark (BOM)",
  94231. category: "Stylistic Issues",
  94232. recommended: false,
  94233. url: "https://eslint.org/docs/rules/unicode-bom"
  94234. },
  94235. fixable: "whitespace",
  94236. schema: [{
  94237. enum: ["always", "never"]
  94238. }]
  94239. },
  94240. create: function create(context) {
  94241. //--------------------------------------------------------------------------
  94242. // Public
  94243. //--------------------------------------------------------------------------
  94244. return {
  94245. Program: function checkUnicodeBOM(node) {
  94246. var sourceCode = context.getSourceCode(),
  94247. location = { column: 0, line: 1 },
  94248. requireBOM = context.options[0] || "never";
  94249. if (!sourceCode.hasBOM && requireBOM === "always") {
  94250. context.report({
  94251. node: node,
  94252. loc: location,
  94253. message: "Expected Unicode BOM (Byte Order Mark).",
  94254. fix: function fix(fixer) {
  94255. return fixer.insertTextBeforeRange([0, 1], "\uFEFF");
  94256. }
  94257. });
  94258. } else if (sourceCode.hasBOM && requireBOM === "never") {
  94259. context.report({
  94260. node: node,
  94261. loc: location,
  94262. message: "Unexpected Unicode BOM (Byte Order Mark).",
  94263. fix: function fix(fixer) {
  94264. return fixer.removeRange([-1, 0]);
  94265. }
  94266. });
  94267. }
  94268. }
  94269. };
  94270. }
  94271. };
  94272. },{}],382:[function(require,module,exports){
  94273. /**
  94274. * @fileoverview Rule to flag comparisons to the value NaN
  94275. * @author James Allardice
  94276. */
  94277. "use strict";
  94278. //------------------------------------------------------------------------------
  94279. // Rule Definition
  94280. //------------------------------------------------------------------------------
  94281. module.exports = {
  94282. meta: {
  94283. type: "problem",
  94284. docs: {
  94285. description: "require calls to `isNaN()` when checking for `NaN`",
  94286. category: "Possible Errors",
  94287. recommended: true,
  94288. url: "https://eslint.org/docs/rules/use-isnan"
  94289. },
  94290. schema: []
  94291. },
  94292. create: function create(context) {
  94293. return {
  94294. BinaryExpression: function BinaryExpression(node) {
  94295. if (/^(?:[<>]|[!=]=)=?$/.test(node.operator) && (node.left.name === "NaN" || node.right.name === "NaN")) {
  94296. context.report({ node: node, message: "Use the isNaN function to compare with NaN." });
  94297. }
  94298. }
  94299. };
  94300. }
  94301. };
  94302. },{}],383:[function(require,module,exports){
  94303. /**
  94304. * @fileoverview Validates JSDoc comments are syntactically correct
  94305. * @author Nicholas C. Zakas
  94306. */
  94307. "use strict";
  94308. //------------------------------------------------------------------------------
  94309. // Requirements
  94310. //------------------------------------------------------------------------------
  94311. var doctrine = require("doctrine");
  94312. //------------------------------------------------------------------------------
  94313. // Rule Definition
  94314. //------------------------------------------------------------------------------
  94315. module.exports = {
  94316. meta: {
  94317. type: "suggestion",
  94318. docs: {
  94319. description: "enforce valid JSDoc comments",
  94320. category: "Possible Errors",
  94321. recommended: false,
  94322. url: "https://eslint.org/docs/rules/valid-jsdoc"
  94323. },
  94324. schema: [{
  94325. type: "object",
  94326. properties: {
  94327. prefer: {
  94328. type: "object",
  94329. additionalProperties: {
  94330. type: "string"
  94331. }
  94332. },
  94333. preferType: {
  94334. type: "object",
  94335. additionalProperties: {
  94336. type: "string"
  94337. }
  94338. },
  94339. requireReturn: {
  94340. type: "boolean"
  94341. },
  94342. requireParamDescription: {
  94343. type: "boolean"
  94344. },
  94345. requireReturnDescription: {
  94346. type: "boolean"
  94347. },
  94348. matchDescription: {
  94349. type: "string"
  94350. },
  94351. requireReturnType: {
  94352. type: "boolean"
  94353. },
  94354. requireParamType: {
  94355. type: "boolean"
  94356. }
  94357. },
  94358. additionalProperties: false
  94359. }],
  94360. fixable: "code",
  94361. deprecated: true,
  94362. replacedBy: []
  94363. },
  94364. create: function create(context) {
  94365. var options = context.options[0] || {},
  94366. prefer = options.prefer || {},
  94367. sourceCode = context.getSourceCode(),
  94368. // these both default to true, so you have to explicitly make them false
  94369. requireReturn = options.requireReturn !== false,
  94370. requireParamDescription = options.requireParamDescription !== false,
  94371. requireReturnDescription = options.requireReturnDescription !== false,
  94372. requireReturnType = options.requireReturnType !== false,
  94373. requireParamType = options.requireParamType !== false,
  94374. preferType = options.preferType || {},
  94375. checkPreferType = Object.keys(preferType).length !== 0;
  94376. //--------------------------------------------------------------------------
  94377. // Helpers
  94378. //--------------------------------------------------------------------------
  94379. // Using a stack to store if a function returns or not (handling nested functions)
  94380. var fns = [];
  94381. /**
  94382. * Check if node type is a Class
  94383. * @param {ASTNode} node node to check.
  94384. * @returns {boolean} True is its a class
  94385. * @private
  94386. */
  94387. function isTypeClass(node) {
  94388. return node.type === "ClassExpression" || node.type === "ClassDeclaration";
  94389. }
  94390. /**
  94391. * When parsing a new function, store it in our function stack.
  94392. * @param {ASTNode} node A function node to check.
  94393. * @returns {void}
  94394. * @private
  94395. */
  94396. function startFunction(node) {
  94397. fns.push({
  94398. returnPresent: node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement" || isTypeClass(node) || node.async
  94399. });
  94400. }
  94401. /**
  94402. * Indicate that return has been found in the current function.
  94403. * @param {ASTNode} node The return node.
  94404. * @returns {void}
  94405. * @private
  94406. */
  94407. function addReturn(node) {
  94408. var functionState = fns[fns.length - 1];
  94409. if (functionState && node.argument !== null) {
  94410. functionState.returnPresent = true;
  94411. }
  94412. }
  94413. /**
  94414. * Check if return tag type is void or undefined
  94415. * @param {Object} tag JSDoc tag
  94416. * @returns {boolean} True if its of type void or undefined
  94417. * @private
  94418. */
  94419. function isValidReturnType(tag) {
  94420. return tag.type === null || tag.type.name === "void" || tag.type.type === "UndefinedLiteral";
  94421. }
  94422. /**
  94423. * Check if type should be validated based on some exceptions
  94424. * @param {Object} type JSDoc tag
  94425. * @returns {boolean} True if it can be validated
  94426. * @private
  94427. */
  94428. function canTypeBeValidated(type) {
  94429. return type !== "UndefinedLiteral" && // {undefined} as there is no name property available.
  94430. type !== "NullLiteral" && // {null}
  94431. type !== "NullableLiteral" && // {?}
  94432. type !== "FunctionType" && // {function(a)}
  94433. type !== "AllLiteral"; // {*}
  94434. }
  94435. /**
  94436. * Extract the current and expected type based on the input type object
  94437. * @param {Object} type JSDoc tag
  94438. * @returns {{currentType: Doctrine.Type, expectedTypeName: string}} The current type annotation and
  94439. * the expected name of the annotation
  94440. * @private
  94441. */
  94442. function getCurrentExpectedTypes(type) {
  94443. var currentType = void 0;
  94444. if (type.name) {
  94445. currentType = type;
  94446. } else if (type.expression) {
  94447. currentType = type.expression;
  94448. }
  94449. return {
  94450. currentType: currentType,
  94451. expectedTypeName: currentType && preferType[currentType.name]
  94452. };
  94453. }
  94454. /**
  94455. * Gets the location of a JSDoc node in a file
  94456. * @param {Token} jsdocComment The comment that this node is parsed from
  94457. * @param {{range: number[]}} parsedJsdocNode A tag or other node which was parsed from this comment
  94458. * @returns {{start: SourceLocation, end: SourceLocation}} The 0-based source location for the tag
  94459. */
  94460. function getAbsoluteRange(jsdocComment, parsedJsdocNode) {
  94461. return {
  94462. start: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[0]),
  94463. end: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[1])
  94464. };
  94465. }
  94466. /**
  94467. * Validate type for a given JSDoc node
  94468. * @param {Object} jsdocNode JSDoc node
  94469. * @param {Object} type JSDoc tag
  94470. * @returns {void}
  94471. * @private
  94472. */
  94473. function validateType(jsdocNode, type) {
  94474. if (!type || !canTypeBeValidated(type.type)) {
  94475. return;
  94476. }
  94477. var typesToCheck = [];
  94478. var elements = [];
  94479. switch (type.type) {
  94480. case "TypeApplication":
  94481. // {Array.<String>}
  94482. elements = type.applications[0].type === "UnionType" ? type.applications[0].elements : type.applications;
  94483. typesToCheck.push(getCurrentExpectedTypes(type));
  94484. break;
  94485. case "RecordType":
  94486. // {{20:String}}
  94487. elements = type.fields;
  94488. break;
  94489. case "UnionType": // {String|number|Test}
  94490. case "ArrayType":
  94491. // {[String, number, Test]}
  94492. elements = type.elements;
  94493. break;
  94494. case "FieldType":
  94495. // Array.<{count: number, votes: number}>
  94496. if (type.value) {
  94497. typesToCheck.push(getCurrentExpectedTypes(type.value));
  94498. }
  94499. break;
  94500. default:
  94501. typesToCheck.push(getCurrentExpectedTypes(type));
  94502. }
  94503. elements.forEach(validateType.bind(null, jsdocNode));
  94504. typesToCheck.forEach(function (typeToCheck) {
  94505. if (typeToCheck.expectedTypeName && typeToCheck.expectedTypeName !== typeToCheck.currentType.name) {
  94506. context.report({
  94507. node: jsdocNode,
  94508. message: "Use '{{expectedTypeName}}' instead of '{{currentTypeName}}'.",
  94509. loc: getAbsoluteRange(jsdocNode, typeToCheck.currentType),
  94510. data: {
  94511. currentTypeName: typeToCheck.currentType.name,
  94512. expectedTypeName: typeToCheck.expectedTypeName
  94513. },
  94514. fix: function fix(fixer) {
  94515. return fixer.replaceTextRange(typeToCheck.currentType.range.map(function (indexInComment) {
  94516. return jsdocNode.range[0] + 2 + indexInComment;
  94517. }), typeToCheck.expectedTypeName);
  94518. }
  94519. });
  94520. }
  94521. });
  94522. }
  94523. /**
  94524. * Validate the JSDoc node and output warnings if anything is wrong.
  94525. * @param {ASTNode} node The AST node to check.
  94526. * @returns {void}
  94527. * @private
  94528. */
  94529. function checkJSDoc(node) {
  94530. var jsdocNode = sourceCode.getJSDocComment(node),
  94531. functionData = fns.pop(),
  94532. paramTagsByName = Object.create(null),
  94533. paramTags = [];
  94534. var hasReturns = false,
  94535. returnsTag = void 0,
  94536. hasConstructor = false,
  94537. isInterface = false,
  94538. isOverride = false,
  94539. isAbstract = false;
  94540. // make sure only to validate JSDoc comments
  94541. if (jsdocNode) {
  94542. var jsdoc = void 0;
  94543. try {
  94544. jsdoc = doctrine.parse(jsdocNode.value, {
  94545. strict: true,
  94546. unwrap: true,
  94547. sloppy: true,
  94548. range: true
  94549. });
  94550. } catch (ex) {
  94551. if (/braces/i.test(ex.message)) {
  94552. context.report({ node: jsdocNode, message: "JSDoc type missing brace." });
  94553. } else {
  94554. context.report({ node: jsdocNode, message: "JSDoc syntax error." });
  94555. }
  94556. return;
  94557. }
  94558. jsdoc.tags.forEach(function (tag) {
  94559. switch (tag.title.toLowerCase()) {
  94560. case "param":
  94561. case "arg":
  94562. case "argument":
  94563. paramTags.push(tag);
  94564. break;
  94565. case "return":
  94566. case "returns":
  94567. hasReturns = true;
  94568. returnsTag = tag;
  94569. break;
  94570. case "constructor":
  94571. case "class":
  94572. hasConstructor = true;
  94573. break;
  94574. case "override":
  94575. case "inheritdoc":
  94576. isOverride = true;
  94577. break;
  94578. case "abstract":
  94579. case "virtual":
  94580. isAbstract = true;
  94581. break;
  94582. case "interface":
  94583. isInterface = true;
  94584. break;
  94585. // no default
  94586. }
  94587. // check tag preferences
  94588. if (Object.prototype.hasOwnProperty.call(prefer, tag.title) && tag.title !== prefer[tag.title]) {
  94589. var entireTagRange = getAbsoluteRange(jsdocNode, tag);
  94590. context.report({
  94591. node: jsdocNode,
  94592. message: "Use @{{name}} instead.",
  94593. loc: {
  94594. start: entireTagRange.start,
  94595. end: {
  94596. line: entireTagRange.start.line,
  94597. column: entireTagRange.start.column + ("@" + tag.title).length
  94598. }
  94599. },
  94600. data: { name: prefer[tag.title] },
  94601. fix: function fix(fixer) {
  94602. return fixer.replaceTextRange([jsdocNode.range[0] + tag.range[0] + 3, jsdocNode.range[0] + tag.range[0] + tag.title.length + 3], prefer[tag.title]);
  94603. }
  94604. });
  94605. }
  94606. // validate the types
  94607. if (checkPreferType && tag.type) {
  94608. validateType(jsdocNode, tag.type);
  94609. }
  94610. });
  94611. paramTags.forEach(function (param) {
  94612. if (requireParamType && !param.type) {
  94613. context.report({
  94614. node: jsdocNode,
  94615. message: "Missing JSDoc parameter type for '{{name}}'.",
  94616. loc: getAbsoluteRange(jsdocNode, param),
  94617. data: { name: param.name }
  94618. });
  94619. }
  94620. if (!param.description && requireParamDescription) {
  94621. context.report({
  94622. node: jsdocNode,
  94623. message: "Missing JSDoc parameter description for '{{name}}'.",
  94624. loc: getAbsoluteRange(jsdocNode, param),
  94625. data: { name: param.name }
  94626. });
  94627. }
  94628. if (paramTagsByName[param.name]) {
  94629. context.report({
  94630. node: jsdocNode,
  94631. message: "Duplicate JSDoc parameter '{{name}}'.",
  94632. loc: getAbsoluteRange(jsdocNode, param),
  94633. data: { name: param.name }
  94634. });
  94635. } else if (param.name.indexOf(".") === -1) {
  94636. paramTagsByName[param.name] = param;
  94637. }
  94638. });
  94639. if (hasReturns) {
  94640. if (!requireReturn && !functionData.returnPresent && (returnsTag.type === null || !isValidReturnType(returnsTag)) && !isAbstract) {
  94641. context.report({
  94642. node: jsdocNode,
  94643. message: "Unexpected @{{title}} tag; function has no return statement.",
  94644. loc: getAbsoluteRange(jsdocNode, returnsTag),
  94645. data: {
  94646. title: returnsTag.title
  94647. }
  94648. });
  94649. } else {
  94650. if (requireReturnType && !returnsTag.type) {
  94651. context.report({ node: jsdocNode, message: "Missing JSDoc return type." });
  94652. }
  94653. if (!isValidReturnType(returnsTag) && !returnsTag.description && requireReturnDescription) {
  94654. context.report({ node: jsdocNode, message: "Missing JSDoc return description." });
  94655. }
  94656. }
  94657. }
  94658. // check for functions missing @returns
  94659. if (!isOverride && !hasReturns && !hasConstructor && !isInterface && node.parent.kind !== "get" && node.parent.kind !== "constructor" && node.parent.kind !== "set" && !isTypeClass(node)) {
  94660. if (requireReturn || functionData.returnPresent && !node.async) {
  94661. context.report({
  94662. node: jsdocNode,
  94663. message: "Missing JSDoc @{{returns}} for function.",
  94664. data: {
  94665. returns: prefer.returns || "returns"
  94666. }
  94667. });
  94668. }
  94669. }
  94670. // check the parameters
  94671. var jsdocParamNames = Object.keys(paramTagsByName);
  94672. if (node.params) {
  94673. node.params.forEach(function (param, paramsIndex) {
  94674. var bindingParam = param.type === "AssignmentPattern" ? param.left : param;
  94675. // TODO(nzakas): Figure out logical things to do with destructured, default, rest params
  94676. if (bindingParam.type === "Identifier") {
  94677. var name = bindingParam.name;
  94678. if (jsdocParamNames[paramsIndex] && name !== jsdocParamNames[paramsIndex]) {
  94679. context.report({
  94680. node: jsdocNode,
  94681. message: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",
  94682. loc: getAbsoluteRange(jsdocNode, paramTagsByName[jsdocParamNames[paramsIndex]]),
  94683. data: {
  94684. name: name,
  94685. jsdocName: jsdocParamNames[paramsIndex]
  94686. }
  94687. });
  94688. } else if (!paramTagsByName[name] && !isOverride) {
  94689. context.report({
  94690. node: jsdocNode,
  94691. message: "Missing JSDoc for parameter '{{name}}'.",
  94692. data: {
  94693. name: name
  94694. }
  94695. });
  94696. }
  94697. }
  94698. });
  94699. }
  94700. if (options.matchDescription) {
  94701. var regex = new RegExp(options.matchDescription);
  94702. if (!regex.test(jsdoc.description)) {
  94703. context.report({ node: jsdocNode, message: "JSDoc description does not satisfy the regex pattern." });
  94704. }
  94705. }
  94706. }
  94707. }
  94708. //--------------------------------------------------------------------------
  94709. // Public
  94710. //--------------------------------------------------------------------------
  94711. return {
  94712. ArrowFunctionExpression: startFunction,
  94713. FunctionExpression: startFunction,
  94714. FunctionDeclaration: startFunction,
  94715. ClassExpression: startFunction,
  94716. ClassDeclaration: startFunction,
  94717. "ArrowFunctionExpression:exit": checkJSDoc,
  94718. "FunctionExpression:exit": checkJSDoc,
  94719. "FunctionDeclaration:exit": checkJSDoc,
  94720. "ClassExpression:exit": checkJSDoc,
  94721. "ClassDeclaration:exit": checkJSDoc,
  94722. ReturnStatement: addReturn
  94723. };
  94724. }
  94725. };
  94726. },{"doctrine":55}],384:[function(require,module,exports){
  94727. /**
  94728. * @fileoverview Ensures that the results of typeof are compared against a valid string
  94729. * @author Ian Christian Myers
  94730. */
  94731. "use strict";
  94732. //------------------------------------------------------------------------------
  94733. // Rule Definition
  94734. //------------------------------------------------------------------------------
  94735. module.exports = {
  94736. meta: {
  94737. type: "problem",
  94738. docs: {
  94739. description: "enforce comparing `typeof` expressions against valid strings",
  94740. category: "Possible Errors",
  94741. recommended: true,
  94742. url: "https://eslint.org/docs/rules/valid-typeof"
  94743. },
  94744. schema: [{
  94745. type: "object",
  94746. properties: {
  94747. requireStringLiterals: {
  94748. type: "boolean"
  94749. }
  94750. },
  94751. additionalProperties: false
  94752. }]
  94753. },
  94754. create: function create(context) {
  94755. var VALID_TYPES = ["symbol", "undefined", "object", "boolean", "number", "string", "function"],
  94756. OPERATORS = ["==", "===", "!=", "!=="];
  94757. var requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
  94758. /**
  94759. * Determines whether a node is a typeof expression.
  94760. * @param {ASTNode} node The node
  94761. * @returns {boolean} `true` if the node is a typeof expression
  94762. */
  94763. function isTypeofExpression(node) {
  94764. return node.type === "UnaryExpression" && node.operator === "typeof";
  94765. }
  94766. //--------------------------------------------------------------------------
  94767. // Public
  94768. //--------------------------------------------------------------------------
  94769. return {
  94770. UnaryExpression: function UnaryExpression(node) {
  94771. if (isTypeofExpression(node)) {
  94772. var parent = context.getAncestors().pop();
  94773. if (parent.type === "BinaryExpression" && OPERATORS.indexOf(parent.operator) !== -1) {
  94774. var sibling = parent.left === node ? parent.right : parent.left;
  94775. if (sibling.type === "Literal" || sibling.type === "TemplateLiteral" && !sibling.expressions.length) {
  94776. var value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked;
  94777. if (VALID_TYPES.indexOf(value) === -1) {
  94778. context.report({ node: sibling, message: "Invalid typeof comparison value." });
  94779. }
  94780. } else if (requireStringLiterals && !isTypeofExpression(sibling)) {
  94781. context.report({ node: sibling, message: "Typeof comparisons should be to string literals." });
  94782. }
  94783. }
  94784. }
  94785. }
  94786. };
  94787. }
  94788. };
  94789. },{}],385:[function(require,module,exports){
  94790. /**
  94791. * @fileoverview Rule to enforce var declarations are only at the top of a function.
  94792. * @author Danny Fritz
  94793. * @author Gyandeep Singh
  94794. */
  94795. "use strict";
  94796. //------------------------------------------------------------------------------
  94797. // Rule Definition
  94798. //------------------------------------------------------------------------------
  94799. module.exports = {
  94800. meta: {
  94801. type: "suggestion",
  94802. docs: {
  94803. description: "require `var` declarations be placed at the top of their containing scope",
  94804. category: "Best Practices",
  94805. recommended: false,
  94806. url: "https://eslint.org/docs/rules/vars-on-top"
  94807. },
  94808. schema: []
  94809. },
  94810. create: function create(context) {
  94811. var errorMessage = "All 'var' declarations must be at the top of the function scope.";
  94812. //--------------------------------------------------------------------------
  94813. // Helpers
  94814. //--------------------------------------------------------------------------
  94815. /**
  94816. * @param {ASTNode} node - any node
  94817. * @returns {boolean} whether the given node structurally represents a directive
  94818. */
  94819. function looksLikeDirective(node) {
  94820. return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
  94821. }
  94822. /**
  94823. * Check to see if its a ES6 import declaration
  94824. * @param {ASTNode} node - any node
  94825. * @returns {boolean} whether the given node represents a import declaration
  94826. */
  94827. function looksLikeImport(node) {
  94828. return node.type === "ImportDeclaration" || node.type === "ImportSpecifier" || node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier";
  94829. }
  94830. /**
  94831. * Checks whether a given node is a variable declaration or not.
  94832. *
  94833. * @param {ASTNode} node - any node
  94834. * @returns {boolean} `true` if the node is a variable declaration.
  94835. */
  94836. function isVariableDeclaration(node) {
  94837. return node.type === "VariableDeclaration" || node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration";
  94838. }
  94839. /**
  94840. * Checks whether this variable is on top of the block body
  94841. * @param {ASTNode} node - The node to check
  94842. * @param {ASTNode[]} statements - collection of ASTNodes for the parent node block
  94843. * @returns {boolean} True if var is on top otherwise false
  94844. */
  94845. function isVarOnTop(node, statements) {
  94846. var l = statements.length;
  94847. var i = 0;
  94848. // skip over directives
  94849. for (; i < l; ++i) {
  94850. if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) {
  94851. break;
  94852. }
  94853. }
  94854. for (; i < l; ++i) {
  94855. if (!isVariableDeclaration(statements[i])) {
  94856. return false;
  94857. }
  94858. if (statements[i] === node) {
  94859. return true;
  94860. }
  94861. }
  94862. return false;
  94863. }
  94864. /**
  94865. * Checks whether variable is on top at the global level
  94866. * @param {ASTNode} node - The node to check
  94867. * @param {ASTNode} parent - Parent of the node
  94868. * @returns {void}
  94869. */
  94870. function globalVarCheck(node, parent) {
  94871. if (!isVarOnTop(node, parent.body)) {
  94872. context.report({ node: node, message: errorMessage });
  94873. }
  94874. }
  94875. /**
  94876. * Checks whether variable is on top at functional block scope level
  94877. * @param {ASTNode} node - The node to check
  94878. * @param {ASTNode} parent - Parent of the node
  94879. * @param {ASTNode} grandParent - Parent of the node's parent
  94880. * @returns {void}
  94881. */
  94882. function blockScopeVarCheck(node, parent, grandParent) {
  94883. if (!(/Function/.test(grandParent.type) && parent.type === "BlockStatement" && isVarOnTop(node, parent.body))) {
  94884. context.report({ node: node, message: errorMessage });
  94885. }
  94886. }
  94887. //--------------------------------------------------------------------------
  94888. // Public API
  94889. //--------------------------------------------------------------------------
  94890. return {
  94891. "VariableDeclaration[kind='var']": function VariableDeclarationKindVar(node) {
  94892. if (node.parent.type === "ExportNamedDeclaration") {
  94893. globalVarCheck(node.parent, node.parent.parent);
  94894. } else if (node.parent.type === "Program") {
  94895. globalVarCheck(node, node.parent);
  94896. } else {
  94897. blockScopeVarCheck(node, node.parent, node.parent.parent);
  94898. }
  94899. }
  94900. };
  94901. }
  94902. };
  94903. },{}],386:[function(require,module,exports){
  94904. /**
  94905. * @fileoverview Rule to flag when IIFE is not wrapped in parens
  94906. * @author Ilya Volodin
  94907. */
  94908. "use strict";
  94909. //------------------------------------------------------------------------------
  94910. // Requirements
  94911. //------------------------------------------------------------------------------
  94912. var astUtils = require("../util/ast-utils");
  94913. //------------------------------------------------------------------------------
  94914. // Rule Definition
  94915. //------------------------------------------------------------------------------
  94916. module.exports = {
  94917. meta: {
  94918. type: "layout",
  94919. docs: {
  94920. description: "require parentheses around immediate `function` invocations",
  94921. category: "Best Practices",
  94922. recommended: false,
  94923. url: "https://eslint.org/docs/rules/wrap-iife"
  94924. },
  94925. schema: [{
  94926. enum: ["outside", "inside", "any"]
  94927. }, {
  94928. type: "object",
  94929. properties: {
  94930. functionPrototypeMethods: {
  94931. type: "boolean"
  94932. }
  94933. },
  94934. additionalProperties: false
  94935. }],
  94936. fixable: "code"
  94937. },
  94938. create: function create(context) {
  94939. var style = context.options[0] || "outside";
  94940. var includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods || false;
  94941. var sourceCode = context.getSourceCode();
  94942. /**
  94943. * Check if the node is wrapped in ()
  94944. * @param {ASTNode} node node to evaluate
  94945. * @returns {boolean} True if it is wrapped
  94946. * @private
  94947. */
  94948. function wrapped(node) {
  94949. return astUtils.isParenthesised(sourceCode, node);
  94950. }
  94951. /**
  94952. * Get the function node from an IIFE
  94953. * @param {ASTNode} node node to evaluate
  94954. * @returns {ASTNode} node that is the function expression of the given IIFE, or null if none exist
  94955. */
  94956. function getFunctionNodeFromIIFE(node) {
  94957. var callee = node.callee;
  94958. if (callee.type === "FunctionExpression") {
  94959. return callee;
  94960. }
  94961. if (includeFunctionPrototypeMethods && callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && (astUtils.getStaticPropertyName(callee) === "call" || astUtils.getStaticPropertyName(callee) === "apply")) {
  94962. return callee.object;
  94963. }
  94964. return null;
  94965. }
  94966. return {
  94967. CallExpression: function CallExpression(node) {
  94968. var innerNode = getFunctionNodeFromIIFE(node);
  94969. if (!innerNode) {
  94970. return;
  94971. }
  94972. var callExpressionWrapped = wrapped(node),
  94973. functionExpressionWrapped = wrapped(innerNode);
  94974. if (!callExpressionWrapped && !functionExpressionWrapped) {
  94975. context.report({
  94976. node: node,
  94977. message: "Wrap an immediate function invocation in parentheses.",
  94978. fix: function fix(fixer) {
  94979. var nodeToSurround = style === "inside" ? innerNode : node;
  94980. return fixer.replaceText(nodeToSurround, "(" + sourceCode.getText(nodeToSurround) + ")");
  94981. }
  94982. });
  94983. } else if (style === "inside" && !functionExpressionWrapped) {
  94984. context.report({
  94985. node: node,
  94986. message: "Wrap only the function expression in parens.",
  94987. fix: function fix(fixer) {
  94988. /*
  94989. * The outer call expression will always be wrapped at this point.
  94990. * Replace the range between the end of the function expression and the end of the call expression.
  94991. * for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`.
  94992. * Replace the parens from the outer expression, and parenthesize the function expression.
  94993. */
  94994. var parenAfter = sourceCode.getTokenAfter(node);
  94995. return fixer.replaceTextRange([innerNode.range[1], parenAfter.range[1]], ")" + sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0]));
  94996. }
  94997. });
  94998. } else if (style === "outside" && !callExpressionWrapped) {
  94999. context.report({
  95000. node: node,
  95001. message: "Move the invocation into the parens that contain the function.",
  95002. fix: function fix(fixer) {
  95003. /*
  95004. * The inner function expression will always be wrapped at this point.
  95005. * It's only necessary to replace the range between the end of the function expression
  95006. * and the call expression. For example, in `(function(foo) {})(bar)`, the range `)(bar)`
  95007. * should get replaced with `(bar))`.
  95008. */
  95009. var parenAfter = sourceCode.getTokenAfter(innerNode);
  95010. return fixer.replaceTextRange([parenAfter.range[0], node.range[1]], sourceCode.getText().slice(parenAfter.range[1], node.range[1]) + ")");
  95011. }
  95012. });
  95013. }
  95014. }
  95015. };
  95016. }
  95017. };
  95018. },{"../util/ast-utils":405}],387:[function(require,module,exports){
  95019. /**
  95020. * @fileoverview Rule to flag when regex literals are not wrapped in parens
  95021. * @author Matt DuVall <http://www.mattduvall.com>
  95022. */
  95023. "use strict";
  95024. //------------------------------------------------------------------------------
  95025. // Rule Definition
  95026. //------------------------------------------------------------------------------
  95027. module.exports = {
  95028. meta: {
  95029. type: "layout",
  95030. docs: {
  95031. description: "require parenthesis around regex literals",
  95032. category: "Stylistic Issues",
  95033. recommended: false,
  95034. url: "https://eslint.org/docs/rules/wrap-regex"
  95035. },
  95036. schema: [],
  95037. fixable: "code",
  95038. messages: {
  95039. requireParens: "Wrap the regexp literal in parens to disambiguate the slash."
  95040. }
  95041. },
  95042. create: function create(context) {
  95043. var sourceCode = context.getSourceCode();
  95044. return {
  95045. Literal: function Literal(node) {
  95046. var token = sourceCode.getFirstToken(node),
  95047. nodeType = token.type;
  95048. if (nodeType === "RegularExpression") {
  95049. var beforeToken = sourceCode.getTokenBefore(node);
  95050. var afterToken = sourceCode.getTokenAfter(node);
  95051. var ancestors = context.getAncestors();
  95052. var grandparent = ancestors[ancestors.length - 1];
  95053. if (grandparent.type === "MemberExpression" && grandparent.object === node && !(beforeToken && beforeToken.value === "(" && afterToken && afterToken.value === ")")) {
  95054. context.report({
  95055. node: node,
  95056. messageId: "requireParens",
  95057. fix: function fix(fixer) {
  95058. return fixer.replaceText(node, "(" + sourceCode.getText(node) + ")");
  95059. }
  95060. });
  95061. }
  95062. }
  95063. }
  95064. };
  95065. }
  95066. };
  95067. },{}],388:[function(require,module,exports){
  95068. /**
  95069. * @fileoverview Rule to check the spacing around the * in yield* expressions.
  95070. * @author Bryan Smith
  95071. */
  95072. "use strict";
  95073. //------------------------------------------------------------------------------
  95074. // Rule Definition
  95075. //------------------------------------------------------------------------------
  95076. module.exports = {
  95077. meta: {
  95078. type: "layout",
  95079. docs: {
  95080. description: "require or disallow spacing around the `*` in `yield*` expressions",
  95081. category: "ECMAScript 6",
  95082. recommended: false,
  95083. url: "https://eslint.org/docs/rules/yield-star-spacing"
  95084. },
  95085. fixable: "whitespace",
  95086. schema: [{
  95087. oneOf: [{
  95088. enum: ["before", "after", "both", "neither"]
  95089. }, {
  95090. type: "object",
  95091. properties: {
  95092. before: { type: "boolean" },
  95093. after: { type: "boolean" }
  95094. },
  95095. additionalProperties: false
  95096. }]
  95097. }]
  95098. },
  95099. create: function create(context) {
  95100. var sourceCode = context.getSourceCode();
  95101. var mode = function (option) {
  95102. if (!option || typeof option === "string") {
  95103. return {
  95104. before: { before: true, after: false },
  95105. after: { before: false, after: true },
  95106. both: { before: true, after: true },
  95107. neither: { before: false, after: false }
  95108. }[option || "after"];
  95109. }
  95110. return option;
  95111. }(context.options[0]);
  95112. /**
  95113. * Checks the spacing between two tokens before or after the star token.
  95114. * @param {string} side Either "before" or "after".
  95115. * @param {Token} leftToken `function` keyword token if side is "before", or
  95116. * star token if side is "after".
  95117. * @param {Token} rightToken Star token if side is "before", or identifier
  95118. * token if side is "after".
  95119. * @returns {void}
  95120. */
  95121. function checkSpacing(side, leftToken, rightToken) {
  95122. if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken) !== mode[side]) {
  95123. var after = leftToken.value === "*";
  95124. var spaceRequired = mode[side];
  95125. var node = after ? leftToken : rightToken;
  95126. var type = spaceRequired ? "Missing" : "Unexpected";
  95127. var message = "{{type}} space {{side}} *.";
  95128. context.report({
  95129. node: node,
  95130. message: message,
  95131. data: {
  95132. type: type,
  95133. side: side
  95134. },
  95135. fix: function fix(fixer) {
  95136. if (spaceRequired) {
  95137. if (after) {
  95138. return fixer.insertTextAfter(node, " ");
  95139. }
  95140. return fixer.insertTextBefore(node, " ");
  95141. }
  95142. return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
  95143. }
  95144. });
  95145. }
  95146. }
  95147. /**
  95148. * Enforces the spacing around the star if node is a yield* expression.
  95149. * @param {ASTNode} node A yield expression node.
  95150. * @returns {void}
  95151. */
  95152. function checkExpression(node) {
  95153. if (!node.delegate) {
  95154. return;
  95155. }
  95156. var tokens = sourceCode.getFirstTokens(node, 3);
  95157. var yieldToken = tokens[0];
  95158. var starToken = tokens[1];
  95159. var nextToken = tokens[2];
  95160. checkSpacing("before", yieldToken, starToken);
  95161. checkSpacing("after", starToken, nextToken);
  95162. }
  95163. return {
  95164. YieldExpression: checkExpression
  95165. };
  95166. }
  95167. };
  95168. },{}],389:[function(require,module,exports){
  95169. /**
  95170. * @fileoverview Rule to require or disallow yoda comparisons
  95171. * @author Nicholas C. Zakas
  95172. */
  95173. "use strict";
  95174. //--------------------------------------------------------------------------
  95175. // Requirements
  95176. //--------------------------------------------------------------------------
  95177. var astUtils = require("../util/ast-utils");
  95178. //--------------------------------------------------------------------------
  95179. // Helpers
  95180. //--------------------------------------------------------------------------
  95181. /**
  95182. * Determines whether an operator is a comparison operator.
  95183. * @param {string} operator The operator to check.
  95184. * @returns {boolean} Whether or not it is a comparison operator.
  95185. */
  95186. function isComparisonOperator(operator) {
  95187. return (/^(==|===|!=|!==|<|>|<=|>=)$/.test(operator)
  95188. );
  95189. }
  95190. /**
  95191. * Determines whether an operator is an equality operator.
  95192. * @param {string} operator The operator to check.
  95193. * @returns {boolean} Whether or not it is an equality operator.
  95194. */
  95195. function isEqualityOperator(operator) {
  95196. return (/^(==|===)$/.test(operator)
  95197. );
  95198. }
  95199. /**
  95200. * Determines whether an operator is one used in a range test.
  95201. * Allowed operators are `<` and `<=`.
  95202. * @param {string} operator The operator to check.
  95203. * @returns {boolean} Whether the operator is used in range tests.
  95204. */
  95205. function isRangeTestOperator(operator) {
  95206. return ["<", "<="].indexOf(operator) >= 0;
  95207. }
  95208. /**
  95209. * Determines whether a non-Literal node is a negative number that should be
  95210. * treated as if it were a single Literal node.
  95211. * @param {ASTNode} node Node to test.
  95212. * @returns {boolean} True if the node is a negative number that looks like a
  95213. * real literal and should be treated as such.
  95214. */
  95215. function looksLikeLiteral(node) {
  95216. return node.type === "UnaryExpression" && node.operator === "-" && node.prefix && node.argument.type === "Literal" && typeof node.argument.value === "number";
  95217. }
  95218. /**
  95219. * Attempts to derive a Literal node from nodes that are treated like literals.
  95220. * @param {ASTNode} node Node to normalize.
  95221. * @param {number} [defaultValue] The default value to be returned if the node
  95222. * is not a Literal.
  95223. * @returns {ASTNode} One of the following options.
  95224. * 1. The original node if the node is already a Literal
  95225. * 2. A normalized Literal node with the negative number as the value if the
  95226. * node represents a negative number literal.
  95227. * 3. The Literal node which has the `defaultValue` argument if it exists.
  95228. * 4. Otherwise `null`.
  95229. */
  95230. function getNormalizedLiteral(node, defaultValue) {
  95231. if (node.type === "Literal") {
  95232. return node;
  95233. }
  95234. if (looksLikeLiteral(node)) {
  95235. return {
  95236. type: "Literal",
  95237. value: -node.argument.value,
  95238. raw: "-" + node.argument.value
  95239. };
  95240. }
  95241. if (defaultValue) {
  95242. return {
  95243. type: "Literal",
  95244. value: defaultValue,
  95245. raw: String(defaultValue)
  95246. };
  95247. }
  95248. return null;
  95249. }
  95250. /**
  95251. * Checks whether two expressions reference the same value. For example:
  95252. * a = a
  95253. * a.b = a.b
  95254. * a[0] = a[0]
  95255. * a['b'] = a['b']
  95256. * @param {ASTNode} a Left side of the comparison.
  95257. * @param {ASTNode} b Right side of the comparison.
  95258. * @returns {boolean} True if both sides match and reference the same value.
  95259. */
  95260. function same(a, b) {
  95261. if (a.type !== b.type) {
  95262. return false;
  95263. }
  95264. switch (a.type) {
  95265. case "Identifier":
  95266. return a.name === b.name;
  95267. case "Literal":
  95268. return a.value === b.value;
  95269. case "MemberExpression":
  95270. {
  95271. var nameA = astUtils.getStaticPropertyName(a);
  95272. // x.y = x["y"]
  95273. if (nameA) {
  95274. return same(a.object, b.object) && nameA === astUtils.getStaticPropertyName(b);
  95275. }
  95276. /*
  95277. * x[0] = x[0]
  95278. * x[y] = x[y]
  95279. * x.y = x.y
  95280. */
  95281. return a.computed === b.computed && same(a.object, b.object) && same(a.property, b.property);
  95282. }
  95283. case "ThisExpression":
  95284. return true;
  95285. default:
  95286. return false;
  95287. }
  95288. }
  95289. //------------------------------------------------------------------------------
  95290. // Rule Definition
  95291. //------------------------------------------------------------------------------
  95292. module.exports = {
  95293. meta: {
  95294. type: "suggestion",
  95295. docs: {
  95296. description: "require or disallow \"Yoda\" conditions",
  95297. category: "Best Practices",
  95298. recommended: false,
  95299. url: "https://eslint.org/docs/rules/yoda"
  95300. },
  95301. schema: [{
  95302. enum: ["always", "never"]
  95303. }, {
  95304. type: "object",
  95305. properties: {
  95306. exceptRange: {
  95307. type: "boolean"
  95308. },
  95309. onlyEquality: {
  95310. type: "boolean"
  95311. }
  95312. },
  95313. additionalProperties: false
  95314. }],
  95315. fixable: "code"
  95316. },
  95317. create: function create(context) {
  95318. // Default to "never" (!always) if no option
  95319. var always = context.options[0] === "always";
  95320. var exceptRange = context.options[1] && context.options[1].exceptRange;
  95321. var onlyEquality = context.options[1] && context.options[1].onlyEquality;
  95322. var sourceCode = context.getSourceCode();
  95323. /**
  95324. * Determines whether node represents a range test.
  95325. * A range test is a "between" test like `(0 <= x && x < 1)` or an "outside"
  95326. * test like `(x < 0 || 1 <= x)`. It must be wrapped in parentheses, and
  95327. * both operators must be `<` or `<=`. Finally, the literal on the left side
  95328. * must be less than or equal to the literal on the right side so that the
  95329. * test makes any sense.
  95330. * @param {ASTNode} node LogicalExpression node to test.
  95331. * @returns {boolean} Whether node is a range test.
  95332. */
  95333. function isRangeTest(node) {
  95334. var left = node.left,
  95335. right = node.right;
  95336. /**
  95337. * Determines whether node is of the form `0 <= x && x < 1`.
  95338. * @returns {boolean} Whether node is a "between" range test.
  95339. */
  95340. function isBetweenTest() {
  95341. var leftLiteral = void 0,
  95342. rightLiteral = void 0;
  95343. return node.operator === "&&" && (leftLiteral = getNormalizedLiteral(left.left)) && (rightLiteral = getNormalizedLiteral(right.right, Number.POSITIVE_INFINITY)) && leftLiteral.value <= rightLiteral.value && same(left.right, right.left);
  95344. }
  95345. /**
  95346. * Determines whether node is of the form `x < 0 || 1 <= x`.
  95347. * @returns {boolean} Whether node is an "outside" range test.
  95348. */
  95349. function isOutsideTest() {
  95350. var leftLiteral = void 0,
  95351. rightLiteral = void 0;
  95352. return node.operator === "||" && (leftLiteral = getNormalizedLiteral(left.right, Number.NEGATIVE_INFINITY)) && (rightLiteral = getNormalizedLiteral(right.left)) && leftLiteral.value <= rightLiteral.value && same(left.left, right.right);
  95353. }
  95354. /**
  95355. * Determines whether node is wrapped in parentheses.
  95356. * @returns {boolean} Whether node is preceded immediately by an open
  95357. * paren token and followed immediately by a close
  95358. * paren token.
  95359. */
  95360. function isParenWrapped() {
  95361. return astUtils.isParenthesised(sourceCode, node);
  95362. }
  95363. return node.type === "LogicalExpression" && left.type === "BinaryExpression" && right.type === "BinaryExpression" && isRangeTestOperator(left.operator) && isRangeTestOperator(right.operator) && (isBetweenTest() || isOutsideTest()) && isParenWrapped();
  95364. }
  95365. var OPERATOR_FLIP_MAP = {
  95366. "===": "===",
  95367. "!==": "!==",
  95368. "==": "==",
  95369. "!=": "!=",
  95370. "<": ">",
  95371. ">": "<",
  95372. "<=": ">=",
  95373. ">=": "<="
  95374. };
  95375. /**
  95376. * Returns a string representation of a BinaryExpression node with its sides/operator flipped around.
  95377. * @param {ASTNode} node The BinaryExpression node
  95378. * @returns {string} A string representation of the node with the sides and operator flipped
  95379. */
  95380. function getFlippedString(node) {
  95381. var operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, function (token) {
  95382. return token.value === node.operator;
  95383. });
  95384. var textBeforeOperator = sourceCode.getText().slice(sourceCode.getTokenBefore(operatorToken).range[1], operatorToken.range[0]);
  95385. var textAfterOperator = sourceCode.getText().slice(operatorToken.range[1], sourceCode.getTokenAfter(operatorToken).range[0]);
  95386. var leftText = sourceCode.getText().slice(node.range[0], sourceCode.getTokenBefore(operatorToken).range[1]);
  95387. var rightText = sourceCode.getText().slice(sourceCode.getTokenAfter(operatorToken).range[0], node.range[1]);
  95388. return rightText + textBeforeOperator + OPERATOR_FLIP_MAP[operatorToken.value] + textAfterOperator + leftText;
  95389. }
  95390. //--------------------------------------------------------------------------
  95391. // Public
  95392. //--------------------------------------------------------------------------
  95393. return {
  95394. BinaryExpression: function BinaryExpression(node) {
  95395. var expectedLiteral = always ? node.left : node.right;
  95396. var expectedNonLiteral = always ? node.right : node.left;
  95397. // If `expectedLiteral` is not a literal, and `expectedNonLiteral` is a literal, raise an error.
  95398. if ((expectedNonLiteral.type === "Literal" || looksLikeLiteral(expectedNonLiteral)) && !(expectedLiteral.type === "Literal" || looksLikeLiteral(expectedLiteral)) && !(!isEqualityOperator(node.operator) && onlyEquality) && isComparisonOperator(node.operator) && !(exceptRange && isRangeTest(context.getAncestors().pop()))) {
  95399. context.report({
  95400. node: node,
  95401. message: "Expected literal to be on the {{expectedSide}} side of {{operator}}.",
  95402. data: {
  95403. operator: node.operator,
  95404. expectedSide: always ? "left" : "right"
  95405. },
  95406. fix: function fix(fixer) {
  95407. return fixer.replaceText(node, getFlippedString(node));
  95408. }
  95409. });
  95410. }
  95411. }
  95412. };
  95413. }
  95414. };
  95415. },{"../util/ast-utils":405}],390:[function(require,module,exports){
  95416. /**
  95417. * @fileoverview Define the cursor which iterates tokens and comments in reverse.
  95418. * @author Toru Nagashima
  95419. */
  95420. "use strict";
  95421. //------------------------------------------------------------------------------
  95422. // Requirements
  95423. //------------------------------------------------------------------------------
  95424. 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; }; }();
  95425. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95426. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  95427. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  95428. var Cursor = require("./cursor");
  95429. var utils = require("./utils");
  95430. //------------------------------------------------------------------------------
  95431. // Exports
  95432. //------------------------------------------------------------------------------
  95433. /**
  95434. * The cursor which iterates tokens and comments in reverse.
  95435. */
  95436. module.exports = function (_Cursor) {
  95437. _inherits(BackwardTokenCommentCursor, _Cursor);
  95438. /**
  95439. * Initializes this cursor.
  95440. * @param {Token[]} tokens - The array of tokens.
  95441. * @param {Comment[]} comments - The array of comments.
  95442. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  95443. * @param {number} startLoc - The start location of the iteration range.
  95444. * @param {number} endLoc - The end location of the iteration range.
  95445. */
  95446. function BackwardTokenCommentCursor(tokens, comments, indexMap, startLoc, endLoc) {
  95447. _classCallCheck(this, BackwardTokenCommentCursor);
  95448. var _this = _possibleConstructorReturn(this, (BackwardTokenCommentCursor.__proto__ || Object.getPrototypeOf(BackwardTokenCommentCursor)).call(this));
  95449. _this.tokens = tokens;
  95450. _this.comments = comments;
  95451. _this.tokenIndex = utils.getLastIndex(tokens, indexMap, endLoc);
  95452. _this.commentIndex = utils.search(comments, endLoc) - 1;
  95453. _this.border = startLoc;
  95454. return _this;
  95455. }
  95456. /** @inheritdoc */
  95457. _createClass(BackwardTokenCommentCursor, [{
  95458. key: "moveNext",
  95459. value: function moveNext() {
  95460. var token = this.tokenIndex >= 0 ? this.tokens[this.tokenIndex] : null;
  95461. var comment = this.commentIndex >= 0 ? this.comments[this.commentIndex] : null;
  95462. if (token && (!comment || token.range[1] > comment.range[1])) {
  95463. this.current = token;
  95464. this.tokenIndex -= 1;
  95465. } else if (comment) {
  95466. this.current = comment;
  95467. this.commentIndex -= 1;
  95468. } else {
  95469. this.current = null;
  95470. }
  95471. return Boolean(this.current) && (this.border === -1 || this.current.range[0] >= this.border);
  95472. }
  95473. }]);
  95474. return BackwardTokenCommentCursor;
  95475. }(Cursor);
  95476. },{"./cursor":392,"./utils":402}],391:[function(require,module,exports){
  95477. /**
  95478. * @fileoverview Define the cursor which iterates tokens only in reverse.
  95479. * @author Toru Nagashima
  95480. */
  95481. "use strict";
  95482. //------------------------------------------------------------------------------
  95483. // Requirements
  95484. //------------------------------------------------------------------------------
  95485. 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; }; }();
  95486. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95487. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  95488. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  95489. var Cursor = require("./cursor");
  95490. var utils = require("./utils");
  95491. //------------------------------------------------------------------------------
  95492. // Exports
  95493. //------------------------------------------------------------------------------
  95494. /**
  95495. * The cursor which iterates tokens only in reverse.
  95496. */
  95497. module.exports = function (_Cursor) {
  95498. _inherits(BackwardTokenCursor, _Cursor);
  95499. /**
  95500. * Initializes this cursor.
  95501. * @param {Token[]} tokens - The array of tokens.
  95502. * @param {Comment[]} comments - The array of comments.
  95503. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  95504. * @param {number} startLoc - The start location of the iteration range.
  95505. * @param {number} endLoc - The end location of the iteration range.
  95506. */
  95507. function BackwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc) {
  95508. _classCallCheck(this, BackwardTokenCursor);
  95509. var _this = _possibleConstructorReturn(this, (BackwardTokenCursor.__proto__ || Object.getPrototypeOf(BackwardTokenCursor)).call(this));
  95510. _this.tokens = tokens;
  95511. _this.index = utils.getLastIndex(tokens, indexMap, endLoc);
  95512. _this.indexEnd = utils.getFirstIndex(tokens, indexMap, startLoc);
  95513. return _this;
  95514. }
  95515. /** @inheritdoc */
  95516. _createClass(BackwardTokenCursor, [{
  95517. key: "moveNext",
  95518. value: function moveNext() {
  95519. if (this.index >= this.indexEnd) {
  95520. this.current = this.tokens[this.index];
  95521. this.index -= 1;
  95522. return true;
  95523. }
  95524. return false;
  95525. }
  95526. /*
  95527. *
  95528. * Shorthand for performance.
  95529. *
  95530. */
  95531. /** @inheritdoc */
  95532. }, {
  95533. key: "getOneToken",
  95534. value: function getOneToken() {
  95535. return this.index >= this.indexEnd ? this.tokens[this.index] : null;
  95536. }
  95537. }]);
  95538. return BackwardTokenCursor;
  95539. }(Cursor);
  95540. },{"./cursor":392,"./utils":402}],392:[function(require,module,exports){
  95541. /**
  95542. * @fileoverview Define the abstract class about cursors which iterate tokens.
  95543. * @author Toru Nagashima
  95544. */
  95545. "use strict";
  95546. //------------------------------------------------------------------------------
  95547. // Exports
  95548. //------------------------------------------------------------------------------
  95549. /**
  95550. * The abstract class about cursors which iterate tokens.
  95551. *
  95552. * This class has 2 abstract methods.
  95553. *
  95554. * - `current: Token | Comment | null` ... The current token.
  95555. * - `moveNext(): boolean` ... Moves this cursor to the next token. If the next token didn't exist, it returns `false`.
  95556. *
  95557. * This is similar to ES2015 Iterators.
  95558. * However, Iterators were slow (at 2017-01), so I created this class as similar to C# IEnumerable.
  95559. *
  95560. * There are the following known sub classes.
  95561. *
  95562. * - ForwardTokenCursor .......... The cursor which iterates tokens only.
  95563. * - BackwardTokenCursor ......... The cursor which iterates tokens only in reverse.
  95564. * - ForwardTokenCommentCursor ... The cursor which iterates tokens and comments.
  95565. * - BackwardTokenCommentCursor .. The cursor which iterates tokens and comments in reverse.
  95566. * - DecorativeCursor
  95567. * - FilterCursor ............ The cursor which ignores the specified tokens.
  95568. * - SkipCursor .............. The cursor which ignores the first few tokens.
  95569. * - LimitCursor ............. The cursor which limits the count of tokens.
  95570. *
  95571. */
  95572. 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; }; }();
  95573. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95574. module.exports = function () {
  95575. /**
  95576. * Initializes this cursor.
  95577. */
  95578. function Cursor() {
  95579. _classCallCheck(this, Cursor);
  95580. this.current = null;
  95581. }
  95582. /**
  95583. * Gets the first token.
  95584. * This consumes this cursor.
  95585. * @returns {Token|Comment} The first token or null.
  95586. */
  95587. _createClass(Cursor, [{
  95588. key: "getOneToken",
  95589. value: function getOneToken() {
  95590. return this.moveNext() ? this.current : null;
  95591. }
  95592. /**
  95593. * Gets the first tokens.
  95594. * This consumes this cursor.
  95595. * @returns {(Token|Comment)[]} All tokens.
  95596. */
  95597. }, {
  95598. key: "getAllTokens",
  95599. value: function getAllTokens() {
  95600. var tokens = [];
  95601. while (this.moveNext()) {
  95602. tokens.push(this.current);
  95603. }
  95604. return tokens;
  95605. }
  95606. /**
  95607. * Moves this cursor to the next token.
  95608. * @returns {boolean} `true` if the next token exists.
  95609. * @abstract
  95610. */
  95611. /* istanbul ignore next */
  95612. }, {
  95613. key: "moveNext",
  95614. value: function moveNext() {
  95615. // eslint-disable-line class-methods-use-this
  95616. throw new Error("Not implemented.");
  95617. }
  95618. }]);
  95619. return Cursor;
  95620. }();
  95621. },{}],393:[function(require,module,exports){
  95622. /**
  95623. * @fileoverview Define 2 token factories; forward and backward.
  95624. * @author Toru Nagashima
  95625. */
  95626. "use strict";
  95627. //------------------------------------------------------------------------------
  95628. // Requirements
  95629. //------------------------------------------------------------------------------
  95630. 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; }; }();
  95631. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95632. var BackwardTokenCommentCursor = require("./backward-token-comment-cursor");
  95633. var BackwardTokenCursor = require("./backward-token-cursor");
  95634. var FilterCursor = require("./filter-cursor");
  95635. var ForwardTokenCommentCursor = require("./forward-token-comment-cursor");
  95636. var ForwardTokenCursor = require("./forward-token-cursor");
  95637. var LimitCursor = require("./limit-cursor");
  95638. var SkipCursor = require("./skip-cursor");
  95639. //------------------------------------------------------------------------------
  95640. // Helpers
  95641. //------------------------------------------------------------------------------
  95642. /**
  95643. * The cursor factory.
  95644. * @private
  95645. */
  95646. var CursorFactory = function () {
  95647. /**
  95648. * Initializes this cursor.
  95649. * @param {Function} TokenCursor - The class of the cursor which iterates tokens only.
  95650. * @param {Function} TokenCommentCursor - The class of the cursor which iterates the mix of tokens and comments.
  95651. */
  95652. function CursorFactory(TokenCursor, TokenCommentCursor) {
  95653. _classCallCheck(this, CursorFactory);
  95654. this.TokenCursor = TokenCursor;
  95655. this.TokenCommentCursor = TokenCommentCursor;
  95656. }
  95657. /**
  95658. * Creates a base cursor instance that can be decorated by createCursor.
  95659. *
  95660. * @param {Token[]} tokens - The array of tokens.
  95661. * @param {Comment[]} comments - The array of comments.
  95662. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  95663. * @param {number} startLoc - The start location of the iteration range.
  95664. * @param {number} endLoc - The end location of the iteration range.
  95665. * @param {boolean} includeComments - The flag to iterate comments as well.
  95666. * @returns {Cursor} The created base cursor.
  95667. */
  95668. _createClass(CursorFactory, [{
  95669. key: "createBaseCursor",
  95670. value: function createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) {
  95671. var Cursor = includeComments ? this.TokenCommentCursor : this.TokenCursor;
  95672. return new Cursor(tokens, comments, indexMap, startLoc, endLoc);
  95673. }
  95674. /**
  95675. * Creates a cursor that iterates tokens with normalized options.
  95676. *
  95677. * @param {Token[]} tokens - The array of tokens.
  95678. * @param {Comment[]} comments - The array of comments.
  95679. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  95680. * @param {number} startLoc - The start location of the iteration range.
  95681. * @param {number} endLoc - The end location of the iteration range.
  95682. * @param {boolean} includeComments - The flag to iterate comments as well.
  95683. * @param {Function|null} filter - The predicate function to choose tokens.
  95684. * @param {number} skip - The count of tokens the cursor skips.
  95685. * @param {number} count - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
  95686. * @returns {Cursor} The created cursor.
  95687. */
  95688. }, {
  95689. key: "createCursor",
  95690. value: function createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, count) {
  95691. var cursor = this.createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments);
  95692. if (filter) {
  95693. cursor = new FilterCursor(cursor, filter);
  95694. }
  95695. if (skip >= 1) {
  95696. cursor = new SkipCursor(cursor, skip);
  95697. }
  95698. if (count >= 0) {
  95699. cursor = new LimitCursor(cursor, count);
  95700. }
  95701. return cursor;
  95702. }
  95703. }]);
  95704. return CursorFactory;
  95705. }();
  95706. //------------------------------------------------------------------------------
  95707. // Exports
  95708. //------------------------------------------------------------------------------
  95709. exports.forward = new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor);
  95710. exports.backward = new CursorFactory(BackwardTokenCursor, BackwardTokenCommentCursor);
  95711. },{"./backward-token-comment-cursor":390,"./backward-token-cursor":391,"./filter-cursor":395,"./forward-token-comment-cursor":396,"./forward-token-cursor":397,"./limit-cursor":399,"./skip-cursor":401}],394:[function(require,module,exports){
  95712. /**
  95713. * @fileoverview Define the abstract class about cursors which manipulate another cursor.
  95714. * @author Toru Nagashima
  95715. */
  95716. "use strict";
  95717. //------------------------------------------------------------------------------
  95718. // Requirements
  95719. //------------------------------------------------------------------------------
  95720. 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; }; }();
  95721. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95722. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  95723. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  95724. var Cursor = require("./cursor");
  95725. //------------------------------------------------------------------------------
  95726. // Exports
  95727. //------------------------------------------------------------------------------
  95728. /**
  95729. * The abstract class about cursors which manipulate another cursor.
  95730. */
  95731. module.exports = function (_Cursor) {
  95732. _inherits(DecorativeCursor, _Cursor);
  95733. /**
  95734. * Initializes this cursor.
  95735. * @param {Cursor} cursor - The cursor to be decorated.
  95736. */
  95737. function DecorativeCursor(cursor) {
  95738. _classCallCheck(this, DecorativeCursor);
  95739. var _this = _possibleConstructorReturn(this, (DecorativeCursor.__proto__ || Object.getPrototypeOf(DecorativeCursor)).call(this));
  95740. _this.cursor = cursor;
  95741. return _this;
  95742. }
  95743. /** @inheritdoc */
  95744. _createClass(DecorativeCursor, [{
  95745. key: "moveNext",
  95746. value: function moveNext() {
  95747. var retv = this.cursor.moveNext();
  95748. this.current = this.cursor.current;
  95749. return retv;
  95750. }
  95751. }]);
  95752. return DecorativeCursor;
  95753. }(Cursor);
  95754. },{"./cursor":392}],395:[function(require,module,exports){
  95755. /**
  95756. * @fileoverview Define the cursor which ignores specified tokens.
  95757. * @author Toru Nagashima
  95758. */
  95759. "use strict";
  95760. //------------------------------------------------------------------------------
  95761. // Requirements
  95762. //------------------------------------------------------------------------------
  95763. 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; }; }();
  95764. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  95765. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95766. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  95767. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  95768. var DecorativeCursor = require("./decorative-cursor");
  95769. //------------------------------------------------------------------------------
  95770. // Exports
  95771. //------------------------------------------------------------------------------
  95772. /**
  95773. * The decorative cursor which ignores specified tokens.
  95774. */
  95775. module.exports = function (_DecorativeCursor) {
  95776. _inherits(FilterCursor, _DecorativeCursor);
  95777. /**
  95778. * Initializes this cursor.
  95779. * @param {Cursor} cursor - The cursor to be decorated.
  95780. * @param {Function} predicate - The predicate function to decide tokens this cursor iterates.
  95781. */
  95782. function FilterCursor(cursor, predicate) {
  95783. _classCallCheck(this, FilterCursor);
  95784. var _this = _possibleConstructorReturn(this, (FilterCursor.__proto__ || Object.getPrototypeOf(FilterCursor)).call(this, cursor));
  95785. _this.predicate = predicate;
  95786. return _this;
  95787. }
  95788. /** @inheritdoc */
  95789. _createClass(FilterCursor, [{
  95790. key: "moveNext",
  95791. value: function moveNext() {
  95792. var predicate = this.predicate;
  95793. while (_get(FilterCursor.prototype.__proto__ || Object.getPrototypeOf(FilterCursor.prototype), "moveNext", this).call(this)) {
  95794. if (predicate(this.current)) {
  95795. return true;
  95796. }
  95797. }
  95798. return false;
  95799. }
  95800. }]);
  95801. return FilterCursor;
  95802. }(DecorativeCursor);
  95803. },{"./decorative-cursor":394}],396:[function(require,module,exports){
  95804. /**
  95805. * @fileoverview Define the cursor which iterates tokens and comments.
  95806. * @author Toru Nagashima
  95807. */
  95808. "use strict";
  95809. //------------------------------------------------------------------------------
  95810. // Requirements
  95811. //------------------------------------------------------------------------------
  95812. 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; }; }();
  95813. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95814. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  95815. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  95816. var Cursor = require("./cursor");
  95817. var utils = require("./utils");
  95818. //------------------------------------------------------------------------------
  95819. // Exports
  95820. //------------------------------------------------------------------------------
  95821. /**
  95822. * The cursor which iterates tokens and comments.
  95823. */
  95824. module.exports = function (_Cursor) {
  95825. _inherits(ForwardTokenCommentCursor, _Cursor);
  95826. /**
  95827. * Initializes this cursor.
  95828. * @param {Token[]} tokens - The array of tokens.
  95829. * @param {Comment[]} comments - The array of comments.
  95830. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  95831. * @param {number} startLoc - The start location of the iteration range.
  95832. * @param {number} endLoc - The end location of the iteration range.
  95833. */
  95834. function ForwardTokenCommentCursor(tokens, comments, indexMap, startLoc, endLoc) {
  95835. _classCallCheck(this, ForwardTokenCommentCursor);
  95836. var _this = _possibleConstructorReturn(this, (ForwardTokenCommentCursor.__proto__ || Object.getPrototypeOf(ForwardTokenCommentCursor)).call(this));
  95837. _this.tokens = tokens;
  95838. _this.comments = comments;
  95839. _this.tokenIndex = utils.getFirstIndex(tokens, indexMap, startLoc);
  95840. _this.commentIndex = utils.search(comments, startLoc);
  95841. _this.border = endLoc;
  95842. return _this;
  95843. }
  95844. /** @inheritdoc */
  95845. _createClass(ForwardTokenCommentCursor, [{
  95846. key: "moveNext",
  95847. value: function moveNext() {
  95848. var token = this.tokenIndex < this.tokens.length ? this.tokens[this.tokenIndex] : null;
  95849. var comment = this.commentIndex < this.comments.length ? this.comments[this.commentIndex] : null;
  95850. if (token && (!comment || token.range[0] < comment.range[0])) {
  95851. this.current = token;
  95852. this.tokenIndex += 1;
  95853. } else if (comment) {
  95854. this.current = comment;
  95855. this.commentIndex += 1;
  95856. } else {
  95857. this.current = null;
  95858. }
  95859. return Boolean(this.current) && (this.border === -1 || this.current.range[1] <= this.border);
  95860. }
  95861. }]);
  95862. return ForwardTokenCommentCursor;
  95863. }(Cursor);
  95864. },{"./cursor":392,"./utils":402}],397:[function(require,module,exports){
  95865. /**
  95866. * @fileoverview Define the cursor which iterates tokens only.
  95867. * @author Toru Nagashima
  95868. */
  95869. "use strict";
  95870. //------------------------------------------------------------------------------
  95871. // Requirements
  95872. //------------------------------------------------------------------------------
  95873. 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; }; }();
  95874. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95875. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  95876. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  95877. var Cursor = require("./cursor");
  95878. var utils = require("./utils");
  95879. //------------------------------------------------------------------------------
  95880. // Exports
  95881. //------------------------------------------------------------------------------
  95882. /**
  95883. * The cursor which iterates tokens only.
  95884. */
  95885. module.exports = function (_Cursor) {
  95886. _inherits(ForwardTokenCursor, _Cursor);
  95887. /**
  95888. * Initializes this cursor.
  95889. * @param {Token[]} tokens - The array of tokens.
  95890. * @param {Comment[]} comments - The array of comments.
  95891. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  95892. * @param {number} startLoc - The start location of the iteration range.
  95893. * @param {number} endLoc - The end location of the iteration range.
  95894. */
  95895. function ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc) {
  95896. _classCallCheck(this, ForwardTokenCursor);
  95897. var _this = _possibleConstructorReturn(this, (ForwardTokenCursor.__proto__ || Object.getPrototypeOf(ForwardTokenCursor)).call(this));
  95898. _this.tokens = tokens;
  95899. _this.index = utils.getFirstIndex(tokens, indexMap, startLoc);
  95900. _this.indexEnd = utils.getLastIndex(tokens, indexMap, endLoc);
  95901. return _this;
  95902. }
  95903. /** @inheritdoc */
  95904. _createClass(ForwardTokenCursor, [{
  95905. key: "moveNext",
  95906. value: function moveNext() {
  95907. if (this.index <= this.indexEnd) {
  95908. this.current = this.tokens[this.index];
  95909. this.index += 1;
  95910. return true;
  95911. }
  95912. return false;
  95913. }
  95914. /*
  95915. *
  95916. * Shorthand for performance.
  95917. *
  95918. */
  95919. /** @inheritdoc */
  95920. }, {
  95921. key: "getOneToken",
  95922. value: function getOneToken() {
  95923. return this.index <= this.indexEnd ? this.tokens[this.index] : null;
  95924. }
  95925. /** @inheritdoc */
  95926. }, {
  95927. key: "getAllTokens",
  95928. value: function getAllTokens() {
  95929. return this.tokens.slice(this.index, this.indexEnd + 1);
  95930. }
  95931. }]);
  95932. return ForwardTokenCursor;
  95933. }(Cursor);
  95934. },{"./cursor":392,"./utils":402}],398:[function(require,module,exports){
  95935. /**
  95936. * @fileoverview Object to handle access and retrieval of tokens.
  95937. * @author Brandon Mills
  95938. */
  95939. "use strict";
  95940. //------------------------------------------------------------------------------
  95941. // Requirements
  95942. //------------------------------------------------------------------------------
  95943. 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; }; }();
  95944. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  95945. var assert = require("assert");
  95946. var cursors = require("./cursors");
  95947. var ForwardTokenCursor = require("./forward-token-cursor");
  95948. var PaddedTokenCursor = require("./padded-token-cursor");
  95949. var utils = require("./utils");
  95950. var astUtils = require("../util/ast-utils");
  95951. //------------------------------------------------------------------------------
  95952. // Helpers
  95953. //------------------------------------------------------------------------------
  95954. var TOKENS = Symbol("tokens");
  95955. var COMMENTS = Symbol("comments");
  95956. var INDEX_MAP = Symbol("indexMap");
  95957. /**
  95958. * Creates the map from locations to indices in `tokens`.
  95959. *
  95960. * The first/last location of tokens is mapped to the index of the token.
  95961. * The first/last location of comments is mapped to the index of the next token of each comment.
  95962. *
  95963. * @param {Token[]} tokens - The array of tokens.
  95964. * @param {Comment[]} comments - The array of comments.
  95965. * @returns {Object} The map from locations to indices in `tokens`.
  95966. * @private
  95967. */
  95968. function createIndexMap(tokens, comments) {
  95969. var map = Object.create(null);
  95970. var tokenIndex = 0;
  95971. var commentIndex = 0;
  95972. var nextStart = 0;
  95973. var range = null;
  95974. while (tokenIndex < tokens.length || commentIndex < comments.length) {
  95975. nextStart = commentIndex < comments.length ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER;
  95976. while (tokenIndex < tokens.length && (range = tokens[tokenIndex].range)[0] < nextStart) {
  95977. map[range[0]] = tokenIndex;
  95978. map[range[1] - 1] = tokenIndex;
  95979. tokenIndex += 1;
  95980. }
  95981. nextStart = tokenIndex < tokens.length ? tokens[tokenIndex].range[0] : Number.MAX_SAFE_INTEGER;
  95982. while (commentIndex < comments.length && (range = comments[commentIndex].range)[0] < nextStart) {
  95983. map[range[0]] = tokenIndex;
  95984. map[range[1] - 1] = tokenIndex;
  95985. commentIndex += 1;
  95986. }
  95987. }
  95988. return map;
  95989. }
  95990. /**
  95991. * Creates the cursor iterates tokens with options.
  95992. *
  95993. * @param {CursorFactory} factory - The cursor factory to initialize cursor.
  95994. * @param {Token[]} tokens - The array of tokens.
  95995. * @param {Comment[]} comments - The array of comments.
  95996. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  95997. * @param {number} startLoc - The start location of the iteration range.
  95998. * @param {number} endLoc - The end location of the iteration range.
  95999. * @param {number|Function|Object} [opts=0] - The option object. If this is a number then it's `opts.skip`. If this is a function then it's `opts.filter`.
  96000. * @param {boolean} [opts.includeComments=false] - The flag to iterate comments as well.
  96001. * @param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
  96002. * @param {number} [opts.skip=0] - The count of tokens the cursor skips.
  96003. * @returns {Cursor} The created cursor.
  96004. * @private
  96005. */
  96006. function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
  96007. var includeComments = false;
  96008. var skip = 0;
  96009. var filter = null;
  96010. if (typeof opts === "number") {
  96011. skip = opts | 0;
  96012. } else if (typeof opts === "function") {
  96013. filter = opts;
  96014. } else if (opts) {
  96015. includeComments = !!opts.includeComments;
  96016. skip = opts.skip | 0;
  96017. filter = opts.filter || null;
  96018. }
  96019. assert(skip >= 0, "options.skip should be zero or a positive integer.");
  96020. assert(!filter || typeof filter === "function", "options.filter should be a function.");
  96021. return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1);
  96022. }
  96023. /**
  96024. * Creates the cursor iterates tokens with options.
  96025. *
  96026. * @param {CursorFactory} factory - The cursor factory to initialize cursor.
  96027. * @param {Token[]} tokens - The array of tokens.
  96028. * @param {Comment[]} comments - The array of comments.
  96029. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  96030. * @param {number} startLoc - The start location of the iteration range.
  96031. * @param {number} endLoc - The end location of the iteration range.
  96032. * @param {number|Function|Object} [opts=0] - The option object. If this is a number then it's `opts.count`. If this is a function then it's `opts.filter`.
  96033. * @param {boolean} [opts.includeComments] - The flag to iterate comments as well.
  96034. * @param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
  96035. * @param {number} [opts.count=0] - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
  96036. * @returns {Cursor} The created cursor.
  96037. * @private
  96038. */
  96039. function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
  96040. var includeComments = false;
  96041. var count = 0;
  96042. var countExists = false;
  96043. var filter = null;
  96044. if (typeof opts === "number") {
  96045. count = opts | 0;
  96046. countExists = true;
  96047. } else if (typeof opts === "function") {
  96048. filter = opts;
  96049. } else if (opts) {
  96050. includeComments = !!opts.includeComments;
  96051. count = opts.count | 0;
  96052. countExists = typeof opts.count === "number";
  96053. filter = opts.filter || null;
  96054. }
  96055. assert(count >= 0, "options.count should be zero or a positive integer.");
  96056. assert(!filter || typeof filter === "function", "options.filter should be a function.");
  96057. return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1);
  96058. }
  96059. /**
  96060. * Creates the cursor iterates tokens with options.
  96061. * This is overload function of the below.
  96062. *
  96063. * @param {Token[]} tokens - The array of tokens.
  96064. * @param {Comment[]} comments - The array of comments.
  96065. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  96066. * @param {number} startLoc - The start location of the iteration range.
  96067. * @param {number} endLoc - The end location of the iteration range.
  96068. * @param {Function|Object} opts - The option object. If this is a function then it's `opts.filter`.
  96069. * @param {boolean} [opts.includeComments] - The flag to iterate comments as well.
  96070. * @param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
  96071. * @param {number} [opts.count=0] - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
  96072. * @returns {Cursor} The created cursor.
  96073. * @private
  96074. */
  96075. /**
  96076. * Creates the cursor iterates tokens with options.
  96077. *
  96078. * @param {Token[]} tokens - The array of tokens.
  96079. * @param {Comment[]} comments - The array of comments.
  96080. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  96081. * @param {number} startLoc - The start location of the iteration range.
  96082. * @param {number} endLoc - The end location of the iteration range.
  96083. * @param {number} [beforeCount=0] - The number of tokens before the node to retrieve.
  96084. * @param {boolean} [afterCount=0] - The number of tokens after the node to retrieve.
  96085. * @returns {Cursor} The created cursor.
  96086. * @private
  96087. */
  96088. function createCursorWithPadding(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
  96089. if (typeof beforeCount === "undefined" && typeof afterCount === "undefined") {
  96090. return new ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc);
  96091. }
  96092. if (typeof beforeCount === "number" || typeof beforeCount === "undefined") {
  96093. return new PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount | 0, afterCount | 0);
  96094. }
  96095. return createCursorWithCount(cursors.forward, tokens, comments, indexMap, startLoc, endLoc, beforeCount);
  96096. }
  96097. /**
  96098. * Gets comment tokens that are adjacent to the current cursor position.
  96099. * @param {Cursor} cursor - A cursor instance.
  96100. * @returns {Array} An array of comment tokens adjacent to the current cursor position.
  96101. * @private
  96102. */
  96103. function getAdjacentCommentTokensFromCursor(cursor) {
  96104. var tokens = [];
  96105. var currentToken = cursor.getOneToken();
  96106. while (currentToken && astUtils.isCommentToken(currentToken)) {
  96107. tokens.push(currentToken);
  96108. currentToken = cursor.getOneToken();
  96109. }
  96110. return tokens;
  96111. }
  96112. //------------------------------------------------------------------------------
  96113. // Exports
  96114. //------------------------------------------------------------------------------
  96115. /**
  96116. * The token store.
  96117. *
  96118. * This class provides methods to get tokens by locations as fast as possible.
  96119. * The methods are a part of public API, so we should be careful if it changes this class.
  96120. *
  96121. * People can get tokens in O(1) by the hash map which is mapping from the location of tokens/comments to tokens.
  96122. * Also people can get a mix of tokens and comments in O(log k), the k is the number of comments.
  96123. * Assuming that comments to be much fewer than tokens, this does not make hash map from token's locations to comments to reduce memory cost.
  96124. * This uses binary-searching instead for comments.
  96125. */
  96126. module.exports = function () {
  96127. /**
  96128. * Initializes this token store.
  96129. * @param {Token[]} tokens - The array of tokens.
  96130. * @param {Comment[]} comments - The array of comments.
  96131. */
  96132. function TokenStore(tokens, comments) {
  96133. _classCallCheck(this, TokenStore);
  96134. this[TOKENS] = tokens;
  96135. this[COMMENTS] = comments;
  96136. this[INDEX_MAP] = createIndexMap(tokens, comments);
  96137. }
  96138. //--------------------------------------------------------------------------
  96139. // Gets single token.
  96140. //--------------------------------------------------------------------------
  96141. /**
  96142. * Gets the token starting at the specified index.
  96143. * @param {number} offset - Index of the start of the token's range.
  96144. * @param {Object} [options=0] - The option object.
  96145. * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
  96146. * @returns {Token|null} The token starting at index, or null if no such token.
  96147. */
  96148. _createClass(TokenStore, [{
  96149. key: "getTokenByRangeStart",
  96150. value: function getTokenByRangeStart(offset, options) {
  96151. var includeComments = options && options.includeComments;
  96152. var token = cursors.forward.createBaseCursor(this[TOKENS], this[COMMENTS], this[INDEX_MAP], offset, -1, includeComments).getOneToken();
  96153. if (token && token.range[0] === offset) {
  96154. return token;
  96155. }
  96156. return null;
  96157. }
  96158. /**
  96159. * Gets the first token of the given node.
  96160. * @param {ASTNode} node - The AST node.
  96161. * @param {number|Function|Object} [options=0] - The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
  96162. * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
  96163. * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
  96164. * @param {number} [options.skip=0] - The count of tokens the cursor skips.
  96165. * @returns {Token|null} An object representing the token.
  96166. */
  96167. }, {
  96168. key: "getFirstToken",
  96169. value: function getFirstToken(node, options) {
  96170. return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getOneToken();
  96171. }
  96172. /**
  96173. * Gets the last token of the given node.
  96174. * @param {ASTNode} node - The AST node.
  96175. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
  96176. * @returns {Token|null} An object representing the token.
  96177. */
  96178. }, {
  96179. key: "getLastToken",
  96180. value: function getLastToken(node, options) {
  96181. return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getOneToken();
  96182. }
  96183. /**
  96184. * Gets the token that precedes a given node or token.
  96185. * @param {ASTNode|Token|Comment} node - The AST node or token.
  96186. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
  96187. * @returns {Token|null} An object representing the token.
  96188. */
  96189. }, {
  96190. key: "getTokenBefore",
  96191. value: function getTokenBefore(node, options) {
  96192. return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, node.range[0], options).getOneToken();
  96193. }
  96194. /**
  96195. * Gets the token that follows a given node or token.
  96196. * @param {ASTNode|Token|Comment} node - The AST node or token.
  96197. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
  96198. * @returns {Token|null} An object representing the token.
  96199. */
  96200. }, {
  96201. key: "getTokenAfter",
  96202. value: function getTokenAfter(node, options) {
  96203. return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[1], -1, options).getOneToken();
  96204. }
  96205. /**
  96206. * Gets the first token between two non-overlapping nodes.
  96207. * @param {ASTNode|Token|Comment} left - Node before the desired token range.
  96208. * @param {ASTNode|Token|Comment} right - Node after the desired token range.
  96209. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
  96210. * @returns {Token|null} An object representing the token.
  96211. */
  96212. }, {
  96213. key: "getFirstTokenBetween",
  96214. value: function getFirstTokenBetween(left, right, options) {
  96215. return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getOneToken();
  96216. }
  96217. /**
  96218. * Gets the last token between two non-overlapping nodes.
  96219. * @param {ASTNode|Token|Comment} left Node before the desired token range.
  96220. * @param {ASTNode|Token|Comment} right Node after the desired token range.
  96221. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
  96222. * @returns {Token|null} An object representing the token.
  96223. */
  96224. }, {
  96225. key: "getLastTokenBetween",
  96226. value: function getLastTokenBetween(left, right, options) {
  96227. return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getOneToken();
  96228. }
  96229. /**
  96230. * Gets the token that precedes a given node or token in the token stream.
  96231. * This is defined for backward compatibility. Use `includeComments` option instead.
  96232. * TODO: We have a plan to remove this in a future major version.
  96233. * @param {ASTNode|Token|Comment} node The AST node or token.
  96234. * @param {number} [skip=0] A number of tokens to skip.
  96235. * @returns {Token|null} An object representing the token.
  96236. * @deprecated
  96237. */
  96238. }, {
  96239. key: "getTokenOrCommentBefore",
  96240. value: function getTokenOrCommentBefore(node, skip) {
  96241. return this.getTokenBefore(node, { includeComments: true, skip: skip });
  96242. }
  96243. /**
  96244. * Gets the token that follows a given node or token in the token stream.
  96245. * This is defined for backward compatibility. Use `includeComments` option instead.
  96246. * TODO: We have a plan to remove this in a future major version.
  96247. * @param {ASTNode|Token|Comment} node The AST node or token.
  96248. * @param {number} [skip=0] A number of tokens to skip.
  96249. * @returns {Token|null} An object representing the token.
  96250. * @deprecated
  96251. */
  96252. }, {
  96253. key: "getTokenOrCommentAfter",
  96254. value: function getTokenOrCommentAfter(node, skip) {
  96255. return this.getTokenAfter(node, { includeComments: true, skip: skip });
  96256. }
  96257. //--------------------------------------------------------------------------
  96258. // Gets multiple tokens.
  96259. //--------------------------------------------------------------------------
  96260. /**
  96261. * Gets the first `count` tokens of the given node.
  96262. * @param {ASTNode} node - The AST node.
  96263. * @param {number|Function|Object} [options=0] - The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
  96264. * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
  96265. * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
  96266. * @param {number} [options.count=0] - The maximum count of tokens the cursor iterates.
  96267. * @returns {Token[]} Tokens.
  96268. */
  96269. }, {
  96270. key: "getFirstTokens",
  96271. value: function getFirstTokens(node, options) {
  96272. return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getAllTokens();
  96273. }
  96274. /**
  96275. * Gets the last `count` tokens of the given node.
  96276. * @param {ASTNode} node - The AST node.
  96277. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
  96278. * @returns {Token[]} Tokens.
  96279. */
  96280. }, {
  96281. key: "getLastTokens",
  96282. value: function getLastTokens(node, options) {
  96283. return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getAllTokens().reverse();
  96284. }
  96285. /**
  96286. * Gets the `count` tokens that precedes a given node or token.
  96287. * @param {ASTNode|Token|Comment} node - The AST node or token.
  96288. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
  96289. * @returns {Token[]} Tokens.
  96290. */
  96291. }, {
  96292. key: "getTokensBefore",
  96293. value: function getTokensBefore(node, options) {
  96294. return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, node.range[0], options).getAllTokens().reverse();
  96295. }
  96296. /**
  96297. * Gets the `count` tokens that follows a given node or token.
  96298. * @param {ASTNode|Token|Comment} node - The AST node or token.
  96299. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
  96300. * @returns {Token[]} Tokens.
  96301. */
  96302. }, {
  96303. key: "getTokensAfter",
  96304. value: function getTokensAfter(node, options) {
  96305. return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[1], -1, options).getAllTokens();
  96306. }
  96307. /**
  96308. * Gets the first `count` tokens between two non-overlapping nodes.
  96309. * @param {ASTNode|Token|Comment} left - Node before the desired token range.
  96310. * @param {ASTNode|Token|Comment} right - Node after the desired token range.
  96311. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
  96312. * @returns {Token[]} Tokens between left and right.
  96313. */
  96314. }, {
  96315. key: "getFirstTokensBetween",
  96316. value: function getFirstTokensBetween(left, right, options) {
  96317. return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getAllTokens();
  96318. }
  96319. /**
  96320. * Gets the last `count` tokens between two non-overlapping nodes.
  96321. * @param {ASTNode|Token|Comment} left Node before the desired token range.
  96322. * @param {ASTNode|Token|Comment} right Node after the desired token range.
  96323. * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
  96324. * @returns {Token[]} Tokens between left and right.
  96325. */
  96326. }, {
  96327. key: "getLastTokensBetween",
  96328. value: function getLastTokensBetween(left, right, options) {
  96329. return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getAllTokens().reverse();
  96330. }
  96331. /**
  96332. * Gets all tokens that are related to the given node.
  96333. * @param {ASTNode} node - The AST node.
  96334. * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
  96335. * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
  96336. * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
  96337. * @param {number} [options.count=0] - The maximum count of tokens the cursor iterates.
  96338. * @returns {Token[]} Array of objects representing tokens.
  96339. */
  96340. /**
  96341. * Gets all tokens that are related to the given node.
  96342. * @param {ASTNode} node - The AST node.
  96343. * @param {int} [beforeCount=0] - The number of tokens before the node to retrieve.
  96344. * @param {int} [afterCount=0] - The number of tokens after the node to retrieve.
  96345. * @returns {Token[]} Array of objects representing tokens.
  96346. */
  96347. }, {
  96348. key: "getTokens",
  96349. value: function getTokens(node, beforeCount, afterCount) {
  96350. return createCursorWithPadding(this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], beforeCount, afterCount).getAllTokens();
  96351. }
  96352. /**
  96353. * Gets all of the tokens between two non-overlapping nodes.
  96354. * @param {ASTNode|Token|Comment} left Node before the desired token range.
  96355. * @param {ASTNode|Token|Comment} right Node after the desired token range.
  96356. * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
  96357. * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
  96358. * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
  96359. * @param {number} [options.count=0] - The maximum count of tokens the cursor iterates.
  96360. * @returns {Token[]} Tokens between left and right.
  96361. */
  96362. /**
  96363. * Gets all of the tokens between two non-overlapping nodes.
  96364. * @param {ASTNode|Token|Comment} left Node before the desired token range.
  96365. * @param {ASTNode|Token|Comment} right Node after the desired token range.
  96366. * @param {int} [padding=0] Number of extra tokens on either side of center.
  96367. * @returns {Token[]} Tokens between left and right.
  96368. */
  96369. }, {
  96370. key: "getTokensBetween",
  96371. value: function getTokensBetween(left, right, padding) {
  96372. return createCursorWithPadding(this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], padding, padding).getAllTokens();
  96373. }
  96374. //--------------------------------------------------------------------------
  96375. // Others.
  96376. //--------------------------------------------------------------------------
  96377. /**
  96378. * Checks whether any comments exist or not between the given 2 nodes.
  96379. *
  96380. * @param {ASTNode} left - The node to check.
  96381. * @param {ASTNode} right - The node to check.
  96382. * @returns {boolean} `true` if one or more comments exist.
  96383. */
  96384. }, {
  96385. key: "commentsExistBetween",
  96386. value: function commentsExistBetween(left, right) {
  96387. var index = utils.search(this[COMMENTS], left.range[1]);
  96388. return index < this[COMMENTS].length && this[COMMENTS][index].range[1] <= right.range[0];
  96389. }
  96390. /**
  96391. * Gets all comment tokens directly before the given node or token.
  96392. * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
  96393. * @returns {Array} An array of comments in occurrence order.
  96394. */
  96395. }, {
  96396. key: "getCommentsBefore",
  96397. value: function getCommentsBefore(nodeOrToken) {
  96398. var cursor = createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, nodeOrToken.range[0], { includeComments: true });
  96399. return getAdjacentCommentTokensFromCursor(cursor).reverse();
  96400. }
  96401. /**
  96402. * Gets all comment tokens directly after the given node or token.
  96403. * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
  96404. * @returns {Array} An array of comments in occurrence order.
  96405. */
  96406. }, {
  96407. key: "getCommentsAfter",
  96408. value: function getCommentsAfter(nodeOrToken) {
  96409. var cursor = createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], nodeOrToken.range[1], -1, { includeComments: true });
  96410. return getAdjacentCommentTokensFromCursor(cursor);
  96411. }
  96412. /**
  96413. * Gets all comment tokens inside the given node.
  96414. * @param {ASTNode} node The AST node to get the comments for.
  96415. * @returns {Array} An array of comments in occurrence order.
  96416. */
  96417. }, {
  96418. key: "getCommentsInside",
  96419. value: function getCommentsInside(node) {
  96420. return this.getTokens(node, {
  96421. includeComments: true,
  96422. filter: astUtils.isCommentToken
  96423. });
  96424. }
  96425. }]);
  96426. return TokenStore;
  96427. }();
  96428. },{"../util/ast-utils":405,"./cursors":393,"./forward-token-cursor":397,"./padded-token-cursor":400,"./utils":402,"assert":46}],399:[function(require,module,exports){
  96429. /**
  96430. * @fileoverview Define the cursor which limits the number of tokens.
  96431. * @author Toru Nagashima
  96432. */
  96433. "use strict";
  96434. //------------------------------------------------------------------------------
  96435. // Requirements
  96436. //------------------------------------------------------------------------------
  96437. 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; }; }();
  96438. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  96439. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  96440. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  96441. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  96442. var DecorativeCursor = require("./decorative-cursor");
  96443. //------------------------------------------------------------------------------
  96444. // Exports
  96445. //------------------------------------------------------------------------------
  96446. /**
  96447. * The decorative cursor which limits the number of tokens.
  96448. */
  96449. module.exports = function (_DecorativeCursor) {
  96450. _inherits(LimitCursor, _DecorativeCursor);
  96451. /**
  96452. * Initializes this cursor.
  96453. * @param {Cursor} cursor - The cursor to be decorated.
  96454. * @param {number} count - The count of tokens this cursor iterates.
  96455. */
  96456. function LimitCursor(cursor, count) {
  96457. _classCallCheck(this, LimitCursor);
  96458. var _this = _possibleConstructorReturn(this, (LimitCursor.__proto__ || Object.getPrototypeOf(LimitCursor)).call(this, cursor));
  96459. _this.count = count;
  96460. return _this;
  96461. }
  96462. /** @inheritdoc */
  96463. _createClass(LimitCursor, [{
  96464. key: "moveNext",
  96465. value: function moveNext() {
  96466. if (this.count > 0) {
  96467. this.count -= 1;
  96468. return _get(LimitCursor.prototype.__proto__ || Object.getPrototypeOf(LimitCursor.prototype), "moveNext", this).call(this);
  96469. }
  96470. return false;
  96471. }
  96472. }]);
  96473. return LimitCursor;
  96474. }(DecorativeCursor);
  96475. },{"./decorative-cursor":394}],400:[function(require,module,exports){
  96476. /**
  96477. * @fileoverview Define the cursor which iterates tokens only, with inflated range.
  96478. * @author Toru Nagashima
  96479. */
  96480. "use strict";
  96481. //------------------------------------------------------------------------------
  96482. // Requirements
  96483. //------------------------------------------------------------------------------
  96484. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  96485. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  96486. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  96487. var ForwardTokenCursor = require("./forward-token-cursor");
  96488. //------------------------------------------------------------------------------
  96489. // Exports
  96490. //------------------------------------------------------------------------------
  96491. /**
  96492. * The cursor which iterates tokens only, with inflated range.
  96493. * This is for the backward compatibility of padding options.
  96494. */
  96495. module.exports = function (_ForwardTokenCursor) {
  96496. _inherits(PaddedTokenCursor, _ForwardTokenCursor);
  96497. /**
  96498. * Initializes this cursor.
  96499. * @param {Token[]} tokens - The array of tokens.
  96500. * @param {Comment[]} comments - The array of comments.
  96501. * @param {Object} indexMap - The map from locations to indices in `tokens`.
  96502. * @param {number} startLoc - The start location of the iteration range.
  96503. * @param {number} endLoc - The end location of the iteration range.
  96504. * @param {number} beforeCount - The number of tokens this cursor iterates before start.
  96505. * @param {number} afterCount - The number of tokens this cursor iterates after end.
  96506. */
  96507. function PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
  96508. _classCallCheck(this, PaddedTokenCursor);
  96509. var _this = _possibleConstructorReturn(this, (PaddedTokenCursor.__proto__ || Object.getPrototypeOf(PaddedTokenCursor)).call(this, tokens, comments, indexMap, startLoc, endLoc));
  96510. _this.index = Math.max(0, _this.index - beforeCount);
  96511. _this.indexEnd = Math.min(tokens.length - 1, _this.indexEnd + afterCount);
  96512. return _this;
  96513. }
  96514. return PaddedTokenCursor;
  96515. }(ForwardTokenCursor);
  96516. },{"./forward-token-cursor":397}],401:[function(require,module,exports){
  96517. /**
  96518. * @fileoverview Define the cursor which ignores the first few tokens.
  96519. * @author Toru Nagashima
  96520. */
  96521. "use strict";
  96522. //------------------------------------------------------------------------------
  96523. // Requirements
  96524. //------------------------------------------------------------------------------
  96525. 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; }; }();
  96526. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  96527. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  96528. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  96529. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  96530. var DecorativeCursor = require("./decorative-cursor");
  96531. //------------------------------------------------------------------------------
  96532. // Exports
  96533. //------------------------------------------------------------------------------
  96534. /**
  96535. * The decorative cursor which ignores the first few tokens.
  96536. */
  96537. module.exports = function (_DecorativeCursor) {
  96538. _inherits(SkipCursor, _DecorativeCursor);
  96539. /**
  96540. * Initializes this cursor.
  96541. * @param {Cursor} cursor - The cursor to be decorated.
  96542. * @param {number} count - The count of tokens this cursor skips.
  96543. */
  96544. function SkipCursor(cursor, count) {
  96545. _classCallCheck(this, SkipCursor);
  96546. var _this = _possibleConstructorReturn(this, (SkipCursor.__proto__ || Object.getPrototypeOf(SkipCursor)).call(this, cursor));
  96547. _this.count = count;
  96548. return _this;
  96549. }
  96550. /** @inheritdoc */
  96551. _createClass(SkipCursor, [{
  96552. key: "moveNext",
  96553. value: function moveNext() {
  96554. while (this.count > 0) {
  96555. this.count -= 1;
  96556. if (!_get(SkipCursor.prototype.__proto__ || Object.getPrototypeOf(SkipCursor.prototype), "moveNext", this).call(this)) {
  96557. return false;
  96558. }
  96559. }
  96560. return _get(SkipCursor.prototype.__proto__ || Object.getPrototypeOf(SkipCursor.prototype), "moveNext", this).call(this);
  96561. }
  96562. }]);
  96563. return SkipCursor;
  96564. }(DecorativeCursor);
  96565. },{"./decorative-cursor":394}],402:[function(require,module,exports){
  96566. /**
  96567. * @fileoverview Define utilify functions for token store.
  96568. * @author Toru Nagashima
  96569. */
  96570. "use strict";
  96571. //------------------------------------------------------------------------------
  96572. // Requirements
  96573. //------------------------------------------------------------------------------
  96574. var lodash = require("lodash");
  96575. //------------------------------------------------------------------------------
  96576. // Helpers
  96577. //------------------------------------------------------------------------------
  96578. /**
  96579. * Gets `token.range[0]` from the given token.
  96580. *
  96581. * @param {Node|Token|Comment} token - The token to get.
  96582. * @returns {number} The start location.
  96583. * @private
  96584. */
  96585. function getStartLocation(token) {
  96586. return token.range[0];
  96587. }
  96588. //------------------------------------------------------------------------------
  96589. // Exports
  96590. //------------------------------------------------------------------------------
  96591. /**
  96592. * Binary-searches the index of the first token which is after the given location.
  96593. * If it was not found, this returns `tokens.length`.
  96594. *
  96595. * @param {(Token|Comment)[]} tokens - It searches the token in this list.
  96596. * @param {number} location - The location to search.
  96597. * @returns {number} The found index or `tokens.length`.
  96598. */
  96599. exports.search = function search(tokens, location) {
  96600. return lodash.sortedIndexBy(tokens, { range: [location] }, getStartLocation);
  96601. };
  96602. /**
  96603. * Gets the index of the `startLoc` in `tokens`.
  96604. * `startLoc` can be the value of `node.range[1]`, so this checks about `startLoc - 1` as well.
  96605. *
  96606. * @param {(Token|Comment)[]} tokens - The tokens to find an index.
  96607. * @param {Object} indexMap - The map from locations to indices.
  96608. * @param {number} startLoc - The location to get an index.
  96609. * @returns {number} The index.
  96610. */
  96611. exports.getFirstIndex = function getFirstIndex(tokens, indexMap, startLoc) {
  96612. if (startLoc in indexMap) {
  96613. return indexMap[startLoc];
  96614. }
  96615. if (startLoc - 1 in indexMap) {
  96616. var index = indexMap[startLoc - 1];
  96617. var token = index >= 0 && index < tokens.length ? tokens[index] : null;
  96618. /*
  96619. * For the map of "comment's location -> token's index", it points the next token of a comment.
  96620. * In that case, +1 is unnecessary.
  96621. */
  96622. if (token && token.range[0] >= startLoc) {
  96623. return index;
  96624. }
  96625. return index + 1;
  96626. }
  96627. return 0;
  96628. };
  96629. /**
  96630. * Gets the index of the `endLoc` in `tokens`.
  96631. * The information of end locations are recorded at `endLoc - 1` in `indexMap`, so this checks about `endLoc - 1` as well.
  96632. *
  96633. * @param {(Token|Comment)[]} tokens - The tokens to find an index.
  96634. * @param {Object} indexMap - The map from locations to indices.
  96635. * @param {number} endLoc - The location to get an index.
  96636. * @returns {number} The index.
  96637. */
  96638. exports.getLastIndex = function getLastIndex(tokens, indexMap, endLoc) {
  96639. if (endLoc in indexMap) {
  96640. return indexMap[endLoc] - 1;
  96641. }
  96642. if (endLoc - 1 in indexMap) {
  96643. var index = indexMap[endLoc - 1];
  96644. var token = index >= 0 && index < tokens.length ? tokens[index] : null;
  96645. /*
  96646. * For the map of "comment's location -> token's index", it points the next token of a comment.
  96647. * In that case, -1 is necessary.
  96648. */
  96649. if (token && token.range[1] > endLoc) {
  96650. return index - 1;
  96651. }
  96652. return index;
  96653. }
  96654. return tokens.length - 1;
  96655. };
  96656. },{"lodash":92}],403:[function(require,module,exports){
  96657. /**
  96658. * @fileoverview The instance of Ajv validator.
  96659. * @author Evgeny Poberezkin
  96660. */
  96661. "use strict";
  96662. //------------------------------------------------------------------------------
  96663. // Requirements
  96664. //------------------------------------------------------------------------------
  96665. var Ajv = require("ajv"),
  96666. metaSchema = require("ajv/lib/refs/json-schema-draft-04.json");
  96667. //------------------------------------------------------------------------------
  96668. // Public Interface
  96669. //------------------------------------------------------------------------------
  96670. var ajv = new Ajv({
  96671. meta: false,
  96672. validateSchema: false,
  96673. missingRefs: "ignore",
  96674. verbose: true,
  96675. schemaId: "auto"
  96676. });
  96677. ajv.addMetaSchema(metaSchema);
  96678. // eslint-disable-next-line no-underscore-dangle
  96679. ajv._opts.defaultMeta = metaSchema.id;
  96680. module.exports = ajv;
  96681. },{"ajv":4,"ajv/lib/refs/json-schema-draft-04.json":44}],404:[function(require,module,exports){
  96682. /**
  96683. * @fileoverview A module that filters reported problems based on `eslint-disable` and `eslint-enable` comments
  96684. * @author Teddy Katz
  96685. */
  96686. "use strict";
  96687. var lodash = require("lodash");
  96688. /**
  96689. * Compares the locations of two objects in a source file
  96690. * @param {{line: number, column: number}} itemA The first object
  96691. * @param {{line: number, column: number}} itemB The second object
  96692. * @returns {number} A value less than 1 if itemA appears before itemB in the source file, greater than 1 if
  96693. * itemA appears after itemB in the source file, or 0 if itemA and itemB have the same location.
  96694. */
  96695. function compareLocations(itemA, itemB) {
  96696. return itemA.line - itemB.line || itemA.column - itemB.column;
  96697. }
  96698. /**
  96699. * This is the same as the exported function, except that it
  96700. * doesn't handle disable-line and disable-next-line directives, and it always reports unused
  96701. * disable directives.
  96702. * @param {Object} options options for applying directives. This is the same as the options
  96703. * for the exported function, except that `reportUnusedDisableDirectives` is not supported
  96704. * (this function always reports unused disable directives).
  96705. * @returns {{problems: Problem[], unusedDisableDirectives: Problem[]}} An object with a list
  96706. * of filtered problems and unused eslint-disable directives
  96707. */
  96708. function applyDirectives(options) {
  96709. var problems = [];
  96710. var nextDirectiveIndex = 0;
  96711. var currentGlobalDisableDirective = null;
  96712. var disabledRuleMap = new Map();
  96713. // enabledRules is only used when there is a current global disable directive.
  96714. var enabledRules = new Set();
  96715. var usedDisableDirectives = new Set();
  96716. var _iteratorNormalCompletion = true;
  96717. var _didIteratorError = false;
  96718. var _iteratorError = undefined;
  96719. try {
  96720. for (var _iterator = options.problems[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  96721. var problem = _step.value;
  96722. while (nextDirectiveIndex < options.directives.length && compareLocations(options.directives[nextDirectiveIndex], problem) <= 0) {
  96723. var directive = options.directives[nextDirectiveIndex++];
  96724. switch (directive.type) {
  96725. case "disable":
  96726. if (directive.ruleId === null) {
  96727. currentGlobalDisableDirective = directive;
  96728. disabledRuleMap.clear();
  96729. enabledRules.clear();
  96730. } else if (currentGlobalDisableDirective) {
  96731. enabledRules.delete(directive.ruleId);
  96732. disabledRuleMap.set(directive.ruleId, directive);
  96733. } else {
  96734. disabledRuleMap.set(directive.ruleId, directive);
  96735. }
  96736. break;
  96737. case "enable":
  96738. if (directive.ruleId === null) {
  96739. currentGlobalDisableDirective = null;
  96740. disabledRuleMap.clear();
  96741. } else if (currentGlobalDisableDirective) {
  96742. enabledRules.add(directive.ruleId);
  96743. disabledRuleMap.delete(directive.ruleId);
  96744. } else {
  96745. disabledRuleMap.delete(directive.ruleId);
  96746. }
  96747. break;
  96748. // no default
  96749. }
  96750. }
  96751. if (disabledRuleMap.has(problem.ruleId)) {
  96752. usedDisableDirectives.add(disabledRuleMap.get(problem.ruleId));
  96753. } else if (currentGlobalDisableDirective && !enabledRules.has(problem.ruleId)) {
  96754. usedDisableDirectives.add(currentGlobalDisableDirective);
  96755. } else {
  96756. problems.push(problem);
  96757. }
  96758. }
  96759. } catch (err) {
  96760. _didIteratorError = true;
  96761. _iteratorError = err;
  96762. } finally {
  96763. try {
  96764. if (!_iteratorNormalCompletion && _iterator.return) {
  96765. _iterator.return();
  96766. }
  96767. } finally {
  96768. if (_didIteratorError) {
  96769. throw _iteratorError;
  96770. }
  96771. }
  96772. }
  96773. var unusedDisableDirectives = options.directives.filter(function (directive) {
  96774. return directive.type === "disable" && !usedDisableDirectives.has(directive);
  96775. }).map(function (directive) {
  96776. return {
  96777. ruleId: null,
  96778. message: directive.ruleId ? "Unused eslint-disable directive (no problems were reported from '" + directive.ruleId + "')." : "Unused eslint-disable directive (no problems were reported).",
  96779. line: directive.unprocessedDirective.line,
  96780. column: directive.unprocessedDirective.column,
  96781. severity: 2,
  96782. nodeType: null
  96783. };
  96784. });
  96785. return { problems: problems, unusedDisableDirectives: unusedDisableDirectives };
  96786. }
  96787. /**
  96788. * Given a list of directive comments (i.e. metadata about eslint-disable and eslint-enable comments) and a list
  96789. * of reported problems, determines which problems should be reported.
  96790. * @param {Object} options Information about directives and problems
  96791. * @param {{
  96792. * type: ("disable"|"enable"|"disable-line"|"disable-next-line"),
  96793. * ruleId: (string|null),
  96794. * line: number,
  96795. * column: number
  96796. * }} options.directives Directive comments found in the file, with one-based columns.
  96797. * Two directive comments can only have the same location if they also have the same type (e.g. a single eslint-disable
  96798. * comment for two different rules is represented as two directives).
  96799. * @param {{ruleId: (string|null), line: number, column: number}[]} options.problems
  96800. * A list of problems reported by rules, sorted by increasing location in the file, with one-based columns.
  96801. * @param {boolean} options.reportUnusedDisableDirectives If `true`, adds additional problems for unused directives
  96802. * @returns {{ruleId: (string|null), line: number, column: number}[]}
  96803. * A list of reported problems that were not disabled by the directive comments.
  96804. */
  96805. module.exports = function (options) {
  96806. var blockDirectives = options.directives.filter(function (directive) {
  96807. return directive.type === "disable" || directive.type === "enable";
  96808. }).map(function (directive) {
  96809. return Object.assign({}, directive, { unprocessedDirective: directive });
  96810. }).sort(compareLocations);
  96811. var lineDirectives = lodash.flatMap(options.directives, function (directive) {
  96812. switch (directive.type) {
  96813. case "disable":
  96814. case "enable":
  96815. return [];
  96816. case "disable-line":
  96817. return [{ type: "disable", line: directive.line, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive }, { type: "enable", line: directive.line + 1, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }];
  96818. case "disable-next-line":
  96819. return [{ type: "disable", line: directive.line + 1, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive }, { type: "enable", line: directive.line + 2, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }];
  96820. default:
  96821. throw new TypeError("Unrecognized directive type '" + directive.type + "'");
  96822. }
  96823. }).sort(compareLocations);
  96824. var blockDirectivesResult = applyDirectives({ problems: options.problems, directives: blockDirectives });
  96825. var lineDirectivesResult = applyDirectives({ problems: blockDirectivesResult.problems, directives: lineDirectives });
  96826. return options.reportUnusedDisableDirectives ? lineDirectivesResult.problems.concat(blockDirectivesResult.unusedDisableDirectives).concat(lineDirectivesResult.unusedDisableDirectives).sort(compareLocations) : lineDirectivesResult.problems;
  96827. };
  96828. },{"lodash":92}],405:[function(require,module,exports){
  96829. /**
  96830. * @fileoverview Common utils for AST.
  96831. * @author Gyandeep Singh
  96832. */
  96833. "use strict";
  96834. //------------------------------------------------------------------------------
  96835. // Requirements
  96836. //------------------------------------------------------------------------------
  96837. var esutils = require("esutils");
  96838. var espree = require("espree");
  96839. //------------------------------------------------------------------------------
  96840. // Helpers
  96841. //------------------------------------------------------------------------------
  96842. var anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/;
  96843. var anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/;
  96844. var arrayOrTypedArrayPattern = /Array$/;
  96845. var arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/;
  96846. var bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/;
  96847. var breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/;
  96848. var thisTagPattern = /^[\s*]*@this/m;
  96849. var COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/;
  96850. var LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
  96851. var LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/;
  96852. var SHEBANG_MATCHER = /^#!([^\r\n]+)/;
  96853. // A set of node types that can contain a list of statements
  96854. var STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
  96855. /**
  96856. * Checks reference if is non initializer and writable.
  96857. * @param {Reference} reference - A reference to check.
  96858. * @param {int} index - The index of the reference in the references.
  96859. * @param {Reference[]} references - The array that the reference belongs to.
  96860. * @returns {boolean} Success/Failure
  96861. * @private
  96862. */
  96863. function isModifyingReference(reference, index, references) {
  96864. var identifier = reference.identifier;
  96865. /*
  96866. * Destructuring assignments can have multiple default value, so
  96867. * possibly there are multiple writeable references for the same
  96868. * identifier.
  96869. */
  96870. var modifyingDifferentIdentifier = index === 0 || references[index - 1].identifier !== identifier;
  96871. return identifier && reference.init === false && reference.isWrite() && modifyingDifferentIdentifier;
  96872. }
  96873. /**
  96874. * Checks whether the given string starts with uppercase or not.
  96875. *
  96876. * @param {string} s - The string to check.
  96877. * @returns {boolean} `true` if the string starts with uppercase.
  96878. */
  96879. function startsWithUpperCase(s) {
  96880. return s[0] !== s[0].toLocaleLowerCase();
  96881. }
  96882. /**
  96883. * Checks whether or not a node is a constructor.
  96884. * @param {ASTNode} node - A function node to check.
  96885. * @returns {boolean} Wehether or not a node is a constructor.
  96886. */
  96887. function isES5Constructor(node) {
  96888. return node.id && startsWithUpperCase(node.id.name);
  96889. }
  96890. /**
  96891. * Finds a function node from ancestors of a node.
  96892. * @param {ASTNode} node - A start node to find.
  96893. * @returns {Node|null} A found function node.
  96894. */
  96895. function getUpperFunction(node) {
  96896. for (var currentNode = node; currentNode; currentNode = currentNode.parent) {
  96897. if (anyFunctionPattern.test(currentNode.type)) {
  96898. return currentNode;
  96899. }
  96900. }
  96901. return null;
  96902. }
  96903. /**
  96904. * Checks whether a given node is a function node or not.
  96905. * The following types are function nodes:
  96906. *
  96907. * - ArrowFunctionExpression
  96908. * - FunctionDeclaration
  96909. * - FunctionExpression
  96910. *
  96911. * @param {ASTNode|null} node - A node to check.
  96912. * @returns {boolean} `true` if the node is a function node.
  96913. */
  96914. function isFunction(node) {
  96915. return Boolean(node && anyFunctionPattern.test(node.type));
  96916. }
  96917. /**
  96918. * Checks whether a given node is a loop node or not.
  96919. * The following types are loop nodes:
  96920. *
  96921. * - DoWhileStatement
  96922. * - ForInStatement
  96923. * - ForOfStatement
  96924. * - ForStatement
  96925. * - WhileStatement
  96926. *
  96927. * @param {ASTNode|null} node - A node to check.
  96928. * @returns {boolean} `true` if the node is a loop node.
  96929. */
  96930. function isLoop(node) {
  96931. return Boolean(node && anyLoopPattern.test(node.type));
  96932. }
  96933. /**
  96934. * Checks whether the given node is in a loop or not.
  96935. *
  96936. * @param {ASTNode} node - The node to check.
  96937. * @returns {boolean} `true` if the node is in a loop.
  96938. */
  96939. function isInLoop(node) {
  96940. for (var currentNode = node; currentNode && !isFunction(currentNode); currentNode = currentNode.parent) {
  96941. if (isLoop(currentNode)) {
  96942. return true;
  96943. }
  96944. }
  96945. return false;
  96946. }
  96947. /**
  96948. * Checks whether or not a node is `null` or `undefined`.
  96949. * @param {ASTNode} node - A node to check.
  96950. * @returns {boolean} Whether or not the node is a `null` or `undefined`.
  96951. * @public
  96952. */
  96953. function isNullOrUndefined(node) {
  96954. return module.exports.isNullLiteral(node) || node.type === "Identifier" && node.name === "undefined" || node.type === "UnaryExpression" && node.operator === "void";
  96955. }
  96956. /**
  96957. * Checks whether or not a node is callee.
  96958. * @param {ASTNode} node - A node to check.
  96959. * @returns {boolean} Whether or not the node is callee.
  96960. */
  96961. function isCallee(node) {
  96962. return node.parent.type === "CallExpression" && node.parent.callee === node;
  96963. }
  96964. /**
  96965. * Checks whether or not a node is `Reflect.apply`.
  96966. * @param {ASTNode} node - A node to check.
  96967. * @returns {boolean} Whether or not the node is a `Reflect.apply`.
  96968. */
  96969. function isReflectApply(node) {
  96970. return node.type === "MemberExpression" && node.object.type === "Identifier" && node.object.name === "Reflect" && node.property.type === "Identifier" && node.property.name === "apply" && node.computed === false;
  96971. }
  96972. /**
  96973. * Checks whether or not a node is `Array.from`.
  96974. * @param {ASTNode} node - A node to check.
  96975. * @returns {boolean} Whether or not the node is a `Array.from`.
  96976. */
  96977. function isArrayFromMethod(node) {
  96978. return node.type === "MemberExpression" && node.object.type === "Identifier" && arrayOrTypedArrayPattern.test(node.object.name) && node.property.type === "Identifier" && node.property.name === "from" && node.computed === false;
  96979. }
  96980. /**
  96981. * Checks whether or not a node is a method which has `thisArg`.
  96982. * @param {ASTNode} node - A node to check.
  96983. * @returns {boolean} Whether or not the node is a method which has `thisArg`.
  96984. */
  96985. function isMethodWhichHasThisArg(node) {
  96986. for (var currentNode = node; currentNode.type === "MemberExpression" && !currentNode.computed; currentNode = currentNode.property) {
  96987. if (currentNode.property.type === "Identifier") {
  96988. return arrayMethodPattern.test(currentNode.property.name);
  96989. }
  96990. }
  96991. return false;
  96992. }
  96993. /**
  96994. * Creates the negate function of the given function.
  96995. * @param {Function} f - The function to negate.
  96996. * @returns {Function} Negated function.
  96997. */
  96998. function negate(f) {
  96999. return function (token) {
  97000. return !f(token);
  97001. };
  97002. }
  97003. /**
  97004. * Checks whether or not a node has a `@this` tag in its comments.
  97005. * @param {ASTNode} node - A node to check.
  97006. * @param {SourceCode} sourceCode - A SourceCode instance to get comments.
  97007. * @returns {boolean} Whether or not the node has a `@this` tag in its comments.
  97008. */
  97009. function hasJSDocThisTag(node, sourceCode) {
  97010. var jsdocComment = sourceCode.getJSDocComment(node);
  97011. if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
  97012. return true;
  97013. }
  97014. // Checks `@this` in its leading comments for callbacks,
  97015. // because callbacks don't have its JSDoc comment.
  97016. // e.g.
  97017. // sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
  97018. return sourceCode.getCommentsBefore(node).some(function (comment) {
  97019. return thisTagPattern.test(comment.value);
  97020. });
  97021. }
  97022. /**
  97023. * Determines if a node is surrounded by parentheses.
  97024. * @param {SourceCode} sourceCode The ESLint source code object
  97025. * @param {ASTNode} node The node to be checked.
  97026. * @returns {boolean} True if the node is parenthesised.
  97027. * @private
  97028. */
  97029. function isParenthesised(sourceCode, node) {
  97030. var previousToken = sourceCode.getTokenBefore(node),
  97031. nextToken = sourceCode.getTokenAfter(node);
  97032. return Boolean(previousToken && nextToken) && previousToken.value === "(" && previousToken.range[1] <= node.range[0] && nextToken.value === ")" && nextToken.range[0] >= node.range[1];
  97033. }
  97034. /**
  97035. * Checks if the given token is an arrow token or not.
  97036. *
  97037. * @param {Token} token - The token to check.
  97038. * @returns {boolean} `true` if the token is an arrow token.
  97039. */
  97040. function isArrowToken(token) {
  97041. return token.value === "=>" && token.type === "Punctuator";
  97042. }
  97043. /**
  97044. * Checks if the given token is a comma token or not.
  97045. *
  97046. * @param {Token} token - The token to check.
  97047. * @returns {boolean} `true` if the token is a comma token.
  97048. */
  97049. function isCommaToken(token) {
  97050. return token.value === "," && token.type === "Punctuator";
  97051. }
  97052. /**
  97053. * Checks if the given token is a semicolon token or not.
  97054. *
  97055. * @param {Token} token - The token to check.
  97056. * @returns {boolean} `true` if the token is a semicolon token.
  97057. */
  97058. function isSemicolonToken(token) {
  97059. return token.value === ";" && token.type === "Punctuator";
  97060. }
  97061. /**
  97062. * Checks if the given token is a colon token or not.
  97063. *
  97064. * @param {Token} token - The token to check.
  97065. * @returns {boolean} `true` if the token is a colon token.
  97066. */
  97067. function isColonToken(token) {
  97068. return token.value === ":" && token.type === "Punctuator";
  97069. }
  97070. /**
  97071. * Checks if the given token is an opening parenthesis token or not.
  97072. *
  97073. * @param {Token} token - The token to check.
  97074. * @returns {boolean} `true` if the token is an opening parenthesis token.
  97075. */
  97076. function isOpeningParenToken(token) {
  97077. return token.value === "(" && token.type === "Punctuator";
  97078. }
  97079. /**
  97080. * Checks if the given token is a closing parenthesis token or not.
  97081. *
  97082. * @param {Token} token - The token to check.
  97083. * @returns {boolean} `true` if the token is a closing parenthesis token.
  97084. */
  97085. function isClosingParenToken(token) {
  97086. return token.value === ")" && token.type === "Punctuator";
  97087. }
  97088. /**
  97089. * Checks if the given token is an opening square bracket token or not.
  97090. *
  97091. * @param {Token} token - The token to check.
  97092. * @returns {boolean} `true` if the token is an opening square bracket token.
  97093. */
  97094. function isOpeningBracketToken(token) {
  97095. return token.value === "[" && token.type === "Punctuator";
  97096. }
  97097. /**
  97098. * Checks if the given token is a closing square bracket token or not.
  97099. *
  97100. * @param {Token} token - The token to check.
  97101. * @returns {boolean} `true` if the token is a closing square bracket token.
  97102. */
  97103. function isClosingBracketToken(token) {
  97104. return token.value === "]" && token.type === "Punctuator";
  97105. }
  97106. /**
  97107. * Checks if the given token is an opening brace token or not.
  97108. *
  97109. * @param {Token} token - The token to check.
  97110. * @returns {boolean} `true` if the token is an opening brace token.
  97111. */
  97112. function isOpeningBraceToken(token) {
  97113. return token.value === "{" && token.type === "Punctuator";
  97114. }
  97115. /**
  97116. * Checks if the given token is a closing brace token or not.
  97117. *
  97118. * @param {Token} token - The token to check.
  97119. * @returns {boolean} `true` if the token is a closing brace token.
  97120. */
  97121. function isClosingBraceToken(token) {
  97122. return token.value === "}" && token.type === "Punctuator";
  97123. }
  97124. /**
  97125. * Checks if the given token is a comment token or not.
  97126. *
  97127. * @param {Token} token - The token to check.
  97128. * @returns {boolean} `true` if the token is a comment token.
  97129. */
  97130. function isCommentToken(token) {
  97131. return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
  97132. }
  97133. /**
  97134. * Checks if the given token is a keyword token or not.
  97135. *
  97136. * @param {Token} token - The token to check.
  97137. * @returns {boolean} `true` if the token is a keyword token.
  97138. */
  97139. function isKeywordToken(token) {
  97140. return token.type === "Keyword";
  97141. }
  97142. /**
  97143. * Gets the `(` token of the given function node.
  97144. *
  97145. * @param {ASTNode} node - The function node to get.
  97146. * @param {SourceCode} sourceCode - The source code object to get tokens.
  97147. * @returns {Token} `(` token.
  97148. */
  97149. function getOpeningParenOfParams(node, sourceCode) {
  97150. return node.id ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) : sourceCode.getFirstToken(node, isOpeningParenToken);
  97151. }
  97152. /**
  97153. * Creates a version of the LINEBREAK_MATCHER regex with the global flag.
  97154. * Global regexes are mutable, so this needs to be a function instead of a constant.
  97155. * @returns {RegExp} A global regular expression that matches line terminators
  97156. */
  97157. function createGlobalLinebreakMatcher() {
  97158. return new RegExp(LINEBREAK_MATCHER.source, "g");
  97159. }
  97160. /**
  97161. * Checks whether or not the tokens of two given nodes are same.
  97162. * @param {ASTNode} left - A node 1 to compare.
  97163. * @param {ASTNode} right - A node 2 to compare.
  97164. * @param {SourceCode} sourceCode - The ESLint source code object.
  97165. * @returns {boolean} the source code for the given node.
  97166. */
  97167. function equalTokens(left, right, sourceCode) {
  97168. var tokensL = sourceCode.getTokens(left);
  97169. var tokensR = sourceCode.getTokens(right);
  97170. if (tokensL.length !== tokensR.length) {
  97171. return false;
  97172. }
  97173. for (var i = 0; i < tokensL.length; ++i) {
  97174. if (tokensL[i].type !== tokensR[i].type || tokensL[i].value !== tokensR[i].value) {
  97175. return false;
  97176. }
  97177. }
  97178. return true;
  97179. }
  97180. //------------------------------------------------------------------------------
  97181. // Public Interface
  97182. //------------------------------------------------------------------------------
  97183. module.exports = {
  97184. COMMENTS_IGNORE_PATTERN: COMMENTS_IGNORE_PATTERN,
  97185. LINEBREAKS: LINEBREAKS,
  97186. LINEBREAK_MATCHER: LINEBREAK_MATCHER,
  97187. SHEBANG_MATCHER: SHEBANG_MATCHER,
  97188. STATEMENT_LIST_PARENTS: STATEMENT_LIST_PARENTS,
  97189. /**
  97190. * Determines whether two adjacent tokens are on the same line.
  97191. * @param {Object} left - The left token object.
  97192. * @param {Object} right - The right token object.
  97193. * @returns {boolean} Whether or not the tokens are on the same line.
  97194. * @public
  97195. */
  97196. isTokenOnSameLine: function isTokenOnSameLine(left, right) {
  97197. return left.loc.end.line === right.loc.start.line;
  97198. },
  97199. isNullOrUndefined: isNullOrUndefined,
  97200. isCallee: isCallee,
  97201. isES5Constructor: isES5Constructor,
  97202. getUpperFunction: getUpperFunction,
  97203. isFunction: isFunction,
  97204. isLoop: isLoop,
  97205. isInLoop: isInLoop,
  97206. isArrayFromMethod: isArrayFromMethod,
  97207. isParenthesised: isParenthesised,
  97208. createGlobalLinebreakMatcher: createGlobalLinebreakMatcher,
  97209. equalTokens: equalTokens,
  97210. isArrowToken: isArrowToken,
  97211. isClosingBraceToken: isClosingBraceToken,
  97212. isClosingBracketToken: isClosingBracketToken,
  97213. isClosingParenToken: isClosingParenToken,
  97214. isColonToken: isColonToken,
  97215. isCommaToken: isCommaToken,
  97216. isCommentToken: isCommentToken,
  97217. isKeywordToken: isKeywordToken,
  97218. isNotClosingBraceToken: negate(isClosingBraceToken),
  97219. isNotClosingBracketToken: negate(isClosingBracketToken),
  97220. isNotClosingParenToken: negate(isClosingParenToken),
  97221. isNotColonToken: negate(isColonToken),
  97222. isNotCommaToken: negate(isCommaToken),
  97223. isNotOpeningBraceToken: negate(isOpeningBraceToken),
  97224. isNotOpeningBracketToken: negate(isOpeningBracketToken),
  97225. isNotOpeningParenToken: negate(isOpeningParenToken),
  97226. isNotSemicolonToken: negate(isSemicolonToken),
  97227. isOpeningBraceToken: isOpeningBraceToken,
  97228. isOpeningBracketToken: isOpeningBracketToken,
  97229. isOpeningParenToken: isOpeningParenToken,
  97230. isSemicolonToken: isSemicolonToken,
  97231. /**
  97232. * Checks whether or not a given node is a string literal.
  97233. * @param {ASTNode} node - A node to check.
  97234. * @returns {boolean} `true` if the node is a string literal.
  97235. */
  97236. isStringLiteral: function isStringLiteral(node) {
  97237. return node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral";
  97238. },
  97239. /**
  97240. * Checks whether a given node is a breakable statement or not.
  97241. * The node is breakable if the node is one of the following type:
  97242. *
  97243. * - DoWhileStatement
  97244. * - ForInStatement
  97245. * - ForOfStatement
  97246. * - ForStatement
  97247. * - SwitchStatement
  97248. * - WhileStatement
  97249. *
  97250. * @param {ASTNode} node - A node to check.
  97251. * @returns {boolean} `true` if the node is breakable.
  97252. */
  97253. isBreakableStatement: function isBreakableStatement(node) {
  97254. return breakableTypePattern.test(node.type);
  97255. },
  97256. /**
  97257. * Gets the label if the parent node of a given node is a LabeledStatement.
  97258. *
  97259. * @param {ASTNode} node - A node to get.
  97260. * @returns {string|null} The label or `null`.
  97261. */
  97262. getLabel: function getLabel(node) {
  97263. if (node.parent.type === "LabeledStatement") {
  97264. return node.parent.label.name;
  97265. }
  97266. return null;
  97267. },
  97268. /**
  97269. * Gets references which are non initializer and writable.
  97270. * @param {Reference[]} references - An array of references.
  97271. * @returns {Reference[]} An array of only references which are non initializer and writable.
  97272. * @public
  97273. */
  97274. getModifyingReferences: function getModifyingReferences(references) {
  97275. return references.filter(isModifyingReference);
  97276. },
  97277. /**
  97278. * Validate that a string passed in is surrounded by the specified character
  97279. * @param {string} val The text to check.
  97280. * @param {string} character The character to see if it's surrounded by.
  97281. * @returns {boolean} True if the text is surrounded by the character, false if not.
  97282. * @private
  97283. */
  97284. isSurroundedBy: function isSurroundedBy(val, character) {
  97285. return val[0] === character && val[val.length - 1] === character;
  97286. },
  97287. /**
  97288. * Returns whether the provided node is an ESLint directive comment or not
  97289. * @param {Line|Block} node The comment token to be checked
  97290. * @returns {boolean} `true` if the node is an ESLint directive comment
  97291. */
  97292. isDirectiveComment: function isDirectiveComment(node) {
  97293. var comment = node.value.trim();
  97294. return node.type === "Line" && comment.indexOf("eslint-") === 0 || node.type === "Block" && (comment.indexOf("global ") === 0 || comment.indexOf("eslint ") === 0 || comment.indexOf("eslint-") === 0);
  97295. },
  97296. /**
  97297. * Gets the trailing statement of a given node.
  97298. *
  97299. * if (code)
  97300. * consequent;
  97301. *
  97302. * When taking this `IfStatement`, returns `consequent;` statement.
  97303. *
  97304. * @param {ASTNode} A node to get.
  97305. * @returns {ASTNode|null} The trailing statement's node.
  97306. */
  97307. getTrailingStatement: esutils.ast.trailingStatement,
  97308. /**
  97309. * Finds the variable by a given name in a given scope and its upper scopes.
  97310. *
  97311. * @param {eslint-scope.Scope} initScope - A scope to start find.
  97312. * @param {string} name - A variable name to find.
  97313. * @returns {eslint-scope.Variable|null} A found variable or `null`.
  97314. */
  97315. getVariableByName: function getVariableByName(initScope, name) {
  97316. var scope = initScope;
  97317. while (scope) {
  97318. var variable = scope.set.get(name);
  97319. if (variable) {
  97320. return variable;
  97321. }
  97322. scope = scope.upper;
  97323. }
  97324. return null;
  97325. },
  97326. /**
  97327. * Checks whether or not a given function node is the default `this` binding.
  97328. *
  97329. * First, this checks the node:
  97330. *
  97331. * - The function name does not start with uppercase (it's a constructor).
  97332. * - The function does not have a JSDoc comment that has a @this tag.
  97333. *
  97334. * Next, this checks the location of the node.
  97335. * If the location is below, this judges `this` is valid.
  97336. *
  97337. * - The location is not on an object literal.
  97338. * - The location is not assigned to a variable which starts with an uppercase letter.
  97339. * - The location is not on an ES2015 class.
  97340. * - Its `bind`/`call`/`apply` method is not called directly.
  97341. * - The function is not a callback of array methods (such as `.forEach()`) if `thisArg` is given.
  97342. *
  97343. * @param {ASTNode} node - A function node to check.
  97344. * @param {SourceCode} sourceCode - A SourceCode instance to get comments.
  97345. * @returns {boolean} The function node is the default `this` binding.
  97346. */
  97347. isDefaultThisBinding: function isDefaultThisBinding(node, sourceCode) {
  97348. if (isES5Constructor(node) || hasJSDocThisTag(node, sourceCode)) {
  97349. return false;
  97350. }
  97351. var isAnonymous = node.id === null;
  97352. var currentNode = node;
  97353. while (currentNode) {
  97354. var parent = currentNode.parent;
  97355. switch (parent.type) {
  97356. /*
  97357. * Looks up the destination.
  97358. * e.g., obj.foo = nativeFoo || function foo() { ... };
  97359. */
  97360. case "LogicalExpression":
  97361. case "ConditionalExpression":
  97362. currentNode = parent;
  97363. break;
  97364. /*
  97365. * If the upper function is IIFE, checks the destination of the return value.
  97366. * e.g.
  97367. * obj.foo = (function() {
  97368. * // setup...
  97369. * return function foo() { ... };
  97370. * })();
  97371. * obj.foo = (() =>
  97372. * function foo() { ... }
  97373. * )();
  97374. */
  97375. case "ReturnStatement":
  97376. {
  97377. var func = getUpperFunction(parent);
  97378. if (func === null || !isCallee(func)) {
  97379. return true;
  97380. }
  97381. currentNode = func.parent;
  97382. break;
  97383. }
  97384. case "ArrowFunctionExpression":
  97385. if (currentNode !== parent.body || !isCallee(parent)) {
  97386. return true;
  97387. }
  97388. currentNode = parent.parent;
  97389. break;
  97390. /*
  97391. * e.g.
  97392. * var obj = { foo() { ... } };
  97393. * var obj = { foo: function() { ... } };
  97394. * class A { constructor() { ... } }
  97395. * class A { foo() { ... } }
  97396. * class A { get foo() { ... } }
  97397. * class A { set foo() { ... } }
  97398. * class A { static foo() { ... } }
  97399. */
  97400. case "Property":
  97401. case "MethodDefinition":
  97402. return parent.value !== currentNode;
  97403. /*
  97404. * e.g.
  97405. * obj.foo = function foo() { ... };
  97406. * Foo = function() { ... };
  97407. * [obj.foo = function foo() { ... }] = a;
  97408. * [Foo = function() { ... }] = a;
  97409. */
  97410. case "AssignmentExpression":
  97411. case "AssignmentPattern":
  97412. if (parent.left.type === "MemberExpression") {
  97413. return false;
  97414. }
  97415. if (isAnonymous && parent.left.type === "Identifier" && startsWithUpperCase(parent.left.name)) {
  97416. return false;
  97417. }
  97418. return true;
  97419. /*
  97420. * e.g.
  97421. * var Foo = function() { ... };
  97422. */
  97423. case "VariableDeclarator":
  97424. return !(isAnonymous && parent.init === currentNode && parent.id.type === "Identifier" && startsWithUpperCase(parent.id.name));
  97425. /*
  97426. * e.g.
  97427. * var foo = function foo() { ... }.bind(obj);
  97428. * (function foo() { ... }).call(obj);
  97429. * (function foo() { ... }).apply(obj, []);
  97430. */
  97431. case "MemberExpression":
  97432. return parent.object !== currentNode || parent.property.type !== "Identifier" || !bindOrCallOrApplyPattern.test(parent.property.name) || !isCallee(parent) || parent.parent.arguments.length === 0 || isNullOrUndefined(parent.parent.arguments[0]);
  97433. /*
  97434. * e.g.
  97435. * Reflect.apply(function() {}, obj, []);
  97436. * Array.from([], function() {}, obj);
  97437. * list.forEach(function() {}, obj);
  97438. */
  97439. case "CallExpression":
  97440. if (isReflectApply(parent.callee)) {
  97441. return parent.arguments.length !== 3 || parent.arguments[0] !== currentNode || isNullOrUndefined(parent.arguments[1]);
  97442. }
  97443. if (isArrayFromMethod(parent.callee)) {
  97444. return parent.arguments.length !== 3 || parent.arguments[1] !== currentNode || isNullOrUndefined(parent.arguments[2]);
  97445. }
  97446. if (isMethodWhichHasThisArg(parent.callee)) {
  97447. return parent.arguments.length !== 2 || parent.arguments[0] !== currentNode || isNullOrUndefined(parent.arguments[1]);
  97448. }
  97449. return true;
  97450. // Otherwise `this` is default.
  97451. default:
  97452. return true;
  97453. }
  97454. }
  97455. /* istanbul ignore next */
  97456. return true;
  97457. },
  97458. /**
  97459. * Get the precedence level based on the node type
  97460. * @param {ASTNode} node node to evaluate
  97461. * @returns {int} precedence level
  97462. * @private
  97463. */
  97464. getPrecedence: function getPrecedence(node) {
  97465. switch (node.type) {
  97466. case "SequenceExpression":
  97467. return 0;
  97468. case "AssignmentExpression":
  97469. case "ArrowFunctionExpression":
  97470. case "YieldExpression":
  97471. return 1;
  97472. case "ConditionalExpression":
  97473. return 3;
  97474. case "LogicalExpression":
  97475. switch (node.operator) {
  97476. case "||":
  97477. return 4;
  97478. case "&&":
  97479. return 5;
  97480. // no default
  97481. }
  97482. /* falls through */
  97483. case "BinaryExpression":
  97484. switch (node.operator) {
  97485. case "|":
  97486. return 6;
  97487. case "^":
  97488. return 7;
  97489. case "&":
  97490. return 8;
  97491. case "==":
  97492. case "!=":
  97493. case "===":
  97494. case "!==":
  97495. return 9;
  97496. case "<":
  97497. case "<=":
  97498. case ">":
  97499. case ">=":
  97500. case "in":
  97501. case "instanceof":
  97502. return 10;
  97503. case "<<":
  97504. case ">>":
  97505. case ">>>":
  97506. return 11;
  97507. case "+":
  97508. case "-":
  97509. return 12;
  97510. case "*":
  97511. case "/":
  97512. case "%":
  97513. return 13;
  97514. case "**":
  97515. return 15;
  97516. // no default
  97517. }
  97518. /* falls through */
  97519. case "UnaryExpression":
  97520. case "AwaitExpression":
  97521. return 16;
  97522. case "UpdateExpression":
  97523. return 17;
  97524. case "CallExpression":
  97525. return 18;
  97526. case "NewExpression":
  97527. return 19;
  97528. default:
  97529. return 20;
  97530. }
  97531. },
  97532. /**
  97533. * Checks whether the given node is an empty block node or not.
  97534. *
  97535. * @param {ASTNode|null} node - The node to check.
  97536. * @returns {boolean} `true` if the node is an empty block.
  97537. */
  97538. isEmptyBlock: function isEmptyBlock(node) {
  97539. return Boolean(node && node.type === "BlockStatement" && node.body.length === 0);
  97540. },
  97541. /**
  97542. * Checks whether the given node is an empty function node or not.
  97543. *
  97544. * @param {ASTNode|null} node - The node to check.
  97545. * @returns {boolean} `true` if the node is an empty function.
  97546. */
  97547. isEmptyFunction: function isEmptyFunction(node) {
  97548. return isFunction(node) && module.exports.isEmptyBlock(node.body);
  97549. },
  97550. /**
  97551. * Gets the property name of a given node.
  97552. * The node can be a MemberExpression, a Property, or a MethodDefinition.
  97553. *
  97554. * If the name is dynamic, this returns `null`.
  97555. *
  97556. * For examples:
  97557. *
  97558. * a.b // => "b"
  97559. * a["b"] // => "b"
  97560. * a['b'] // => "b"
  97561. * a[`b`] // => "b"
  97562. * a[100] // => "100"
  97563. * a[b] // => null
  97564. * a["a" + "b"] // => null
  97565. * a[tag`b`] // => null
  97566. * a[`${b}`] // => null
  97567. *
  97568. * let a = {b: 1} // => "b"
  97569. * let a = {["b"]: 1} // => "b"
  97570. * let a = {['b']: 1} // => "b"
  97571. * let a = {[`b`]: 1} // => "b"
  97572. * let a = {[100]: 1} // => "100"
  97573. * let a = {[b]: 1} // => null
  97574. * let a = {["a" + "b"]: 1} // => null
  97575. * let a = {[tag`b`]: 1} // => null
  97576. * let a = {[`${b}`]: 1} // => null
  97577. *
  97578. * @param {ASTNode} node - The node to get.
  97579. * @returns {string|null} The property name if static. Otherwise, null.
  97580. */
  97581. getStaticPropertyName: function getStaticPropertyName(node) {
  97582. var prop = void 0;
  97583. switch (node && node.type) {
  97584. case "Property":
  97585. case "MethodDefinition":
  97586. prop = node.key;
  97587. break;
  97588. case "MemberExpression":
  97589. prop = node.property;
  97590. break;
  97591. // no default
  97592. }
  97593. switch (prop && prop.type) {
  97594. case "Literal":
  97595. return String(prop.value);
  97596. case "TemplateLiteral":
  97597. if (prop.expressions.length === 0 && prop.quasis.length === 1) {
  97598. return prop.quasis[0].value.cooked;
  97599. }
  97600. break;
  97601. case "Identifier":
  97602. if (!node.computed) {
  97603. return prop.name;
  97604. }
  97605. break;
  97606. // no default
  97607. }
  97608. return null;
  97609. },
  97610. /**
  97611. * Get directives from directive prologue of a Program or Function node.
  97612. * @param {ASTNode} node - The node to check.
  97613. * @returns {ASTNode[]} The directives found in the directive prologue.
  97614. */
  97615. getDirectivePrologue: function getDirectivePrologue(node) {
  97616. var directives = [];
  97617. // Directive prologues only occur at the top of files or functions.
  97618. if (node.type === "Program" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression" ||
  97619. /*
  97620. * Do not check arrow functions with implicit return.
  97621. * `() => "use strict";` returns the string `"use strict"`.
  97622. */
  97623. node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement") {
  97624. var statements = node.type === "Program" ? node.body : node.body.body;
  97625. var _iteratorNormalCompletion = true;
  97626. var _didIteratorError = false;
  97627. var _iteratorError = undefined;
  97628. try {
  97629. for (var _iterator = statements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  97630. var statement = _step.value;
  97631. if (statement.type === "ExpressionStatement" && statement.expression.type === "Literal") {
  97632. directives.push(statement);
  97633. } else {
  97634. break;
  97635. }
  97636. }
  97637. } catch (err) {
  97638. _didIteratorError = true;
  97639. _iteratorError = err;
  97640. } finally {
  97641. try {
  97642. if (!_iteratorNormalCompletion && _iterator.return) {
  97643. _iterator.return();
  97644. }
  97645. } finally {
  97646. if (_didIteratorError) {
  97647. throw _iteratorError;
  97648. }
  97649. }
  97650. }
  97651. }
  97652. return directives;
  97653. },
  97654. /**
  97655. * Determines whether this node is a decimal integer literal. If a node is a decimal integer literal, a dot added
  97656. * after the node will be parsed as a decimal point, rather than a property-access dot.
  97657. * @param {ASTNode} node - The node to check.
  97658. * @returns {boolean} `true` if this node is a decimal integer.
  97659. * @example
  97660. *
  97661. * 5 // true
  97662. * 5. // false
  97663. * 5.0 // false
  97664. * 05 // false
  97665. * 0x5 // false
  97666. * 0b101 // false
  97667. * 0o5 // false
  97668. * 5e0 // false
  97669. * '5' // false
  97670. */
  97671. isDecimalInteger: function isDecimalInteger(node) {
  97672. return node.type === "Literal" && typeof node.value === "number" && /^(0|[1-9]\d*)$/.test(node.raw);
  97673. },
  97674. /**
  97675. * Gets the name and kind of the given function node.
  97676. *
  97677. * - `function foo() {}` .................... `function 'foo'`
  97678. * - `(function foo() {})` .................. `function 'foo'`
  97679. * - `(function() {})` ...................... `function`
  97680. * - `function* foo() {}` ................... `generator function 'foo'`
  97681. * - `(function* foo() {})` ................. `generator function 'foo'`
  97682. * - `(function*() {})` ..................... `generator function`
  97683. * - `() => {}` ............................. `arrow function`
  97684. * - `async () => {}` ....................... `async arrow function`
  97685. * - `({ foo: function foo() {} })` ......... `method 'foo'`
  97686. * - `({ foo: function() {} })` ............. `method 'foo'`
  97687. * - `({ ['foo']: function() {} })` ......... `method 'foo'`
  97688. * - `({ [foo]: function() {} })` ........... `method`
  97689. * - `({ foo() {} })` ....................... `method 'foo'`
  97690. * - `({ foo: function* foo() {} })` ........ `generator method 'foo'`
  97691. * - `({ foo: function*() {} })` ............ `generator method 'foo'`
  97692. * - `({ ['foo']: function*() {} })` ........ `generator method 'foo'`
  97693. * - `({ [foo]: function*() {} })` .......... `generator method`
  97694. * - `({ *foo() {} })` ...................... `generator method 'foo'`
  97695. * - `({ foo: async function foo() {} })` ... `async method 'foo'`
  97696. * - `({ foo: async function() {} })` ....... `async method 'foo'`
  97697. * - `({ ['foo']: async function() {} })` ... `async method 'foo'`
  97698. * - `({ [foo]: async function() {} })` ..... `async method`
  97699. * - `({ async foo() {} })` ................. `async method 'foo'`
  97700. * - `({ get foo() {} })` ................... `getter 'foo'`
  97701. * - `({ set foo(a) {} })` .................. `setter 'foo'`
  97702. * - `class A { constructor() {} }` ......... `constructor`
  97703. * - `class A { foo() {} }` ................. `method 'foo'`
  97704. * - `class A { *foo() {} }` ................ `generator method 'foo'`
  97705. * - `class A { async foo() {} }` ........... `async method 'foo'`
  97706. * - `class A { ['foo']() {} }` ............. `method 'foo'`
  97707. * - `class A { *['foo']() {} }` ............ `generator method 'foo'`
  97708. * - `class A { async ['foo']() {} }` ....... `async method 'foo'`
  97709. * - `class A { [foo]() {} }` ............... `method`
  97710. * - `class A { *[foo]() {} }` .............. `generator method`
  97711. * - `class A { async [foo]() {} }` ......... `async method`
  97712. * - `class A { get foo() {} }` ............. `getter 'foo'`
  97713. * - `class A { set foo(a) {} }` ............ `setter 'foo'`
  97714. * - `class A { static foo() {} }` .......... `static method 'foo'`
  97715. * - `class A { static *foo() {} }` ......... `static generator method 'foo'`
  97716. * - `class A { static async foo() {} }` .... `static async method 'foo'`
  97717. * - `class A { static get foo() {} }` ...... `static getter 'foo'`
  97718. * - `class A { static set foo(a) {} }` ..... `static setter 'foo'`
  97719. *
  97720. * @param {ASTNode} node - The function node to get.
  97721. * @returns {string} The name and kind of the function node.
  97722. */
  97723. getFunctionNameWithKind: function getFunctionNameWithKind(node) {
  97724. var parent = node.parent;
  97725. var tokens = [];
  97726. if (parent.type === "MethodDefinition" && parent.static) {
  97727. tokens.push("static");
  97728. }
  97729. if (node.async) {
  97730. tokens.push("async");
  97731. }
  97732. if (node.generator) {
  97733. tokens.push("generator");
  97734. }
  97735. if (node.type === "ArrowFunctionExpression") {
  97736. tokens.push("arrow", "function");
  97737. } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
  97738. if (parent.kind === "constructor") {
  97739. return "constructor";
  97740. }
  97741. if (parent.kind === "get") {
  97742. tokens.push("getter");
  97743. } else if (parent.kind === "set") {
  97744. tokens.push("setter");
  97745. } else {
  97746. tokens.push("method");
  97747. }
  97748. } else {
  97749. tokens.push("function");
  97750. }
  97751. if (node.id) {
  97752. tokens.push("'" + node.id.name + "'");
  97753. } else {
  97754. var name = module.exports.getStaticPropertyName(parent);
  97755. if (name) {
  97756. tokens.push("'" + name + "'");
  97757. }
  97758. }
  97759. return tokens.join(" ");
  97760. },
  97761. /**
  97762. * Gets the location of the given function node for reporting.
  97763. *
  97764. * - `function foo() {}`
  97765. * ^^^^^^^^^^^^
  97766. * - `(function foo() {})`
  97767. * ^^^^^^^^^^^^
  97768. * - `(function() {})`
  97769. * ^^^^^^^^
  97770. * - `function* foo() {}`
  97771. * ^^^^^^^^^^^^^
  97772. * - `(function* foo() {})`
  97773. * ^^^^^^^^^^^^^
  97774. * - `(function*() {})`
  97775. * ^^^^^^^^^
  97776. * - `() => {}`
  97777. * ^^
  97778. * - `async () => {}`
  97779. * ^^
  97780. * - `({ foo: function foo() {} })`
  97781. * ^^^^^^^^^^^^^^^^^
  97782. * - `({ foo: function() {} })`
  97783. * ^^^^^^^^^^^^^
  97784. * - `({ ['foo']: function() {} })`
  97785. * ^^^^^^^^^^^^^^^^^
  97786. * - `({ [foo]: function() {} })`
  97787. * ^^^^^^^^^^^^^^^
  97788. * - `({ foo() {} })`
  97789. * ^^^
  97790. * - `({ foo: function* foo() {} })`
  97791. * ^^^^^^^^^^^^^^^^^^
  97792. * - `({ foo: function*() {} })`
  97793. * ^^^^^^^^^^^^^^
  97794. * - `({ ['foo']: function*() {} })`
  97795. * ^^^^^^^^^^^^^^^^^^
  97796. * - `({ [foo]: function*() {} })`
  97797. * ^^^^^^^^^^^^^^^^
  97798. * - `({ *foo() {} })`
  97799. * ^^^^
  97800. * - `({ foo: async function foo() {} })`
  97801. * ^^^^^^^^^^^^^^^^^^^^^^^
  97802. * - `({ foo: async function() {} })`
  97803. * ^^^^^^^^^^^^^^^^^^^
  97804. * - `({ ['foo']: async function() {} })`
  97805. * ^^^^^^^^^^^^^^^^^^^^^^^
  97806. * - `({ [foo]: async function() {} })`
  97807. * ^^^^^^^^^^^^^^^^^^^^^
  97808. * - `({ async foo() {} })`
  97809. * ^^^^^^^^^
  97810. * - `({ get foo() {} })`
  97811. * ^^^^^^^
  97812. * - `({ set foo(a) {} })`
  97813. * ^^^^^^^
  97814. * - `class A { constructor() {} }`
  97815. * ^^^^^^^^^^^
  97816. * - `class A { foo() {} }`
  97817. * ^^^
  97818. * - `class A { *foo() {} }`
  97819. * ^^^^
  97820. * - `class A { async foo() {} }`
  97821. * ^^^^^^^^^
  97822. * - `class A { ['foo']() {} }`
  97823. * ^^^^^^^
  97824. * - `class A { *['foo']() {} }`
  97825. * ^^^^^^^^
  97826. * - `class A { async ['foo']() {} }`
  97827. * ^^^^^^^^^^^^^
  97828. * - `class A { [foo]() {} }`
  97829. * ^^^^^
  97830. * - `class A { *[foo]() {} }`
  97831. * ^^^^^^
  97832. * - `class A { async [foo]() {} }`
  97833. * ^^^^^^^^^^^
  97834. * - `class A { get foo() {} }`
  97835. * ^^^^^^^
  97836. * - `class A { set foo(a) {} }`
  97837. * ^^^^^^^
  97838. * - `class A { static foo() {} }`
  97839. * ^^^^^^^^^^
  97840. * - `class A { static *foo() {} }`
  97841. * ^^^^^^^^^^^
  97842. * - `class A { static async foo() {} }`
  97843. * ^^^^^^^^^^^^^^^^
  97844. * - `class A { static get foo() {} }`
  97845. * ^^^^^^^^^^^^^^
  97846. * - `class A { static set foo(a) {} }`
  97847. * ^^^^^^^^^^^^^^
  97848. *
  97849. * @param {ASTNode} node - The function node to get.
  97850. * @param {SourceCode} sourceCode - The source code object to get tokens.
  97851. * @returns {string} The location of the function node for reporting.
  97852. */
  97853. getFunctionHeadLoc: function getFunctionHeadLoc(node, sourceCode) {
  97854. var parent = node.parent;
  97855. var start = null;
  97856. var end = null;
  97857. if (node.type === "ArrowFunctionExpression") {
  97858. var arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
  97859. start = arrowToken.loc.start;
  97860. end = arrowToken.loc.end;
  97861. } else if (parent.type === "Property" || parent.type === "MethodDefinition") {
  97862. start = parent.loc.start;
  97863. end = getOpeningParenOfParams(node, sourceCode).loc.start;
  97864. } else {
  97865. start = node.loc.start;
  97866. end = getOpeningParenOfParams(node, sourceCode).loc.start;
  97867. }
  97868. return {
  97869. start: Object.assign({}, start),
  97870. end: Object.assign({}, end)
  97871. };
  97872. },
  97873. /**
  97874. * Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses
  97875. * surrounding the node.
  97876. * @param {SourceCode} sourceCode The source code object
  97877. * @param {ASTNode} node An expression node
  97878. * @returns {string} The text representing the node, with all surrounding parentheses included
  97879. */
  97880. getParenthesisedText: function getParenthesisedText(sourceCode, node) {
  97881. var leftToken = sourceCode.getFirstToken(node);
  97882. var rightToken = sourceCode.getLastToken(node);
  97883. while (sourceCode.getTokenBefore(leftToken) && sourceCode.getTokenBefore(leftToken).type === "Punctuator" && sourceCode.getTokenBefore(leftToken).value === "(" && sourceCode.getTokenAfter(rightToken) && sourceCode.getTokenAfter(rightToken).type === "Punctuator" && sourceCode.getTokenAfter(rightToken).value === ")") {
  97884. leftToken = sourceCode.getTokenBefore(leftToken);
  97885. rightToken = sourceCode.getTokenAfter(rightToken);
  97886. }
  97887. return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]);
  97888. },
  97889. /*
  97890. * Determine if a node has a possiblity to be an Error object
  97891. * @param {ASTNode} node ASTNode to check
  97892. * @returns {boolean} True if there is a chance it contains an Error obj
  97893. */
  97894. couldBeError: function couldBeError(node) {
  97895. switch (node.type) {
  97896. case "Identifier":
  97897. case "CallExpression":
  97898. case "NewExpression":
  97899. case "MemberExpression":
  97900. case "TaggedTemplateExpression":
  97901. case "YieldExpression":
  97902. case "AwaitExpression":
  97903. return true; // possibly an error object.
  97904. case "AssignmentExpression":
  97905. return module.exports.couldBeError(node.right);
  97906. case "SequenceExpression":
  97907. {
  97908. var exprs = node.expressions;
  97909. return exprs.length !== 0 && module.exports.couldBeError(exprs[exprs.length - 1]);
  97910. }
  97911. case "LogicalExpression":
  97912. return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right);
  97913. case "ConditionalExpression":
  97914. return module.exports.couldBeError(node.consequent) || module.exports.couldBeError(node.alternate);
  97915. default:
  97916. return false;
  97917. }
  97918. },
  97919. /**
  97920. * Determines whether the given node is a `null` literal.
  97921. * @param {ASTNode} node The node to check
  97922. * @returns {boolean} `true` if the node is a `null` literal
  97923. */
  97924. isNullLiteral: function isNullLiteral(node) {
  97925. /*
  97926. * Checking `node.value === null` does not guarantee that a literal is a null literal.
  97927. * When parsing values that cannot be represented in the current environment (e.g. unicode
  97928. * regexes in Node 4), `node.value` is set to `null` because it wouldn't be possible to
  97929. * set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
  97930. * `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
  97931. */
  97932. return node.type === "Literal" && node.value === null && !node.regex;
  97933. },
  97934. /**
  97935. * Determines whether two tokens can safely be placed next to each other without merging into a single token
  97936. * @param {Token|string} leftValue The left token. If this is a string, it will be tokenized and the last token will be used.
  97937. * @param {Token|string} rightValue The right token. If this is a string, it will be tokenized and the first token will be used.
  97938. * @returns {boolean} If the tokens cannot be safely placed next to each other, returns `false`. If the tokens can be placed
  97939. * next to each other, behavior is undefined (although it should return `true` in most cases).
  97940. */
  97941. canTokensBeAdjacent: function canTokensBeAdjacent(leftValue, rightValue) {
  97942. var leftToken = void 0;
  97943. if (typeof leftValue === "string") {
  97944. var leftTokens = espree.tokenize(leftValue, { ecmaVersion: 2015 });
  97945. leftToken = leftTokens[leftTokens.length - 1];
  97946. } else {
  97947. leftToken = leftValue;
  97948. }
  97949. var rightToken = typeof rightValue === "string" ? espree.tokenize(rightValue, { ecmaVersion: 2015 })[0] : rightValue;
  97950. if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") {
  97951. if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") {
  97952. var PLUS_TOKENS = new Set(["+", "++"]);
  97953. var MINUS_TOKENS = new Set(["-", "--"]);
  97954. return !(PLUS_TOKENS.has(leftToken.value) && PLUS_TOKENS.has(rightToken.value) || MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value));
  97955. }
  97956. return true;
  97957. }
  97958. if (leftToken.type === "String" || rightToken.type === "String" || leftToken.type === "Template" || rightToken.type === "Template") {
  97959. return true;
  97960. }
  97961. if (leftToken.type !== "Numeric" && rightToken.type === "Numeric" && rightToken.value.startsWith(".")) {
  97962. return true;
  97963. }
  97964. return false;
  97965. }
  97966. };
  97967. },{"espree":"espree","esutils":80}],406:[function(require,module,exports){
  97968. /**
  97969. * @fileoverview Config Comment Parser
  97970. * @author Nicholas C. Zakas
  97971. */
  97972. /* eslint-disable class-methods-use-this*/
  97973. "use strict";
  97974. //------------------------------------------------------------------------------
  97975. // Requirements
  97976. //------------------------------------------------------------------------------
  97977. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  97978. 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; }; }();
  97979. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  97980. var levn = require("levn"),
  97981. ConfigOps = require("../config/config-ops");
  97982. var debug = require("debug")("eslint:config-comment-parser");
  97983. //------------------------------------------------------------------------------
  97984. // Public Interface
  97985. //------------------------------------------------------------------------------
  97986. /**
  97987. * Object to parse ESLint configuration comments inside JavaScript files.
  97988. * @name ConfigCommentParser
  97989. */
  97990. module.exports = function () {
  97991. function ConfigCommentParser() {
  97992. _classCallCheck(this, ConfigCommentParser);
  97993. }
  97994. _createClass(ConfigCommentParser, [{
  97995. key: "parseBooleanConfig",
  97996. /**
  97997. * Parses a list of "name:boolean_value" or/and "name" options divided by comma or
  97998. * whitespace. Used for "global" and "exported" comments.
  97999. * @param {string} string The string to parse.
  98000. * @param {Comment} comment The comment node which has the string.
  98001. * @returns {Object} Result map object of names and boolean values
  98002. */
  98003. value: function parseBooleanConfig(string, comment) {
  98004. debug("Parsing Boolean config");
  98005. var items = {};
  98006. // Collapse whitespace around `:` and `,` to make parsing easier
  98007. var trimmedString = string.replace(/\s*([:,])\s*/g, "$1");
  98008. trimmedString.split(/\s|,+/).forEach(function (name) {
  98009. if (!name) {
  98010. return;
  98011. }
  98012. // value defaults to "false" (if not provided), e.g: "foo" => ["foo", "false"]
  98013. var _name$split = name.split(":"),
  98014. _name$split2 = _slicedToArray(_name$split, 2),
  98015. key = _name$split2[0],
  98016. _name$split2$ = _name$split2[1],
  98017. value = _name$split2$ === undefined ? "false" : _name$split2$;
  98018. items[key] = {
  98019. value: value === "true",
  98020. comment: comment
  98021. };
  98022. });
  98023. return items;
  98024. }
  98025. /**
  98026. * Parses a JSON-like config.
  98027. * @param {string} string The string to parse.
  98028. * @param {Object} location Start line and column of comments for potential error message.
  98029. * @returns {({success: true, config: Object}|{success: false, error: Problem})} Result map object
  98030. */
  98031. }, {
  98032. key: "parseJsonConfig",
  98033. value: function parseJsonConfig(string, location) {
  98034. debug("Parsing JSON config");
  98035. var items = {};
  98036. // Parses a JSON-like comment by the same way as parsing CLI option.
  98037. try {
  98038. items = levn.parse("Object", string) || {};
  98039. // Some tests say that it should ignore invalid comments such as `/*eslint no-alert:abc*/`.
  98040. // Also, commaless notations have invalid severity:
  98041. // "no-alert: 2 no-console: 2" --> {"no-alert": "2 no-console: 2"}
  98042. // Should ignore that case as well.
  98043. if (ConfigOps.isEverySeverityValid(items)) {
  98044. return {
  98045. success: true,
  98046. config: items
  98047. };
  98048. }
  98049. } catch (ex) {
  98050. debug("Levn parsing failed; falling back to manual parsing.");
  98051. // ignore to parse the string by a fallback.
  98052. }
  98053. /*
  98054. * Optionator cannot parse commaless notations.
  98055. * But we are supporting that. So this is a fallback for that.
  98056. */
  98057. items = {};
  98058. var normalizedString = string.replace(/([a-zA-Z0-9\-/]+):/g, "\"$1\":").replace(/(]|[0-9])\s+(?=")/, "$1,");
  98059. try {
  98060. items = JSON.parse("{" + normalizedString + "}");
  98061. } catch (ex) {
  98062. debug("Manual parsing failed.");
  98063. return {
  98064. success: false,
  98065. error: {
  98066. ruleId: null,
  98067. fatal: true,
  98068. severity: 2,
  98069. message: "Failed to parse JSON from '" + normalizedString + "': " + ex.message,
  98070. line: location.start.line,
  98071. column: location.start.column + 1
  98072. }
  98073. };
  98074. }
  98075. return {
  98076. success: true,
  98077. config: items
  98078. };
  98079. }
  98080. /**
  98081. * Parses a config of values separated by comma.
  98082. * @param {string} string The string to parse.
  98083. * @returns {Object} Result map of values and true values
  98084. */
  98085. }, {
  98086. key: "parseListConfig",
  98087. value: function parseListConfig(string) {
  98088. debug("Parsing list config");
  98089. var items = {};
  98090. // Collapse whitespace around commas
  98091. string.replace(/\s*,\s*/g, ",").split(/,+/).forEach(function (name) {
  98092. var trimmedName = name.trim();
  98093. if (trimmedName) {
  98094. items[trimmedName] = true;
  98095. }
  98096. });
  98097. return items;
  98098. }
  98099. }]);
  98100. return ConfigCommentParser;
  98101. }();
  98102. },{"../config/config-ops":119,"debug":53,"levn":90}],407:[function(require,module,exports){
  98103. /**
  98104. * @fileoverview Helper class to aid in constructing fix commands.
  98105. * @author Alan Pierce
  98106. */
  98107. "use strict";
  98108. //------------------------------------------------------------------------------
  98109. // Requirements
  98110. //------------------------------------------------------------------------------
  98111. 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; }; }();
  98112. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  98113. var astUtils = require("../util/ast-utils");
  98114. //------------------------------------------------------------------------------
  98115. // Public Interface
  98116. //------------------------------------------------------------------------------
  98117. /**
  98118. * A helper class to combine fix options into a fix command. Currently, it
  98119. * exposes some "retain" methods that extend the range of the text being
  98120. * replaced so that other fixes won't touch that region in the same pass.
  98121. */
  98122. var FixTracker = function () {
  98123. /**
  98124. * Create a new FixTracker.
  98125. *
  98126. * @param {ruleFixer} fixer A ruleFixer instance.
  98127. * @param {SourceCode} sourceCode A SourceCode object for the current code.
  98128. */
  98129. function FixTracker(fixer, sourceCode) {
  98130. _classCallCheck(this, FixTracker);
  98131. this.fixer = fixer;
  98132. this.sourceCode = sourceCode;
  98133. this.retainedRange = null;
  98134. }
  98135. /**
  98136. * Mark the given range as "retained", meaning that other fixes may not
  98137. * may not modify this region in the same pass.
  98138. *
  98139. * @param {int[]} range The range to retain.
  98140. * @returns {FixTracker} The same RuleFixer, for chained calls.
  98141. */
  98142. _createClass(FixTracker, [{
  98143. key: "retainRange",
  98144. value: function retainRange(range) {
  98145. this.retainedRange = range;
  98146. return this;
  98147. }
  98148. /**
  98149. * Given a node, find the function containing it (or the entire program) and
  98150. * mark it as retained, meaning that other fixes may not modify it in this
  98151. * pass. This is useful for avoiding conflicts in fixes that modify control
  98152. * flow.
  98153. *
  98154. * @param {ASTNode} node The node to use as a starting point.
  98155. * @returns {FixTracker} The same RuleFixer, for chained calls.
  98156. */
  98157. }, {
  98158. key: "retainEnclosingFunction",
  98159. value: function retainEnclosingFunction(node) {
  98160. var functionNode = astUtils.getUpperFunction(node);
  98161. return this.retainRange(functionNode ? functionNode.range : this.sourceCode.ast.range);
  98162. }
  98163. /**
  98164. * Given a node or token, find the token before and afterward, and mark that
  98165. * range as retained, meaning that other fixes may not modify it in this
  98166. * pass. This is useful for avoiding conflicts in fixes that make a small
  98167. * change to the code where the AST should not be changed.
  98168. *
  98169. * @param {ASTNode|Token} nodeOrToken The node or token to use as a starting
  98170. * point. The token to the left and right are use in the range.
  98171. * @returns {FixTracker} The same RuleFixer, for chained calls.
  98172. */
  98173. }, {
  98174. key: "retainSurroundingTokens",
  98175. value: function retainSurroundingTokens(nodeOrToken) {
  98176. var tokenBefore = this.sourceCode.getTokenBefore(nodeOrToken) || nodeOrToken;
  98177. var tokenAfter = this.sourceCode.getTokenAfter(nodeOrToken) || nodeOrToken;
  98178. return this.retainRange([tokenBefore.range[0], tokenAfter.range[1]]);
  98179. }
  98180. /**
  98181. * Create a fix command that replaces the given range with the given text,
  98182. * accounting for any retained ranges.
  98183. *
  98184. * @param {int[]} range The range to remove in the fix.
  98185. * @param {string} text The text to insert in place of the range.
  98186. * @returns {Object} The fix command.
  98187. */
  98188. }, {
  98189. key: "replaceTextRange",
  98190. value: function replaceTextRange(range, text) {
  98191. var actualRange = void 0;
  98192. if (this.retainedRange) {
  98193. actualRange = [Math.min(this.retainedRange[0], range[0]), Math.max(this.retainedRange[1], range[1])];
  98194. } else {
  98195. actualRange = range;
  98196. }
  98197. return this.fixer.replaceTextRange(actualRange, this.sourceCode.text.slice(actualRange[0], range[0]) + text + this.sourceCode.text.slice(range[1], actualRange[1]));
  98198. }
  98199. /**
  98200. * Create a fix command that removes the given node or token, accounting for
  98201. * any retained ranges.
  98202. *
  98203. * @param {ASTNode|Token} nodeOrToken The node or token to remove.
  98204. * @returns {Object} The fix command.
  98205. */
  98206. }, {
  98207. key: "remove",
  98208. value: function remove(nodeOrToken) {
  98209. return this.replaceTextRange(nodeOrToken.range, "");
  98210. }
  98211. }]);
  98212. return FixTracker;
  98213. }();
  98214. module.exports = FixTracker;
  98215. },{"../util/ast-utils":405}],408:[function(require,module,exports){
  98216. /**
  98217. * @fileoverview Interpolate keys from an object into a string with {{ }} markers.
  98218. * @author Jed Fox
  98219. */
  98220. "use strict";
  98221. //------------------------------------------------------------------------------
  98222. // Public Interface
  98223. //------------------------------------------------------------------------------
  98224. module.exports = function (text, data) {
  98225. if (!data) {
  98226. return text;
  98227. }
  98228. // Substitution content for any {{ }} markers.
  98229. return text.replace(/\{\{([^{}]+?)\}\}/g, function (fullMatch, termWithWhitespace) {
  98230. var term = termWithWhitespace.trim();
  98231. if (term in data) {
  98232. return data[term];
  98233. }
  98234. // Preserve old behavior: If parameter name not provided, don't replace it.
  98235. return fullMatch;
  98236. });
  98237. };
  98238. },{}],409:[function(require,module,exports){
  98239. /**
  98240. * @fileoverview A shared list of ES3 keywords.
  98241. * @author Josh Perez
  98242. */
  98243. "use strict";
  98244. module.exports = ["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with"];
  98245. },{}],410:[function(require,module,exports){
  98246. /**
  98247. * @fileoverview The event generator for AST nodes.
  98248. * @author Toru Nagashima
  98249. */
  98250. "use strict";
  98251. //------------------------------------------------------------------------------
  98252. // Requirements
  98253. //------------------------------------------------------------------------------
  98254. 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; }; }();
  98255. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  98256. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  98257. var esquery = require("esquery");
  98258. var lodash = require("lodash");
  98259. //------------------------------------------------------------------------------
  98260. // Typedefs
  98261. //------------------------------------------------------------------------------
  98262. /**
  98263. * An object describing an AST selector
  98264. * @typedef {Object} ASTSelector
  98265. * @property {string} rawSelector The string that was parsed into this selector
  98266. * @property {boolean} isExit `true` if this should be emitted when exiting the node rather than when entering
  98267. * @property {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector
  98268. * @property {string[]|null} listenerTypes A list of node types that could possibly cause the selector to match,
  98269. * or `null` if all node types could cause a match
  98270. * @property {number} attributeCount The total number of classes, pseudo-classes, and attribute queries in this selector
  98271. * @property {number} identifierCount The total number of identifier queries in this selector
  98272. */
  98273. //------------------------------------------------------------------------------
  98274. // Helpers
  98275. //------------------------------------------------------------------------------
  98276. /**
  98277. * Gets the possible types of a selector
  98278. * @param {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector
  98279. * @returns {string[]|null} The node types that could possibly trigger this selector, or `null` if all node types could trigger it
  98280. */
  98281. function getPossibleTypes(parsedSelector) {
  98282. switch (parsedSelector.type) {
  98283. case "identifier":
  98284. return [parsedSelector.value];
  98285. case "matches":
  98286. {
  98287. var typesForComponents = parsedSelector.selectors.map(getPossibleTypes);
  98288. if (typesForComponents.every(Boolean)) {
  98289. return lodash.union.apply(lodash, _toConsumableArray(typesForComponents));
  98290. }
  98291. return null;
  98292. }
  98293. case "compound":
  98294. {
  98295. var _typesForComponents = parsedSelector.selectors.map(getPossibleTypes).filter(function (typesForComponent) {
  98296. return typesForComponent;
  98297. });
  98298. // If all of the components could match any type, then the compound could also match any type.
  98299. if (!_typesForComponents.length) {
  98300. return null;
  98301. }
  98302. /*
  98303. * If at least one of the components could only match a particular type, the compound could only match
  98304. * the intersection of those types.
  98305. */
  98306. return lodash.intersection.apply(lodash, _toConsumableArray(_typesForComponents));
  98307. }
  98308. case "child":
  98309. case "descendant":
  98310. case "sibling":
  98311. case "adjacent":
  98312. return getPossibleTypes(parsedSelector.right);
  98313. default:
  98314. return null;
  98315. }
  98316. }
  98317. /**
  98318. * Counts the number of class, pseudo-class, and attribute queries in this selector
  98319. * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
  98320. * @returns {number} The number of class, pseudo-class, and attribute queries in this selector
  98321. */
  98322. function countClassAttributes(parsedSelector) {
  98323. switch (parsedSelector.type) {
  98324. case "child":
  98325. case "descendant":
  98326. case "sibling":
  98327. case "adjacent":
  98328. return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right);
  98329. case "compound":
  98330. case "not":
  98331. case "matches":
  98332. return parsedSelector.selectors.reduce(function (sum, childSelector) {
  98333. return sum + countClassAttributes(childSelector);
  98334. }, 0);
  98335. case "attribute":
  98336. case "field":
  98337. case "nth-child":
  98338. case "nth-last-child":
  98339. return 1;
  98340. default:
  98341. return 0;
  98342. }
  98343. }
  98344. /**
  98345. * Counts the number of identifier queries in this selector
  98346. * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
  98347. * @returns {number} The number of identifier queries
  98348. */
  98349. function countIdentifiers(parsedSelector) {
  98350. switch (parsedSelector.type) {
  98351. case "child":
  98352. case "descendant":
  98353. case "sibling":
  98354. case "adjacent":
  98355. return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);
  98356. case "compound":
  98357. case "not":
  98358. case "matches":
  98359. return parsedSelector.selectors.reduce(function (sum, childSelector) {
  98360. return sum + countIdentifiers(childSelector);
  98361. }, 0);
  98362. case "identifier":
  98363. return 1;
  98364. default:
  98365. return 0;
  98366. }
  98367. }
  98368. /**
  98369. * Compares the specificity of two selector objects, with CSS-like rules.
  98370. * @param {ASTSelector} selectorA An AST selector descriptor
  98371. * @param {ASTSelector} selectorB Another AST selector descriptor
  98372. * @returns {number}
  98373. * a value less than 0 if selectorA is less specific than selectorB
  98374. * a value greater than 0 if selectorA is more specific than selectorB
  98375. * a value less than 0 if selectorA and selectorB have the same specificity, and selectorA <= selectorB alphabetically
  98376. * a value greater than 0 if selectorA and selectorB have the same specificity, and selectorA > selectorB alphabetically
  98377. */
  98378. function compareSpecificity(selectorA, selectorB) {
  98379. return selectorA.attributeCount - selectorB.attributeCount || selectorA.identifierCount - selectorB.identifierCount || (selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1);
  98380. }
  98381. /**
  98382. * Parses a raw selector string, and throws a useful error if parsing fails.
  98383. * @param {string} rawSelector A raw AST selector
  98384. * @returns {Object} An object (from esquery) describing the matching behavior of this selector
  98385. * @throws {Error} An error if the selector is invalid
  98386. */
  98387. function tryParseSelector(rawSelector) {
  98388. try {
  98389. return esquery.parse(rawSelector.replace(/:exit$/, ""));
  98390. } catch (err) {
  98391. if (typeof err.offset === "number") {
  98392. throw new SyntaxError("Syntax error in selector \"" + rawSelector + "\" at position " + err.offset + ": " + err.message);
  98393. }
  98394. throw err;
  98395. }
  98396. }
  98397. /**
  98398. * Parses a raw selector string, and returns the parsed selector along with specificity and type information.
  98399. * @param {string} rawSelector A raw AST selector
  98400. * @returns {ASTSelector} A selector descriptor
  98401. */
  98402. var parseSelector = lodash.memoize(function (rawSelector) {
  98403. var parsedSelector = tryParseSelector(rawSelector);
  98404. return {
  98405. rawSelector: rawSelector,
  98406. isExit: rawSelector.endsWith(":exit"),
  98407. parsedSelector: parsedSelector,
  98408. listenerTypes: getPossibleTypes(parsedSelector),
  98409. attributeCount: countClassAttributes(parsedSelector),
  98410. identifierCount: countIdentifiers(parsedSelector)
  98411. };
  98412. });
  98413. //------------------------------------------------------------------------------
  98414. // Public Interface
  98415. //------------------------------------------------------------------------------
  98416. /**
  98417. * The event generator for AST nodes.
  98418. * This implements below interface.
  98419. *
  98420. * ```ts
  98421. * interface EventGenerator {
  98422. * emitter: SafeEmitter;
  98423. * enterNode(node: ASTNode): void;
  98424. * leaveNode(node: ASTNode): void;
  98425. * }
  98426. * ```
  98427. */
  98428. var NodeEventGenerator = function () {
  98429. /**
  98430. * @param {SafeEmitter} emitter
  98431. * An SafeEmitter which is the destination of events. This emitter must already
  98432. * have registered listeners for all of the events that it needs to listen for.
  98433. * (See lib/util/safe-emitter.js for more details on `SafeEmitter`.)
  98434. * @returns {NodeEventGenerator} new instance
  98435. */
  98436. function NodeEventGenerator(emitter) {
  98437. var _this = this;
  98438. _classCallCheck(this, NodeEventGenerator);
  98439. this.emitter = emitter;
  98440. this.currentAncestry = [];
  98441. this.enterSelectorsByNodeType = new Map();
  98442. this.exitSelectorsByNodeType = new Map();
  98443. this.anyTypeEnterSelectors = [];
  98444. this.anyTypeExitSelectors = [];
  98445. emitter.eventNames().forEach(function (rawSelector) {
  98446. var selector = parseSelector(rawSelector);
  98447. if (selector.listenerTypes) {
  98448. selector.listenerTypes.forEach(function (nodeType) {
  98449. var typeMap = selector.isExit ? _this.exitSelectorsByNodeType : _this.enterSelectorsByNodeType;
  98450. if (!typeMap.has(nodeType)) {
  98451. typeMap.set(nodeType, []);
  98452. }
  98453. typeMap.get(nodeType).push(selector);
  98454. });
  98455. } else {
  98456. (selector.isExit ? _this.anyTypeExitSelectors : _this.anyTypeEnterSelectors).push(selector);
  98457. }
  98458. });
  98459. this.anyTypeEnterSelectors.sort(compareSpecificity);
  98460. this.anyTypeExitSelectors.sort(compareSpecificity);
  98461. this.enterSelectorsByNodeType.forEach(function (selectorList) {
  98462. return selectorList.sort(compareSpecificity);
  98463. });
  98464. this.exitSelectorsByNodeType.forEach(function (selectorList) {
  98465. return selectorList.sort(compareSpecificity);
  98466. });
  98467. }
  98468. /**
  98469. * Checks a selector against a node, and emits it if it matches
  98470. * @param {ASTNode} node The node to check
  98471. * @param {ASTSelector} selector An AST selector descriptor
  98472. * @returns {void}
  98473. */
  98474. _createClass(NodeEventGenerator, [{
  98475. key: "applySelector",
  98476. value: function applySelector(node, selector) {
  98477. if (esquery.matches(node, selector.parsedSelector, this.currentAncestry)) {
  98478. this.emitter.emit(selector.rawSelector, node);
  98479. }
  98480. }
  98481. /**
  98482. * Applies all appropriate selectors to a node, in specificity order
  98483. * @param {ASTNode} node The node to check
  98484. * @param {boolean} isExit `false` if the node is currently being entered, `true` if it's currently being exited
  98485. * @returns {void}
  98486. */
  98487. }, {
  98488. key: "applySelectors",
  98489. value: function applySelectors(node, isExit) {
  98490. var selectorsByNodeType = (isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType).get(node.type) || [];
  98491. var anyTypeSelectors = isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
  98492. /*
  98493. * selectorsByNodeType and anyTypeSelectors were already sorted by specificity in the constructor.
  98494. * Iterate through each of them, applying selectors in the right order.
  98495. */
  98496. var selectorsByTypeIndex = 0;
  98497. var anyTypeSelectorsIndex = 0;
  98498. while (selectorsByTypeIndex < selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length) {
  98499. if (selectorsByTypeIndex >= selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length && compareSpecificity(anyTypeSelectors[anyTypeSelectorsIndex], selectorsByNodeType[selectorsByTypeIndex]) < 0) {
  98500. this.applySelector(node, anyTypeSelectors[anyTypeSelectorsIndex++]);
  98501. } else {
  98502. this.applySelector(node, selectorsByNodeType[selectorsByTypeIndex++]);
  98503. }
  98504. }
  98505. }
  98506. /**
  98507. * Emits an event of entering AST node.
  98508. * @param {ASTNode} node - A node which was entered.
  98509. * @returns {void}
  98510. */
  98511. }, {
  98512. key: "enterNode",
  98513. value: function enterNode(node) {
  98514. if (node.parent) {
  98515. this.currentAncestry.unshift(node.parent);
  98516. }
  98517. this.applySelectors(node, false);
  98518. }
  98519. /**
  98520. * Emits an event of leaving AST node.
  98521. * @param {ASTNode} node - A node which was left.
  98522. * @returns {void}
  98523. */
  98524. }, {
  98525. key: "leaveNode",
  98526. value: function leaveNode(node) {
  98527. this.applySelectors(node, true);
  98528. this.currentAncestry.shift();
  98529. }
  98530. }]);
  98531. return NodeEventGenerator;
  98532. }();
  98533. module.exports = NodeEventGenerator;
  98534. },{"esquery":71,"lodash":92}],411:[function(require,module,exports){
  98535. /**
  98536. * @fileoverview Pattern for detecting any letter (even letters outside of ASCII).
  98537. * NOTE: This file was generated using this script in JSCS based on the Unicode 7.0.0 standard: https://github.com/jscs-dev/node-jscs/blob/f5ed14427deb7e7aac84f3056a5aab2d9f3e563e/publish/helpers/generate-patterns.js
  98538. * Do not edit this file by hand-- please use https://github.com/mathiasbynens/regenerate to regenerate the regular expression exported from this file.
  98539. * @author Kevin Partington
  98540. * @license MIT License (from JSCS). See below.
  98541. */
  98542. /*
  98543. * The MIT License (MIT)
  98544. *
  98545. * Copyright 2013-2016 Dulin Marat and other contributors
  98546. *
  98547. * Permission is hereby granted, free of charge, to any person obtaining
  98548. * a copy of this software and associated documentation files (the
  98549. * "Software"), to deal in the Software without restriction, including
  98550. * without limitation the rights to use, copy, modify, merge, publish,
  98551. * distribute, sublicense, and/or sell copies of the Software, and to
  98552. * permit persons to whom the Software is furnished to do so, subject to
  98553. * the following conditions:
  98554. *
  98555. * The above copyright notice and this permission notice shall be
  98556. * included in all copies or substantial portions of the Software.
  98557. *
  98558. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  98559. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  98560. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  98561. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  98562. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  98563. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  98564. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  98565. */
  98566. "use strict";
  98567. module.exports = /[A-Za-z\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\u16F1-\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\u2183\u2184\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\u3006\u3031-\u3035\u303B\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-\uA6E5\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\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\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]|[\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]/;
  98568. },{}],412:[function(require,module,exports){
  98569. /**
  98570. * @fileoverview A helper that translates context.report() calls from the rule API into generic problem objects
  98571. * @author Teddy Katz
  98572. */
  98573. "use strict";
  98574. //------------------------------------------------------------------------------
  98575. // Requirements
  98576. //------------------------------------------------------------------------------
  98577. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  98578. var assert = require("assert");
  98579. var ruleFixer = require("./rule-fixer");
  98580. var interpolate = require("./interpolate");
  98581. //------------------------------------------------------------------------------
  98582. // Typedefs
  98583. //------------------------------------------------------------------------------
  98584. /**
  98585. * An error message description
  98586. * @typedef {Object} MessageDescriptor
  98587. * @property {ASTNode} [node] The reported node
  98588. * @property {Location} loc The location of the problem.
  98589. * @property {string} message The problem message.
  98590. * @property {Object} [data] Optional data to use to fill in placeholders in the
  98591. * message.
  98592. * @property {Function} [fix] The function to call that creates a fix command.
  98593. */
  98594. /**
  98595. * Information about the report
  98596. * @typedef {Object} ReportInfo
  98597. * @property {string} ruleId
  98598. * @property {(0|1|2)} severity
  98599. * @property {(string|undefined)} message
  98600. * @property {(string|undefined)} messageId
  98601. * @property {number} line
  98602. * @property {number} column
  98603. * @property {(number|undefined)} endLine
  98604. * @property {(number|undefined)} endColumn
  98605. * @property {(string|null)} nodeType
  98606. * @property {string} source
  98607. * @property {({text: string, range: (number[]|null)}|null)} fix
  98608. */
  98609. //------------------------------------------------------------------------------
  98610. // Module Definition
  98611. //------------------------------------------------------------------------------
  98612. /**
  98613. * Translates a multi-argument context.report() call into a single object argument call
  98614. * @param {...*} args A list of arguments passed to `context.report`
  98615. * @returns {MessageDescriptor} A normalized object containing report information
  98616. */
  98617. function normalizeMultiArgReportCall() {
  98618. // If there is one argument, it is considered to be a new-style call already.
  98619. if (arguments.length === 1) {
  98620. // Shallow clone the object to avoid surprises if reusing the descriptor
  98621. return Object.assign({}, arguments.length <= 0 ? undefined : arguments[0]);
  98622. }
  98623. // If the second argument is a string, the arguments are interpreted as [node, message, data, fix].
  98624. if (typeof (arguments.length <= 1 ? undefined : arguments[1]) === "string") {
  98625. return {
  98626. node: arguments.length <= 0 ? undefined : arguments[0],
  98627. message: arguments.length <= 1 ? undefined : arguments[1],
  98628. data: arguments.length <= 2 ? undefined : arguments[2],
  98629. fix: arguments.length <= 3 ? undefined : arguments[3]
  98630. };
  98631. }
  98632. // Otherwise, the arguments are interpreted as [node, loc, message, data, fix].
  98633. return {
  98634. node: arguments.length <= 0 ? undefined : arguments[0],
  98635. loc: arguments.length <= 1 ? undefined : arguments[1],
  98636. message: arguments.length <= 2 ? undefined : arguments[2],
  98637. data: arguments.length <= 3 ? undefined : arguments[3],
  98638. fix: arguments.length <= 4 ? undefined : arguments[4]
  98639. };
  98640. }
  98641. /**
  98642. * Asserts that either a loc or a node was provided, and the node is valid if it was provided.
  98643. * @param {MessageDescriptor} descriptor A descriptor to validate
  98644. * @returns {void}
  98645. * @throws AssertionError if neither a node nor a loc was provided, or if the node is not an object
  98646. */
  98647. function assertValidNodeInfo(descriptor) {
  98648. if (descriptor.node) {
  98649. assert(_typeof(descriptor.node) === "object", "Node must be an object");
  98650. } else {
  98651. assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
  98652. }
  98653. }
  98654. /**
  98655. * Normalizes a MessageDescriptor to always have a `loc` with `start` and `end` properties
  98656. * @param {MessageDescriptor} descriptor A descriptor for the report from a rule.
  98657. * @returns {{start: Location, end: (Location|null)}} An updated location that infers the `start` and `end` properties
  98658. * from the `node` of the original descriptor, or infers the `start` from the `loc` of the original descriptor.
  98659. */
  98660. function normalizeReportLoc(descriptor) {
  98661. if (descriptor.loc) {
  98662. if (descriptor.loc.start) {
  98663. return descriptor.loc;
  98664. }
  98665. return { start: descriptor.loc, end: null };
  98666. }
  98667. return descriptor.node.loc;
  98668. }
  98669. /**
  98670. * Compares items in a fixes array by range.
  98671. * @param {Fix} a The first message.
  98672. * @param {Fix} b The second message.
  98673. * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
  98674. * @private
  98675. */
  98676. function compareFixesByRange(a, b) {
  98677. return a.range[0] - b.range[0] || a.range[1] - b.range[1];
  98678. }
  98679. /**
  98680. * Merges the given fixes array into one.
  98681. * @param {Fix[]} fixes The fixes to merge.
  98682. * @param {SourceCode} sourceCode The source code object to get the text between fixes.
  98683. * @returns {{text: string, range: number[]}} The merged fixes
  98684. */
  98685. function mergeFixes(fixes, sourceCode) {
  98686. if (fixes.length === 0) {
  98687. return null;
  98688. }
  98689. if (fixes.length === 1) {
  98690. return fixes[0];
  98691. }
  98692. fixes.sort(compareFixesByRange);
  98693. var originalText = sourceCode.text;
  98694. var start = fixes[0].range[0];
  98695. var end = fixes[fixes.length - 1].range[1];
  98696. var text = "";
  98697. var lastPos = Number.MIN_SAFE_INTEGER;
  98698. var _iteratorNormalCompletion = true;
  98699. var _didIteratorError = false;
  98700. var _iteratorError = undefined;
  98701. try {
  98702. for (var _iterator = fixes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  98703. var fix = _step.value;
  98704. assert(fix.range[0] >= lastPos, "Fix objects must not be overlapped in a report.");
  98705. if (fix.range[0] >= 0) {
  98706. text += originalText.slice(Math.max(0, start, lastPos), fix.range[0]);
  98707. }
  98708. text += fix.text;
  98709. lastPos = fix.range[1];
  98710. }
  98711. } catch (err) {
  98712. _didIteratorError = true;
  98713. _iteratorError = err;
  98714. } finally {
  98715. try {
  98716. if (!_iteratorNormalCompletion && _iterator.return) {
  98717. _iterator.return();
  98718. }
  98719. } finally {
  98720. if (_didIteratorError) {
  98721. throw _iteratorError;
  98722. }
  98723. }
  98724. }
  98725. text += originalText.slice(Math.max(0, start, lastPos), end);
  98726. return { range: [start, end], text: text };
  98727. }
  98728. /**
  98729. * Gets one fix object from the given descriptor.
  98730. * If the descriptor retrieves multiple fixes, this merges those to one.
  98731. * @param {MessageDescriptor} descriptor The report descriptor.
  98732. * @param {SourceCode} sourceCode The source code object to get text between fixes.
  98733. * @returns {({text: string, range: number[]}|null)} The fix for the descriptor
  98734. */
  98735. function normalizeFixes(descriptor, sourceCode) {
  98736. if (typeof descriptor.fix !== "function") {
  98737. return null;
  98738. }
  98739. // @type {null | Fix | Fix[] | IterableIterator<Fix>}
  98740. var fix = descriptor.fix(ruleFixer);
  98741. // Merge to one.
  98742. if (fix && Symbol.iterator in fix) {
  98743. return mergeFixes(Array.from(fix), sourceCode);
  98744. }
  98745. return fix;
  98746. }
  98747. /**
  98748. * Creates information about the report from a descriptor
  98749. * @param {Object} options Information about the problem
  98750. * @param {string} options.ruleId Rule ID
  98751. * @param {(0|1|2)} options.severity Rule severity
  98752. * @param {(ASTNode|null)} options.node Node
  98753. * @param {string} options.message Error message
  98754. * @param {string} [options.messageId] The error message ID.
  98755. * @param {{start: SourceLocation, end: (SourceLocation|null)}} options.loc Start and end location
  98756. * @param {{text: string, range: (number[]|null)}} options.fix The fix object
  98757. * @returns {function(...args): ReportInfo} Function that returns information about the report
  98758. */
  98759. function createProblem(options) {
  98760. var problem = {
  98761. ruleId: options.ruleId,
  98762. severity: options.severity,
  98763. message: options.message,
  98764. line: options.loc.start.line,
  98765. column: options.loc.start.column + 1,
  98766. nodeType: options.node && options.node.type || null
  98767. };
  98768. /*
  98769. * If this isn’t in the conditional, some of the tests fail
  98770. * because `messageId` is present in the problem object
  98771. */
  98772. if (options.messageId) {
  98773. problem.messageId = options.messageId;
  98774. }
  98775. if (options.loc.end) {
  98776. problem.endLine = options.loc.end.line;
  98777. problem.endColumn = options.loc.end.column + 1;
  98778. }
  98779. if (options.fix) {
  98780. problem.fix = options.fix;
  98781. }
  98782. return problem;
  98783. }
  98784. /**
  98785. * Returns a function that converts the arguments of a `context.report` call from a rule into a reported
  98786. * problem for the Node.js API.
  98787. * @param {{ruleId: string, severity: number, sourceCode: SourceCode, messageIds: Object}} metadata Metadata for the reported problem
  98788. * @param {SourceCode} sourceCode The `SourceCode` instance for the text being linted
  98789. * @returns {function(...args): ReportInfo} Function that returns information about the report
  98790. */
  98791. module.exports = function createReportTranslator(metadata) {
  98792. /*
  98793. * `createReportTranslator` gets called once per enabled rule per file. It needs to be very performant.
  98794. * The report translator itself (i.e. the function that `createReportTranslator` returns) gets
  98795. * called every time a rule reports a problem, which happens much less frequently (usually, the vast
  98796. * majority of rules don't report any problems for a given file).
  98797. */
  98798. return function () {
  98799. var descriptor = normalizeMultiArgReportCall.apply(undefined, arguments);
  98800. assertValidNodeInfo(descriptor);
  98801. var computedMessage = void 0;
  98802. if (descriptor.messageId) {
  98803. if (!metadata.messageIds) {
  98804. throw new TypeError("context.report() called with a messageId, but no messages were present in the rule metadata.");
  98805. }
  98806. var id = descriptor.messageId;
  98807. var messages = metadata.messageIds;
  98808. if (descriptor.message) {
  98809. throw new TypeError("context.report() called with a message and a messageId. Please only pass one.");
  98810. }
  98811. if (!messages || !Object.prototype.hasOwnProperty.call(messages, id)) {
  98812. throw new TypeError("context.report() called with a messageId of '" + id + "' which is not present in the 'messages' config: " + JSON.stringify(messages, null, 2));
  98813. }
  98814. computedMessage = messages[id];
  98815. } else if (descriptor.message) {
  98816. computedMessage = descriptor.message;
  98817. } else {
  98818. throw new TypeError("Missing `message` property in report() call; add a message that describes the linting problem.");
  98819. }
  98820. return createProblem({
  98821. ruleId: metadata.ruleId,
  98822. severity: metadata.severity,
  98823. node: descriptor.node,
  98824. message: interpolate(computedMessage, descriptor.data),
  98825. messageId: descriptor.messageId,
  98826. loc: normalizeReportLoc(descriptor),
  98827. fix: normalizeFixes(descriptor, metadata.sourceCode)
  98828. });
  98829. };
  98830. };
  98831. },{"./interpolate":408,"./rule-fixer":413,"assert":46}],413:[function(require,module,exports){
  98832. /**
  98833. * @fileoverview An object that creates fix commands for rules.
  98834. * @author Nicholas C. Zakas
  98835. */
  98836. "use strict";
  98837. //------------------------------------------------------------------------------
  98838. // Requirements
  98839. //------------------------------------------------------------------------------
  98840. // none!
  98841. //------------------------------------------------------------------------------
  98842. // Helpers
  98843. //------------------------------------------------------------------------------
  98844. /**
  98845. * Creates a fix command that inserts text at the specified index in the source text.
  98846. * @param {int} index The 0-based index at which to insert the new text.
  98847. * @param {string} text The text to insert.
  98848. * @returns {Object} The fix command.
  98849. * @private
  98850. */
  98851. function insertTextAt(index, text) {
  98852. return {
  98853. range: [index, index],
  98854. text: text
  98855. };
  98856. }
  98857. //------------------------------------------------------------------------------
  98858. // Public Interface
  98859. //------------------------------------------------------------------------------
  98860. /**
  98861. * Creates code fixing commands for rules.
  98862. */
  98863. var ruleFixer = Object.freeze({
  98864. /**
  98865. * Creates a fix command that inserts text after the given node or token.
  98866. * The fix is not applied until applyFixes() is called.
  98867. * @param {ASTNode|Token} nodeOrToken The node or token to insert after.
  98868. * @param {string} text The text to insert.
  98869. * @returns {Object} The fix command.
  98870. */
  98871. insertTextAfter: function insertTextAfter(nodeOrToken, text) {
  98872. return this.insertTextAfterRange(nodeOrToken.range, text);
  98873. },
  98874. /**
  98875. * Creates a fix command that inserts text after the specified range in the source text.
  98876. * The fix is not applied until applyFixes() is called.
  98877. * @param {int[]} range The range to replace, first item is start of range, second
  98878. * is end of range.
  98879. * @param {string} text The text to insert.
  98880. * @returns {Object} The fix command.
  98881. */
  98882. insertTextAfterRange: function insertTextAfterRange(range, text) {
  98883. return insertTextAt(range[1], text);
  98884. },
  98885. /**
  98886. * Creates a fix command that inserts text before the given node or token.
  98887. * The fix is not applied until applyFixes() is called.
  98888. * @param {ASTNode|Token} nodeOrToken The node or token to insert before.
  98889. * @param {string} text The text to insert.
  98890. * @returns {Object} The fix command.
  98891. */
  98892. insertTextBefore: function insertTextBefore(nodeOrToken, text) {
  98893. return this.insertTextBeforeRange(nodeOrToken.range, text);
  98894. },
  98895. /**
  98896. * Creates a fix command that inserts text before the specified range in the source text.
  98897. * The fix is not applied until applyFixes() is called.
  98898. * @param {int[]} range The range to replace, first item is start of range, second
  98899. * is end of range.
  98900. * @param {string} text The text to insert.
  98901. * @returns {Object} The fix command.
  98902. */
  98903. insertTextBeforeRange: function insertTextBeforeRange(range, text) {
  98904. return insertTextAt(range[0], text);
  98905. },
  98906. /**
  98907. * Creates a fix command that replaces text at the node or token.
  98908. * The fix is not applied until applyFixes() is called.
  98909. * @param {ASTNode|Token} nodeOrToken The node or token to remove.
  98910. * @param {string} text The text to insert.
  98911. * @returns {Object} The fix command.
  98912. */
  98913. replaceText: function replaceText(nodeOrToken, text) {
  98914. return this.replaceTextRange(nodeOrToken.range, text);
  98915. },
  98916. /**
  98917. * Creates a fix command that replaces text at the specified range in the source text.
  98918. * The fix is not applied until applyFixes() is called.
  98919. * @param {int[]} range The range to replace, first item is start of range, second
  98920. * is end of range.
  98921. * @param {string} text The text to insert.
  98922. * @returns {Object} The fix command.
  98923. */
  98924. replaceTextRange: function replaceTextRange(range, text) {
  98925. return {
  98926. range: range,
  98927. text: text
  98928. };
  98929. },
  98930. /**
  98931. * Creates a fix command that removes the node or token from the source.
  98932. * The fix is not applied until applyFixes() is called.
  98933. * @param {ASTNode|Token} nodeOrToken The node or token to remove.
  98934. * @returns {Object} The fix command.
  98935. */
  98936. remove: function remove(nodeOrToken) {
  98937. return this.removeRange(nodeOrToken.range);
  98938. },
  98939. /**
  98940. * Creates a fix command that removes the specified range of text from the source.
  98941. * The fix is not applied until applyFixes() is called.
  98942. * @param {int[]} range The range to remove, first item is start of range, second
  98943. * is end of range.
  98944. * @returns {Object} The fix command.
  98945. */
  98946. removeRange: function removeRange(range) {
  98947. return {
  98948. range: range,
  98949. text: ""
  98950. };
  98951. }
  98952. });
  98953. module.exports = ruleFixer;
  98954. },{}],414:[function(require,module,exports){
  98955. /**
  98956. * @fileoverview A variant of EventEmitter which does not give listeners information about each other
  98957. * @author Teddy Katz
  98958. */
  98959. "use strict";
  98960. //------------------------------------------------------------------------------
  98961. // Typedefs
  98962. //------------------------------------------------------------------------------
  98963. /**
  98964. * An event emitter
  98965. * @typedef {Object} SafeEmitter
  98966. * @property {function(eventName: string, listenerFunc: Function): void} on Adds a listener for a given event name
  98967. * @property {function(eventName: string, arg1?: any, arg2?: any, arg3?: any)} emit Emits an event with a given name.
  98968. * This calls all the listeners that were listening for that name, with `arg1`, `arg2`, and `arg3` as arguments.
  98969. * @property {function(): string[]} eventNames Gets the list of event names that have registered listeners.
  98970. */
  98971. /**
  98972. * Creates an object which can listen for and emit events.
  98973. * This is similar to the EventEmitter API in Node's standard library, but it has a few differences.
  98974. * The goal is to allow multiple modules to attach arbitrary listeners to the same emitter, without
  98975. * letting the modules know about each other at all.
  98976. * 1. It has no special keys like `error` and `newListener`, which would allow modules to detect when
  98977. * another module throws an error or registers a listener.
  98978. * 2. It calls listener functions without any `this` value. (`EventEmitter` calls listeners with a
  98979. * `this` value of the emitter instance, which would give listeners access to other listeners.)
  98980. * @returns {SafeEmitter} An emitter
  98981. */
  98982. module.exports = function () {
  98983. var listeners = Object.create(null);
  98984. return Object.freeze({
  98985. on: function on(eventName, listener) {
  98986. if (eventName in listeners) {
  98987. listeners[eventName].push(listener);
  98988. } else {
  98989. listeners[eventName] = [listener];
  98990. }
  98991. },
  98992. emit: function emit(eventName) {
  98993. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  98994. args[_key - 1] = arguments[_key];
  98995. }
  98996. if (eventName in listeners) {
  98997. listeners[eventName].forEach(function (listener) {
  98998. return listener.apply(undefined, args);
  98999. });
  99000. }
  99001. },
  99002. eventNames: function eventNames() {
  99003. return Object.keys(listeners);
  99004. }
  99005. });
  99006. };
  99007. },{}],415:[function(require,module,exports){
  99008. /**
  99009. * @fileoverview An object that caches and applies source code fixes.
  99010. * @author Nicholas C. Zakas
  99011. */
  99012. "use strict";
  99013. //------------------------------------------------------------------------------
  99014. // Requirements
  99015. //------------------------------------------------------------------------------
  99016. var debug = require("debug")("eslint:source-code-fixer");
  99017. //------------------------------------------------------------------------------
  99018. // Helpers
  99019. //------------------------------------------------------------------------------
  99020. var BOM = "\uFEFF";
  99021. /**
  99022. * Compares items in a messages array by range.
  99023. * @param {Message} a The first message.
  99024. * @param {Message} b The second message.
  99025. * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
  99026. * @private
  99027. */
  99028. function compareMessagesByFixRange(a, b) {
  99029. return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1];
  99030. }
  99031. /**
  99032. * Compares items in a messages array by line and column.
  99033. * @param {Message} a The first message.
  99034. * @param {Message} b The second message.
  99035. * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
  99036. * @private
  99037. */
  99038. function compareMessagesByLocation(a, b) {
  99039. return a.line - b.line || a.column - b.column;
  99040. }
  99041. //------------------------------------------------------------------------------
  99042. // Public Interface
  99043. //------------------------------------------------------------------------------
  99044. /**
  99045. * Utility for apply fixes to source code.
  99046. * @constructor
  99047. */
  99048. function SourceCodeFixer() {
  99049. Object.freeze(this);
  99050. }
  99051. /**
  99052. * Applies the fixes specified by the messages to the given text. Tries to be
  99053. * smart about the fixes and won't apply fixes over the same area in the text.
  99054. * @param {string} sourceText The text to apply the changes to.
  99055. * @param {Message[]} messages The array of messages reported by ESLint.
  99056. * @param {boolean|Function} [shouldFix=true] Determines whether each message should be fixed
  99057. * @returns {Object} An object containing the fixed text and any unfixed messages.
  99058. */
  99059. SourceCodeFixer.applyFixes = function (sourceText, messages, shouldFix) {
  99060. debug("Applying fixes");
  99061. if (shouldFix === false) {
  99062. debug("shouldFix parameter was false, not attempting fixes");
  99063. return {
  99064. fixed: false,
  99065. messages: messages,
  99066. output: sourceText
  99067. };
  99068. }
  99069. // clone the array
  99070. var remainingMessages = [],
  99071. fixes = [],
  99072. bom = sourceText.startsWith(BOM) ? BOM : "",
  99073. text = bom ? sourceText.slice(1) : sourceText;
  99074. var lastPos = Number.NEGATIVE_INFINITY,
  99075. output = bom;
  99076. /**
  99077. * Try to use the 'fix' from a problem.
  99078. * @param {Message} problem The message object to apply fixes from
  99079. * @returns {boolean} Whether fix was successfully applied
  99080. */
  99081. function attemptFix(problem) {
  99082. var fix = problem.fix;
  99083. var start = fix.range[0];
  99084. var end = fix.range[1];
  99085. // Remain it as a problem if it's overlapped or it's a negative range
  99086. if (lastPos >= start || start > end) {
  99087. remainingMessages.push(problem);
  99088. return false;
  99089. }
  99090. // Remove BOM.
  99091. if (start < 0 && end >= 0 || start === 0 && fix.text.startsWith(BOM)) {
  99092. output = "";
  99093. }
  99094. // Make output to this fix.
  99095. output += text.slice(Math.max(0, lastPos), Math.max(0, start));
  99096. output += fix.text;
  99097. lastPos = end;
  99098. return true;
  99099. }
  99100. messages.forEach(function (problem) {
  99101. if (Object.prototype.hasOwnProperty.call(problem, "fix")) {
  99102. fixes.push(problem);
  99103. } else {
  99104. remainingMessages.push(problem);
  99105. }
  99106. });
  99107. if (fixes.length) {
  99108. debug("Found fixes to apply");
  99109. var fixesWereApplied = false;
  99110. var _iteratorNormalCompletion = true;
  99111. var _didIteratorError = false;
  99112. var _iteratorError = undefined;
  99113. try {
  99114. for (var _iterator = fixes.sort(compareMessagesByFixRange)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  99115. var problem = _step.value;
  99116. if (typeof shouldFix !== "function" || shouldFix(problem)) {
  99117. attemptFix(problem);
  99118. /*
  99119. * The only time attemptFix will fail is if a previous fix was
  99120. * applied which conflicts with it. So we can mark this as true.
  99121. */
  99122. fixesWereApplied = true;
  99123. } else {
  99124. remainingMessages.push(problem);
  99125. }
  99126. }
  99127. } catch (err) {
  99128. _didIteratorError = true;
  99129. _iteratorError = err;
  99130. } finally {
  99131. try {
  99132. if (!_iteratorNormalCompletion && _iterator.return) {
  99133. _iterator.return();
  99134. }
  99135. } finally {
  99136. if (_didIteratorError) {
  99137. throw _iteratorError;
  99138. }
  99139. }
  99140. }
  99141. output += text.slice(Math.max(0, lastPos));
  99142. return {
  99143. fixed: fixesWereApplied,
  99144. messages: remainingMessages.sort(compareMessagesByLocation),
  99145. output: output
  99146. };
  99147. }
  99148. debug("No fixes to apply");
  99149. return {
  99150. fixed: false,
  99151. messages: messages,
  99152. output: bom + text
  99153. };
  99154. };
  99155. module.exports = SourceCodeFixer;
  99156. },{"debug":53}],416:[function(require,module,exports){
  99157. /**
  99158. * @fileoverview Abstraction of JavaScript source code.
  99159. * @author Nicholas C. Zakas
  99160. */
  99161. "use strict";
  99162. //------------------------------------------------------------------------------
  99163. // Requirements
  99164. //------------------------------------------------------------------------------
  99165. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  99166. 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; }; }();
  99167. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  99168. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  99169. 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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  99170. var TokenStore = require("../token-store"),
  99171. Traverser = require("./traverser"),
  99172. astUtils = require("../util/ast-utils"),
  99173. lodash = require("lodash");
  99174. //------------------------------------------------------------------------------
  99175. // Private
  99176. //------------------------------------------------------------------------------
  99177. /**
  99178. * Validates that the given AST has the required information.
  99179. * @param {ASTNode} ast The Program node of the AST to check.
  99180. * @throws {Error} If the AST doesn't contain the correct information.
  99181. * @returns {void}
  99182. * @private
  99183. */
  99184. function validate(ast) {
  99185. if (!ast.tokens) {
  99186. throw new Error("AST is missing the tokens array.");
  99187. }
  99188. if (!ast.comments) {
  99189. throw new Error("AST is missing the comments array.");
  99190. }
  99191. if (!ast.loc) {
  99192. throw new Error("AST is missing location information.");
  99193. }
  99194. if (!ast.range) {
  99195. throw new Error("AST is missing range information");
  99196. }
  99197. }
  99198. /**
  99199. * Check to see if its a ES6 export declaration.
  99200. * @param {ASTNode} astNode An AST node.
  99201. * @returns {boolean} whether the given node represents an export declaration.
  99202. * @private
  99203. */
  99204. function looksLikeExport(astNode) {
  99205. return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" || astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier";
  99206. }
  99207. /**
  99208. * Merges two sorted lists into a larger sorted list in O(n) time.
  99209. * @param {Token[]} tokens The list of tokens.
  99210. * @param {Token[]} comments The list of comments.
  99211. * @returns {Token[]} A sorted list of tokens and comments.
  99212. * @private
  99213. */
  99214. function sortedMerge(tokens, comments) {
  99215. var result = [];
  99216. var tokenIndex = 0;
  99217. var commentIndex = 0;
  99218. while (tokenIndex < tokens.length || commentIndex < comments.length) {
  99219. if (commentIndex >= comments.length || tokenIndex < tokens.length && tokens[tokenIndex].range[0] < comments[commentIndex].range[0]) {
  99220. result.push(tokens[tokenIndex++]);
  99221. } else {
  99222. result.push(comments[commentIndex++]);
  99223. }
  99224. }
  99225. return result;
  99226. }
  99227. //------------------------------------------------------------------------------
  99228. // Public Interface
  99229. //------------------------------------------------------------------------------
  99230. var SourceCode = function (_TokenStore) {
  99231. _inherits(SourceCode, _TokenStore);
  99232. /**
  99233. * Represents parsed source code.
  99234. * @param {string|Object} textOrConfig - The source code text or config object.
  99235. * @param {string} textOrConfig.text - The source code text.
  99236. * @param {ASTNode} textOrConfig.ast - The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
  99237. * @param {Object|null} textOrConfig.parserServices - The parser services.
  99238. * @param {ScopeManager|null} textOrConfig.scopeManager - The scope of this source code.
  99239. * @param {Object|null} textOrConfig.visitorKeys - The visitor keys to traverse AST.
  99240. * @param {ASTNode} [astIfNoConfig] - The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
  99241. * @constructor
  99242. */
  99243. function SourceCode(textOrConfig, astIfNoConfig) {
  99244. _classCallCheck(this, SourceCode);
  99245. var text = void 0,
  99246. ast = void 0,
  99247. parserServices = void 0,
  99248. scopeManager = void 0,
  99249. visitorKeys = void 0;
  99250. // Process overloading.
  99251. if (typeof textOrConfig === "string") {
  99252. text = textOrConfig;
  99253. ast = astIfNoConfig;
  99254. } else if ((typeof textOrConfig === "undefined" ? "undefined" : _typeof(textOrConfig)) === "object" && textOrConfig !== null) {
  99255. text = textOrConfig.text;
  99256. ast = textOrConfig.ast;
  99257. parserServices = textOrConfig.parserServices;
  99258. scopeManager = textOrConfig.scopeManager;
  99259. visitorKeys = textOrConfig.visitorKeys;
  99260. }
  99261. validate(ast);
  99262. /**
  99263. * The flag to indicate that the source code has Unicode BOM.
  99264. * @type boolean
  99265. */
  99266. var _this = _possibleConstructorReturn(this, (SourceCode.__proto__ || Object.getPrototypeOf(SourceCode)).call(this, ast.tokens, ast.comments));
  99267. _this.hasBOM = text.charCodeAt(0) === 0xFEFF;
  99268. /**
  99269. * The original text source code.
  99270. * BOM was stripped from this text.
  99271. * @type string
  99272. */
  99273. _this.text = _this.hasBOM ? text.slice(1) : text;
  99274. /**
  99275. * The parsed AST for the source code.
  99276. * @type ASTNode
  99277. */
  99278. _this.ast = ast;
  99279. /**
  99280. * The parser services of this source code.
  99281. * @type {Object}
  99282. */
  99283. _this.parserServices = parserServices || {};
  99284. /**
  99285. * The scope of this source code.
  99286. * @type {ScopeManager|null}
  99287. */
  99288. _this.scopeManager = scopeManager || null;
  99289. /**
  99290. * The visitor keys to traverse AST.
  99291. * @type {Object}
  99292. */
  99293. _this.visitorKeys = visitorKeys || Traverser.DEFAULT_VISITOR_KEYS;
  99294. // Check the source text for the presence of a shebang since it is parsed as a standard line comment.
  99295. var shebangMatched = _this.text.match(astUtils.SHEBANG_MATCHER);
  99296. var hasShebang = shebangMatched && ast.comments.length && ast.comments[0].value === shebangMatched[1];
  99297. if (hasShebang) {
  99298. ast.comments[0].type = "Shebang";
  99299. }
  99300. _this.tokensAndComments = sortedMerge(ast.tokens, ast.comments);
  99301. /**
  99302. * The source code split into lines according to ECMA-262 specification.
  99303. * This is done to avoid each rule needing to do so separately.
  99304. * @type string[]
  99305. */
  99306. _this.lines = [];
  99307. _this.lineStartIndices = [0];
  99308. var lineEndingPattern = astUtils.createGlobalLinebreakMatcher();
  99309. var match = void 0;
  99310. /*
  99311. * Previously, this was implemented using a regex that
  99312. * matched a sequence of non-linebreak characters followed by a
  99313. * linebreak, then adding the lengths of the matches. However,
  99314. * this caused a catastrophic backtracking issue when the end
  99315. * of a file contained a large number of non-newline characters.
  99316. * To avoid this, the current implementation just matches newlines
  99317. * and uses match.index to get the correct line start indices.
  99318. */
  99319. while (match = lineEndingPattern.exec(_this.text)) {
  99320. _this.lines.push(_this.text.slice(_this.lineStartIndices[_this.lineStartIndices.length - 1], match.index));
  99321. _this.lineStartIndices.push(match.index + match[0].length);
  99322. }
  99323. _this.lines.push(_this.text.slice(_this.lineStartIndices[_this.lineStartIndices.length - 1]));
  99324. // Cache for comments found using getComments().
  99325. _this._commentCache = new WeakMap();
  99326. // don't allow modification of this object
  99327. Object.freeze(_this);
  99328. Object.freeze(_this.lines);
  99329. return _this;
  99330. }
  99331. /**
  99332. * Split the source code into multiple lines based on the line delimiters.
  99333. * @param {string} text Source code as a string.
  99334. * @returns {string[]} Array of source code lines.
  99335. * @public
  99336. */
  99337. _createClass(SourceCode, [{
  99338. key: "getText",
  99339. /**
  99340. * Gets the source code for the given node.
  99341. * @param {ASTNode=} node The AST node to get the text for.
  99342. * @param {int=} beforeCount The number of characters before the node to retrieve.
  99343. * @param {int=} afterCount The number of characters after the node to retrieve.
  99344. * @returns {string} The text representing the AST node.
  99345. * @public
  99346. */
  99347. value: function getText(node, beforeCount, afterCount) {
  99348. if (node) {
  99349. return this.text.slice(Math.max(node.range[0] - (beforeCount || 0), 0), node.range[1] + (afterCount || 0));
  99350. }
  99351. return this.text;
  99352. }
  99353. /**
  99354. * Gets the entire source text split into an array of lines.
  99355. * @returns {Array} The source text as an array of lines.
  99356. * @public
  99357. */
  99358. }, {
  99359. key: "getLines",
  99360. value: function getLines() {
  99361. return this.lines;
  99362. }
  99363. /**
  99364. * Retrieves an array containing all comments in the source code.
  99365. * @returns {ASTNode[]} An array of comment nodes.
  99366. * @public
  99367. */
  99368. }, {
  99369. key: "getAllComments",
  99370. value: function getAllComments() {
  99371. return this.ast.comments;
  99372. }
  99373. /**
  99374. * Gets all comments for the given node.
  99375. * @param {ASTNode} node The AST node to get the comments for.
  99376. * @returns {Object} An object containing a leading and trailing array
  99377. * of comments indexed by their position.
  99378. * @public
  99379. */
  99380. }, {
  99381. key: "getComments",
  99382. value: function getComments(node) {
  99383. if (this._commentCache.has(node)) {
  99384. return this._commentCache.get(node);
  99385. }
  99386. var comments = {
  99387. leading: [],
  99388. trailing: []
  99389. };
  99390. /*
  99391. * Return all comments as leading comments of the Program node when
  99392. * there is no executable code.
  99393. */
  99394. if (node.type === "Program") {
  99395. if (node.body.length === 0) {
  99396. comments.leading = node.comments;
  99397. }
  99398. } else {
  99399. /*
  99400. * Return comments as trailing comments of nodes that only contain
  99401. * comments (to mimic the comment attachment behavior present in Espree).
  99402. */
  99403. if ((node.type === "BlockStatement" || node.type === "ClassBody") && node.body.length === 0 || node.type === "ObjectExpression" && node.properties.length === 0 || node.type === "ArrayExpression" && node.elements.length === 0 || node.type === "SwitchStatement" && node.cases.length === 0) {
  99404. comments.trailing = this.getTokens(node, {
  99405. includeComments: true,
  99406. filter: astUtils.isCommentToken
  99407. });
  99408. }
  99409. /*
  99410. * Iterate over tokens before and after node and collect comment tokens.
  99411. * Do not include comments that exist outside of the parent node
  99412. * to avoid duplication.
  99413. */
  99414. var currentToken = this.getTokenBefore(node, { includeComments: true });
  99415. while (currentToken && astUtils.isCommentToken(currentToken)) {
  99416. if (node.parent && currentToken.start < node.parent.start) {
  99417. break;
  99418. }
  99419. comments.leading.push(currentToken);
  99420. currentToken = this.getTokenBefore(currentToken, { includeComments: true });
  99421. }
  99422. comments.leading.reverse();
  99423. currentToken = this.getTokenAfter(node, { includeComments: true });
  99424. while (currentToken && astUtils.isCommentToken(currentToken)) {
  99425. if (node.parent && currentToken.end > node.parent.end) {
  99426. break;
  99427. }
  99428. comments.trailing.push(currentToken);
  99429. currentToken = this.getTokenAfter(currentToken, { includeComments: true });
  99430. }
  99431. }
  99432. this._commentCache.set(node, comments);
  99433. return comments;
  99434. }
  99435. /**
  99436. * Retrieves the JSDoc comment for a given node.
  99437. * @param {ASTNode} node The AST node to get the comment for.
  99438. * @returns {Token|null} The Block comment token containing the JSDoc comment
  99439. * for the given node or null if not found.
  99440. * @public
  99441. * @deprecated
  99442. */
  99443. }, {
  99444. key: "getJSDocComment",
  99445. value: function getJSDocComment(node) {
  99446. var _this2 = this;
  99447. /**
  99448. * Checks for the presence of a JSDoc comment for the given node and returns it.
  99449. * @param {ASTNode} astNode The AST node to get the comment for.
  99450. * @returns {Token|null} The Block comment token containing the JSDoc comment
  99451. * for the given node or null if not found.
  99452. * @private
  99453. */
  99454. var findJSDocComment = function findJSDocComment(astNode) {
  99455. var tokenBefore = _this2.getTokenBefore(astNode, { includeComments: true });
  99456. if (tokenBefore && astUtils.isCommentToken(tokenBefore) && tokenBefore.type === "Block" && tokenBefore.value.charAt(0) === "*" && astNode.loc.start.line - tokenBefore.loc.end.line <= 1) {
  99457. return tokenBefore;
  99458. }
  99459. return null;
  99460. };
  99461. var parent = node.parent;
  99462. switch (node.type) {
  99463. case "ClassDeclaration":
  99464. case "FunctionDeclaration":
  99465. return findJSDocComment(looksLikeExport(parent) ? parent : node);
  99466. case "ClassExpression":
  99467. return findJSDocComment(parent.parent);
  99468. case "ArrowFunctionExpression":
  99469. case "FunctionExpression":
  99470. if (parent.type !== "CallExpression" && parent.type !== "NewExpression") {
  99471. while (!this.getCommentsBefore(parent).length && !/Function/.test(parent.type) && parent.type !== "MethodDefinition" && parent.type !== "Property") {
  99472. parent = parent.parent;
  99473. if (!parent) {
  99474. break;
  99475. }
  99476. }
  99477. if (parent && parent.type !== "FunctionDeclaration" && parent.type !== "Program") {
  99478. return findJSDocComment(parent);
  99479. }
  99480. }
  99481. return findJSDocComment(node);
  99482. // falls through
  99483. default:
  99484. return null;
  99485. }
  99486. }
  99487. /**
  99488. * Gets the deepest node containing a range index.
  99489. * @param {int} index Range index of the desired node.
  99490. * @returns {ASTNode} The node if found or null if not found.
  99491. * @public
  99492. */
  99493. }, {
  99494. key: "getNodeByRangeIndex",
  99495. value: function getNodeByRangeIndex(index) {
  99496. var result = null;
  99497. Traverser.traverse(this.ast, {
  99498. visitorKeys: this.visitorKeys,
  99499. enter: function enter(node) {
  99500. if (node.range[0] <= index && index < node.range[1]) {
  99501. result = node;
  99502. } else {
  99503. this.skip();
  99504. }
  99505. },
  99506. leave: function leave(node) {
  99507. if (node === result) {
  99508. this.break();
  99509. }
  99510. }
  99511. });
  99512. return result;
  99513. }
  99514. /**
  99515. * Determines if two tokens have at least one whitespace character
  99516. * between them. This completely disregards comments in making the
  99517. * determination, so comments count as zero-length substrings.
  99518. * @param {Token} first The token to check after.
  99519. * @param {Token} second The token to check before.
  99520. * @returns {boolean} True if there is only space between tokens, false
  99521. * if there is anything other than whitespace between tokens.
  99522. * @public
  99523. */
  99524. }, {
  99525. key: "isSpaceBetweenTokens",
  99526. value: function isSpaceBetweenTokens(first, second) {
  99527. var text = this.text.slice(first.range[1], second.range[0]);
  99528. return (/\s/.test(text.replace(/\/\*.*?\*\//g, ""))
  99529. );
  99530. }
  99531. /**
  99532. * Converts a source text index into a (line, column) pair.
  99533. * @param {number} index The index of a character in a file
  99534. * @returns {Object} A {line, column} location object with a 0-indexed column
  99535. * @public
  99536. */
  99537. }, {
  99538. key: "getLocFromIndex",
  99539. value: function getLocFromIndex(index) {
  99540. if (typeof index !== "number") {
  99541. throw new TypeError("Expected `index` to be a number.");
  99542. }
  99543. if (index < 0 || index > this.text.length) {
  99544. throw new RangeError("Index out of range (requested index " + index + ", but source text has length " + this.text.length + ").");
  99545. }
  99546. /*
  99547. * For an argument of this.text.length, return the location one "spot" past the last character
  99548. * of the file. If the last character is a linebreak, the location will be column 0 of the next
  99549. * line; otherwise, the location will be in the next column on the same line.
  99550. *
  99551. * See getIndexFromLoc for the motivation for this special case.
  99552. */
  99553. if (index === this.text.length) {
  99554. return { line: this.lines.length, column: this.lines[this.lines.length - 1].length };
  99555. }
  99556. /*
  99557. * To figure out which line rangeIndex is on, determine the last index at which rangeIndex could
  99558. * be inserted into lineIndices to keep the list sorted.
  99559. */
  99560. var lineNumber = lodash.sortedLastIndex(this.lineStartIndices, index);
  99561. return { line: lineNumber, column: index - this.lineStartIndices[lineNumber - 1] };
  99562. }
  99563. /**
  99564. * Converts a (line, column) pair into a range index.
  99565. * @param {Object} loc A line/column location
  99566. * @param {number} loc.line The line number of the location (1-indexed)
  99567. * @param {number} loc.column The column number of the location (0-indexed)
  99568. * @returns {number} The range index of the location in the file.
  99569. * @public
  99570. */
  99571. }, {
  99572. key: "getIndexFromLoc",
  99573. value: function getIndexFromLoc(loc) {
  99574. if ((typeof loc === "undefined" ? "undefined" : _typeof(loc)) !== "object" || typeof loc.line !== "number" || typeof loc.column !== "number") {
  99575. throw new TypeError("Expected `loc` to be an object with numeric `line` and `column` properties.");
  99576. }
  99577. if (loc.line <= 0) {
  99578. throw new RangeError("Line number out of range (line " + loc.line + " requested). Line numbers should be 1-based.");
  99579. }
  99580. if (loc.line > this.lineStartIndices.length) {
  99581. throw new RangeError("Line number out of range (line " + loc.line + " requested, but only " + this.lineStartIndices.length + " lines present).");
  99582. }
  99583. var lineStartIndex = this.lineStartIndices[loc.line - 1];
  99584. var lineEndIndex = loc.line === this.lineStartIndices.length ? this.text.length : this.lineStartIndices[loc.line];
  99585. var positionIndex = lineStartIndex + loc.column;
  99586. /*
  99587. * By design, getIndexFromLoc({ line: lineNum, column: 0 }) should return the start index of
  99588. * the given line, provided that the line number is valid element of this.lines. Since the
  99589. * last element of this.lines is an empty string for files with trailing newlines, add a
  99590. * special case where getting the index for the first location after the end of the file
  99591. * will return the length of the file, rather than throwing an error. This allows rules to
  99592. * use getIndexFromLoc consistently without worrying about edge cases at the end of a file.
  99593. */
  99594. if (loc.line === this.lineStartIndices.length && positionIndex > lineEndIndex || loc.line < this.lineStartIndices.length && positionIndex >= lineEndIndex) {
  99595. throw new RangeError("Column number out of range (column " + loc.column + " requested, but the length of line " + loc.line + " is " + (lineEndIndex - lineStartIndex) + ").");
  99596. }
  99597. return positionIndex;
  99598. }
  99599. }], [{
  99600. key: "splitLines",
  99601. value: function splitLines(text) {
  99602. return text.split(astUtils.createGlobalLinebreakMatcher());
  99603. }
  99604. }]);
  99605. return SourceCode;
  99606. }(TokenStore);
  99607. module.exports = SourceCode;
  99608. },{"../token-store":398,"../util/ast-utils":405,"./traverser":418,"lodash":92}],417:[function(require,module,exports){
  99609. (function (process){
  99610. /**
  99611. * @fileoverview Tracks performance of individual rules.
  99612. * @author Brandon Mills
  99613. */
  99614. "use strict";
  99615. //------------------------------------------------------------------------------
  99616. // Helpers
  99617. //------------------------------------------------------------------------------
  99618. /* istanbul ignore next */
  99619. /**
  99620. * Align the string to left
  99621. * @param {string} str string to evaluate
  99622. * @param {int} len length of the string
  99623. * @param {string} ch delimiter character
  99624. * @returns {string} modified string
  99625. * @private
  99626. */
  99627. function alignLeft(str, len, ch) {
  99628. return str + new Array(len - str.length + 1).join(ch || " ");
  99629. }
  99630. /* istanbul ignore next */
  99631. /**
  99632. * Align the string to right
  99633. * @param {string} str string to evaluate
  99634. * @param {int} len length of the string
  99635. * @param {string} ch delimiter character
  99636. * @returns {string} modified string
  99637. * @private
  99638. */
  99639. function alignRight(str, len, ch) {
  99640. return new Array(len - str.length + 1).join(ch || " ") + str;
  99641. }
  99642. //------------------------------------------------------------------------------
  99643. // Module definition
  99644. //------------------------------------------------------------------------------
  99645. var enabled = !!process.env.TIMING;
  99646. var HEADERS = ["Rule", "Time (ms)", "Relative"];
  99647. var ALIGN = [alignLeft, alignRight, alignRight];
  99648. /* istanbul ignore next */
  99649. /**
  99650. * display the data
  99651. * @param {Object} data Data object to be displayed
  99652. * @returns {string} modified string
  99653. * @private
  99654. */
  99655. function display(data) {
  99656. var total = 0;
  99657. var rows = Object.keys(data).map(function (key) {
  99658. var time = data[key];
  99659. total += time;
  99660. return [key, time];
  99661. }).sort(function (a, b) {
  99662. return b[1] - a[1];
  99663. }).slice(0, 10);
  99664. rows.forEach(function (row) {
  99665. row.push((row[1] * 100 / total).toFixed(1) + "%");
  99666. row[1] = row[1].toFixed(3);
  99667. });
  99668. rows.unshift(HEADERS);
  99669. var widths = [];
  99670. rows.forEach(function (row) {
  99671. var len = row.length;
  99672. for (var i = 0; i < len; i++) {
  99673. var n = row[i].length;
  99674. if (!widths[i] || n > widths[i]) {
  99675. widths[i] = n;
  99676. }
  99677. }
  99678. });
  99679. var table = rows.map(function (row) {
  99680. return row.map(function (cell, index) {
  99681. return ALIGN[index](cell, widths[index]);
  99682. }).join(" | ");
  99683. });
  99684. table.splice(1, 0, widths.map(function (width, index) {
  99685. var extraAlignment = index !== 0 && index !== widths.length - 1 ? 2 : 1;
  99686. return ALIGN[index](":", width + extraAlignment, "-");
  99687. }).join("|"));
  99688. console.log(table.join("\n")); // eslint-disable-line no-console
  99689. }
  99690. /* istanbul ignore next */
  99691. module.exports = function () {
  99692. var data = Object.create(null);
  99693. /**
  99694. * Time the run
  99695. * @param {*} key key from the data object
  99696. * @param {Function} fn function to be called
  99697. * @returns {Function} function to be executed
  99698. * @private
  99699. */
  99700. function time(key, fn) {
  99701. if (typeof data[key] === "undefined") {
  99702. data[key] = 0;
  99703. }
  99704. return function () {
  99705. var t = process.hrtime();
  99706. fn.apply(undefined, arguments);
  99707. t = process.hrtime(t);
  99708. data[key] += t[0] * 1e3 + t[1] / 1e6;
  99709. };
  99710. }
  99711. if (enabled) {
  99712. process.on("exit", function () {
  99713. display(data);
  99714. });
  99715. }
  99716. return {
  99717. time: time,
  99718. enabled: enabled
  99719. };
  99720. }();
  99721. }).call(this,require('_process'))
  99722. },{"_process":103}],418:[function(require,module,exports){
  99723. /**
  99724. * @fileoverview Traverser to traverse AST trees.
  99725. * @author Nicholas C. Zakas
  99726. * @author Toru Nagashima
  99727. */
  99728. "use strict";
  99729. //------------------------------------------------------------------------------
  99730. // Requirements
  99731. //------------------------------------------------------------------------------
  99732. 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; }; }();
  99733. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  99734. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  99735. var vk = require("eslint-visitor-keys");
  99736. var debug = require("debug")("eslint:traverser");
  99737. //------------------------------------------------------------------------------
  99738. // Helpers
  99739. //------------------------------------------------------------------------------
  99740. /**
  99741. * Do nothing.
  99742. * @returns {void}
  99743. */
  99744. function noop() {}
  99745. // do nothing.
  99746. /**
  99747. * Check whether the given value is an ASTNode or not.
  99748. * @param {any} x The value to check.
  99749. * @returns {boolean} `true` if the value is an ASTNode.
  99750. */
  99751. function isNode(x) {
  99752. return x !== null && (typeof x === "undefined" ? "undefined" : _typeof(x)) === "object" && typeof x.type === "string";
  99753. }
  99754. /**
  99755. * Get the visitor keys of a given node.
  99756. * @param {Object} visitorKeys The map of visitor keys.
  99757. * @param {ASTNode} node The node to get their visitor keys.
  99758. * @returns {string[]} The visitor keys of the node.
  99759. */
  99760. function getVisitorKeys(visitorKeys, node) {
  99761. var keys = visitorKeys[node.type];
  99762. if (!keys) {
  99763. keys = vk.getKeys(node);
  99764. debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys);
  99765. }
  99766. return keys;
  99767. }
  99768. /**
  99769. * The traverser class to traverse AST trees.
  99770. */
  99771. var Traverser = function () {
  99772. function Traverser() {
  99773. _classCallCheck(this, Traverser);
  99774. this._current = null;
  99775. this._parents = [];
  99776. this._skipped = false;
  99777. this._broken = false;
  99778. this._visitorKeys = null;
  99779. this._enter = null;
  99780. this._leave = null;
  99781. }
  99782. /**
  99783. * @returns {ASTNode} The current node.
  99784. */
  99785. _createClass(Traverser, [{
  99786. key: "current",
  99787. value: function current() {
  99788. return this._current;
  99789. }
  99790. /**
  99791. * @returns {ASTNode[]} The ancestor nodes.
  99792. */
  99793. }, {
  99794. key: "parents",
  99795. value: function parents() {
  99796. return this._parents.slice(0);
  99797. }
  99798. /**
  99799. * Break the current traversal.
  99800. * @returns {void}
  99801. */
  99802. }, {
  99803. key: "break",
  99804. value: function _break() {
  99805. this._broken = true;
  99806. }
  99807. /**
  99808. * Skip child nodes for the current traversal.
  99809. * @returns {void}
  99810. */
  99811. }, {
  99812. key: "skip",
  99813. value: function skip() {
  99814. this._skipped = true;
  99815. }
  99816. /**
  99817. * Traverse the given AST tree.
  99818. * @param {ASTNode} node The root node to traverse.
  99819. * @param {Object} options The option object.
  99820. * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
  99821. * @param {Function} [options.enter=noop] The callback function which is called on entering each node.
  99822. * @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
  99823. * @returns {void}
  99824. */
  99825. }, {
  99826. key: "traverse",
  99827. value: function traverse(node, options) {
  99828. this._current = null;
  99829. this._parents = [];
  99830. this._skipped = false;
  99831. this._broken = false;
  99832. this._visitorKeys = options.visitorKeys || vk.KEYS;
  99833. this._enter = options.enter || noop;
  99834. this._leave = options.leave || noop;
  99835. this._traverse(node, null);
  99836. }
  99837. /**
  99838. * Traverse the given AST tree recursively.
  99839. * @param {ASTNode} node The current node.
  99840. * @param {ASTNode|null} parent The parent node.
  99841. * @returns {void}
  99842. * @private
  99843. */
  99844. }, {
  99845. key: "_traverse",
  99846. value: function _traverse(node, parent) {
  99847. if (!isNode(node)) {
  99848. return;
  99849. }
  99850. this._current = node;
  99851. this._skipped = false;
  99852. this._enter(node, parent);
  99853. if (!this._skipped && !this._broken) {
  99854. var keys = getVisitorKeys(this._visitorKeys, node);
  99855. if (keys.length >= 1) {
  99856. this._parents.push(node);
  99857. for (var i = 0; i < keys.length && !this._broken; ++i) {
  99858. var child = node[keys[i]];
  99859. if (Array.isArray(child)) {
  99860. for (var j = 0; j < child.length && !this._broken; ++j) {
  99861. this._traverse(child[j], node);
  99862. }
  99863. } else {
  99864. this._traverse(child, node);
  99865. }
  99866. }
  99867. this._parents.pop();
  99868. }
  99869. }
  99870. if (!this._broken) {
  99871. this._leave(node, parent);
  99872. }
  99873. this._current = parent;
  99874. }
  99875. /**
  99876. * Calculates the keys to use for traversal.
  99877. * @param {ASTNode} node The node to read keys from.
  99878. * @returns {string[]} An array of keys to visit on the node.
  99879. * @private
  99880. */
  99881. }], [{
  99882. key: "getKeys",
  99883. value: function getKeys(node) {
  99884. return vk.getKeys(node);
  99885. }
  99886. /**
  99887. * Traverse the given AST tree.
  99888. * @param {ASTNode} node The root node to traverse.
  99889. * @param {Object} options The option object.
  99890. * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
  99891. * @param {Function} [options.enter=noop] The callback function which is called on entering each node.
  99892. * @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
  99893. * @returns {void}
  99894. */
  99895. }, {
  99896. key: "traverse",
  99897. value: function traverse(node, options) {
  99898. new Traverser().traverse(node, options);
  99899. }
  99900. /**
  99901. * The default visitor keys.
  99902. * @type {Object}
  99903. */
  99904. }, {
  99905. key: "DEFAULT_VISITOR_KEYS",
  99906. get: function get() {
  99907. return vk.KEYS;
  99908. }
  99909. }]);
  99910. return Traverser;
  99911. }();
  99912. module.exports = Traverser;
  99913. },{"debug":53,"eslint-visitor-keys":69}],419:[function(require,module,exports){
  99914. /**
  99915. * @author Toru Nagashima <https://github.com/mysticatea>
  99916. */
  99917. "use strict";
  99918. module.exports = {
  99919. isCombiningCharacter: require("./is-combining-character"),
  99920. isEmojiModifier: require("./is-emoji-modifier"),
  99921. isRegionalIndicatorSymbol: require("./is-regional-indicator-symbol"),
  99922. isSurrogatePair: require("./is-surrogate-pair")
  99923. };
  99924. },{"./is-combining-character":420,"./is-emoji-modifier":421,"./is-regional-indicator-symbol":422,"./is-surrogate-pair":423}],420:[function(require,module,exports){
  99925. // THIS FILE WAS GENERATED BY 'tools/update-unicode-utils.js'
  99926. "use strict";
  99927. var combiningChars = new Set([768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1471, 1473, 1474, 1476, 1477, 1479, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1648, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1759, 1760, 1761, 1762, 1763, 1764, 1767, 1768, 1770, 1771, 1772, 1773, 1809, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2070, 2071, 2072, 2073, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2085, 2086, 2087, 2089, 2090, 2091, 2092, 2093, 2137, 2138, 2139, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2362, 2363, 2364, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2402, 2403, 2433, 2434, 2435, 2492, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2503, 2504, 2507, 2508, 2509, 2519, 2530, 2531, 2561, 2562, 2563, 2620, 2622, 2623, 2624, 2625, 2626, 2631, 2632, 2635, 2636, 2637, 2641, 2672, 2673, 2677, 2689, 2690, 2691, 2748, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2759, 2760, 2761, 2763, 2764, 2765, 2786, 2787, 2810, 2811, 2812, 2813, 2814, 2815, 2817, 2818, 2819, 2876, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2887, 2888, 2891, 2892, 2893, 2902, 2903, 2914, 2915, 2946, 3006, 3007, 3008, 3009, 3010, 3014, 3015, 3016, 3018, 3019, 3020, 3021, 3031, 3072, 3073, 3074, 3075, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3142, 3143, 3144, 3146, 3147, 3148, 3149, 3157, 3158, 3170, 3171, 3201, 3202, 3203, 3260, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3270, 3271, 3272, 3274, 3275, 3276, 3277, 3285, 3286, 3298, 3299, 3328, 3329, 3330, 3331, 3387, 3388, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3398, 3399, 3400, 3402, 3403, 3404, 3405, 3415, 3426, 3427, 3458, 3459, 3530, 3535, 3536, 3537, 3538, 3539, 3540, 3542, 3544, 3545, 3546, 3547, 3548, 3549, 3550, 3551, 3570, 3571, 3633, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3761, 3764, 3765, 3766, 3767, 3768, 3769, 3771, 3772, 3784, 3785, 3786, 3787, 3788, 3789, 3864, 3865, 3893, 3895, 3897, 3902, 3903, 3953, 3954, 3955, 3956, 3957, 3958, 3959, 3960, 3961, 3962, 3963, 3964, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3974, 3975, 3981, 3982, 3983, 3984, 3985, 3986, 3987, 3988, 3989, 3990, 3991, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4038, 4139, 4140, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4182, 4183, 4184, 4185, 4190, 4191, 4192, 4194, 4195, 4196, 4199, 4200, 4201, 4202, 4203, 4204, 4205, 4209, 4210, 4211, 4212, 4226, 4227, 4228, 4229, 4230, 4231, 4232, 4233, 4234, 4235, 4236, 4237, 4239, 4250, 4251, 4252, 4253, 4957, 4958, 4959, 5906, 5907, 5908, 5938, 5939, 5940, 5970, 5971, 6002, 6003, 6068, 6069, 6070, 6071, 6072, 6073, 6074, 6075, 6076, 6077, 6078, 6079, 6080, 6081, 6082, 6083, 6084, 6085, 6086, 6087, 6088, 6089, 6090, 6091, 6092, 6093, 6094, 6095, 6096, 6097, 6098, 6099, 6109, 6155, 6156, 6157, 6277, 6278, 6313, 6432, 6433, 6434, 6435, 6436, 6437, 6438, 6439, 6440, 6441, 6442, 6443, 6448, 6449, 6450, 6451, 6452, 6453, 6454, 6455, 6456, 6457, 6458, 6459, 6679, 6680, 6681, 6682, 6683, 6741, 6742, 6743, 6744, 6745, 6746, 6747, 6748, 6749, 6750, 6752, 6753, 6754, 6755, 6756, 6757, 6758, 6759, 6760, 6761, 6762, 6763, 6764, 6765, 6766, 6767, 6768, 6769, 6770, 6771, 6772, 6773, 6774, 6775, 6776, 6777, 6778, 6779, 6780, 6783, 6832, 6833, 6834, 6835, 6836, 6837, 6838, 6839, 6840, 6841, 6842, 6843, 6844, 6845, 6846, 6912, 6913, 6914, 6915, 6916, 6964, 6965, 6966, 6967, 6968, 6969, 6970, 6971, 6972, 6973, 6974, 6975, 6976, 6977, 6978, 6979, 6980, 7019, 7020, 7021, 7022, 7023, 7024, 7025, 7026, 7027, 7040, 7041, 7042, 7073, 7074, 7075, 7076, 7077, 7078, 7079, 7080, 7081, 7082, 7083, 7084, 7085, 7142, 7143, 7144, 7145, 7146, 7147, 7148, 7149, 7150, 7151, 7152, 7153, 7154, 7155, 7204, 7205, 7206, 7207, 7208, 7209, 7210, 7211, 7212, 7213, 7214, 7215, 7216, 7217, 7218, 7219, 7220, 7221, 7222, 7223, 7376, 7377, 7378, 7380, 7381, 7382, 7383, 7384, 7385, 7386, 7387, 7388, 7389, 7390, 7391, 7392, 7393, 7394, 7395, 7396, 7397, 7398, 7399, 7400, 7405, 7410, 7411, 7412, 7415, 7416, 7417, 7616, 7617, 7618, 7619, 7620, 7621, 7622, 7623, 7624, 7625, 7626, 7627, 7628, 7629, 7630, 7631, 7632, 7633, 7634, 7635, 7636, 7637, 7638, 7639, 7640, 7641, 7642, 7643, 7644, 7645, 7646, 7647, 7648, 7649, 7650, 7651, 7652, 7653, 7654, 7655, 7656, 7657, 7658, 7659, 7660, 7661, 7662, 7663, 7664, 7665, 7666, 7667, 7668, 7669, 7670, 7671, 7672, 7673, 7675, 7676, 7677, 7678, 7679, 8400, 8401, 8402, 8403, 8404, 8405, 8406, 8407, 8408, 8409, 8410, 8411, 8412, 8413, 8414, 8415, 8416, 8417, 8418, 8419, 8420, 8421, 8422, 8423, 8424, 8425, 8426, 8427, 8428, 8429, 8430, 8431, 8432, 11503, 11504, 11505, 11647, 11744, 11745, 11746, 11747, 11748, 11749, 11750, 11751, 11752, 11753, 11754, 11755, 11756, 11757, 11758, 11759, 11760, 11761, 11762, 11763, 11764, 11765, 11766, 11767, 11768, 11769, 11770, 11771, 11772, 11773, 11774, 11775, 12330, 12331, 12332, 12333, 12334, 12335, 12441, 12442, 42607, 42608, 42609, 42610, 42612, 42613, 42614, 42615, 42616, 42617, 42618, 42619, 42620, 42621, 42654, 42655, 42736, 42737, 43010, 43014, 43019, 43043, 43044, 43045, 43046, 43047, 43136, 43137, 43188, 43189, 43190, 43191, 43192, 43193, 43194, 43195, 43196, 43197, 43198, 43199, 43200, 43201, 43202, 43203, 43204, 43205, 43232, 43233, 43234, 43235, 43236, 43237, 43238, 43239, 43240, 43241, 43242, 43243, 43244, 43245, 43246, 43247, 43248, 43249, 43302, 43303, 43304, 43305, 43306, 43307, 43308, 43309, 43335, 43336, 43337, 43338, 43339, 43340, 43341, 43342, 43343, 43344, 43345, 43346, 43347, 43392, 43393, 43394, 43395, 43443, 43444, 43445, 43446, 43447, 43448, 43449, 43450, 43451, 43452, 43453, 43454, 43455, 43456, 43493, 43561, 43562, 43563, 43564, 43565, 43566, 43567, 43568, 43569, 43570, 43571, 43572, 43573, 43574, 43587, 43596, 43597, 43643, 43644, 43645, 43696, 43698, 43699, 43700, 43703, 43704, 43710, 43711, 43713, 43755, 43756, 43757, 43758, 43759, 43765, 43766, 44003, 44004, 44005, 44006, 44007, 44008, 44009, 44010, 44012, 44013, 64286, 65024, 65025, 65026, 65027, 65028, 65029, 65030, 65031, 65032, 65033, 65034, 65035, 65036, 65037, 65038, 65039, 65056, 65057, 65058, 65059, 65060, 65061, 65062, 65063, 65064, 65065, 65066, 65067, 65068, 65069, 65070, 65071, 66045, 66272, 66422, 66423, 66424, 66425, 66426, 68097, 68098, 68099, 68101, 68102, 68108, 68109, 68110, 68111, 68152, 68153, 68154, 68159, 68325, 68326, 69632, 69633, 69634, 69688, 69689, 69690, 69691, 69692, 69693, 69694, 69695, 69696, 69697, 69698, 69699, 69700, 69701, 69702, 69759, 69760, 69761, 69762, 69808, 69809, 69810, 69811, 69812, 69813, 69814, 69815, 69816, 69817, 69818, 69888, 69889, 69890, 69927, 69928, 69929, 69930, 69931, 69932, 69933, 69934, 69935, 69936, 69937, 69938, 69939, 69940, 70003, 70016, 70017, 70018, 70067, 70068, 70069, 70070, 70071, 70072, 70073, 70074, 70075, 70076, 70077, 70078, 70079, 70080, 70090, 70091, 70092, 70188, 70189, 70190, 70191, 70192, 70193, 70194, 70195, 70196, 70197, 70198, 70199, 70206, 70367, 70368, 70369, 70370, 70371, 70372, 70373, 70374, 70375, 70376, 70377, 70378, 70400, 70401, 70402, 70403, 70460, 70462, 70463, 70464, 70465, 70466, 70467, 70468, 70471, 70472, 70475, 70476, 70477, 70487, 70498, 70499, 70502, 70503, 70504, 70505, 70506, 70507, 70508, 70512, 70513, 70514, 70515, 70516, 70709, 70710, 70711, 70712, 70713, 70714, 70715, 70716, 70717, 70718, 70719, 70720, 70721, 70722, 70723, 70724, 70725, 70726, 70832, 70833, 70834, 70835, 70836, 70837, 70838, 70839, 70840, 70841, 70842, 70843, 70844, 70845, 70846, 70847, 70848, 70849, 70850, 70851, 71087, 71088, 71089, 71090, 71091, 71092, 71093, 71096, 71097, 71098, 71099, 71100, 71101, 71102, 71103, 71104, 71132, 71133, 71216, 71217, 71218, 71219, 71220, 71221, 71222, 71223, 71224, 71225, 71226, 71227, 71228, 71229, 71230, 71231, 71232, 71339, 71340, 71341, 71342, 71343, 71344, 71345, 71346, 71347, 71348, 71349, 71350, 71351, 71453, 71454, 71455, 71456, 71457, 71458, 71459, 71460, 71461, 71462, 71463, 71464, 71465, 71466, 71467, 72193, 72194, 72195, 72196, 72197, 72198, 72199, 72200, 72201, 72202, 72243, 72244, 72245, 72246, 72247, 72248, 72249, 72251, 72252, 72253, 72254, 72263, 72273, 72274, 72275, 72276, 72277, 72278, 72279, 72280, 72281, 72282, 72283, 72330, 72331, 72332, 72333, 72334, 72335, 72336, 72337, 72338, 72339, 72340, 72341, 72342, 72343, 72344, 72345, 72751, 72752, 72753, 72754, 72755, 72756, 72757, 72758, 72760, 72761, 72762, 72763, 72764, 72765, 72766, 72767, 72850, 72851, 72852, 72853, 72854, 72855, 72856, 72857, 72858, 72859, 72860, 72861, 72862, 72863, 72864, 72865, 72866, 72867, 72868, 72869, 72870, 72871, 72873, 72874, 72875, 72876, 72877, 72878, 72879, 72880, 72881, 72882, 72883, 72884, 72885, 72886, 73009, 73010, 73011, 73012, 73013, 73014, 73018, 73020, 73021, 73023, 73024, 73025, 73026, 73027, 73028, 73029, 73031, 92912, 92913, 92914, 92915, 92916, 92976, 92977, 92978, 92979, 92980, 92981, 92982, 94033, 94034, 94035, 94036, 94037, 94038, 94039, 94040, 94041, 94042, 94043, 94044, 94045, 94046, 94047, 94048, 94049, 94050, 94051, 94052, 94053, 94054, 94055, 94056, 94057, 94058, 94059, 94060, 94061, 94062, 94063, 94064, 94065, 94066, 94067, 94068, 94069, 94070, 94071, 94072, 94073, 94074, 94075, 94076, 94077, 94078, 94095, 94096, 94097, 94098, 113821, 113822, 119141, 119142, 119143, 119144, 119145, 119149, 119150, 119151, 119152, 119153, 119154, 119163, 119164, 119165, 119166, 119167, 119168, 119169, 119170, 119173, 119174, 119175, 119176, 119177, 119178, 119179, 119210, 119211, 119212, 119213, 119362, 119363, 119364, 121344, 121345, 121346, 121347, 121348, 121349, 121350, 121351, 121352, 121353, 121354, 121355, 121356, 121357, 121358, 121359, 121360, 121361, 121362, 121363, 121364, 121365, 121366, 121367, 121368, 121369, 121370, 121371, 121372, 121373, 121374, 121375, 121376, 121377, 121378, 121379, 121380, 121381, 121382, 121383, 121384, 121385, 121386, 121387, 121388, 121389, 121390, 121391, 121392, 121393, 121394, 121395, 121396, 121397, 121398, 121403, 121404, 121405, 121406, 121407, 121408, 121409, 121410, 121411, 121412, 121413, 121414, 121415, 121416, 121417, 121418, 121419, 121420, 121421, 121422, 121423, 121424, 121425, 121426, 121427, 121428, 121429, 121430, 121431, 121432, 121433, 121434, 121435, 121436, 121437, 121438, 121439, 121440, 121441, 121442, 121443, 121444, 121445, 121446, 121447, 121448, 121449, 121450, 121451, 121452, 121461, 121476, 121499, 121500, 121501, 121502, 121503, 121505, 121506, 121507, 121508, 121509, 121510, 121511, 121512, 121513, 121514, 121515, 121516, 121517, 121518, 121519, 122880, 122881, 122882, 122883, 122884, 122885, 122886, 122888, 122889, 122890, 122891, 122892, 122893, 122894, 122895, 122896, 122897, 122898, 122899, 122900, 122901, 122902, 122903, 122904, 122907, 122908, 122909, 122910, 122911, 122912, 122913, 122915, 122916, 122918, 122919, 122920, 122921, 122922, 125136, 125137, 125138, 125139, 125140, 125141, 125142, 125252, 125253, 125254, 125255, 125256, 125257, 125258, 917760, 917761, 917762, 917763, 917764, 917765, 917766, 917767, 917768, 917769, 917770, 917771, 917772, 917773, 917774, 917775, 917776, 917777, 917778, 917779, 917780, 917781, 917782, 917783, 917784, 917785, 917786, 917787, 917788, 917789, 917790, 917791, 917792, 917793, 917794, 917795, 917796, 917797, 917798, 917799, 917800, 917801, 917802, 917803, 917804, 917805, 917806, 917807, 917808, 917809, 917810, 917811, 917812, 917813, 917814, 917815, 917816, 917817, 917818, 917819, 917820, 917821, 917822, 917823, 917824, 917825, 917826, 917827, 917828, 917829, 917830, 917831, 917832, 917833, 917834, 917835, 917836, 917837, 917838, 917839, 917840, 917841, 917842, 917843, 917844, 917845, 917846, 917847, 917848, 917849, 917850, 917851, 917852, 917853, 917854, 917855, 917856, 917857, 917858, 917859, 917860, 917861, 917862, 917863, 917864, 917865, 917866, 917867, 917868, 917869, 917870, 917871, 917872, 917873, 917874, 917875, 917876, 917877, 917878, 917879, 917880, 917881, 917882, 917883, 917884, 917885, 917886, 917887, 917888, 917889, 917890, 917891, 917892, 917893, 917894, 917895, 917896, 917897, 917898, 917899, 917900, 917901, 917902, 917903, 917904, 917905, 917906, 917907, 917908, 917909, 917910, 917911, 917912, 917913, 917914, 917915, 917916, 917917, 917918, 917919, 917920, 917921, 917922, 917923, 917924, 917925, 917926, 917927, 917928, 917929, 917930, 917931, 917932, 917933, 917934, 917935, 917936, 917937, 917938, 917939, 917940, 917941, 917942, 917943, 917944, 917945, 917946, 917947, 917948, 917949, 917950, 917951, 917952, 917953, 917954, 917955, 917956, 917957, 917958, 917959, 917960, 917961, 917962, 917963, 917964, 917965, 917966, 917967, 917968, 917969, 917970, 917971, 917972, 917973, 917974, 917975, 917976, 917977, 917978, 917979, 917980, 917981, 917982, 917983, 917984, 917985, 917986, 917987, 917988, 917989, 917990, 917991, 917992, 917993, 917994, 917995, 917996, 917997, 917998, 917999]);
  99928. /**
  99929. * Check whether a given character is a combining mark or not.
  99930. * @param {number} c The character code to check.
  99931. * @returns {boolean} `true` if the character belongs to the category, one of `Mc`, `Me`, and `Mn`.
  99932. */
  99933. module.exports = function isCombiningCharacter(c) {
  99934. return combiningChars.has(c);
  99935. };
  99936. },{}],421:[function(require,module,exports){
  99937. /**
  99938. * @author Toru Nagashima <https://github.com/mysticatea>
  99939. */
  99940. "use strict";
  99941. /**
  99942. * Check whether a given character is an emoji modifier.
  99943. * @param {number} code The character code to check.
  99944. * @returns {boolean} `true` if the character is an emoji modifier.
  99945. */
  99946. module.exports = function isEmojiModifier(code) {
  99947. return code >= 0x1F3FB && code <= 0x1F3FF;
  99948. };
  99949. },{}],422:[function(require,module,exports){
  99950. /**
  99951. * @author Toru Nagashima <https://github.com/mysticatea>
  99952. */
  99953. "use strict";
  99954. /**
  99955. * Check whether a given character is a regional indicator symbol.
  99956. * @param {number} code The character code to check.
  99957. * @returns {boolean} `true` if the character is a regional indicator symbol.
  99958. */
  99959. module.exports = function isRegionalIndicatorSymbol(code) {
  99960. return code >= 0x1F1E6 && code <= 0x1F1FF;
  99961. };
  99962. },{}],423:[function(require,module,exports){
  99963. /**
  99964. * @author Toru Nagashima <https://github.com/mysticatea>
  99965. */
  99966. "use strict";
  99967. /**
  99968. * Check whether given two characters are a surrogate pair.
  99969. * @param {number} lead The code of the lead character.
  99970. * @param {number} tail The code of the tail character.
  99971. * @returns {boolean} `true` if the character pair is a surrogate pair.
  99972. */
  99973. module.exports = function isSurrogatePair(lead, tail) {
  99974. return lead >= 0xD800 && lead < 0xDC00 && tail >= 0xDC00 && tail < 0xE000;
  99975. };
  99976. },{}]},{},[122])(122)
  99977. });