resources_js_pages_home_Index_vue.js 625KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860
  1. (self["webpackChunk"] = self["webpackChunk"] || []).push([["resources_js_pages_home_Index_vue"],{
  2. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppMessage.vue?vue&type=script&setup=true&lang=js":
  3. /*!***************************************************************************************************************************************************************************************************************!*\
  4. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppMessage.vue?vue&type=script&setup=true&lang=js ***!
  5. \***************************************************************************************************************************************************************************************************************/
  6. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  7. "use strict";
  8. __webpack_require__.r(__webpack_exports__);
  9. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  11. /* harmony export */ });
  12. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  13. /* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
  14. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  15. setup: function setup(__props, _ref) {
  16. var expose = _ref.expose;
  17. expose();
  18. var flashMessage = (0,vue__WEBPACK_IMPORTED_MODULE_0__.computed)(function () {
  19. return (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.usePage)().props.value.flash;
  20. });
  21. var messageDisplay = (0,vue__WEBPACK_IMPORTED_MODULE_0__.ref)({});
  22. var onClose = function onClose() {
  23. (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.usePage)().props.value.errors = {};
  24. (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.usePage)().props.value.flash.success = null;
  25. (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.usePage)().props.value.flash.error = null;
  26. messageDisplay.value = {
  27. display: 'none'
  28. };
  29. };
  30. (0,vue__WEBPACK_IMPORTED_MODULE_0__.watch)(flashMessage, function () {
  31. messageDisplay.value = {
  32. display: ''
  33. };
  34. }, {
  35. deep: true
  36. });
  37. var __returned__ = {
  38. flashMessage: flashMessage,
  39. messageDisplay: messageDisplay,
  40. onClose: onClose,
  41. ref: vue__WEBPACK_IMPORTED_MODULE_0__.ref,
  42. watch: vue__WEBPACK_IMPORTED_MODULE_0__.watch,
  43. computed: vue__WEBPACK_IMPORTED_MODULE_0__.computed,
  44. usePage: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.usePage
  45. };
  46. Object.defineProperty(__returned__, '__isScriptSetup', {
  47. enumerable: false,
  48. value: true
  49. });
  50. return __returned__;
  51. }
  52. });
  53. /***/ }),
  54. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSidebar.vue?vue&type=script&setup=true&lang=js":
  55. /*!***************************************************************************************************************************************************************************************************************!*\
  56. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSidebar.vue?vue&type=script&setup=true&lang=js ***!
  57. \***************************************************************************************************************************************************************************************************************/
  58. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  59. "use strict";
  60. __webpack_require__.r(__webpack_exports__);
  61. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  62. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  63. /* harmony export */ });
  64. /* harmony import */ var _components_AppSubSidebar_vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/components/AppSubSidebar.vue */ "./resources/js/components/AppSubSidebar.vue");
  65. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  66. props: {
  67. model: Array
  68. },
  69. emits: ['menuitem-click'],
  70. setup: function setup(__props, _ref) {
  71. var expose = _ref.expose,
  72. emits = _ref.emit;
  73. expose();
  74. var onKeyDown = function onKeyDown(event) {
  75. var nodeElement = event.target;
  76. if (event.code === 'Enter' || event.code === 'Space') {
  77. nodeElement.click();
  78. event.preventDefault();
  79. }
  80. };
  81. var onMenuItemClick = function onMenuItemClick(event) {
  82. emits('menuitem-click', event);
  83. };
  84. var __returned__ = {
  85. emits: emits,
  86. onKeyDown: onKeyDown,
  87. onMenuItemClick: onMenuItemClick,
  88. AppSubSidebar: _components_AppSubSidebar_vue__WEBPACK_IMPORTED_MODULE_0__["default"]
  89. };
  90. Object.defineProperty(__returned__, '__isScriptSetup', {
  91. enumerable: false,
  92. value: true
  93. });
  94. return __returned__;
  95. }
  96. });
  97. /***/ }),
  98. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSubSidebar.vue?vue&type=script&setup=true&lang=js":
  99. /*!******************************************************************************************************************************************************************************************************************!*\
  100. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSubSidebar.vue?vue&type=script&setup=true&lang=js ***!
  101. \******************************************************************************************************************************************************************************************************************/
  102. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  103. "use strict";
  104. __webpack_require__.r(__webpack_exports__);
  105. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  106. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  107. /* harmony export */ });
  108. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  109. /* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
  110. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  111. props: {
  112. items: Array,
  113. root: {
  114. type: Boolean,
  115. "default": false
  116. }
  117. },
  118. emits: ['menuitem-click'],
  119. setup: function setup(__props, _ref) {
  120. var expose = _ref.expose,
  121. emits = _ref.emit;
  122. expose();
  123. var activeIndex = (0,vue__WEBPACK_IMPORTED_MODULE_0__.ref)(null);
  124. var onMenuItemClick = function onMenuItemClick(event, item, index) {
  125. if (item.disabled) {
  126. event.preventDefault();
  127. return;
  128. }
  129. if (!item.to && !item.url) {
  130. event.preventDefault();
  131. }
  132. if (item.command) {
  133. item.command({
  134. originalEvent: event,
  135. item: item
  136. });
  137. }
  138. activeIndex.value = index === activeIndex.value ? null : index;
  139. emits('menuitem-click', {
  140. originalEvent: event,
  141. item: item
  142. });
  143. };
  144. var visible = function visible(item) {
  145. return typeof item.visible === 'function' ? item.visible() : item.visible !== false;
  146. };
  147. var __returned__ = {
  148. emits: emits,
  149. activeIndex: activeIndex,
  150. onMenuItemClick: onMenuItemClick,
  151. visible: visible,
  152. ref: vue__WEBPACK_IMPORTED_MODULE_0__.ref,
  153. Link: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.Link
  154. };
  155. Object.defineProperty(__returned__, '__isScriptSetup', {
  156. enumerable: false,
  157. value: true
  158. });
  159. return __returned__;
  160. }
  161. });
  162. /***/ }),
  163. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppTopBar.vue?vue&type=script&setup=true&lang=js":
  164. /*!**************************************************************************************************************************************************************************************************************!*\
  165. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppTopBar.vue?vue&type=script&setup=true&lang=js ***!
  166. \**************************************************************************************************************************************************************************************************************/
  167. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  168. "use strict";
  169. __webpack_require__.r(__webpack_exports__);
  170. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  171. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  172. /* harmony export */ });
  173. /* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
  174. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  175. emits: ['menu-toggle'],
  176. setup: function setup(__props, _ref) {
  177. var expose = _ref.expose;
  178. expose();
  179. var __returned__ = {
  180. Link: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_0__.Link
  181. };
  182. Object.defineProperty(__returned__, '__isScriptSetup', {
  183. enumerable: false,
  184. value: true
  185. });
  186. return __returned__;
  187. }
  188. });
  189. /***/ }),
  190. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/layouts/AppLayout.vue?vue&type=script&setup=true&lang=js":
  191. /*!***********************************************************************************************************************************************************************************************************!*\
  192. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/layouts/AppLayout.vue?vue&type=script&setup=true&lang=js ***!
  193. \***********************************************************************************************************************************************************************************************************/
  194. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  195. "use strict";
  196. __webpack_require__.r(__webpack_exports__);
  197. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  198. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  199. /* harmony export */ });
  200. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  201. /* harmony import */ var _components_AppTopBar_vue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/components/AppTopBar.vue */ "./resources/js/components/AppTopBar.vue");
  202. /* harmony import */ var _components_AppSidebar_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/components/AppSidebar.vue */ "./resources/js/components/AppSidebar.vue");
  203. /* harmony import */ var _components_AppFooter_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/components/AppFooter.vue */ "./resources/js/components/AppFooter.vue");
  204. /* harmony import */ var _components_AppMessage_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/AppMessage.vue */ "./resources/js/components/AppMessage.vue");
  205. /* harmony import */ var _utils_menu__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/utils/menu */ "./resources/js/utils/menu.js");
  206. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  207. setup: function setup(__props, _ref) {
  208. var expose = _ref.expose;
  209. expose();
  210. var mobileMenuActive = (0,vue__WEBPACK_IMPORTED_MODULE_0__.ref)(false);
  211. var staticMenuInactive = (0,vue__WEBPACK_IMPORTED_MODULE_0__.ref)(false);
  212. var menuClick = (0,vue__WEBPACK_IMPORTED_MODULE_0__.ref)(false);
  213. var isDesktop = function isDesktop() {
  214. return window.innerWidth >= 992;
  215. };
  216. var addClass = function addClass(element, className) {
  217. if (element.classList) element.classList.add(className);else element.className += ' ' + className;
  218. };
  219. var removeClass = function removeClass(element, className) {
  220. if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
  221. };
  222. (0,vue__WEBPACK_IMPORTED_MODULE_0__.onBeforeUpdate)(function () {
  223. if (mobileMenuActive.value) {
  224. addClass(document.body, 'body-overflow-hidden');
  225. } else {
  226. removeClass(document.body, 'body-overflow-hidden');
  227. }
  228. });
  229. var containerClass = (0,vue__WEBPACK_IMPORTED_MODULE_0__.computed)(function () {
  230. return ['layout-wrapper', 'layout-static', {
  231. 'layout-static-sidebar-inactive': staticMenuInactive.value,
  232. 'layout-mobile-sidebar-active': mobileMenuActive.value
  233. }];
  234. });
  235. var onWrapperClick = function onWrapperClick() {
  236. if (!menuClick.value) {
  237. mobileMenuActive.value = false;
  238. }
  239. menuClick.value = false;
  240. };
  241. var onMenuToggle = function onMenuToggle(event) {
  242. menuClick.value = true;
  243. if (isDesktop()) {
  244. staticMenuInactive.value = !staticMenuInactive.value;
  245. } else {
  246. mobileMenuActive.value = !mobileMenuActive.value;
  247. }
  248. event.preventDefault();
  249. };
  250. var onSidebarClick = function onSidebarClick() {
  251. menuClick.value = true;
  252. };
  253. var onMenuItemClick = function onMenuItemClick(event) {
  254. if (event.item && !event.item.items) {
  255. mobileMenuActive.value = false;
  256. }
  257. };
  258. var __returned__ = {
  259. mobileMenuActive: mobileMenuActive,
  260. staticMenuInactive: staticMenuInactive,
  261. menuClick: menuClick,
  262. isDesktop: isDesktop,
  263. addClass: addClass,
  264. removeClass: removeClass,
  265. containerClass: containerClass,
  266. onWrapperClick: onWrapperClick,
  267. onMenuToggle: onMenuToggle,
  268. onSidebarClick: onSidebarClick,
  269. onMenuItemClick: onMenuItemClick,
  270. ref: vue__WEBPACK_IMPORTED_MODULE_0__.ref,
  271. computed: vue__WEBPACK_IMPORTED_MODULE_0__.computed,
  272. onBeforeUpdate: vue__WEBPACK_IMPORTED_MODULE_0__.onBeforeUpdate,
  273. AppTopBar: _components_AppTopBar_vue__WEBPACK_IMPORTED_MODULE_1__["default"],
  274. AppSidebar: _components_AppSidebar_vue__WEBPACK_IMPORTED_MODULE_2__["default"],
  275. AppFooter: _components_AppFooter_vue__WEBPACK_IMPORTED_MODULE_3__["default"],
  276. AppMessage: _components_AppMessage_vue__WEBPACK_IMPORTED_MODULE_4__["default"],
  277. menu: _utils_menu__WEBPACK_IMPORTED_MODULE_5__["default"]
  278. };
  279. Object.defineProperty(__returned__, '__isScriptSetup', {
  280. enumerable: false,
  281. value: true
  282. });
  283. return __returned__;
  284. }
  285. });
  286. /***/ }),
  287. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/pages/home/Index.vue?vue&type=script&setup=true&lang=js":
  288. /*!**********************************************************************************************************************************************************************************************************!*\
  289. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/pages/home/Index.vue?vue&type=script&setup=true&lang=js ***!
  290. \**********************************************************************************************************************************************************************************************************/
  291. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  292. "use strict";
  293. __webpack_require__.r(__webpack_exports__);
  294. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  295. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  296. /* harmony export */ });
  297. /* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
  298. /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  299. /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
  300. /* harmony import */ var _layouts_AppLayout_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/layouts/AppLayout.vue */ "./resources/js/layouts/AppLayout.vue");
  301. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  302. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  303. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  304. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  305. props: {
  306. cardStatistics: Array,
  307. barStatistics: Array,
  308. barHorizontalStatistics: Array
  309. },
  310. setup: function setup(__props, _ref) {
  311. var expose = _ref.expose;
  312. expose();
  313. var colors = ['#349dcf', '#00b2da', '#00c7dd', '#1fdbdb', '#57eed3', '#88ffc9', '#96ed9a', '#a8d96c', '#bbc242', '#cda91d'];
  314. var barChart = function barChart(chartData) {
  315. var colors = ['#349dcf', '#a8d96c'];
  316. var data = {
  317. datasets: []
  318. };
  319. var id = 0;
  320. for (var key in chartData) {
  321. data.datasets.push({
  322. label: key,
  323. backgroundColor: colors[id],
  324. data: chartData[key]
  325. });
  326. id++;
  327. }
  328. return data;
  329. };
  330. var barChartOption = {
  331. maintainAspectRatio: false,
  332. datasetFill: false
  333. };
  334. var barHorizontalChart = function barHorizontalChart(chartData) {
  335. var labels = [];
  336. var data = [];
  337. var _iterator = _createForOfIteratorHelper(chartData),
  338. _step;
  339. try {
  340. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  341. var obj = _step.value;
  342. labels.push([obj.label1, obj.label2]);
  343. data.push(obj.data);
  344. }
  345. } catch (err) {
  346. _iterator.e(err);
  347. } finally {
  348. _iterator.f();
  349. }
  350. return {
  351. labels: labels,
  352. datasets: [{
  353. data: data,
  354. backgroundColor: colors
  355. }]
  356. };
  357. };
  358. var barHorizontalChartOption = {
  359. maintainAspectRatio: false,
  360. datasetFill: false,
  361. indexAxis: 'y',
  362. plugins: {
  363. legend: {
  364. display: false
  365. }
  366. }
  367. };
  368. var pieChart = function pieChart(chartData) {
  369. var labels = [];
  370. var data = [];
  371. for (var key in chartData) {
  372. labels.push(key);
  373. data.push(chartData[key]);
  374. }
  375. return {
  376. labels: labels,
  377. datasets: [{
  378. data: data,
  379. backgroundColor: colors
  380. }]
  381. };
  382. };
  383. var pieChartOption = {
  384. maintainAspectRatio: false,
  385. datasetFill: false
  386. };
  387. var __returned__ = {
  388. colors: colors,
  389. barChart: barChart,
  390. barChartOption: barChartOption,
  391. barHorizontalChart: barHorizontalChart,
  392. barHorizontalChartOption: barHorizontalChartOption,
  393. pieChart: pieChart,
  394. pieChartOption: pieChartOption,
  395. Head: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_0__.Head,
  396. includes: lodash__WEBPACK_IMPORTED_MODULE_1__.includes,
  397. AppLayout: _layouts_AppLayout_vue__WEBPACK_IMPORTED_MODULE_2__["default"]
  398. };
  399. Object.defineProperty(__returned__, '__isScriptSetup', {
  400. enumerable: false,
  401. value: true
  402. });
  403. return __returned__;
  404. }
  405. });
  406. /***/ }),
  407. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppFooter.vue?vue&type=template&id=4ab6097e":
  408. /*!*******************************************************************************************************************************************************************************************************************************************************************************!*\
  409. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppFooter.vue?vue&type=template&id=4ab6097e ***!
  410. \*******************************************************************************************************************************************************************************************************************************************************************************/
  411. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  412. "use strict";
  413. __webpack_require__.r(__webpack_exports__);
  414. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  415. /* harmony export */ "render": () => (/* binding */ render)
  416. /* harmony export */ });
  417. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  418. var _hoisted_1 = {
  419. "class": "layout-footer"
  420. };
  421. var _hoisted_2 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Developed by ");
  422. var _hoisted_3 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("a", {
  423. href: "https://dijitalcode.com",
  424. target: "_blank",
  425. "class": "font-medium ml-2"
  426. }, "DijitalCODE", -1
  427. /* HOISTED */
  428. );
  429. var _hoisted_4 = [_hoisted_2, _hoisted_3];
  430. function render(_ctx, _cache) {
  431. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_1, _hoisted_4);
  432. }
  433. /***/ }),
  434. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppMessage.vue?vue&type=template&id=07159051":
  435. /*!********************************************************************************************************************************************************************************************************************************************************************************!*\
  436. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppMessage.vue?vue&type=template&id=07159051 ***!
  437. \********************************************************************************************************************************************************************************************************************************************************************************/
  438. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  439. "use strict";
  440. __webpack_require__.r(__webpack_exports__);
  441. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  442. /* harmony export */ "render": () => (/* binding */ render)
  443. /* harmony export */ });
  444. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  445. var _hoisted_1 = {
  446. "class": "grid"
  447. };
  448. var _hoisted_2 = {
  449. "class": "col-12"
  450. };
  451. var _hoisted_3 = {
  452. key: 0
  453. };
  454. var _hoisted_4 = {
  455. key: 1
  456. };
  457. function render(_ctx, _cache, $props, $setup, $data, $options) {
  458. var _component_Message = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("Message");
  459. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_2, [_ctx.$page.props.flash.success ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(_component_Message, {
  460. key: 0,
  461. severity: "success",
  462. style: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeStyle)($setup.messageDisplay),
  463. onClose: $setup.onClose
  464. }, {
  465. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  466. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)((0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(_ctx.$page.props.flash.success), 1
  467. /* TEXT */
  468. )];
  469. }),
  470. _: 1
  471. /* STABLE */
  472. }, 8
  473. /* PROPS */
  474. , ["style"])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), _ctx.$page.props.flash.error || Object.keys(_ctx.$page.props.errors).length > 0 ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
  475. key: 1
  476. }, [_ctx.$page.props.flash.error ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(_component_Message, {
  477. key: 0,
  478. severity: "error",
  479. style: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeStyle)($setup.messageDisplay),
  480. onClose: $setup.onClose
  481. }, {
  482. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  483. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)((0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(_ctx.$page.props.flash.error), 1
  484. /* TEXT */
  485. )];
  486. }),
  487. _: 1
  488. /* STABLE */
  489. }, 8
  490. /* PROPS */
  491. , ["style"])) : ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(_component_Message, {
  492. key: 1,
  493. severity: "error",
  494. style: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeStyle)($setup.messageDisplay),
  495. onClose: $setup.onClose
  496. }, {
  497. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  498. return [Object.keys(_ctx.$page.props.errors).length === 1 ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_3, "Ditemukan satu error pada form")) : ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_4, "Ditemukan " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(Object.keys(_ctx.$page.props.errors).length) + " error pada form", 1
  499. /* TEXT */
  500. ))];
  501. }),
  502. _: 1
  503. /* STABLE */
  504. }, 8
  505. /* PROPS */
  506. , ["style"]))], 2112
  507. /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
  508. )) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)])]);
  509. }
  510. /***/ }),
  511. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSidebar.vue?vue&type=template&id=22a4e926":
  512. /*!********************************************************************************************************************************************************************************************************************************************************************************!*\
  513. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSidebar.vue?vue&type=template&id=22a4e926 ***!
  514. \********************************************************************************************************************************************************************************************************************************************************************************/
  515. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  516. "use strict";
  517. __webpack_require__.r(__webpack_exports__);
  518. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  519. /* harmony export */ "render": () => (/* binding */ render)
  520. /* harmony export */ });
  521. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  522. var _hoisted_1 = {
  523. "class": "layout-menu-container"
  524. };
  525. function render(_ctx, _cache, $props, $setup, $data, $options) {
  526. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["AppSubSidebar"], {
  527. "class": "layout-menu",
  528. items: $props.model,
  529. root: true,
  530. onKeydown: $setup.onKeyDown,
  531. onMenuitemClick: $setup.onMenuItemClick
  532. }, null, 8
  533. /* PROPS */
  534. , ["items"])]);
  535. }
  536. /***/ }),
  537. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSubSidebar.vue?vue&type=template&id=0addd9bc":
  538. /*!***********************************************************************************************************************************************************************************************************************************************************************************!*\
  539. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSubSidebar.vue?vue&type=template&id=0addd9bc ***!
  540. \***********************************************************************************************************************************************************************************************************************************************************************************/
  541. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  542. "use strict";
  543. __webpack_require__.r(__webpack_exports__);
  544. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  545. /* harmony export */ "render": () => (/* binding */ render)
  546. /* harmony export */ });
  547. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  548. var _hoisted_1 = {
  549. key: 0
  550. };
  551. var _hoisted_2 = ["aria-label"];
  552. var _hoisted_3 = {
  553. key: 0,
  554. "class": "pi pi-fw pi-angle-down menuitem-toggle-icon"
  555. };
  556. var _hoisted_4 = ["href", "target", "aria-label", "onClick"];
  557. var _hoisted_5 = {
  558. key: 0,
  559. "class": "pi pi-fw pi-angle-down menuitem-toggle-icon"
  560. };
  561. function render(_ctx, _cache, $props, $setup, $data, $options) {
  562. var _component_AppSubSidebar = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("AppSubSidebar", true);
  563. var _component_Badge = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("Badge");
  564. var _directive_ripple = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveDirective)("ripple");
  565. return $props.items ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("ul", _hoisted_1, [((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.renderList)($props.items, function (item, i) {
  566. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, [$setup.visible(item) && !item.separator ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("li", {
  567. key: item.label || i,
  568. "class": (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)([{
  569. 'layout-menuitem-category': $props.root,
  570. 'active-menuitem': $setup.activeIndex === i && !item.to && !item.disabled
  571. }]),
  572. role: "none"
  573. }, [$props.root ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
  574. key: 0
  575. }, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", {
  576. "class": "layout-menuitem-root-text",
  577. "aria-label": item.label
  578. }, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(item.label), 9
  579. /* TEXT, PROPS */
  580. , _hoisted_2), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_AppSubSidebar, {
  581. items: $setup.visible(item) && item.items,
  582. onMenuitemClick: _cache[0] || (_cache[0] = function ($event) {
  583. return _ctx.$emit('menuitem-click', $event);
  584. })
  585. }, null, 8
  586. /* PROPS */
  587. , ["items"])], 64
  588. /* STABLE_FRAGMENT */
  589. )) : ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
  590. key: 1
  591. }, [item.to ? (0,vue__WEBPACK_IMPORTED_MODULE_0__.withDirectives)(((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)($setup["Link"], {
  592. key: 0,
  593. role: "menuitem",
  594. href: item.to,
  595. "class": (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)([item["class"], 'p-ripple', {
  596. 'p-disabled': item.disabled,
  597. 'router-link-active': _ctx.$page.component.startsWith(item.component) || _ctx.$page.url.startsWith(item.to),
  598. 'router-link-exact-active': _ctx.$page.component.startsWith(item.component) || _ctx.$page.url.startsWith(item.to)
  599. }]),
  600. style: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeStyle)(item.style),
  601. target: item.target,
  602. "aria-label": item.label,
  603. onClick: function onClick($event) {
  604. return $setup.onMenuItemClick($event, item, i);
  605. }
  606. }, {
  607. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  608. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("i", {
  609. "class": (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)(item.icon)
  610. }, null, 2
  611. /* CLASS */
  612. ), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(item.label), 1
  613. /* TEXT */
  614. ), item.items ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("i", _hoisted_3)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), item.badge ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(_component_Badge, {
  615. key: 1,
  616. value: item.badge
  617. }, null, 8
  618. /* PROPS */
  619. , ["value"])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)];
  620. }),
  621. _: 2
  622. /* DYNAMIC */
  623. }, 1032
  624. /* PROPS, DYNAMIC_SLOTS */
  625. , ["href", "class", "style", "target", "aria-label", "onClick"])), [[_directive_ripple]]) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), !item.to ? (0,vue__WEBPACK_IMPORTED_MODULE_0__.withDirectives)(((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("a", {
  626. key: 1,
  627. role: "menuitem",
  628. style: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeStyle)(item.style),
  629. "class": (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)([item["class"], 'p-ripple', {
  630. 'p-disabled': item.disabled
  631. }]),
  632. href: item.url || '#',
  633. target: item.target,
  634. "aria-label": item.label,
  635. onClick: function onClick($event) {
  636. return $setup.onMenuItemClick($event, item, i);
  637. }
  638. }, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("i", {
  639. "class": (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)(item.icon)
  640. }, null, 2
  641. /* CLASS */
  642. ), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(item.label), 1
  643. /* TEXT */
  644. ), item.items ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("i", _hoisted_5)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), item.badge ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(_component_Badge, {
  645. key: 1,
  646. value: item.badge
  647. }, null, 8
  648. /* PROPS */
  649. , ["value"])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)], 14
  650. /* CLASS, STYLE, PROPS */
  651. , _hoisted_4)), [[_directive_ripple]]) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(vue__WEBPACK_IMPORTED_MODULE_0__.Transition, {
  652. name: "layout-submenu-wrapper"
  653. }, {
  654. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  655. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.withDirectives)((0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_AppSubSidebar, {
  656. items: $setup.visible(item) && item.items,
  657. onMenuitemClick: _cache[1] || (_cache[1] = function ($event) {
  658. return _ctx.$emit('menuitem-click', $event);
  659. })
  660. }, null, 8
  661. /* PROPS */
  662. , ["items"]), [[vue__WEBPACK_IMPORTED_MODULE_0__.vShow, $setup.activeIndex === i]])];
  663. }),
  664. _: 2
  665. /* DYNAMIC */
  666. }, 1024
  667. /* DYNAMIC_SLOTS */
  668. )], 64
  669. /* STABLE_FRAGMENT */
  670. ))], 2
  671. /* CLASS */
  672. )) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $setup.visible(item) && item.separator ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("li", {
  673. "class": "p-menu-separator",
  674. role: "separator",
  675. style: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeStyle)(item.style),
  676. key: 'separator' + i
  677. }, null, 4
  678. /* STYLE */
  679. )) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)], 64
  680. /* STABLE_FRAGMENT */
  681. );
  682. }), 256
  683. /* UNKEYED_FRAGMENT */
  684. ))])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true);
  685. }
  686. /***/ }),
  687. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppTopBar.vue?vue&type=template&id=42bf62a4":
  688. /*!*******************************************************************************************************************************************************************************************************************************************************************************!*\
  689. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppTopBar.vue?vue&type=template&id=42bf62a4 ***!
  690. \*******************************************************************************************************************************************************************************************************************************************************************************/
  691. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  692. "use strict";
  693. __webpack_require__.r(__webpack_exports__);
  694. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  695. /* harmony export */ "render": () => (/* binding */ render)
  696. /* harmony export */ });
  697. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  698. var _hoisted_1 = {
  699. "class": "layout-topbar"
  700. };
  701. var _hoisted_2 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("img", {
  702. alt: "Logo",
  703. src: "/images/logo.svg",
  704. "class": "md:mr-3"
  705. }, null, -1
  706. /* HOISTED */
  707. );
  708. var _hoisted_3 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", null, "Parkirin", -1
  709. /* HOISTED */
  710. );
  711. var _hoisted_4 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("i", {
  712. "class": "pi pi-bars"
  713. }, null, -1
  714. /* HOISTED */
  715. );
  716. var _hoisted_5 = [_hoisted_4];
  717. var _hoisted_6 = {
  718. "class": "p-link layout-topbar-menu-button layout-topbar-button"
  719. };
  720. var _hoisted_7 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("i", {
  721. "class": "pi pi-ellipsis-v"
  722. }, null, -1
  723. /* HOISTED */
  724. );
  725. var _hoisted_8 = [_hoisted_7];
  726. var _hoisted_9 = {
  727. "class": "layout-topbar-menu hidden lg:flex origin-top"
  728. };
  729. var _hoisted_10 = {
  730. "class": "align-self-center"
  731. };
  732. var _hoisted_11 = {
  733. "class": "hidden lg:inline"
  734. };
  735. var _hoisted_12 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("i", {
  736. "class": "pi pi-user"
  737. }, null, -1
  738. /* HOISTED */
  739. );
  740. var _hoisted_13 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", null, "Profil Saya", -1
  741. /* HOISTED */
  742. );
  743. var _hoisted_14 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("i", {
  744. "class": "pi pi-sign-out"
  745. }, null, -1
  746. /* HOISTED */
  747. );
  748. var _hoisted_15 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", null, "Sign Out", -1
  749. /* HOISTED */
  750. );
  751. function render(_ctx, _cache, $props, $setup, $data, $options) {
  752. var _directive_styleclass = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveDirective)("styleclass");
  753. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["Link"], {
  754. href: "/",
  755. "class": "layout-topbar-logo"
  756. }, {
  757. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  758. return [_hoisted_2, _hoisted_3];
  759. }),
  760. _: 1
  761. /* STABLE */
  762. }), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("button", {
  763. "class": "p-link layout-menu-button layout-topbar-button",
  764. onClick: _cache[0] || (_cache[0] = function ($event) {
  765. return _ctx.$emit('menu-toggle', $event);
  766. })
  767. }, _hoisted_5), (0,vue__WEBPACK_IMPORTED_MODULE_0__.withDirectives)(((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("button", _hoisted_6, _hoisted_8)), [[_directive_styleclass, {
  768. selector: '@next',
  769. enterClass: 'hidden',
  770. enterActiveClass: 'scalein',
  771. leaveToClass: 'hidden',
  772. leaveActiveClass: 'fadeout',
  773. hideOnOutsideClick: true
  774. }]]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("ul", _hoisted_9, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("li", _hoisted_10, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", _hoisted_11, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(_ctx.$page.props.auth.user.name), 1
  775. /* TEXT */
  776. )]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("li", null, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["Link"], {
  777. href: _ctx.route('users.show', _ctx.$page.props.auth.user.id),
  778. "class": "p-link layout-topbar-button"
  779. }, {
  780. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  781. return [_hoisted_12, _hoisted_13];
  782. }),
  783. _: 1
  784. /* STABLE */
  785. }, 8
  786. /* PROPS */
  787. , ["href"])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("li", null, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["Link"], {
  788. href: _ctx.route('logout'),
  789. as: "button",
  790. method: "post",
  791. "class": "p-link layout-topbar-button"
  792. }, {
  793. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  794. return [_hoisted_14, _hoisted_15];
  795. }),
  796. _: 1
  797. /* STABLE */
  798. }, 8
  799. /* PROPS */
  800. , ["href"])])])]);
  801. }
  802. /***/ }),
  803. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/layouts/AppLayout.vue?vue&type=template&id=2cfb4112":
  804. /*!****************************************************************************************************************************************************************************************************************************************************************************!*\
  805. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/layouts/AppLayout.vue?vue&type=template&id=2cfb4112 ***!
  806. \****************************************************************************************************************************************************************************************************************************************************************************/
  807. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  808. "use strict";
  809. __webpack_require__.r(__webpack_exports__);
  810. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  811. /* harmony export */ "render": () => (/* binding */ render)
  812. /* harmony export */ });
  813. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  814. var _hoisted_1 = {
  815. "class": "layout-main-container"
  816. };
  817. var _hoisted_2 = {
  818. "class": "layout-main"
  819. };
  820. var _hoisted_3 = {
  821. key: 0,
  822. "class": "layout-mask p-component-overlay"
  823. };
  824. function render(_ctx, _cache, $props, $setup, $data, $options) {
  825. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", {
  826. "class": (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)($setup.containerClass),
  827. onClick: $setup.onWrapperClick
  828. }, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["AppTopBar"], {
  829. onMenuToggle: $setup.onMenuToggle
  830. }), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", {
  831. "class": "layout-sidebar",
  832. onClick: $setup.onSidebarClick
  833. }, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["AppSidebar"], {
  834. model: $setup.menu[_ctx.$page.props.auth.user.role_id],
  835. onMenuitemClick: $setup.onMenuItemClick
  836. }, null, 8
  837. /* PROPS */
  838. , ["model"])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_2, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["AppMessage"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.renderSlot)(_ctx.$slots, "default")]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["AppFooter"])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(vue__WEBPACK_IMPORTED_MODULE_0__.Transition, {
  839. name: "layout-mask"
  840. }, {
  841. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  842. return [$setup.mobileMenuActive ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_3)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)];
  843. }),
  844. _: 1
  845. /* STABLE */
  846. })], 2
  847. /* CLASS */
  848. );
  849. }
  850. /***/ }),
  851. /***/ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/pages/home/Index.vue?vue&type=template&id=9329f6aa":
  852. /*!***************************************************************************************************************************************************************************************************************************************************************************!*\
  853. !*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/pages/home/Index.vue?vue&type=template&id=9329f6aa ***!
  854. \***************************************************************************************************************************************************************************************************************************************************************************/
  855. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  856. "use strict";
  857. __webpack_require__.r(__webpack_exports__);
  858. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  859. /* harmony export */ "render": () => (/* binding */ render)
  860. /* harmony export */ });
  861. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
  862. var _hoisted_1 = {
  863. "class": "grid"
  864. };
  865. var _hoisted_2 = {
  866. key: 0,
  867. "class": "col-12 md:col-4 xl:col-3"
  868. };
  869. var _hoisted_3 = {
  870. "class": "flex justify-content-between mb-3"
  871. };
  872. var _hoisted_4 = {
  873. "class": "block text-500 font-medium mb-3"
  874. };
  875. var _hoisted_5 = {
  876. key: 0,
  877. "class": "text-900 font-medium text-xl"
  878. };
  879. var _hoisted_6 = {
  880. "class": "flex align-items-center justify-content-center bg-orange-100 border-round",
  881. style: {
  882. "width": "2.5rem",
  883. "height": "2.5rem"
  884. }
  885. };
  886. var _hoisted_7 = {
  887. "class": "text-green-500 font-medium"
  888. };
  889. var _hoisted_8 = {
  890. "class": "text-500"
  891. };
  892. var _hoisted_9 = {
  893. "class": "grid"
  894. };
  895. var _hoisted_10 = {
  896. key: 0,
  897. "class": "col-12 md:col-6"
  898. };
  899. var _hoisted_11 = {
  900. "class": "flex flex-column"
  901. };
  902. var _hoisted_12 = {
  903. key: 0,
  904. "class": "text-base font-normal"
  905. };
  906. function render(_ctx, _cache, $props, $setup, $data, $options) {
  907. var _component_Card = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("Card");
  908. var _component_Chart = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("Chart");
  909. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)($setup["AppLayout"], null, {
  910. "default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  911. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["Head"], {
  912. title: "Dashboard"
  913. }), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_1, [((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.renderList)($props.cardStatistics, function (cardStatistic) {
  914. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, [$setup.includes(cardStatistic.roleId, _ctx.$page.props.auth.user.role_id) ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_2, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_Card, {
  915. "class": "h-full"
  916. }, {
  917. content: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  918. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_3, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", null, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", _hoisted_4, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(cardStatistic.title), 1
  919. /* TEXT */
  920. ), cardStatistic.value ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_5, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(cardStatistic.value), 1
  921. /* TEXT */
  922. )) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_6, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("i", {
  923. "class": (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)(["text-orange-500 text-xl", cardStatistic.icon])
  924. }, null, 2
  925. /* CLASS */
  926. )])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", _hoisted_7, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(cardStatistic.amount), 1
  927. /* TEXT */
  928. ), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", _hoisted_8, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(' ' + cardStatistic.amountLabel), 1
  929. /* TEXT */
  930. )];
  931. }),
  932. _: 2
  933. /* DYNAMIC */
  934. }, 1024
  935. /* DYNAMIC_SLOTS */
  936. )])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)], 64
  937. /* STABLE_FRAGMENT */
  938. );
  939. }), 256
  940. /* UNKEYED_FRAGMENT */
  941. ))]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_9, [((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.renderList)($props.barStatistics, function (barStatistic) {
  942. return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, [$setup.includes(barStatistic.roleId, _ctx.$page.props.auth.user.role_id) ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("div", _hoisted_10, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_Card, null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.createSlots)({
  943. title: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  944. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_11, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(barStatistic.title), 1
  945. /* TEXT */
  946. ), barStatistic.description ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)("span", _hoisted_12, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(barStatistic.description), 1
  947. /* TEXT */
  948. )) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)])];
  949. }),
  950. _: 2
  951. /* DYNAMIC */
  952. }, [Object.keys(barStatistic.data).length ? {
  953. name: "content",
  954. fn: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
  955. return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_Chart, {
  956. type: "bar",
  957. width: 600,
  958. height: 300,
  959. data: $setup.barChart(barStatistic.data),
  960. options: $setup.barChartOption
  961. }, null, 8
  962. /* PROPS */
  963. , ["data"])];
  964. })
  965. } : undefined]), 1024
  966. /* DYNAMIC_SLOTS */
  967. )])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)], 64
  968. /* STABLE_FRAGMENT */
  969. );
  970. }), 256
  971. /* UNKEYED_FRAGMENT */
  972. )), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(" <div v-for=\"barHorizontalStatistic in barHorizontalStatistics\" class=\"col-12 md:col-6\">\n <Card>\n <template #title>\n <div class=\"flex flex-column\">\n <span>{{ barHorizontalStatistic.title }}</span>\n <span v-if=\"barHorizontalStatistic.description\" class=\"text-base font-normal\">{{\n barHorizontalStatistic.description\n }}</span>\n </div>\n </template>\n <template #content>\n <Chart\n type=\"bar\"\n :width=\"600\"\n :height=\"300\"\n :data=\"barHorizontalChart(barHorizontalStatistic.data)\"\n :options=\"barHorizontalChartOption\"\n />\n </template>\n </Card>\n </div> "), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(" <div v-for=\"pieStatistic in pieStatistics\" class=\"col-12 md:col-6\">\n <Card>\n <template #title>\n <div class=\"flex flex-column\">\n <span>{{ pieStatistic.title }}</span>\n <span v-if=\"pieStatistic.description\" class=\"text-base font-normal\">{{ pieStatistic.description }}</span>\n </div>\n </template>\n <template #content>\n <Chart\n type=\"pie\"\n :width=\"600\"\n :height=\"300\"\n :data=\"pieChart(pieStatistic.data)\"\n :options=\"pieChartOption\"\n />\n </template>\n </Card>\n </div> ")])];
  973. }),
  974. _: 1
  975. /* STABLE */
  976. });
  977. }
  978. /***/ }),
  979. /***/ "./resources/js/utils/menu.js":
  980. /*!************************************!*\
  981. !*** ./resources/js/utils/menu.js ***!
  982. \************************************/
  983. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  984. "use strict";
  985. __webpack_require__.r(__webpack_exports__);
  986. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  987. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  988. /* harmony export */ });
  989. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  990. // Admin
  991. 1: [{
  992. label: 'Home',
  993. items: [{
  994. label: 'Dashboard',
  995. icon: 'pi pi-home',
  996. to: '/dashboards',
  997. component: 'home/Index'
  998. }]
  999. }, {
  1000. label: 'Master',
  1001. items: [{
  1002. label: 'User',
  1003. icon: 'pi pi-user',
  1004. to: '/users',
  1005. component: 'user/Index'
  1006. }]
  1007. }],
  1008. // Supervisor
  1009. 2: [{
  1010. label: 'Home',
  1011. items: [{
  1012. label: 'Dashboard',
  1013. icon: 'pi pi-home',
  1014. to: '/dashboards',
  1015. component: 'home/Index'
  1016. }]
  1017. }, {
  1018. label: 'Menu',
  1019. items: [{
  1020. label: 'Pengeluaran',
  1021. icon: 'pi pi-wallet',
  1022. to: '/expenses',
  1023. component: 'expense/Index'
  1024. }, {
  1025. label: 'Laporan',
  1026. icon: 'pi pi-book',
  1027. items: [{
  1028. label: 'Mutasi',
  1029. icon: 'pi pi-circle',
  1030. to: '/reports/mutations',
  1031. component: 'mutation/Report'
  1032. }]
  1033. }]
  1034. }, {
  1035. label: 'Master',
  1036. items: [{
  1037. label: 'Jenis Kendaraan',
  1038. icon: 'pi pi-car',
  1039. to: '/type-vehicles',
  1040. component: 'typevehicle/Index'
  1041. }, {
  1042. label: 'Jenis Member',
  1043. icon: 'pi pi-id-card',
  1044. to: '/type-members',
  1045. component: 'typemember/Index'
  1046. }]
  1047. }, {
  1048. label: 'Pengaturan',
  1049. items: [{
  1050. label: 'Tarif Parkir',
  1051. icon: 'pi pi-car',
  1052. to: '/parking-fees/create',
  1053. component: 'parkingfee/Create'
  1054. }]
  1055. }],
  1056. // Operator
  1057. 3: [{
  1058. label: 'Home',
  1059. items: [{
  1060. label: 'Dashboard',
  1061. icon: 'pi pi-home',
  1062. to: '/dashboards',
  1063. component: 'home/Index'
  1064. }]
  1065. }, {
  1066. label: 'Menu',
  1067. items: [{
  1068. label: 'Pengeluaran',
  1069. icon: 'pi pi-wallet',
  1070. to: '/expenses',
  1071. component: 'expense/Index'
  1072. }, {
  1073. label: 'Member',
  1074. icon: 'pi pi-id-card',
  1075. to: '/members',
  1076. component: 'member/Index'
  1077. }, {
  1078. label: 'Top Up',
  1079. icon: 'pi pi-car',
  1080. to: '/top-ups',
  1081. component: 'topup/Index'
  1082. }]
  1083. }]
  1084. });
  1085. /***/ }),
  1086. /***/ "./node_modules/lodash/lodash.js":
  1087. /*!***************************************!*\
  1088. !*** ./node_modules/lodash/lodash.js ***!
  1089. \***************************************/
  1090. /***/ (function(module, exports, __webpack_require__) {
  1091. /* module decorator */ module = __webpack_require__.nmd(module);
  1092. var __WEBPACK_AMD_DEFINE_RESULT__;/**
  1093. * @license
  1094. * Lodash <https://lodash.com/>
  1095. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  1096. * Released under MIT license <https://lodash.com/license>
  1097. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1098. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1099. */
  1100. ;(function() {
  1101. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  1102. var undefined;
  1103. /** Used as the semantic version number. */
  1104. var VERSION = '4.17.21';
  1105. /** Used as the size to enable large array optimizations. */
  1106. var LARGE_ARRAY_SIZE = 200;
  1107. /** Error message constants. */
  1108. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  1109. FUNC_ERROR_TEXT = 'Expected a function',
  1110. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  1111. /** Used to stand-in for `undefined` hash values. */
  1112. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1113. /** Used as the maximum memoize cache size. */
  1114. var MAX_MEMOIZE_SIZE = 500;
  1115. /** Used as the internal argument placeholder. */
  1116. var PLACEHOLDER = '__lodash_placeholder__';
  1117. /** Used to compose bitmasks for cloning. */
  1118. var CLONE_DEEP_FLAG = 1,
  1119. CLONE_FLAT_FLAG = 2,
  1120. CLONE_SYMBOLS_FLAG = 4;
  1121. /** Used to compose bitmasks for value comparisons. */
  1122. var COMPARE_PARTIAL_FLAG = 1,
  1123. COMPARE_UNORDERED_FLAG = 2;
  1124. /** Used to compose bitmasks for function metadata. */
  1125. var WRAP_BIND_FLAG = 1,
  1126. WRAP_BIND_KEY_FLAG = 2,
  1127. WRAP_CURRY_BOUND_FLAG = 4,
  1128. WRAP_CURRY_FLAG = 8,
  1129. WRAP_CURRY_RIGHT_FLAG = 16,
  1130. WRAP_PARTIAL_FLAG = 32,
  1131. WRAP_PARTIAL_RIGHT_FLAG = 64,
  1132. WRAP_ARY_FLAG = 128,
  1133. WRAP_REARG_FLAG = 256,
  1134. WRAP_FLIP_FLAG = 512;
  1135. /** Used as default options for `_.truncate`. */
  1136. var DEFAULT_TRUNC_LENGTH = 30,
  1137. DEFAULT_TRUNC_OMISSION = '...';
  1138. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  1139. var HOT_COUNT = 800,
  1140. HOT_SPAN = 16;
  1141. /** Used to indicate the type of lazy iteratees. */
  1142. var LAZY_FILTER_FLAG = 1,
  1143. LAZY_MAP_FLAG = 2,
  1144. LAZY_WHILE_FLAG = 3;
  1145. /** Used as references for various `Number` constants. */
  1146. var INFINITY = 1 / 0,
  1147. MAX_SAFE_INTEGER = 9007199254740991,
  1148. MAX_INTEGER = 1.7976931348623157e+308,
  1149. NAN = 0 / 0;
  1150. /** Used as references for the maximum length and index of an array. */
  1151. var MAX_ARRAY_LENGTH = 4294967295,
  1152. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  1153. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  1154. /** Used to associate wrap methods with their bit flags. */
  1155. var wrapFlags = [
  1156. ['ary', WRAP_ARY_FLAG],
  1157. ['bind', WRAP_BIND_FLAG],
  1158. ['bindKey', WRAP_BIND_KEY_FLAG],
  1159. ['curry', WRAP_CURRY_FLAG],
  1160. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  1161. ['flip', WRAP_FLIP_FLAG],
  1162. ['partial', WRAP_PARTIAL_FLAG],
  1163. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  1164. ['rearg', WRAP_REARG_FLAG]
  1165. ];
  1166. /** `Object#toString` result references. */
  1167. var argsTag = '[object Arguments]',
  1168. arrayTag = '[object Array]',
  1169. asyncTag = '[object AsyncFunction]',
  1170. boolTag = '[object Boolean]',
  1171. dateTag = '[object Date]',
  1172. domExcTag = '[object DOMException]',
  1173. errorTag = '[object Error]',
  1174. funcTag = '[object Function]',
  1175. genTag = '[object GeneratorFunction]',
  1176. mapTag = '[object Map]',
  1177. numberTag = '[object Number]',
  1178. nullTag = '[object Null]',
  1179. objectTag = '[object Object]',
  1180. promiseTag = '[object Promise]',
  1181. proxyTag = '[object Proxy]',
  1182. regexpTag = '[object RegExp]',
  1183. setTag = '[object Set]',
  1184. stringTag = '[object String]',
  1185. symbolTag = '[object Symbol]',
  1186. undefinedTag = '[object Undefined]',
  1187. weakMapTag = '[object WeakMap]',
  1188. weakSetTag = '[object WeakSet]';
  1189. var arrayBufferTag = '[object ArrayBuffer]',
  1190. dataViewTag = '[object DataView]',
  1191. float32Tag = '[object Float32Array]',
  1192. float64Tag = '[object Float64Array]',
  1193. int8Tag = '[object Int8Array]',
  1194. int16Tag = '[object Int16Array]',
  1195. int32Tag = '[object Int32Array]',
  1196. uint8Tag = '[object Uint8Array]',
  1197. uint8ClampedTag = '[object Uint8ClampedArray]',
  1198. uint16Tag = '[object Uint16Array]',
  1199. uint32Tag = '[object Uint32Array]';
  1200. /** Used to match empty string literals in compiled template source. */
  1201. var reEmptyStringLeading = /\b__p \+= '';/g,
  1202. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  1203. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  1204. /** Used to match HTML entities and HTML characters. */
  1205. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  1206. reUnescapedHtml = /[&<>"']/g,
  1207. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  1208. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  1209. /** Used to match template delimiters. */
  1210. var reEscape = /<%-([\s\S]+?)%>/g,
  1211. reEvaluate = /<%([\s\S]+?)%>/g,
  1212. reInterpolate = /<%=([\s\S]+?)%>/g;
  1213. /** Used to match property names within property paths. */
  1214. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  1215. reIsPlainProp = /^\w*$/,
  1216. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1217. /**
  1218. * Used to match `RegExp`
  1219. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1220. */
  1221. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  1222. reHasRegExpChar = RegExp(reRegExpChar.source);
  1223. /** Used to match leading whitespace. */
  1224. var reTrimStart = /^\s+/;
  1225. /** Used to match a single whitespace character. */
  1226. var reWhitespace = /\s/;
  1227. /** Used to match wrap detail comments. */
  1228. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  1229. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  1230. reSplitDetails = /,? & /;
  1231. /** Used to match words composed of alphanumeric characters. */
  1232. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  1233. /**
  1234. * Used to validate the `validate` option in `_.template` variable.
  1235. *
  1236. * Forbids characters which could potentially change the meaning of the function argument definition:
  1237. * - "()," (modification of function parameters)
  1238. * - "=" (default value)
  1239. * - "[]{}" (destructuring of function parameters)
  1240. * - "/" (beginning of a comment)
  1241. * - whitespace
  1242. */
  1243. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  1244. /** Used to match backslashes in property paths. */
  1245. var reEscapeChar = /\\(\\)?/g;
  1246. /**
  1247. * Used to match
  1248. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  1249. */
  1250. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  1251. /** Used to match `RegExp` flags from their coerced string values. */
  1252. var reFlags = /\w*$/;
  1253. /** Used to detect bad signed hexadecimal string values. */
  1254. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1255. /** Used to detect binary string values. */
  1256. var reIsBinary = /^0b[01]+$/i;
  1257. /** Used to detect host constructors (Safari). */
  1258. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1259. /** Used to detect octal string values. */
  1260. var reIsOctal = /^0o[0-7]+$/i;
  1261. /** Used to detect unsigned integer values. */
  1262. var reIsUint = /^(?:0|[1-9]\d*)$/;
  1263. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  1264. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  1265. /** Used to ensure capturing order of template delimiters. */
  1266. var reNoMatch = /($^)/;
  1267. /** Used to match unescaped characters in compiled string literals. */
  1268. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  1269. /** Used to compose unicode character classes. */
  1270. var rsAstralRange = '\\ud800-\\udfff',
  1271. rsComboMarksRange = '\\u0300-\\u036f',
  1272. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  1273. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  1274. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  1275. rsDingbatRange = '\\u2700-\\u27bf',
  1276. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  1277. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  1278. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  1279. rsPunctuationRange = '\\u2000-\\u206f',
  1280. 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',
  1281. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1282. rsVarRange = '\\ufe0e\\ufe0f',
  1283. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1284. /** Used to compose unicode capture groups. */
  1285. var rsApos = "['\u2019]",
  1286. rsAstral = '[' + rsAstralRange + ']',
  1287. rsBreak = '[' + rsBreakRange + ']',
  1288. rsCombo = '[' + rsComboRange + ']',
  1289. rsDigits = '\\d+',
  1290. rsDingbat = '[' + rsDingbatRange + ']',
  1291. rsLower = '[' + rsLowerRange + ']',
  1292. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1293. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1294. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1295. rsNonAstral = '[^' + rsAstralRange + ']',
  1296. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1297. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1298. rsUpper = '[' + rsUpperRange + ']',
  1299. rsZWJ = '\\u200d';
  1300. /** Used to compose unicode regexes. */
  1301. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  1302. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  1303. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1304. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1305. reOptMod = rsModifier + '?',
  1306. rsOptVar = '[' + rsVarRange + ']?',
  1307. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1308. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  1309. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  1310. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1311. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1312. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1313. /** Used to match apostrophes. */
  1314. var reApos = RegExp(rsApos, 'g');
  1315. /**
  1316. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  1317. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  1318. */
  1319. var reComboMark = RegExp(rsCombo, 'g');
  1320. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  1321. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  1322. /** Used to match complex or compound words. */
  1323. var reUnicodeWord = RegExp([
  1324. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  1325. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  1326. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  1327. rsUpper + '+' + rsOptContrUpper,
  1328. rsOrdUpper,
  1329. rsOrdLower,
  1330. rsDigits,
  1331. rsEmoji
  1332. ].join('|'), 'g');
  1333. /** 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/). */
  1334. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  1335. /** Used to detect strings that need a more robust regexp to match words. */
  1336. 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 ]/;
  1337. /** Used to assign default `context` object properties. */
  1338. var contextProps = [
  1339. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  1340. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  1341. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  1342. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  1343. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  1344. ];
  1345. /** Used to make template sourceURLs easier to identify. */
  1346. var templateCounter = -1;
  1347. /** Used to identify `toStringTag` values of typed arrays. */
  1348. var typedArrayTags = {};
  1349. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1350. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1351. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1352. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1353. typedArrayTags[uint32Tag] = true;
  1354. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1355. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1356. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1357. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1358. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1359. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1360. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1361. typedArrayTags[weakMapTag] = false;
  1362. /** Used to identify `toStringTag` values supported by `_.clone`. */
  1363. var cloneableTags = {};
  1364. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1365. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  1366. cloneableTags[boolTag] = cloneableTags[dateTag] =
  1367. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  1368. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  1369. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  1370. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1371. cloneableTags[regexpTag] = cloneableTags[setTag] =
  1372. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  1373. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1374. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1375. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1376. cloneableTags[weakMapTag] = false;
  1377. /** Used to map Latin Unicode letters to basic Latin letters. */
  1378. var deburredLetters = {
  1379. // Latin-1 Supplement block.
  1380. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  1381. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  1382. '\xc7': 'C', '\xe7': 'c',
  1383. '\xd0': 'D', '\xf0': 'd',
  1384. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  1385. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  1386. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  1387. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  1388. '\xd1': 'N', '\xf1': 'n',
  1389. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  1390. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  1391. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  1392. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  1393. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  1394. '\xc6': 'Ae', '\xe6': 'ae',
  1395. '\xde': 'Th', '\xfe': 'th',
  1396. '\xdf': 'ss',
  1397. // Latin Extended-A block.
  1398. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  1399. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  1400. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  1401. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  1402. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  1403. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  1404. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  1405. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  1406. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  1407. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  1408. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  1409. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  1410. '\u0134': 'J', '\u0135': 'j',
  1411. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  1412. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  1413. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  1414. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  1415. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  1416. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  1417. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  1418. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  1419. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  1420. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  1421. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  1422. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  1423. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  1424. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  1425. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  1426. '\u0174': 'W', '\u0175': 'w',
  1427. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  1428. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  1429. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  1430. '\u0132': 'IJ', '\u0133': 'ij',
  1431. '\u0152': 'Oe', '\u0153': 'oe',
  1432. '\u0149': "'n", '\u017f': 's'
  1433. };
  1434. /** Used to map characters to HTML entities. */
  1435. var htmlEscapes = {
  1436. '&': '&amp;',
  1437. '<': '&lt;',
  1438. '>': '&gt;',
  1439. '"': '&quot;',
  1440. "'": '&#39;'
  1441. };
  1442. /** Used to map HTML entities to characters. */
  1443. var htmlUnescapes = {
  1444. '&amp;': '&',
  1445. '&lt;': '<',
  1446. '&gt;': '>',
  1447. '&quot;': '"',
  1448. '&#39;': "'"
  1449. };
  1450. /** Used to escape characters for inclusion in compiled string literals. */
  1451. var stringEscapes = {
  1452. '\\': '\\',
  1453. "'": "'",
  1454. '\n': 'n',
  1455. '\r': 'r',
  1456. '\u2028': 'u2028',
  1457. '\u2029': 'u2029'
  1458. };
  1459. /** Built-in method references without a dependency on `root`. */
  1460. var freeParseFloat = parseFloat,
  1461. freeParseInt = parseInt;
  1462. /** Detect free variable `global` from Node.js. */
  1463. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  1464. /** Detect free variable `self`. */
  1465. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1466. /** Used as a reference to the global object. */
  1467. var root = freeGlobal || freeSelf || Function('return this')();
  1468. /** Detect free variable `exports`. */
  1469. var freeExports = true && exports && !exports.nodeType && exports;
  1470. /** Detect free variable `module`. */
  1471. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  1472. /** Detect the popular CommonJS extension `module.exports`. */
  1473. var moduleExports = freeModule && freeModule.exports === freeExports;
  1474. /** Detect free variable `process` from Node.js. */
  1475. var freeProcess = moduleExports && freeGlobal.process;
  1476. /** Used to access faster Node.js helpers. */
  1477. var nodeUtil = (function() {
  1478. try {
  1479. // Use `util.types` for Node.js 10+.
  1480. var types = freeModule && freeModule.require && freeModule.require('util').types;
  1481. if (types) {
  1482. return types;
  1483. }
  1484. // Legacy `process.binding('util')` for Node.js < 10.
  1485. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  1486. } catch (e) {}
  1487. }());
  1488. /* Node.js helper references. */
  1489. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  1490. nodeIsDate = nodeUtil && nodeUtil.isDate,
  1491. nodeIsMap = nodeUtil && nodeUtil.isMap,
  1492. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  1493. nodeIsSet = nodeUtil && nodeUtil.isSet,
  1494. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  1495. /*--------------------------------------------------------------------------*/
  1496. /**
  1497. * A faster alternative to `Function#apply`, this function invokes `func`
  1498. * with the `this` binding of `thisArg` and the arguments of `args`.
  1499. *
  1500. * @private
  1501. * @param {Function} func The function to invoke.
  1502. * @param {*} thisArg The `this` binding of `func`.
  1503. * @param {Array} args The arguments to invoke `func` with.
  1504. * @returns {*} Returns the result of `func`.
  1505. */
  1506. function apply(func, thisArg, args) {
  1507. switch (args.length) {
  1508. case 0: return func.call(thisArg);
  1509. case 1: return func.call(thisArg, args[0]);
  1510. case 2: return func.call(thisArg, args[0], args[1]);
  1511. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  1512. }
  1513. return func.apply(thisArg, args);
  1514. }
  1515. /**
  1516. * A specialized version of `baseAggregator` for arrays.
  1517. *
  1518. * @private
  1519. * @param {Array} [array] The array to iterate over.
  1520. * @param {Function} setter The function to set `accumulator` values.
  1521. * @param {Function} iteratee The iteratee to transform keys.
  1522. * @param {Object} accumulator The initial aggregated object.
  1523. * @returns {Function} Returns `accumulator`.
  1524. */
  1525. function arrayAggregator(array, setter, iteratee, accumulator) {
  1526. var index = -1,
  1527. length = array == null ? 0 : array.length;
  1528. while (++index < length) {
  1529. var value = array[index];
  1530. setter(accumulator, value, iteratee(value), array);
  1531. }
  1532. return accumulator;
  1533. }
  1534. /**
  1535. * A specialized version of `_.forEach` for arrays without support for
  1536. * iteratee shorthands.
  1537. *
  1538. * @private
  1539. * @param {Array} [array] The array to iterate over.
  1540. * @param {Function} iteratee The function invoked per iteration.
  1541. * @returns {Array} Returns `array`.
  1542. */
  1543. function arrayEach(array, iteratee) {
  1544. var index = -1,
  1545. length = array == null ? 0 : array.length;
  1546. while (++index < length) {
  1547. if (iteratee(array[index], index, array) === false) {
  1548. break;
  1549. }
  1550. }
  1551. return array;
  1552. }
  1553. /**
  1554. * A specialized version of `_.forEachRight` for arrays without support for
  1555. * iteratee shorthands.
  1556. *
  1557. * @private
  1558. * @param {Array} [array] The array to iterate over.
  1559. * @param {Function} iteratee The function invoked per iteration.
  1560. * @returns {Array} Returns `array`.
  1561. */
  1562. function arrayEachRight(array, iteratee) {
  1563. var length = array == null ? 0 : array.length;
  1564. while (length--) {
  1565. if (iteratee(array[length], length, array) === false) {
  1566. break;
  1567. }
  1568. }
  1569. return array;
  1570. }
  1571. /**
  1572. * A specialized version of `_.every` for arrays without support for
  1573. * iteratee shorthands.
  1574. *
  1575. * @private
  1576. * @param {Array} [array] The array to iterate over.
  1577. * @param {Function} predicate The function invoked per iteration.
  1578. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  1579. * else `false`.
  1580. */
  1581. function arrayEvery(array, predicate) {
  1582. var index = -1,
  1583. length = array == null ? 0 : array.length;
  1584. while (++index < length) {
  1585. if (!predicate(array[index], index, array)) {
  1586. return false;
  1587. }
  1588. }
  1589. return true;
  1590. }
  1591. /**
  1592. * A specialized version of `_.filter` for arrays without support for
  1593. * iteratee shorthands.
  1594. *
  1595. * @private
  1596. * @param {Array} [array] The array to iterate over.
  1597. * @param {Function} predicate The function invoked per iteration.
  1598. * @returns {Array} Returns the new filtered array.
  1599. */
  1600. function arrayFilter(array, predicate) {
  1601. var index = -1,
  1602. length = array == null ? 0 : array.length,
  1603. resIndex = 0,
  1604. result = [];
  1605. while (++index < length) {
  1606. var value = array[index];
  1607. if (predicate(value, index, array)) {
  1608. result[resIndex++] = value;
  1609. }
  1610. }
  1611. return result;
  1612. }
  1613. /**
  1614. * A specialized version of `_.includes` for arrays without support for
  1615. * specifying an index to search from.
  1616. *
  1617. * @private
  1618. * @param {Array} [array] The array to inspect.
  1619. * @param {*} target The value to search for.
  1620. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1621. */
  1622. function arrayIncludes(array, value) {
  1623. var length = array == null ? 0 : array.length;
  1624. return !!length && baseIndexOf(array, value, 0) > -1;
  1625. }
  1626. /**
  1627. * This function is like `arrayIncludes` except that it accepts a comparator.
  1628. *
  1629. * @private
  1630. * @param {Array} [array] The array to inspect.
  1631. * @param {*} target The value to search for.
  1632. * @param {Function} comparator The comparator invoked per element.
  1633. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  1634. */
  1635. function arrayIncludesWith(array, value, comparator) {
  1636. var index = -1,
  1637. length = array == null ? 0 : array.length;
  1638. while (++index < length) {
  1639. if (comparator(value, array[index])) {
  1640. return true;
  1641. }
  1642. }
  1643. return false;
  1644. }
  1645. /**
  1646. * A specialized version of `_.map` for arrays without support for iteratee
  1647. * shorthands.
  1648. *
  1649. * @private
  1650. * @param {Array} [array] The array to iterate over.
  1651. * @param {Function} iteratee The function invoked per iteration.
  1652. * @returns {Array} Returns the new mapped array.
  1653. */
  1654. function arrayMap(array, iteratee) {
  1655. var index = -1,
  1656. length = array == null ? 0 : array.length,
  1657. result = Array(length);
  1658. while (++index < length) {
  1659. result[index] = iteratee(array[index], index, array);
  1660. }
  1661. return result;
  1662. }
  1663. /**
  1664. * Appends the elements of `values` to `array`.
  1665. *
  1666. * @private
  1667. * @param {Array} array The array to modify.
  1668. * @param {Array} values The values to append.
  1669. * @returns {Array} Returns `array`.
  1670. */
  1671. function arrayPush(array, values) {
  1672. var index = -1,
  1673. length = values.length,
  1674. offset = array.length;
  1675. while (++index < length) {
  1676. array[offset + index] = values[index];
  1677. }
  1678. return array;
  1679. }
  1680. /**
  1681. * A specialized version of `_.reduce` for arrays without support for
  1682. * iteratee shorthands.
  1683. *
  1684. * @private
  1685. * @param {Array} [array] The array to iterate over.
  1686. * @param {Function} iteratee The function invoked per iteration.
  1687. * @param {*} [accumulator] The initial value.
  1688. * @param {boolean} [initAccum] Specify using the first element of `array` as
  1689. * the initial value.
  1690. * @returns {*} Returns the accumulated value.
  1691. */
  1692. function arrayReduce(array, iteratee, accumulator, initAccum) {
  1693. var index = -1,
  1694. length = array == null ? 0 : array.length;
  1695. if (initAccum && length) {
  1696. accumulator = array[++index];
  1697. }
  1698. while (++index < length) {
  1699. accumulator = iteratee(accumulator, array[index], index, array);
  1700. }
  1701. return accumulator;
  1702. }
  1703. /**
  1704. * A specialized version of `_.reduceRight` for arrays without support for
  1705. * iteratee shorthands.
  1706. *
  1707. * @private
  1708. * @param {Array} [array] The array to iterate over.
  1709. * @param {Function} iteratee The function invoked per iteration.
  1710. * @param {*} [accumulator] The initial value.
  1711. * @param {boolean} [initAccum] Specify using the last element of `array` as
  1712. * the initial value.
  1713. * @returns {*} Returns the accumulated value.
  1714. */
  1715. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  1716. var length = array == null ? 0 : array.length;
  1717. if (initAccum && length) {
  1718. accumulator = array[--length];
  1719. }
  1720. while (length--) {
  1721. accumulator = iteratee(accumulator, array[length], length, array);
  1722. }
  1723. return accumulator;
  1724. }
  1725. /**
  1726. * A specialized version of `_.some` for arrays without support for iteratee
  1727. * shorthands.
  1728. *
  1729. * @private
  1730. * @param {Array} [array] The array to iterate over.
  1731. * @param {Function} predicate The function invoked per iteration.
  1732. * @returns {boolean} Returns `true` if any element passes the predicate check,
  1733. * else `false`.
  1734. */
  1735. function arraySome(array, predicate) {
  1736. var index = -1,
  1737. length = array == null ? 0 : array.length;
  1738. while (++index < length) {
  1739. if (predicate(array[index], index, array)) {
  1740. return true;
  1741. }
  1742. }
  1743. return false;
  1744. }
  1745. /**
  1746. * Gets the size of an ASCII `string`.
  1747. *
  1748. * @private
  1749. * @param {string} string The string inspect.
  1750. * @returns {number} Returns the string size.
  1751. */
  1752. var asciiSize = baseProperty('length');
  1753. /**
  1754. * Converts an ASCII `string` to an array.
  1755. *
  1756. * @private
  1757. * @param {string} string The string to convert.
  1758. * @returns {Array} Returns the converted array.
  1759. */
  1760. function asciiToArray(string) {
  1761. return string.split('');
  1762. }
  1763. /**
  1764. * Splits an ASCII `string` into an array of its words.
  1765. *
  1766. * @private
  1767. * @param {string} The string to inspect.
  1768. * @returns {Array} Returns the words of `string`.
  1769. */
  1770. function asciiWords(string) {
  1771. return string.match(reAsciiWord) || [];
  1772. }
  1773. /**
  1774. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  1775. * without support for iteratee shorthands, which iterates over `collection`
  1776. * using `eachFunc`.
  1777. *
  1778. * @private
  1779. * @param {Array|Object} collection The collection to inspect.
  1780. * @param {Function} predicate The function invoked per iteration.
  1781. * @param {Function} eachFunc The function to iterate over `collection`.
  1782. * @returns {*} Returns the found element or its key, else `undefined`.
  1783. */
  1784. function baseFindKey(collection, predicate, eachFunc) {
  1785. var result;
  1786. eachFunc(collection, function(value, key, collection) {
  1787. if (predicate(value, key, collection)) {
  1788. result = key;
  1789. return false;
  1790. }
  1791. });
  1792. return result;
  1793. }
  1794. /**
  1795. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  1796. * support for iteratee shorthands.
  1797. *
  1798. * @private
  1799. * @param {Array} array The array to inspect.
  1800. * @param {Function} predicate The function invoked per iteration.
  1801. * @param {number} fromIndex The index to search from.
  1802. * @param {boolean} [fromRight] Specify iterating from right to left.
  1803. * @returns {number} Returns the index of the matched value, else `-1`.
  1804. */
  1805. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  1806. var length = array.length,
  1807. index = fromIndex + (fromRight ? 1 : -1);
  1808. while ((fromRight ? index-- : ++index < length)) {
  1809. if (predicate(array[index], index, array)) {
  1810. return index;
  1811. }
  1812. }
  1813. return -1;
  1814. }
  1815. /**
  1816. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  1817. *
  1818. * @private
  1819. * @param {Array} array The array to inspect.
  1820. * @param {*} value The value to search for.
  1821. * @param {number} fromIndex The index to search from.
  1822. * @returns {number} Returns the index of the matched value, else `-1`.
  1823. */
  1824. function baseIndexOf(array, value, fromIndex) {
  1825. return value === value
  1826. ? strictIndexOf(array, value, fromIndex)
  1827. : baseFindIndex(array, baseIsNaN, fromIndex);
  1828. }
  1829. /**
  1830. * This function is like `baseIndexOf` except that it accepts a comparator.
  1831. *
  1832. * @private
  1833. * @param {Array} array The array to inspect.
  1834. * @param {*} value The value to search for.
  1835. * @param {number} fromIndex The index to search from.
  1836. * @param {Function} comparator The comparator invoked per element.
  1837. * @returns {number} Returns the index of the matched value, else `-1`.
  1838. */
  1839. function baseIndexOfWith(array, value, fromIndex, comparator) {
  1840. var index = fromIndex - 1,
  1841. length = array.length;
  1842. while (++index < length) {
  1843. if (comparator(array[index], value)) {
  1844. return index;
  1845. }
  1846. }
  1847. return -1;
  1848. }
  1849. /**
  1850. * The base implementation of `_.isNaN` without support for number objects.
  1851. *
  1852. * @private
  1853. * @param {*} value The value to check.
  1854. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  1855. */
  1856. function baseIsNaN(value) {
  1857. return value !== value;
  1858. }
  1859. /**
  1860. * The base implementation of `_.mean` and `_.meanBy` without support for
  1861. * iteratee shorthands.
  1862. *
  1863. * @private
  1864. * @param {Array} array The array to iterate over.
  1865. * @param {Function} iteratee The function invoked per iteration.
  1866. * @returns {number} Returns the mean.
  1867. */
  1868. function baseMean(array, iteratee) {
  1869. var length = array == null ? 0 : array.length;
  1870. return length ? (baseSum(array, iteratee) / length) : NAN;
  1871. }
  1872. /**
  1873. * The base implementation of `_.property` without support for deep paths.
  1874. *
  1875. * @private
  1876. * @param {string} key The key of the property to get.
  1877. * @returns {Function} Returns the new accessor function.
  1878. */
  1879. function baseProperty(key) {
  1880. return function(object) {
  1881. return object == null ? undefined : object[key];
  1882. };
  1883. }
  1884. /**
  1885. * The base implementation of `_.propertyOf` without support for deep paths.
  1886. *
  1887. * @private
  1888. * @param {Object} object The object to query.
  1889. * @returns {Function} Returns the new accessor function.
  1890. */
  1891. function basePropertyOf(object) {
  1892. return function(key) {
  1893. return object == null ? undefined : object[key];
  1894. };
  1895. }
  1896. /**
  1897. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  1898. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  1899. *
  1900. * @private
  1901. * @param {Array|Object} collection The collection to iterate over.
  1902. * @param {Function} iteratee The function invoked per iteration.
  1903. * @param {*} accumulator The initial value.
  1904. * @param {boolean} initAccum Specify using the first or last element of
  1905. * `collection` as the initial value.
  1906. * @param {Function} eachFunc The function to iterate over `collection`.
  1907. * @returns {*} Returns the accumulated value.
  1908. */
  1909. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  1910. eachFunc(collection, function(value, index, collection) {
  1911. accumulator = initAccum
  1912. ? (initAccum = false, value)
  1913. : iteratee(accumulator, value, index, collection);
  1914. });
  1915. return accumulator;
  1916. }
  1917. /**
  1918. * The base implementation of `_.sortBy` which uses `comparer` to define the
  1919. * sort order of `array` and replaces criteria objects with their corresponding
  1920. * values.
  1921. *
  1922. * @private
  1923. * @param {Array} array The array to sort.
  1924. * @param {Function} comparer The function to define sort order.
  1925. * @returns {Array} Returns `array`.
  1926. */
  1927. function baseSortBy(array, comparer) {
  1928. var length = array.length;
  1929. array.sort(comparer);
  1930. while (length--) {
  1931. array[length] = array[length].value;
  1932. }
  1933. return array;
  1934. }
  1935. /**
  1936. * The base implementation of `_.sum` and `_.sumBy` without support for
  1937. * iteratee shorthands.
  1938. *
  1939. * @private
  1940. * @param {Array} array The array to iterate over.
  1941. * @param {Function} iteratee The function invoked per iteration.
  1942. * @returns {number} Returns the sum.
  1943. */
  1944. function baseSum(array, iteratee) {
  1945. var result,
  1946. index = -1,
  1947. length = array.length;
  1948. while (++index < length) {
  1949. var current = iteratee(array[index]);
  1950. if (current !== undefined) {
  1951. result = result === undefined ? current : (result + current);
  1952. }
  1953. }
  1954. return result;
  1955. }
  1956. /**
  1957. * The base implementation of `_.times` without support for iteratee shorthands
  1958. * or max array length checks.
  1959. *
  1960. * @private
  1961. * @param {number} n The number of times to invoke `iteratee`.
  1962. * @param {Function} iteratee The function invoked per iteration.
  1963. * @returns {Array} Returns the array of results.
  1964. */
  1965. function baseTimes(n, iteratee) {
  1966. var index = -1,
  1967. result = Array(n);
  1968. while (++index < n) {
  1969. result[index] = iteratee(index);
  1970. }
  1971. return result;
  1972. }
  1973. /**
  1974. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  1975. * of key-value pairs for `object` corresponding to the property names of `props`.
  1976. *
  1977. * @private
  1978. * @param {Object} object The object to query.
  1979. * @param {Array} props The property names to get values for.
  1980. * @returns {Object} Returns the key-value pairs.
  1981. */
  1982. function baseToPairs(object, props) {
  1983. return arrayMap(props, function(key) {
  1984. return [key, object[key]];
  1985. });
  1986. }
  1987. /**
  1988. * The base implementation of `_.trim`.
  1989. *
  1990. * @private
  1991. * @param {string} string The string to trim.
  1992. * @returns {string} Returns the trimmed string.
  1993. */
  1994. function baseTrim(string) {
  1995. return string
  1996. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  1997. : string;
  1998. }
  1999. /**
  2000. * The base implementation of `_.unary` without support for storing metadata.
  2001. *
  2002. * @private
  2003. * @param {Function} func The function to cap arguments for.
  2004. * @returns {Function} Returns the new capped function.
  2005. */
  2006. function baseUnary(func) {
  2007. return function(value) {
  2008. return func(value);
  2009. };
  2010. }
  2011. /**
  2012. * The base implementation of `_.values` and `_.valuesIn` which creates an
  2013. * array of `object` property values corresponding to the property names
  2014. * of `props`.
  2015. *
  2016. * @private
  2017. * @param {Object} object The object to query.
  2018. * @param {Array} props The property names to get values for.
  2019. * @returns {Object} Returns the array of property values.
  2020. */
  2021. function baseValues(object, props) {
  2022. return arrayMap(props, function(key) {
  2023. return object[key];
  2024. });
  2025. }
  2026. /**
  2027. * Checks if a `cache` value for `key` exists.
  2028. *
  2029. * @private
  2030. * @param {Object} cache The cache to query.
  2031. * @param {string} key The key of the entry to check.
  2032. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2033. */
  2034. function cacheHas(cache, key) {
  2035. return cache.has(key);
  2036. }
  2037. /**
  2038. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  2039. * that is not found in the character symbols.
  2040. *
  2041. * @private
  2042. * @param {Array} strSymbols The string symbols to inspect.
  2043. * @param {Array} chrSymbols The character symbols to find.
  2044. * @returns {number} Returns the index of the first unmatched string symbol.
  2045. */
  2046. function charsStartIndex(strSymbols, chrSymbols) {
  2047. var index = -1,
  2048. length = strSymbols.length;
  2049. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2050. return index;
  2051. }
  2052. /**
  2053. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  2054. * that is not found in the character symbols.
  2055. *
  2056. * @private
  2057. * @param {Array} strSymbols The string symbols to inspect.
  2058. * @param {Array} chrSymbols The character symbols to find.
  2059. * @returns {number} Returns the index of the last unmatched string symbol.
  2060. */
  2061. function charsEndIndex(strSymbols, chrSymbols) {
  2062. var index = strSymbols.length;
  2063. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2064. return index;
  2065. }
  2066. /**
  2067. * Gets the number of `placeholder` occurrences in `array`.
  2068. *
  2069. * @private
  2070. * @param {Array} array The array to inspect.
  2071. * @param {*} placeholder The placeholder to search for.
  2072. * @returns {number} Returns the placeholder count.
  2073. */
  2074. function countHolders(array, placeholder) {
  2075. var length = array.length,
  2076. result = 0;
  2077. while (length--) {
  2078. if (array[length] === placeholder) {
  2079. ++result;
  2080. }
  2081. }
  2082. return result;
  2083. }
  2084. /**
  2085. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  2086. * letters to basic Latin letters.
  2087. *
  2088. * @private
  2089. * @param {string} letter The matched letter to deburr.
  2090. * @returns {string} Returns the deburred letter.
  2091. */
  2092. var deburrLetter = basePropertyOf(deburredLetters);
  2093. /**
  2094. * Used by `_.escape` to convert characters to HTML entities.
  2095. *
  2096. * @private
  2097. * @param {string} chr The matched character to escape.
  2098. * @returns {string} Returns the escaped character.
  2099. */
  2100. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  2101. /**
  2102. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  2103. *
  2104. * @private
  2105. * @param {string} chr The matched character to escape.
  2106. * @returns {string} Returns the escaped character.
  2107. */
  2108. function escapeStringChar(chr) {
  2109. return '\\' + stringEscapes[chr];
  2110. }
  2111. /**
  2112. * Gets the value at `key` of `object`.
  2113. *
  2114. * @private
  2115. * @param {Object} [object] The object to query.
  2116. * @param {string} key The key of the property to get.
  2117. * @returns {*} Returns the property value.
  2118. */
  2119. function getValue(object, key) {
  2120. return object == null ? undefined : object[key];
  2121. }
  2122. /**
  2123. * Checks if `string` contains Unicode symbols.
  2124. *
  2125. * @private
  2126. * @param {string} string The string to inspect.
  2127. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  2128. */
  2129. function hasUnicode(string) {
  2130. return reHasUnicode.test(string);
  2131. }
  2132. /**
  2133. * Checks if `string` contains a word composed of Unicode symbols.
  2134. *
  2135. * @private
  2136. * @param {string} string The string to inspect.
  2137. * @returns {boolean} Returns `true` if a word is found, else `false`.
  2138. */
  2139. function hasUnicodeWord(string) {
  2140. return reHasUnicodeWord.test(string);
  2141. }
  2142. /**
  2143. * Converts `iterator` to an array.
  2144. *
  2145. * @private
  2146. * @param {Object} iterator The iterator to convert.
  2147. * @returns {Array} Returns the converted array.
  2148. */
  2149. function iteratorToArray(iterator) {
  2150. var data,
  2151. result = [];
  2152. while (!(data = iterator.next()).done) {
  2153. result.push(data.value);
  2154. }
  2155. return result;
  2156. }
  2157. /**
  2158. * Converts `map` to its key-value pairs.
  2159. *
  2160. * @private
  2161. * @param {Object} map The map to convert.
  2162. * @returns {Array} Returns the key-value pairs.
  2163. */
  2164. function mapToArray(map) {
  2165. var index = -1,
  2166. result = Array(map.size);
  2167. map.forEach(function(value, key) {
  2168. result[++index] = [key, value];
  2169. });
  2170. return result;
  2171. }
  2172. /**
  2173. * Creates a unary function that invokes `func` with its argument transformed.
  2174. *
  2175. * @private
  2176. * @param {Function} func The function to wrap.
  2177. * @param {Function} transform The argument transform.
  2178. * @returns {Function} Returns the new function.
  2179. */
  2180. function overArg(func, transform) {
  2181. return function(arg) {
  2182. return func(transform(arg));
  2183. };
  2184. }
  2185. /**
  2186. * Replaces all `placeholder` elements in `array` with an internal placeholder
  2187. * and returns an array of their indexes.
  2188. *
  2189. * @private
  2190. * @param {Array} array The array to modify.
  2191. * @param {*} placeholder The placeholder to replace.
  2192. * @returns {Array} Returns the new array of placeholder indexes.
  2193. */
  2194. function replaceHolders(array, placeholder) {
  2195. var index = -1,
  2196. length = array.length,
  2197. resIndex = 0,
  2198. result = [];
  2199. while (++index < length) {
  2200. var value = array[index];
  2201. if (value === placeholder || value === PLACEHOLDER) {
  2202. array[index] = PLACEHOLDER;
  2203. result[resIndex++] = index;
  2204. }
  2205. }
  2206. return result;
  2207. }
  2208. /**
  2209. * Converts `set` to an array of its values.
  2210. *
  2211. * @private
  2212. * @param {Object} set The set to convert.
  2213. * @returns {Array} Returns the values.
  2214. */
  2215. function setToArray(set) {
  2216. var index = -1,
  2217. result = Array(set.size);
  2218. set.forEach(function(value) {
  2219. result[++index] = value;
  2220. });
  2221. return result;
  2222. }
  2223. /**
  2224. * Converts `set` to its value-value pairs.
  2225. *
  2226. * @private
  2227. * @param {Object} set The set to convert.
  2228. * @returns {Array} Returns the value-value pairs.
  2229. */
  2230. function setToPairs(set) {
  2231. var index = -1,
  2232. result = Array(set.size);
  2233. set.forEach(function(value) {
  2234. result[++index] = [value, value];
  2235. });
  2236. return result;
  2237. }
  2238. /**
  2239. * A specialized version of `_.indexOf` which performs strict equality
  2240. * comparisons of values, i.e. `===`.
  2241. *
  2242. * @private
  2243. * @param {Array} array The array to inspect.
  2244. * @param {*} value The value to search for.
  2245. * @param {number} fromIndex The index to search from.
  2246. * @returns {number} Returns the index of the matched value, else `-1`.
  2247. */
  2248. function strictIndexOf(array, value, fromIndex) {
  2249. var index = fromIndex - 1,
  2250. length = array.length;
  2251. while (++index < length) {
  2252. if (array[index] === value) {
  2253. return index;
  2254. }
  2255. }
  2256. return -1;
  2257. }
  2258. /**
  2259. * A specialized version of `_.lastIndexOf` which performs strict equality
  2260. * comparisons of values, i.e. `===`.
  2261. *
  2262. * @private
  2263. * @param {Array} array The array to inspect.
  2264. * @param {*} value The value to search for.
  2265. * @param {number} fromIndex The index to search from.
  2266. * @returns {number} Returns the index of the matched value, else `-1`.
  2267. */
  2268. function strictLastIndexOf(array, value, fromIndex) {
  2269. var index = fromIndex + 1;
  2270. while (index--) {
  2271. if (array[index] === value) {
  2272. return index;
  2273. }
  2274. }
  2275. return index;
  2276. }
  2277. /**
  2278. * Gets the number of symbols in `string`.
  2279. *
  2280. * @private
  2281. * @param {string} string The string to inspect.
  2282. * @returns {number} Returns the string size.
  2283. */
  2284. function stringSize(string) {
  2285. return hasUnicode(string)
  2286. ? unicodeSize(string)
  2287. : asciiSize(string);
  2288. }
  2289. /**
  2290. * Converts `string` to an array.
  2291. *
  2292. * @private
  2293. * @param {string} string The string to convert.
  2294. * @returns {Array} Returns the converted array.
  2295. */
  2296. function stringToArray(string) {
  2297. return hasUnicode(string)
  2298. ? unicodeToArray(string)
  2299. : asciiToArray(string);
  2300. }
  2301. /**
  2302. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  2303. * character of `string`.
  2304. *
  2305. * @private
  2306. * @param {string} string The string to inspect.
  2307. * @returns {number} Returns the index of the last non-whitespace character.
  2308. */
  2309. function trimmedEndIndex(string) {
  2310. var index = string.length;
  2311. while (index-- && reWhitespace.test(string.charAt(index))) {}
  2312. return index;
  2313. }
  2314. /**
  2315. * Used by `_.unescape` to convert HTML entities to characters.
  2316. *
  2317. * @private
  2318. * @param {string} chr The matched character to unescape.
  2319. * @returns {string} Returns the unescaped character.
  2320. */
  2321. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  2322. /**
  2323. * Gets the size of a Unicode `string`.
  2324. *
  2325. * @private
  2326. * @param {string} string The string inspect.
  2327. * @returns {number} Returns the string size.
  2328. */
  2329. function unicodeSize(string) {
  2330. var result = reUnicode.lastIndex = 0;
  2331. while (reUnicode.test(string)) {
  2332. ++result;
  2333. }
  2334. return result;
  2335. }
  2336. /**
  2337. * Converts a Unicode `string` to an array.
  2338. *
  2339. * @private
  2340. * @param {string} string The string to convert.
  2341. * @returns {Array} Returns the converted array.
  2342. */
  2343. function unicodeToArray(string) {
  2344. return string.match(reUnicode) || [];
  2345. }
  2346. /**
  2347. * Splits a Unicode `string` into an array of its words.
  2348. *
  2349. * @private
  2350. * @param {string} The string to inspect.
  2351. * @returns {Array} Returns the words of `string`.
  2352. */
  2353. function unicodeWords(string) {
  2354. return string.match(reUnicodeWord) || [];
  2355. }
  2356. /*--------------------------------------------------------------------------*/
  2357. /**
  2358. * Create a new pristine `lodash` function using the `context` object.
  2359. *
  2360. * @static
  2361. * @memberOf _
  2362. * @since 1.1.0
  2363. * @category Util
  2364. * @param {Object} [context=root] The context object.
  2365. * @returns {Function} Returns a new `lodash` function.
  2366. * @example
  2367. *
  2368. * _.mixin({ 'foo': _.constant('foo') });
  2369. *
  2370. * var lodash = _.runInContext();
  2371. * lodash.mixin({ 'bar': lodash.constant('bar') });
  2372. *
  2373. * _.isFunction(_.foo);
  2374. * // => true
  2375. * _.isFunction(_.bar);
  2376. * // => false
  2377. *
  2378. * lodash.isFunction(lodash.foo);
  2379. * // => false
  2380. * lodash.isFunction(lodash.bar);
  2381. * // => true
  2382. *
  2383. * // Create a suped-up `defer` in Node.js.
  2384. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  2385. */
  2386. var runInContext = (function runInContext(context) {
  2387. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  2388. /** Built-in constructor references. */
  2389. var Array = context.Array,
  2390. Date = context.Date,
  2391. Error = context.Error,
  2392. Function = context.Function,
  2393. Math = context.Math,
  2394. Object = context.Object,
  2395. RegExp = context.RegExp,
  2396. String = context.String,
  2397. TypeError = context.TypeError;
  2398. /** Used for built-in method references. */
  2399. var arrayProto = Array.prototype,
  2400. funcProto = Function.prototype,
  2401. objectProto = Object.prototype;
  2402. /** Used to detect overreaching core-js shims. */
  2403. var coreJsData = context['__core-js_shared__'];
  2404. /** Used to resolve the decompiled source of functions. */
  2405. var funcToString = funcProto.toString;
  2406. /** Used to check objects for own properties. */
  2407. var hasOwnProperty = objectProto.hasOwnProperty;
  2408. /** Used to generate unique IDs. */
  2409. var idCounter = 0;
  2410. /** Used to detect methods masquerading as native. */
  2411. var maskSrcKey = (function() {
  2412. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2413. return uid ? ('Symbol(src)_1.' + uid) : '';
  2414. }());
  2415. /**
  2416. * Used to resolve the
  2417. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2418. * of values.
  2419. */
  2420. var nativeObjectToString = objectProto.toString;
  2421. /** Used to infer the `Object` constructor. */
  2422. var objectCtorString = funcToString.call(Object);
  2423. /** Used to restore the original `_` reference in `_.noConflict`. */
  2424. var oldDash = root._;
  2425. /** Used to detect if a method is native. */
  2426. var reIsNative = RegExp('^' +
  2427. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2428. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2429. );
  2430. /** Built-in value references. */
  2431. var Buffer = moduleExports ? context.Buffer : undefined,
  2432. Symbol = context.Symbol,
  2433. Uint8Array = context.Uint8Array,
  2434. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  2435. getPrototype = overArg(Object.getPrototypeOf, Object),
  2436. objectCreate = Object.create,
  2437. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2438. splice = arrayProto.splice,
  2439. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  2440. symIterator = Symbol ? Symbol.iterator : undefined,
  2441. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  2442. var defineProperty = (function() {
  2443. try {
  2444. var func = getNative(Object, 'defineProperty');
  2445. func({}, '', {});
  2446. return func;
  2447. } catch (e) {}
  2448. }());
  2449. /** Mocked built-ins. */
  2450. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  2451. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  2452. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  2453. /* Built-in method references for those with the same name as other `lodash` methods. */
  2454. var nativeCeil = Math.ceil,
  2455. nativeFloor = Math.floor,
  2456. nativeGetSymbols = Object.getOwnPropertySymbols,
  2457. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  2458. nativeIsFinite = context.isFinite,
  2459. nativeJoin = arrayProto.join,
  2460. nativeKeys = overArg(Object.keys, Object),
  2461. nativeMax = Math.max,
  2462. nativeMin = Math.min,
  2463. nativeNow = Date.now,
  2464. nativeParseInt = context.parseInt,
  2465. nativeRandom = Math.random,
  2466. nativeReverse = arrayProto.reverse;
  2467. /* Built-in method references that are verified to be native. */
  2468. var DataView = getNative(context, 'DataView'),
  2469. Map = getNative(context, 'Map'),
  2470. Promise = getNative(context, 'Promise'),
  2471. Set = getNative(context, 'Set'),
  2472. WeakMap = getNative(context, 'WeakMap'),
  2473. nativeCreate = getNative(Object, 'create');
  2474. /** Used to store function metadata. */
  2475. var metaMap = WeakMap && new WeakMap;
  2476. /** Used to lookup unminified function names. */
  2477. var realNames = {};
  2478. /** Used to detect maps, sets, and weakmaps. */
  2479. var dataViewCtorString = toSource(DataView),
  2480. mapCtorString = toSource(Map),
  2481. promiseCtorString = toSource(Promise),
  2482. setCtorString = toSource(Set),
  2483. weakMapCtorString = toSource(WeakMap);
  2484. /** Used to convert symbols to primitives and strings. */
  2485. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2486. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2487. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2488. /*------------------------------------------------------------------------*/
  2489. /**
  2490. * Creates a `lodash` object which wraps `value` to enable implicit method
  2491. * chain sequences. Methods that operate on and return arrays, collections,
  2492. * and functions can be chained together. Methods that retrieve a single value
  2493. * or may return a primitive value will automatically end the chain sequence
  2494. * and return the unwrapped value. Otherwise, the value must be unwrapped
  2495. * with `_#value`.
  2496. *
  2497. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  2498. * enabled using `_.chain`.
  2499. *
  2500. * The execution of chained methods is lazy, that is, it's deferred until
  2501. * `_#value` is implicitly or explicitly called.
  2502. *
  2503. * Lazy evaluation allows several methods to support shortcut fusion.
  2504. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  2505. * the creation of intermediate arrays and can greatly reduce the number of
  2506. * iteratee executions. Sections of a chain sequence qualify for shortcut
  2507. * fusion if the section is applied to an array and iteratees accept only
  2508. * one argument. The heuristic for whether a section qualifies for shortcut
  2509. * fusion is subject to change.
  2510. *
  2511. * Chaining is supported in custom builds as long as the `_#value` method is
  2512. * directly or indirectly included in the build.
  2513. *
  2514. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  2515. *
  2516. * The wrapper `Array` methods are:
  2517. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  2518. *
  2519. * The wrapper `String` methods are:
  2520. * `replace` and `split`
  2521. *
  2522. * The wrapper methods that support shortcut fusion are:
  2523. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  2524. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  2525. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  2526. *
  2527. * The chainable wrapper methods are:
  2528. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  2529. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  2530. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  2531. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  2532. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  2533. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  2534. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  2535. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  2536. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  2537. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  2538. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  2539. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  2540. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  2541. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  2542. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  2543. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  2544. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  2545. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  2546. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  2547. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  2548. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  2549. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  2550. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  2551. * `zipObject`, `zipObjectDeep`, and `zipWith`
  2552. *
  2553. * The wrapper methods that are **not** chainable by default are:
  2554. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  2555. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  2556. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  2557. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  2558. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  2559. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  2560. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  2561. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  2562. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  2563. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  2564. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  2565. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  2566. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  2567. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  2568. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  2569. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  2570. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  2571. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  2572. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  2573. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  2574. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  2575. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  2576. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  2577. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  2578. * `upperFirst`, `value`, and `words`
  2579. *
  2580. * @name _
  2581. * @constructor
  2582. * @category Seq
  2583. * @param {*} value The value to wrap in a `lodash` instance.
  2584. * @returns {Object} Returns the new `lodash` wrapper instance.
  2585. * @example
  2586. *
  2587. * function square(n) {
  2588. * return n * n;
  2589. * }
  2590. *
  2591. * var wrapped = _([1, 2, 3]);
  2592. *
  2593. * // Returns an unwrapped value.
  2594. * wrapped.reduce(_.add);
  2595. * // => 6
  2596. *
  2597. * // Returns a wrapped value.
  2598. * var squares = wrapped.map(square);
  2599. *
  2600. * _.isArray(squares);
  2601. * // => false
  2602. *
  2603. * _.isArray(squares.value());
  2604. * // => true
  2605. */
  2606. function lodash(value) {
  2607. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  2608. if (value instanceof LodashWrapper) {
  2609. return value;
  2610. }
  2611. if (hasOwnProperty.call(value, '__wrapped__')) {
  2612. return wrapperClone(value);
  2613. }
  2614. }
  2615. return new LodashWrapper(value);
  2616. }
  2617. /**
  2618. * The base implementation of `_.create` without support for assigning
  2619. * properties to the created object.
  2620. *
  2621. * @private
  2622. * @param {Object} proto The object to inherit from.
  2623. * @returns {Object} Returns the new object.
  2624. */
  2625. var baseCreate = (function() {
  2626. function object() {}
  2627. return function(proto) {
  2628. if (!isObject(proto)) {
  2629. return {};
  2630. }
  2631. if (objectCreate) {
  2632. return objectCreate(proto);
  2633. }
  2634. object.prototype = proto;
  2635. var result = new object;
  2636. object.prototype = undefined;
  2637. return result;
  2638. };
  2639. }());
  2640. /**
  2641. * The function whose prototype chain sequence wrappers inherit from.
  2642. *
  2643. * @private
  2644. */
  2645. function baseLodash() {
  2646. // No operation performed.
  2647. }
  2648. /**
  2649. * The base constructor for creating `lodash` wrapper objects.
  2650. *
  2651. * @private
  2652. * @param {*} value The value to wrap.
  2653. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  2654. */
  2655. function LodashWrapper(value, chainAll) {
  2656. this.__wrapped__ = value;
  2657. this.__actions__ = [];
  2658. this.__chain__ = !!chainAll;
  2659. this.__index__ = 0;
  2660. this.__values__ = undefined;
  2661. }
  2662. /**
  2663. * By default, the template delimiters used by lodash are like those in
  2664. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  2665. * following template settings to use alternative delimiters.
  2666. *
  2667. * @static
  2668. * @memberOf _
  2669. * @type {Object}
  2670. */
  2671. lodash.templateSettings = {
  2672. /**
  2673. * Used to detect `data` property values to be HTML-escaped.
  2674. *
  2675. * @memberOf _.templateSettings
  2676. * @type {RegExp}
  2677. */
  2678. 'escape': reEscape,
  2679. /**
  2680. * Used to detect code to be evaluated.
  2681. *
  2682. * @memberOf _.templateSettings
  2683. * @type {RegExp}
  2684. */
  2685. 'evaluate': reEvaluate,
  2686. /**
  2687. * Used to detect `data` property values to inject.
  2688. *
  2689. * @memberOf _.templateSettings
  2690. * @type {RegExp}
  2691. */
  2692. 'interpolate': reInterpolate,
  2693. /**
  2694. * Used to reference the data object in the template text.
  2695. *
  2696. * @memberOf _.templateSettings
  2697. * @type {string}
  2698. */
  2699. 'variable': '',
  2700. /**
  2701. * Used to import variables into the compiled template.
  2702. *
  2703. * @memberOf _.templateSettings
  2704. * @type {Object}
  2705. */
  2706. 'imports': {
  2707. /**
  2708. * A reference to the `lodash` function.
  2709. *
  2710. * @memberOf _.templateSettings.imports
  2711. * @type {Function}
  2712. */
  2713. '_': lodash
  2714. }
  2715. };
  2716. // Ensure wrappers are instances of `baseLodash`.
  2717. lodash.prototype = baseLodash.prototype;
  2718. lodash.prototype.constructor = lodash;
  2719. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  2720. LodashWrapper.prototype.constructor = LodashWrapper;
  2721. /*------------------------------------------------------------------------*/
  2722. /**
  2723. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  2724. *
  2725. * @private
  2726. * @constructor
  2727. * @param {*} value The value to wrap.
  2728. */
  2729. function LazyWrapper(value) {
  2730. this.__wrapped__ = value;
  2731. this.__actions__ = [];
  2732. this.__dir__ = 1;
  2733. this.__filtered__ = false;
  2734. this.__iteratees__ = [];
  2735. this.__takeCount__ = MAX_ARRAY_LENGTH;
  2736. this.__views__ = [];
  2737. }
  2738. /**
  2739. * Creates a clone of the lazy wrapper object.
  2740. *
  2741. * @private
  2742. * @name clone
  2743. * @memberOf LazyWrapper
  2744. * @returns {Object} Returns the cloned `LazyWrapper` object.
  2745. */
  2746. function lazyClone() {
  2747. var result = new LazyWrapper(this.__wrapped__);
  2748. result.__actions__ = copyArray(this.__actions__);
  2749. result.__dir__ = this.__dir__;
  2750. result.__filtered__ = this.__filtered__;
  2751. result.__iteratees__ = copyArray(this.__iteratees__);
  2752. result.__takeCount__ = this.__takeCount__;
  2753. result.__views__ = copyArray(this.__views__);
  2754. return result;
  2755. }
  2756. /**
  2757. * Reverses the direction of lazy iteration.
  2758. *
  2759. * @private
  2760. * @name reverse
  2761. * @memberOf LazyWrapper
  2762. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  2763. */
  2764. function lazyReverse() {
  2765. if (this.__filtered__) {
  2766. var result = new LazyWrapper(this);
  2767. result.__dir__ = -1;
  2768. result.__filtered__ = true;
  2769. } else {
  2770. result = this.clone();
  2771. result.__dir__ *= -1;
  2772. }
  2773. return result;
  2774. }
  2775. /**
  2776. * Extracts the unwrapped value from its lazy wrapper.
  2777. *
  2778. * @private
  2779. * @name value
  2780. * @memberOf LazyWrapper
  2781. * @returns {*} Returns the unwrapped value.
  2782. */
  2783. function lazyValue() {
  2784. var array = this.__wrapped__.value(),
  2785. dir = this.__dir__,
  2786. isArr = isArray(array),
  2787. isRight = dir < 0,
  2788. arrLength = isArr ? array.length : 0,
  2789. view = getView(0, arrLength, this.__views__),
  2790. start = view.start,
  2791. end = view.end,
  2792. length = end - start,
  2793. index = isRight ? end : (start - 1),
  2794. iteratees = this.__iteratees__,
  2795. iterLength = iteratees.length,
  2796. resIndex = 0,
  2797. takeCount = nativeMin(length, this.__takeCount__);
  2798. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  2799. return baseWrapperValue(array, this.__actions__);
  2800. }
  2801. var result = [];
  2802. outer:
  2803. while (length-- && resIndex < takeCount) {
  2804. index += dir;
  2805. var iterIndex = -1,
  2806. value = array[index];
  2807. while (++iterIndex < iterLength) {
  2808. var data = iteratees[iterIndex],
  2809. iteratee = data.iteratee,
  2810. type = data.type,
  2811. computed = iteratee(value);
  2812. if (type == LAZY_MAP_FLAG) {
  2813. value = computed;
  2814. } else if (!computed) {
  2815. if (type == LAZY_FILTER_FLAG) {
  2816. continue outer;
  2817. } else {
  2818. break outer;
  2819. }
  2820. }
  2821. }
  2822. result[resIndex++] = value;
  2823. }
  2824. return result;
  2825. }
  2826. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  2827. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  2828. LazyWrapper.prototype.constructor = LazyWrapper;
  2829. /*------------------------------------------------------------------------*/
  2830. /**
  2831. * Creates a hash object.
  2832. *
  2833. * @private
  2834. * @constructor
  2835. * @param {Array} [entries] The key-value pairs to cache.
  2836. */
  2837. function Hash(entries) {
  2838. var index = -1,
  2839. length = entries == null ? 0 : entries.length;
  2840. this.clear();
  2841. while (++index < length) {
  2842. var entry = entries[index];
  2843. this.set(entry[0], entry[1]);
  2844. }
  2845. }
  2846. /**
  2847. * Removes all key-value entries from the hash.
  2848. *
  2849. * @private
  2850. * @name clear
  2851. * @memberOf Hash
  2852. */
  2853. function hashClear() {
  2854. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2855. this.size = 0;
  2856. }
  2857. /**
  2858. * Removes `key` and its value from the hash.
  2859. *
  2860. * @private
  2861. * @name delete
  2862. * @memberOf Hash
  2863. * @param {Object} hash The hash to modify.
  2864. * @param {string} key The key of the value to remove.
  2865. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2866. */
  2867. function hashDelete(key) {
  2868. var result = this.has(key) && delete this.__data__[key];
  2869. this.size -= result ? 1 : 0;
  2870. return result;
  2871. }
  2872. /**
  2873. * Gets the hash value for `key`.
  2874. *
  2875. * @private
  2876. * @name get
  2877. * @memberOf Hash
  2878. * @param {string} key The key of the value to get.
  2879. * @returns {*} Returns the entry value.
  2880. */
  2881. function hashGet(key) {
  2882. var data = this.__data__;
  2883. if (nativeCreate) {
  2884. var result = data[key];
  2885. return result === HASH_UNDEFINED ? undefined : result;
  2886. }
  2887. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2888. }
  2889. /**
  2890. * Checks if a hash value for `key` exists.
  2891. *
  2892. * @private
  2893. * @name has
  2894. * @memberOf Hash
  2895. * @param {string} key The key of the entry to check.
  2896. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2897. */
  2898. function hashHas(key) {
  2899. var data = this.__data__;
  2900. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  2901. }
  2902. /**
  2903. * Sets the hash `key` to `value`.
  2904. *
  2905. * @private
  2906. * @name set
  2907. * @memberOf Hash
  2908. * @param {string} key The key of the value to set.
  2909. * @param {*} value The value to set.
  2910. * @returns {Object} Returns the hash instance.
  2911. */
  2912. function hashSet(key, value) {
  2913. var data = this.__data__;
  2914. this.size += this.has(key) ? 0 : 1;
  2915. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2916. return this;
  2917. }
  2918. // Add methods to `Hash`.
  2919. Hash.prototype.clear = hashClear;
  2920. Hash.prototype['delete'] = hashDelete;
  2921. Hash.prototype.get = hashGet;
  2922. Hash.prototype.has = hashHas;
  2923. Hash.prototype.set = hashSet;
  2924. /*------------------------------------------------------------------------*/
  2925. /**
  2926. * Creates an list cache object.
  2927. *
  2928. * @private
  2929. * @constructor
  2930. * @param {Array} [entries] The key-value pairs to cache.
  2931. */
  2932. function ListCache(entries) {
  2933. var index = -1,
  2934. length = entries == null ? 0 : entries.length;
  2935. this.clear();
  2936. while (++index < length) {
  2937. var entry = entries[index];
  2938. this.set(entry[0], entry[1]);
  2939. }
  2940. }
  2941. /**
  2942. * Removes all key-value entries from the list cache.
  2943. *
  2944. * @private
  2945. * @name clear
  2946. * @memberOf ListCache
  2947. */
  2948. function listCacheClear() {
  2949. this.__data__ = [];
  2950. this.size = 0;
  2951. }
  2952. /**
  2953. * Removes `key` and its value from the list cache.
  2954. *
  2955. * @private
  2956. * @name delete
  2957. * @memberOf ListCache
  2958. * @param {string} key The key of the value to remove.
  2959. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2960. */
  2961. function listCacheDelete(key) {
  2962. var data = this.__data__,
  2963. index = assocIndexOf(data, key);
  2964. if (index < 0) {
  2965. return false;
  2966. }
  2967. var lastIndex = data.length - 1;
  2968. if (index == lastIndex) {
  2969. data.pop();
  2970. } else {
  2971. splice.call(data, index, 1);
  2972. }
  2973. --this.size;
  2974. return true;
  2975. }
  2976. /**
  2977. * Gets the list cache value for `key`.
  2978. *
  2979. * @private
  2980. * @name get
  2981. * @memberOf ListCache
  2982. * @param {string} key The key of the value to get.
  2983. * @returns {*} Returns the entry value.
  2984. */
  2985. function listCacheGet(key) {
  2986. var data = this.__data__,
  2987. index = assocIndexOf(data, key);
  2988. return index < 0 ? undefined : data[index][1];
  2989. }
  2990. /**
  2991. * Checks if a list cache value for `key` exists.
  2992. *
  2993. * @private
  2994. * @name has
  2995. * @memberOf ListCache
  2996. * @param {string} key The key of the entry to check.
  2997. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2998. */
  2999. function listCacheHas(key) {
  3000. return assocIndexOf(this.__data__, key) > -1;
  3001. }
  3002. /**
  3003. * Sets the list cache `key` to `value`.
  3004. *
  3005. * @private
  3006. * @name set
  3007. * @memberOf ListCache
  3008. * @param {string} key The key of the value to set.
  3009. * @param {*} value The value to set.
  3010. * @returns {Object} Returns the list cache instance.
  3011. */
  3012. function listCacheSet(key, value) {
  3013. var data = this.__data__,
  3014. index = assocIndexOf(data, key);
  3015. if (index < 0) {
  3016. ++this.size;
  3017. data.push([key, value]);
  3018. } else {
  3019. data[index][1] = value;
  3020. }
  3021. return this;
  3022. }
  3023. // Add methods to `ListCache`.
  3024. ListCache.prototype.clear = listCacheClear;
  3025. ListCache.prototype['delete'] = listCacheDelete;
  3026. ListCache.prototype.get = listCacheGet;
  3027. ListCache.prototype.has = listCacheHas;
  3028. ListCache.prototype.set = listCacheSet;
  3029. /*------------------------------------------------------------------------*/
  3030. /**
  3031. * Creates a map cache object to store key-value pairs.
  3032. *
  3033. * @private
  3034. * @constructor
  3035. * @param {Array} [entries] The key-value pairs to cache.
  3036. */
  3037. function MapCache(entries) {
  3038. var index = -1,
  3039. length = entries == null ? 0 : entries.length;
  3040. this.clear();
  3041. while (++index < length) {
  3042. var entry = entries[index];
  3043. this.set(entry[0], entry[1]);
  3044. }
  3045. }
  3046. /**
  3047. * Removes all key-value entries from the map.
  3048. *
  3049. * @private
  3050. * @name clear
  3051. * @memberOf MapCache
  3052. */
  3053. function mapCacheClear() {
  3054. this.size = 0;
  3055. this.__data__ = {
  3056. 'hash': new Hash,
  3057. 'map': new (Map || ListCache),
  3058. 'string': new Hash
  3059. };
  3060. }
  3061. /**
  3062. * Removes `key` and its value from the map.
  3063. *
  3064. * @private
  3065. * @name delete
  3066. * @memberOf MapCache
  3067. * @param {string} key The key of the value to remove.
  3068. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3069. */
  3070. function mapCacheDelete(key) {
  3071. var result = getMapData(this, key)['delete'](key);
  3072. this.size -= result ? 1 : 0;
  3073. return result;
  3074. }
  3075. /**
  3076. * Gets the map value for `key`.
  3077. *
  3078. * @private
  3079. * @name get
  3080. * @memberOf MapCache
  3081. * @param {string} key The key of the value to get.
  3082. * @returns {*} Returns the entry value.
  3083. */
  3084. function mapCacheGet(key) {
  3085. return getMapData(this, key).get(key);
  3086. }
  3087. /**
  3088. * Checks if a map value for `key` exists.
  3089. *
  3090. * @private
  3091. * @name has
  3092. * @memberOf MapCache
  3093. * @param {string} key The key of the entry to check.
  3094. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3095. */
  3096. function mapCacheHas(key) {
  3097. return getMapData(this, key).has(key);
  3098. }
  3099. /**
  3100. * Sets the map `key` to `value`.
  3101. *
  3102. * @private
  3103. * @name set
  3104. * @memberOf MapCache
  3105. * @param {string} key The key of the value to set.
  3106. * @param {*} value The value to set.
  3107. * @returns {Object} Returns the map cache instance.
  3108. */
  3109. function mapCacheSet(key, value) {
  3110. var data = getMapData(this, key),
  3111. size = data.size;
  3112. data.set(key, value);
  3113. this.size += data.size == size ? 0 : 1;
  3114. return this;
  3115. }
  3116. // Add methods to `MapCache`.
  3117. MapCache.prototype.clear = mapCacheClear;
  3118. MapCache.prototype['delete'] = mapCacheDelete;
  3119. MapCache.prototype.get = mapCacheGet;
  3120. MapCache.prototype.has = mapCacheHas;
  3121. MapCache.prototype.set = mapCacheSet;
  3122. /*------------------------------------------------------------------------*/
  3123. /**
  3124. *
  3125. * Creates an array cache object to store unique values.
  3126. *
  3127. * @private
  3128. * @constructor
  3129. * @param {Array} [values] The values to cache.
  3130. */
  3131. function SetCache(values) {
  3132. var index = -1,
  3133. length = values == null ? 0 : values.length;
  3134. this.__data__ = new MapCache;
  3135. while (++index < length) {
  3136. this.add(values[index]);
  3137. }
  3138. }
  3139. /**
  3140. * Adds `value` to the array cache.
  3141. *
  3142. * @private
  3143. * @name add
  3144. * @memberOf SetCache
  3145. * @alias push
  3146. * @param {*} value The value to cache.
  3147. * @returns {Object} Returns the cache instance.
  3148. */
  3149. function setCacheAdd(value) {
  3150. this.__data__.set(value, HASH_UNDEFINED);
  3151. return this;
  3152. }
  3153. /**
  3154. * Checks if `value` is in the array cache.
  3155. *
  3156. * @private
  3157. * @name has
  3158. * @memberOf SetCache
  3159. * @param {*} value The value to search for.
  3160. * @returns {number} Returns `true` if `value` is found, else `false`.
  3161. */
  3162. function setCacheHas(value) {
  3163. return this.__data__.has(value);
  3164. }
  3165. // Add methods to `SetCache`.
  3166. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  3167. SetCache.prototype.has = setCacheHas;
  3168. /*------------------------------------------------------------------------*/
  3169. /**
  3170. * Creates a stack cache object to store key-value pairs.
  3171. *
  3172. * @private
  3173. * @constructor
  3174. * @param {Array} [entries] The key-value pairs to cache.
  3175. */
  3176. function Stack(entries) {
  3177. var data = this.__data__ = new ListCache(entries);
  3178. this.size = data.size;
  3179. }
  3180. /**
  3181. * Removes all key-value entries from the stack.
  3182. *
  3183. * @private
  3184. * @name clear
  3185. * @memberOf Stack
  3186. */
  3187. function stackClear() {
  3188. this.__data__ = new ListCache;
  3189. this.size = 0;
  3190. }
  3191. /**
  3192. * Removes `key` and its value from the stack.
  3193. *
  3194. * @private
  3195. * @name delete
  3196. * @memberOf Stack
  3197. * @param {string} key The key of the value to remove.
  3198. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3199. */
  3200. function stackDelete(key) {
  3201. var data = this.__data__,
  3202. result = data['delete'](key);
  3203. this.size = data.size;
  3204. return result;
  3205. }
  3206. /**
  3207. * Gets the stack value for `key`.
  3208. *
  3209. * @private
  3210. * @name get
  3211. * @memberOf Stack
  3212. * @param {string} key The key of the value to get.
  3213. * @returns {*} Returns the entry value.
  3214. */
  3215. function stackGet(key) {
  3216. return this.__data__.get(key);
  3217. }
  3218. /**
  3219. * Checks if a stack value for `key` exists.
  3220. *
  3221. * @private
  3222. * @name has
  3223. * @memberOf Stack
  3224. * @param {string} key The key of the entry to check.
  3225. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3226. */
  3227. function stackHas(key) {
  3228. return this.__data__.has(key);
  3229. }
  3230. /**
  3231. * Sets the stack `key` to `value`.
  3232. *
  3233. * @private
  3234. * @name set
  3235. * @memberOf Stack
  3236. * @param {string} key The key of the value to set.
  3237. * @param {*} value The value to set.
  3238. * @returns {Object} Returns the stack cache instance.
  3239. */
  3240. function stackSet(key, value) {
  3241. var data = this.__data__;
  3242. if (data instanceof ListCache) {
  3243. var pairs = data.__data__;
  3244. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  3245. pairs.push([key, value]);
  3246. this.size = ++data.size;
  3247. return this;
  3248. }
  3249. data = this.__data__ = new MapCache(pairs);
  3250. }
  3251. data.set(key, value);
  3252. this.size = data.size;
  3253. return this;
  3254. }
  3255. // Add methods to `Stack`.
  3256. Stack.prototype.clear = stackClear;
  3257. Stack.prototype['delete'] = stackDelete;
  3258. Stack.prototype.get = stackGet;
  3259. Stack.prototype.has = stackHas;
  3260. Stack.prototype.set = stackSet;
  3261. /*------------------------------------------------------------------------*/
  3262. /**
  3263. * Creates an array of the enumerable property names of the array-like `value`.
  3264. *
  3265. * @private
  3266. * @param {*} value The value to query.
  3267. * @param {boolean} inherited Specify returning inherited property names.
  3268. * @returns {Array} Returns the array of property names.
  3269. */
  3270. function arrayLikeKeys(value, inherited) {
  3271. var isArr = isArray(value),
  3272. isArg = !isArr && isArguments(value),
  3273. isBuff = !isArr && !isArg && isBuffer(value),
  3274. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  3275. skipIndexes = isArr || isArg || isBuff || isType,
  3276. result = skipIndexes ? baseTimes(value.length, String) : [],
  3277. length = result.length;
  3278. for (var key in value) {
  3279. if ((inherited || hasOwnProperty.call(value, key)) &&
  3280. !(skipIndexes && (
  3281. // Safari 9 has enumerable `arguments.length` in strict mode.
  3282. key == 'length' ||
  3283. // Node.js 0.10 has enumerable non-index properties on buffers.
  3284. (isBuff && (key == 'offset' || key == 'parent')) ||
  3285. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3286. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3287. // Skip index properties.
  3288. isIndex(key, length)
  3289. ))) {
  3290. result.push(key);
  3291. }
  3292. }
  3293. return result;
  3294. }
  3295. /**
  3296. * A specialized version of `_.sample` for arrays.
  3297. *
  3298. * @private
  3299. * @param {Array} array The array to sample.
  3300. * @returns {*} Returns the random element.
  3301. */
  3302. function arraySample(array) {
  3303. var length = array.length;
  3304. return length ? array[baseRandom(0, length - 1)] : undefined;
  3305. }
  3306. /**
  3307. * A specialized version of `_.sampleSize` for arrays.
  3308. *
  3309. * @private
  3310. * @param {Array} array The array to sample.
  3311. * @param {number} n The number of elements to sample.
  3312. * @returns {Array} Returns the random elements.
  3313. */
  3314. function arraySampleSize(array, n) {
  3315. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  3316. }
  3317. /**
  3318. * A specialized version of `_.shuffle` for arrays.
  3319. *
  3320. * @private
  3321. * @param {Array} array The array to shuffle.
  3322. * @returns {Array} Returns the new shuffled array.
  3323. */
  3324. function arrayShuffle(array) {
  3325. return shuffleSelf(copyArray(array));
  3326. }
  3327. /**
  3328. * This function is like `assignValue` except that it doesn't assign
  3329. * `undefined` values.
  3330. *
  3331. * @private
  3332. * @param {Object} object The object to modify.
  3333. * @param {string} key The key of the property to assign.
  3334. * @param {*} value The value to assign.
  3335. */
  3336. function assignMergeValue(object, key, value) {
  3337. if ((value !== undefined && !eq(object[key], value)) ||
  3338. (value === undefined && !(key in object))) {
  3339. baseAssignValue(object, key, value);
  3340. }
  3341. }
  3342. /**
  3343. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  3344. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3345. * for equality comparisons.
  3346. *
  3347. * @private
  3348. * @param {Object} object The object to modify.
  3349. * @param {string} key The key of the property to assign.
  3350. * @param {*} value The value to assign.
  3351. */
  3352. function assignValue(object, key, value) {
  3353. var objValue = object[key];
  3354. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  3355. (value === undefined && !(key in object))) {
  3356. baseAssignValue(object, key, value);
  3357. }
  3358. }
  3359. /**
  3360. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3361. *
  3362. * @private
  3363. * @param {Array} array The array to inspect.
  3364. * @param {*} key The key to search for.
  3365. * @returns {number} Returns the index of the matched value, else `-1`.
  3366. */
  3367. function assocIndexOf(array, key) {
  3368. var length = array.length;
  3369. while (length--) {
  3370. if (eq(array[length][0], key)) {
  3371. return length;
  3372. }
  3373. }
  3374. return -1;
  3375. }
  3376. /**
  3377. * Aggregates elements of `collection` on `accumulator` with keys transformed
  3378. * by `iteratee` and values set by `setter`.
  3379. *
  3380. * @private
  3381. * @param {Array|Object} collection The collection to iterate over.
  3382. * @param {Function} setter The function to set `accumulator` values.
  3383. * @param {Function} iteratee The iteratee to transform keys.
  3384. * @param {Object} accumulator The initial aggregated object.
  3385. * @returns {Function} Returns `accumulator`.
  3386. */
  3387. function baseAggregator(collection, setter, iteratee, accumulator) {
  3388. baseEach(collection, function(value, key, collection) {
  3389. setter(accumulator, value, iteratee(value), collection);
  3390. });
  3391. return accumulator;
  3392. }
  3393. /**
  3394. * The base implementation of `_.assign` without support for multiple sources
  3395. * or `customizer` functions.
  3396. *
  3397. * @private
  3398. * @param {Object} object The destination object.
  3399. * @param {Object} source The source object.
  3400. * @returns {Object} Returns `object`.
  3401. */
  3402. function baseAssign(object, source) {
  3403. return object && copyObject(source, keys(source), object);
  3404. }
  3405. /**
  3406. * The base implementation of `_.assignIn` without support for multiple sources
  3407. * or `customizer` functions.
  3408. *
  3409. * @private
  3410. * @param {Object} object The destination object.
  3411. * @param {Object} source The source object.
  3412. * @returns {Object} Returns `object`.
  3413. */
  3414. function baseAssignIn(object, source) {
  3415. return object && copyObject(source, keysIn(source), object);
  3416. }
  3417. /**
  3418. * The base implementation of `assignValue` and `assignMergeValue` without
  3419. * value checks.
  3420. *
  3421. * @private
  3422. * @param {Object} object The object to modify.
  3423. * @param {string} key The key of the property to assign.
  3424. * @param {*} value The value to assign.
  3425. */
  3426. function baseAssignValue(object, key, value) {
  3427. if (key == '__proto__' && defineProperty) {
  3428. defineProperty(object, key, {
  3429. 'configurable': true,
  3430. 'enumerable': true,
  3431. 'value': value,
  3432. 'writable': true
  3433. });
  3434. } else {
  3435. object[key] = value;
  3436. }
  3437. }
  3438. /**
  3439. * The base implementation of `_.at` without support for individual paths.
  3440. *
  3441. * @private
  3442. * @param {Object} object The object to iterate over.
  3443. * @param {string[]} paths The property paths to pick.
  3444. * @returns {Array} Returns the picked elements.
  3445. */
  3446. function baseAt(object, paths) {
  3447. var index = -1,
  3448. length = paths.length,
  3449. result = Array(length),
  3450. skip = object == null;
  3451. while (++index < length) {
  3452. result[index] = skip ? undefined : get(object, paths[index]);
  3453. }
  3454. return result;
  3455. }
  3456. /**
  3457. * The base implementation of `_.clamp` which doesn't coerce arguments.
  3458. *
  3459. * @private
  3460. * @param {number} number The number to clamp.
  3461. * @param {number} [lower] The lower bound.
  3462. * @param {number} upper The upper bound.
  3463. * @returns {number} Returns the clamped number.
  3464. */
  3465. function baseClamp(number, lower, upper) {
  3466. if (number === number) {
  3467. if (upper !== undefined) {
  3468. number = number <= upper ? number : upper;
  3469. }
  3470. if (lower !== undefined) {
  3471. number = number >= lower ? number : lower;
  3472. }
  3473. }
  3474. return number;
  3475. }
  3476. /**
  3477. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  3478. * traversed objects.
  3479. *
  3480. * @private
  3481. * @param {*} value The value to clone.
  3482. * @param {boolean} bitmask The bitmask flags.
  3483. * 1 - Deep clone
  3484. * 2 - Flatten inherited properties
  3485. * 4 - Clone symbols
  3486. * @param {Function} [customizer] The function to customize cloning.
  3487. * @param {string} [key] The key of `value`.
  3488. * @param {Object} [object] The parent object of `value`.
  3489. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  3490. * @returns {*} Returns the cloned value.
  3491. */
  3492. function baseClone(value, bitmask, customizer, key, object, stack) {
  3493. var result,
  3494. isDeep = bitmask & CLONE_DEEP_FLAG,
  3495. isFlat = bitmask & CLONE_FLAT_FLAG,
  3496. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  3497. if (customizer) {
  3498. result = object ? customizer(value, key, object, stack) : customizer(value);
  3499. }
  3500. if (result !== undefined) {
  3501. return result;
  3502. }
  3503. if (!isObject(value)) {
  3504. return value;
  3505. }
  3506. var isArr = isArray(value);
  3507. if (isArr) {
  3508. result = initCloneArray(value);
  3509. if (!isDeep) {
  3510. return copyArray(value, result);
  3511. }
  3512. } else {
  3513. var tag = getTag(value),
  3514. isFunc = tag == funcTag || tag == genTag;
  3515. if (isBuffer(value)) {
  3516. return cloneBuffer(value, isDeep);
  3517. }
  3518. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  3519. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  3520. if (!isDeep) {
  3521. return isFlat
  3522. ? copySymbolsIn(value, baseAssignIn(result, value))
  3523. : copySymbols(value, baseAssign(result, value));
  3524. }
  3525. } else {
  3526. if (!cloneableTags[tag]) {
  3527. return object ? value : {};
  3528. }
  3529. result = initCloneByTag(value, tag, isDeep);
  3530. }
  3531. }
  3532. // Check for circular references and return its corresponding clone.
  3533. stack || (stack = new Stack);
  3534. var stacked = stack.get(value);
  3535. if (stacked) {
  3536. return stacked;
  3537. }
  3538. stack.set(value, result);
  3539. if (isSet(value)) {
  3540. value.forEach(function(subValue) {
  3541. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  3542. });
  3543. } else if (isMap(value)) {
  3544. value.forEach(function(subValue, key) {
  3545. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  3546. });
  3547. }
  3548. var keysFunc = isFull
  3549. ? (isFlat ? getAllKeysIn : getAllKeys)
  3550. : (isFlat ? keysIn : keys);
  3551. var props = isArr ? undefined : keysFunc(value);
  3552. arrayEach(props || value, function(subValue, key) {
  3553. if (props) {
  3554. key = subValue;
  3555. subValue = value[key];
  3556. }
  3557. // Recursively populate clone (susceptible to call stack limits).
  3558. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  3559. });
  3560. return result;
  3561. }
  3562. /**
  3563. * The base implementation of `_.conforms` which doesn't clone `source`.
  3564. *
  3565. * @private
  3566. * @param {Object} source The object of property predicates to conform to.
  3567. * @returns {Function} Returns the new spec function.
  3568. */
  3569. function baseConforms(source) {
  3570. var props = keys(source);
  3571. return function(object) {
  3572. return baseConformsTo(object, source, props);
  3573. };
  3574. }
  3575. /**
  3576. * The base implementation of `_.conformsTo` which accepts `props` to check.
  3577. *
  3578. * @private
  3579. * @param {Object} object The object to inspect.
  3580. * @param {Object} source The object of property predicates to conform to.
  3581. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  3582. */
  3583. function baseConformsTo(object, source, props) {
  3584. var length = props.length;
  3585. if (object == null) {
  3586. return !length;
  3587. }
  3588. object = Object(object);
  3589. while (length--) {
  3590. var key = props[length],
  3591. predicate = source[key],
  3592. value = object[key];
  3593. if ((value === undefined && !(key in object)) || !predicate(value)) {
  3594. return false;
  3595. }
  3596. }
  3597. return true;
  3598. }
  3599. /**
  3600. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  3601. * to provide to `func`.
  3602. *
  3603. * @private
  3604. * @param {Function} func The function to delay.
  3605. * @param {number} wait The number of milliseconds to delay invocation.
  3606. * @param {Array} args The arguments to provide to `func`.
  3607. * @returns {number|Object} Returns the timer id or timeout object.
  3608. */
  3609. function baseDelay(func, wait, args) {
  3610. if (typeof func != 'function') {
  3611. throw new TypeError(FUNC_ERROR_TEXT);
  3612. }
  3613. return setTimeout(function() { func.apply(undefined, args); }, wait);
  3614. }
  3615. /**
  3616. * The base implementation of methods like `_.difference` without support
  3617. * for excluding multiple arrays or iteratee shorthands.
  3618. *
  3619. * @private
  3620. * @param {Array} array The array to inspect.
  3621. * @param {Array} values The values to exclude.
  3622. * @param {Function} [iteratee] The iteratee invoked per element.
  3623. * @param {Function} [comparator] The comparator invoked per element.
  3624. * @returns {Array} Returns the new array of filtered values.
  3625. */
  3626. function baseDifference(array, values, iteratee, comparator) {
  3627. var index = -1,
  3628. includes = arrayIncludes,
  3629. isCommon = true,
  3630. length = array.length,
  3631. result = [],
  3632. valuesLength = values.length;
  3633. if (!length) {
  3634. return result;
  3635. }
  3636. if (iteratee) {
  3637. values = arrayMap(values, baseUnary(iteratee));
  3638. }
  3639. if (comparator) {
  3640. includes = arrayIncludesWith;
  3641. isCommon = false;
  3642. }
  3643. else if (values.length >= LARGE_ARRAY_SIZE) {
  3644. includes = cacheHas;
  3645. isCommon = false;
  3646. values = new SetCache(values);
  3647. }
  3648. outer:
  3649. while (++index < length) {
  3650. var value = array[index],
  3651. computed = iteratee == null ? value : iteratee(value);
  3652. value = (comparator || value !== 0) ? value : 0;
  3653. if (isCommon && computed === computed) {
  3654. var valuesIndex = valuesLength;
  3655. while (valuesIndex--) {
  3656. if (values[valuesIndex] === computed) {
  3657. continue outer;
  3658. }
  3659. }
  3660. result.push(value);
  3661. }
  3662. else if (!includes(values, computed, comparator)) {
  3663. result.push(value);
  3664. }
  3665. }
  3666. return result;
  3667. }
  3668. /**
  3669. * The base implementation of `_.forEach` without support for iteratee shorthands.
  3670. *
  3671. * @private
  3672. * @param {Array|Object} collection The collection to iterate over.
  3673. * @param {Function} iteratee The function invoked per iteration.
  3674. * @returns {Array|Object} Returns `collection`.
  3675. */
  3676. var baseEach = createBaseEach(baseForOwn);
  3677. /**
  3678. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  3679. *
  3680. * @private
  3681. * @param {Array|Object} collection The collection to iterate over.
  3682. * @param {Function} iteratee The function invoked per iteration.
  3683. * @returns {Array|Object} Returns `collection`.
  3684. */
  3685. var baseEachRight = createBaseEach(baseForOwnRight, true);
  3686. /**
  3687. * The base implementation of `_.every` without support for iteratee shorthands.
  3688. *
  3689. * @private
  3690. * @param {Array|Object} collection The collection to iterate over.
  3691. * @param {Function} predicate The function invoked per iteration.
  3692. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  3693. * else `false`
  3694. */
  3695. function baseEvery(collection, predicate) {
  3696. var result = true;
  3697. baseEach(collection, function(value, index, collection) {
  3698. result = !!predicate(value, index, collection);
  3699. return result;
  3700. });
  3701. return result;
  3702. }
  3703. /**
  3704. * The base implementation of methods like `_.max` and `_.min` which accepts a
  3705. * `comparator` to determine the extremum value.
  3706. *
  3707. * @private
  3708. * @param {Array} array The array to iterate over.
  3709. * @param {Function} iteratee The iteratee invoked per iteration.
  3710. * @param {Function} comparator The comparator used to compare values.
  3711. * @returns {*} Returns the extremum value.
  3712. */
  3713. function baseExtremum(array, iteratee, comparator) {
  3714. var index = -1,
  3715. length = array.length;
  3716. while (++index < length) {
  3717. var value = array[index],
  3718. current = iteratee(value);
  3719. if (current != null && (computed === undefined
  3720. ? (current === current && !isSymbol(current))
  3721. : comparator(current, computed)
  3722. )) {
  3723. var computed = current,
  3724. result = value;
  3725. }
  3726. }
  3727. return result;
  3728. }
  3729. /**
  3730. * The base implementation of `_.fill` without an iteratee call guard.
  3731. *
  3732. * @private
  3733. * @param {Array} array The array to fill.
  3734. * @param {*} value The value to fill `array` with.
  3735. * @param {number} [start=0] The start position.
  3736. * @param {number} [end=array.length] The end position.
  3737. * @returns {Array} Returns `array`.
  3738. */
  3739. function baseFill(array, value, start, end) {
  3740. var length = array.length;
  3741. start = toInteger(start);
  3742. if (start < 0) {
  3743. start = -start > length ? 0 : (length + start);
  3744. }
  3745. end = (end === undefined || end > length) ? length : toInteger(end);
  3746. if (end < 0) {
  3747. end += length;
  3748. }
  3749. end = start > end ? 0 : toLength(end);
  3750. while (start < end) {
  3751. array[start++] = value;
  3752. }
  3753. return array;
  3754. }
  3755. /**
  3756. * The base implementation of `_.filter` without support for iteratee shorthands.
  3757. *
  3758. * @private
  3759. * @param {Array|Object} collection The collection to iterate over.
  3760. * @param {Function} predicate The function invoked per iteration.
  3761. * @returns {Array} Returns the new filtered array.
  3762. */
  3763. function baseFilter(collection, predicate) {
  3764. var result = [];
  3765. baseEach(collection, function(value, index, collection) {
  3766. if (predicate(value, index, collection)) {
  3767. result.push(value);
  3768. }
  3769. });
  3770. return result;
  3771. }
  3772. /**
  3773. * The base implementation of `_.flatten` with support for restricting flattening.
  3774. *
  3775. * @private
  3776. * @param {Array} array The array to flatten.
  3777. * @param {number} depth The maximum recursion depth.
  3778. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  3779. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  3780. * @param {Array} [result=[]] The initial result value.
  3781. * @returns {Array} Returns the new flattened array.
  3782. */
  3783. function baseFlatten(array, depth, predicate, isStrict, result) {
  3784. var index = -1,
  3785. length = array.length;
  3786. predicate || (predicate = isFlattenable);
  3787. result || (result = []);
  3788. while (++index < length) {
  3789. var value = array[index];
  3790. if (depth > 0 && predicate(value)) {
  3791. if (depth > 1) {
  3792. // Recursively flatten arrays (susceptible to call stack limits).
  3793. baseFlatten(value, depth - 1, predicate, isStrict, result);
  3794. } else {
  3795. arrayPush(result, value);
  3796. }
  3797. } else if (!isStrict) {
  3798. result[result.length] = value;
  3799. }
  3800. }
  3801. return result;
  3802. }
  3803. /**
  3804. * The base implementation of `baseForOwn` which iterates over `object`
  3805. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  3806. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3807. *
  3808. * @private
  3809. * @param {Object} object The object to iterate over.
  3810. * @param {Function} iteratee The function invoked per iteration.
  3811. * @param {Function} keysFunc The function to get the keys of `object`.
  3812. * @returns {Object} Returns `object`.
  3813. */
  3814. var baseFor = createBaseFor();
  3815. /**
  3816. * This function is like `baseFor` except that it iterates over properties
  3817. * in the opposite order.
  3818. *
  3819. * @private
  3820. * @param {Object} object The object to iterate over.
  3821. * @param {Function} iteratee The function invoked per iteration.
  3822. * @param {Function} keysFunc The function to get the keys of `object`.
  3823. * @returns {Object} Returns `object`.
  3824. */
  3825. var baseForRight = createBaseFor(true);
  3826. /**
  3827. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  3828. *
  3829. * @private
  3830. * @param {Object} object The object to iterate over.
  3831. * @param {Function} iteratee The function invoked per iteration.
  3832. * @returns {Object} Returns `object`.
  3833. */
  3834. function baseForOwn(object, iteratee) {
  3835. return object && baseFor(object, iteratee, keys);
  3836. }
  3837. /**
  3838. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  3839. *
  3840. * @private
  3841. * @param {Object} object The object to iterate over.
  3842. * @param {Function} iteratee The function invoked per iteration.
  3843. * @returns {Object} Returns `object`.
  3844. */
  3845. function baseForOwnRight(object, iteratee) {
  3846. return object && baseForRight(object, iteratee, keys);
  3847. }
  3848. /**
  3849. * The base implementation of `_.functions` which creates an array of
  3850. * `object` function property names filtered from `props`.
  3851. *
  3852. * @private
  3853. * @param {Object} object The object to inspect.
  3854. * @param {Array} props The property names to filter.
  3855. * @returns {Array} Returns the function names.
  3856. */
  3857. function baseFunctions(object, props) {
  3858. return arrayFilter(props, function(key) {
  3859. return isFunction(object[key]);
  3860. });
  3861. }
  3862. /**
  3863. * The base implementation of `_.get` without support for default values.
  3864. *
  3865. * @private
  3866. * @param {Object} object The object to query.
  3867. * @param {Array|string} path The path of the property to get.
  3868. * @returns {*} Returns the resolved value.
  3869. */
  3870. function baseGet(object, path) {
  3871. path = castPath(path, object);
  3872. var index = 0,
  3873. length = path.length;
  3874. while (object != null && index < length) {
  3875. object = object[toKey(path[index++])];
  3876. }
  3877. return (index && index == length) ? object : undefined;
  3878. }
  3879. /**
  3880. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  3881. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  3882. * symbols of `object`.
  3883. *
  3884. * @private
  3885. * @param {Object} object The object to query.
  3886. * @param {Function} keysFunc The function to get the keys of `object`.
  3887. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  3888. * @returns {Array} Returns the array of property names and symbols.
  3889. */
  3890. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  3891. var result = keysFunc(object);
  3892. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  3893. }
  3894. /**
  3895. * The base implementation of `getTag` without fallbacks for buggy environments.
  3896. *
  3897. * @private
  3898. * @param {*} value The value to query.
  3899. * @returns {string} Returns the `toStringTag`.
  3900. */
  3901. function baseGetTag(value) {
  3902. if (value == null) {
  3903. return value === undefined ? undefinedTag : nullTag;
  3904. }
  3905. return (symToStringTag && symToStringTag in Object(value))
  3906. ? getRawTag(value)
  3907. : objectToString(value);
  3908. }
  3909. /**
  3910. * The base implementation of `_.gt` which doesn't coerce arguments.
  3911. *
  3912. * @private
  3913. * @param {*} value The value to compare.
  3914. * @param {*} other The other value to compare.
  3915. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  3916. * else `false`.
  3917. */
  3918. function baseGt(value, other) {
  3919. return value > other;
  3920. }
  3921. /**
  3922. * The base implementation of `_.has` without support for deep paths.
  3923. *
  3924. * @private
  3925. * @param {Object} [object] The object to query.
  3926. * @param {Array|string} key The key to check.
  3927. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3928. */
  3929. function baseHas(object, key) {
  3930. return object != null && hasOwnProperty.call(object, key);
  3931. }
  3932. /**
  3933. * The base implementation of `_.hasIn` without support for deep paths.
  3934. *
  3935. * @private
  3936. * @param {Object} [object] The object to query.
  3937. * @param {Array|string} key The key to check.
  3938. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3939. */
  3940. function baseHasIn(object, key) {
  3941. return object != null && key in Object(object);
  3942. }
  3943. /**
  3944. * The base implementation of `_.inRange` which doesn't coerce arguments.
  3945. *
  3946. * @private
  3947. * @param {number} number The number to check.
  3948. * @param {number} start The start of the range.
  3949. * @param {number} end The end of the range.
  3950. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  3951. */
  3952. function baseInRange(number, start, end) {
  3953. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  3954. }
  3955. /**
  3956. * The base implementation of methods like `_.intersection`, without support
  3957. * for iteratee shorthands, that accepts an array of arrays to inspect.
  3958. *
  3959. * @private
  3960. * @param {Array} arrays The arrays to inspect.
  3961. * @param {Function} [iteratee] The iteratee invoked per element.
  3962. * @param {Function} [comparator] The comparator invoked per element.
  3963. * @returns {Array} Returns the new array of shared values.
  3964. */
  3965. function baseIntersection(arrays, iteratee, comparator) {
  3966. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  3967. length = arrays[0].length,
  3968. othLength = arrays.length,
  3969. othIndex = othLength,
  3970. caches = Array(othLength),
  3971. maxLength = Infinity,
  3972. result = [];
  3973. while (othIndex--) {
  3974. var array = arrays[othIndex];
  3975. if (othIndex && iteratee) {
  3976. array = arrayMap(array, baseUnary(iteratee));
  3977. }
  3978. maxLength = nativeMin(array.length, maxLength);
  3979. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  3980. ? new SetCache(othIndex && array)
  3981. : undefined;
  3982. }
  3983. array = arrays[0];
  3984. var index = -1,
  3985. seen = caches[0];
  3986. outer:
  3987. while (++index < length && result.length < maxLength) {
  3988. var value = array[index],
  3989. computed = iteratee ? iteratee(value) : value;
  3990. value = (comparator || value !== 0) ? value : 0;
  3991. if (!(seen
  3992. ? cacheHas(seen, computed)
  3993. : includes(result, computed, comparator)
  3994. )) {
  3995. othIndex = othLength;
  3996. while (--othIndex) {
  3997. var cache = caches[othIndex];
  3998. if (!(cache
  3999. ? cacheHas(cache, computed)
  4000. : includes(arrays[othIndex], computed, comparator))
  4001. ) {
  4002. continue outer;
  4003. }
  4004. }
  4005. if (seen) {
  4006. seen.push(computed);
  4007. }
  4008. result.push(value);
  4009. }
  4010. }
  4011. return result;
  4012. }
  4013. /**
  4014. * The base implementation of `_.invert` and `_.invertBy` which inverts
  4015. * `object` with values transformed by `iteratee` and set by `setter`.
  4016. *
  4017. * @private
  4018. * @param {Object} object The object to iterate over.
  4019. * @param {Function} setter The function to set `accumulator` values.
  4020. * @param {Function} iteratee The iteratee to transform values.
  4021. * @param {Object} accumulator The initial inverted object.
  4022. * @returns {Function} Returns `accumulator`.
  4023. */
  4024. function baseInverter(object, setter, iteratee, accumulator) {
  4025. baseForOwn(object, function(value, key, object) {
  4026. setter(accumulator, iteratee(value), key, object);
  4027. });
  4028. return accumulator;
  4029. }
  4030. /**
  4031. * The base implementation of `_.invoke` without support for individual
  4032. * method arguments.
  4033. *
  4034. * @private
  4035. * @param {Object} object The object to query.
  4036. * @param {Array|string} path The path of the method to invoke.
  4037. * @param {Array} args The arguments to invoke the method with.
  4038. * @returns {*} Returns the result of the invoked method.
  4039. */
  4040. function baseInvoke(object, path, args) {
  4041. path = castPath(path, object);
  4042. object = parent(object, path);
  4043. var func = object == null ? object : object[toKey(last(path))];
  4044. return func == null ? undefined : apply(func, object, args);
  4045. }
  4046. /**
  4047. * The base implementation of `_.isArguments`.
  4048. *
  4049. * @private
  4050. * @param {*} value The value to check.
  4051. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  4052. */
  4053. function baseIsArguments(value) {
  4054. return isObjectLike(value) && baseGetTag(value) == argsTag;
  4055. }
  4056. /**
  4057. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  4058. *
  4059. * @private
  4060. * @param {*} value The value to check.
  4061. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  4062. */
  4063. function baseIsArrayBuffer(value) {
  4064. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  4065. }
  4066. /**
  4067. * The base implementation of `_.isDate` without Node.js optimizations.
  4068. *
  4069. * @private
  4070. * @param {*} value The value to check.
  4071. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  4072. */
  4073. function baseIsDate(value) {
  4074. return isObjectLike(value) && baseGetTag(value) == dateTag;
  4075. }
  4076. /**
  4077. * The base implementation of `_.isEqual` which supports partial comparisons
  4078. * and tracks traversed objects.
  4079. *
  4080. * @private
  4081. * @param {*} value The value to compare.
  4082. * @param {*} other The other value to compare.
  4083. * @param {boolean} bitmask The bitmask flags.
  4084. * 1 - Unordered comparison
  4085. * 2 - Partial comparison
  4086. * @param {Function} [customizer] The function to customize comparisons.
  4087. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  4088. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4089. */
  4090. function baseIsEqual(value, other, bitmask, customizer, stack) {
  4091. if (value === other) {
  4092. return true;
  4093. }
  4094. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  4095. return value !== value && other !== other;
  4096. }
  4097. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  4098. }
  4099. /**
  4100. * A specialized version of `baseIsEqual` for arrays and objects which performs
  4101. * deep comparisons and tracks traversed objects enabling objects with circular
  4102. * references to be compared.
  4103. *
  4104. * @private
  4105. * @param {Object} object The object to compare.
  4106. * @param {Object} other The other object to compare.
  4107. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  4108. * @param {Function} customizer The function to customize comparisons.
  4109. * @param {Function} equalFunc The function to determine equivalents of values.
  4110. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  4111. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4112. */
  4113. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  4114. var objIsArr = isArray(object),
  4115. othIsArr = isArray(other),
  4116. objTag = objIsArr ? arrayTag : getTag(object),
  4117. othTag = othIsArr ? arrayTag : getTag(other);
  4118. objTag = objTag == argsTag ? objectTag : objTag;
  4119. othTag = othTag == argsTag ? objectTag : othTag;
  4120. var objIsObj = objTag == objectTag,
  4121. othIsObj = othTag == objectTag,
  4122. isSameTag = objTag == othTag;
  4123. if (isSameTag && isBuffer(object)) {
  4124. if (!isBuffer(other)) {
  4125. return false;
  4126. }
  4127. objIsArr = true;
  4128. objIsObj = false;
  4129. }
  4130. if (isSameTag && !objIsObj) {
  4131. stack || (stack = new Stack);
  4132. return (objIsArr || isTypedArray(object))
  4133. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  4134. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  4135. }
  4136. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  4137. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  4138. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  4139. if (objIsWrapped || othIsWrapped) {
  4140. var objUnwrapped = objIsWrapped ? object.value() : object,
  4141. othUnwrapped = othIsWrapped ? other.value() : other;
  4142. stack || (stack = new Stack);
  4143. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  4144. }
  4145. }
  4146. if (!isSameTag) {
  4147. return false;
  4148. }
  4149. stack || (stack = new Stack);
  4150. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  4151. }
  4152. /**
  4153. * The base implementation of `_.isMap` without Node.js optimizations.
  4154. *
  4155. * @private
  4156. * @param {*} value The value to check.
  4157. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  4158. */
  4159. function baseIsMap(value) {
  4160. return isObjectLike(value) && getTag(value) == mapTag;
  4161. }
  4162. /**
  4163. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  4164. *
  4165. * @private
  4166. * @param {Object} object The object to inspect.
  4167. * @param {Object} source The object of property values to match.
  4168. * @param {Array} matchData The property names, values, and compare flags to match.
  4169. * @param {Function} [customizer] The function to customize comparisons.
  4170. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  4171. */
  4172. function baseIsMatch(object, source, matchData, customizer) {
  4173. var index = matchData.length,
  4174. length = index,
  4175. noCustomizer = !customizer;
  4176. if (object == null) {
  4177. return !length;
  4178. }
  4179. object = Object(object);
  4180. while (index--) {
  4181. var data = matchData[index];
  4182. if ((noCustomizer && data[2])
  4183. ? data[1] !== object[data[0]]
  4184. : !(data[0] in object)
  4185. ) {
  4186. return false;
  4187. }
  4188. }
  4189. while (++index < length) {
  4190. data = matchData[index];
  4191. var key = data[0],
  4192. objValue = object[key],
  4193. srcValue = data[1];
  4194. if (noCustomizer && data[2]) {
  4195. if (objValue === undefined && !(key in object)) {
  4196. return false;
  4197. }
  4198. } else {
  4199. var stack = new Stack;
  4200. if (customizer) {
  4201. var result = customizer(objValue, srcValue, key, object, source, stack);
  4202. }
  4203. if (!(result === undefined
  4204. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  4205. : result
  4206. )) {
  4207. return false;
  4208. }
  4209. }
  4210. }
  4211. return true;
  4212. }
  4213. /**
  4214. * The base implementation of `_.isNative` without bad shim checks.
  4215. *
  4216. * @private
  4217. * @param {*} value The value to check.
  4218. * @returns {boolean} Returns `true` if `value` is a native function,
  4219. * else `false`.
  4220. */
  4221. function baseIsNative(value) {
  4222. if (!isObject(value) || isMasked(value)) {
  4223. return false;
  4224. }
  4225. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  4226. return pattern.test(toSource(value));
  4227. }
  4228. /**
  4229. * The base implementation of `_.isRegExp` without Node.js optimizations.
  4230. *
  4231. * @private
  4232. * @param {*} value The value to check.
  4233. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  4234. */
  4235. function baseIsRegExp(value) {
  4236. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  4237. }
  4238. /**
  4239. * The base implementation of `_.isSet` without Node.js optimizations.
  4240. *
  4241. * @private
  4242. * @param {*} value The value to check.
  4243. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  4244. */
  4245. function baseIsSet(value) {
  4246. return isObjectLike(value) && getTag(value) == setTag;
  4247. }
  4248. /**
  4249. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  4250. *
  4251. * @private
  4252. * @param {*} value The value to check.
  4253. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  4254. */
  4255. function baseIsTypedArray(value) {
  4256. return isObjectLike(value) &&
  4257. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  4258. }
  4259. /**
  4260. * The base implementation of `_.iteratee`.
  4261. *
  4262. * @private
  4263. * @param {*} [value=_.identity] The value to convert to an iteratee.
  4264. * @returns {Function} Returns the iteratee.
  4265. */
  4266. function baseIteratee(value) {
  4267. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  4268. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  4269. if (typeof value == 'function') {
  4270. return value;
  4271. }
  4272. if (value == null) {
  4273. return identity;
  4274. }
  4275. if (typeof value == 'object') {
  4276. return isArray(value)
  4277. ? baseMatchesProperty(value[0], value[1])
  4278. : baseMatches(value);
  4279. }
  4280. return property(value);
  4281. }
  4282. /**
  4283. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  4284. *
  4285. * @private
  4286. * @param {Object} object The object to query.
  4287. * @returns {Array} Returns the array of property names.
  4288. */
  4289. function baseKeys(object) {
  4290. if (!isPrototype(object)) {
  4291. return nativeKeys(object);
  4292. }
  4293. var result = [];
  4294. for (var key in Object(object)) {
  4295. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  4296. result.push(key);
  4297. }
  4298. }
  4299. return result;
  4300. }
  4301. /**
  4302. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  4303. *
  4304. * @private
  4305. * @param {Object} object The object to query.
  4306. * @returns {Array} Returns the array of property names.
  4307. */
  4308. function baseKeysIn(object) {
  4309. if (!isObject(object)) {
  4310. return nativeKeysIn(object);
  4311. }
  4312. var isProto = isPrototype(object),
  4313. result = [];
  4314. for (var key in object) {
  4315. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  4316. result.push(key);
  4317. }
  4318. }
  4319. return result;
  4320. }
  4321. /**
  4322. * The base implementation of `_.lt` which doesn't coerce arguments.
  4323. *
  4324. * @private
  4325. * @param {*} value The value to compare.
  4326. * @param {*} other The other value to compare.
  4327. * @returns {boolean} Returns `true` if `value` is less than `other`,
  4328. * else `false`.
  4329. */
  4330. function baseLt(value, other) {
  4331. return value < other;
  4332. }
  4333. /**
  4334. * The base implementation of `_.map` without support for iteratee shorthands.
  4335. *
  4336. * @private
  4337. * @param {Array|Object} collection The collection to iterate over.
  4338. * @param {Function} iteratee The function invoked per iteration.
  4339. * @returns {Array} Returns the new mapped array.
  4340. */
  4341. function baseMap(collection, iteratee) {
  4342. var index = -1,
  4343. result = isArrayLike(collection) ? Array(collection.length) : [];
  4344. baseEach(collection, function(value, key, collection) {
  4345. result[++index] = iteratee(value, key, collection);
  4346. });
  4347. return result;
  4348. }
  4349. /**
  4350. * The base implementation of `_.matches` which doesn't clone `source`.
  4351. *
  4352. * @private
  4353. * @param {Object} source The object of property values to match.
  4354. * @returns {Function} Returns the new spec function.
  4355. */
  4356. function baseMatches(source) {
  4357. var matchData = getMatchData(source);
  4358. if (matchData.length == 1 && matchData[0][2]) {
  4359. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  4360. }
  4361. return function(object) {
  4362. return object === source || baseIsMatch(object, source, matchData);
  4363. };
  4364. }
  4365. /**
  4366. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  4367. *
  4368. * @private
  4369. * @param {string} path The path of the property to get.
  4370. * @param {*} srcValue The value to match.
  4371. * @returns {Function} Returns the new spec function.
  4372. */
  4373. function baseMatchesProperty(path, srcValue) {
  4374. if (isKey(path) && isStrictComparable(srcValue)) {
  4375. return matchesStrictComparable(toKey(path), srcValue);
  4376. }
  4377. return function(object) {
  4378. var objValue = get(object, path);
  4379. return (objValue === undefined && objValue === srcValue)
  4380. ? hasIn(object, path)
  4381. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  4382. };
  4383. }
  4384. /**
  4385. * The base implementation of `_.merge` without support for multiple sources.
  4386. *
  4387. * @private
  4388. * @param {Object} object The destination object.
  4389. * @param {Object} source The source object.
  4390. * @param {number} srcIndex The index of `source`.
  4391. * @param {Function} [customizer] The function to customize merged values.
  4392. * @param {Object} [stack] Tracks traversed source values and their merged
  4393. * counterparts.
  4394. */
  4395. function baseMerge(object, source, srcIndex, customizer, stack) {
  4396. if (object === source) {
  4397. return;
  4398. }
  4399. baseFor(source, function(srcValue, key) {
  4400. stack || (stack = new Stack);
  4401. if (isObject(srcValue)) {
  4402. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  4403. }
  4404. else {
  4405. var newValue = customizer
  4406. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  4407. : undefined;
  4408. if (newValue === undefined) {
  4409. newValue = srcValue;
  4410. }
  4411. assignMergeValue(object, key, newValue);
  4412. }
  4413. }, keysIn);
  4414. }
  4415. /**
  4416. * A specialized version of `baseMerge` for arrays and objects which performs
  4417. * deep merges and tracks traversed objects enabling objects with circular
  4418. * references to be merged.
  4419. *
  4420. * @private
  4421. * @param {Object} object The destination object.
  4422. * @param {Object} source The source object.
  4423. * @param {string} key The key of the value to merge.
  4424. * @param {number} srcIndex The index of `source`.
  4425. * @param {Function} mergeFunc The function to merge values.
  4426. * @param {Function} [customizer] The function to customize assigned values.
  4427. * @param {Object} [stack] Tracks traversed source values and their merged
  4428. * counterparts.
  4429. */
  4430. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  4431. var objValue = safeGet(object, key),
  4432. srcValue = safeGet(source, key),
  4433. stacked = stack.get(srcValue);
  4434. if (stacked) {
  4435. assignMergeValue(object, key, stacked);
  4436. return;
  4437. }
  4438. var newValue = customizer
  4439. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  4440. : undefined;
  4441. var isCommon = newValue === undefined;
  4442. if (isCommon) {
  4443. var isArr = isArray(srcValue),
  4444. isBuff = !isArr && isBuffer(srcValue),
  4445. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  4446. newValue = srcValue;
  4447. if (isArr || isBuff || isTyped) {
  4448. if (isArray(objValue)) {
  4449. newValue = objValue;
  4450. }
  4451. else if (isArrayLikeObject(objValue)) {
  4452. newValue = copyArray(objValue);
  4453. }
  4454. else if (isBuff) {
  4455. isCommon = false;
  4456. newValue = cloneBuffer(srcValue, true);
  4457. }
  4458. else if (isTyped) {
  4459. isCommon = false;
  4460. newValue = cloneTypedArray(srcValue, true);
  4461. }
  4462. else {
  4463. newValue = [];
  4464. }
  4465. }
  4466. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  4467. newValue = objValue;
  4468. if (isArguments(objValue)) {
  4469. newValue = toPlainObject(objValue);
  4470. }
  4471. else if (!isObject(objValue) || isFunction(objValue)) {
  4472. newValue = initCloneObject(srcValue);
  4473. }
  4474. }
  4475. else {
  4476. isCommon = false;
  4477. }
  4478. }
  4479. if (isCommon) {
  4480. // Recursively merge objects and arrays (susceptible to call stack limits).
  4481. stack.set(srcValue, newValue);
  4482. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  4483. stack['delete'](srcValue);
  4484. }
  4485. assignMergeValue(object, key, newValue);
  4486. }
  4487. /**
  4488. * The base implementation of `_.nth` which doesn't coerce arguments.
  4489. *
  4490. * @private
  4491. * @param {Array} array The array to query.
  4492. * @param {number} n The index of the element to return.
  4493. * @returns {*} Returns the nth element of `array`.
  4494. */
  4495. function baseNth(array, n) {
  4496. var length = array.length;
  4497. if (!length) {
  4498. return;
  4499. }
  4500. n += n < 0 ? length : 0;
  4501. return isIndex(n, length) ? array[n] : undefined;
  4502. }
  4503. /**
  4504. * The base implementation of `_.orderBy` without param guards.
  4505. *
  4506. * @private
  4507. * @param {Array|Object} collection The collection to iterate over.
  4508. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  4509. * @param {string[]} orders The sort orders of `iteratees`.
  4510. * @returns {Array} Returns the new sorted array.
  4511. */
  4512. function baseOrderBy(collection, iteratees, orders) {
  4513. if (iteratees.length) {
  4514. iteratees = arrayMap(iteratees, function(iteratee) {
  4515. if (isArray(iteratee)) {
  4516. return function(value) {
  4517. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  4518. }
  4519. }
  4520. return iteratee;
  4521. });
  4522. } else {
  4523. iteratees = [identity];
  4524. }
  4525. var index = -1;
  4526. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  4527. var result = baseMap(collection, function(value, key, collection) {
  4528. var criteria = arrayMap(iteratees, function(iteratee) {
  4529. return iteratee(value);
  4530. });
  4531. return { 'criteria': criteria, 'index': ++index, 'value': value };
  4532. });
  4533. return baseSortBy(result, function(object, other) {
  4534. return compareMultiple(object, other, orders);
  4535. });
  4536. }
  4537. /**
  4538. * The base implementation of `_.pick` without support for individual
  4539. * property identifiers.
  4540. *
  4541. * @private
  4542. * @param {Object} object The source object.
  4543. * @param {string[]} paths The property paths to pick.
  4544. * @returns {Object} Returns the new object.
  4545. */
  4546. function basePick(object, paths) {
  4547. return basePickBy(object, paths, function(value, path) {
  4548. return hasIn(object, path);
  4549. });
  4550. }
  4551. /**
  4552. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  4553. *
  4554. * @private
  4555. * @param {Object} object The source object.
  4556. * @param {string[]} paths The property paths to pick.
  4557. * @param {Function} predicate The function invoked per property.
  4558. * @returns {Object} Returns the new object.
  4559. */
  4560. function basePickBy(object, paths, predicate) {
  4561. var index = -1,
  4562. length = paths.length,
  4563. result = {};
  4564. while (++index < length) {
  4565. var path = paths[index],
  4566. value = baseGet(object, path);
  4567. if (predicate(value, path)) {
  4568. baseSet(result, castPath(path, object), value);
  4569. }
  4570. }
  4571. return result;
  4572. }
  4573. /**
  4574. * A specialized version of `baseProperty` which supports deep paths.
  4575. *
  4576. * @private
  4577. * @param {Array|string} path The path of the property to get.
  4578. * @returns {Function} Returns the new accessor function.
  4579. */
  4580. function basePropertyDeep(path) {
  4581. return function(object) {
  4582. return baseGet(object, path);
  4583. };
  4584. }
  4585. /**
  4586. * The base implementation of `_.pullAllBy` without support for iteratee
  4587. * shorthands.
  4588. *
  4589. * @private
  4590. * @param {Array} array The array to modify.
  4591. * @param {Array} values The values to remove.
  4592. * @param {Function} [iteratee] The iteratee invoked per element.
  4593. * @param {Function} [comparator] The comparator invoked per element.
  4594. * @returns {Array} Returns `array`.
  4595. */
  4596. function basePullAll(array, values, iteratee, comparator) {
  4597. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  4598. index = -1,
  4599. length = values.length,
  4600. seen = array;
  4601. if (array === values) {
  4602. values = copyArray(values);
  4603. }
  4604. if (iteratee) {
  4605. seen = arrayMap(array, baseUnary(iteratee));
  4606. }
  4607. while (++index < length) {
  4608. var fromIndex = 0,
  4609. value = values[index],
  4610. computed = iteratee ? iteratee(value) : value;
  4611. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  4612. if (seen !== array) {
  4613. splice.call(seen, fromIndex, 1);
  4614. }
  4615. splice.call(array, fromIndex, 1);
  4616. }
  4617. }
  4618. return array;
  4619. }
  4620. /**
  4621. * The base implementation of `_.pullAt` without support for individual
  4622. * indexes or capturing the removed elements.
  4623. *
  4624. * @private
  4625. * @param {Array} array The array to modify.
  4626. * @param {number[]} indexes The indexes of elements to remove.
  4627. * @returns {Array} Returns `array`.
  4628. */
  4629. function basePullAt(array, indexes) {
  4630. var length = array ? indexes.length : 0,
  4631. lastIndex = length - 1;
  4632. while (length--) {
  4633. var index = indexes[length];
  4634. if (length == lastIndex || index !== previous) {
  4635. var previous = index;
  4636. if (isIndex(index)) {
  4637. splice.call(array, index, 1);
  4638. } else {
  4639. baseUnset(array, index);
  4640. }
  4641. }
  4642. }
  4643. return array;
  4644. }
  4645. /**
  4646. * The base implementation of `_.random` without support for returning
  4647. * floating-point numbers.
  4648. *
  4649. * @private
  4650. * @param {number} lower The lower bound.
  4651. * @param {number} upper The upper bound.
  4652. * @returns {number} Returns the random number.
  4653. */
  4654. function baseRandom(lower, upper) {
  4655. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  4656. }
  4657. /**
  4658. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  4659. * coerce arguments.
  4660. *
  4661. * @private
  4662. * @param {number} start The start of the range.
  4663. * @param {number} end The end of the range.
  4664. * @param {number} step The value to increment or decrement by.
  4665. * @param {boolean} [fromRight] Specify iterating from right to left.
  4666. * @returns {Array} Returns the range of numbers.
  4667. */
  4668. function baseRange(start, end, step, fromRight) {
  4669. var index = -1,
  4670. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  4671. result = Array(length);
  4672. while (length--) {
  4673. result[fromRight ? length : ++index] = start;
  4674. start += step;
  4675. }
  4676. return result;
  4677. }
  4678. /**
  4679. * The base implementation of `_.repeat` which doesn't coerce arguments.
  4680. *
  4681. * @private
  4682. * @param {string} string The string to repeat.
  4683. * @param {number} n The number of times to repeat the string.
  4684. * @returns {string} Returns the repeated string.
  4685. */
  4686. function baseRepeat(string, n) {
  4687. var result = '';
  4688. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  4689. return result;
  4690. }
  4691. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  4692. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  4693. do {
  4694. if (n % 2) {
  4695. result += string;
  4696. }
  4697. n = nativeFloor(n / 2);
  4698. if (n) {
  4699. string += string;
  4700. }
  4701. } while (n);
  4702. return result;
  4703. }
  4704. /**
  4705. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  4706. *
  4707. * @private
  4708. * @param {Function} func The function to apply a rest parameter to.
  4709. * @param {number} [start=func.length-1] The start position of the rest parameter.
  4710. * @returns {Function} Returns the new function.
  4711. */
  4712. function baseRest(func, start) {
  4713. return setToString(overRest(func, start, identity), func + '');
  4714. }
  4715. /**
  4716. * The base implementation of `_.sample`.
  4717. *
  4718. * @private
  4719. * @param {Array|Object} collection The collection to sample.
  4720. * @returns {*} Returns the random element.
  4721. */
  4722. function baseSample(collection) {
  4723. return arraySample(values(collection));
  4724. }
  4725. /**
  4726. * The base implementation of `_.sampleSize` without param guards.
  4727. *
  4728. * @private
  4729. * @param {Array|Object} collection The collection to sample.
  4730. * @param {number} n The number of elements to sample.
  4731. * @returns {Array} Returns the random elements.
  4732. */
  4733. function baseSampleSize(collection, n) {
  4734. var array = values(collection);
  4735. return shuffleSelf(array, baseClamp(n, 0, array.length));
  4736. }
  4737. /**
  4738. * The base implementation of `_.set`.
  4739. *
  4740. * @private
  4741. * @param {Object} object The object to modify.
  4742. * @param {Array|string} path The path of the property to set.
  4743. * @param {*} value The value to set.
  4744. * @param {Function} [customizer] The function to customize path creation.
  4745. * @returns {Object} Returns `object`.
  4746. */
  4747. function baseSet(object, path, value, customizer) {
  4748. if (!isObject(object)) {
  4749. return object;
  4750. }
  4751. path = castPath(path, object);
  4752. var index = -1,
  4753. length = path.length,
  4754. lastIndex = length - 1,
  4755. nested = object;
  4756. while (nested != null && ++index < length) {
  4757. var key = toKey(path[index]),
  4758. newValue = value;
  4759. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  4760. return object;
  4761. }
  4762. if (index != lastIndex) {
  4763. var objValue = nested[key];
  4764. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  4765. if (newValue === undefined) {
  4766. newValue = isObject(objValue)
  4767. ? objValue
  4768. : (isIndex(path[index + 1]) ? [] : {});
  4769. }
  4770. }
  4771. assignValue(nested, key, newValue);
  4772. nested = nested[key];
  4773. }
  4774. return object;
  4775. }
  4776. /**
  4777. * The base implementation of `setData` without support for hot loop shorting.
  4778. *
  4779. * @private
  4780. * @param {Function} func The function to associate metadata with.
  4781. * @param {*} data The metadata.
  4782. * @returns {Function} Returns `func`.
  4783. */
  4784. var baseSetData = !metaMap ? identity : function(func, data) {
  4785. metaMap.set(func, data);
  4786. return func;
  4787. };
  4788. /**
  4789. * The base implementation of `setToString` without support for hot loop shorting.
  4790. *
  4791. * @private
  4792. * @param {Function} func The function to modify.
  4793. * @param {Function} string The `toString` result.
  4794. * @returns {Function} Returns `func`.
  4795. */
  4796. var baseSetToString = !defineProperty ? identity : function(func, string) {
  4797. return defineProperty(func, 'toString', {
  4798. 'configurable': true,
  4799. 'enumerable': false,
  4800. 'value': constant(string),
  4801. 'writable': true
  4802. });
  4803. };
  4804. /**
  4805. * The base implementation of `_.shuffle`.
  4806. *
  4807. * @private
  4808. * @param {Array|Object} collection The collection to shuffle.
  4809. * @returns {Array} Returns the new shuffled array.
  4810. */
  4811. function baseShuffle(collection) {
  4812. return shuffleSelf(values(collection));
  4813. }
  4814. /**
  4815. * The base implementation of `_.slice` without an iteratee call guard.
  4816. *
  4817. * @private
  4818. * @param {Array} array The array to slice.
  4819. * @param {number} [start=0] The start position.
  4820. * @param {number} [end=array.length] The end position.
  4821. * @returns {Array} Returns the slice of `array`.
  4822. */
  4823. function baseSlice(array, start, end) {
  4824. var index = -1,
  4825. length = array.length;
  4826. if (start < 0) {
  4827. start = -start > length ? 0 : (length + start);
  4828. }
  4829. end = end > length ? length : end;
  4830. if (end < 0) {
  4831. end += length;
  4832. }
  4833. length = start > end ? 0 : ((end - start) >>> 0);
  4834. start >>>= 0;
  4835. var result = Array(length);
  4836. while (++index < length) {
  4837. result[index] = array[index + start];
  4838. }
  4839. return result;
  4840. }
  4841. /**
  4842. * The base implementation of `_.some` without support for iteratee shorthands.
  4843. *
  4844. * @private
  4845. * @param {Array|Object} collection The collection to iterate over.
  4846. * @param {Function} predicate The function invoked per iteration.
  4847. * @returns {boolean} Returns `true` if any element passes the predicate check,
  4848. * else `false`.
  4849. */
  4850. function baseSome(collection, predicate) {
  4851. var result;
  4852. baseEach(collection, function(value, index, collection) {
  4853. result = predicate(value, index, collection);
  4854. return !result;
  4855. });
  4856. return !!result;
  4857. }
  4858. /**
  4859. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  4860. * performs a binary search of `array` to determine the index at which `value`
  4861. * should be inserted into `array` in order to maintain its sort order.
  4862. *
  4863. * @private
  4864. * @param {Array} array The sorted array to inspect.
  4865. * @param {*} value The value to evaluate.
  4866. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4867. * @returns {number} Returns the index at which `value` should be inserted
  4868. * into `array`.
  4869. */
  4870. function baseSortedIndex(array, value, retHighest) {
  4871. var low = 0,
  4872. high = array == null ? low : array.length;
  4873. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  4874. while (low < high) {
  4875. var mid = (low + high) >>> 1,
  4876. computed = array[mid];
  4877. if (computed !== null && !isSymbol(computed) &&
  4878. (retHighest ? (computed <= value) : (computed < value))) {
  4879. low = mid + 1;
  4880. } else {
  4881. high = mid;
  4882. }
  4883. }
  4884. return high;
  4885. }
  4886. return baseSortedIndexBy(array, value, identity, retHighest);
  4887. }
  4888. /**
  4889. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  4890. * which invokes `iteratee` for `value` and each element of `array` to compute
  4891. * their sort ranking. The iteratee is invoked with one argument; (value).
  4892. *
  4893. * @private
  4894. * @param {Array} array The sorted array to inspect.
  4895. * @param {*} value The value to evaluate.
  4896. * @param {Function} iteratee The iteratee invoked per element.
  4897. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  4898. * @returns {number} Returns the index at which `value` should be inserted
  4899. * into `array`.
  4900. */
  4901. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  4902. var low = 0,
  4903. high = array == null ? 0 : array.length;
  4904. if (high === 0) {
  4905. return 0;
  4906. }
  4907. value = iteratee(value);
  4908. var valIsNaN = value !== value,
  4909. valIsNull = value === null,
  4910. valIsSymbol = isSymbol(value),
  4911. valIsUndefined = value === undefined;
  4912. while (low < high) {
  4913. var mid = nativeFloor((low + high) / 2),
  4914. computed = iteratee(array[mid]),
  4915. othIsDefined = computed !== undefined,
  4916. othIsNull = computed === null,
  4917. othIsReflexive = computed === computed,
  4918. othIsSymbol = isSymbol(computed);
  4919. if (valIsNaN) {
  4920. var setLow = retHighest || othIsReflexive;
  4921. } else if (valIsUndefined) {
  4922. setLow = othIsReflexive && (retHighest || othIsDefined);
  4923. } else if (valIsNull) {
  4924. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  4925. } else if (valIsSymbol) {
  4926. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  4927. } else if (othIsNull || othIsSymbol) {
  4928. setLow = false;
  4929. } else {
  4930. setLow = retHighest ? (computed <= value) : (computed < value);
  4931. }
  4932. if (setLow) {
  4933. low = mid + 1;
  4934. } else {
  4935. high = mid;
  4936. }
  4937. }
  4938. return nativeMin(high, MAX_ARRAY_INDEX);
  4939. }
  4940. /**
  4941. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  4942. * support for iteratee shorthands.
  4943. *
  4944. * @private
  4945. * @param {Array} array The array to inspect.
  4946. * @param {Function} [iteratee] The iteratee invoked per element.
  4947. * @returns {Array} Returns the new duplicate free array.
  4948. */
  4949. function baseSortedUniq(array, iteratee) {
  4950. var index = -1,
  4951. length = array.length,
  4952. resIndex = 0,
  4953. result = [];
  4954. while (++index < length) {
  4955. var value = array[index],
  4956. computed = iteratee ? iteratee(value) : value;
  4957. if (!index || !eq(computed, seen)) {
  4958. var seen = computed;
  4959. result[resIndex++] = value === 0 ? 0 : value;
  4960. }
  4961. }
  4962. return result;
  4963. }
  4964. /**
  4965. * The base implementation of `_.toNumber` which doesn't ensure correct
  4966. * conversions of binary, hexadecimal, or octal string values.
  4967. *
  4968. * @private
  4969. * @param {*} value The value to process.
  4970. * @returns {number} Returns the number.
  4971. */
  4972. function baseToNumber(value) {
  4973. if (typeof value == 'number') {
  4974. return value;
  4975. }
  4976. if (isSymbol(value)) {
  4977. return NAN;
  4978. }
  4979. return +value;
  4980. }
  4981. /**
  4982. * The base implementation of `_.toString` which doesn't convert nullish
  4983. * values to empty strings.
  4984. *
  4985. * @private
  4986. * @param {*} value The value to process.
  4987. * @returns {string} Returns the string.
  4988. */
  4989. function baseToString(value) {
  4990. // Exit early for strings to avoid a performance hit in some environments.
  4991. if (typeof value == 'string') {
  4992. return value;
  4993. }
  4994. if (isArray(value)) {
  4995. // Recursively convert values (susceptible to call stack limits).
  4996. return arrayMap(value, baseToString) + '';
  4997. }
  4998. if (isSymbol(value)) {
  4999. return symbolToString ? symbolToString.call(value) : '';
  5000. }
  5001. var result = (value + '');
  5002. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  5003. }
  5004. /**
  5005. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  5006. *
  5007. * @private
  5008. * @param {Array} array The array to inspect.
  5009. * @param {Function} [iteratee] The iteratee invoked per element.
  5010. * @param {Function} [comparator] The comparator invoked per element.
  5011. * @returns {Array} Returns the new duplicate free array.
  5012. */
  5013. function baseUniq(array, iteratee, comparator) {
  5014. var index = -1,
  5015. includes = arrayIncludes,
  5016. length = array.length,
  5017. isCommon = true,
  5018. result = [],
  5019. seen = result;
  5020. if (comparator) {
  5021. isCommon = false;
  5022. includes = arrayIncludesWith;
  5023. }
  5024. else if (length >= LARGE_ARRAY_SIZE) {
  5025. var set = iteratee ? null : createSet(array);
  5026. if (set) {
  5027. return setToArray(set);
  5028. }
  5029. isCommon = false;
  5030. includes = cacheHas;
  5031. seen = new SetCache;
  5032. }
  5033. else {
  5034. seen = iteratee ? [] : result;
  5035. }
  5036. outer:
  5037. while (++index < length) {
  5038. var value = array[index],
  5039. computed = iteratee ? iteratee(value) : value;
  5040. value = (comparator || value !== 0) ? value : 0;
  5041. if (isCommon && computed === computed) {
  5042. var seenIndex = seen.length;
  5043. while (seenIndex--) {
  5044. if (seen[seenIndex] === computed) {
  5045. continue outer;
  5046. }
  5047. }
  5048. if (iteratee) {
  5049. seen.push(computed);
  5050. }
  5051. result.push(value);
  5052. }
  5053. else if (!includes(seen, computed, comparator)) {
  5054. if (seen !== result) {
  5055. seen.push(computed);
  5056. }
  5057. result.push(value);
  5058. }
  5059. }
  5060. return result;
  5061. }
  5062. /**
  5063. * The base implementation of `_.unset`.
  5064. *
  5065. * @private
  5066. * @param {Object} object The object to modify.
  5067. * @param {Array|string} path The property path to unset.
  5068. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  5069. */
  5070. function baseUnset(object, path) {
  5071. path = castPath(path, object);
  5072. object = parent(object, path);
  5073. return object == null || delete object[toKey(last(path))];
  5074. }
  5075. /**
  5076. * The base implementation of `_.update`.
  5077. *
  5078. * @private
  5079. * @param {Object} object The object to modify.
  5080. * @param {Array|string} path The path of the property to update.
  5081. * @param {Function} updater The function to produce the updated value.
  5082. * @param {Function} [customizer] The function to customize path creation.
  5083. * @returns {Object} Returns `object`.
  5084. */
  5085. function baseUpdate(object, path, updater, customizer) {
  5086. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  5087. }
  5088. /**
  5089. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  5090. * without support for iteratee shorthands.
  5091. *
  5092. * @private
  5093. * @param {Array} array The array to query.
  5094. * @param {Function} predicate The function invoked per iteration.
  5095. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  5096. * @param {boolean} [fromRight] Specify iterating from right to left.
  5097. * @returns {Array} Returns the slice of `array`.
  5098. */
  5099. function baseWhile(array, predicate, isDrop, fromRight) {
  5100. var length = array.length,
  5101. index = fromRight ? length : -1;
  5102. while ((fromRight ? index-- : ++index < length) &&
  5103. predicate(array[index], index, array)) {}
  5104. return isDrop
  5105. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  5106. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  5107. }
  5108. /**
  5109. * The base implementation of `wrapperValue` which returns the result of
  5110. * performing a sequence of actions on the unwrapped `value`, where each
  5111. * successive action is supplied the return value of the previous.
  5112. *
  5113. * @private
  5114. * @param {*} value The unwrapped value.
  5115. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  5116. * @returns {*} Returns the resolved value.
  5117. */
  5118. function baseWrapperValue(value, actions) {
  5119. var result = value;
  5120. if (result instanceof LazyWrapper) {
  5121. result = result.value();
  5122. }
  5123. return arrayReduce(actions, function(result, action) {
  5124. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  5125. }, result);
  5126. }
  5127. /**
  5128. * The base implementation of methods like `_.xor`, without support for
  5129. * iteratee shorthands, that accepts an array of arrays to inspect.
  5130. *
  5131. * @private
  5132. * @param {Array} arrays The arrays to inspect.
  5133. * @param {Function} [iteratee] The iteratee invoked per element.
  5134. * @param {Function} [comparator] The comparator invoked per element.
  5135. * @returns {Array} Returns the new array of values.
  5136. */
  5137. function baseXor(arrays, iteratee, comparator) {
  5138. var length = arrays.length;
  5139. if (length < 2) {
  5140. return length ? baseUniq(arrays[0]) : [];
  5141. }
  5142. var index = -1,
  5143. result = Array(length);
  5144. while (++index < length) {
  5145. var array = arrays[index],
  5146. othIndex = -1;
  5147. while (++othIndex < length) {
  5148. if (othIndex != index) {
  5149. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  5150. }
  5151. }
  5152. }
  5153. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  5154. }
  5155. /**
  5156. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  5157. *
  5158. * @private
  5159. * @param {Array} props The property identifiers.
  5160. * @param {Array} values The property values.
  5161. * @param {Function} assignFunc The function to assign values.
  5162. * @returns {Object} Returns the new object.
  5163. */
  5164. function baseZipObject(props, values, assignFunc) {
  5165. var index = -1,
  5166. length = props.length,
  5167. valsLength = values.length,
  5168. result = {};
  5169. while (++index < length) {
  5170. var value = index < valsLength ? values[index] : undefined;
  5171. assignFunc(result, props[index], value);
  5172. }
  5173. return result;
  5174. }
  5175. /**
  5176. * Casts `value` to an empty array if it's not an array like object.
  5177. *
  5178. * @private
  5179. * @param {*} value The value to inspect.
  5180. * @returns {Array|Object} Returns the cast array-like object.
  5181. */
  5182. function castArrayLikeObject(value) {
  5183. return isArrayLikeObject(value) ? value : [];
  5184. }
  5185. /**
  5186. * Casts `value` to `identity` if it's not a function.
  5187. *
  5188. * @private
  5189. * @param {*} value The value to inspect.
  5190. * @returns {Function} Returns cast function.
  5191. */
  5192. function castFunction(value) {
  5193. return typeof value == 'function' ? value : identity;
  5194. }
  5195. /**
  5196. * Casts `value` to a path array if it's not one.
  5197. *
  5198. * @private
  5199. * @param {*} value The value to inspect.
  5200. * @param {Object} [object] The object to query keys on.
  5201. * @returns {Array} Returns the cast property path array.
  5202. */
  5203. function castPath(value, object) {
  5204. if (isArray(value)) {
  5205. return value;
  5206. }
  5207. return isKey(value, object) ? [value] : stringToPath(toString(value));
  5208. }
  5209. /**
  5210. * A `baseRest` alias which can be replaced with `identity` by module
  5211. * replacement plugins.
  5212. *
  5213. * @private
  5214. * @type {Function}
  5215. * @param {Function} func The function to apply a rest parameter to.
  5216. * @returns {Function} Returns the new function.
  5217. */
  5218. var castRest = baseRest;
  5219. /**
  5220. * Casts `array` to a slice if it's needed.
  5221. *
  5222. * @private
  5223. * @param {Array} array The array to inspect.
  5224. * @param {number} start The start position.
  5225. * @param {number} [end=array.length] The end position.
  5226. * @returns {Array} Returns the cast slice.
  5227. */
  5228. function castSlice(array, start, end) {
  5229. var length = array.length;
  5230. end = end === undefined ? length : end;
  5231. return (!start && end >= length) ? array : baseSlice(array, start, end);
  5232. }
  5233. /**
  5234. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  5235. *
  5236. * @private
  5237. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  5238. */
  5239. var clearTimeout = ctxClearTimeout || function(id) {
  5240. return root.clearTimeout(id);
  5241. };
  5242. /**
  5243. * Creates a clone of `buffer`.
  5244. *
  5245. * @private
  5246. * @param {Buffer} buffer The buffer to clone.
  5247. * @param {boolean} [isDeep] Specify a deep clone.
  5248. * @returns {Buffer} Returns the cloned buffer.
  5249. */
  5250. function cloneBuffer(buffer, isDeep) {
  5251. if (isDeep) {
  5252. return buffer.slice();
  5253. }
  5254. var length = buffer.length,
  5255. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  5256. buffer.copy(result);
  5257. return result;
  5258. }
  5259. /**
  5260. * Creates a clone of `arrayBuffer`.
  5261. *
  5262. * @private
  5263. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  5264. * @returns {ArrayBuffer} Returns the cloned array buffer.
  5265. */
  5266. function cloneArrayBuffer(arrayBuffer) {
  5267. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  5268. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  5269. return result;
  5270. }
  5271. /**
  5272. * Creates a clone of `dataView`.
  5273. *
  5274. * @private
  5275. * @param {Object} dataView The data view to clone.
  5276. * @param {boolean} [isDeep] Specify a deep clone.
  5277. * @returns {Object} Returns the cloned data view.
  5278. */
  5279. function cloneDataView(dataView, isDeep) {
  5280. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  5281. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  5282. }
  5283. /**
  5284. * Creates a clone of `regexp`.
  5285. *
  5286. * @private
  5287. * @param {Object} regexp The regexp to clone.
  5288. * @returns {Object} Returns the cloned regexp.
  5289. */
  5290. function cloneRegExp(regexp) {
  5291. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  5292. result.lastIndex = regexp.lastIndex;
  5293. return result;
  5294. }
  5295. /**
  5296. * Creates a clone of the `symbol` object.
  5297. *
  5298. * @private
  5299. * @param {Object} symbol The symbol object to clone.
  5300. * @returns {Object} Returns the cloned symbol object.
  5301. */
  5302. function cloneSymbol(symbol) {
  5303. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  5304. }
  5305. /**
  5306. * Creates a clone of `typedArray`.
  5307. *
  5308. * @private
  5309. * @param {Object} typedArray The typed array to clone.
  5310. * @param {boolean} [isDeep] Specify a deep clone.
  5311. * @returns {Object} Returns the cloned typed array.
  5312. */
  5313. function cloneTypedArray(typedArray, isDeep) {
  5314. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  5315. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  5316. }
  5317. /**
  5318. * Compares values to sort them in ascending order.
  5319. *
  5320. * @private
  5321. * @param {*} value The value to compare.
  5322. * @param {*} other The other value to compare.
  5323. * @returns {number} Returns the sort order indicator for `value`.
  5324. */
  5325. function compareAscending(value, other) {
  5326. if (value !== other) {
  5327. var valIsDefined = value !== undefined,
  5328. valIsNull = value === null,
  5329. valIsReflexive = value === value,
  5330. valIsSymbol = isSymbol(value);
  5331. var othIsDefined = other !== undefined,
  5332. othIsNull = other === null,
  5333. othIsReflexive = other === other,
  5334. othIsSymbol = isSymbol(other);
  5335. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  5336. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  5337. (valIsNull && othIsDefined && othIsReflexive) ||
  5338. (!valIsDefined && othIsReflexive) ||
  5339. !valIsReflexive) {
  5340. return 1;
  5341. }
  5342. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  5343. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  5344. (othIsNull && valIsDefined && valIsReflexive) ||
  5345. (!othIsDefined && valIsReflexive) ||
  5346. !othIsReflexive) {
  5347. return -1;
  5348. }
  5349. }
  5350. return 0;
  5351. }
  5352. /**
  5353. * Used by `_.orderBy` to compare multiple properties of a value to another
  5354. * and stable sort them.
  5355. *
  5356. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  5357. * specify an order of "desc" for descending or "asc" for ascending sort order
  5358. * of corresponding values.
  5359. *
  5360. * @private
  5361. * @param {Object} object The object to compare.
  5362. * @param {Object} other The other object to compare.
  5363. * @param {boolean[]|string[]} orders The order to sort by for each property.
  5364. * @returns {number} Returns the sort order indicator for `object`.
  5365. */
  5366. function compareMultiple(object, other, orders) {
  5367. var index = -1,
  5368. objCriteria = object.criteria,
  5369. othCriteria = other.criteria,
  5370. length = objCriteria.length,
  5371. ordersLength = orders.length;
  5372. while (++index < length) {
  5373. var result = compareAscending(objCriteria[index], othCriteria[index]);
  5374. if (result) {
  5375. if (index >= ordersLength) {
  5376. return result;
  5377. }
  5378. var order = orders[index];
  5379. return result * (order == 'desc' ? -1 : 1);
  5380. }
  5381. }
  5382. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  5383. // that causes it, under certain circumstances, to provide the same value for
  5384. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  5385. // for more details.
  5386. //
  5387. // This also ensures a stable sort in V8 and other engines.
  5388. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  5389. return object.index - other.index;
  5390. }
  5391. /**
  5392. * Creates an array that is the composition of partially applied arguments,
  5393. * placeholders, and provided arguments into a single array of arguments.
  5394. *
  5395. * @private
  5396. * @param {Array} args The provided arguments.
  5397. * @param {Array} partials The arguments to prepend to those provided.
  5398. * @param {Array} holders The `partials` placeholder indexes.
  5399. * @params {boolean} [isCurried] Specify composing for a curried function.
  5400. * @returns {Array} Returns the new array of composed arguments.
  5401. */
  5402. function composeArgs(args, partials, holders, isCurried) {
  5403. var argsIndex = -1,
  5404. argsLength = args.length,
  5405. holdersLength = holders.length,
  5406. leftIndex = -1,
  5407. leftLength = partials.length,
  5408. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5409. result = Array(leftLength + rangeLength),
  5410. isUncurried = !isCurried;
  5411. while (++leftIndex < leftLength) {
  5412. result[leftIndex] = partials[leftIndex];
  5413. }
  5414. while (++argsIndex < holdersLength) {
  5415. if (isUncurried || argsIndex < argsLength) {
  5416. result[holders[argsIndex]] = args[argsIndex];
  5417. }
  5418. }
  5419. while (rangeLength--) {
  5420. result[leftIndex++] = args[argsIndex++];
  5421. }
  5422. return result;
  5423. }
  5424. /**
  5425. * This function is like `composeArgs` except that the arguments composition
  5426. * is tailored for `_.partialRight`.
  5427. *
  5428. * @private
  5429. * @param {Array} args The provided arguments.
  5430. * @param {Array} partials The arguments to append to those provided.
  5431. * @param {Array} holders The `partials` placeholder indexes.
  5432. * @params {boolean} [isCurried] Specify composing for a curried function.
  5433. * @returns {Array} Returns the new array of composed arguments.
  5434. */
  5435. function composeArgsRight(args, partials, holders, isCurried) {
  5436. var argsIndex = -1,
  5437. argsLength = args.length,
  5438. holdersIndex = -1,
  5439. holdersLength = holders.length,
  5440. rightIndex = -1,
  5441. rightLength = partials.length,
  5442. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5443. result = Array(rangeLength + rightLength),
  5444. isUncurried = !isCurried;
  5445. while (++argsIndex < rangeLength) {
  5446. result[argsIndex] = args[argsIndex];
  5447. }
  5448. var offset = argsIndex;
  5449. while (++rightIndex < rightLength) {
  5450. result[offset + rightIndex] = partials[rightIndex];
  5451. }
  5452. while (++holdersIndex < holdersLength) {
  5453. if (isUncurried || argsIndex < argsLength) {
  5454. result[offset + holders[holdersIndex]] = args[argsIndex++];
  5455. }
  5456. }
  5457. return result;
  5458. }
  5459. /**
  5460. * Copies the values of `source` to `array`.
  5461. *
  5462. * @private
  5463. * @param {Array} source The array to copy values from.
  5464. * @param {Array} [array=[]] The array to copy values to.
  5465. * @returns {Array} Returns `array`.
  5466. */
  5467. function copyArray(source, array) {
  5468. var index = -1,
  5469. length = source.length;
  5470. array || (array = Array(length));
  5471. while (++index < length) {
  5472. array[index] = source[index];
  5473. }
  5474. return array;
  5475. }
  5476. /**
  5477. * Copies properties of `source` to `object`.
  5478. *
  5479. * @private
  5480. * @param {Object} source The object to copy properties from.
  5481. * @param {Array} props The property identifiers to copy.
  5482. * @param {Object} [object={}] The object to copy properties to.
  5483. * @param {Function} [customizer] The function to customize copied values.
  5484. * @returns {Object} Returns `object`.
  5485. */
  5486. function copyObject(source, props, object, customizer) {
  5487. var isNew = !object;
  5488. object || (object = {});
  5489. var index = -1,
  5490. length = props.length;
  5491. while (++index < length) {
  5492. var key = props[index];
  5493. var newValue = customizer
  5494. ? customizer(object[key], source[key], key, object, source)
  5495. : undefined;
  5496. if (newValue === undefined) {
  5497. newValue = source[key];
  5498. }
  5499. if (isNew) {
  5500. baseAssignValue(object, key, newValue);
  5501. } else {
  5502. assignValue(object, key, newValue);
  5503. }
  5504. }
  5505. return object;
  5506. }
  5507. /**
  5508. * Copies own symbols of `source` to `object`.
  5509. *
  5510. * @private
  5511. * @param {Object} source The object to copy symbols from.
  5512. * @param {Object} [object={}] The object to copy symbols to.
  5513. * @returns {Object} Returns `object`.
  5514. */
  5515. function copySymbols(source, object) {
  5516. return copyObject(source, getSymbols(source), object);
  5517. }
  5518. /**
  5519. * Copies own and inherited symbols of `source` to `object`.
  5520. *
  5521. * @private
  5522. * @param {Object} source The object to copy symbols from.
  5523. * @param {Object} [object={}] The object to copy symbols to.
  5524. * @returns {Object} Returns `object`.
  5525. */
  5526. function copySymbolsIn(source, object) {
  5527. return copyObject(source, getSymbolsIn(source), object);
  5528. }
  5529. /**
  5530. * Creates a function like `_.groupBy`.
  5531. *
  5532. * @private
  5533. * @param {Function} setter The function to set accumulator values.
  5534. * @param {Function} [initializer] The accumulator object initializer.
  5535. * @returns {Function} Returns the new aggregator function.
  5536. */
  5537. function createAggregator(setter, initializer) {
  5538. return function(collection, iteratee) {
  5539. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  5540. accumulator = initializer ? initializer() : {};
  5541. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  5542. };
  5543. }
  5544. /**
  5545. * Creates a function like `_.assign`.
  5546. *
  5547. * @private
  5548. * @param {Function} assigner The function to assign values.
  5549. * @returns {Function} Returns the new assigner function.
  5550. */
  5551. function createAssigner(assigner) {
  5552. return baseRest(function(object, sources) {
  5553. var index = -1,
  5554. length = sources.length,
  5555. customizer = length > 1 ? sources[length - 1] : undefined,
  5556. guard = length > 2 ? sources[2] : undefined;
  5557. customizer = (assigner.length > 3 && typeof customizer == 'function')
  5558. ? (length--, customizer)
  5559. : undefined;
  5560. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  5561. customizer = length < 3 ? undefined : customizer;
  5562. length = 1;
  5563. }
  5564. object = Object(object);
  5565. while (++index < length) {
  5566. var source = sources[index];
  5567. if (source) {
  5568. assigner(object, source, index, customizer);
  5569. }
  5570. }
  5571. return object;
  5572. });
  5573. }
  5574. /**
  5575. * Creates a `baseEach` or `baseEachRight` function.
  5576. *
  5577. * @private
  5578. * @param {Function} eachFunc The function to iterate over a collection.
  5579. * @param {boolean} [fromRight] Specify iterating from right to left.
  5580. * @returns {Function} Returns the new base function.
  5581. */
  5582. function createBaseEach(eachFunc, fromRight) {
  5583. return function(collection, iteratee) {
  5584. if (collection == null) {
  5585. return collection;
  5586. }
  5587. if (!isArrayLike(collection)) {
  5588. return eachFunc(collection, iteratee);
  5589. }
  5590. var length = collection.length,
  5591. index = fromRight ? length : -1,
  5592. iterable = Object(collection);
  5593. while ((fromRight ? index-- : ++index < length)) {
  5594. if (iteratee(iterable[index], index, iterable) === false) {
  5595. break;
  5596. }
  5597. }
  5598. return collection;
  5599. };
  5600. }
  5601. /**
  5602. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  5603. *
  5604. * @private
  5605. * @param {boolean} [fromRight] Specify iterating from right to left.
  5606. * @returns {Function} Returns the new base function.
  5607. */
  5608. function createBaseFor(fromRight) {
  5609. return function(object, iteratee, keysFunc) {
  5610. var index = -1,
  5611. iterable = Object(object),
  5612. props = keysFunc(object),
  5613. length = props.length;
  5614. while (length--) {
  5615. var key = props[fromRight ? length : ++index];
  5616. if (iteratee(iterable[key], key, iterable) === false) {
  5617. break;
  5618. }
  5619. }
  5620. return object;
  5621. };
  5622. }
  5623. /**
  5624. * Creates a function that wraps `func` to invoke it with the optional `this`
  5625. * binding of `thisArg`.
  5626. *
  5627. * @private
  5628. * @param {Function} func The function to wrap.
  5629. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5630. * @param {*} [thisArg] The `this` binding of `func`.
  5631. * @returns {Function} Returns the new wrapped function.
  5632. */
  5633. function createBind(func, bitmask, thisArg) {
  5634. var isBind = bitmask & WRAP_BIND_FLAG,
  5635. Ctor = createCtor(func);
  5636. function wrapper() {
  5637. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5638. return fn.apply(isBind ? thisArg : this, arguments);
  5639. }
  5640. return wrapper;
  5641. }
  5642. /**
  5643. * Creates a function like `_.lowerFirst`.
  5644. *
  5645. * @private
  5646. * @param {string} methodName The name of the `String` case method to use.
  5647. * @returns {Function} Returns the new case function.
  5648. */
  5649. function createCaseFirst(methodName) {
  5650. return function(string) {
  5651. string = toString(string);
  5652. var strSymbols = hasUnicode(string)
  5653. ? stringToArray(string)
  5654. : undefined;
  5655. var chr = strSymbols
  5656. ? strSymbols[0]
  5657. : string.charAt(0);
  5658. var trailing = strSymbols
  5659. ? castSlice(strSymbols, 1).join('')
  5660. : string.slice(1);
  5661. return chr[methodName]() + trailing;
  5662. };
  5663. }
  5664. /**
  5665. * Creates a function like `_.camelCase`.
  5666. *
  5667. * @private
  5668. * @param {Function} callback The function to combine each word.
  5669. * @returns {Function} Returns the new compounder function.
  5670. */
  5671. function createCompounder(callback) {
  5672. return function(string) {
  5673. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  5674. };
  5675. }
  5676. /**
  5677. * Creates a function that produces an instance of `Ctor` regardless of
  5678. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  5679. *
  5680. * @private
  5681. * @param {Function} Ctor The constructor to wrap.
  5682. * @returns {Function} Returns the new wrapped function.
  5683. */
  5684. function createCtor(Ctor) {
  5685. return function() {
  5686. // Use a `switch` statement to work with class constructors. See
  5687. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  5688. // for more details.
  5689. var args = arguments;
  5690. switch (args.length) {
  5691. case 0: return new Ctor;
  5692. case 1: return new Ctor(args[0]);
  5693. case 2: return new Ctor(args[0], args[1]);
  5694. case 3: return new Ctor(args[0], args[1], args[2]);
  5695. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  5696. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  5697. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  5698. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  5699. }
  5700. var thisBinding = baseCreate(Ctor.prototype),
  5701. result = Ctor.apply(thisBinding, args);
  5702. // Mimic the constructor's `return` behavior.
  5703. // See https://es5.github.io/#x13.2.2 for more details.
  5704. return isObject(result) ? result : thisBinding;
  5705. };
  5706. }
  5707. /**
  5708. * Creates a function that wraps `func` to enable currying.
  5709. *
  5710. * @private
  5711. * @param {Function} func The function to wrap.
  5712. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5713. * @param {number} arity The arity of `func`.
  5714. * @returns {Function} Returns the new wrapped function.
  5715. */
  5716. function createCurry(func, bitmask, arity) {
  5717. var Ctor = createCtor(func);
  5718. function wrapper() {
  5719. var length = arguments.length,
  5720. args = Array(length),
  5721. index = length,
  5722. placeholder = getHolder(wrapper);
  5723. while (index--) {
  5724. args[index] = arguments[index];
  5725. }
  5726. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  5727. ? []
  5728. : replaceHolders(args, placeholder);
  5729. length -= holders.length;
  5730. if (length < arity) {
  5731. return createRecurry(
  5732. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  5733. args, holders, undefined, undefined, arity - length);
  5734. }
  5735. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5736. return apply(fn, this, args);
  5737. }
  5738. return wrapper;
  5739. }
  5740. /**
  5741. * Creates a `_.find` or `_.findLast` function.
  5742. *
  5743. * @private
  5744. * @param {Function} findIndexFunc The function to find the collection index.
  5745. * @returns {Function} Returns the new find function.
  5746. */
  5747. function createFind(findIndexFunc) {
  5748. return function(collection, predicate, fromIndex) {
  5749. var iterable = Object(collection);
  5750. if (!isArrayLike(collection)) {
  5751. var iteratee = getIteratee(predicate, 3);
  5752. collection = keys(collection);
  5753. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  5754. }
  5755. var index = findIndexFunc(collection, predicate, fromIndex);
  5756. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  5757. };
  5758. }
  5759. /**
  5760. * Creates a `_.flow` or `_.flowRight` function.
  5761. *
  5762. * @private
  5763. * @param {boolean} [fromRight] Specify iterating from right to left.
  5764. * @returns {Function} Returns the new flow function.
  5765. */
  5766. function createFlow(fromRight) {
  5767. return flatRest(function(funcs) {
  5768. var length = funcs.length,
  5769. index = length,
  5770. prereq = LodashWrapper.prototype.thru;
  5771. if (fromRight) {
  5772. funcs.reverse();
  5773. }
  5774. while (index--) {
  5775. var func = funcs[index];
  5776. if (typeof func != 'function') {
  5777. throw new TypeError(FUNC_ERROR_TEXT);
  5778. }
  5779. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  5780. var wrapper = new LodashWrapper([], true);
  5781. }
  5782. }
  5783. index = wrapper ? index : length;
  5784. while (++index < length) {
  5785. func = funcs[index];
  5786. var funcName = getFuncName(func),
  5787. data = funcName == 'wrapper' ? getData(func) : undefined;
  5788. if (data && isLaziable(data[0]) &&
  5789. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  5790. !data[4].length && data[9] == 1
  5791. ) {
  5792. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  5793. } else {
  5794. wrapper = (func.length == 1 && isLaziable(func))
  5795. ? wrapper[funcName]()
  5796. : wrapper.thru(func);
  5797. }
  5798. }
  5799. return function() {
  5800. var args = arguments,
  5801. value = args[0];
  5802. if (wrapper && args.length == 1 && isArray(value)) {
  5803. return wrapper.plant(value).value();
  5804. }
  5805. var index = 0,
  5806. result = length ? funcs[index].apply(this, args) : value;
  5807. while (++index < length) {
  5808. result = funcs[index].call(this, result);
  5809. }
  5810. return result;
  5811. };
  5812. });
  5813. }
  5814. /**
  5815. * Creates a function that wraps `func` to invoke it with optional `this`
  5816. * binding of `thisArg`, partial application, and currying.
  5817. *
  5818. * @private
  5819. * @param {Function|string} func The function or method name to wrap.
  5820. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5821. * @param {*} [thisArg] The `this` binding of `func`.
  5822. * @param {Array} [partials] The arguments to prepend to those provided to
  5823. * the new function.
  5824. * @param {Array} [holders] The `partials` placeholder indexes.
  5825. * @param {Array} [partialsRight] The arguments to append to those provided
  5826. * to the new function.
  5827. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  5828. * @param {Array} [argPos] The argument positions of the new function.
  5829. * @param {number} [ary] The arity cap of `func`.
  5830. * @param {number} [arity] The arity of `func`.
  5831. * @returns {Function} Returns the new wrapped function.
  5832. */
  5833. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  5834. var isAry = bitmask & WRAP_ARY_FLAG,
  5835. isBind = bitmask & WRAP_BIND_FLAG,
  5836. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  5837. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  5838. isFlip = bitmask & WRAP_FLIP_FLAG,
  5839. Ctor = isBindKey ? undefined : createCtor(func);
  5840. function wrapper() {
  5841. var length = arguments.length,
  5842. args = Array(length),
  5843. index = length;
  5844. while (index--) {
  5845. args[index] = arguments[index];
  5846. }
  5847. if (isCurried) {
  5848. var placeholder = getHolder(wrapper),
  5849. holdersCount = countHolders(args, placeholder);
  5850. }
  5851. if (partials) {
  5852. args = composeArgs(args, partials, holders, isCurried);
  5853. }
  5854. if (partialsRight) {
  5855. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  5856. }
  5857. length -= holdersCount;
  5858. if (isCurried && length < arity) {
  5859. var newHolders = replaceHolders(args, placeholder);
  5860. return createRecurry(
  5861. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  5862. args, newHolders, argPos, ary, arity - length
  5863. );
  5864. }
  5865. var thisBinding = isBind ? thisArg : this,
  5866. fn = isBindKey ? thisBinding[func] : func;
  5867. length = args.length;
  5868. if (argPos) {
  5869. args = reorder(args, argPos);
  5870. } else if (isFlip && length > 1) {
  5871. args.reverse();
  5872. }
  5873. if (isAry && ary < length) {
  5874. args.length = ary;
  5875. }
  5876. if (this && this !== root && this instanceof wrapper) {
  5877. fn = Ctor || createCtor(fn);
  5878. }
  5879. return fn.apply(thisBinding, args);
  5880. }
  5881. return wrapper;
  5882. }
  5883. /**
  5884. * Creates a function like `_.invertBy`.
  5885. *
  5886. * @private
  5887. * @param {Function} setter The function to set accumulator values.
  5888. * @param {Function} toIteratee The function to resolve iteratees.
  5889. * @returns {Function} Returns the new inverter function.
  5890. */
  5891. function createInverter(setter, toIteratee) {
  5892. return function(object, iteratee) {
  5893. return baseInverter(object, setter, toIteratee(iteratee), {});
  5894. };
  5895. }
  5896. /**
  5897. * Creates a function that performs a mathematical operation on two values.
  5898. *
  5899. * @private
  5900. * @param {Function} operator The function to perform the operation.
  5901. * @param {number} [defaultValue] The value used for `undefined` arguments.
  5902. * @returns {Function} Returns the new mathematical operation function.
  5903. */
  5904. function createMathOperation(operator, defaultValue) {
  5905. return function(value, other) {
  5906. var result;
  5907. if (value === undefined && other === undefined) {
  5908. return defaultValue;
  5909. }
  5910. if (value !== undefined) {
  5911. result = value;
  5912. }
  5913. if (other !== undefined) {
  5914. if (result === undefined) {
  5915. return other;
  5916. }
  5917. if (typeof value == 'string' || typeof other == 'string') {
  5918. value = baseToString(value);
  5919. other = baseToString(other);
  5920. } else {
  5921. value = baseToNumber(value);
  5922. other = baseToNumber(other);
  5923. }
  5924. result = operator(value, other);
  5925. }
  5926. return result;
  5927. };
  5928. }
  5929. /**
  5930. * Creates a function like `_.over`.
  5931. *
  5932. * @private
  5933. * @param {Function} arrayFunc The function to iterate over iteratees.
  5934. * @returns {Function} Returns the new over function.
  5935. */
  5936. function createOver(arrayFunc) {
  5937. return flatRest(function(iteratees) {
  5938. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  5939. return baseRest(function(args) {
  5940. var thisArg = this;
  5941. return arrayFunc(iteratees, function(iteratee) {
  5942. return apply(iteratee, thisArg, args);
  5943. });
  5944. });
  5945. });
  5946. }
  5947. /**
  5948. * Creates the padding for `string` based on `length`. The `chars` string
  5949. * is truncated if the number of characters exceeds `length`.
  5950. *
  5951. * @private
  5952. * @param {number} length The padding length.
  5953. * @param {string} [chars=' '] The string used as padding.
  5954. * @returns {string} Returns the padding for `string`.
  5955. */
  5956. function createPadding(length, chars) {
  5957. chars = chars === undefined ? ' ' : baseToString(chars);
  5958. var charsLength = chars.length;
  5959. if (charsLength < 2) {
  5960. return charsLength ? baseRepeat(chars, length) : chars;
  5961. }
  5962. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  5963. return hasUnicode(chars)
  5964. ? castSlice(stringToArray(result), 0, length).join('')
  5965. : result.slice(0, length);
  5966. }
  5967. /**
  5968. * Creates a function that wraps `func` to invoke it with the `this` binding
  5969. * of `thisArg` and `partials` prepended to the arguments it receives.
  5970. *
  5971. * @private
  5972. * @param {Function} func The function to wrap.
  5973. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  5974. * @param {*} thisArg The `this` binding of `func`.
  5975. * @param {Array} partials The arguments to prepend to those provided to
  5976. * the new function.
  5977. * @returns {Function} Returns the new wrapped function.
  5978. */
  5979. function createPartial(func, bitmask, thisArg, partials) {
  5980. var isBind = bitmask & WRAP_BIND_FLAG,
  5981. Ctor = createCtor(func);
  5982. function wrapper() {
  5983. var argsIndex = -1,
  5984. argsLength = arguments.length,
  5985. leftIndex = -1,
  5986. leftLength = partials.length,
  5987. args = Array(leftLength + argsLength),
  5988. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  5989. while (++leftIndex < leftLength) {
  5990. args[leftIndex] = partials[leftIndex];
  5991. }
  5992. while (argsLength--) {
  5993. args[leftIndex++] = arguments[++argsIndex];
  5994. }
  5995. return apply(fn, isBind ? thisArg : this, args);
  5996. }
  5997. return wrapper;
  5998. }
  5999. /**
  6000. * Creates a `_.range` or `_.rangeRight` function.
  6001. *
  6002. * @private
  6003. * @param {boolean} [fromRight] Specify iterating from right to left.
  6004. * @returns {Function} Returns the new range function.
  6005. */
  6006. function createRange(fromRight) {
  6007. return function(start, end, step) {
  6008. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  6009. end = step = undefined;
  6010. }
  6011. // Ensure the sign of `-0` is preserved.
  6012. start = toFinite(start);
  6013. if (end === undefined) {
  6014. end = start;
  6015. start = 0;
  6016. } else {
  6017. end = toFinite(end);
  6018. }
  6019. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  6020. return baseRange(start, end, step, fromRight);
  6021. };
  6022. }
  6023. /**
  6024. * Creates a function that performs a relational operation on two values.
  6025. *
  6026. * @private
  6027. * @param {Function} operator The function to perform the operation.
  6028. * @returns {Function} Returns the new relational operation function.
  6029. */
  6030. function createRelationalOperation(operator) {
  6031. return function(value, other) {
  6032. if (!(typeof value == 'string' && typeof other == 'string')) {
  6033. value = toNumber(value);
  6034. other = toNumber(other);
  6035. }
  6036. return operator(value, other);
  6037. };
  6038. }
  6039. /**
  6040. * Creates a function that wraps `func` to continue currying.
  6041. *
  6042. * @private
  6043. * @param {Function} func The function to wrap.
  6044. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6045. * @param {Function} wrapFunc The function to create the `func` wrapper.
  6046. * @param {*} placeholder The placeholder value.
  6047. * @param {*} [thisArg] The `this` binding of `func`.
  6048. * @param {Array} [partials] The arguments to prepend to those provided to
  6049. * the new function.
  6050. * @param {Array} [holders] The `partials` placeholder indexes.
  6051. * @param {Array} [argPos] The argument positions of the new function.
  6052. * @param {number} [ary] The arity cap of `func`.
  6053. * @param {number} [arity] The arity of `func`.
  6054. * @returns {Function} Returns the new wrapped function.
  6055. */
  6056. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  6057. var isCurry = bitmask & WRAP_CURRY_FLAG,
  6058. newHolders = isCurry ? holders : undefined,
  6059. newHoldersRight = isCurry ? undefined : holders,
  6060. newPartials = isCurry ? partials : undefined,
  6061. newPartialsRight = isCurry ? undefined : partials;
  6062. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  6063. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  6064. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  6065. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  6066. }
  6067. var newData = [
  6068. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  6069. newHoldersRight, argPos, ary, arity
  6070. ];
  6071. var result = wrapFunc.apply(undefined, newData);
  6072. if (isLaziable(func)) {
  6073. setData(result, newData);
  6074. }
  6075. result.placeholder = placeholder;
  6076. return setWrapToString(result, func, bitmask);
  6077. }
  6078. /**
  6079. * Creates a function like `_.round`.
  6080. *
  6081. * @private
  6082. * @param {string} methodName The name of the `Math` method to use when rounding.
  6083. * @returns {Function} Returns the new round function.
  6084. */
  6085. function createRound(methodName) {
  6086. var func = Math[methodName];
  6087. return function(number, precision) {
  6088. number = toNumber(number);
  6089. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  6090. if (precision && nativeIsFinite(number)) {
  6091. // Shift with exponential notation to avoid floating-point issues.
  6092. // See [MDN](https://mdn.io/round#Examples) for more details.
  6093. var pair = (toString(number) + 'e').split('e'),
  6094. value = func(pair[0] + 'e' + (+pair[1] + precision));
  6095. pair = (toString(value) + 'e').split('e');
  6096. return +(pair[0] + 'e' + (+pair[1] - precision));
  6097. }
  6098. return func(number);
  6099. };
  6100. }
  6101. /**
  6102. * Creates a set object of `values`.
  6103. *
  6104. * @private
  6105. * @param {Array} values The values to add to the set.
  6106. * @returns {Object} Returns the new set.
  6107. */
  6108. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  6109. return new Set(values);
  6110. };
  6111. /**
  6112. * Creates a `_.toPairs` or `_.toPairsIn` function.
  6113. *
  6114. * @private
  6115. * @param {Function} keysFunc The function to get the keys of a given object.
  6116. * @returns {Function} Returns the new pairs function.
  6117. */
  6118. function createToPairs(keysFunc) {
  6119. return function(object) {
  6120. var tag = getTag(object);
  6121. if (tag == mapTag) {
  6122. return mapToArray(object);
  6123. }
  6124. if (tag == setTag) {
  6125. return setToPairs(object);
  6126. }
  6127. return baseToPairs(object, keysFunc(object));
  6128. };
  6129. }
  6130. /**
  6131. * Creates a function that either curries or invokes `func` with optional
  6132. * `this` binding and partially applied arguments.
  6133. *
  6134. * @private
  6135. * @param {Function|string} func The function or method name to wrap.
  6136. * @param {number} bitmask The bitmask flags.
  6137. * 1 - `_.bind`
  6138. * 2 - `_.bindKey`
  6139. * 4 - `_.curry` or `_.curryRight` of a bound function
  6140. * 8 - `_.curry`
  6141. * 16 - `_.curryRight`
  6142. * 32 - `_.partial`
  6143. * 64 - `_.partialRight`
  6144. * 128 - `_.rearg`
  6145. * 256 - `_.ary`
  6146. * 512 - `_.flip`
  6147. * @param {*} [thisArg] The `this` binding of `func`.
  6148. * @param {Array} [partials] The arguments to be partially applied.
  6149. * @param {Array} [holders] The `partials` placeholder indexes.
  6150. * @param {Array} [argPos] The argument positions of the new function.
  6151. * @param {number} [ary] The arity cap of `func`.
  6152. * @param {number} [arity] The arity of `func`.
  6153. * @returns {Function} Returns the new wrapped function.
  6154. */
  6155. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  6156. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  6157. if (!isBindKey && typeof func != 'function') {
  6158. throw new TypeError(FUNC_ERROR_TEXT);
  6159. }
  6160. var length = partials ? partials.length : 0;
  6161. if (!length) {
  6162. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  6163. partials = holders = undefined;
  6164. }
  6165. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  6166. arity = arity === undefined ? arity : toInteger(arity);
  6167. length -= holders ? holders.length : 0;
  6168. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  6169. var partialsRight = partials,
  6170. holdersRight = holders;
  6171. partials = holders = undefined;
  6172. }
  6173. var data = isBindKey ? undefined : getData(func);
  6174. var newData = [
  6175. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  6176. argPos, ary, arity
  6177. ];
  6178. if (data) {
  6179. mergeData(newData, data);
  6180. }
  6181. func = newData[0];
  6182. bitmask = newData[1];
  6183. thisArg = newData[2];
  6184. partials = newData[3];
  6185. holders = newData[4];
  6186. arity = newData[9] = newData[9] === undefined
  6187. ? (isBindKey ? 0 : func.length)
  6188. : nativeMax(newData[9] - length, 0);
  6189. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  6190. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  6191. }
  6192. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  6193. var result = createBind(func, bitmask, thisArg);
  6194. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  6195. result = createCurry(func, bitmask, arity);
  6196. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  6197. result = createPartial(func, bitmask, thisArg, partials);
  6198. } else {
  6199. result = createHybrid.apply(undefined, newData);
  6200. }
  6201. var setter = data ? baseSetData : setData;
  6202. return setWrapToString(setter(result, newData), func, bitmask);
  6203. }
  6204. /**
  6205. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  6206. * of source objects to the destination object for all destination properties
  6207. * that resolve to `undefined`.
  6208. *
  6209. * @private
  6210. * @param {*} objValue The destination value.
  6211. * @param {*} srcValue The source value.
  6212. * @param {string} key The key of the property to assign.
  6213. * @param {Object} object The parent object of `objValue`.
  6214. * @returns {*} Returns the value to assign.
  6215. */
  6216. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  6217. if (objValue === undefined ||
  6218. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  6219. return srcValue;
  6220. }
  6221. return objValue;
  6222. }
  6223. /**
  6224. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  6225. * objects into destination objects that are passed thru.
  6226. *
  6227. * @private
  6228. * @param {*} objValue The destination value.
  6229. * @param {*} srcValue The source value.
  6230. * @param {string} key The key of the property to merge.
  6231. * @param {Object} object The parent object of `objValue`.
  6232. * @param {Object} source The parent object of `srcValue`.
  6233. * @param {Object} [stack] Tracks traversed source values and their merged
  6234. * counterparts.
  6235. * @returns {*} Returns the value to assign.
  6236. */
  6237. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  6238. if (isObject(objValue) && isObject(srcValue)) {
  6239. // Recursively merge objects and arrays (susceptible to call stack limits).
  6240. stack.set(srcValue, objValue);
  6241. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  6242. stack['delete'](srcValue);
  6243. }
  6244. return objValue;
  6245. }
  6246. /**
  6247. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  6248. * objects.
  6249. *
  6250. * @private
  6251. * @param {*} value The value to inspect.
  6252. * @param {string} key The key of the property to inspect.
  6253. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  6254. */
  6255. function customOmitClone(value) {
  6256. return isPlainObject(value) ? undefined : value;
  6257. }
  6258. /**
  6259. * A specialized version of `baseIsEqualDeep` for arrays with support for
  6260. * partial deep comparisons.
  6261. *
  6262. * @private
  6263. * @param {Array} array The array to compare.
  6264. * @param {Array} other The other array to compare.
  6265. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6266. * @param {Function} customizer The function to customize comparisons.
  6267. * @param {Function} equalFunc The function to determine equivalents of values.
  6268. * @param {Object} stack Tracks traversed `array` and `other` objects.
  6269. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  6270. */
  6271. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  6272. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6273. arrLength = array.length,
  6274. othLength = other.length;
  6275. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  6276. return false;
  6277. }
  6278. // Check that cyclic values are equal.
  6279. var arrStacked = stack.get(array);
  6280. var othStacked = stack.get(other);
  6281. if (arrStacked && othStacked) {
  6282. return arrStacked == other && othStacked == array;
  6283. }
  6284. var index = -1,
  6285. result = true,
  6286. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  6287. stack.set(array, other);
  6288. stack.set(other, array);
  6289. // Ignore non-index properties.
  6290. while (++index < arrLength) {
  6291. var arrValue = array[index],
  6292. othValue = other[index];
  6293. if (customizer) {
  6294. var compared = isPartial
  6295. ? customizer(othValue, arrValue, index, other, array, stack)
  6296. : customizer(arrValue, othValue, index, array, other, stack);
  6297. }
  6298. if (compared !== undefined) {
  6299. if (compared) {
  6300. continue;
  6301. }
  6302. result = false;
  6303. break;
  6304. }
  6305. // Recursively compare arrays (susceptible to call stack limits).
  6306. if (seen) {
  6307. if (!arraySome(other, function(othValue, othIndex) {
  6308. if (!cacheHas(seen, othIndex) &&
  6309. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6310. return seen.push(othIndex);
  6311. }
  6312. })) {
  6313. result = false;
  6314. break;
  6315. }
  6316. } else if (!(
  6317. arrValue === othValue ||
  6318. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  6319. )) {
  6320. result = false;
  6321. break;
  6322. }
  6323. }
  6324. stack['delete'](array);
  6325. stack['delete'](other);
  6326. return result;
  6327. }
  6328. /**
  6329. * A specialized version of `baseIsEqualDeep` for comparing objects of
  6330. * the same `toStringTag`.
  6331. *
  6332. * **Note:** This function only supports comparing values with tags of
  6333. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6334. *
  6335. * @private
  6336. * @param {Object} object The object to compare.
  6337. * @param {Object} other The other object to compare.
  6338. * @param {string} tag The `toStringTag` of the objects to compare.
  6339. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6340. * @param {Function} customizer The function to customize comparisons.
  6341. * @param {Function} equalFunc The function to determine equivalents of values.
  6342. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6343. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6344. */
  6345. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  6346. switch (tag) {
  6347. case dataViewTag:
  6348. if ((object.byteLength != other.byteLength) ||
  6349. (object.byteOffset != other.byteOffset)) {
  6350. return false;
  6351. }
  6352. object = object.buffer;
  6353. other = other.buffer;
  6354. case arrayBufferTag:
  6355. if ((object.byteLength != other.byteLength) ||
  6356. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  6357. return false;
  6358. }
  6359. return true;
  6360. case boolTag:
  6361. case dateTag:
  6362. case numberTag:
  6363. // Coerce booleans to `1` or `0` and dates to milliseconds.
  6364. // Invalid dates are coerced to `NaN`.
  6365. return eq(+object, +other);
  6366. case errorTag:
  6367. return object.name == other.name && object.message == other.message;
  6368. case regexpTag:
  6369. case stringTag:
  6370. // Coerce regexes to strings and treat strings, primitives and objects,
  6371. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  6372. // for more details.
  6373. return object == (other + '');
  6374. case mapTag:
  6375. var convert = mapToArray;
  6376. case setTag:
  6377. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  6378. convert || (convert = setToArray);
  6379. if (object.size != other.size && !isPartial) {
  6380. return false;
  6381. }
  6382. // Assume cyclic values are equal.
  6383. var stacked = stack.get(object);
  6384. if (stacked) {
  6385. return stacked == other;
  6386. }
  6387. bitmask |= COMPARE_UNORDERED_FLAG;
  6388. // Recursively compare objects (susceptible to call stack limits).
  6389. stack.set(object, other);
  6390. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  6391. stack['delete'](object);
  6392. return result;
  6393. case symbolTag:
  6394. if (symbolValueOf) {
  6395. return symbolValueOf.call(object) == symbolValueOf.call(other);
  6396. }
  6397. }
  6398. return false;
  6399. }
  6400. /**
  6401. * A specialized version of `baseIsEqualDeep` for objects with support for
  6402. * partial deep comparisons.
  6403. *
  6404. * @private
  6405. * @param {Object} object The object to compare.
  6406. * @param {Object} other The other object to compare.
  6407. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6408. * @param {Function} customizer The function to customize comparisons.
  6409. * @param {Function} equalFunc The function to determine equivalents of values.
  6410. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6411. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6412. */
  6413. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  6414. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6415. objProps = getAllKeys(object),
  6416. objLength = objProps.length,
  6417. othProps = getAllKeys(other),
  6418. othLength = othProps.length;
  6419. if (objLength != othLength && !isPartial) {
  6420. return false;
  6421. }
  6422. var index = objLength;
  6423. while (index--) {
  6424. var key = objProps[index];
  6425. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  6426. return false;
  6427. }
  6428. }
  6429. // Check that cyclic values are equal.
  6430. var objStacked = stack.get(object);
  6431. var othStacked = stack.get(other);
  6432. if (objStacked && othStacked) {
  6433. return objStacked == other && othStacked == object;
  6434. }
  6435. var result = true;
  6436. stack.set(object, other);
  6437. stack.set(other, object);
  6438. var skipCtor = isPartial;
  6439. while (++index < objLength) {
  6440. key = objProps[index];
  6441. var objValue = object[key],
  6442. othValue = other[key];
  6443. if (customizer) {
  6444. var compared = isPartial
  6445. ? customizer(othValue, objValue, key, other, object, stack)
  6446. : customizer(objValue, othValue, key, object, other, stack);
  6447. }
  6448. // Recursively compare objects (susceptible to call stack limits).
  6449. if (!(compared === undefined
  6450. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  6451. : compared
  6452. )) {
  6453. result = false;
  6454. break;
  6455. }
  6456. skipCtor || (skipCtor = key == 'constructor');
  6457. }
  6458. if (result && !skipCtor) {
  6459. var objCtor = object.constructor,
  6460. othCtor = other.constructor;
  6461. // Non `Object` object instances with different constructors are not equal.
  6462. if (objCtor != othCtor &&
  6463. ('constructor' in object && 'constructor' in other) &&
  6464. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  6465. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  6466. result = false;
  6467. }
  6468. }
  6469. stack['delete'](object);
  6470. stack['delete'](other);
  6471. return result;
  6472. }
  6473. /**
  6474. * A specialized version of `baseRest` which flattens the rest array.
  6475. *
  6476. * @private
  6477. * @param {Function} func The function to apply a rest parameter to.
  6478. * @returns {Function} Returns the new function.
  6479. */
  6480. function flatRest(func) {
  6481. return setToString(overRest(func, undefined, flatten), func + '');
  6482. }
  6483. /**
  6484. * Creates an array of own enumerable property names and symbols of `object`.
  6485. *
  6486. * @private
  6487. * @param {Object} object The object to query.
  6488. * @returns {Array} Returns the array of property names and symbols.
  6489. */
  6490. function getAllKeys(object) {
  6491. return baseGetAllKeys(object, keys, getSymbols);
  6492. }
  6493. /**
  6494. * Creates an array of own and inherited enumerable property names and
  6495. * symbols of `object`.
  6496. *
  6497. * @private
  6498. * @param {Object} object The object to query.
  6499. * @returns {Array} Returns the array of property names and symbols.
  6500. */
  6501. function getAllKeysIn(object) {
  6502. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  6503. }
  6504. /**
  6505. * Gets metadata for `func`.
  6506. *
  6507. * @private
  6508. * @param {Function} func The function to query.
  6509. * @returns {*} Returns the metadata for `func`.
  6510. */
  6511. var getData = !metaMap ? noop : function(func) {
  6512. return metaMap.get(func);
  6513. };
  6514. /**
  6515. * Gets the name of `func`.
  6516. *
  6517. * @private
  6518. * @param {Function} func The function to query.
  6519. * @returns {string} Returns the function name.
  6520. */
  6521. function getFuncName(func) {
  6522. var result = (func.name + ''),
  6523. array = realNames[result],
  6524. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  6525. while (length--) {
  6526. var data = array[length],
  6527. otherFunc = data.func;
  6528. if (otherFunc == null || otherFunc == func) {
  6529. return data.name;
  6530. }
  6531. }
  6532. return result;
  6533. }
  6534. /**
  6535. * Gets the argument placeholder value for `func`.
  6536. *
  6537. * @private
  6538. * @param {Function} func The function to inspect.
  6539. * @returns {*} Returns the placeholder value.
  6540. */
  6541. function getHolder(func) {
  6542. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  6543. return object.placeholder;
  6544. }
  6545. /**
  6546. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  6547. * this function returns the custom method, otherwise it returns `baseIteratee`.
  6548. * If arguments are provided, the chosen function is invoked with them and
  6549. * its result is returned.
  6550. *
  6551. * @private
  6552. * @param {*} [value] The value to convert to an iteratee.
  6553. * @param {number} [arity] The arity of the created iteratee.
  6554. * @returns {Function} Returns the chosen function or its result.
  6555. */
  6556. function getIteratee() {
  6557. var result = lodash.iteratee || iteratee;
  6558. result = result === iteratee ? baseIteratee : result;
  6559. return arguments.length ? result(arguments[0], arguments[1]) : result;
  6560. }
  6561. /**
  6562. * Gets the data for `map`.
  6563. *
  6564. * @private
  6565. * @param {Object} map The map to query.
  6566. * @param {string} key The reference key.
  6567. * @returns {*} Returns the map data.
  6568. */
  6569. function getMapData(map, key) {
  6570. var data = map.__data__;
  6571. return isKeyable(key)
  6572. ? data[typeof key == 'string' ? 'string' : 'hash']
  6573. : data.map;
  6574. }
  6575. /**
  6576. * Gets the property names, values, and compare flags of `object`.
  6577. *
  6578. * @private
  6579. * @param {Object} object The object to query.
  6580. * @returns {Array} Returns the match data of `object`.
  6581. */
  6582. function getMatchData(object) {
  6583. var result = keys(object),
  6584. length = result.length;
  6585. while (length--) {
  6586. var key = result[length],
  6587. value = object[key];
  6588. result[length] = [key, value, isStrictComparable(value)];
  6589. }
  6590. return result;
  6591. }
  6592. /**
  6593. * Gets the native function at `key` of `object`.
  6594. *
  6595. * @private
  6596. * @param {Object} object The object to query.
  6597. * @param {string} key The key of the method to get.
  6598. * @returns {*} Returns the function if it's native, else `undefined`.
  6599. */
  6600. function getNative(object, key) {
  6601. var value = getValue(object, key);
  6602. return baseIsNative(value) ? value : undefined;
  6603. }
  6604. /**
  6605. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  6606. *
  6607. * @private
  6608. * @param {*} value The value to query.
  6609. * @returns {string} Returns the raw `toStringTag`.
  6610. */
  6611. function getRawTag(value) {
  6612. var isOwn = hasOwnProperty.call(value, symToStringTag),
  6613. tag = value[symToStringTag];
  6614. try {
  6615. value[symToStringTag] = undefined;
  6616. var unmasked = true;
  6617. } catch (e) {}
  6618. var result = nativeObjectToString.call(value);
  6619. if (unmasked) {
  6620. if (isOwn) {
  6621. value[symToStringTag] = tag;
  6622. } else {
  6623. delete value[symToStringTag];
  6624. }
  6625. }
  6626. return result;
  6627. }
  6628. /**
  6629. * Creates an array of the own enumerable symbols of `object`.
  6630. *
  6631. * @private
  6632. * @param {Object} object The object to query.
  6633. * @returns {Array} Returns the array of symbols.
  6634. */
  6635. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  6636. if (object == null) {
  6637. return [];
  6638. }
  6639. object = Object(object);
  6640. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  6641. return propertyIsEnumerable.call(object, symbol);
  6642. });
  6643. };
  6644. /**
  6645. * Creates an array of the own and inherited enumerable symbols of `object`.
  6646. *
  6647. * @private
  6648. * @param {Object} object The object to query.
  6649. * @returns {Array} Returns the array of symbols.
  6650. */
  6651. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  6652. var result = [];
  6653. while (object) {
  6654. arrayPush(result, getSymbols(object));
  6655. object = getPrototype(object);
  6656. }
  6657. return result;
  6658. };
  6659. /**
  6660. * Gets the `toStringTag` of `value`.
  6661. *
  6662. * @private
  6663. * @param {*} value The value to query.
  6664. * @returns {string} Returns the `toStringTag`.
  6665. */
  6666. var getTag = baseGetTag;
  6667. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  6668. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  6669. (Map && getTag(new Map) != mapTag) ||
  6670. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  6671. (Set && getTag(new Set) != setTag) ||
  6672. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  6673. getTag = function(value) {
  6674. var result = baseGetTag(value),
  6675. Ctor = result == objectTag ? value.constructor : undefined,
  6676. ctorString = Ctor ? toSource(Ctor) : '';
  6677. if (ctorString) {
  6678. switch (ctorString) {
  6679. case dataViewCtorString: return dataViewTag;
  6680. case mapCtorString: return mapTag;
  6681. case promiseCtorString: return promiseTag;
  6682. case setCtorString: return setTag;
  6683. case weakMapCtorString: return weakMapTag;
  6684. }
  6685. }
  6686. return result;
  6687. };
  6688. }
  6689. /**
  6690. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  6691. *
  6692. * @private
  6693. * @param {number} start The start of the view.
  6694. * @param {number} end The end of the view.
  6695. * @param {Array} transforms The transformations to apply to the view.
  6696. * @returns {Object} Returns an object containing the `start` and `end`
  6697. * positions of the view.
  6698. */
  6699. function getView(start, end, transforms) {
  6700. var index = -1,
  6701. length = transforms.length;
  6702. while (++index < length) {
  6703. var data = transforms[index],
  6704. size = data.size;
  6705. switch (data.type) {
  6706. case 'drop': start += size; break;
  6707. case 'dropRight': end -= size; break;
  6708. case 'take': end = nativeMin(end, start + size); break;
  6709. case 'takeRight': start = nativeMax(start, end - size); break;
  6710. }
  6711. }
  6712. return { 'start': start, 'end': end };
  6713. }
  6714. /**
  6715. * Extracts wrapper details from the `source` body comment.
  6716. *
  6717. * @private
  6718. * @param {string} source The source to inspect.
  6719. * @returns {Array} Returns the wrapper details.
  6720. */
  6721. function getWrapDetails(source) {
  6722. var match = source.match(reWrapDetails);
  6723. return match ? match[1].split(reSplitDetails) : [];
  6724. }
  6725. /**
  6726. * Checks if `path` exists on `object`.
  6727. *
  6728. * @private
  6729. * @param {Object} object The object to query.
  6730. * @param {Array|string} path The path to check.
  6731. * @param {Function} hasFunc The function to check properties.
  6732. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  6733. */
  6734. function hasPath(object, path, hasFunc) {
  6735. path = castPath(path, object);
  6736. var index = -1,
  6737. length = path.length,
  6738. result = false;
  6739. while (++index < length) {
  6740. var key = toKey(path[index]);
  6741. if (!(result = object != null && hasFunc(object, key))) {
  6742. break;
  6743. }
  6744. object = object[key];
  6745. }
  6746. if (result || ++index != length) {
  6747. return result;
  6748. }
  6749. length = object == null ? 0 : object.length;
  6750. return !!length && isLength(length) && isIndex(key, length) &&
  6751. (isArray(object) || isArguments(object));
  6752. }
  6753. /**
  6754. * Initializes an array clone.
  6755. *
  6756. * @private
  6757. * @param {Array} array The array to clone.
  6758. * @returns {Array} Returns the initialized clone.
  6759. */
  6760. function initCloneArray(array) {
  6761. var length = array.length,
  6762. result = new array.constructor(length);
  6763. // Add properties assigned by `RegExp#exec`.
  6764. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  6765. result.index = array.index;
  6766. result.input = array.input;
  6767. }
  6768. return result;
  6769. }
  6770. /**
  6771. * Initializes an object clone.
  6772. *
  6773. * @private
  6774. * @param {Object} object The object to clone.
  6775. * @returns {Object} Returns the initialized clone.
  6776. */
  6777. function initCloneObject(object) {
  6778. return (typeof object.constructor == 'function' && !isPrototype(object))
  6779. ? baseCreate(getPrototype(object))
  6780. : {};
  6781. }
  6782. /**
  6783. * Initializes an object clone based on its `toStringTag`.
  6784. *
  6785. * **Note:** This function only supports cloning values with tags of
  6786. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  6787. *
  6788. * @private
  6789. * @param {Object} object The object to clone.
  6790. * @param {string} tag The `toStringTag` of the object to clone.
  6791. * @param {boolean} [isDeep] Specify a deep clone.
  6792. * @returns {Object} Returns the initialized clone.
  6793. */
  6794. function initCloneByTag(object, tag, isDeep) {
  6795. var Ctor = object.constructor;
  6796. switch (tag) {
  6797. case arrayBufferTag:
  6798. return cloneArrayBuffer(object);
  6799. case boolTag:
  6800. case dateTag:
  6801. return new Ctor(+object);
  6802. case dataViewTag:
  6803. return cloneDataView(object, isDeep);
  6804. case float32Tag: case float64Tag:
  6805. case int8Tag: case int16Tag: case int32Tag:
  6806. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  6807. return cloneTypedArray(object, isDeep);
  6808. case mapTag:
  6809. return new Ctor;
  6810. case numberTag:
  6811. case stringTag:
  6812. return new Ctor(object);
  6813. case regexpTag:
  6814. return cloneRegExp(object);
  6815. case setTag:
  6816. return new Ctor;
  6817. case symbolTag:
  6818. return cloneSymbol(object);
  6819. }
  6820. }
  6821. /**
  6822. * Inserts wrapper `details` in a comment at the top of the `source` body.
  6823. *
  6824. * @private
  6825. * @param {string} source The source to modify.
  6826. * @returns {Array} details The details to insert.
  6827. * @returns {string} Returns the modified source.
  6828. */
  6829. function insertWrapDetails(source, details) {
  6830. var length = details.length;
  6831. if (!length) {
  6832. return source;
  6833. }
  6834. var lastIndex = length - 1;
  6835. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  6836. details = details.join(length > 2 ? ', ' : ' ');
  6837. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  6838. }
  6839. /**
  6840. * Checks if `value` is a flattenable `arguments` object or array.
  6841. *
  6842. * @private
  6843. * @param {*} value The value to check.
  6844. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  6845. */
  6846. function isFlattenable(value) {
  6847. return isArray(value) || isArguments(value) ||
  6848. !!(spreadableSymbol && value && value[spreadableSymbol]);
  6849. }
  6850. /**
  6851. * Checks if `value` is a valid array-like index.
  6852. *
  6853. * @private
  6854. * @param {*} value The value to check.
  6855. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  6856. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  6857. */
  6858. function isIndex(value, length) {
  6859. var type = typeof value;
  6860. length = length == null ? MAX_SAFE_INTEGER : length;
  6861. return !!length &&
  6862. (type == 'number' ||
  6863. (type != 'symbol' && reIsUint.test(value))) &&
  6864. (value > -1 && value % 1 == 0 && value < length);
  6865. }
  6866. /**
  6867. * Checks if the given arguments are from an iteratee call.
  6868. *
  6869. * @private
  6870. * @param {*} value The potential iteratee value argument.
  6871. * @param {*} index The potential iteratee index or key argument.
  6872. * @param {*} object The potential iteratee object argument.
  6873. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  6874. * else `false`.
  6875. */
  6876. function isIterateeCall(value, index, object) {
  6877. if (!isObject(object)) {
  6878. return false;
  6879. }
  6880. var type = typeof index;
  6881. if (type == 'number'
  6882. ? (isArrayLike(object) && isIndex(index, object.length))
  6883. : (type == 'string' && index in object)
  6884. ) {
  6885. return eq(object[index], value);
  6886. }
  6887. return false;
  6888. }
  6889. /**
  6890. * Checks if `value` is a property name and not a property path.
  6891. *
  6892. * @private
  6893. * @param {*} value The value to check.
  6894. * @param {Object} [object] The object to query keys on.
  6895. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  6896. */
  6897. function isKey(value, object) {
  6898. if (isArray(value)) {
  6899. return false;
  6900. }
  6901. var type = typeof value;
  6902. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  6903. value == null || isSymbol(value)) {
  6904. return true;
  6905. }
  6906. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  6907. (object != null && value in Object(object));
  6908. }
  6909. /**
  6910. * Checks if `value` is suitable for use as unique object key.
  6911. *
  6912. * @private
  6913. * @param {*} value The value to check.
  6914. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  6915. */
  6916. function isKeyable(value) {
  6917. var type = typeof value;
  6918. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  6919. ? (value !== '__proto__')
  6920. : (value === null);
  6921. }
  6922. /**
  6923. * Checks if `func` has a lazy counterpart.
  6924. *
  6925. * @private
  6926. * @param {Function} func The function to check.
  6927. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  6928. * else `false`.
  6929. */
  6930. function isLaziable(func) {
  6931. var funcName = getFuncName(func),
  6932. other = lodash[funcName];
  6933. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  6934. return false;
  6935. }
  6936. if (func === other) {
  6937. return true;
  6938. }
  6939. var data = getData(other);
  6940. return !!data && func === data[0];
  6941. }
  6942. /**
  6943. * Checks if `func` has its source masked.
  6944. *
  6945. * @private
  6946. * @param {Function} func The function to check.
  6947. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  6948. */
  6949. function isMasked(func) {
  6950. return !!maskSrcKey && (maskSrcKey in func);
  6951. }
  6952. /**
  6953. * Checks if `func` is capable of being masked.
  6954. *
  6955. * @private
  6956. * @param {*} value The value to check.
  6957. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  6958. */
  6959. var isMaskable = coreJsData ? isFunction : stubFalse;
  6960. /**
  6961. * Checks if `value` is likely a prototype object.
  6962. *
  6963. * @private
  6964. * @param {*} value The value to check.
  6965. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  6966. */
  6967. function isPrototype(value) {
  6968. var Ctor = value && value.constructor,
  6969. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  6970. return value === proto;
  6971. }
  6972. /**
  6973. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  6974. *
  6975. * @private
  6976. * @param {*} value The value to check.
  6977. * @returns {boolean} Returns `true` if `value` if suitable for strict
  6978. * equality comparisons, else `false`.
  6979. */
  6980. function isStrictComparable(value) {
  6981. return value === value && !isObject(value);
  6982. }
  6983. /**
  6984. * A specialized version of `matchesProperty` for source values suitable
  6985. * for strict equality comparisons, i.e. `===`.
  6986. *
  6987. * @private
  6988. * @param {string} key The key of the property to get.
  6989. * @param {*} srcValue The value to match.
  6990. * @returns {Function} Returns the new spec function.
  6991. */
  6992. function matchesStrictComparable(key, srcValue) {
  6993. return function(object) {
  6994. if (object == null) {
  6995. return false;
  6996. }
  6997. return object[key] === srcValue &&
  6998. (srcValue !== undefined || (key in Object(object)));
  6999. };
  7000. }
  7001. /**
  7002. * A specialized version of `_.memoize` which clears the memoized function's
  7003. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  7004. *
  7005. * @private
  7006. * @param {Function} func The function to have its output memoized.
  7007. * @returns {Function} Returns the new memoized function.
  7008. */
  7009. function memoizeCapped(func) {
  7010. var result = memoize(func, function(key) {
  7011. if (cache.size === MAX_MEMOIZE_SIZE) {
  7012. cache.clear();
  7013. }
  7014. return key;
  7015. });
  7016. var cache = result.cache;
  7017. return result;
  7018. }
  7019. /**
  7020. * Merges the function metadata of `source` into `data`.
  7021. *
  7022. * Merging metadata reduces the number of wrappers used to invoke a function.
  7023. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  7024. * may be applied regardless of execution order. Methods like `_.ary` and
  7025. * `_.rearg` modify function arguments, making the order in which they are
  7026. * executed important, preventing the merging of metadata. However, we make
  7027. * an exception for a safe combined case where curried functions have `_.ary`
  7028. * and or `_.rearg` applied.
  7029. *
  7030. * @private
  7031. * @param {Array} data The destination metadata.
  7032. * @param {Array} source The source metadata.
  7033. * @returns {Array} Returns `data`.
  7034. */
  7035. function mergeData(data, source) {
  7036. var bitmask = data[1],
  7037. srcBitmask = source[1],
  7038. newBitmask = bitmask | srcBitmask,
  7039. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  7040. var isCombo =
  7041. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  7042. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  7043. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  7044. // Exit early if metadata can't be merged.
  7045. if (!(isCommon || isCombo)) {
  7046. return data;
  7047. }
  7048. // Use source `thisArg` if available.
  7049. if (srcBitmask & WRAP_BIND_FLAG) {
  7050. data[2] = source[2];
  7051. // Set when currying a bound function.
  7052. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  7053. }
  7054. // Compose partial arguments.
  7055. var value = source[3];
  7056. if (value) {
  7057. var partials = data[3];
  7058. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  7059. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  7060. }
  7061. // Compose partial right arguments.
  7062. value = source[5];
  7063. if (value) {
  7064. partials = data[5];
  7065. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  7066. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  7067. }
  7068. // Use source `argPos` if available.
  7069. value = source[7];
  7070. if (value) {
  7071. data[7] = value;
  7072. }
  7073. // Use source `ary` if it's smaller.
  7074. if (srcBitmask & WRAP_ARY_FLAG) {
  7075. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  7076. }
  7077. // Use source `arity` if one is not provided.
  7078. if (data[9] == null) {
  7079. data[9] = source[9];
  7080. }
  7081. // Use source `func` and merge bitmasks.
  7082. data[0] = source[0];
  7083. data[1] = newBitmask;
  7084. return data;
  7085. }
  7086. /**
  7087. * This function is like
  7088. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  7089. * except that it includes inherited enumerable properties.
  7090. *
  7091. * @private
  7092. * @param {Object} object The object to query.
  7093. * @returns {Array} Returns the array of property names.
  7094. */
  7095. function nativeKeysIn(object) {
  7096. var result = [];
  7097. if (object != null) {
  7098. for (var key in Object(object)) {
  7099. result.push(key);
  7100. }
  7101. }
  7102. return result;
  7103. }
  7104. /**
  7105. * Converts `value` to a string using `Object.prototype.toString`.
  7106. *
  7107. * @private
  7108. * @param {*} value The value to convert.
  7109. * @returns {string} Returns the converted string.
  7110. */
  7111. function objectToString(value) {
  7112. return nativeObjectToString.call(value);
  7113. }
  7114. /**
  7115. * A specialized version of `baseRest` which transforms the rest array.
  7116. *
  7117. * @private
  7118. * @param {Function} func The function to apply a rest parameter to.
  7119. * @param {number} [start=func.length-1] The start position of the rest parameter.
  7120. * @param {Function} transform The rest array transform.
  7121. * @returns {Function} Returns the new function.
  7122. */
  7123. function overRest(func, start, transform) {
  7124. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  7125. return function() {
  7126. var args = arguments,
  7127. index = -1,
  7128. length = nativeMax(args.length - start, 0),
  7129. array = Array(length);
  7130. while (++index < length) {
  7131. array[index] = args[start + index];
  7132. }
  7133. index = -1;
  7134. var otherArgs = Array(start + 1);
  7135. while (++index < start) {
  7136. otherArgs[index] = args[index];
  7137. }
  7138. otherArgs[start] = transform(array);
  7139. return apply(func, this, otherArgs);
  7140. };
  7141. }
  7142. /**
  7143. * Gets the parent value at `path` of `object`.
  7144. *
  7145. * @private
  7146. * @param {Object} object The object to query.
  7147. * @param {Array} path The path to get the parent value of.
  7148. * @returns {*} Returns the parent value.
  7149. */
  7150. function parent(object, path) {
  7151. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  7152. }
  7153. /**
  7154. * Reorder `array` according to the specified indexes where the element at
  7155. * the first index is assigned as the first element, the element at
  7156. * the second index is assigned as the second element, and so on.
  7157. *
  7158. * @private
  7159. * @param {Array} array The array to reorder.
  7160. * @param {Array} indexes The arranged array indexes.
  7161. * @returns {Array} Returns `array`.
  7162. */
  7163. function reorder(array, indexes) {
  7164. var arrLength = array.length,
  7165. length = nativeMin(indexes.length, arrLength),
  7166. oldArray = copyArray(array);
  7167. while (length--) {
  7168. var index = indexes[length];
  7169. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  7170. }
  7171. return array;
  7172. }
  7173. /**
  7174. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  7175. *
  7176. * @private
  7177. * @param {Object} object The object to query.
  7178. * @param {string} key The key of the property to get.
  7179. * @returns {*} Returns the property value.
  7180. */
  7181. function safeGet(object, key) {
  7182. if (key === 'constructor' && typeof object[key] === 'function') {
  7183. return;
  7184. }
  7185. if (key == '__proto__') {
  7186. return;
  7187. }
  7188. return object[key];
  7189. }
  7190. /**
  7191. * Sets metadata for `func`.
  7192. *
  7193. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  7194. * period of time, it will trip its breaker and transition to an identity
  7195. * function to avoid garbage collection pauses in V8. See
  7196. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  7197. * for more details.
  7198. *
  7199. * @private
  7200. * @param {Function} func The function to associate metadata with.
  7201. * @param {*} data The metadata.
  7202. * @returns {Function} Returns `func`.
  7203. */
  7204. var setData = shortOut(baseSetData);
  7205. /**
  7206. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  7207. *
  7208. * @private
  7209. * @param {Function} func The function to delay.
  7210. * @param {number} wait The number of milliseconds to delay invocation.
  7211. * @returns {number|Object} Returns the timer id or timeout object.
  7212. */
  7213. var setTimeout = ctxSetTimeout || function(func, wait) {
  7214. return root.setTimeout(func, wait);
  7215. };
  7216. /**
  7217. * Sets the `toString` method of `func` to return `string`.
  7218. *
  7219. * @private
  7220. * @param {Function} func The function to modify.
  7221. * @param {Function} string The `toString` result.
  7222. * @returns {Function} Returns `func`.
  7223. */
  7224. var setToString = shortOut(baseSetToString);
  7225. /**
  7226. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  7227. * with wrapper details in a comment at the top of the source body.
  7228. *
  7229. * @private
  7230. * @param {Function} wrapper The function to modify.
  7231. * @param {Function} reference The reference function.
  7232. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7233. * @returns {Function} Returns `wrapper`.
  7234. */
  7235. function setWrapToString(wrapper, reference, bitmask) {
  7236. var source = (reference + '');
  7237. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  7238. }
  7239. /**
  7240. * Creates a function that'll short out and invoke `identity` instead
  7241. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  7242. * milliseconds.
  7243. *
  7244. * @private
  7245. * @param {Function} func The function to restrict.
  7246. * @returns {Function} Returns the new shortable function.
  7247. */
  7248. function shortOut(func) {
  7249. var count = 0,
  7250. lastCalled = 0;
  7251. return function() {
  7252. var stamp = nativeNow(),
  7253. remaining = HOT_SPAN - (stamp - lastCalled);
  7254. lastCalled = stamp;
  7255. if (remaining > 0) {
  7256. if (++count >= HOT_COUNT) {
  7257. return arguments[0];
  7258. }
  7259. } else {
  7260. count = 0;
  7261. }
  7262. return func.apply(undefined, arguments);
  7263. };
  7264. }
  7265. /**
  7266. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  7267. *
  7268. * @private
  7269. * @param {Array} array The array to shuffle.
  7270. * @param {number} [size=array.length] The size of `array`.
  7271. * @returns {Array} Returns `array`.
  7272. */
  7273. function shuffleSelf(array, size) {
  7274. var index = -1,
  7275. length = array.length,
  7276. lastIndex = length - 1;
  7277. size = size === undefined ? length : size;
  7278. while (++index < size) {
  7279. var rand = baseRandom(index, lastIndex),
  7280. value = array[rand];
  7281. array[rand] = array[index];
  7282. array[index] = value;
  7283. }
  7284. array.length = size;
  7285. return array;
  7286. }
  7287. /**
  7288. * Converts `string` to a property path array.
  7289. *
  7290. * @private
  7291. * @param {string} string The string to convert.
  7292. * @returns {Array} Returns the property path array.
  7293. */
  7294. var stringToPath = memoizeCapped(function(string) {
  7295. var result = [];
  7296. if (string.charCodeAt(0) === 46 /* . */) {
  7297. result.push('');
  7298. }
  7299. string.replace(rePropName, function(match, number, quote, subString) {
  7300. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  7301. });
  7302. return result;
  7303. });
  7304. /**
  7305. * Converts `value` to a string key if it's not a string or symbol.
  7306. *
  7307. * @private
  7308. * @param {*} value The value to inspect.
  7309. * @returns {string|symbol} Returns the key.
  7310. */
  7311. function toKey(value) {
  7312. if (typeof value == 'string' || isSymbol(value)) {
  7313. return value;
  7314. }
  7315. var result = (value + '');
  7316. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  7317. }
  7318. /**
  7319. * Converts `func` to its source code.
  7320. *
  7321. * @private
  7322. * @param {Function} func The function to convert.
  7323. * @returns {string} Returns the source code.
  7324. */
  7325. function toSource(func) {
  7326. if (func != null) {
  7327. try {
  7328. return funcToString.call(func);
  7329. } catch (e) {}
  7330. try {
  7331. return (func + '');
  7332. } catch (e) {}
  7333. }
  7334. return '';
  7335. }
  7336. /**
  7337. * Updates wrapper `details` based on `bitmask` flags.
  7338. *
  7339. * @private
  7340. * @returns {Array} details The details to modify.
  7341. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7342. * @returns {Array} Returns `details`.
  7343. */
  7344. function updateWrapDetails(details, bitmask) {
  7345. arrayEach(wrapFlags, function(pair) {
  7346. var value = '_.' + pair[0];
  7347. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  7348. details.push(value);
  7349. }
  7350. });
  7351. return details.sort();
  7352. }
  7353. /**
  7354. * Creates a clone of `wrapper`.
  7355. *
  7356. * @private
  7357. * @param {Object} wrapper The wrapper to clone.
  7358. * @returns {Object} Returns the cloned wrapper.
  7359. */
  7360. function wrapperClone(wrapper) {
  7361. if (wrapper instanceof LazyWrapper) {
  7362. return wrapper.clone();
  7363. }
  7364. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  7365. result.__actions__ = copyArray(wrapper.__actions__);
  7366. result.__index__ = wrapper.__index__;
  7367. result.__values__ = wrapper.__values__;
  7368. return result;
  7369. }
  7370. /*------------------------------------------------------------------------*/
  7371. /**
  7372. * Creates an array of elements split into groups the length of `size`.
  7373. * If `array` can't be split evenly, the final chunk will be the remaining
  7374. * elements.
  7375. *
  7376. * @static
  7377. * @memberOf _
  7378. * @since 3.0.0
  7379. * @category Array
  7380. * @param {Array} array The array to process.
  7381. * @param {number} [size=1] The length of each chunk
  7382. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7383. * @returns {Array} Returns the new array of chunks.
  7384. * @example
  7385. *
  7386. * _.chunk(['a', 'b', 'c', 'd'], 2);
  7387. * // => [['a', 'b'], ['c', 'd']]
  7388. *
  7389. * _.chunk(['a', 'b', 'c', 'd'], 3);
  7390. * // => [['a', 'b', 'c'], ['d']]
  7391. */
  7392. function chunk(array, size, guard) {
  7393. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  7394. size = 1;
  7395. } else {
  7396. size = nativeMax(toInteger(size), 0);
  7397. }
  7398. var length = array == null ? 0 : array.length;
  7399. if (!length || size < 1) {
  7400. return [];
  7401. }
  7402. var index = 0,
  7403. resIndex = 0,
  7404. result = Array(nativeCeil(length / size));
  7405. while (index < length) {
  7406. result[resIndex++] = baseSlice(array, index, (index += size));
  7407. }
  7408. return result;
  7409. }
  7410. /**
  7411. * Creates an array with all falsey values removed. The values `false`, `null`,
  7412. * `0`, `""`, `undefined`, and `NaN` are falsey.
  7413. *
  7414. * @static
  7415. * @memberOf _
  7416. * @since 0.1.0
  7417. * @category Array
  7418. * @param {Array} array The array to compact.
  7419. * @returns {Array} Returns the new array of filtered values.
  7420. * @example
  7421. *
  7422. * _.compact([0, 1, false, 2, '', 3]);
  7423. * // => [1, 2, 3]
  7424. */
  7425. function compact(array) {
  7426. var index = -1,
  7427. length = array == null ? 0 : array.length,
  7428. resIndex = 0,
  7429. result = [];
  7430. while (++index < length) {
  7431. var value = array[index];
  7432. if (value) {
  7433. result[resIndex++] = value;
  7434. }
  7435. }
  7436. return result;
  7437. }
  7438. /**
  7439. * Creates a new array concatenating `array` with any additional arrays
  7440. * and/or values.
  7441. *
  7442. * @static
  7443. * @memberOf _
  7444. * @since 4.0.0
  7445. * @category Array
  7446. * @param {Array} array The array to concatenate.
  7447. * @param {...*} [values] The values to concatenate.
  7448. * @returns {Array} Returns the new concatenated array.
  7449. * @example
  7450. *
  7451. * var array = [1];
  7452. * var other = _.concat(array, 2, [3], [[4]]);
  7453. *
  7454. * console.log(other);
  7455. * // => [1, 2, 3, [4]]
  7456. *
  7457. * console.log(array);
  7458. * // => [1]
  7459. */
  7460. function concat() {
  7461. var length = arguments.length;
  7462. if (!length) {
  7463. return [];
  7464. }
  7465. var args = Array(length - 1),
  7466. array = arguments[0],
  7467. index = length;
  7468. while (index--) {
  7469. args[index - 1] = arguments[index];
  7470. }
  7471. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  7472. }
  7473. /**
  7474. * Creates an array of `array` values not included in the other given arrays
  7475. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7476. * for equality comparisons. The order and references of result values are
  7477. * determined by the first array.
  7478. *
  7479. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  7480. *
  7481. * @static
  7482. * @memberOf _
  7483. * @since 0.1.0
  7484. * @category Array
  7485. * @param {Array} array The array to inspect.
  7486. * @param {...Array} [values] The values to exclude.
  7487. * @returns {Array} Returns the new array of filtered values.
  7488. * @see _.without, _.xor
  7489. * @example
  7490. *
  7491. * _.difference([2, 1], [2, 3]);
  7492. * // => [1]
  7493. */
  7494. var difference = baseRest(function(array, values) {
  7495. return isArrayLikeObject(array)
  7496. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  7497. : [];
  7498. });
  7499. /**
  7500. * This method is like `_.difference` except that it accepts `iteratee` which
  7501. * is invoked for each element of `array` and `values` to generate the criterion
  7502. * by which they're compared. The order and references of result values are
  7503. * determined by the first array. The iteratee is invoked with one argument:
  7504. * (value).
  7505. *
  7506. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  7507. *
  7508. * @static
  7509. * @memberOf _
  7510. * @since 4.0.0
  7511. * @category Array
  7512. * @param {Array} array The array to inspect.
  7513. * @param {...Array} [values] The values to exclude.
  7514. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7515. * @returns {Array} Returns the new array of filtered values.
  7516. * @example
  7517. *
  7518. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7519. * // => [1.2]
  7520. *
  7521. * // The `_.property` iteratee shorthand.
  7522. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  7523. * // => [{ 'x': 2 }]
  7524. */
  7525. var differenceBy = baseRest(function(array, values) {
  7526. var iteratee = last(values);
  7527. if (isArrayLikeObject(iteratee)) {
  7528. iteratee = undefined;
  7529. }
  7530. return isArrayLikeObject(array)
  7531. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  7532. : [];
  7533. });
  7534. /**
  7535. * This method is like `_.difference` except that it accepts `comparator`
  7536. * which is invoked to compare elements of `array` to `values`. The order and
  7537. * references of result values are determined by the first array. The comparator
  7538. * is invoked with two arguments: (arrVal, othVal).
  7539. *
  7540. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  7541. *
  7542. * @static
  7543. * @memberOf _
  7544. * @since 4.0.0
  7545. * @category Array
  7546. * @param {Array} array The array to inspect.
  7547. * @param {...Array} [values] The values to exclude.
  7548. * @param {Function} [comparator] The comparator invoked per element.
  7549. * @returns {Array} Returns the new array of filtered values.
  7550. * @example
  7551. *
  7552. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  7553. *
  7554. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  7555. * // => [{ 'x': 2, 'y': 1 }]
  7556. */
  7557. var differenceWith = baseRest(function(array, values) {
  7558. var comparator = last(values);
  7559. if (isArrayLikeObject(comparator)) {
  7560. comparator = undefined;
  7561. }
  7562. return isArrayLikeObject(array)
  7563. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  7564. : [];
  7565. });
  7566. /**
  7567. * Creates a slice of `array` with `n` elements dropped from the beginning.
  7568. *
  7569. * @static
  7570. * @memberOf _
  7571. * @since 0.5.0
  7572. * @category Array
  7573. * @param {Array} array The array to query.
  7574. * @param {number} [n=1] The number of elements to drop.
  7575. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7576. * @returns {Array} Returns the slice of `array`.
  7577. * @example
  7578. *
  7579. * _.drop([1, 2, 3]);
  7580. * // => [2, 3]
  7581. *
  7582. * _.drop([1, 2, 3], 2);
  7583. * // => [3]
  7584. *
  7585. * _.drop([1, 2, 3], 5);
  7586. * // => []
  7587. *
  7588. * _.drop([1, 2, 3], 0);
  7589. * // => [1, 2, 3]
  7590. */
  7591. function drop(array, n, guard) {
  7592. var length = array == null ? 0 : array.length;
  7593. if (!length) {
  7594. return [];
  7595. }
  7596. n = (guard || n === undefined) ? 1 : toInteger(n);
  7597. return baseSlice(array, n < 0 ? 0 : n, length);
  7598. }
  7599. /**
  7600. * Creates a slice of `array` with `n` elements dropped from the end.
  7601. *
  7602. * @static
  7603. * @memberOf _
  7604. * @since 3.0.0
  7605. * @category Array
  7606. * @param {Array} array The array to query.
  7607. * @param {number} [n=1] The number of elements to drop.
  7608. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7609. * @returns {Array} Returns the slice of `array`.
  7610. * @example
  7611. *
  7612. * _.dropRight([1, 2, 3]);
  7613. * // => [1, 2]
  7614. *
  7615. * _.dropRight([1, 2, 3], 2);
  7616. * // => [1]
  7617. *
  7618. * _.dropRight([1, 2, 3], 5);
  7619. * // => []
  7620. *
  7621. * _.dropRight([1, 2, 3], 0);
  7622. * // => [1, 2, 3]
  7623. */
  7624. function dropRight(array, n, guard) {
  7625. var length = array == null ? 0 : array.length;
  7626. if (!length) {
  7627. return [];
  7628. }
  7629. n = (guard || n === undefined) ? 1 : toInteger(n);
  7630. n = length - n;
  7631. return baseSlice(array, 0, n < 0 ? 0 : n);
  7632. }
  7633. /**
  7634. * Creates a slice of `array` excluding elements dropped from the end.
  7635. * Elements are dropped until `predicate` returns falsey. The predicate is
  7636. * invoked with three arguments: (value, index, array).
  7637. *
  7638. * @static
  7639. * @memberOf _
  7640. * @since 3.0.0
  7641. * @category Array
  7642. * @param {Array} array The array to query.
  7643. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7644. * @returns {Array} Returns the slice of `array`.
  7645. * @example
  7646. *
  7647. * var users = [
  7648. * { 'user': 'barney', 'active': true },
  7649. * { 'user': 'fred', 'active': false },
  7650. * { 'user': 'pebbles', 'active': false }
  7651. * ];
  7652. *
  7653. * _.dropRightWhile(users, function(o) { return !o.active; });
  7654. * // => objects for ['barney']
  7655. *
  7656. * // The `_.matches` iteratee shorthand.
  7657. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  7658. * // => objects for ['barney', 'fred']
  7659. *
  7660. * // The `_.matchesProperty` iteratee shorthand.
  7661. * _.dropRightWhile(users, ['active', false]);
  7662. * // => objects for ['barney']
  7663. *
  7664. * // The `_.property` iteratee shorthand.
  7665. * _.dropRightWhile(users, 'active');
  7666. * // => objects for ['barney', 'fred', 'pebbles']
  7667. */
  7668. function dropRightWhile(array, predicate) {
  7669. return (array && array.length)
  7670. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  7671. : [];
  7672. }
  7673. /**
  7674. * Creates a slice of `array` excluding elements dropped from the beginning.
  7675. * Elements are dropped until `predicate` returns falsey. The predicate is
  7676. * invoked with three arguments: (value, index, array).
  7677. *
  7678. * @static
  7679. * @memberOf _
  7680. * @since 3.0.0
  7681. * @category Array
  7682. * @param {Array} array The array to query.
  7683. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7684. * @returns {Array} Returns the slice of `array`.
  7685. * @example
  7686. *
  7687. * var users = [
  7688. * { 'user': 'barney', 'active': false },
  7689. * { 'user': 'fred', 'active': false },
  7690. * { 'user': 'pebbles', 'active': true }
  7691. * ];
  7692. *
  7693. * _.dropWhile(users, function(o) { return !o.active; });
  7694. * // => objects for ['pebbles']
  7695. *
  7696. * // The `_.matches` iteratee shorthand.
  7697. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  7698. * // => objects for ['fred', 'pebbles']
  7699. *
  7700. * // The `_.matchesProperty` iteratee shorthand.
  7701. * _.dropWhile(users, ['active', false]);
  7702. * // => objects for ['pebbles']
  7703. *
  7704. * // The `_.property` iteratee shorthand.
  7705. * _.dropWhile(users, 'active');
  7706. * // => objects for ['barney', 'fred', 'pebbles']
  7707. */
  7708. function dropWhile(array, predicate) {
  7709. return (array && array.length)
  7710. ? baseWhile(array, getIteratee(predicate, 3), true)
  7711. : [];
  7712. }
  7713. /**
  7714. * Fills elements of `array` with `value` from `start` up to, but not
  7715. * including, `end`.
  7716. *
  7717. * **Note:** This method mutates `array`.
  7718. *
  7719. * @static
  7720. * @memberOf _
  7721. * @since 3.2.0
  7722. * @category Array
  7723. * @param {Array} array The array to fill.
  7724. * @param {*} value The value to fill `array` with.
  7725. * @param {number} [start=0] The start position.
  7726. * @param {number} [end=array.length] The end position.
  7727. * @returns {Array} Returns `array`.
  7728. * @example
  7729. *
  7730. * var array = [1, 2, 3];
  7731. *
  7732. * _.fill(array, 'a');
  7733. * console.log(array);
  7734. * // => ['a', 'a', 'a']
  7735. *
  7736. * _.fill(Array(3), 2);
  7737. * // => [2, 2, 2]
  7738. *
  7739. * _.fill([4, 6, 8, 10], '*', 1, 3);
  7740. * // => [4, '*', '*', 10]
  7741. */
  7742. function fill(array, value, start, end) {
  7743. var length = array == null ? 0 : array.length;
  7744. if (!length) {
  7745. return [];
  7746. }
  7747. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  7748. start = 0;
  7749. end = length;
  7750. }
  7751. return baseFill(array, value, start, end);
  7752. }
  7753. /**
  7754. * This method is like `_.find` except that it returns the index of the first
  7755. * element `predicate` returns truthy for instead of the element itself.
  7756. *
  7757. * @static
  7758. * @memberOf _
  7759. * @since 1.1.0
  7760. * @category Array
  7761. * @param {Array} array The array to inspect.
  7762. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7763. * @param {number} [fromIndex=0] The index to search from.
  7764. * @returns {number} Returns the index of the found element, else `-1`.
  7765. * @example
  7766. *
  7767. * var users = [
  7768. * { 'user': 'barney', 'active': false },
  7769. * { 'user': 'fred', 'active': false },
  7770. * { 'user': 'pebbles', 'active': true }
  7771. * ];
  7772. *
  7773. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  7774. * // => 0
  7775. *
  7776. * // The `_.matches` iteratee shorthand.
  7777. * _.findIndex(users, { 'user': 'fred', 'active': false });
  7778. * // => 1
  7779. *
  7780. * // The `_.matchesProperty` iteratee shorthand.
  7781. * _.findIndex(users, ['active', false]);
  7782. * // => 0
  7783. *
  7784. * // The `_.property` iteratee shorthand.
  7785. * _.findIndex(users, 'active');
  7786. * // => 2
  7787. */
  7788. function findIndex(array, predicate, fromIndex) {
  7789. var length = array == null ? 0 : array.length;
  7790. if (!length) {
  7791. return -1;
  7792. }
  7793. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7794. if (index < 0) {
  7795. index = nativeMax(length + index, 0);
  7796. }
  7797. return baseFindIndex(array, getIteratee(predicate, 3), index);
  7798. }
  7799. /**
  7800. * This method is like `_.findIndex` except that it iterates over elements
  7801. * of `collection` from right to left.
  7802. *
  7803. * @static
  7804. * @memberOf _
  7805. * @since 2.0.0
  7806. * @category Array
  7807. * @param {Array} array The array to inspect.
  7808. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  7809. * @param {number} [fromIndex=array.length-1] The index to search from.
  7810. * @returns {number} Returns the index of the found element, else `-1`.
  7811. * @example
  7812. *
  7813. * var users = [
  7814. * { 'user': 'barney', 'active': true },
  7815. * { 'user': 'fred', 'active': false },
  7816. * { 'user': 'pebbles', 'active': false }
  7817. * ];
  7818. *
  7819. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  7820. * // => 2
  7821. *
  7822. * // The `_.matches` iteratee shorthand.
  7823. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  7824. * // => 0
  7825. *
  7826. * // The `_.matchesProperty` iteratee shorthand.
  7827. * _.findLastIndex(users, ['active', false]);
  7828. * // => 2
  7829. *
  7830. * // The `_.property` iteratee shorthand.
  7831. * _.findLastIndex(users, 'active');
  7832. * // => 0
  7833. */
  7834. function findLastIndex(array, predicate, fromIndex) {
  7835. var length = array == null ? 0 : array.length;
  7836. if (!length) {
  7837. return -1;
  7838. }
  7839. var index = length - 1;
  7840. if (fromIndex !== undefined) {
  7841. index = toInteger(fromIndex);
  7842. index = fromIndex < 0
  7843. ? nativeMax(length + index, 0)
  7844. : nativeMin(index, length - 1);
  7845. }
  7846. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  7847. }
  7848. /**
  7849. * Flattens `array` a single level deep.
  7850. *
  7851. * @static
  7852. * @memberOf _
  7853. * @since 0.1.0
  7854. * @category Array
  7855. * @param {Array} array The array to flatten.
  7856. * @returns {Array} Returns the new flattened array.
  7857. * @example
  7858. *
  7859. * _.flatten([1, [2, [3, [4]], 5]]);
  7860. * // => [1, 2, [3, [4]], 5]
  7861. */
  7862. function flatten(array) {
  7863. var length = array == null ? 0 : array.length;
  7864. return length ? baseFlatten(array, 1) : [];
  7865. }
  7866. /**
  7867. * Recursively flattens `array`.
  7868. *
  7869. * @static
  7870. * @memberOf _
  7871. * @since 3.0.0
  7872. * @category Array
  7873. * @param {Array} array The array to flatten.
  7874. * @returns {Array} Returns the new flattened array.
  7875. * @example
  7876. *
  7877. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  7878. * // => [1, 2, 3, 4, 5]
  7879. */
  7880. function flattenDeep(array) {
  7881. var length = array == null ? 0 : array.length;
  7882. return length ? baseFlatten(array, INFINITY) : [];
  7883. }
  7884. /**
  7885. * Recursively flatten `array` up to `depth` times.
  7886. *
  7887. * @static
  7888. * @memberOf _
  7889. * @since 4.4.0
  7890. * @category Array
  7891. * @param {Array} array The array to flatten.
  7892. * @param {number} [depth=1] The maximum recursion depth.
  7893. * @returns {Array} Returns the new flattened array.
  7894. * @example
  7895. *
  7896. * var array = [1, [2, [3, [4]], 5]];
  7897. *
  7898. * _.flattenDepth(array, 1);
  7899. * // => [1, 2, [3, [4]], 5]
  7900. *
  7901. * _.flattenDepth(array, 2);
  7902. * // => [1, 2, 3, [4], 5]
  7903. */
  7904. function flattenDepth(array, depth) {
  7905. var length = array == null ? 0 : array.length;
  7906. if (!length) {
  7907. return [];
  7908. }
  7909. depth = depth === undefined ? 1 : toInteger(depth);
  7910. return baseFlatten(array, depth);
  7911. }
  7912. /**
  7913. * The inverse of `_.toPairs`; this method returns an object composed
  7914. * from key-value `pairs`.
  7915. *
  7916. * @static
  7917. * @memberOf _
  7918. * @since 4.0.0
  7919. * @category Array
  7920. * @param {Array} pairs The key-value pairs.
  7921. * @returns {Object} Returns the new object.
  7922. * @example
  7923. *
  7924. * _.fromPairs([['a', 1], ['b', 2]]);
  7925. * // => { 'a': 1, 'b': 2 }
  7926. */
  7927. function fromPairs(pairs) {
  7928. var index = -1,
  7929. length = pairs == null ? 0 : pairs.length,
  7930. result = {};
  7931. while (++index < length) {
  7932. var pair = pairs[index];
  7933. result[pair[0]] = pair[1];
  7934. }
  7935. return result;
  7936. }
  7937. /**
  7938. * Gets the first element of `array`.
  7939. *
  7940. * @static
  7941. * @memberOf _
  7942. * @since 0.1.0
  7943. * @alias first
  7944. * @category Array
  7945. * @param {Array} array The array to query.
  7946. * @returns {*} Returns the first element of `array`.
  7947. * @example
  7948. *
  7949. * _.head([1, 2, 3]);
  7950. * // => 1
  7951. *
  7952. * _.head([]);
  7953. * // => undefined
  7954. */
  7955. function head(array) {
  7956. return (array && array.length) ? array[0] : undefined;
  7957. }
  7958. /**
  7959. * Gets the index at which the first occurrence of `value` is found in `array`
  7960. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7961. * for equality comparisons. If `fromIndex` is negative, it's used as the
  7962. * offset from the end of `array`.
  7963. *
  7964. * @static
  7965. * @memberOf _
  7966. * @since 0.1.0
  7967. * @category Array
  7968. * @param {Array} array The array to inspect.
  7969. * @param {*} value The value to search for.
  7970. * @param {number} [fromIndex=0] The index to search from.
  7971. * @returns {number} Returns the index of the matched value, else `-1`.
  7972. * @example
  7973. *
  7974. * _.indexOf([1, 2, 1, 2], 2);
  7975. * // => 1
  7976. *
  7977. * // Search from the `fromIndex`.
  7978. * _.indexOf([1, 2, 1, 2], 2, 2);
  7979. * // => 3
  7980. */
  7981. function indexOf(array, value, fromIndex) {
  7982. var length = array == null ? 0 : array.length;
  7983. if (!length) {
  7984. return -1;
  7985. }
  7986. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  7987. if (index < 0) {
  7988. index = nativeMax(length + index, 0);
  7989. }
  7990. return baseIndexOf(array, value, index);
  7991. }
  7992. /**
  7993. * Gets all but the last element of `array`.
  7994. *
  7995. * @static
  7996. * @memberOf _
  7997. * @since 0.1.0
  7998. * @category Array
  7999. * @param {Array} array The array to query.
  8000. * @returns {Array} Returns the slice of `array`.
  8001. * @example
  8002. *
  8003. * _.initial([1, 2, 3]);
  8004. * // => [1, 2]
  8005. */
  8006. function initial(array) {
  8007. var length = array == null ? 0 : array.length;
  8008. return length ? baseSlice(array, 0, -1) : [];
  8009. }
  8010. /**
  8011. * Creates an array of unique values that are included in all given arrays
  8012. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8013. * for equality comparisons. The order and references of result values are
  8014. * determined by the first array.
  8015. *
  8016. * @static
  8017. * @memberOf _
  8018. * @since 0.1.0
  8019. * @category Array
  8020. * @param {...Array} [arrays] The arrays to inspect.
  8021. * @returns {Array} Returns the new array of intersecting values.
  8022. * @example
  8023. *
  8024. * _.intersection([2, 1], [2, 3]);
  8025. * // => [2]
  8026. */
  8027. var intersection = baseRest(function(arrays) {
  8028. var mapped = arrayMap(arrays, castArrayLikeObject);
  8029. return (mapped.length && mapped[0] === arrays[0])
  8030. ? baseIntersection(mapped)
  8031. : [];
  8032. });
  8033. /**
  8034. * This method is like `_.intersection` except that it accepts `iteratee`
  8035. * which is invoked for each element of each `arrays` to generate the criterion
  8036. * by which they're compared. The order and references of result values are
  8037. * determined by the first array. The iteratee is invoked with one argument:
  8038. * (value).
  8039. *
  8040. * @static
  8041. * @memberOf _
  8042. * @since 4.0.0
  8043. * @category Array
  8044. * @param {...Array} [arrays] The arrays to inspect.
  8045. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8046. * @returns {Array} Returns the new array of intersecting values.
  8047. * @example
  8048. *
  8049. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8050. * // => [2.1]
  8051. *
  8052. * // The `_.property` iteratee shorthand.
  8053. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8054. * // => [{ 'x': 1 }]
  8055. */
  8056. var intersectionBy = baseRest(function(arrays) {
  8057. var iteratee = last(arrays),
  8058. mapped = arrayMap(arrays, castArrayLikeObject);
  8059. if (iteratee === last(mapped)) {
  8060. iteratee = undefined;
  8061. } else {
  8062. mapped.pop();
  8063. }
  8064. return (mapped.length && mapped[0] === arrays[0])
  8065. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  8066. : [];
  8067. });
  8068. /**
  8069. * This method is like `_.intersection` except that it accepts `comparator`
  8070. * which is invoked to compare elements of `arrays`. The order and references
  8071. * of result values are determined by the first array. The comparator is
  8072. * invoked with two arguments: (arrVal, othVal).
  8073. *
  8074. * @static
  8075. * @memberOf _
  8076. * @since 4.0.0
  8077. * @category Array
  8078. * @param {...Array} [arrays] The arrays to inspect.
  8079. * @param {Function} [comparator] The comparator invoked per element.
  8080. * @returns {Array} Returns the new array of intersecting values.
  8081. * @example
  8082. *
  8083. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8084. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8085. *
  8086. * _.intersectionWith(objects, others, _.isEqual);
  8087. * // => [{ 'x': 1, 'y': 2 }]
  8088. */
  8089. var intersectionWith = baseRest(function(arrays) {
  8090. var comparator = last(arrays),
  8091. mapped = arrayMap(arrays, castArrayLikeObject);
  8092. comparator = typeof comparator == 'function' ? comparator : undefined;
  8093. if (comparator) {
  8094. mapped.pop();
  8095. }
  8096. return (mapped.length && mapped[0] === arrays[0])
  8097. ? baseIntersection(mapped, undefined, comparator)
  8098. : [];
  8099. });
  8100. /**
  8101. * Converts all elements in `array` into a string separated by `separator`.
  8102. *
  8103. * @static
  8104. * @memberOf _
  8105. * @since 4.0.0
  8106. * @category Array
  8107. * @param {Array} array The array to convert.
  8108. * @param {string} [separator=','] The element separator.
  8109. * @returns {string} Returns the joined string.
  8110. * @example
  8111. *
  8112. * _.join(['a', 'b', 'c'], '~');
  8113. * // => 'a~b~c'
  8114. */
  8115. function join(array, separator) {
  8116. return array == null ? '' : nativeJoin.call(array, separator);
  8117. }
  8118. /**
  8119. * Gets the last element of `array`.
  8120. *
  8121. * @static
  8122. * @memberOf _
  8123. * @since 0.1.0
  8124. * @category Array
  8125. * @param {Array} array The array to query.
  8126. * @returns {*} Returns the last element of `array`.
  8127. * @example
  8128. *
  8129. * _.last([1, 2, 3]);
  8130. * // => 3
  8131. */
  8132. function last(array) {
  8133. var length = array == null ? 0 : array.length;
  8134. return length ? array[length - 1] : undefined;
  8135. }
  8136. /**
  8137. * This method is like `_.indexOf` except that it iterates over elements of
  8138. * `array` from right to left.
  8139. *
  8140. * @static
  8141. * @memberOf _
  8142. * @since 0.1.0
  8143. * @category Array
  8144. * @param {Array} array The array to inspect.
  8145. * @param {*} value The value to search for.
  8146. * @param {number} [fromIndex=array.length-1] The index to search from.
  8147. * @returns {number} Returns the index of the matched value, else `-1`.
  8148. * @example
  8149. *
  8150. * _.lastIndexOf([1, 2, 1, 2], 2);
  8151. * // => 3
  8152. *
  8153. * // Search from the `fromIndex`.
  8154. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  8155. * // => 1
  8156. */
  8157. function lastIndexOf(array, value, fromIndex) {
  8158. var length = array == null ? 0 : array.length;
  8159. if (!length) {
  8160. return -1;
  8161. }
  8162. var index = length;
  8163. if (fromIndex !== undefined) {
  8164. index = toInteger(fromIndex);
  8165. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  8166. }
  8167. return value === value
  8168. ? strictLastIndexOf(array, value, index)
  8169. : baseFindIndex(array, baseIsNaN, index, true);
  8170. }
  8171. /**
  8172. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  8173. * element from the end is returned.
  8174. *
  8175. * @static
  8176. * @memberOf _
  8177. * @since 4.11.0
  8178. * @category Array
  8179. * @param {Array} array The array to query.
  8180. * @param {number} [n=0] The index of the element to return.
  8181. * @returns {*} Returns the nth element of `array`.
  8182. * @example
  8183. *
  8184. * var array = ['a', 'b', 'c', 'd'];
  8185. *
  8186. * _.nth(array, 1);
  8187. * // => 'b'
  8188. *
  8189. * _.nth(array, -2);
  8190. * // => 'c';
  8191. */
  8192. function nth(array, n) {
  8193. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  8194. }
  8195. /**
  8196. * Removes all given values from `array` using
  8197. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8198. * for equality comparisons.
  8199. *
  8200. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  8201. * to remove elements from an array by predicate.
  8202. *
  8203. * @static
  8204. * @memberOf _
  8205. * @since 2.0.0
  8206. * @category Array
  8207. * @param {Array} array The array to modify.
  8208. * @param {...*} [values] The values to remove.
  8209. * @returns {Array} Returns `array`.
  8210. * @example
  8211. *
  8212. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8213. *
  8214. * _.pull(array, 'a', 'c');
  8215. * console.log(array);
  8216. * // => ['b', 'b']
  8217. */
  8218. var pull = baseRest(pullAll);
  8219. /**
  8220. * This method is like `_.pull` except that it accepts an array of values to remove.
  8221. *
  8222. * **Note:** Unlike `_.difference`, this method mutates `array`.
  8223. *
  8224. * @static
  8225. * @memberOf _
  8226. * @since 4.0.0
  8227. * @category Array
  8228. * @param {Array} array The array to modify.
  8229. * @param {Array} values The values to remove.
  8230. * @returns {Array} Returns `array`.
  8231. * @example
  8232. *
  8233. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8234. *
  8235. * _.pullAll(array, ['a', 'c']);
  8236. * console.log(array);
  8237. * // => ['b', 'b']
  8238. */
  8239. function pullAll(array, values) {
  8240. return (array && array.length && values && values.length)
  8241. ? basePullAll(array, values)
  8242. : array;
  8243. }
  8244. /**
  8245. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  8246. * invoked for each element of `array` and `values` to generate the criterion
  8247. * by which they're compared. The iteratee is invoked with one argument: (value).
  8248. *
  8249. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  8250. *
  8251. * @static
  8252. * @memberOf _
  8253. * @since 4.0.0
  8254. * @category Array
  8255. * @param {Array} array The array to modify.
  8256. * @param {Array} values The values to remove.
  8257. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8258. * @returns {Array} Returns `array`.
  8259. * @example
  8260. *
  8261. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  8262. *
  8263. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  8264. * console.log(array);
  8265. * // => [{ 'x': 2 }]
  8266. */
  8267. function pullAllBy(array, values, iteratee) {
  8268. return (array && array.length && values && values.length)
  8269. ? basePullAll(array, values, getIteratee(iteratee, 2))
  8270. : array;
  8271. }
  8272. /**
  8273. * This method is like `_.pullAll` except that it accepts `comparator` which
  8274. * is invoked to compare elements of `array` to `values`. The comparator is
  8275. * invoked with two arguments: (arrVal, othVal).
  8276. *
  8277. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  8278. *
  8279. * @static
  8280. * @memberOf _
  8281. * @since 4.6.0
  8282. * @category Array
  8283. * @param {Array} array The array to modify.
  8284. * @param {Array} values The values to remove.
  8285. * @param {Function} [comparator] The comparator invoked per element.
  8286. * @returns {Array} Returns `array`.
  8287. * @example
  8288. *
  8289. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  8290. *
  8291. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  8292. * console.log(array);
  8293. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  8294. */
  8295. function pullAllWith(array, values, comparator) {
  8296. return (array && array.length && values && values.length)
  8297. ? basePullAll(array, values, undefined, comparator)
  8298. : array;
  8299. }
  8300. /**
  8301. * Removes elements from `array` corresponding to `indexes` and returns an
  8302. * array of removed elements.
  8303. *
  8304. * **Note:** Unlike `_.at`, this method mutates `array`.
  8305. *
  8306. * @static
  8307. * @memberOf _
  8308. * @since 3.0.0
  8309. * @category Array
  8310. * @param {Array} array The array to modify.
  8311. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  8312. * @returns {Array} Returns the new array of removed elements.
  8313. * @example
  8314. *
  8315. * var array = ['a', 'b', 'c', 'd'];
  8316. * var pulled = _.pullAt(array, [1, 3]);
  8317. *
  8318. * console.log(array);
  8319. * // => ['a', 'c']
  8320. *
  8321. * console.log(pulled);
  8322. * // => ['b', 'd']
  8323. */
  8324. var pullAt = flatRest(function(array, indexes) {
  8325. var length = array == null ? 0 : array.length,
  8326. result = baseAt(array, indexes);
  8327. basePullAt(array, arrayMap(indexes, function(index) {
  8328. return isIndex(index, length) ? +index : index;
  8329. }).sort(compareAscending));
  8330. return result;
  8331. });
  8332. /**
  8333. * Removes all elements from `array` that `predicate` returns truthy for
  8334. * and returns an array of the removed elements. The predicate is invoked
  8335. * with three arguments: (value, index, array).
  8336. *
  8337. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  8338. * to pull elements from an array by value.
  8339. *
  8340. * @static
  8341. * @memberOf _
  8342. * @since 2.0.0
  8343. * @category Array
  8344. * @param {Array} array The array to modify.
  8345. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8346. * @returns {Array} Returns the new array of removed elements.
  8347. * @example
  8348. *
  8349. * var array = [1, 2, 3, 4];
  8350. * var evens = _.remove(array, function(n) {
  8351. * return n % 2 == 0;
  8352. * });
  8353. *
  8354. * console.log(array);
  8355. * // => [1, 3]
  8356. *
  8357. * console.log(evens);
  8358. * // => [2, 4]
  8359. */
  8360. function remove(array, predicate) {
  8361. var result = [];
  8362. if (!(array && array.length)) {
  8363. return result;
  8364. }
  8365. var index = -1,
  8366. indexes = [],
  8367. length = array.length;
  8368. predicate = getIteratee(predicate, 3);
  8369. while (++index < length) {
  8370. var value = array[index];
  8371. if (predicate(value, index, array)) {
  8372. result.push(value);
  8373. indexes.push(index);
  8374. }
  8375. }
  8376. basePullAt(array, indexes);
  8377. return result;
  8378. }
  8379. /**
  8380. * Reverses `array` so that the first element becomes the last, the second
  8381. * element becomes the second to last, and so on.
  8382. *
  8383. * **Note:** This method mutates `array` and is based on
  8384. * [`Array#reverse`](https://mdn.io/Array/reverse).
  8385. *
  8386. * @static
  8387. * @memberOf _
  8388. * @since 4.0.0
  8389. * @category Array
  8390. * @param {Array} array The array to modify.
  8391. * @returns {Array} Returns `array`.
  8392. * @example
  8393. *
  8394. * var array = [1, 2, 3];
  8395. *
  8396. * _.reverse(array);
  8397. * // => [3, 2, 1]
  8398. *
  8399. * console.log(array);
  8400. * // => [3, 2, 1]
  8401. */
  8402. function reverse(array) {
  8403. return array == null ? array : nativeReverse.call(array);
  8404. }
  8405. /**
  8406. * Creates a slice of `array` from `start` up to, but not including, `end`.
  8407. *
  8408. * **Note:** This method is used instead of
  8409. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  8410. * returned.
  8411. *
  8412. * @static
  8413. * @memberOf _
  8414. * @since 3.0.0
  8415. * @category Array
  8416. * @param {Array} array The array to slice.
  8417. * @param {number} [start=0] The start position.
  8418. * @param {number} [end=array.length] The end position.
  8419. * @returns {Array} Returns the slice of `array`.
  8420. */
  8421. function slice(array, start, end) {
  8422. var length = array == null ? 0 : array.length;
  8423. if (!length) {
  8424. return [];
  8425. }
  8426. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  8427. start = 0;
  8428. end = length;
  8429. }
  8430. else {
  8431. start = start == null ? 0 : toInteger(start);
  8432. end = end === undefined ? length : toInteger(end);
  8433. }
  8434. return baseSlice(array, start, end);
  8435. }
  8436. /**
  8437. * Uses a binary search to determine the lowest index at which `value`
  8438. * should be inserted into `array` in order to maintain its sort order.
  8439. *
  8440. * @static
  8441. * @memberOf _
  8442. * @since 0.1.0
  8443. * @category Array
  8444. * @param {Array} array The sorted array to inspect.
  8445. * @param {*} value The value to evaluate.
  8446. * @returns {number} Returns the index at which `value` should be inserted
  8447. * into `array`.
  8448. * @example
  8449. *
  8450. * _.sortedIndex([30, 50], 40);
  8451. * // => 1
  8452. */
  8453. function sortedIndex(array, value) {
  8454. return baseSortedIndex(array, value);
  8455. }
  8456. /**
  8457. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  8458. * which is invoked for `value` and each element of `array` to compute their
  8459. * sort ranking. The iteratee is invoked with one argument: (value).
  8460. *
  8461. * @static
  8462. * @memberOf _
  8463. * @since 4.0.0
  8464. * @category Array
  8465. * @param {Array} array The sorted array to inspect.
  8466. * @param {*} value The value to evaluate.
  8467. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8468. * @returns {number} Returns the index at which `value` should be inserted
  8469. * into `array`.
  8470. * @example
  8471. *
  8472. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8473. *
  8474. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8475. * // => 0
  8476. *
  8477. * // The `_.property` iteratee shorthand.
  8478. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  8479. * // => 0
  8480. */
  8481. function sortedIndexBy(array, value, iteratee) {
  8482. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  8483. }
  8484. /**
  8485. * This method is like `_.indexOf` except that it performs a binary
  8486. * search on a sorted `array`.
  8487. *
  8488. * @static
  8489. * @memberOf _
  8490. * @since 4.0.0
  8491. * @category Array
  8492. * @param {Array} array The array to inspect.
  8493. * @param {*} value The value to search for.
  8494. * @returns {number} Returns the index of the matched value, else `-1`.
  8495. * @example
  8496. *
  8497. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  8498. * // => 1
  8499. */
  8500. function sortedIndexOf(array, value) {
  8501. var length = array == null ? 0 : array.length;
  8502. if (length) {
  8503. var index = baseSortedIndex(array, value);
  8504. if (index < length && eq(array[index], value)) {
  8505. return index;
  8506. }
  8507. }
  8508. return -1;
  8509. }
  8510. /**
  8511. * This method is like `_.sortedIndex` except that it returns the highest
  8512. * index at which `value` should be inserted into `array` in order to
  8513. * maintain its sort order.
  8514. *
  8515. * @static
  8516. * @memberOf _
  8517. * @since 3.0.0
  8518. * @category Array
  8519. * @param {Array} array The sorted array to inspect.
  8520. * @param {*} value The value to evaluate.
  8521. * @returns {number} Returns the index at which `value` should be inserted
  8522. * into `array`.
  8523. * @example
  8524. *
  8525. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  8526. * // => 4
  8527. */
  8528. function sortedLastIndex(array, value) {
  8529. return baseSortedIndex(array, value, true);
  8530. }
  8531. /**
  8532. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  8533. * which is invoked for `value` and each element of `array` to compute their
  8534. * sort ranking. The iteratee is invoked with one argument: (value).
  8535. *
  8536. * @static
  8537. * @memberOf _
  8538. * @since 4.0.0
  8539. * @category Array
  8540. * @param {Array} array The sorted array to inspect.
  8541. * @param {*} value The value to evaluate.
  8542. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8543. * @returns {number} Returns the index at which `value` should be inserted
  8544. * into `array`.
  8545. * @example
  8546. *
  8547. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8548. *
  8549. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8550. * // => 1
  8551. *
  8552. * // The `_.property` iteratee shorthand.
  8553. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  8554. * // => 1
  8555. */
  8556. function sortedLastIndexBy(array, value, iteratee) {
  8557. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  8558. }
  8559. /**
  8560. * This method is like `_.lastIndexOf` except that it performs a binary
  8561. * search on a sorted `array`.
  8562. *
  8563. * @static
  8564. * @memberOf _
  8565. * @since 4.0.0
  8566. * @category Array
  8567. * @param {Array} array The array to inspect.
  8568. * @param {*} value The value to search for.
  8569. * @returns {number} Returns the index of the matched value, else `-1`.
  8570. * @example
  8571. *
  8572. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  8573. * // => 3
  8574. */
  8575. function sortedLastIndexOf(array, value) {
  8576. var length = array == null ? 0 : array.length;
  8577. if (length) {
  8578. var index = baseSortedIndex(array, value, true) - 1;
  8579. if (eq(array[index], value)) {
  8580. return index;
  8581. }
  8582. }
  8583. return -1;
  8584. }
  8585. /**
  8586. * This method is like `_.uniq` except that it's designed and optimized
  8587. * for sorted arrays.
  8588. *
  8589. * @static
  8590. * @memberOf _
  8591. * @since 4.0.0
  8592. * @category Array
  8593. * @param {Array} array The array to inspect.
  8594. * @returns {Array} Returns the new duplicate free array.
  8595. * @example
  8596. *
  8597. * _.sortedUniq([1, 1, 2]);
  8598. * // => [1, 2]
  8599. */
  8600. function sortedUniq(array) {
  8601. return (array && array.length)
  8602. ? baseSortedUniq(array)
  8603. : [];
  8604. }
  8605. /**
  8606. * This method is like `_.uniqBy` except that it's designed and optimized
  8607. * for sorted arrays.
  8608. *
  8609. * @static
  8610. * @memberOf _
  8611. * @since 4.0.0
  8612. * @category Array
  8613. * @param {Array} array The array to inspect.
  8614. * @param {Function} [iteratee] The iteratee invoked per element.
  8615. * @returns {Array} Returns the new duplicate free array.
  8616. * @example
  8617. *
  8618. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  8619. * // => [1.1, 2.3]
  8620. */
  8621. function sortedUniqBy(array, iteratee) {
  8622. return (array && array.length)
  8623. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  8624. : [];
  8625. }
  8626. /**
  8627. * Gets all but the first element of `array`.
  8628. *
  8629. * @static
  8630. * @memberOf _
  8631. * @since 4.0.0
  8632. * @category Array
  8633. * @param {Array} array The array to query.
  8634. * @returns {Array} Returns the slice of `array`.
  8635. * @example
  8636. *
  8637. * _.tail([1, 2, 3]);
  8638. * // => [2, 3]
  8639. */
  8640. function tail(array) {
  8641. var length = array == null ? 0 : array.length;
  8642. return length ? baseSlice(array, 1, length) : [];
  8643. }
  8644. /**
  8645. * Creates a slice of `array` with `n` elements taken from the beginning.
  8646. *
  8647. * @static
  8648. * @memberOf _
  8649. * @since 0.1.0
  8650. * @category Array
  8651. * @param {Array} array The array to query.
  8652. * @param {number} [n=1] The number of elements to take.
  8653. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8654. * @returns {Array} Returns the slice of `array`.
  8655. * @example
  8656. *
  8657. * _.take([1, 2, 3]);
  8658. * // => [1]
  8659. *
  8660. * _.take([1, 2, 3], 2);
  8661. * // => [1, 2]
  8662. *
  8663. * _.take([1, 2, 3], 5);
  8664. * // => [1, 2, 3]
  8665. *
  8666. * _.take([1, 2, 3], 0);
  8667. * // => []
  8668. */
  8669. function take(array, n, guard) {
  8670. if (!(array && array.length)) {
  8671. return [];
  8672. }
  8673. n = (guard || n === undefined) ? 1 : toInteger(n);
  8674. return baseSlice(array, 0, n < 0 ? 0 : n);
  8675. }
  8676. /**
  8677. * Creates a slice of `array` with `n` elements taken from the end.
  8678. *
  8679. * @static
  8680. * @memberOf _
  8681. * @since 3.0.0
  8682. * @category Array
  8683. * @param {Array} array The array to query.
  8684. * @param {number} [n=1] The number of elements to take.
  8685. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8686. * @returns {Array} Returns the slice of `array`.
  8687. * @example
  8688. *
  8689. * _.takeRight([1, 2, 3]);
  8690. * // => [3]
  8691. *
  8692. * _.takeRight([1, 2, 3], 2);
  8693. * // => [2, 3]
  8694. *
  8695. * _.takeRight([1, 2, 3], 5);
  8696. * // => [1, 2, 3]
  8697. *
  8698. * _.takeRight([1, 2, 3], 0);
  8699. * // => []
  8700. */
  8701. function takeRight(array, n, guard) {
  8702. var length = array == null ? 0 : array.length;
  8703. if (!length) {
  8704. return [];
  8705. }
  8706. n = (guard || n === undefined) ? 1 : toInteger(n);
  8707. n = length - n;
  8708. return baseSlice(array, n < 0 ? 0 : n, length);
  8709. }
  8710. /**
  8711. * Creates a slice of `array` with elements taken from the end. Elements are
  8712. * taken until `predicate` returns falsey. The predicate is invoked with
  8713. * three arguments: (value, index, array).
  8714. *
  8715. * @static
  8716. * @memberOf _
  8717. * @since 3.0.0
  8718. * @category Array
  8719. * @param {Array} array The array to query.
  8720. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8721. * @returns {Array} Returns the slice of `array`.
  8722. * @example
  8723. *
  8724. * var users = [
  8725. * { 'user': 'barney', 'active': true },
  8726. * { 'user': 'fred', 'active': false },
  8727. * { 'user': 'pebbles', 'active': false }
  8728. * ];
  8729. *
  8730. * _.takeRightWhile(users, function(o) { return !o.active; });
  8731. * // => objects for ['fred', 'pebbles']
  8732. *
  8733. * // The `_.matches` iteratee shorthand.
  8734. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  8735. * // => objects for ['pebbles']
  8736. *
  8737. * // The `_.matchesProperty` iteratee shorthand.
  8738. * _.takeRightWhile(users, ['active', false]);
  8739. * // => objects for ['fred', 'pebbles']
  8740. *
  8741. * // The `_.property` iteratee shorthand.
  8742. * _.takeRightWhile(users, 'active');
  8743. * // => []
  8744. */
  8745. function takeRightWhile(array, predicate) {
  8746. return (array && array.length)
  8747. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  8748. : [];
  8749. }
  8750. /**
  8751. * Creates a slice of `array` with elements taken from the beginning. Elements
  8752. * are taken until `predicate` returns falsey. The predicate is invoked with
  8753. * three arguments: (value, index, array).
  8754. *
  8755. * @static
  8756. * @memberOf _
  8757. * @since 3.0.0
  8758. * @category Array
  8759. * @param {Array} array The array to query.
  8760. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8761. * @returns {Array} Returns the slice of `array`.
  8762. * @example
  8763. *
  8764. * var users = [
  8765. * { 'user': 'barney', 'active': false },
  8766. * { 'user': 'fred', 'active': false },
  8767. * { 'user': 'pebbles', 'active': true }
  8768. * ];
  8769. *
  8770. * _.takeWhile(users, function(o) { return !o.active; });
  8771. * // => objects for ['barney', 'fred']
  8772. *
  8773. * // The `_.matches` iteratee shorthand.
  8774. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  8775. * // => objects for ['barney']
  8776. *
  8777. * // The `_.matchesProperty` iteratee shorthand.
  8778. * _.takeWhile(users, ['active', false]);
  8779. * // => objects for ['barney', 'fred']
  8780. *
  8781. * // The `_.property` iteratee shorthand.
  8782. * _.takeWhile(users, 'active');
  8783. * // => []
  8784. */
  8785. function takeWhile(array, predicate) {
  8786. return (array && array.length)
  8787. ? baseWhile(array, getIteratee(predicate, 3))
  8788. : [];
  8789. }
  8790. /**
  8791. * Creates an array of unique values, in order, from all given arrays using
  8792. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8793. * for equality comparisons.
  8794. *
  8795. * @static
  8796. * @memberOf _
  8797. * @since 0.1.0
  8798. * @category Array
  8799. * @param {...Array} [arrays] The arrays to inspect.
  8800. * @returns {Array} Returns the new array of combined values.
  8801. * @example
  8802. *
  8803. * _.union([2], [1, 2]);
  8804. * // => [2, 1]
  8805. */
  8806. var union = baseRest(function(arrays) {
  8807. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  8808. });
  8809. /**
  8810. * This method is like `_.union` except that it accepts `iteratee` which is
  8811. * invoked for each element of each `arrays` to generate the criterion by
  8812. * which uniqueness is computed. Result values are chosen from the first
  8813. * array in which the value occurs. The iteratee is invoked with one argument:
  8814. * (value).
  8815. *
  8816. * @static
  8817. * @memberOf _
  8818. * @since 4.0.0
  8819. * @category Array
  8820. * @param {...Array} [arrays] The arrays to inspect.
  8821. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8822. * @returns {Array} Returns the new array of combined values.
  8823. * @example
  8824. *
  8825. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  8826. * // => [2.1, 1.2]
  8827. *
  8828. * // The `_.property` iteratee shorthand.
  8829. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8830. * // => [{ 'x': 1 }, { 'x': 2 }]
  8831. */
  8832. var unionBy = baseRest(function(arrays) {
  8833. var iteratee = last(arrays);
  8834. if (isArrayLikeObject(iteratee)) {
  8835. iteratee = undefined;
  8836. }
  8837. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  8838. });
  8839. /**
  8840. * This method is like `_.union` except that it accepts `comparator` which
  8841. * is invoked to compare elements of `arrays`. Result values are chosen from
  8842. * the first array in which the value occurs. The comparator is invoked
  8843. * with two arguments: (arrVal, othVal).
  8844. *
  8845. * @static
  8846. * @memberOf _
  8847. * @since 4.0.0
  8848. * @category Array
  8849. * @param {...Array} [arrays] The arrays to inspect.
  8850. * @param {Function} [comparator] The comparator invoked per element.
  8851. * @returns {Array} Returns the new array of combined values.
  8852. * @example
  8853. *
  8854. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8855. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8856. *
  8857. * _.unionWith(objects, others, _.isEqual);
  8858. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  8859. */
  8860. var unionWith = baseRest(function(arrays) {
  8861. var comparator = last(arrays);
  8862. comparator = typeof comparator == 'function' ? comparator : undefined;
  8863. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  8864. });
  8865. /**
  8866. * Creates a duplicate-free version of an array, using
  8867. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8868. * for equality comparisons, in which only the first occurrence of each element
  8869. * is kept. The order of result values is determined by the order they occur
  8870. * in the array.
  8871. *
  8872. * @static
  8873. * @memberOf _
  8874. * @since 0.1.0
  8875. * @category Array
  8876. * @param {Array} array The array to inspect.
  8877. * @returns {Array} Returns the new duplicate free array.
  8878. * @example
  8879. *
  8880. * _.uniq([2, 1, 2]);
  8881. * // => [2, 1]
  8882. */
  8883. function uniq(array) {
  8884. return (array && array.length) ? baseUniq(array) : [];
  8885. }
  8886. /**
  8887. * This method is like `_.uniq` except that it accepts `iteratee` which is
  8888. * invoked for each element in `array` to generate the criterion by which
  8889. * uniqueness is computed. The order of result values is determined by the
  8890. * order they occur in the array. The iteratee is invoked with one argument:
  8891. * (value).
  8892. *
  8893. * @static
  8894. * @memberOf _
  8895. * @since 4.0.0
  8896. * @category Array
  8897. * @param {Array} array The array to inspect.
  8898. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8899. * @returns {Array} Returns the new duplicate free array.
  8900. * @example
  8901. *
  8902. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  8903. * // => [2.1, 1.2]
  8904. *
  8905. * // The `_.property` iteratee shorthand.
  8906. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  8907. * // => [{ 'x': 1 }, { 'x': 2 }]
  8908. */
  8909. function uniqBy(array, iteratee) {
  8910. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  8911. }
  8912. /**
  8913. * This method is like `_.uniq` except that it accepts `comparator` which
  8914. * is invoked to compare elements of `array`. The order of result values is
  8915. * determined by the order they occur in the array.The comparator is invoked
  8916. * with two arguments: (arrVal, othVal).
  8917. *
  8918. * @static
  8919. * @memberOf _
  8920. * @since 4.0.0
  8921. * @category Array
  8922. * @param {Array} array The array to inspect.
  8923. * @param {Function} [comparator] The comparator invoked per element.
  8924. * @returns {Array} Returns the new duplicate free array.
  8925. * @example
  8926. *
  8927. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8928. *
  8929. * _.uniqWith(objects, _.isEqual);
  8930. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  8931. */
  8932. function uniqWith(array, comparator) {
  8933. comparator = typeof comparator == 'function' ? comparator : undefined;
  8934. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  8935. }
  8936. /**
  8937. * This method is like `_.zip` except that it accepts an array of grouped
  8938. * elements and creates an array regrouping the elements to their pre-zip
  8939. * configuration.
  8940. *
  8941. * @static
  8942. * @memberOf _
  8943. * @since 1.2.0
  8944. * @category Array
  8945. * @param {Array} array The array of grouped elements to process.
  8946. * @returns {Array} Returns the new array of regrouped elements.
  8947. * @example
  8948. *
  8949. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  8950. * // => [['a', 1, true], ['b', 2, false]]
  8951. *
  8952. * _.unzip(zipped);
  8953. * // => [['a', 'b'], [1, 2], [true, false]]
  8954. */
  8955. function unzip(array) {
  8956. if (!(array && array.length)) {
  8957. return [];
  8958. }
  8959. var length = 0;
  8960. array = arrayFilter(array, function(group) {
  8961. if (isArrayLikeObject(group)) {
  8962. length = nativeMax(group.length, length);
  8963. return true;
  8964. }
  8965. });
  8966. return baseTimes(length, function(index) {
  8967. return arrayMap(array, baseProperty(index));
  8968. });
  8969. }
  8970. /**
  8971. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  8972. * how regrouped values should be combined. The iteratee is invoked with the
  8973. * elements of each group: (...group).
  8974. *
  8975. * @static
  8976. * @memberOf _
  8977. * @since 3.8.0
  8978. * @category Array
  8979. * @param {Array} array The array of grouped elements to process.
  8980. * @param {Function} [iteratee=_.identity] The function to combine
  8981. * regrouped values.
  8982. * @returns {Array} Returns the new array of regrouped elements.
  8983. * @example
  8984. *
  8985. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  8986. * // => [[1, 10, 100], [2, 20, 200]]
  8987. *
  8988. * _.unzipWith(zipped, _.add);
  8989. * // => [3, 30, 300]
  8990. */
  8991. function unzipWith(array, iteratee) {
  8992. if (!(array && array.length)) {
  8993. return [];
  8994. }
  8995. var result = unzip(array);
  8996. if (iteratee == null) {
  8997. return result;
  8998. }
  8999. return arrayMap(result, function(group) {
  9000. return apply(iteratee, undefined, group);
  9001. });
  9002. }
  9003. /**
  9004. * Creates an array excluding all given values using
  9005. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9006. * for equality comparisons.
  9007. *
  9008. * **Note:** Unlike `_.pull`, this method returns a new array.
  9009. *
  9010. * @static
  9011. * @memberOf _
  9012. * @since 0.1.0
  9013. * @category Array
  9014. * @param {Array} array The array to inspect.
  9015. * @param {...*} [values] The values to exclude.
  9016. * @returns {Array} Returns the new array of filtered values.
  9017. * @see _.difference, _.xor
  9018. * @example
  9019. *
  9020. * _.without([2, 1, 2, 3], 1, 2);
  9021. * // => [3]
  9022. */
  9023. var without = baseRest(function(array, values) {
  9024. return isArrayLikeObject(array)
  9025. ? baseDifference(array, values)
  9026. : [];
  9027. });
  9028. /**
  9029. * Creates an array of unique values that is the
  9030. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  9031. * of the given arrays. The order of result values is determined by the order
  9032. * they occur in the arrays.
  9033. *
  9034. * @static
  9035. * @memberOf _
  9036. * @since 2.4.0
  9037. * @category Array
  9038. * @param {...Array} [arrays] The arrays to inspect.
  9039. * @returns {Array} Returns the new array of filtered values.
  9040. * @see _.difference, _.without
  9041. * @example
  9042. *
  9043. * _.xor([2, 1], [2, 3]);
  9044. * // => [1, 3]
  9045. */
  9046. var xor = baseRest(function(arrays) {
  9047. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  9048. });
  9049. /**
  9050. * This method is like `_.xor` except that it accepts `iteratee` which is
  9051. * invoked for each element of each `arrays` to generate the criterion by
  9052. * which by which they're compared. The order of result values is determined
  9053. * by the order they occur in the arrays. The iteratee is invoked with one
  9054. * argument: (value).
  9055. *
  9056. * @static
  9057. * @memberOf _
  9058. * @since 4.0.0
  9059. * @category Array
  9060. * @param {...Array} [arrays] The arrays to inspect.
  9061. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9062. * @returns {Array} Returns the new array of filtered values.
  9063. * @example
  9064. *
  9065. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  9066. * // => [1.2, 3.4]
  9067. *
  9068. * // The `_.property` iteratee shorthand.
  9069. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  9070. * // => [{ 'x': 2 }]
  9071. */
  9072. var xorBy = baseRest(function(arrays) {
  9073. var iteratee = last(arrays);
  9074. if (isArrayLikeObject(iteratee)) {
  9075. iteratee = undefined;
  9076. }
  9077. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  9078. });
  9079. /**
  9080. * This method is like `_.xor` except that it accepts `comparator` which is
  9081. * invoked to compare elements of `arrays`. The order of result values is
  9082. * determined by the order they occur in the arrays. The comparator is invoked
  9083. * with two arguments: (arrVal, othVal).
  9084. *
  9085. * @static
  9086. * @memberOf _
  9087. * @since 4.0.0
  9088. * @category Array
  9089. * @param {...Array} [arrays] The arrays to inspect.
  9090. * @param {Function} [comparator] The comparator invoked per element.
  9091. * @returns {Array} Returns the new array of filtered values.
  9092. * @example
  9093. *
  9094. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  9095. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9096. *
  9097. * _.xorWith(objects, others, _.isEqual);
  9098. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  9099. */
  9100. var xorWith = baseRest(function(arrays) {
  9101. var comparator = last(arrays);
  9102. comparator = typeof comparator == 'function' ? comparator : undefined;
  9103. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  9104. });
  9105. /**
  9106. * Creates an array of grouped elements, the first of which contains the
  9107. * first elements of the given arrays, the second of which contains the
  9108. * second elements of the given arrays, and so on.
  9109. *
  9110. * @static
  9111. * @memberOf _
  9112. * @since 0.1.0
  9113. * @category Array
  9114. * @param {...Array} [arrays] The arrays to process.
  9115. * @returns {Array} Returns the new array of grouped elements.
  9116. * @example
  9117. *
  9118. * _.zip(['a', 'b'], [1, 2], [true, false]);
  9119. * // => [['a', 1, true], ['b', 2, false]]
  9120. */
  9121. var zip = baseRest(unzip);
  9122. /**
  9123. * This method is like `_.fromPairs` except that it accepts two arrays,
  9124. * one of property identifiers and one of corresponding values.
  9125. *
  9126. * @static
  9127. * @memberOf _
  9128. * @since 0.4.0
  9129. * @category Array
  9130. * @param {Array} [props=[]] The property identifiers.
  9131. * @param {Array} [values=[]] The property values.
  9132. * @returns {Object} Returns the new object.
  9133. * @example
  9134. *
  9135. * _.zipObject(['a', 'b'], [1, 2]);
  9136. * // => { 'a': 1, 'b': 2 }
  9137. */
  9138. function zipObject(props, values) {
  9139. return baseZipObject(props || [], values || [], assignValue);
  9140. }
  9141. /**
  9142. * This method is like `_.zipObject` except that it supports property paths.
  9143. *
  9144. * @static
  9145. * @memberOf _
  9146. * @since 4.1.0
  9147. * @category Array
  9148. * @param {Array} [props=[]] The property identifiers.
  9149. * @param {Array} [values=[]] The property values.
  9150. * @returns {Object} Returns the new object.
  9151. * @example
  9152. *
  9153. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  9154. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  9155. */
  9156. function zipObjectDeep(props, values) {
  9157. return baseZipObject(props || [], values || [], baseSet);
  9158. }
  9159. /**
  9160. * This method is like `_.zip` except that it accepts `iteratee` to specify
  9161. * how grouped values should be combined. The iteratee is invoked with the
  9162. * elements of each group: (...group).
  9163. *
  9164. * @static
  9165. * @memberOf _
  9166. * @since 3.8.0
  9167. * @category Array
  9168. * @param {...Array} [arrays] The arrays to process.
  9169. * @param {Function} [iteratee=_.identity] The function to combine
  9170. * grouped values.
  9171. * @returns {Array} Returns the new array of grouped elements.
  9172. * @example
  9173. *
  9174. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  9175. * return a + b + c;
  9176. * });
  9177. * // => [111, 222]
  9178. */
  9179. var zipWith = baseRest(function(arrays) {
  9180. var length = arrays.length,
  9181. iteratee = length > 1 ? arrays[length - 1] : undefined;
  9182. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  9183. return unzipWith(arrays, iteratee);
  9184. });
  9185. /*------------------------------------------------------------------------*/
  9186. /**
  9187. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  9188. * chain sequences enabled. The result of such sequences must be unwrapped
  9189. * with `_#value`.
  9190. *
  9191. * @static
  9192. * @memberOf _
  9193. * @since 1.3.0
  9194. * @category Seq
  9195. * @param {*} value The value to wrap.
  9196. * @returns {Object} Returns the new `lodash` wrapper instance.
  9197. * @example
  9198. *
  9199. * var users = [
  9200. * { 'user': 'barney', 'age': 36 },
  9201. * { 'user': 'fred', 'age': 40 },
  9202. * { 'user': 'pebbles', 'age': 1 }
  9203. * ];
  9204. *
  9205. * var youngest = _
  9206. * .chain(users)
  9207. * .sortBy('age')
  9208. * .map(function(o) {
  9209. * return o.user + ' is ' + o.age;
  9210. * })
  9211. * .head()
  9212. * .value();
  9213. * // => 'pebbles is 1'
  9214. */
  9215. function chain(value) {
  9216. var result = lodash(value);
  9217. result.__chain__ = true;
  9218. return result;
  9219. }
  9220. /**
  9221. * This method invokes `interceptor` and returns `value`. The interceptor
  9222. * is invoked with one argument; (value). The purpose of this method is to
  9223. * "tap into" a method chain sequence in order to modify intermediate results.
  9224. *
  9225. * @static
  9226. * @memberOf _
  9227. * @since 0.1.0
  9228. * @category Seq
  9229. * @param {*} value The value to provide to `interceptor`.
  9230. * @param {Function} interceptor The function to invoke.
  9231. * @returns {*} Returns `value`.
  9232. * @example
  9233. *
  9234. * _([1, 2, 3])
  9235. * .tap(function(array) {
  9236. * // Mutate input array.
  9237. * array.pop();
  9238. * })
  9239. * .reverse()
  9240. * .value();
  9241. * // => [2, 1]
  9242. */
  9243. function tap(value, interceptor) {
  9244. interceptor(value);
  9245. return value;
  9246. }
  9247. /**
  9248. * This method is like `_.tap` except that it returns the result of `interceptor`.
  9249. * The purpose of this method is to "pass thru" values replacing intermediate
  9250. * results in a method chain sequence.
  9251. *
  9252. * @static
  9253. * @memberOf _
  9254. * @since 3.0.0
  9255. * @category Seq
  9256. * @param {*} value The value to provide to `interceptor`.
  9257. * @param {Function} interceptor The function to invoke.
  9258. * @returns {*} Returns the result of `interceptor`.
  9259. * @example
  9260. *
  9261. * _(' abc ')
  9262. * .chain()
  9263. * .trim()
  9264. * .thru(function(value) {
  9265. * return [value];
  9266. * })
  9267. * .value();
  9268. * // => ['abc']
  9269. */
  9270. function thru(value, interceptor) {
  9271. return interceptor(value);
  9272. }
  9273. /**
  9274. * This method is the wrapper version of `_.at`.
  9275. *
  9276. * @name at
  9277. * @memberOf _
  9278. * @since 1.0.0
  9279. * @category Seq
  9280. * @param {...(string|string[])} [paths] The property paths to pick.
  9281. * @returns {Object} Returns the new `lodash` wrapper instance.
  9282. * @example
  9283. *
  9284. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  9285. *
  9286. * _(object).at(['a[0].b.c', 'a[1]']).value();
  9287. * // => [3, 4]
  9288. */
  9289. var wrapperAt = flatRest(function(paths) {
  9290. var length = paths.length,
  9291. start = length ? paths[0] : 0,
  9292. value = this.__wrapped__,
  9293. interceptor = function(object) { return baseAt(object, paths); };
  9294. if (length > 1 || this.__actions__.length ||
  9295. !(value instanceof LazyWrapper) || !isIndex(start)) {
  9296. return this.thru(interceptor);
  9297. }
  9298. value = value.slice(start, +start + (length ? 1 : 0));
  9299. value.__actions__.push({
  9300. 'func': thru,
  9301. 'args': [interceptor],
  9302. 'thisArg': undefined
  9303. });
  9304. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  9305. if (length && !array.length) {
  9306. array.push(undefined);
  9307. }
  9308. return array;
  9309. });
  9310. });
  9311. /**
  9312. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  9313. *
  9314. * @name chain
  9315. * @memberOf _
  9316. * @since 0.1.0
  9317. * @category Seq
  9318. * @returns {Object} Returns the new `lodash` wrapper instance.
  9319. * @example
  9320. *
  9321. * var users = [
  9322. * { 'user': 'barney', 'age': 36 },
  9323. * { 'user': 'fred', 'age': 40 }
  9324. * ];
  9325. *
  9326. * // A sequence without explicit chaining.
  9327. * _(users).head();
  9328. * // => { 'user': 'barney', 'age': 36 }
  9329. *
  9330. * // A sequence with explicit chaining.
  9331. * _(users)
  9332. * .chain()
  9333. * .head()
  9334. * .pick('user')
  9335. * .value();
  9336. * // => { 'user': 'barney' }
  9337. */
  9338. function wrapperChain() {
  9339. return chain(this);
  9340. }
  9341. /**
  9342. * Executes the chain sequence and returns the wrapped result.
  9343. *
  9344. * @name commit
  9345. * @memberOf _
  9346. * @since 3.2.0
  9347. * @category Seq
  9348. * @returns {Object} Returns the new `lodash` wrapper instance.
  9349. * @example
  9350. *
  9351. * var array = [1, 2];
  9352. * var wrapped = _(array).push(3);
  9353. *
  9354. * console.log(array);
  9355. * // => [1, 2]
  9356. *
  9357. * wrapped = wrapped.commit();
  9358. * console.log(array);
  9359. * // => [1, 2, 3]
  9360. *
  9361. * wrapped.last();
  9362. * // => 3
  9363. *
  9364. * console.log(array);
  9365. * // => [1, 2, 3]
  9366. */
  9367. function wrapperCommit() {
  9368. return new LodashWrapper(this.value(), this.__chain__);
  9369. }
  9370. /**
  9371. * Gets the next value on a wrapped object following the
  9372. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  9373. *
  9374. * @name next
  9375. * @memberOf _
  9376. * @since 4.0.0
  9377. * @category Seq
  9378. * @returns {Object} Returns the next iterator value.
  9379. * @example
  9380. *
  9381. * var wrapped = _([1, 2]);
  9382. *
  9383. * wrapped.next();
  9384. * // => { 'done': false, 'value': 1 }
  9385. *
  9386. * wrapped.next();
  9387. * // => { 'done': false, 'value': 2 }
  9388. *
  9389. * wrapped.next();
  9390. * // => { 'done': true, 'value': undefined }
  9391. */
  9392. function wrapperNext() {
  9393. if (this.__values__ === undefined) {
  9394. this.__values__ = toArray(this.value());
  9395. }
  9396. var done = this.__index__ >= this.__values__.length,
  9397. value = done ? undefined : this.__values__[this.__index__++];
  9398. return { 'done': done, 'value': value };
  9399. }
  9400. /**
  9401. * Enables the wrapper to be iterable.
  9402. *
  9403. * @name Symbol.iterator
  9404. * @memberOf _
  9405. * @since 4.0.0
  9406. * @category Seq
  9407. * @returns {Object} Returns the wrapper object.
  9408. * @example
  9409. *
  9410. * var wrapped = _([1, 2]);
  9411. *
  9412. * wrapped[Symbol.iterator]() === wrapped;
  9413. * // => true
  9414. *
  9415. * Array.from(wrapped);
  9416. * // => [1, 2]
  9417. */
  9418. function wrapperToIterator() {
  9419. return this;
  9420. }
  9421. /**
  9422. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  9423. *
  9424. * @name plant
  9425. * @memberOf _
  9426. * @since 3.2.0
  9427. * @category Seq
  9428. * @param {*} value The value to plant.
  9429. * @returns {Object} Returns the new `lodash` wrapper instance.
  9430. * @example
  9431. *
  9432. * function square(n) {
  9433. * return n * n;
  9434. * }
  9435. *
  9436. * var wrapped = _([1, 2]).map(square);
  9437. * var other = wrapped.plant([3, 4]);
  9438. *
  9439. * other.value();
  9440. * // => [9, 16]
  9441. *
  9442. * wrapped.value();
  9443. * // => [1, 4]
  9444. */
  9445. function wrapperPlant(value) {
  9446. var result,
  9447. parent = this;
  9448. while (parent instanceof baseLodash) {
  9449. var clone = wrapperClone(parent);
  9450. clone.__index__ = 0;
  9451. clone.__values__ = undefined;
  9452. if (result) {
  9453. previous.__wrapped__ = clone;
  9454. } else {
  9455. result = clone;
  9456. }
  9457. var previous = clone;
  9458. parent = parent.__wrapped__;
  9459. }
  9460. previous.__wrapped__ = value;
  9461. return result;
  9462. }
  9463. /**
  9464. * This method is the wrapper version of `_.reverse`.
  9465. *
  9466. * **Note:** This method mutates the wrapped array.
  9467. *
  9468. * @name reverse
  9469. * @memberOf _
  9470. * @since 0.1.0
  9471. * @category Seq
  9472. * @returns {Object} Returns the new `lodash` wrapper instance.
  9473. * @example
  9474. *
  9475. * var array = [1, 2, 3];
  9476. *
  9477. * _(array).reverse().value()
  9478. * // => [3, 2, 1]
  9479. *
  9480. * console.log(array);
  9481. * // => [3, 2, 1]
  9482. */
  9483. function wrapperReverse() {
  9484. var value = this.__wrapped__;
  9485. if (value instanceof LazyWrapper) {
  9486. var wrapped = value;
  9487. if (this.__actions__.length) {
  9488. wrapped = new LazyWrapper(this);
  9489. }
  9490. wrapped = wrapped.reverse();
  9491. wrapped.__actions__.push({
  9492. 'func': thru,
  9493. 'args': [reverse],
  9494. 'thisArg': undefined
  9495. });
  9496. return new LodashWrapper(wrapped, this.__chain__);
  9497. }
  9498. return this.thru(reverse);
  9499. }
  9500. /**
  9501. * Executes the chain sequence to resolve the unwrapped value.
  9502. *
  9503. * @name value
  9504. * @memberOf _
  9505. * @since 0.1.0
  9506. * @alias toJSON, valueOf
  9507. * @category Seq
  9508. * @returns {*} Returns the resolved unwrapped value.
  9509. * @example
  9510. *
  9511. * _([1, 2, 3]).value();
  9512. * // => [1, 2, 3]
  9513. */
  9514. function wrapperValue() {
  9515. return baseWrapperValue(this.__wrapped__, this.__actions__);
  9516. }
  9517. /*------------------------------------------------------------------------*/
  9518. /**
  9519. * Creates an object composed of keys generated from the results of running
  9520. * each element of `collection` thru `iteratee`. The corresponding value of
  9521. * each key is the number of times the key was returned by `iteratee`. The
  9522. * iteratee is invoked with one argument: (value).
  9523. *
  9524. * @static
  9525. * @memberOf _
  9526. * @since 0.5.0
  9527. * @category Collection
  9528. * @param {Array|Object} collection The collection to iterate over.
  9529. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9530. * @returns {Object} Returns the composed aggregate object.
  9531. * @example
  9532. *
  9533. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  9534. * // => { '4': 1, '6': 2 }
  9535. *
  9536. * // The `_.property` iteratee shorthand.
  9537. * _.countBy(['one', 'two', 'three'], 'length');
  9538. * // => { '3': 2, '5': 1 }
  9539. */
  9540. var countBy = createAggregator(function(result, value, key) {
  9541. if (hasOwnProperty.call(result, key)) {
  9542. ++result[key];
  9543. } else {
  9544. baseAssignValue(result, key, 1);
  9545. }
  9546. });
  9547. /**
  9548. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  9549. * Iteration is stopped once `predicate` returns falsey. The predicate is
  9550. * invoked with three arguments: (value, index|key, collection).
  9551. *
  9552. * **Note:** This method returns `true` for
  9553. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  9554. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  9555. * elements of empty collections.
  9556. *
  9557. * @static
  9558. * @memberOf _
  9559. * @since 0.1.0
  9560. * @category Collection
  9561. * @param {Array|Object} collection The collection to iterate over.
  9562. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9563. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9564. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  9565. * else `false`.
  9566. * @example
  9567. *
  9568. * _.every([true, 1, null, 'yes'], Boolean);
  9569. * // => false
  9570. *
  9571. * var users = [
  9572. * { 'user': 'barney', 'age': 36, 'active': false },
  9573. * { 'user': 'fred', 'age': 40, 'active': false }
  9574. * ];
  9575. *
  9576. * // The `_.matches` iteratee shorthand.
  9577. * _.every(users, { 'user': 'barney', 'active': false });
  9578. * // => false
  9579. *
  9580. * // The `_.matchesProperty` iteratee shorthand.
  9581. * _.every(users, ['active', false]);
  9582. * // => true
  9583. *
  9584. * // The `_.property` iteratee shorthand.
  9585. * _.every(users, 'active');
  9586. * // => false
  9587. */
  9588. function every(collection, predicate, guard) {
  9589. var func = isArray(collection) ? arrayEvery : baseEvery;
  9590. if (guard && isIterateeCall(collection, predicate, guard)) {
  9591. predicate = undefined;
  9592. }
  9593. return func(collection, getIteratee(predicate, 3));
  9594. }
  9595. /**
  9596. * Iterates over elements of `collection`, returning an array of all elements
  9597. * `predicate` returns truthy for. The predicate is invoked with three
  9598. * arguments: (value, index|key, collection).
  9599. *
  9600. * **Note:** Unlike `_.remove`, this method returns a new array.
  9601. *
  9602. * @static
  9603. * @memberOf _
  9604. * @since 0.1.0
  9605. * @category Collection
  9606. * @param {Array|Object} collection The collection to iterate over.
  9607. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9608. * @returns {Array} Returns the new filtered array.
  9609. * @see _.reject
  9610. * @example
  9611. *
  9612. * var users = [
  9613. * { 'user': 'barney', 'age': 36, 'active': true },
  9614. * { 'user': 'fred', 'age': 40, 'active': false }
  9615. * ];
  9616. *
  9617. * _.filter(users, function(o) { return !o.active; });
  9618. * // => objects for ['fred']
  9619. *
  9620. * // The `_.matches` iteratee shorthand.
  9621. * _.filter(users, { 'age': 36, 'active': true });
  9622. * // => objects for ['barney']
  9623. *
  9624. * // The `_.matchesProperty` iteratee shorthand.
  9625. * _.filter(users, ['active', false]);
  9626. * // => objects for ['fred']
  9627. *
  9628. * // The `_.property` iteratee shorthand.
  9629. * _.filter(users, 'active');
  9630. * // => objects for ['barney']
  9631. *
  9632. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  9633. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  9634. * // => objects for ['fred', 'barney']
  9635. */
  9636. function filter(collection, predicate) {
  9637. var func = isArray(collection) ? arrayFilter : baseFilter;
  9638. return func(collection, getIteratee(predicate, 3));
  9639. }
  9640. /**
  9641. * Iterates over elements of `collection`, returning the first element
  9642. * `predicate` returns truthy for. The predicate is invoked with three
  9643. * arguments: (value, index|key, collection).
  9644. *
  9645. * @static
  9646. * @memberOf _
  9647. * @since 0.1.0
  9648. * @category Collection
  9649. * @param {Array|Object} collection The collection to inspect.
  9650. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9651. * @param {number} [fromIndex=0] The index to search from.
  9652. * @returns {*} Returns the matched element, else `undefined`.
  9653. * @example
  9654. *
  9655. * var users = [
  9656. * { 'user': 'barney', 'age': 36, 'active': true },
  9657. * { 'user': 'fred', 'age': 40, 'active': false },
  9658. * { 'user': 'pebbles', 'age': 1, 'active': true }
  9659. * ];
  9660. *
  9661. * _.find(users, function(o) { return o.age < 40; });
  9662. * // => object for 'barney'
  9663. *
  9664. * // The `_.matches` iteratee shorthand.
  9665. * _.find(users, { 'age': 1, 'active': true });
  9666. * // => object for 'pebbles'
  9667. *
  9668. * // The `_.matchesProperty` iteratee shorthand.
  9669. * _.find(users, ['active', false]);
  9670. * // => object for 'fred'
  9671. *
  9672. * // The `_.property` iteratee shorthand.
  9673. * _.find(users, 'active');
  9674. * // => object for 'barney'
  9675. */
  9676. var find = createFind(findIndex);
  9677. /**
  9678. * This method is like `_.find` except that it iterates over elements of
  9679. * `collection` from right to left.
  9680. *
  9681. * @static
  9682. * @memberOf _
  9683. * @since 2.0.0
  9684. * @category Collection
  9685. * @param {Array|Object} collection The collection to inspect.
  9686. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9687. * @param {number} [fromIndex=collection.length-1] The index to search from.
  9688. * @returns {*} Returns the matched element, else `undefined`.
  9689. * @example
  9690. *
  9691. * _.findLast([1, 2, 3, 4], function(n) {
  9692. * return n % 2 == 1;
  9693. * });
  9694. * // => 3
  9695. */
  9696. var findLast = createFind(findLastIndex);
  9697. /**
  9698. * Creates a flattened array of values by running each element in `collection`
  9699. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  9700. * with three arguments: (value, index|key, collection).
  9701. *
  9702. * @static
  9703. * @memberOf _
  9704. * @since 4.0.0
  9705. * @category Collection
  9706. * @param {Array|Object} collection The collection to iterate over.
  9707. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9708. * @returns {Array} Returns the new flattened array.
  9709. * @example
  9710. *
  9711. * function duplicate(n) {
  9712. * return [n, n];
  9713. * }
  9714. *
  9715. * _.flatMap([1, 2], duplicate);
  9716. * // => [1, 1, 2, 2]
  9717. */
  9718. function flatMap(collection, iteratee) {
  9719. return baseFlatten(map(collection, iteratee), 1);
  9720. }
  9721. /**
  9722. * This method is like `_.flatMap` except that it recursively flattens the
  9723. * mapped results.
  9724. *
  9725. * @static
  9726. * @memberOf _
  9727. * @since 4.7.0
  9728. * @category Collection
  9729. * @param {Array|Object} collection The collection to iterate over.
  9730. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9731. * @returns {Array} Returns the new flattened array.
  9732. * @example
  9733. *
  9734. * function duplicate(n) {
  9735. * return [[[n, n]]];
  9736. * }
  9737. *
  9738. * _.flatMapDeep([1, 2], duplicate);
  9739. * // => [1, 1, 2, 2]
  9740. */
  9741. function flatMapDeep(collection, iteratee) {
  9742. return baseFlatten(map(collection, iteratee), INFINITY);
  9743. }
  9744. /**
  9745. * This method is like `_.flatMap` except that it recursively flattens the
  9746. * mapped results up to `depth` times.
  9747. *
  9748. * @static
  9749. * @memberOf _
  9750. * @since 4.7.0
  9751. * @category Collection
  9752. * @param {Array|Object} collection The collection to iterate over.
  9753. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9754. * @param {number} [depth=1] The maximum recursion depth.
  9755. * @returns {Array} Returns the new flattened array.
  9756. * @example
  9757. *
  9758. * function duplicate(n) {
  9759. * return [[[n, n]]];
  9760. * }
  9761. *
  9762. * _.flatMapDepth([1, 2], duplicate, 2);
  9763. * // => [[1, 1], [2, 2]]
  9764. */
  9765. function flatMapDepth(collection, iteratee, depth) {
  9766. depth = depth === undefined ? 1 : toInteger(depth);
  9767. return baseFlatten(map(collection, iteratee), depth);
  9768. }
  9769. /**
  9770. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  9771. * The iteratee is invoked with three arguments: (value, index|key, collection).
  9772. * Iteratee functions may exit iteration early by explicitly returning `false`.
  9773. *
  9774. * **Note:** As with other "Collections" methods, objects with a "length"
  9775. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  9776. * or `_.forOwn` for object iteration.
  9777. *
  9778. * @static
  9779. * @memberOf _
  9780. * @since 0.1.0
  9781. * @alias each
  9782. * @category Collection
  9783. * @param {Array|Object} collection The collection to iterate over.
  9784. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9785. * @returns {Array|Object} Returns `collection`.
  9786. * @see _.forEachRight
  9787. * @example
  9788. *
  9789. * _.forEach([1, 2], function(value) {
  9790. * console.log(value);
  9791. * });
  9792. * // => Logs `1` then `2`.
  9793. *
  9794. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  9795. * console.log(key);
  9796. * });
  9797. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  9798. */
  9799. function forEach(collection, iteratee) {
  9800. var func = isArray(collection) ? arrayEach : baseEach;
  9801. return func(collection, getIteratee(iteratee, 3));
  9802. }
  9803. /**
  9804. * This method is like `_.forEach` except that it iterates over elements of
  9805. * `collection` from right to left.
  9806. *
  9807. * @static
  9808. * @memberOf _
  9809. * @since 2.0.0
  9810. * @alias eachRight
  9811. * @category Collection
  9812. * @param {Array|Object} collection The collection to iterate over.
  9813. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9814. * @returns {Array|Object} Returns `collection`.
  9815. * @see _.forEach
  9816. * @example
  9817. *
  9818. * _.forEachRight([1, 2], function(value) {
  9819. * console.log(value);
  9820. * });
  9821. * // => Logs `2` then `1`.
  9822. */
  9823. function forEachRight(collection, iteratee) {
  9824. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  9825. return func(collection, getIteratee(iteratee, 3));
  9826. }
  9827. /**
  9828. * Creates an object composed of keys generated from the results of running
  9829. * each element of `collection` thru `iteratee`. The order of grouped values
  9830. * is determined by the order they occur in `collection`. The corresponding
  9831. * value of each key is an array of elements responsible for generating the
  9832. * key. The iteratee is invoked with one argument: (value).
  9833. *
  9834. * @static
  9835. * @memberOf _
  9836. * @since 0.1.0
  9837. * @category Collection
  9838. * @param {Array|Object} collection The collection to iterate over.
  9839. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9840. * @returns {Object} Returns the composed aggregate object.
  9841. * @example
  9842. *
  9843. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  9844. * // => { '4': [4.2], '6': [6.1, 6.3] }
  9845. *
  9846. * // The `_.property` iteratee shorthand.
  9847. * _.groupBy(['one', 'two', 'three'], 'length');
  9848. * // => { '3': ['one', 'two'], '5': ['three'] }
  9849. */
  9850. var groupBy = createAggregator(function(result, value, key) {
  9851. if (hasOwnProperty.call(result, key)) {
  9852. result[key].push(value);
  9853. } else {
  9854. baseAssignValue(result, key, [value]);
  9855. }
  9856. });
  9857. /**
  9858. * Checks if `value` is in `collection`. If `collection` is a string, it's
  9859. * checked for a substring of `value`, otherwise
  9860. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9861. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  9862. * the offset from the end of `collection`.
  9863. *
  9864. * @static
  9865. * @memberOf _
  9866. * @since 0.1.0
  9867. * @category Collection
  9868. * @param {Array|Object|string} collection The collection to inspect.
  9869. * @param {*} value The value to search for.
  9870. * @param {number} [fromIndex=0] The index to search from.
  9871. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  9872. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  9873. * @example
  9874. *
  9875. * _.includes([1, 2, 3], 1);
  9876. * // => true
  9877. *
  9878. * _.includes([1, 2, 3], 1, 2);
  9879. * // => false
  9880. *
  9881. * _.includes({ 'a': 1, 'b': 2 }, 1);
  9882. * // => true
  9883. *
  9884. * _.includes('abcd', 'bc');
  9885. * // => true
  9886. */
  9887. function includes(collection, value, fromIndex, guard) {
  9888. collection = isArrayLike(collection) ? collection : values(collection);
  9889. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  9890. var length = collection.length;
  9891. if (fromIndex < 0) {
  9892. fromIndex = nativeMax(length + fromIndex, 0);
  9893. }
  9894. return isString(collection)
  9895. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  9896. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  9897. }
  9898. /**
  9899. * Invokes the method at `path` of each element in `collection`, returning
  9900. * an array of the results of each invoked method. Any additional arguments
  9901. * are provided to each invoked method. If `path` is a function, it's invoked
  9902. * for, and `this` bound to, each element in `collection`.
  9903. *
  9904. * @static
  9905. * @memberOf _
  9906. * @since 4.0.0
  9907. * @category Collection
  9908. * @param {Array|Object} collection The collection to iterate over.
  9909. * @param {Array|Function|string} path The path of the method to invoke or
  9910. * the function invoked per iteration.
  9911. * @param {...*} [args] The arguments to invoke each method with.
  9912. * @returns {Array} Returns the array of results.
  9913. * @example
  9914. *
  9915. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  9916. * // => [[1, 5, 7], [1, 2, 3]]
  9917. *
  9918. * _.invokeMap([123, 456], String.prototype.split, '');
  9919. * // => [['1', '2', '3'], ['4', '5', '6']]
  9920. */
  9921. var invokeMap = baseRest(function(collection, path, args) {
  9922. var index = -1,
  9923. isFunc = typeof path == 'function',
  9924. result = isArrayLike(collection) ? Array(collection.length) : [];
  9925. baseEach(collection, function(value) {
  9926. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  9927. });
  9928. return result;
  9929. });
  9930. /**
  9931. * Creates an object composed of keys generated from the results of running
  9932. * each element of `collection` thru `iteratee`. The corresponding value of
  9933. * each key is the last element responsible for generating the key. The
  9934. * iteratee is invoked with one argument: (value).
  9935. *
  9936. * @static
  9937. * @memberOf _
  9938. * @since 4.0.0
  9939. * @category Collection
  9940. * @param {Array|Object} collection The collection to iterate over.
  9941. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9942. * @returns {Object} Returns the composed aggregate object.
  9943. * @example
  9944. *
  9945. * var array = [
  9946. * { 'dir': 'left', 'code': 97 },
  9947. * { 'dir': 'right', 'code': 100 }
  9948. * ];
  9949. *
  9950. * _.keyBy(array, function(o) {
  9951. * return String.fromCharCode(o.code);
  9952. * });
  9953. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  9954. *
  9955. * _.keyBy(array, 'dir');
  9956. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  9957. */
  9958. var keyBy = createAggregator(function(result, value, key) {
  9959. baseAssignValue(result, key, value);
  9960. });
  9961. /**
  9962. * Creates an array of values by running each element in `collection` thru
  9963. * `iteratee`. The iteratee is invoked with three arguments:
  9964. * (value, index|key, collection).
  9965. *
  9966. * Many lodash methods are guarded to work as iteratees for methods like
  9967. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  9968. *
  9969. * The guarded methods are:
  9970. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  9971. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  9972. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  9973. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  9974. *
  9975. * @static
  9976. * @memberOf _
  9977. * @since 0.1.0
  9978. * @category Collection
  9979. * @param {Array|Object} collection The collection to iterate over.
  9980. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  9981. * @returns {Array} Returns the new mapped array.
  9982. * @example
  9983. *
  9984. * function square(n) {
  9985. * return n * n;
  9986. * }
  9987. *
  9988. * _.map([4, 8], square);
  9989. * // => [16, 64]
  9990. *
  9991. * _.map({ 'a': 4, 'b': 8 }, square);
  9992. * // => [16, 64] (iteration order is not guaranteed)
  9993. *
  9994. * var users = [
  9995. * { 'user': 'barney' },
  9996. * { 'user': 'fred' }
  9997. * ];
  9998. *
  9999. * // The `_.property` iteratee shorthand.
  10000. * _.map(users, 'user');
  10001. * // => ['barney', 'fred']
  10002. */
  10003. function map(collection, iteratee) {
  10004. var func = isArray(collection) ? arrayMap : baseMap;
  10005. return func(collection, getIteratee(iteratee, 3));
  10006. }
  10007. /**
  10008. * This method is like `_.sortBy` except that it allows specifying the sort
  10009. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  10010. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  10011. * descending or "asc" for ascending sort order of corresponding values.
  10012. *
  10013. * @static
  10014. * @memberOf _
  10015. * @since 4.0.0
  10016. * @category Collection
  10017. * @param {Array|Object} collection The collection to iterate over.
  10018. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  10019. * The iteratees to sort by.
  10020. * @param {string[]} [orders] The sort orders of `iteratees`.
  10021. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  10022. * @returns {Array} Returns the new sorted array.
  10023. * @example
  10024. *
  10025. * var users = [
  10026. * { 'user': 'fred', 'age': 48 },
  10027. * { 'user': 'barney', 'age': 34 },
  10028. * { 'user': 'fred', 'age': 40 },
  10029. * { 'user': 'barney', 'age': 36 }
  10030. * ];
  10031. *
  10032. * // Sort by `user` in ascending order and by `age` in descending order.
  10033. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  10034. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  10035. */
  10036. function orderBy(collection, iteratees, orders, guard) {
  10037. if (collection == null) {
  10038. return [];
  10039. }
  10040. if (!isArray(iteratees)) {
  10041. iteratees = iteratees == null ? [] : [iteratees];
  10042. }
  10043. orders = guard ? undefined : orders;
  10044. if (!isArray(orders)) {
  10045. orders = orders == null ? [] : [orders];
  10046. }
  10047. return baseOrderBy(collection, iteratees, orders);
  10048. }
  10049. /**
  10050. * Creates an array of elements split into two groups, the first of which
  10051. * contains elements `predicate` returns truthy for, the second of which
  10052. * contains elements `predicate` returns falsey for. The predicate is
  10053. * invoked with one argument: (value).
  10054. *
  10055. * @static
  10056. * @memberOf _
  10057. * @since 3.0.0
  10058. * @category Collection
  10059. * @param {Array|Object} collection The collection to iterate over.
  10060. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10061. * @returns {Array} Returns the array of grouped elements.
  10062. * @example
  10063. *
  10064. * var users = [
  10065. * { 'user': 'barney', 'age': 36, 'active': false },
  10066. * { 'user': 'fred', 'age': 40, 'active': true },
  10067. * { 'user': 'pebbles', 'age': 1, 'active': false }
  10068. * ];
  10069. *
  10070. * _.partition(users, function(o) { return o.active; });
  10071. * // => objects for [['fred'], ['barney', 'pebbles']]
  10072. *
  10073. * // The `_.matches` iteratee shorthand.
  10074. * _.partition(users, { 'age': 1, 'active': false });
  10075. * // => objects for [['pebbles'], ['barney', 'fred']]
  10076. *
  10077. * // The `_.matchesProperty` iteratee shorthand.
  10078. * _.partition(users, ['active', false]);
  10079. * // => objects for [['barney', 'pebbles'], ['fred']]
  10080. *
  10081. * // The `_.property` iteratee shorthand.
  10082. * _.partition(users, 'active');
  10083. * // => objects for [['fred'], ['barney', 'pebbles']]
  10084. */
  10085. var partition = createAggregator(function(result, value, key) {
  10086. result[key ? 0 : 1].push(value);
  10087. }, function() { return [[], []]; });
  10088. /**
  10089. * Reduces `collection` to a value which is the accumulated result of running
  10090. * each element in `collection` thru `iteratee`, where each successive
  10091. * invocation is supplied the return value of the previous. If `accumulator`
  10092. * is not given, the first element of `collection` is used as the initial
  10093. * value. The iteratee is invoked with four arguments:
  10094. * (accumulator, value, index|key, collection).
  10095. *
  10096. * Many lodash methods are guarded to work as iteratees for methods like
  10097. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  10098. *
  10099. * The guarded methods are:
  10100. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  10101. * and `sortBy`
  10102. *
  10103. * @static
  10104. * @memberOf _
  10105. * @since 0.1.0
  10106. * @category Collection
  10107. * @param {Array|Object} collection The collection to iterate over.
  10108. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10109. * @param {*} [accumulator] The initial value.
  10110. * @returns {*} Returns the accumulated value.
  10111. * @see _.reduceRight
  10112. * @example
  10113. *
  10114. * _.reduce([1, 2], function(sum, n) {
  10115. * return sum + n;
  10116. * }, 0);
  10117. * // => 3
  10118. *
  10119. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  10120. * (result[value] || (result[value] = [])).push(key);
  10121. * return result;
  10122. * }, {});
  10123. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  10124. */
  10125. function reduce(collection, iteratee, accumulator) {
  10126. var func = isArray(collection) ? arrayReduce : baseReduce,
  10127. initAccum = arguments.length < 3;
  10128. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  10129. }
  10130. /**
  10131. * This method is like `_.reduce` except that it iterates over elements of
  10132. * `collection` from right to left.
  10133. *
  10134. * @static
  10135. * @memberOf _
  10136. * @since 0.1.0
  10137. * @category Collection
  10138. * @param {Array|Object} collection The collection to iterate over.
  10139. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10140. * @param {*} [accumulator] The initial value.
  10141. * @returns {*} Returns the accumulated value.
  10142. * @see _.reduce
  10143. * @example
  10144. *
  10145. * var array = [[0, 1], [2, 3], [4, 5]];
  10146. *
  10147. * _.reduceRight(array, function(flattened, other) {
  10148. * return flattened.concat(other);
  10149. * }, []);
  10150. * // => [4, 5, 2, 3, 0, 1]
  10151. */
  10152. function reduceRight(collection, iteratee, accumulator) {
  10153. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  10154. initAccum = arguments.length < 3;
  10155. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  10156. }
  10157. /**
  10158. * The opposite of `_.filter`; this method returns the elements of `collection`
  10159. * that `predicate` does **not** return truthy for.
  10160. *
  10161. * @static
  10162. * @memberOf _
  10163. * @since 0.1.0
  10164. * @category Collection
  10165. * @param {Array|Object} collection The collection to iterate over.
  10166. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10167. * @returns {Array} Returns the new filtered array.
  10168. * @see _.filter
  10169. * @example
  10170. *
  10171. * var users = [
  10172. * { 'user': 'barney', 'age': 36, 'active': false },
  10173. * { 'user': 'fred', 'age': 40, 'active': true }
  10174. * ];
  10175. *
  10176. * _.reject(users, function(o) { return !o.active; });
  10177. * // => objects for ['fred']
  10178. *
  10179. * // The `_.matches` iteratee shorthand.
  10180. * _.reject(users, { 'age': 40, 'active': true });
  10181. * // => objects for ['barney']
  10182. *
  10183. * // The `_.matchesProperty` iteratee shorthand.
  10184. * _.reject(users, ['active', false]);
  10185. * // => objects for ['fred']
  10186. *
  10187. * // The `_.property` iteratee shorthand.
  10188. * _.reject(users, 'active');
  10189. * // => objects for ['barney']
  10190. */
  10191. function reject(collection, predicate) {
  10192. var func = isArray(collection) ? arrayFilter : baseFilter;
  10193. return func(collection, negate(getIteratee(predicate, 3)));
  10194. }
  10195. /**
  10196. * Gets a random element from `collection`.
  10197. *
  10198. * @static
  10199. * @memberOf _
  10200. * @since 2.0.0
  10201. * @category Collection
  10202. * @param {Array|Object} collection The collection to sample.
  10203. * @returns {*} Returns the random element.
  10204. * @example
  10205. *
  10206. * _.sample([1, 2, 3, 4]);
  10207. * // => 2
  10208. */
  10209. function sample(collection) {
  10210. var func = isArray(collection) ? arraySample : baseSample;
  10211. return func(collection);
  10212. }
  10213. /**
  10214. * Gets `n` random elements at unique keys from `collection` up to the
  10215. * size of `collection`.
  10216. *
  10217. * @static
  10218. * @memberOf _
  10219. * @since 4.0.0
  10220. * @category Collection
  10221. * @param {Array|Object} collection The collection to sample.
  10222. * @param {number} [n=1] The number of elements to sample.
  10223. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10224. * @returns {Array} Returns the random elements.
  10225. * @example
  10226. *
  10227. * _.sampleSize([1, 2, 3], 2);
  10228. * // => [3, 1]
  10229. *
  10230. * _.sampleSize([1, 2, 3], 4);
  10231. * // => [2, 3, 1]
  10232. */
  10233. function sampleSize(collection, n, guard) {
  10234. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  10235. n = 1;
  10236. } else {
  10237. n = toInteger(n);
  10238. }
  10239. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  10240. return func(collection, n);
  10241. }
  10242. /**
  10243. * Creates an array of shuffled values, using a version of the
  10244. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  10245. *
  10246. * @static
  10247. * @memberOf _
  10248. * @since 0.1.0
  10249. * @category Collection
  10250. * @param {Array|Object} collection The collection to shuffle.
  10251. * @returns {Array} Returns the new shuffled array.
  10252. * @example
  10253. *
  10254. * _.shuffle([1, 2, 3, 4]);
  10255. * // => [4, 1, 3, 2]
  10256. */
  10257. function shuffle(collection) {
  10258. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  10259. return func(collection);
  10260. }
  10261. /**
  10262. * Gets the size of `collection` by returning its length for array-like
  10263. * values or the number of own enumerable string keyed properties for objects.
  10264. *
  10265. * @static
  10266. * @memberOf _
  10267. * @since 0.1.0
  10268. * @category Collection
  10269. * @param {Array|Object|string} collection The collection to inspect.
  10270. * @returns {number} Returns the collection size.
  10271. * @example
  10272. *
  10273. * _.size([1, 2, 3]);
  10274. * // => 3
  10275. *
  10276. * _.size({ 'a': 1, 'b': 2 });
  10277. * // => 2
  10278. *
  10279. * _.size('pebbles');
  10280. * // => 7
  10281. */
  10282. function size(collection) {
  10283. if (collection == null) {
  10284. return 0;
  10285. }
  10286. if (isArrayLike(collection)) {
  10287. return isString(collection) ? stringSize(collection) : collection.length;
  10288. }
  10289. var tag = getTag(collection);
  10290. if (tag == mapTag || tag == setTag) {
  10291. return collection.size;
  10292. }
  10293. return baseKeys(collection).length;
  10294. }
  10295. /**
  10296. * Checks if `predicate` returns truthy for **any** element of `collection`.
  10297. * Iteration is stopped once `predicate` returns truthy. The predicate is
  10298. * invoked with three arguments: (value, index|key, collection).
  10299. *
  10300. * @static
  10301. * @memberOf _
  10302. * @since 0.1.0
  10303. * @category Collection
  10304. * @param {Array|Object} collection The collection to iterate over.
  10305. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10306. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10307. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10308. * else `false`.
  10309. * @example
  10310. *
  10311. * _.some([null, 0, 'yes', false], Boolean);
  10312. * // => true
  10313. *
  10314. * var users = [
  10315. * { 'user': 'barney', 'active': true },
  10316. * { 'user': 'fred', 'active': false }
  10317. * ];
  10318. *
  10319. * // The `_.matches` iteratee shorthand.
  10320. * _.some(users, { 'user': 'barney', 'active': false });
  10321. * // => false
  10322. *
  10323. * // The `_.matchesProperty` iteratee shorthand.
  10324. * _.some(users, ['active', false]);
  10325. * // => true
  10326. *
  10327. * // The `_.property` iteratee shorthand.
  10328. * _.some(users, 'active');
  10329. * // => true
  10330. */
  10331. function some(collection, predicate, guard) {
  10332. var func = isArray(collection) ? arraySome : baseSome;
  10333. if (guard && isIterateeCall(collection, predicate, guard)) {
  10334. predicate = undefined;
  10335. }
  10336. return func(collection, getIteratee(predicate, 3));
  10337. }
  10338. /**
  10339. * Creates an array of elements, sorted in ascending order by the results of
  10340. * running each element in a collection thru each iteratee. This method
  10341. * performs a stable sort, that is, it preserves the original sort order of
  10342. * equal elements. The iteratees are invoked with one argument: (value).
  10343. *
  10344. * @static
  10345. * @memberOf _
  10346. * @since 0.1.0
  10347. * @category Collection
  10348. * @param {Array|Object} collection The collection to iterate over.
  10349. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  10350. * The iteratees to sort by.
  10351. * @returns {Array} Returns the new sorted array.
  10352. * @example
  10353. *
  10354. * var users = [
  10355. * { 'user': 'fred', 'age': 48 },
  10356. * { 'user': 'barney', 'age': 36 },
  10357. * { 'user': 'fred', 'age': 30 },
  10358. * { 'user': 'barney', 'age': 34 }
  10359. * ];
  10360. *
  10361. * _.sortBy(users, [function(o) { return o.user; }]);
  10362. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  10363. *
  10364. * _.sortBy(users, ['user', 'age']);
  10365. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  10366. */
  10367. var sortBy = baseRest(function(collection, iteratees) {
  10368. if (collection == null) {
  10369. return [];
  10370. }
  10371. var length = iteratees.length;
  10372. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  10373. iteratees = [];
  10374. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  10375. iteratees = [iteratees[0]];
  10376. }
  10377. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  10378. });
  10379. /*------------------------------------------------------------------------*/
  10380. /**
  10381. * Gets the timestamp of the number of milliseconds that have elapsed since
  10382. * the Unix epoch (1 January 1970 00:00:00 UTC).
  10383. *
  10384. * @static
  10385. * @memberOf _
  10386. * @since 2.4.0
  10387. * @category Date
  10388. * @returns {number} Returns the timestamp.
  10389. * @example
  10390. *
  10391. * _.defer(function(stamp) {
  10392. * console.log(_.now() - stamp);
  10393. * }, _.now());
  10394. * // => Logs the number of milliseconds it took for the deferred invocation.
  10395. */
  10396. var now = ctxNow || function() {
  10397. return root.Date.now();
  10398. };
  10399. /*------------------------------------------------------------------------*/
  10400. /**
  10401. * The opposite of `_.before`; this method creates a function that invokes
  10402. * `func` once it's called `n` or more times.
  10403. *
  10404. * @static
  10405. * @memberOf _
  10406. * @since 0.1.0
  10407. * @category Function
  10408. * @param {number} n The number of calls before `func` is invoked.
  10409. * @param {Function} func The function to restrict.
  10410. * @returns {Function} Returns the new restricted function.
  10411. * @example
  10412. *
  10413. * var saves = ['profile', 'settings'];
  10414. *
  10415. * var done = _.after(saves.length, function() {
  10416. * console.log('done saving!');
  10417. * });
  10418. *
  10419. * _.forEach(saves, function(type) {
  10420. * asyncSave({ 'type': type, 'complete': done });
  10421. * });
  10422. * // => Logs 'done saving!' after the two async saves have completed.
  10423. */
  10424. function after(n, func) {
  10425. if (typeof func != 'function') {
  10426. throw new TypeError(FUNC_ERROR_TEXT);
  10427. }
  10428. n = toInteger(n);
  10429. return function() {
  10430. if (--n < 1) {
  10431. return func.apply(this, arguments);
  10432. }
  10433. };
  10434. }
  10435. /**
  10436. * Creates a function that invokes `func`, with up to `n` arguments,
  10437. * ignoring any additional arguments.
  10438. *
  10439. * @static
  10440. * @memberOf _
  10441. * @since 3.0.0
  10442. * @category Function
  10443. * @param {Function} func The function to cap arguments for.
  10444. * @param {number} [n=func.length] The arity cap.
  10445. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10446. * @returns {Function} Returns the new capped function.
  10447. * @example
  10448. *
  10449. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  10450. * // => [6, 8, 10]
  10451. */
  10452. function ary(func, n, guard) {
  10453. n = guard ? undefined : n;
  10454. n = (func && n == null) ? func.length : n;
  10455. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  10456. }
  10457. /**
  10458. * Creates a function that invokes `func`, with the `this` binding and arguments
  10459. * of the created function, while it's called less than `n` times. Subsequent
  10460. * calls to the created function return the result of the last `func` invocation.
  10461. *
  10462. * @static
  10463. * @memberOf _
  10464. * @since 3.0.0
  10465. * @category Function
  10466. * @param {number} n The number of calls at which `func` is no longer invoked.
  10467. * @param {Function} func The function to restrict.
  10468. * @returns {Function} Returns the new restricted function.
  10469. * @example
  10470. *
  10471. * jQuery(element).on('click', _.before(5, addContactToList));
  10472. * // => Allows adding up to 4 contacts to the list.
  10473. */
  10474. function before(n, func) {
  10475. var result;
  10476. if (typeof func != 'function') {
  10477. throw new TypeError(FUNC_ERROR_TEXT);
  10478. }
  10479. n = toInteger(n);
  10480. return function() {
  10481. if (--n > 0) {
  10482. result = func.apply(this, arguments);
  10483. }
  10484. if (n <= 1) {
  10485. func = undefined;
  10486. }
  10487. return result;
  10488. };
  10489. }
  10490. /**
  10491. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  10492. * and `partials` prepended to the arguments it receives.
  10493. *
  10494. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  10495. * may be used as a placeholder for partially applied arguments.
  10496. *
  10497. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  10498. * property of bound functions.
  10499. *
  10500. * @static
  10501. * @memberOf _
  10502. * @since 0.1.0
  10503. * @category Function
  10504. * @param {Function} func The function to bind.
  10505. * @param {*} thisArg The `this` binding of `func`.
  10506. * @param {...*} [partials] The arguments to be partially applied.
  10507. * @returns {Function} Returns the new bound function.
  10508. * @example
  10509. *
  10510. * function greet(greeting, punctuation) {
  10511. * return greeting + ' ' + this.user + punctuation;
  10512. * }
  10513. *
  10514. * var object = { 'user': 'fred' };
  10515. *
  10516. * var bound = _.bind(greet, object, 'hi');
  10517. * bound('!');
  10518. * // => 'hi fred!'
  10519. *
  10520. * // Bound with placeholders.
  10521. * var bound = _.bind(greet, object, _, '!');
  10522. * bound('hi');
  10523. * // => 'hi fred!'
  10524. */
  10525. var bind = baseRest(function(func, thisArg, partials) {
  10526. var bitmask = WRAP_BIND_FLAG;
  10527. if (partials.length) {
  10528. var holders = replaceHolders(partials, getHolder(bind));
  10529. bitmask |= WRAP_PARTIAL_FLAG;
  10530. }
  10531. return createWrap(func, bitmask, thisArg, partials, holders);
  10532. });
  10533. /**
  10534. * Creates a function that invokes the method at `object[key]` with `partials`
  10535. * prepended to the arguments it receives.
  10536. *
  10537. * This method differs from `_.bind` by allowing bound functions to reference
  10538. * methods that may be redefined or don't yet exist. See
  10539. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  10540. * for more details.
  10541. *
  10542. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  10543. * builds, may be used as a placeholder for partially applied arguments.
  10544. *
  10545. * @static
  10546. * @memberOf _
  10547. * @since 0.10.0
  10548. * @category Function
  10549. * @param {Object} object The object to invoke the method on.
  10550. * @param {string} key The key of the method.
  10551. * @param {...*} [partials] The arguments to be partially applied.
  10552. * @returns {Function} Returns the new bound function.
  10553. * @example
  10554. *
  10555. * var object = {
  10556. * 'user': 'fred',
  10557. * 'greet': function(greeting, punctuation) {
  10558. * return greeting + ' ' + this.user + punctuation;
  10559. * }
  10560. * };
  10561. *
  10562. * var bound = _.bindKey(object, 'greet', 'hi');
  10563. * bound('!');
  10564. * // => 'hi fred!'
  10565. *
  10566. * object.greet = function(greeting, punctuation) {
  10567. * return greeting + 'ya ' + this.user + punctuation;
  10568. * };
  10569. *
  10570. * bound('!');
  10571. * // => 'hiya fred!'
  10572. *
  10573. * // Bound with placeholders.
  10574. * var bound = _.bindKey(object, 'greet', _, '!');
  10575. * bound('hi');
  10576. * // => 'hiya fred!'
  10577. */
  10578. var bindKey = baseRest(function(object, key, partials) {
  10579. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  10580. if (partials.length) {
  10581. var holders = replaceHolders(partials, getHolder(bindKey));
  10582. bitmask |= WRAP_PARTIAL_FLAG;
  10583. }
  10584. return createWrap(key, bitmask, object, partials, holders);
  10585. });
  10586. /**
  10587. * Creates a function that accepts arguments of `func` and either invokes
  10588. * `func` returning its result, if at least `arity` number of arguments have
  10589. * been provided, or returns a function that accepts the remaining `func`
  10590. * arguments, and so on. The arity of `func` may be specified if `func.length`
  10591. * is not sufficient.
  10592. *
  10593. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  10594. * may be used as a placeholder for provided arguments.
  10595. *
  10596. * **Note:** This method doesn't set the "length" property of curried functions.
  10597. *
  10598. * @static
  10599. * @memberOf _
  10600. * @since 2.0.0
  10601. * @category Function
  10602. * @param {Function} func The function to curry.
  10603. * @param {number} [arity=func.length] The arity of `func`.
  10604. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10605. * @returns {Function} Returns the new curried function.
  10606. * @example
  10607. *
  10608. * var abc = function(a, b, c) {
  10609. * return [a, b, c];
  10610. * };
  10611. *
  10612. * var curried = _.curry(abc);
  10613. *
  10614. * curried(1)(2)(3);
  10615. * // => [1, 2, 3]
  10616. *
  10617. * curried(1, 2)(3);
  10618. * // => [1, 2, 3]
  10619. *
  10620. * curried(1, 2, 3);
  10621. * // => [1, 2, 3]
  10622. *
  10623. * // Curried with placeholders.
  10624. * curried(1)(_, 3)(2);
  10625. * // => [1, 2, 3]
  10626. */
  10627. function curry(func, arity, guard) {
  10628. arity = guard ? undefined : arity;
  10629. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10630. result.placeholder = curry.placeholder;
  10631. return result;
  10632. }
  10633. /**
  10634. * This method is like `_.curry` except that arguments are applied to `func`
  10635. * in the manner of `_.partialRight` instead of `_.partial`.
  10636. *
  10637. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  10638. * builds, may be used as a placeholder for provided arguments.
  10639. *
  10640. * **Note:** This method doesn't set the "length" property of curried functions.
  10641. *
  10642. * @static
  10643. * @memberOf _
  10644. * @since 3.0.0
  10645. * @category Function
  10646. * @param {Function} func The function to curry.
  10647. * @param {number} [arity=func.length] The arity of `func`.
  10648. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10649. * @returns {Function} Returns the new curried function.
  10650. * @example
  10651. *
  10652. * var abc = function(a, b, c) {
  10653. * return [a, b, c];
  10654. * };
  10655. *
  10656. * var curried = _.curryRight(abc);
  10657. *
  10658. * curried(3)(2)(1);
  10659. * // => [1, 2, 3]
  10660. *
  10661. * curried(2, 3)(1);
  10662. * // => [1, 2, 3]
  10663. *
  10664. * curried(1, 2, 3);
  10665. * // => [1, 2, 3]
  10666. *
  10667. * // Curried with placeholders.
  10668. * curried(3)(1, _)(2);
  10669. * // => [1, 2, 3]
  10670. */
  10671. function curryRight(func, arity, guard) {
  10672. arity = guard ? undefined : arity;
  10673. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  10674. result.placeholder = curryRight.placeholder;
  10675. return result;
  10676. }
  10677. /**
  10678. * Creates a debounced function that delays invoking `func` until after `wait`
  10679. * milliseconds have elapsed since the last time the debounced function was
  10680. * invoked. The debounced function comes with a `cancel` method to cancel
  10681. * delayed `func` invocations and a `flush` method to immediately invoke them.
  10682. * Provide `options` to indicate whether `func` should be invoked on the
  10683. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  10684. * with the last arguments provided to the debounced function. Subsequent
  10685. * calls to the debounced function return the result of the last `func`
  10686. * invocation.
  10687. *
  10688. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  10689. * invoked on the trailing edge of the timeout only if the debounced function
  10690. * is invoked more than once during the `wait` timeout.
  10691. *
  10692. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  10693. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  10694. *
  10695. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  10696. * for details over the differences between `_.debounce` and `_.throttle`.
  10697. *
  10698. * @static
  10699. * @memberOf _
  10700. * @since 0.1.0
  10701. * @category Function
  10702. * @param {Function} func The function to debounce.
  10703. * @param {number} [wait=0] The number of milliseconds to delay.
  10704. * @param {Object} [options={}] The options object.
  10705. * @param {boolean} [options.leading=false]
  10706. * Specify invoking on the leading edge of the timeout.
  10707. * @param {number} [options.maxWait]
  10708. * The maximum time `func` is allowed to be delayed before it's invoked.
  10709. * @param {boolean} [options.trailing=true]
  10710. * Specify invoking on the trailing edge of the timeout.
  10711. * @returns {Function} Returns the new debounced function.
  10712. * @example
  10713. *
  10714. * // Avoid costly calculations while the window size is in flux.
  10715. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  10716. *
  10717. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  10718. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  10719. * 'leading': true,
  10720. * 'trailing': false
  10721. * }));
  10722. *
  10723. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  10724. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  10725. * var source = new EventSource('/stream');
  10726. * jQuery(source).on('message', debounced);
  10727. *
  10728. * // Cancel the trailing debounced invocation.
  10729. * jQuery(window).on('popstate', debounced.cancel);
  10730. */
  10731. function debounce(func, wait, options) {
  10732. var lastArgs,
  10733. lastThis,
  10734. maxWait,
  10735. result,
  10736. timerId,
  10737. lastCallTime,
  10738. lastInvokeTime = 0,
  10739. leading = false,
  10740. maxing = false,
  10741. trailing = true;
  10742. if (typeof func != 'function') {
  10743. throw new TypeError(FUNC_ERROR_TEXT);
  10744. }
  10745. wait = toNumber(wait) || 0;
  10746. if (isObject(options)) {
  10747. leading = !!options.leading;
  10748. maxing = 'maxWait' in options;
  10749. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  10750. trailing = 'trailing' in options ? !!options.trailing : trailing;
  10751. }
  10752. function invokeFunc(time) {
  10753. var args = lastArgs,
  10754. thisArg = lastThis;
  10755. lastArgs = lastThis = undefined;
  10756. lastInvokeTime = time;
  10757. result = func.apply(thisArg, args);
  10758. return result;
  10759. }
  10760. function leadingEdge(time) {
  10761. // Reset any `maxWait` timer.
  10762. lastInvokeTime = time;
  10763. // Start the timer for the trailing edge.
  10764. timerId = setTimeout(timerExpired, wait);
  10765. // Invoke the leading edge.
  10766. return leading ? invokeFunc(time) : result;
  10767. }
  10768. function remainingWait(time) {
  10769. var timeSinceLastCall = time - lastCallTime,
  10770. timeSinceLastInvoke = time - lastInvokeTime,
  10771. timeWaiting = wait - timeSinceLastCall;
  10772. return maxing
  10773. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  10774. : timeWaiting;
  10775. }
  10776. function shouldInvoke(time) {
  10777. var timeSinceLastCall = time - lastCallTime,
  10778. timeSinceLastInvoke = time - lastInvokeTime;
  10779. // Either this is the first call, activity has stopped and we're at the
  10780. // trailing edge, the system time has gone backwards and we're treating
  10781. // it as the trailing edge, or we've hit the `maxWait` limit.
  10782. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  10783. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  10784. }
  10785. function timerExpired() {
  10786. var time = now();
  10787. if (shouldInvoke(time)) {
  10788. return trailingEdge(time);
  10789. }
  10790. // Restart the timer.
  10791. timerId = setTimeout(timerExpired, remainingWait(time));
  10792. }
  10793. function trailingEdge(time) {
  10794. timerId = undefined;
  10795. // Only invoke if we have `lastArgs` which means `func` has been
  10796. // debounced at least once.
  10797. if (trailing && lastArgs) {
  10798. return invokeFunc(time);
  10799. }
  10800. lastArgs = lastThis = undefined;
  10801. return result;
  10802. }
  10803. function cancel() {
  10804. if (timerId !== undefined) {
  10805. clearTimeout(timerId);
  10806. }
  10807. lastInvokeTime = 0;
  10808. lastArgs = lastCallTime = lastThis = timerId = undefined;
  10809. }
  10810. function flush() {
  10811. return timerId === undefined ? result : trailingEdge(now());
  10812. }
  10813. function debounced() {
  10814. var time = now(),
  10815. isInvoking = shouldInvoke(time);
  10816. lastArgs = arguments;
  10817. lastThis = this;
  10818. lastCallTime = time;
  10819. if (isInvoking) {
  10820. if (timerId === undefined) {
  10821. return leadingEdge(lastCallTime);
  10822. }
  10823. if (maxing) {
  10824. // Handle invocations in a tight loop.
  10825. clearTimeout(timerId);
  10826. timerId = setTimeout(timerExpired, wait);
  10827. return invokeFunc(lastCallTime);
  10828. }
  10829. }
  10830. if (timerId === undefined) {
  10831. timerId = setTimeout(timerExpired, wait);
  10832. }
  10833. return result;
  10834. }
  10835. debounced.cancel = cancel;
  10836. debounced.flush = flush;
  10837. return debounced;
  10838. }
  10839. /**
  10840. * Defers invoking the `func` until the current call stack has cleared. Any
  10841. * additional arguments are provided to `func` when it's invoked.
  10842. *
  10843. * @static
  10844. * @memberOf _
  10845. * @since 0.1.0
  10846. * @category Function
  10847. * @param {Function} func The function to defer.
  10848. * @param {...*} [args] The arguments to invoke `func` with.
  10849. * @returns {number} Returns the timer id.
  10850. * @example
  10851. *
  10852. * _.defer(function(text) {
  10853. * console.log(text);
  10854. * }, 'deferred');
  10855. * // => Logs 'deferred' after one millisecond.
  10856. */
  10857. var defer = baseRest(function(func, args) {
  10858. return baseDelay(func, 1, args);
  10859. });
  10860. /**
  10861. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  10862. * provided to `func` when it's invoked.
  10863. *
  10864. * @static
  10865. * @memberOf _
  10866. * @since 0.1.0
  10867. * @category Function
  10868. * @param {Function} func The function to delay.
  10869. * @param {number} wait The number of milliseconds to delay invocation.
  10870. * @param {...*} [args] The arguments to invoke `func` with.
  10871. * @returns {number} Returns the timer id.
  10872. * @example
  10873. *
  10874. * _.delay(function(text) {
  10875. * console.log(text);
  10876. * }, 1000, 'later');
  10877. * // => Logs 'later' after one second.
  10878. */
  10879. var delay = baseRest(function(func, wait, args) {
  10880. return baseDelay(func, toNumber(wait) || 0, args);
  10881. });
  10882. /**
  10883. * Creates a function that invokes `func` with arguments reversed.
  10884. *
  10885. * @static
  10886. * @memberOf _
  10887. * @since 4.0.0
  10888. * @category Function
  10889. * @param {Function} func The function to flip arguments for.
  10890. * @returns {Function} Returns the new flipped function.
  10891. * @example
  10892. *
  10893. * var flipped = _.flip(function() {
  10894. * return _.toArray(arguments);
  10895. * });
  10896. *
  10897. * flipped('a', 'b', 'c', 'd');
  10898. * // => ['d', 'c', 'b', 'a']
  10899. */
  10900. function flip(func) {
  10901. return createWrap(func, WRAP_FLIP_FLAG);
  10902. }
  10903. /**
  10904. * Creates a function that memoizes the result of `func`. If `resolver` is
  10905. * provided, it determines the cache key for storing the result based on the
  10906. * arguments provided to the memoized function. By default, the first argument
  10907. * provided to the memoized function is used as the map cache key. The `func`
  10908. * is invoked with the `this` binding of the memoized function.
  10909. *
  10910. * **Note:** The cache is exposed as the `cache` property on the memoized
  10911. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  10912. * constructor with one whose instances implement the
  10913. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  10914. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  10915. *
  10916. * @static
  10917. * @memberOf _
  10918. * @since 0.1.0
  10919. * @category Function
  10920. * @param {Function} func The function to have its output memoized.
  10921. * @param {Function} [resolver] The function to resolve the cache key.
  10922. * @returns {Function} Returns the new memoized function.
  10923. * @example
  10924. *
  10925. * var object = { 'a': 1, 'b': 2 };
  10926. * var other = { 'c': 3, 'd': 4 };
  10927. *
  10928. * var values = _.memoize(_.values);
  10929. * values(object);
  10930. * // => [1, 2]
  10931. *
  10932. * values(other);
  10933. * // => [3, 4]
  10934. *
  10935. * object.a = 2;
  10936. * values(object);
  10937. * // => [1, 2]
  10938. *
  10939. * // Modify the result cache.
  10940. * values.cache.set(object, ['a', 'b']);
  10941. * values(object);
  10942. * // => ['a', 'b']
  10943. *
  10944. * // Replace `_.memoize.Cache`.
  10945. * _.memoize.Cache = WeakMap;
  10946. */
  10947. function memoize(func, resolver) {
  10948. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  10949. throw new TypeError(FUNC_ERROR_TEXT);
  10950. }
  10951. var memoized = function() {
  10952. var args = arguments,
  10953. key = resolver ? resolver.apply(this, args) : args[0],
  10954. cache = memoized.cache;
  10955. if (cache.has(key)) {
  10956. return cache.get(key);
  10957. }
  10958. var result = func.apply(this, args);
  10959. memoized.cache = cache.set(key, result) || cache;
  10960. return result;
  10961. };
  10962. memoized.cache = new (memoize.Cache || MapCache);
  10963. return memoized;
  10964. }
  10965. // Expose `MapCache`.
  10966. memoize.Cache = MapCache;
  10967. /**
  10968. * Creates a function that negates the result of the predicate `func`. The
  10969. * `func` predicate is invoked with the `this` binding and arguments of the
  10970. * created function.
  10971. *
  10972. * @static
  10973. * @memberOf _
  10974. * @since 3.0.0
  10975. * @category Function
  10976. * @param {Function} predicate The predicate to negate.
  10977. * @returns {Function} Returns the new negated function.
  10978. * @example
  10979. *
  10980. * function isEven(n) {
  10981. * return n % 2 == 0;
  10982. * }
  10983. *
  10984. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  10985. * // => [1, 3, 5]
  10986. */
  10987. function negate(predicate) {
  10988. if (typeof predicate != 'function') {
  10989. throw new TypeError(FUNC_ERROR_TEXT);
  10990. }
  10991. return function() {
  10992. var args = arguments;
  10993. switch (args.length) {
  10994. case 0: return !predicate.call(this);
  10995. case 1: return !predicate.call(this, args[0]);
  10996. case 2: return !predicate.call(this, args[0], args[1]);
  10997. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  10998. }
  10999. return !predicate.apply(this, args);
  11000. };
  11001. }
  11002. /**
  11003. * Creates a function that is restricted to invoking `func` once. Repeat calls
  11004. * to the function return the value of the first invocation. The `func` is
  11005. * invoked with the `this` binding and arguments of the created function.
  11006. *
  11007. * @static
  11008. * @memberOf _
  11009. * @since 0.1.0
  11010. * @category Function
  11011. * @param {Function} func The function to restrict.
  11012. * @returns {Function} Returns the new restricted function.
  11013. * @example
  11014. *
  11015. * var initialize = _.once(createApplication);
  11016. * initialize();
  11017. * initialize();
  11018. * // => `createApplication` is invoked once
  11019. */
  11020. function once(func) {
  11021. return before(2, func);
  11022. }
  11023. /**
  11024. * Creates a function that invokes `func` with its arguments transformed.
  11025. *
  11026. * @static
  11027. * @since 4.0.0
  11028. * @memberOf _
  11029. * @category Function
  11030. * @param {Function} func The function to wrap.
  11031. * @param {...(Function|Function[])} [transforms=[_.identity]]
  11032. * The argument transforms.
  11033. * @returns {Function} Returns the new function.
  11034. * @example
  11035. *
  11036. * function doubled(n) {
  11037. * return n * 2;
  11038. * }
  11039. *
  11040. * function square(n) {
  11041. * return n * n;
  11042. * }
  11043. *
  11044. * var func = _.overArgs(function(x, y) {
  11045. * return [x, y];
  11046. * }, [square, doubled]);
  11047. *
  11048. * func(9, 3);
  11049. * // => [81, 6]
  11050. *
  11051. * func(10, 5);
  11052. * // => [100, 10]
  11053. */
  11054. var overArgs = castRest(function(func, transforms) {
  11055. transforms = (transforms.length == 1 && isArray(transforms[0]))
  11056. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  11057. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  11058. var funcsLength = transforms.length;
  11059. return baseRest(function(args) {
  11060. var index = -1,
  11061. length = nativeMin(args.length, funcsLength);
  11062. while (++index < length) {
  11063. args[index] = transforms[index].call(this, args[index]);
  11064. }
  11065. return apply(func, this, args);
  11066. });
  11067. });
  11068. /**
  11069. * Creates a function that invokes `func` with `partials` prepended to the
  11070. * arguments it receives. This method is like `_.bind` except it does **not**
  11071. * alter the `this` binding.
  11072. *
  11073. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  11074. * builds, may be used as a placeholder for partially applied arguments.
  11075. *
  11076. * **Note:** This method doesn't set the "length" property of partially
  11077. * applied functions.
  11078. *
  11079. * @static
  11080. * @memberOf _
  11081. * @since 0.2.0
  11082. * @category Function
  11083. * @param {Function} func The function to partially apply arguments to.
  11084. * @param {...*} [partials] The arguments to be partially applied.
  11085. * @returns {Function} Returns the new partially applied function.
  11086. * @example
  11087. *
  11088. * function greet(greeting, name) {
  11089. * return greeting + ' ' + name;
  11090. * }
  11091. *
  11092. * var sayHelloTo = _.partial(greet, 'hello');
  11093. * sayHelloTo('fred');
  11094. * // => 'hello fred'
  11095. *
  11096. * // Partially applied with placeholders.
  11097. * var greetFred = _.partial(greet, _, 'fred');
  11098. * greetFred('hi');
  11099. * // => 'hi fred'
  11100. */
  11101. var partial = baseRest(function(func, partials) {
  11102. var holders = replaceHolders(partials, getHolder(partial));
  11103. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  11104. });
  11105. /**
  11106. * This method is like `_.partial` except that partially applied arguments
  11107. * are appended to the arguments it receives.
  11108. *
  11109. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  11110. * builds, may be used as a placeholder for partially applied arguments.
  11111. *
  11112. * **Note:** This method doesn't set the "length" property of partially
  11113. * applied functions.
  11114. *
  11115. * @static
  11116. * @memberOf _
  11117. * @since 1.0.0
  11118. * @category Function
  11119. * @param {Function} func The function to partially apply arguments to.
  11120. * @param {...*} [partials] The arguments to be partially applied.
  11121. * @returns {Function} Returns the new partially applied function.
  11122. * @example
  11123. *
  11124. * function greet(greeting, name) {
  11125. * return greeting + ' ' + name;
  11126. * }
  11127. *
  11128. * var greetFred = _.partialRight(greet, 'fred');
  11129. * greetFred('hi');
  11130. * // => 'hi fred'
  11131. *
  11132. * // Partially applied with placeholders.
  11133. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  11134. * sayHelloTo('fred');
  11135. * // => 'hello fred'
  11136. */
  11137. var partialRight = baseRest(function(func, partials) {
  11138. var holders = replaceHolders(partials, getHolder(partialRight));
  11139. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  11140. });
  11141. /**
  11142. * Creates a function that invokes `func` with arguments arranged according
  11143. * to the specified `indexes` where the argument value at the first index is
  11144. * provided as the first argument, the argument value at the second index is
  11145. * provided as the second argument, and so on.
  11146. *
  11147. * @static
  11148. * @memberOf _
  11149. * @since 3.0.0
  11150. * @category Function
  11151. * @param {Function} func The function to rearrange arguments for.
  11152. * @param {...(number|number[])} indexes The arranged argument indexes.
  11153. * @returns {Function} Returns the new function.
  11154. * @example
  11155. *
  11156. * var rearged = _.rearg(function(a, b, c) {
  11157. * return [a, b, c];
  11158. * }, [2, 0, 1]);
  11159. *
  11160. * rearged('b', 'c', 'a')
  11161. * // => ['a', 'b', 'c']
  11162. */
  11163. var rearg = flatRest(function(func, indexes) {
  11164. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  11165. });
  11166. /**
  11167. * Creates a function that invokes `func` with the `this` binding of the
  11168. * created function and arguments from `start` and beyond provided as
  11169. * an array.
  11170. *
  11171. * **Note:** This method is based on the
  11172. * [rest parameter](https://mdn.io/rest_parameters).
  11173. *
  11174. * @static
  11175. * @memberOf _
  11176. * @since 4.0.0
  11177. * @category Function
  11178. * @param {Function} func The function to apply a rest parameter to.
  11179. * @param {number} [start=func.length-1] The start position of the rest parameter.
  11180. * @returns {Function} Returns the new function.
  11181. * @example
  11182. *
  11183. * var say = _.rest(function(what, names) {
  11184. * return what + ' ' + _.initial(names).join(', ') +
  11185. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  11186. * });
  11187. *
  11188. * say('hello', 'fred', 'barney', 'pebbles');
  11189. * // => 'hello fred, barney, & pebbles'
  11190. */
  11191. function rest(func, start) {
  11192. if (typeof func != 'function') {
  11193. throw new TypeError(FUNC_ERROR_TEXT);
  11194. }
  11195. start = start === undefined ? start : toInteger(start);
  11196. return baseRest(func, start);
  11197. }
  11198. /**
  11199. * Creates a function that invokes `func` with the `this` binding of the
  11200. * create function and an array of arguments much like
  11201. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  11202. *
  11203. * **Note:** This method is based on the
  11204. * [spread operator](https://mdn.io/spread_operator).
  11205. *
  11206. * @static
  11207. * @memberOf _
  11208. * @since 3.2.0
  11209. * @category Function
  11210. * @param {Function} func The function to spread arguments over.
  11211. * @param {number} [start=0] The start position of the spread.
  11212. * @returns {Function} Returns the new function.
  11213. * @example
  11214. *
  11215. * var say = _.spread(function(who, what) {
  11216. * return who + ' says ' + what;
  11217. * });
  11218. *
  11219. * say(['fred', 'hello']);
  11220. * // => 'fred says hello'
  11221. *
  11222. * var numbers = Promise.all([
  11223. * Promise.resolve(40),
  11224. * Promise.resolve(36)
  11225. * ]);
  11226. *
  11227. * numbers.then(_.spread(function(x, y) {
  11228. * return x + y;
  11229. * }));
  11230. * // => a Promise of 76
  11231. */
  11232. function spread(func, start) {
  11233. if (typeof func != 'function') {
  11234. throw new TypeError(FUNC_ERROR_TEXT);
  11235. }
  11236. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  11237. return baseRest(function(args) {
  11238. var array = args[start],
  11239. otherArgs = castSlice(args, 0, start);
  11240. if (array) {
  11241. arrayPush(otherArgs, array);
  11242. }
  11243. return apply(func, this, otherArgs);
  11244. });
  11245. }
  11246. /**
  11247. * Creates a throttled function that only invokes `func` at most once per
  11248. * every `wait` milliseconds. The throttled function comes with a `cancel`
  11249. * method to cancel delayed `func` invocations and a `flush` method to
  11250. * immediately invoke them. Provide `options` to indicate whether `func`
  11251. * should be invoked on the leading and/or trailing edge of the `wait`
  11252. * timeout. The `func` is invoked with the last arguments provided to the
  11253. * throttled function. Subsequent calls to the throttled function return the
  11254. * result of the last `func` invocation.
  11255. *
  11256. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  11257. * invoked on the trailing edge of the timeout only if the throttled function
  11258. * is invoked more than once during the `wait` timeout.
  11259. *
  11260. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  11261. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  11262. *
  11263. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  11264. * for details over the differences between `_.throttle` and `_.debounce`.
  11265. *
  11266. * @static
  11267. * @memberOf _
  11268. * @since 0.1.0
  11269. * @category Function
  11270. * @param {Function} func The function to throttle.
  11271. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  11272. * @param {Object} [options={}] The options object.
  11273. * @param {boolean} [options.leading=true]
  11274. * Specify invoking on the leading edge of the timeout.
  11275. * @param {boolean} [options.trailing=true]
  11276. * Specify invoking on the trailing edge of the timeout.
  11277. * @returns {Function} Returns the new throttled function.
  11278. * @example
  11279. *
  11280. * // Avoid excessively updating the position while scrolling.
  11281. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  11282. *
  11283. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  11284. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  11285. * jQuery(element).on('click', throttled);
  11286. *
  11287. * // Cancel the trailing throttled invocation.
  11288. * jQuery(window).on('popstate', throttled.cancel);
  11289. */
  11290. function throttle(func, wait, options) {
  11291. var leading = true,
  11292. trailing = true;
  11293. if (typeof func != 'function') {
  11294. throw new TypeError(FUNC_ERROR_TEXT);
  11295. }
  11296. if (isObject(options)) {
  11297. leading = 'leading' in options ? !!options.leading : leading;
  11298. trailing = 'trailing' in options ? !!options.trailing : trailing;
  11299. }
  11300. return debounce(func, wait, {
  11301. 'leading': leading,
  11302. 'maxWait': wait,
  11303. 'trailing': trailing
  11304. });
  11305. }
  11306. /**
  11307. * Creates a function that accepts up to one argument, ignoring any
  11308. * additional arguments.
  11309. *
  11310. * @static
  11311. * @memberOf _
  11312. * @since 4.0.0
  11313. * @category Function
  11314. * @param {Function} func The function to cap arguments for.
  11315. * @returns {Function} Returns the new capped function.
  11316. * @example
  11317. *
  11318. * _.map(['6', '8', '10'], _.unary(parseInt));
  11319. * // => [6, 8, 10]
  11320. */
  11321. function unary(func) {
  11322. return ary(func, 1);
  11323. }
  11324. /**
  11325. * Creates a function that provides `value` to `wrapper` as its first
  11326. * argument. Any additional arguments provided to the function are appended
  11327. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  11328. * binding of the created function.
  11329. *
  11330. * @static
  11331. * @memberOf _
  11332. * @since 0.1.0
  11333. * @category Function
  11334. * @param {*} value The value to wrap.
  11335. * @param {Function} [wrapper=identity] The wrapper function.
  11336. * @returns {Function} Returns the new function.
  11337. * @example
  11338. *
  11339. * var p = _.wrap(_.escape, function(func, text) {
  11340. * return '<p>' + func(text) + '</p>';
  11341. * });
  11342. *
  11343. * p('fred, barney, & pebbles');
  11344. * // => '<p>fred, barney, &amp; pebbles</p>'
  11345. */
  11346. function wrap(value, wrapper) {
  11347. return partial(castFunction(wrapper), value);
  11348. }
  11349. /*------------------------------------------------------------------------*/
  11350. /**
  11351. * Casts `value` as an array if it's not one.
  11352. *
  11353. * @static
  11354. * @memberOf _
  11355. * @since 4.4.0
  11356. * @category Lang
  11357. * @param {*} value The value to inspect.
  11358. * @returns {Array} Returns the cast array.
  11359. * @example
  11360. *
  11361. * _.castArray(1);
  11362. * // => [1]
  11363. *
  11364. * _.castArray({ 'a': 1 });
  11365. * // => [{ 'a': 1 }]
  11366. *
  11367. * _.castArray('abc');
  11368. * // => ['abc']
  11369. *
  11370. * _.castArray(null);
  11371. * // => [null]
  11372. *
  11373. * _.castArray(undefined);
  11374. * // => [undefined]
  11375. *
  11376. * _.castArray();
  11377. * // => []
  11378. *
  11379. * var array = [1, 2, 3];
  11380. * console.log(_.castArray(array) === array);
  11381. * // => true
  11382. */
  11383. function castArray() {
  11384. if (!arguments.length) {
  11385. return [];
  11386. }
  11387. var value = arguments[0];
  11388. return isArray(value) ? value : [value];
  11389. }
  11390. /**
  11391. * Creates a shallow clone of `value`.
  11392. *
  11393. * **Note:** This method is loosely based on the
  11394. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  11395. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  11396. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  11397. * arrays. The own enumerable properties of `arguments` objects are cloned
  11398. * as plain objects. An empty object is returned for uncloneable values such
  11399. * as error objects, functions, DOM nodes, and WeakMaps.
  11400. *
  11401. * @static
  11402. * @memberOf _
  11403. * @since 0.1.0
  11404. * @category Lang
  11405. * @param {*} value The value to clone.
  11406. * @returns {*} Returns the cloned value.
  11407. * @see _.cloneDeep
  11408. * @example
  11409. *
  11410. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11411. *
  11412. * var shallow = _.clone(objects);
  11413. * console.log(shallow[0] === objects[0]);
  11414. * // => true
  11415. */
  11416. function clone(value) {
  11417. return baseClone(value, CLONE_SYMBOLS_FLAG);
  11418. }
  11419. /**
  11420. * This method is like `_.clone` except that it accepts `customizer` which
  11421. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  11422. * cloning is handled by the method instead. The `customizer` is invoked with
  11423. * up to four arguments; (value [, index|key, object, stack]).
  11424. *
  11425. * @static
  11426. * @memberOf _
  11427. * @since 4.0.0
  11428. * @category Lang
  11429. * @param {*} value The value to clone.
  11430. * @param {Function} [customizer] The function to customize cloning.
  11431. * @returns {*} Returns the cloned value.
  11432. * @see _.cloneDeepWith
  11433. * @example
  11434. *
  11435. * function customizer(value) {
  11436. * if (_.isElement(value)) {
  11437. * return value.cloneNode(false);
  11438. * }
  11439. * }
  11440. *
  11441. * var el = _.cloneWith(document.body, customizer);
  11442. *
  11443. * console.log(el === document.body);
  11444. * // => false
  11445. * console.log(el.nodeName);
  11446. * // => 'BODY'
  11447. * console.log(el.childNodes.length);
  11448. * // => 0
  11449. */
  11450. function cloneWith(value, customizer) {
  11451. customizer = typeof customizer == 'function' ? customizer : undefined;
  11452. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  11453. }
  11454. /**
  11455. * This method is like `_.clone` except that it recursively clones `value`.
  11456. *
  11457. * @static
  11458. * @memberOf _
  11459. * @since 1.0.0
  11460. * @category Lang
  11461. * @param {*} value The value to recursively clone.
  11462. * @returns {*} Returns the deep cloned value.
  11463. * @see _.clone
  11464. * @example
  11465. *
  11466. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11467. *
  11468. * var deep = _.cloneDeep(objects);
  11469. * console.log(deep[0] === objects[0]);
  11470. * // => false
  11471. */
  11472. function cloneDeep(value) {
  11473. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  11474. }
  11475. /**
  11476. * This method is like `_.cloneWith` except that it recursively clones `value`.
  11477. *
  11478. * @static
  11479. * @memberOf _
  11480. * @since 4.0.0
  11481. * @category Lang
  11482. * @param {*} value The value to recursively clone.
  11483. * @param {Function} [customizer] The function to customize cloning.
  11484. * @returns {*} Returns the deep cloned value.
  11485. * @see _.cloneWith
  11486. * @example
  11487. *
  11488. * function customizer(value) {
  11489. * if (_.isElement(value)) {
  11490. * return value.cloneNode(true);
  11491. * }
  11492. * }
  11493. *
  11494. * var el = _.cloneDeepWith(document.body, customizer);
  11495. *
  11496. * console.log(el === document.body);
  11497. * // => false
  11498. * console.log(el.nodeName);
  11499. * // => 'BODY'
  11500. * console.log(el.childNodes.length);
  11501. * // => 20
  11502. */
  11503. function cloneDeepWith(value, customizer) {
  11504. customizer = typeof customizer == 'function' ? customizer : undefined;
  11505. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  11506. }
  11507. /**
  11508. * Checks if `object` conforms to `source` by invoking the predicate
  11509. * properties of `source` with the corresponding property values of `object`.
  11510. *
  11511. * **Note:** This method is equivalent to `_.conforms` when `source` is
  11512. * partially applied.
  11513. *
  11514. * @static
  11515. * @memberOf _
  11516. * @since 4.14.0
  11517. * @category Lang
  11518. * @param {Object} object The object to inspect.
  11519. * @param {Object} source The object of property predicates to conform to.
  11520. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  11521. * @example
  11522. *
  11523. * var object = { 'a': 1, 'b': 2 };
  11524. *
  11525. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  11526. * // => true
  11527. *
  11528. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  11529. * // => false
  11530. */
  11531. function conformsTo(object, source) {
  11532. return source == null || baseConformsTo(object, source, keys(source));
  11533. }
  11534. /**
  11535. * Performs a
  11536. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11537. * comparison between two values to determine if they are equivalent.
  11538. *
  11539. * @static
  11540. * @memberOf _
  11541. * @since 4.0.0
  11542. * @category Lang
  11543. * @param {*} value The value to compare.
  11544. * @param {*} other The other value to compare.
  11545. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11546. * @example
  11547. *
  11548. * var object = { 'a': 1 };
  11549. * var other = { 'a': 1 };
  11550. *
  11551. * _.eq(object, object);
  11552. * // => true
  11553. *
  11554. * _.eq(object, other);
  11555. * // => false
  11556. *
  11557. * _.eq('a', 'a');
  11558. * // => true
  11559. *
  11560. * _.eq('a', Object('a'));
  11561. * // => false
  11562. *
  11563. * _.eq(NaN, NaN);
  11564. * // => true
  11565. */
  11566. function eq(value, other) {
  11567. return value === other || (value !== value && other !== other);
  11568. }
  11569. /**
  11570. * Checks if `value` is greater than `other`.
  11571. *
  11572. * @static
  11573. * @memberOf _
  11574. * @since 3.9.0
  11575. * @category Lang
  11576. * @param {*} value The value to compare.
  11577. * @param {*} other The other value to compare.
  11578. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  11579. * else `false`.
  11580. * @see _.lt
  11581. * @example
  11582. *
  11583. * _.gt(3, 1);
  11584. * // => true
  11585. *
  11586. * _.gt(3, 3);
  11587. * // => false
  11588. *
  11589. * _.gt(1, 3);
  11590. * // => false
  11591. */
  11592. var gt = createRelationalOperation(baseGt);
  11593. /**
  11594. * Checks if `value` is greater than or equal to `other`.
  11595. *
  11596. * @static
  11597. * @memberOf _
  11598. * @since 3.9.0
  11599. * @category Lang
  11600. * @param {*} value The value to compare.
  11601. * @param {*} other The other value to compare.
  11602. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  11603. * `other`, else `false`.
  11604. * @see _.lte
  11605. * @example
  11606. *
  11607. * _.gte(3, 1);
  11608. * // => true
  11609. *
  11610. * _.gte(3, 3);
  11611. * // => true
  11612. *
  11613. * _.gte(1, 3);
  11614. * // => false
  11615. */
  11616. var gte = createRelationalOperation(function(value, other) {
  11617. return value >= other;
  11618. });
  11619. /**
  11620. * Checks if `value` is likely an `arguments` object.
  11621. *
  11622. * @static
  11623. * @memberOf _
  11624. * @since 0.1.0
  11625. * @category Lang
  11626. * @param {*} value The value to check.
  11627. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  11628. * else `false`.
  11629. * @example
  11630. *
  11631. * _.isArguments(function() { return arguments; }());
  11632. * // => true
  11633. *
  11634. * _.isArguments([1, 2, 3]);
  11635. * // => false
  11636. */
  11637. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  11638. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  11639. !propertyIsEnumerable.call(value, 'callee');
  11640. };
  11641. /**
  11642. * Checks if `value` is classified as an `Array` object.
  11643. *
  11644. * @static
  11645. * @memberOf _
  11646. * @since 0.1.0
  11647. * @category Lang
  11648. * @param {*} value The value to check.
  11649. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  11650. * @example
  11651. *
  11652. * _.isArray([1, 2, 3]);
  11653. * // => true
  11654. *
  11655. * _.isArray(document.body.children);
  11656. * // => false
  11657. *
  11658. * _.isArray('abc');
  11659. * // => false
  11660. *
  11661. * _.isArray(_.noop);
  11662. * // => false
  11663. */
  11664. var isArray = Array.isArray;
  11665. /**
  11666. * Checks if `value` is classified as an `ArrayBuffer` object.
  11667. *
  11668. * @static
  11669. * @memberOf _
  11670. * @since 4.3.0
  11671. * @category Lang
  11672. * @param {*} value The value to check.
  11673. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  11674. * @example
  11675. *
  11676. * _.isArrayBuffer(new ArrayBuffer(2));
  11677. * // => true
  11678. *
  11679. * _.isArrayBuffer(new Array(2));
  11680. * // => false
  11681. */
  11682. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  11683. /**
  11684. * Checks if `value` is array-like. A value is considered array-like if it's
  11685. * not a function and has a `value.length` that's an integer greater than or
  11686. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  11687. *
  11688. * @static
  11689. * @memberOf _
  11690. * @since 4.0.0
  11691. * @category Lang
  11692. * @param {*} value The value to check.
  11693. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  11694. * @example
  11695. *
  11696. * _.isArrayLike([1, 2, 3]);
  11697. * // => true
  11698. *
  11699. * _.isArrayLike(document.body.children);
  11700. * // => true
  11701. *
  11702. * _.isArrayLike('abc');
  11703. * // => true
  11704. *
  11705. * _.isArrayLike(_.noop);
  11706. * // => false
  11707. */
  11708. function isArrayLike(value) {
  11709. return value != null && isLength(value.length) && !isFunction(value);
  11710. }
  11711. /**
  11712. * This method is like `_.isArrayLike` except that it also checks if `value`
  11713. * is an object.
  11714. *
  11715. * @static
  11716. * @memberOf _
  11717. * @since 4.0.0
  11718. * @category Lang
  11719. * @param {*} value The value to check.
  11720. * @returns {boolean} Returns `true` if `value` is an array-like object,
  11721. * else `false`.
  11722. * @example
  11723. *
  11724. * _.isArrayLikeObject([1, 2, 3]);
  11725. * // => true
  11726. *
  11727. * _.isArrayLikeObject(document.body.children);
  11728. * // => true
  11729. *
  11730. * _.isArrayLikeObject('abc');
  11731. * // => false
  11732. *
  11733. * _.isArrayLikeObject(_.noop);
  11734. * // => false
  11735. */
  11736. function isArrayLikeObject(value) {
  11737. return isObjectLike(value) && isArrayLike(value);
  11738. }
  11739. /**
  11740. * Checks if `value` is classified as a boolean primitive or object.
  11741. *
  11742. * @static
  11743. * @memberOf _
  11744. * @since 0.1.0
  11745. * @category Lang
  11746. * @param {*} value The value to check.
  11747. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  11748. * @example
  11749. *
  11750. * _.isBoolean(false);
  11751. * // => true
  11752. *
  11753. * _.isBoolean(null);
  11754. * // => false
  11755. */
  11756. function isBoolean(value) {
  11757. return value === true || value === false ||
  11758. (isObjectLike(value) && baseGetTag(value) == boolTag);
  11759. }
  11760. /**
  11761. * Checks if `value` is a buffer.
  11762. *
  11763. * @static
  11764. * @memberOf _
  11765. * @since 4.3.0
  11766. * @category Lang
  11767. * @param {*} value The value to check.
  11768. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  11769. * @example
  11770. *
  11771. * _.isBuffer(new Buffer(2));
  11772. * // => true
  11773. *
  11774. * _.isBuffer(new Uint8Array(2));
  11775. * // => false
  11776. */
  11777. var isBuffer = nativeIsBuffer || stubFalse;
  11778. /**
  11779. * Checks if `value` is classified as a `Date` object.
  11780. *
  11781. * @static
  11782. * @memberOf _
  11783. * @since 0.1.0
  11784. * @category Lang
  11785. * @param {*} value The value to check.
  11786. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  11787. * @example
  11788. *
  11789. * _.isDate(new Date);
  11790. * // => true
  11791. *
  11792. * _.isDate('Mon April 23 2012');
  11793. * // => false
  11794. */
  11795. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  11796. /**
  11797. * Checks if `value` is likely a DOM element.
  11798. *
  11799. * @static
  11800. * @memberOf _
  11801. * @since 0.1.0
  11802. * @category Lang
  11803. * @param {*} value The value to check.
  11804. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  11805. * @example
  11806. *
  11807. * _.isElement(document.body);
  11808. * // => true
  11809. *
  11810. * _.isElement('<body>');
  11811. * // => false
  11812. */
  11813. function isElement(value) {
  11814. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  11815. }
  11816. /**
  11817. * Checks if `value` is an empty object, collection, map, or set.
  11818. *
  11819. * Objects are considered empty if they have no own enumerable string keyed
  11820. * properties.
  11821. *
  11822. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  11823. * jQuery-like collections are considered empty if they have a `length` of `0`.
  11824. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  11825. *
  11826. * @static
  11827. * @memberOf _
  11828. * @since 0.1.0
  11829. * @category Lang
  11830. * @param {*} value The value to check.
  11831. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  11832. * @example
  11833. *
  11834. * _.isEmpty(null);
  11835. * // => true
  11836. *
  11837. * _.isEmpty(true);
  11838. * // => true
  11839. *
  11840. * _.isEmpty(1);
  11841. * // => true
  11842. *
  11843. * _.isEmpty([1, 2, 3]);
  11844. * // => false
  11845. *
  11846. * _.isEmpty({ 'a': 1 });
  11847. * // => false
  11848. */
  11849. function isEmpty(value) {
  11850. if (value == null) {
  11851. return true;
  11852. }
  11853. if (isArrayLike(value) &&
  11854. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  11855. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  11856. return !value.length;
  11857. }
  11858. var tag = getTag(value);
  11859. if (tag == mapTag || tag == setTag) {
  11860. return !value.size;
  11861. }
  11862. if (isPrototype(value)) {
  11863. return !baseKeys(value).length;
  11864. }
  11865. for (var key in value) {
  11866. if (hasOwnProperty.call(value, key)) {
  11867. return false;
  11868. }
  11869. }
  11870. return true;
  11871. }
  11872. /**
  11873. * Performs a deep comparison between two values to determine if they are
  11874. * equivalent.
  11875. *
  11876. * **Note:** This method supports comparing arrays, array buffers, booleans,
  11877. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  11878. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  11879. * by their own, not inherited, enumerable properties. Functions and DOM
  11880. * nodes are compared by strict equality, i.e. `===`.
  11881. *
  11882. * @static
  11883. * @memberOf _
  11884. * @since 0.1.0
  11885. * @category Lang
  11886. * @param {*} value The value to compare.
  11887. * @param {*} other The other value to compare.
  11888. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11889. * @example
  11890. *
  11891. * var object = { 'a': 1 };
  11892. * var other = { 'a': 1 };
  11893. *
  11894. * _.isEqual(object, other);
  11895. * // => true
  11896. *
  11897. * object === other;
  11898. * // => false
  11899. */
  11900. function isEqual(value, other) {
  11901. return baseIsEqual(value, other);
  11902. }
  11903. /**
  11904. * This method is like `_.isEqual` except that it accepts `customizer` which
  11905. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  11906. * are handled by the method instead. The `customizer` is invoked with up to
  11907. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  11908. *
  11909. * @static
  11910. * @memberOf _
  11911. * @since 4.0.0
  11912. * @category Lang
  11913. * @param {*} value The value to compare.
  11914. * @param {*} other The other value to compare.
  11915. * @param {Function} [customizer] The function to customize comparisons.
  11916. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11917. * @example
  11918. *
  11919. * function isGreeting(value) {
  11920. * return /^h(?:i|ello)$/.test(value);
  11921. * }
  11922. *
  11923. * function customizer(objValue, othValue) {
  11924. * if (isGreeting(objValue) && isGreeting(othValue)) {
  11925. * return true;
  11926. * }
  11927. * }
  11928. *
  11929. * var array = ['hello', 'goodbye'];
  11930. * var other = ['hi', 'goodbye'];
  11931. *
  11932. * _.isEqualWith(array, other, customizer);
  11933. * // => true
  11934. */
  11935. function isEqualWith(value, other, customizer) {
  11936. customizer = typeof customizer == 'function' ? customizer : undefined;
  11937. var result = customizer ? customizer(value, other) : undefined;
  11938. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  11939. }
  11940. /**
  11941. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  11942. * `SyntaxError`, `TypeError`, or `URIError` object.
  11943. *
  11944. * @static
  11945. * @memberOf _
  11946. * @since 3.0.0
  11947. * @category Lang
  11948. * @param {*} value The value to check.
  11949. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  11950. * @example
  11951. *
  11952. * _.isError(new Error);
  11953. * // => true
  11954. *
  11955. * _.isError(Error);
  11956. * // => false
  11957. */
  11958. function isError(value) {
  11959. if (!isObjectLike(value)) {
  11960. return false;
  11961. }
  11962. var tag = baseGetTag(value);
  11963. return tag == errorTag || tag == domExcTag ||
  11964. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  11965. }
  11966. /**
  11967. * Checks if `value` is a finite primitive number.
  11968. *
  11969. * **Note:** This method is based on
  11970. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  11971. *
  11972. * @static
  11973. * @memberOf _
  11974. * @since 0.1.0
  11975. * @category Lang
  11976. * @param {*} value The value to check.
  11977. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  11978. * @example
  11979. *
  11980. * _.isFinite(3);
  11981. * // => true
  11982. *
  11983. * _.isFinite(Number.MIN_VALUE);
  11984. * // => true
  11985. *
  11986. * _.isFinite(Infinity);
  11987. * // => false
  11988. *
  11989. * _.isFinite('3');
  11990. * // => false
  11991. */
  11992. function isFinite(value) {
  11993. return typeof value == 'number' && nativeIsFinite(value);
  11994. }
  11995. /**
  11996. * Checks if `value` is classified as a `Function` object.
  11997. *
  11998. * @static
  11999. * @memberOf _
  12000. * @since 0.1.0
  12001. * @category Lang
  12002. * @param {*} value The value to check.
  12003. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  12004. * @example
  12005. *
  12006. * _.isFunction(_);
  12007. * // => true
  12008. *
  12009. * _.isFunction(/abc/);
  12010. * // => false
  12011. */
  12012. function isFunction(value) {
  12013. if (!isObject(value)) {
  12014. return false;
  12015. }
  12016. // The use of `Object#toString` avoids issues with the `typeof` operator
  12017. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  12018. var tag = baseGetTag(value);
  12019. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  12020. }
  12021. /**
  12022. * Checks if `value` is an integer.
  12023. *
  12024. * **Note:** This method is based on
  12025. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  12026. *
  12027. * @static
  12028. * @memberOf _
  12029. * @since 4.0.0
  12030. * @category Lang
  12031. * @param {*} value The value to check.
  12032. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  12033. * @example
  12034. *
  12035. * _.isInteger(3);
  12036. * // => true
  12037. *
  12038. * _.isInteger(Number.MIN_VALUE);
  12039. * // => false
  12040. *
  12041. * _.isInteger(Infinity);
  12042. * // => false
  12043. *
  12044. * _.isInteger('3');
  12045. * // => false
  12046. */
  12047. function isInteger(value) {
  12048. return typeof value == 'number' && value == toInteger(value);
  12049. }
  12050. /**
  12051. * Checks if `value` is a valid array-like length.
  12052. *
  12053. * **Note:** This method is loosely based on
  12054. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12055. *
  12056. * @static
  12057. * @memberOf _
  12058. * @since 4.0.0
  12059. * @category Lang
  12060. * @param {*} value The value to check.
  12061. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  12062. * @example
  12063. *
  12064. * _.isLength(3);
  12065. * // => true
  12066. *
  12067. * _.isLength(Number.MIN_VALUE);
  12068. * // => false
  12069. *
  12070. * _.isLength(Infinity);
  12071. * // => false
  12072. *
  12073. * _.isLength('3');
  12074. * // => false
  12075. */
  12076. function isLength(value) {
  12077. return typeof value == 'number' &&
  12078. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  12079. }
  12080. /**
  12081. * Checks if `value` is the
  12082. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  12083. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  12084. *
  12085. * @static
  12086. * @memberOf _
  12087. * @since 0.1.0
  12088. * @category Lang
  12089. * @param {*} value The value to check.
  12090. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  12091. * @example
  12092. *
  12093. * _.isObject({});
  12094. * // => true
  12095. *
  12096. * _.isObject([1, 2, 3]);
  12097. * // => true
  12098. *
  12099. * _.isObject(_.noop);
  12100. * // => true
  12101. *
  12102. * _.isObject(null);
  12103. * // => false
  12104. */
  12105. function isObject(value) {
  12106. var type = typeof value;
  12107. return value != null && (type == 'object' || type == 'function');
  12108. }
  12109. /**
  12110. * Checks if `value` is object-like. A value is object-like if it's not `null`
  12111. * and has a `typeof` result of "object".
  12112. *
  12113. * @static
  12114. * @memberOf _
  12115. * @since 4.0.0
  12116. * @category Lang
  12117. * @param {*} value The value to check.
  12118. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  12119. * @example
  12120. *
  12121. * _.isObjectLike({});
  12122. * // => true
  12123. *
  12124. * _.isObjectLike([1, 2, 3]);
  12125. * // => true
  12126. *
  12127. * _.isObjectLike(_.noop);
  12128. * // => false
  12129. *
  12130. * _.isObjectLike(null);
  12131. * // => false
  12132. */
  12133. function isObjectLike(value) {
  12134. return value != null && typeof value == 'object';
  12135. }
  12136. /**
  12137. * Checks if `value` is classified as a `Map` object.
  12138. *
  12139. * @static
  12140. * @memberOf _
  12141. * @since 4.3.0
  12142. * @category Lang
  12143. * @param {*} value The value to check.
  12144. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  12145. * @example
  12146. *
  12147. * _.isMap(new Map);
  12148. * // => true
  12149. *
  12150. * _.isMap(new WeakMap);
  12151. * // => false
  12152. */
  12153. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  12154. /**
  12155. * Performs a partial deep comparison between `object` and `source` to
  12156. * determine if `object` contains equivalent property values.
  12157. *
  12158. * **Note:** This method is equivalent to `_.matches` when `source` is
  12159. * partially applied.
  12160. *
  12161. * Partial comparisons will match empty array and empty object `source`
  12162. * values against any array or object value, respectively. See `_.isEqual`
  12163. * for a list of supported value comparisons.
  12164. *
  12165. * @static
  12166. * @memberOf _
  12167. * @since 3.0.0
  12168. * @category Lang
  12169. * @param {Object} object The object to inspect.
  12170. * @param {Object} source The object of property values to match.
  12171. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12172. * @example
  12173. *
  12174. * var object = { 'a': 1, 'b': 2 };
  12175. *
  12176. * _.isMatch(object, { 'b': 2 });
  12177. * // => true
  12178. *
  12179. * _.isMatch(object, { 'b': 1 });
  12180. * // => false
  12181. */
  12182. function isMatch(object, source) {
  12183. return object === source || baseIsMatch(object, source, getMatchData(source));
  12184. }
  12185. /**
  12186. * This method is like `_.isMatch` except that it accepts `customizer` which
  12187. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  12188. * are handled by the method instead. The `customizer` is invoked with five
  12189. * arguments: (objValue, srcValue, index|key, object, source).
  12190. *
  12191. * @static
  12192. * @memberOf _
  12193. * @since 4.0.0
  12194. * @category Lang
  12195. * @param {Object} object The object to inspect.
  12196. * @param {Object} source The object of property values to match.
  12197. * @param {Function} [customizer] The function to customize comparisons.
  12198. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12199. * @example
  12200. *
  12201. * function isGreeting(value) {
  12202. * return /^h(?:i|ello)$/.test(value);
  12203. * }
  12204. *
  12205. * function customizer(objValue, srcValue) {
  12206. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  12207. * return true;
  12208. * }
  12209. * }
  12210. *
  12211. * var object = { 'greeting': 'hello' };
  12212. * var source = { 'greeting': 'hi' };
  12213. *
  12214. * _.isMatchWith(object, source, customizer);
  12215. * // => true
  12216. */
  12217. function isMatchWith(object, source, customizer) {
  12218. customizer = typeof customizer == 'function' ? customizer : undefined;
  12219. return baseIsMatch(object, source, getMatchData(source), customizer);
  12220. }
  12221. /**
  12222. * Checks if `value` is `NaN`.
  12223. *
  12224. * **Note:** This method is based on
  12225. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  12226. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  12227. * `undefined` and other non-number values.
  12228. *
  12229. * @static
  12230. * @memberOf _
  12231. * @since 0.1.0
  12232. * @category Lang
  12233. * @param {*} value The value to check.
  12234. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  12235. * @example
  12236. *
  12237. * _.isNaN(NaN);
  12238. * // => true
  12239. *
  12240. * _.isNaN(new Number(NaN));
  12241. * // => true
  12242. *
  12243. * isNaN(undefined);
  12244. * // => true
  12245. *
  12246. * _.isNaN(undefined);
  12247. * // => false
  12248. */
  12249. function isNaN(value) {
  12250. // An `NaN` primitive is the only value that is not equal to itself.
  12251. // Perform the `toStringTag` check first to avoid errors with some
  12252. // ActiveX objects in IE.
  12253. return isNumber(value) && value != +value;
  12254. }
  12255. /**
  12256. * Checks if `value` is a pristine native function.
  12257. *
  12258. * **Note:** This method can't reliably detect native functions in the presence
  12259. * of the core-js package because core-js circumvents this kind of detection.
  12260. * Despite multiple requests, the core-js maintainer has made it clear: any
  12261. * attempt to fix the detection will be obstructed. As a result, we're left
  12262. * with little choice but to throw an error. Unfortunately, this also affects
  12263. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  12264. * which rely on core-js.
  12265. *
  12266. * @static
  12267. * @memberOf _
  12268. * @since 3.0.0
  12269. * @category Lang
  12270. * @param {*} value The value to check.
  12271. * @returns {boolean} Returns `true` if `value` is a native function,
  12272. * else `false`.
  12273. * @example
  12274. *
  12275. * _.isNative(Array.prototype.push);
  12276. * // => true
  12277. *
  12278. * _.isNative(_);
  12279. * // => false
  12280. */
  12281. function isNative(value) {
  12282. if (isMaskable(value)) {
  12283. throw new Error(CORE_ERROR_TEXT);
  12284. }
  12285. return baseIsNative(value);
  12286. }
  12287. /**
  12288. * Checks if `value` is `null`.
  12289. *
  12290. * @static
  12291. * @memberOf _
  12292. * @since 0.1.0
  12293. * @category Lang
  12294. * @param {*} value The value to check.
  12295. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  12296. * @example
  12297. *
  12298. * _.isNull(null);
  12299. * // => true
  12300. *
  12301. * _.isNull(void 0);
  12302. * // => false
  12303. */
  12304. function isNull(value) {
  12305. return value === null;
  12306. }
  12307. /**
  12308. * Checks if `value` is `null` or `undefined`.
  12309. *
  12310. * @static
  12311. * @memberOf _
  12312. * @since 4.0.0
  12313. * @category Lang
  12314. * @param {*} value The value to check.
  12315. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  12316. * @example
  12317. *
  12318. * _.isNil(null);
  12319. * // => true
  12320. *
  12321. * _.isNil(void 0);
  12322. * // => true
  12323. *
  12324. * _.isNil(NaN);
  12325. * // => false
  12326. */
  12327. function isNil(value) {
  12328. return value == null;
  12329. }
  12330. /**
  12331. * Checks if `value` is classified as a `Number` primitive or object.
  12332. *
  12333. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  12334. * classified as numbers, use the `_.isFinite` method.
  12335. *
  12336. * @static
  12337. * @memberOf _
  12338. * @since 0.1.0
  12339. * @category Lang
  12340. * @param {*} value The value to check.
  12341. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  12342. * @example
  12343. *
  12344. * _.isNumber(3);
  12345. * // => true
  12346. *
  12347. * _.isNumber(Number.MIN_VALUE);
  12348. * // => true
  12349. *
  12350. * _.isNumber(Infinity);
  12351. * // => true
  12352. *
  12353. * _.isNumber('3');
  12354. * // => false
  12355. */
  12356. function isNumber(value) {
  12357. return typeof value == 'number' ||
  12358. (isObjectLike(value) && baseGetTag(value) == numberTag);
  12359. }
  12360. /**
  12361. * Checks if `value` is a plain object, that is, an object created by the
  12362. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  12363. *
  12364. * @static
  12365. * @memberOf _
  12366. * @since 0.8.0
  12367. * @category Lang
  12368. * @param {*} value The value to check.
  12369. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  12370. * @example
  12371. *
  12372. * function Foo() {
  12373. * this.a = 1;
  12374. * }
  12375. *
  12376. * _.isPlainObject(new Foo);
  12377. * // => false
  12378. *
  12379. * _.isPlainObject([1, 2, 3]);
  12380. * // => false
  12381. *
  12382. * _.isPlainObject({ 'x': 0, 'y': 0 });
  12383. * // => true
  12384. *
  12385. * _.isPlainObject(Object.create(null));
  12386. * // => true
  12387. */
  12388. function isPlainObject(value) {
  12389. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  12390. return false;
  12391. }
  12392. var proto = getPrototype(value);
  12393. if (proto === null) {
  12394. return true;
  12395. }
  12396. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  12397. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  12398. funcToString.call(Ctor) == objectCtorString;
  12399. }
  12400. /**
  12401. * Checks if `value` is classified as a `RegExp` object.
  12402. *
  12403. * @static
  12404. * @memberOf _
  12405. * @since 0.1.0
  12406. * @category Lang
  12407. * @param {*} value The value to check.
  12408. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  12409. * @example
  12410. *
  12411. * _.isRegExp(/abc/);
  12412. * // => true
  12413. *
  12414. * _.isRegExp('/abc/');
  12415. * // => false
  12416. */
  12417. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  12418. /**
  12419. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  12420. * double precision number which isn't the result of a rounded unsafe integer.
  12421. *
  12422. * **Note:** This method is based on
  12423. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  12424. *
  12425. * @static
  12426. * @memberOf _
  12427. * @since 4.0.0
  12428. * @category Lang
  12429. * @param {*} value The value to check.
  12430. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  12431. * @example
  12432. *
  12433. * _.isSafeInteger(3);
  12434. * // => true
  12435. *
  12436. * _.isSafeInteger(Number.MIN_VALUE);
  12437. * // => false
  12438. *
  12439. * _.isSafeInteger(Infinity);
  12440. * // => false
  12441. *
  12442. * _.isSafeInteger('3');
  12443. * // => false
  12444. */
  12445. function isSafeInteger(value) {
  12446. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  12447. }
  12448. /**
  12449. * Checks if `value` is classified as a `Set` object.
  12450. *
  12451. * @static
  12452. * @memberOf _
  12453. * @since 4.3.0
  12454. * @category Lang
  12455. * @param {*} value The value to check.
  12456. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  12457. * @example
  12458. *
  12459. * _.isSet(new Set);
  12460. * // => true
  12461. *
  12462. * _.isSet(new WeakSet);
  12463. * // => false
  12464. */
  12465. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  12466. /**
  12467. * Checks if `value` is classified as a `String` primitive or object.
  12468. *
  12469. * @static
  12470. * @since 0.1.0
  12471. * @memberOf _
  12472. * @category Lang
  12473. * @param {*} value The value to check.
  12474. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  12475. * @example
  12476. *
  12477. * _.isString('abc');
  12478. * // => true
  12479. *
  12480. * _.isString(1);
  12481. * // => false
  12482. */
  12483. function isString(value) {
  12484. return typeof value == 'string' ||
  12485. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  12486. }
  12487. /**
  12488. * Checks if `value` is classified as a `Symbol` primitive or object.
  12489. *
  12490. * @static
  12491. * @memberOf _
  12492. * @since 4.0.0
  12493. * @category Lang
  12494. * @param {*} value The value to check.
  12495. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  12496. * @example
  12497. *
  12498. * _.isSymbol(Symbol.iterator);
  12499. * // => true
  12500. *
  12501. * _.isSymbol('abc');
  12502. * // => false
  12503. */
  12504. function isSymbol(value) {
  12505. return typeof value == 'symbol' ||
  12506. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  12507. }
  12508. /**
  12509. * Checks if `value` is classified as a typed array.
  12510. *
  12511. * @static
  12512. * @memberOf _
  12513. * @since 3.0.0
  12514. * @category Lang
  12515. * @param {*} value The value to check.
  12516. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  12517. * @example
  12518. *
  12519. * _.isTypedArray(new Uint8Array);
  12520. * // => true
  12521. *
  12522. * _.isTypedArray([]);
  12523. * // => false
  12524. */
  12525. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  12526. /**
  12527. * Checks if `value` is `undefined`.
  12528. *
  12529. * @static
  12530. * @since 0.1.0
  12531. * @memberOf _
  12532. * @category Lang
  12533. * @param {*} value The value to check.
  12534. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  12535. * @example
  12536. *
  12537. * _.isUndefined(void 0);
  12538. * // => true
  12539. *
  12540. * _.isUndefined(null);
  12541. * // => false
  12542. */
  12543. function isUndefined(value) {
  12544. return value === undefined;
  12545. }
  12546. /**
  12547. * Checks if `value` is classified as a `WeakMap` object.
  12548. *
  12549. * @static
  12550. * @memberOf _
  12551. * @since 4.3.0
  12552. * @category Lang
  12553. * @param {*} value The value to check.
  12554. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  12555. * @example
  12556. *
  12557. * _.isWeakMap(new WeakMap);
  12558. * // => true
  12559. *
  12560. * _.isWeakMap(new Map);
  12561. * // => false
  12562. */
  12563. function isWeakMap(value) {
  12564. return isObjectLike(value) && getTag(value) == weakMapTag;
  12565. }
  12566. /**
  12567. * Checks if `value` is classified as a `WeakSet` object.
  12568. *
  12569. * @static
  12570. * @memberOf _
  12571. * @since 4.3.0
  12572. * @category Lang
  12573. * @param {*} value The value to check.
  12574. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  12575. * @example
  12576. *
  12577. * _.isWeakSet(new WeakSet);
  12578. * // => true
  12579. *
  12580. * _.isWeakSet(new Set);
  12581. * // => false
  12582. */
  12583. function isWeakSet(value) {
  12584. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  12585. }
  12586. /**
  12587. * Checks if `value` is less than `other`.
  12588. *
  12589. * @static
  12590. * @memberOf _
  12591. * @since 3.9.0
  12592. * @category Lang
  12593. * @param {*} value The value to compare.
  12594. * @param {*} other The other value to compare.
  12595. * @returns {boolean} Returns `true` if `value` is less than `other`,
  12596. * else `false`.
  12597. * @see _.gt
  12598. * @example
  12599. *
  12600. * _.lt(1, 3);
  12601. * // => true
  12602. *
  12603. * _.lt(3, 3);
  12604. * // => false
  12605. *
  12606. * _.lt(3, 1);
  12607. * // => false
  12608. */
  12609. var lt = createRelationalOperation(baseLt);
  12610. /**
  12611. * Checks if `value` is less than or equal to `other`.
  12612. *
  12613. * @static
  12614. * @memberOf _
  12615. * @since 3.9.0
  12616. * @category Lang
  12617. * @param {*} value The value to compare.
  12618. * @param {*} other The other value to compare.
  12619. * @returns {boolean} Returns `true` if `value` is less than or equal to
  12620. * `other`, else `false`.
  12621. * @see _.gte
  12622. * @example
  12623. *
  12624. * _.lte(1, 3);
  12625. * // => true
  12626. *
  12627. * _.lte(3, 3);
  12628. * // => true
  12629. *
  12630. * _.lte(3, 1);
  12631. * // => false
  12632. */
  12633. var lte = createRelationalOperation(function(value, other) {
  12634. return value <= other;
  12635. });
  12636. /**
  12637. * Converts `value` to an array.
  12638. *
  12639. * @static
  12640. * @since 0.1.0
  12641. * @memberOf _
  12642. * @category Lang
  12643. * @param {*} value The value to convert.
  12644. * @returns {Array} Returns the converted array.
  12645. * @example
  12646. *
  12647. * _.toArray({ 'a': 1, 'b': 2 });
  12648. * // => [1, 2]
  12649. *
  12650. * _.toArray('abc');
  12651. * // => ['a', 'b', 'c']
  12652. *
  12653. * _.toArray(1);
  12654. * // => []
  12655. *
  12656. * _.toArray(null);
  12657. * // => []
  12658. */
  12659. function toArray(value) {
  12660. if (!value) {
  12661. return [];
  12662. }
  12663. if (isArrayLike(value)) {
  12664. return isString(value) ? stringToArray(value) : copyArray(value);
  12665. }
  12666. if (symIterator && value[symIterator]) {
  12667. return iteratorToArray(value[symIterator]());
  12668. }
  12669. var tag = getTag(value),
  12670. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  12671. return func(value);
  12672. }
  12673. /**
  12674. * Converts `value` to a finite number.
  12675. *
  12676. * @static
  12677. * @memberOf _
  12678. * @since 4.12.0
  12679. * @category Lang
  12680. * @param {*} value The value to convert.
  12681. * @returns {number} Returns the converted number.
  12682. * @example
  12683. *
  12684. * _.toFinite(3.2);
  12685. * // => 3.2
  12686. *
  12687. * _.toFinite(Number.MIN_VALUE);
  12688. * // => 5e-324
  12689. *
  12690. * _.toFinite(Infinity);
  12691. * // => 1.7976931348623157e+308
  12692. *
  12693. * _.toFinite('3.2');
  12694. * // => 3.2
  12695. */
  12696. function toFinite(value) {
  12697. if (!value) {
  12698. return value === 0 ? value : 0;
  12699. }
  12700. value = toNumber(value);
  12701. if (value === INFINITY || value === -INFINITY) {
  12702. var sign = (value < 0 ? -1 : 1);
  12703. return sign * MAX_INTEGER;
  12704. }
  12705. return value === value ? value : 0;
  12706. }
  12707. /**
  12708. * Converts `value` to an integer.
  12709. *
  12710. * **Note:** This method is loosely based on
  12711. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  12712. *
  12713. * @static
  12714. * @memberOf _
  12715. * @since 4.0.0
  12716. * @category Lang
  12717. * @param {*} value The value to convert.
  12718. * @returns {number} Returns the converted integer.
  12719. * @example
  12720. *
  12721. * _.toInteger(3.2);
  12722. * // => 3
  12723. *
  12724. * _.toInteger(Number.MIN_VALUE);
  12725. * // => 0
  12726. *
  12727. * _.toInteger(Infinity);
  12728. * // => 1.7976931348623157e+308
  12729. *
  12730. * _.toInteger('3.2');
  12731. * // => 3
  12732. */
  12733. function toInteger(value) {
  12734. var result = toFinite(value),
  12735. remainder = result % 1;
  12736. return result === result ? (remainder ? result - remainder : result) : 0;
  12737. }
  12738. /**
  12739. * Converts `value` to an integer suitable for use as the length of an
  12740. * array-like object.
  12741. *
  12742. * **Note:** This method is based on
  12743. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12744. *
  12745. * @static
  12746. * @memberOf _
  12747. * @since 4.0.0
  12748. * @category Lang
  12749. * @param {*} value The value to convert.
  12750. * @returns {number} Returns the converted integer.
  12751. * @example
  12752. *
  12753. * _.toLength(3.2);
  12754. * // => 3
  12755. *
  12756. * _.toLength(Number.MIN_VALUE);
  12757. * // => 0
  12758. *
  12759. * _.toLength(Infinity);
  12760. * // => 4294967295
  12761. *
  12762. * _.toLength('3.2');
  12763. * // => 3
  12764. */
  12765. function toLength(value) {
  12766. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  12767. }
  12768. /**
  12769. * Converts `value` to a number.
  12770. *
  12771. * @static
  12772. * @memberOf _
  12773. * @since 4.0.0
  12774. * @category Lang
  12775. * @param {*} value The value to process.
  12776. * @returns {number} Returns the number.
  12777. * @example
  12778. *
  12779. * _.toNumber(3.2);
  12780. * // => 3.2
  12781. *
  12782. * _.toNumber(Number.MIN_VALUE);
  12783. * // => 5e-324
  12784. *
  12785. * _.toNumber(Infinity);
  12786. * // => Infinity
  12787. *
  12788. * _.toNumber('3.2');
  12789. * // => 3.2
  12790. */
  12791. function toNumber(value) {
  12792. if (typeof value == 'number') {
  12793. return value;
  12794. }
  12795. if (isSymbol(value)) {
  12796. return NAN;
  12797. }
  12798. if (isObject(value)) {
  12799. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  12800. value = isObject(other) ? (other + '') : other;
  12801. }
  12802. if (typeof value != 'string') {
  12803. return value === 0 ? value : +value;
  12804. }
  12805. value = baseTrim(value);
  12806. var isBinary = reIsBinary.test(value);
  12807. return (isBinary || reIsOctal.test(value))
  12808. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  12809. : (reIsBadHex.test(value) ? NAN : +value);
  12810. }
  12811. /**
  12812. * Converts `value` to a plain object flattening inherited enumerable string
  12813. * keyed properties of `value` to own properties of the plain object.
  12814. *
  12815. * @static
  12816. * @memberOf _
  12817. * @since 3.0.0
  12818. * @category Lang
  12819. * @param {*} value The value to convert.
  12820. * @returns {Object} Returns the converted plain object.
  12821. * @example
  12822. *
  12823. * function Foo() {
  12824. * this.b = 2;
  12825. * }
  12826. *
  12827. * Foo.prototype.c = 3;
  12828. *
  12829. * _.assign({ 'a': 1 }, new Foo);
  12830. * // => { 'a': 1, 'b': 2 }
  12831. *
  12832. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  12833. * // => { 'a': 1, 'b': 2, 'c': 3 }
  12834. */
  12835. function toPlainObject(value) {
  12836. return copyObject(value, keysIn(value));
  12837. }
  12838. /**
  12839. * Converts `value` to a safe integer. A safe integer can be compared and
  12840. * represented correctly.
  12841. *
  12842. * @static
  12843. * @memberOf _
  12844. * @since 4.0.0
  12845. * @category Lang
  12846. * @param {*} value The value to convert.
  12847. * @returns {number} Returns the converted integer.
  12848. * @example
  12849. *
  12850. * _.toSafeInteger(3.2);
  12851. * // => 3
  12852. *
  12853. * _.toSafeInteger(Number.MIN_VALUE);
  12854. * // => 0
  12855. *
  12856. * _.toSafeInteger(Infinity);
  12857. * // => 9007199254740991
  12858. *
  12859. * _.toSafeInteger('3.2');
  12860. * // => 3
  12861. */
  12862. function toSafeInteger(value) {
  12863. return value
  12864. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  12865. : (value === 0 ? value : 0);
  12866. }
  12867. /**
  12868. * Converts `value` to a string. An empty string is returned for `null`
  12869. * and `undefined` values. The sign of `-0` is preserved.
  12870. *
  12871. * @static
  12872. * @memberOf _
  12873. * @since 4.0.0
  12874. * @category Lang
  12875. * @param {*} value The value to convert.
  12876. * @returns {string} Returns the converted string.
  12877. * @example
  12878. *
  12879. * _.toString(null);
  12880. * // => ''
  12881. *
  12882. * _.toString(-0);
  12883. * // => '-0'
  12884. *
  12885. * _.toString([1, 2, 3]);
  12886. * // => '1,2,3'
  12887. */
  12888. function toString(value) {
  12889. return value == null ? '' : baseToString(value);
  12890. }
  12891. /*------------------------------------------------------------------------*/
  12892. /**
  12893. * Assigns own enumerable string keyed properties of source objects to the
  12894. * destination object. Source objects are applied from left to right.
  12895. * Subsequent sources overwrite property assignments of previous sources.
  12896. *
  12897. * **Note:** This method mutates `object` and is loosely based on
  12898. * [`Object.assign`](https://mdn.io/Object/assign).
  12899. *
  12900. * @static
  12901. * @memberOf _
  12902. * @since 0.10.0
  12903. * @category Object
  12904. * @param {Object} object The destination object.
  12905. * @param {...Object} [sources] The source objects.
  12906. * @returns {Object} Returns `object`.
  12907. * @see _.assignIn
  12908. * @example
  12909. *
  12910. * function Foo() {
  12911. * this.a = 1;
  12912. * }
  12913. *
  12914. * function Bar() {
  12915. * this.c = 3;
  12916. * }
  12917. *
  12918. * Foo.prototype.b = 2;
  12919. * Bar.prototype.d = 4;
  12920. *
  12921. * _.assign({ 'a': 0 }, new Foo, new Bar);
  12922. * // => { 'a': 1, 'c': 3 }
  12923. */
  12924. var assign = createAssigner(function(object, source) {
  12925. if (isPrototype(source) || isArrayLike(source)) {
  12926. copyObject(source, keys(source), object);
  12927. return;
  12928. }
  12929. for (var key in source) {
  12930. if (hasOwnProperty.call(source, key)) {
  12931. assignValue(object, key, source[key]);
  12932. }
  12933. }
  12934. });
  12935. /**
  12936. * This method is like `_.assign` except that it iterates over own and
  12937. * inherited source properties.
  12938. *
  12939. * **Note:** This method mutates `object`.
  12940. *
  12941. * @static
  12942. * @memberOf _
  12943. * @since 4.0.0
  12944. * @alias extend
  12945. * @category Object
  12946. * @param {Object} object The destination object.
  12947. * @param {...Object} [sources] The source objects.
  12948. * @returns {Object} Returns `object`.
  12949. * @see _.assign
  12950. * @example
  12951. *
  12952. * function Foo() {
  12953. * this.a = 1;
  12954. * }
  12955. *
  12956. * function Bar() {
  12957. * this.c = 3;
  12958. * }
  12959. *
  12960. * Foo.prototype.b = 2;
  12961. * Bar.prototype.d = 4;
  12962. *
  12963. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  12964. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  12965. */
  12966. var assignIn = createAssigner(function(object, source) {
  12967. copyObject(source, keysIn(source), object);
  12968. });
  12969. /**
  12970. * This method is like `_.assignIn` except that it accepts `customizer`
  12971. * which is invoked to produce the assigned values. If `customizer` returns
  12972. * `undefined`, assignment is handled by the method instead. The `customizer`
  12973. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  12974. *
  12975. * **Note:** This method mutates `object`.
  12976. *
  12977. * @static
  12978. * @memberOf _
  12979. * @since 4.0.0
  12980. * @alias extendWith
  12981. * @category Object
  12982. * @param {Object} object The destination object.
  12983. * @param {...Object} sources The source objects.
  12984. * @param {Function} [customizer] The function to customize assigned values.
  12985. * @returns {Object} Returns `object`.
  12986. * @see _.assignWith
  12987. * @example
  12988. *
  12989. * function customizer(objValue, srcValue) {
  12990. * return _.isUndefined(objValue) ? srcValue : objValue;
  12991. * }
  12992. *
  12993. * var defaults = _.partialRight(_.assignInWith, customizer);
  12994. *
  12995. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12996. * // => { 'a': 1, 'b': 2 }
  12997. */
  12998. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  12999. copyObject(source, keysIn(source), object, customizer);
  13000. });
  13001. /**
  13002. * This method is like `_.assign` except that it accepts `customizer`
  13003. * which is invoked to produce the assigned values. If `customizer` returns
  13004. * `undefined`, assignment is handled by the method instead. The `customizer`
  13005. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  13006. *
  13007. * **Note:** This method mutates `object`.
  13008. *
  13009. * @static
  13010. * @memberOf _
  13011. * @since 4.0.0
  13012. * @category Object
  13013. * @param {Object} object The destination object.
  13014. * @param {...Object} sources The source objects.
  13015. * @param {Function} [customizer] The function to customize assigned values.
  13016. * @returns {Object} Returns `object`.
  13017. * @see _.assignInWith
  13018. * @example
  13019. *
  13020. * function customizer(objValue, srcValue) {
  13021. * return _.isUndefined(objValue) ? srcValue : objValue;
  13022. * }
  13023. *
  13024. * var defaults = _.partialRight(_.assignWith, customizer);
  13025. *
  13026. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13027. * // => { 'a': 1, 'b': 2 }
  13028. */
  13029. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  13030. copyObject(source, keys(source), object, customizer);
  13031. });
  13032. /**
  13033. * Creates an array of values corresponding to `paths` of `object`.
  13034. *
  13035. * @static
  13036. * @memberOf _
  13037. * @since 1.0.0
  13038. * @category Object
  13039. * @param {Object} object The object to iterate over.
  13040. * @param {...(string|string[])} [paths] The property paths to pick.
  13041. * @returns {Array} Returns the picked values.
  13042. * @example
  13043. *
  13044. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  13045. *
  13046. * _.at(object, ['a[0].b.c', 'a[1]']);
  13047. * // => [3, 4]
  13048. */
  13049. var at = flatRest(baseAt);
  13050. /**
  13051. * Creates an object that inherits from the `prototype` object. If a
  13052. * `properties` object is given, its own enumerable string keyed properties
  13053. * are assigned to the created object.
  13054. *
  13055. * @static
  13056. * @memberOf _
  13057. * @since 2.3.0
  13058. * @category Object
  13059. * @param {Object} prototype The object to inherit from.
  13060. * @param {Object} [properties] The properties to assign to the object.
  13061. * @returns {Object} Returns the new object.
  13062. * @example
  13063. *
  13064. * function Shape() {
  13065. * this.x = 0;
  13066. * this.y = 0;
  13067. * }
  13068. *
  13069. * function Circle() {
  13070. * Shape.call(this);
  13071. * }
  13072. *
  13073. * Circle.prototype = _.create(Shape.prototype, {
  13074. * 'constructor': Circle
  13075. * });
  13076. *
  13077. * var circle = new Circle;
  13078. * circle instanceof Circle;
  13079. * // => true
  13080. *
  13081. * circle instanceof Shape;
  13082. * // => true
  13083. */
  13084. function create(prototype, properties) {
  13085. var result = baseCreate(prototype);
  13086. return properties == null ? result : baseAssign(result, properties);
  13087. }
  13088. /**
  13089. * Assigns own and inherited enumerable string keyed properties of source
  13090. * objects to the destination object for all destination properties that
  13091. * resolve to `undefined`. Source objects are applied from left to right.
  13092. * Once a property is set, additional values of the same property are ignored.
  13093. *
  13094. * **Note:** This method mutates `object`.
  13095. *
  13096. * @static
  13097. * @since 0.1.0
  13098. * @memberOf _
  13099. * @category Object
  13100. * @param {Object} object The destination object.
  13101. * @param {...Object} [sources] The source objects.
  13102. * @returns {Object} Returns `object`.
  13103. * @see _.defaultsDeep
  13104. * @example
  13105. *
  13106. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13107. * // => { 'a': 1, 'b': 2 }
  13108. */
  13109. var defaults = baseRest(function(object, sources) {
  13110. object = Object(object);
  13111. var index = -1;
  13112. var length = sources.length;
  13113. var guard = length > 2 ? sources[2] : undefined;
  13114. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  13115. length = 1;
  13116. }
  13117. while (++index < length) {
  13118. var source = sources[index];
  13119. var props = keysIn(source);
  13120. var propsIndex = -1;
  13121. var propsLength = props.length;
  13122. while (++propsIndex < propsLength) {
  13123. var key = props[propsIndex];
  13124. var value = object[key];
  13125. if (value === undefined ||
  13126. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  13127. object[key] = source[key];
  13128. }
  13129. }
  13130. }
  13131. return object;
  13132. });
  13133. /**
  13134. * This method is like `_.defaults` except that it recursively assigns
  13135. * default properties.
  13136. *
  13137. * **Note:** This method mutates `object`.
  13138. *
  13139. * @static
  13140. * @memberOf _
  13141. * @since 3.10.0
  13142. * @category Object
  13143. * @param {Object} object The destination object.
  13144. * @param {...Object} [sources] The source objects.
  13145. * @returns {Object} Returns `object`.
  13146. * @see _.defaults
  13147. * @example
  13148. *
  13149. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  13150. * // => { 'a': { 'b': 2, 'c': 3 } }
  13151. */
  13152. var defaultsDeep = baseRest(function(args) {
  13153. args.push(undefined, customDefaultsMerge);
  13154. return apply(mergeWith, undefined, args);
  13155. });
  13156. /**
  13157. * This method is like `_.find` except that it returns the key of the first
  13158. * element `predicate` returns truthy for instead of the element itself.
  13159. *
  13160. * @static
  13161. * @memberOf _
  13162. * @since 1.1.0
  13163. * @category Object
  13164. * @param {Object} object The object to inspect.
  13165. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13166. * @returns {string|undefined} Returns the key of the matched element,
  13167. * else `undefined`.
  13168. * @example
  13169. *
  13170. * var users = {
  13171. * 'barney': { 'age': 36, 'active': true },
  13172. * 'fred': { 'age': 40, 'active': false },
  13173. * 'pebbles': { 'age': 1, 'active': true }
  13174. * };
  13175. *
  13176. * _.findKey(users, function(o) { return o.age < 40; });
  13177. * // => 'barney' (iteration order is not guaranteed)
  13178. *
  13179. * // The `_.matches` iteratee shorthand.
  13180. * _.findKey(users, { 'age': 1, 'active': true });
  13181. * // => 'pebbles'
  13182. *
  13183. * // The `_.matchesProperty` iteratee shorthand.
  13184. * _.findKey(users, ['active', false]);
  13185. * // => 'fred'
  13186. *
  13187. * // The `_.property` iteratee shorthand.
  13188. * _.findKey(users, 'active');
  13189. * // => 'barney'
  13190. */
  13191. function findKey(object, predicate) {
  13192. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  13193. }
  13194. /**
  13195. * This method is like `_.findKey` except that it iterates over elements of
  13196. * a collection in the opposite order.
  13197. *
  13198. * @static
  13199. * @memberOf _
  13200. * @since 2.0.0
  13201. * @category Object
  13202. * @param {Object} object The object to inspect.
  13203. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13204. * @returns {string|undefined} Returns the key of the matched element,
  13205. * else `undefined`.
  13206. * @example
  13207. *
  13208. * var users = {
  13209. * 'barney': { 'age': 36, 'active': true },
  13210. * 'fred': { 'age': 40, 'active': false },
  13211. * 'pebbles': { 'age': 1, 'active': true }
  13212. * };
  13213. *
  13214. * _.findLastKey(users, function(o) { return o.age < 40; });
  13215. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  13216. *
  13217. * // The `_.matches` iteratee shorthand.
  13218. * _.findLastKey(users, { 'age': 36, 'active': true });
  13219. * // => 'barney'
  13220. *
  13221. * // The `_.matchesProperty` iteratee shorthand.
  13222. * _.findLastKey(users, ['active', false]);
  13223. * // => 'fred'
  13224. *
  13225. * // The `_.property` iteratee shorthand.
  13226. * _.findLastKey(users, 'active');
  13227. * // => 'pebbles'
  13228. */
  13229. function findLastKey(object, predicate) {
  13230. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  13231. }
  13232. /**
  13233. * Iterates over own and inherited enumerable string keyed properties of an
  13234. * object and invokes `iteratee` for each property. The iteratee is invoked
  13235. * with three arguments: (value, key, object). Iteratee functions may exit
  13236. * iteration early by explicitly returning `false`.
  13237. *
  13238. * @static
  13239. * @memberOf _
  13240. * @since 0.3.0
  13241. * @category Object
  13242. * @param {Object} object The object to iterate over.
  13243. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13244. * @returns {Object} Returns `object`.
  13245. * @see _.forInRight
  13246. * @example
  13247. *
  13248. * function Foo() {
  13249. * this.a = 1;
  13250. * this.b = 2;
  13251. * }
  13252. *
  13253. * Foo.prototype.c = 3;
  13254. *
  13255. * _.forIn(new Foo, function(value, key) {
  13256. * console.log(key);
  13257. * });
  13258. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  13259. */
  13260. function forIn(object, iteratee) {
  13261. return object == null
  13262. ? object
  13263. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  13264. }
  13265. /**
  13266. * This method is like `_.forIn` except that it iterates over properties of
  13267. * `object` in the opposite order.
  13268. *
  13269. * @static
  13270. * @memberOf _
  13271. * @since 2.0.0
  13272. * @category Object
  13273. * @param {Object} object The object to iterate over.
  13274. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13275. * @returns {Object} Returns `object`.
  13276. * @see _.forIn
  13277. * @example
  13278. *
  13279. * function Foo() {
  13280. * this.a = 1;
  13281. * this.b = 2;
  13282. * }
  13283. *
  13284. * Foo.prototype.c = 3;
  13285. *
  13286. * _.forInRight(new Foo, function(value, key) {
  13287. * console.log(key);
  13288. * });
  13289. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  13290. */
  13291. function forInRight(object, iteratee) {
  13292. return object == null
  13293. ? object
  13294. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  13295. }
  13296. /**
  13297. * Iterates over own enumerable string keyed properties of an object and
  13298. * invokes `iteratee` for each property. The iteratee is invoked with three
  13299. * arguments: (value, key, object). Iteratee functions may exit iteration
  13300. * early by explicitly returning `false`.
  13301. *
  13302. * @static
  13303. * @memberOf _
  13304. * @since 0.3.0
  13305. * @category Object
  13306. * @param {Object} object The object to iterate over.
  13307. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13308. * @returns {Object} Returns `object`.
  13309. * @see _.forOwnRight
  13310. * @example
  13311. *
  13312. * function Foo() {
  13313. * this.a = 1;
  13314. * this.b = 2;
  13315. * }
  13316. *
  13317. * Foo.prototype.c = 3;
  13318. *
  13319. * _.forOwn(new Foo, function(value, key) {
  13320. * console.log(key);
  13321. * });
  13322. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  13323. */
  13324. function forOwn(object, iteratee) {
  13325. return object && baseForOwn(object, getIteratee(iteratee, 3));
  13326. }
  13327. /**
  13328. * This method is like `_.forOwn` except that it iterates over properties of
  13329. * `object` in the opposite order.
  13330. *
  13331. * @static
  13332. * @memberOf _
  13333. * @since 2.0.0
  13334. * @category Object
  13335. * @param {Object} object The object to iterate over.
  13336. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13337. * @returns {Object} Returns `object`.
  13338. * @see _.forOwn
  13339. * @example
  13340. *
  13341. * function Foo() {
  13342. * this.a = 1;
  13343. * this.b = 2;
  13344. * }
  13345. *
  13346. * Foo.prototype.c = 3;
  13347. *
  13348. * _.forOwnRight(new Foo, function(value, key) {
  13349. * console.log(key);
  13350. * });
  13351. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  13352. */
  13353. function forOwnRight(object, iteratee) {
  13354. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  13355. }
  13356. /**
  13357. * Creates an array of function property names from own enumerable properties
  13358. * of `object`.
  13359. *
  13360. * @static
  13361. * @since 0.1.0
  13362. * @memberOf _
  13363. * @category Object
  13364. * @param {Object} object The object to inspect.
  13365. * @returns {Array} Returns the function names.
  13366. * @see _.functionsIn
  13367. * @example
  13368. *
  13369. * function Foo() {
  13370. * this.a = _.constant('a');
  13371. * this.b = _.constant('b');
  13372. * }
  13373. *
  13374. * Foo.prototype.c = _.constant('c');
  13375. *
  13376. * _.functions(new Foo);
  13377. * // => ['a', 'b']
  13378. */
  13379. function functions(object) {
  13380. return object == null ? [] : baseFunctions(object, keys(object));
  13381. }
  13382. /**
  13383. * Creates an array of function property names from own and inherited
  13384. * enumerable properties of `object`.
  13385. *
  13386. * @static
  13387. * @memberOf _
  13388. * @since 4.0.0
  13389. * @category Object
  13390. * @param {Object} object The object to inspect.
  13391. * @returns {Array} Returns the function names.
  13392. * @see _.functions
  13393. * @example
  13394. *
  13395. * function Foo() {
  13396. * this.a = _.constant('a');
  13397. * this.b = _.constant('b');
  13398. * }
  13399. *
  13400. * Foo.prototype.c = _.constant('c');
  13401. *
  13402. * _.functionsIn(new Foo);
  13403. * // => ['a', 'b', 'c']
  13404. */
  13405. function functionsIn(object) {
  13406. return object == null ? [] : baseFunctions(object, keysIn(object));
  13407. }
  13408. /**
  13409. * Gets the value at `path` of `object`. If the resolved value is
  13410. * `undefined`, the `defaultValue` is returned in its place.
  13411. *
  13412. * @static
  13413. * @memberOf _
  13414. * @since 3.7.0
  13415. * @category Object
  13416. * @param {Object} object The object to query.
  13417. * @param {Array|string} path The path of the property to get.
  13418. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13419. * @returns {*} Returns the resolved value.
  13420. * @example
  13421. *
  13422. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13423. *
  13424. * _.get(object, 'a[0].b.c');
  13425. * // => 3
  13426. *
  13427. * _.get(object, ['a', '0', 'b', 'c']);
  13428. * // => 3
  13429. *
  13430. * _.get(object, 'a.b.c', 'default');
  13431. * // => 'default'
  13432. */
  13433. function get(object, path, defaultValue) {
  13434. var result = object == null ? undefined : baseGet(object, path);
  13435. return result === undefined ? defaultValue : result;
  13436. }
  13437. /**
  13438. * Checks if `path` is a direct property of `object`.
  13439. *
  13440. * @static
  13441. * @since 0.1.0
  13442. * @memberOf _
  13443. * @category Object
  13444. * @param {Object} object The object to query.
  13445. * @param {Array|string} path The path to check.
  13446. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13447. * @example
  13448. *
  13449. * var object = { 'a': { 'b': 2 } };
  13450. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  13451. *
  13452. * _.has(object, 'a');
  13453. * // => true
  13454. *
  13455. * _.has(object, 'a.b');
  13456. * // => true
  13457. *
  13458. * _.has(object, ['a', 'b']);
  13459. * // => true
  13460. *
  13461. * _.has(other, 'a');
  13462. * // => false
  13463. */
  13464. function has(object, path) {
  13465. return object != null && hasPath(object, path, baseHas);
  13466. }
  13467. /**
  13468. * Checks if `path` is a direct or inherited property of `object`.
  13469. *
  13470. * @static
  13471. * @memberOf _
  13472. * @since 4.0.0
  13473. * @category Object
  13474. * @param {Object} object The object to query.
  13475. * @param {Array|string} path The path to check.
  13476. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13477. * @example
  13478. *
  13479. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  13480. *
  13481. * _.hasIn(object, 'a');
  13482. * // => true
  13483. *
  13484. * _.hasIn(object, 'a.b');
  13485. * // => true
  13486. *
  13487. * _.hasIn(object, ['a', 'b']);
  13488. * // => true
  13489. *
  13490. * _.hasIn(object, 'b');
  13491. * // => false
  13492. */
  13493. function hasIn(object, path) {
  13494. return object != null && hasPath(object, path, baseHasIn);
  13495. }
  13496. /**
  13497. * Creates an object composed of the inverted keys and values of `object`.
  13498. * If `object` contains duplicate values, subsequent values overwrite
  13499. * property assignments of previous values.
  13500. *
  13501. * @static
  13502. * @memberOf _
  13503. * @since 0.7.0
  13504. * @category Object
  13505. * @param {Object} object The object to invert.
  13506. * @returns {Object} Returns the new inverted object.
  13507. * @example
  13508. *
  13509. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13510. *
  13511. * _.invert(object);
  13512. * // => { '1': 'c', '2': 'b' }
  13513. */
  13514. var invert = createInverter(function(result, value, key) {
  13515. if (value != null &&
  13516. typeof value.toString != 'function') {
  13517. value = nativeObjectToString.call(value);
  13518. }
  13519. result[value] = key;
  13520. }, constant(identity));
  13521. /**
  13522. * This method is like `_.invert` except that the inverted object is generated
  13523. * from the results of running each element of `object` thru `iteratee`. The
  13524. * corresponding inverted value of each inverted key is an array of keys
  13525. * responsible for generating the inverted value. The iteratee is invoked
  13526. * with one argument: (value).
  13527. *
  13528. * @static
  13529. * @memberOf _
  13530. * @since 4.1.0
  13531. * @category Object
  13532. * @param {Object} object The object to invert.
  13533. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13534. * @returns {Object} Returns the new inverted object.
  13535. * @example
  13536. *
  13537. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13538. *
  13539. * _.invertBy(object);
  13540. * // => { '1': ['a', 'c'], '2': ['b'] }
  13541. *
  13542. * _.invertBy(object, function(value) {
  13543. * return 'group' + value;
  13544. * });
  13545. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  13546. */
  13547. var invertBy = createInverter(function(result, value, key) {
  13548. if (value != null &&
  13549. typeof value.toString != 'function') {
  13550. value = nativeObjectToString.call(value);
  13551. }
  13552. if (hasOwnProperty.call(result, value)) {
  13553. result[value].push(key);
  13554. } else {
  13555. result[value] = [key];
  13556. }
  13557. }, getIteratee);
  13558. /**
  13559. * Invokes the method at `path` of `object`.
  13560. *
  13561. * @static
  13562. * @memberOf _
  13563. * @since 4.0.0
  13564. * @category Object
  13565. * @param {Object} object The object to query.
  13566. * @param {Array|string} path The path of the method to invoke.
  13567. * @param {...*} [args] The arguments to invoke the method with.
  13568. * @returns {*} Returns the result of the invoked method.
  13569. * @example
  13570. *
  13571. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  13572. *
  13573. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  13574. * // => [2, 3]
  13575. */
  13576. var invoke = baseRest(baseInvoke);
  13577. /**
  13578. * Creates an array of the own enumerable property names of `object`.
  13579. *
  13580. * **Note:** Non-object values are coerced to objects. See the
  13581. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  13582. * for more details.
  13583. *
  13584. * @static
  13585. * @since 0.1.0
  13586. * @memberOf _
  13587. * @category Object
  13588. * @param {Object} object The object to query.
  13589. * @returns {Array} Returns the array of property names.
  13590. * @example
  13591. *
  13592. * function Foo() {
  13593. * this.a = 1;
  13594. * this.b = 2;
  13595. * }
  13596. *
  13597. * Foo.prototype.c = 3;
  13598. *
  13599. * _.keys(new Foo);
  13600. * // => ['a', 'b'] (iteration order is not guaranteed)
  13601. *
  13602. * _.keys('hi');
  13603. * // => ['0', '1']
  13604. */
  13605. function keys(object) {
  13606. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  13607. }
  13608. /**
  13609. * Creates an array of the own and inherited enumerable property names of `object`.
  13610. *
  13611. * **Note:** Non-object values are coerced to objects.
  13612. *
  13613. * @static
  13614. * @memberOf _
  13615. * @since 3.0.0
  13616. * @category Object
  13617. * @param {Object} object The object to query.
  13618. * @returns {Array} Returns the array of property names.
  13619. * @example
  13620. *
  13621. * function Foo() {
  13622. * this.a = 1;
  13623. * this.b = 2;
  13624. * }
  13625. *
  13626. * Foo.prototype.c = 3;
  13627. *
  13628. * _.keysIn(new Foo);
  13629. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  13630. */
  13631. function keysIn(object) {
  13632. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  13633. }
  13634. /**
  13635. * The opposite of `_.mapValues`; this method creates an object with the
  13636. * same values as `object` and keys generated by running each own enumerable
  13637. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  13638. * with three arguments: (value, key, object).
  13639. *
  13640. * @static
  13641. * @memberOf _
  13642. * @since 3.8.0
  13643. * @category Object
  13644. * @param {Object} object The object to iterate over.
  13645. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13646. * @returns {Object} Returns the new mapped object.
  13647. * @see _.mapValues
  13648. * @example
  13649. *
  13650. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  13651. * return key + value;
  13652. * });
  13653. * // => { 'a1': 1, 'b2': 2 }
  13654. */
  13655. function mapKeys(object, iteratee) {
  13656. var result = {};
  13657. iteratee = getIteratee(iteratee, 3);
  13658. baseForOwn(object, function(value, key, object) {
  13659. baseAssignValue(result, iteratee(value, key, object), value);
  13660. });
  13661. return result;
  13662. }
  13663. /**
  13664. * Creates an object with the same keys as `object` and values generated
  13665. * by running each own enumerable string keyed property of `object` thru
  13666. * `iteratee`. The iteratee is invoked with three arguments:
  13667. * (value, key, object).
  13668. *
  13669. * @static
  13670. * @memberOf _
  13671. * @since 2.4.0
  13672. * @category Object
  13673. * @param {Object} object The object to iterate over.
  13674. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13675. * @returns {Object} Returns the new mapped object.
  13676. * @see _.mapKeys
  13677. * @example
  13678. *
  13679. * var users = {
  13680. * 'fred': { 'user': 'fred', 'age': 40 },
  13681. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  13682. * };
  13683. *
  13684. * _.mapValues(users, function(o) { return o.age; });
  13685. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13686. *
  13687. * // The `_.property` iteratee shorthand.
  13688. * _.mapValues(users, 'age');
  13689. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  13690. */
  13691. function mapValues(object, iteratee) {
  13692. var result = {};
  13693. iteratee = getIteratee(iteratee, 3);
  13694. baseForOwn(object, function(value, key, object) {
  13695. baseAssignValue(result, key, iteratee(value, key, object));
  13696. });
  13697. return result;
  13698. }
  13699. /**
  13700. * This method is like `_.assign` except that it recursively merges own and
  13701. * inherited enumerable string keyed properties of source objects into the
  13702. * destination object. Source properties that resolve to `undefined` are
  13703. * skipped if a destination value exists. Array and plain object properties
  13704. * are merged recursively. Other objects and value types are overridden by
  13705. * assignment. Source objects are applied from left to right. Subsequent
  13706. * sources overwrite property assignments of previous sources.
  13707. *
  13708. * **Note:** This method mutates `object`.
  13709. *
  13710. * @static
  13711. * @memberOf _
  13712. * @since 0.5.0
  13713. * @category Object
  13714. * @param {Object} object The destination object.
  13715. * @param {...Object} [sources] The source objects.
  13716. * @returns {Object} Returns `object`.
  13717. * @example
  13718. *
  13719. * var object = {
  13720. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  13721. * };
  13722. *
  13723. * var other = {
  13724. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  13725. * };
  13726. *
  13727. * _.merge(object, other);
  13728. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  13729. */
  13730. var merge = createAssigner(function(object, source, srcIndex) {
  13731. baseMerge(object, source, srcIndex);
  13732. });
  13733. /**
  13734. * This method is like `_.merge` except that it accepts `customizer` which
  13735. * is invoked to produce the merged values of the destination and source
  13736. * properties. If `customizer` returns `undefined`, merging is handled by the
  13737. * method instead. The `customizer` is invoked with six arguments:
  13738. * (objValue, srcValue, key, object, source, stack).
  13739. *
  13740. * **Note:** This method mutates `object`.
  13741. *
  13742. * @static
  13743. * @memberOf _
  13744. * @since 4.0.0
  13745. * @category Object
  13746. * @param {Object} object The destination object.
  13747. * @param {...Object} sources The source objects.
  13748. * @param {Function} customizer The function to customize assigned values.
  13749. * @returns {Object} Returns `object`.
  13750. * @example
  13751. *
  13752. * function customizer(objValue, srcValue) {
  13753. * if (_.isArray(objValue)) {
  13754. * return objValue.concat(srcValue);
  13755. * }
  13756. * }
  13757. *
  13758. * var object = { 'a': [1], 'b': [2] };
  13759. * var other = { 'a': [3], 'b': [4] };
  13760. *
  13761. * _.mergeWith(object, other, customizer);
  13762. * // => { 'a': [1, 3], 'b': [2, 4] }
  13763. */
  13764. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  13765. baseMerge(object, source, srcIndex, customizer);
  13766. });
  13767. /**
  13768. * The opposite of `_.pick`; this method creates an object composed of the
  13769. * own and inherited enumerable property paths of `object` that are not omitted.
  13770. *
  13771. * **Note:** This method is considerably slower than `_.pick`.
  13772. *
  13773. * @static
  13774. * @since 0.1.0
  13775. * @memberOf _
  13776. * @category Object
  13777. * @param {Object} object The source object.
  13778. * @param {...(string|string[])} [paths] The property paths to omit.
  13779. * @returns {Object} Returns the new object.
  13780. * @example
  13781. *
  13782. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13783. *
  13784. * _.omit(object, ['a', 'c']);
  13785. * // => { 'b': '2' }
  13786. */
  13787. var omit = flatRest(function(object, paths) {
  13788. var result = {};
  13789. if (object == null) {
  13790. return result;
  13791. }
  13792. var isDeep = false;
  13793. paths = arrayMap(paths, function(path) {
  13794. path = castPath(path, object);
  13795. isDeep || (isDeep = path.length > 1);
  13796. return path;
  13797. });
  13798. copyObject(object, getAllKeysIn(object), result);
  13799. if (isDeep) {
  13800. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  13801. }
  13802. var length = paths.length;
  13803. while (length--) {
  13804. baseUnset(result, paths[length]);
  13805. }
  13806. return result;
  13807. });
  13808. /**
  13809. * The opposite of `_.pickBy`; this method creates an object composed of
  13810. * the own and inherited enumerable string keyed properties of `object` that
  13811. * `predicate` doesn't return truthy for. The predicate is invoked with two
  13812. * arguments: (value, key).
  13813. *
  13814. * @static
  13815. * @memberOf _
  13816. * @since 4.0.0
  13817. * @category Object
  13818. * @param {Object} object The source object.
  13819. * @param {Function} [predicate=_.identity] The function invoked per property.
  13820. * @returns {Object} Returns the new object.
  13821. * @example
  13822. *
  13823. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13824. *
  13825. * _.omitBy(object, _.isNumber);
  13826. * // => { 'b': '2' }
  13827. */
  13828. function omitBy(object, predicate) {
  13829. return pickBy(object, negate(getIteratee(predicate)));
  13830. }
  13831. /**
  13832. * Creates an object composed of the picked `object` properties.
  13833. *
  13834. * @static
  13835. * @since 0.1.0
  13836. * @memberOf _
  13837. * @category Object
  13838. * @param {Object} object The source object.
  13839. * @param {...(string|string[])} [paths] The property paths to pick.
  13840. * @returns {Object} Returns the new object.
  13841. * @example
  13842. *
  13843. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13844. *
  13845. * _.pick(object, ['a', 'c']);
  13846. * // => { 'a': 1, 'c': 3 }
  13847. */
  13848. var pick = flatRest(function(object, paths) {
  13849. return object == null ? {} : basePick(object, paths);
  13850. });
  13851. /**
  13852. * Creates an object composed of the `object` properties `predicate` returns
  13853. * truthy for. The predicate is invoked with two arguments: (value, key).
  13854. *
  13855. * @static
  13856. * @memberOf _
  13857. * @since 4.0.0
  13858. * @category Object
  13859. * @param {Object} object The source object.
  13860. * @param {Function} [predicate=_.identity] The function invoked per property.
  13861. * @returns {Object} Returns the new object.
  13862. * @example
  13863. *
  13864. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  13865. *
  13866. * _.pickBy(object, _.isNumber);
  13867. * // => { 'a': 1, 'c': 3 }
  13868. */
  13869. function pickBy(object, predicate) {
  13870. if (object == null) {
  13871. return {};
  13872. }
  13873. var props = arrayMap(getAllKeysIn(object), function(prop) {
  13874. return [prop];
  13875. });
  13876. predicate = getIteratee(predicate);
  13877. return basePickBy(object, props, function(value, path) {
  13878. return predicate(value, path[0]);
  13879. });
  13880. }
  13881. /**
  13882. * This method is like `_.get` except that if the resolved value is a
  13883. * function it's invoked with the `this` binding of its parent object and
  13884. * its result is returned.
  13885. *
  13886. * @static
  13887. * @since 0.1.0
  13888. * @memberOf _
  13889. * @category Object
  13890. * @param {Object} object The object to query.
  13891. * @param {Array|string} path The path of the property to resolve.
  13892. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13893. * @returns {*} Returns the resolved value.
  13894. * @example
  13895. *
  13896. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  13897. *
  13898. * _.result(object, 'a[0].b.c1');
  13899. * // => 3
  13900. *
  13901. * _.result(object, 'a[0].b.c2');
  13902. * // => 4
  13903. *
  13904. * _.result(object, 'a[0].b.c3', 'default');
  13905. * // => 'default'
  13906. *
  13907. * _.result(object, 'a[0].b.c3', _.constant('default'));
  13908. * // => 'default'
  13909. */
  13910. function result(object, path, defaultValue) {
  13911. path = castPath(path, object);
  13912. var index = -1,
  13913. length = path.length;
  13914. // Ensure the loop is entered when path is empty.
  13915. if (!length) {
  13916. length = 1;
  13917. object = undefined;
  13918. }
  13919. while (++index < length) {
  13920. var value = object == null ? undefined : object[toKey(path[index])];
  13921. if (value === undefined) {
  13922. index = length;
  13923. value = defaultValue;
  13924. }
  13925. object = isFunction(value) ? value.call(object) : value;
  13926. }
  13927. return object;
  13928. }
  13929. /**
  13930. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  13931. * it's created. Arrays are created for missing index properties while objects
  13932. * are created for all other missing properties. Use `_.setWith` to customize
  13933. * `path` creation.
  13934. *
  13935. * **Note:** This method mutates `object`.
  13936. *
  13937. * @static
  13938. * @memberOf _
  13939. * @since 3.7.0
  13940. * @category Object
  13941. * @param {Object} object The object to modify.
  13942. * @param {Array|string} path The path of the property to set.
  13943. * @param {*} value The value to set.
  13944. * @returns {Object} Returns `object`.
  13945. * @example
  13946. *
  13947. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13948. *
  13949. * _.set(object, 'a[0].b.c', 4);
  13950. * console.log(object.a[0].b.c);
  13951. * // => 4
  13952. *
  13953. * _.set(object, ['x', '0', 'y', 'z'], 5);
  13954. * console.log(object.x[0].y.z);
  13955. * // => 5
  13956. */
  13957. function set(object, path, value) {
  13958. return object == null ? object : baseSet(object, path, value);
  13959. }
  13960. /**
  13961. * This method is like `_.set` except that it accepts `customizer` which is
  13962. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  13963. * path creation is handled by the method instead. The `customizer` is invoked
  13964. * with three arguments: (nsValue, key, nsObject).
  13965. *
  13966. * **Note:** This method mutates `object`.
  13967. *
  13968. * @static
  13969. * @memberOf _
  13970. * @since 4.0.0
  13971. * @category Object
  13972. * @param {Object} object The object to modify.
  13973. * @param {Array|string} path The path of the property to set.
  13974. * @param {*} value The value to set.
  13975. * @param {Function} [customizer] The function to customize assigned values.
  13976. * @returns {Object} Returns `object`.
  13977. * @example
  13978. *
  13979. * var object = {};
  13980. *
  13981. * _.setWith(object, '[0][1]', 'a', Object);
  13982. * // => { '0': { '1': 'a' } }
  13983. */
  13984. function setWith(object, path, value, customizer) {
  13985. customizer = typeof customizer == 'function' ? customizer : undefined;
  13986. return object == null ? object : baseSet(object, path, value, customizer);
  13987. }
  13988. /**
  13989. * Creates an array of own enumerable string keyed-value pairs for `object`
  13990. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  13991. * entries are returned.
  13992. *
  13993. * @static
  13994. * @memberOf _
  13995. * @since 4.0.0
  13996. * @alias entries
  13997. * @category Object
  13998. * @param {Object} object The object to query.
  13999. * @returns {Array} Returns the key-value pairs.
  14000. * @example
  14001. *
  14002. * function Foo() {
  14003. * this.a = 1;
  14004. * this.b = 2;
  14005. * }
  14006. *
  14007. * Foo.prototype.c = 3;
  14008. *
  14009. * _.toPairs(new Foo);
  14010. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  14011. */
  14012. var toPairs = createToPairs(keys);
  14013. /**
  14014. * Creates an array of own and inherited enumerable string keyed-value pairs
  14015. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  14016. * or set, its entries are returned.
  14017. *
  14018. * @static
  14019. * @memberOf _
  14020. * @since 4.0.0
  14021. * @alias entriesIn
  14022. * @category Object
  14023. * @param {Object} object The object to query.
  14024. * @returns {Array} Returns the key-value pairs.
  14025. * @example
  14026. *
  14027. * function Foo() {
  14028. * this.a = 1;
  14029. * this.b = 2;
  14030. * }
  14031. *
  14032. * Foo.prototype.c = 3;
  14033. *
  14034. * _.toPairsIn(new Foo);
  14035. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  14036. */
  14037. var toPairsIn = createToPairs(keysIn);
  14038. /**
  14039. * An alternative to `_.reduce`; this method transforms `object` to a new
  14040. * `accumulator` object which is the result of running each of its own
  14041. * enumerable string keyed properties thru `iteratee`, with each invocation
  14042. * potentially mutating the `accumulator` object. If `accumulator` is not
  14043. * provided, a new object with the same `[[Prototype]]` will be used. The
  14044. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  14045. * Iteratee functions may exit iteration early by explicitly returning `false`.
  14046. *
  14047. * @static
  14048. * @memberOf _
  14049. * @since 1.3.0
  14050. * @category Object
  14051. * @param {Object} object The object to iterate over.
  14052. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14053. * @param {*} [accumulator] The custom accumulator value.
  14054. * @returns {*} Returns the accumulated value.
  14055. * @example
  14056. *
  14057. * _.transform([2, 3, 4], function(result, n) {
  14058. * result.push(n *= n);
  14059. * return n % 2 == 0;
  14060. * }, []);
  14061. * // => [4, 9]
  14062. *
  14063. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  14064. * (result[value] || (result[value] = [])).push(key);
  14065. * }, {});
  14066. * // => { '1': ['a', 'c'], '2': ['b'] }
  14067. */
  14068. function transform(object, iteratee, accumulator) {
  14069. var isArr = isArray(object),
  14070. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  14071. iteratee = getIteratee(iteratee, 4);
  14072. if (accumulator == null) {
  14073. var Ctor = object && object.constructor;
  14074. if (isArrLike) {
  14075. accumulator = isArr ? new Ctor : [];
  14076. }
  14077. else if (isObject(object)) {
  14078. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  14079. }
  14080. else {
  14081. accumulator = {};
  14082. }
  14083. }
  14084. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  14085. return iteratee(accumulator, value, index, object);
  14086. });
  14087. return accumulator;
  14088. }
  14089. /**
  14090. * Removes the property at `path` of `object`.
  14091. *
  14092. * **Note:** This method mutates `object`.
  14093. *
  14094. * @static
  14095. * @memberOf _
  14096. * @since 4.0.0
  14097. * @category Object
  14098. * @param {Object} object The object to modify.
  14099. * @param {Array|string} path The path of the property to unset.
  14100. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  14101. * @example
  14102. *
  14103. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  14104. * _.unset(object, 'a[0].b.c');
  14105. * // => true
  14106. *
  14107. * console.log(object);
  14108. * // => { 'a': [{ 'b': {} }] };
  14109. *
  14110. * _.unset(object, ['a', '0', 'b', 'c']);
  14111. * // => true
  14112. *
  14113. * console.log(object);
  14114. * // => { 'a': [{ 'b': {} }] };
  14115. */
  14116. function unset(object, path) {
  14117. return object == null ? true : baseUnset(object, path);
  14118. }
  14119. /**
  14120. * This method is like `_.set` except that accepts `updater` to produce the
  14121. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  14122. * is invoked with one argument: (value).
  14123. *
  14124. * **Note:** This method mutates `object`.
  14125. *
  14126. * @static
  14127. * @memberOf _
  14128. * @since 4.6.0
  14129. * @category Object
  14130. * @param {Object} object The object to modify.
  14131. * @param {Array|string} path The path of the property to set.
  14132. * @param {Function} updater The function to produce the updated value.
  14133. * @returns {Object} Returns `object`.
  14134. * @example
  14135. *
  14136. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14137. *
  14138. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  14139. * console.log(object.a[0].b.c);
  14140. * // => 9
  14141. *
  14142. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  14143. * console.log(object.x[0].y.z);
  14144. * // => 0
  14145. */
  14146. function update(object, path, updater) {
  14147. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  14148. }
  14149. /**
  14150. * This method is like `_.update` except that it accepts `customizer` which is
  14151. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  14152. * path creation is handled by the method instead. The `customizer` is invoked
  14153. * with three arguments: (nsValue, key, nsObject).
  14154. *
  14155. * **Note:** This method mutates `object`.
  14156. *
  14157. * @static
  14158. * @memberOf _
  14159. * @since 4.6.0
  14160. * @category Object
  14161. * @param {Object} object The object to modify.
  14162. * @param {Array|string} path The path of the property to set.
  14163. * @param {Function} updater The function to produce the updated value.
  14164. * @param {Function} [customizer] The function to customize assigned values.
  14165. * @returns {Object} Returns `object`.
  14166. * @example
  14167. *
  14168. * var object = {};
  14169. *
  14170. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  14171. * // => { '0': { '1': 'a' } }
  14172. */
  14173. function updateWith(object, path, updater, customizer) {
  14174. customizer = typeof customizer == 'function' ? customizer : undefined;
  14175. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  14176. }
  14177. /**
  14178. * Creates an array of the own enumerable string keyed property values of `object`.
  14179. *
  14180. * **Note:** Non-object values are coerced to objects.
  14181. *
  14182. * @static
  14183. * @since 0.1.0
  14184. * @memberOf _
  14185. * @category Object
  14186. * @param {Object} object The object to query.
  14187. * @returns {Array} Returns the array of property values.
  14188. * @example
  14189. *
  14190. * function Foo() {
  14191. * this.a = 1;
  14192. * this.b = 2;
  14193. * }
  14194. *
  14195. * Foo.prototype.c = 3;
  14196. *
  14197. * _.values(new Foo);
  14198. * // => [1, 2] (iteration order is not guaranteed)
  14199. *
  14200. * _.values('hi');
  14201. * // => ['h', 'i']
  14202. */
  14203. function values(object) {
  14204. return object == null ? [] : baseValues(object, keys(object));
  14205. }
  14206. /**
  14207. * Creates an array of the own and inherited enumerable string keyed property
  14208. * values of `object`.
  14209. *
  14210. * **Note:** Non-object values are coerced to objects.
  14211. *
  14212. * @static
  14213. * @memberOf _
  14214. * @since 3.0.0
  14215. * @category Object
  14216. * @param {Object} object The object to query.
  14217. * @returns {Array} Returns the array of property values.
  14218. * @example
  14219. *
  14220. * function Foo() {
  14221. * this.a = 1;
  14222. * this.b = 2;
  14223. * }
  14224. *
  14225. * Foo.prototype.c = 3;
  14226. *
  14227. * _.valuesIn(new Foo);
  14228. * // => [1, 2, 3] (iteration order is not guaranteed)
  14229. */
  14230. function valuesIn(object) {
  14231. return object == null ? [] : baseValues(object, keysIn(object));
  14232. }
  14233. /*------------------------------------------------------------------------*/
  14234. /**
  14235. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  14236. *
  14237. * @static
  14238. * @memberOf _
  14239. * @since 4.0.0
  14240. * @category Number
  14241. * @param {number} number The number to clamp.
  14242. * @param {number} [lower] The lower bound.
  14243. * @param {number} upper The upper bound.
  14244. * @returns {number} Returns the clamped number.
  14245. * @example
  14246. *
  14247. * _.clamp(-10, -5, 5);
  14248. * // => -5
  14249. *
  14250. * _.clamp(10, -5, 5);
  14251. * // => 5
  14252. */
  14253. function clamp(number, lower, upper) {
  14254. if (upper === undefined) {
  14255. upper = lower;
  14256. lower = undefined;
  14257. }
  14258. if (upper !== undefined) {
  14259. upper = toNumber(upper);
  14260. upper = upper === upper ? upper : 0;
  14261. }
  14262. if (lower !== undefined) {
  14263. lower = toNumber(lower);
  14264. lower = lower === lower ? lower : 0;
  14265. }
  14266. return baseClamp(toNumber(number), lower, upper);
  14267. }
  14268. /**
  14269. * Checks if `n` is between `start` and up to, but not including, `end`. If
  14270. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  14271. * If `start` is greater than `end` the params are swapped to support
  14272. * negative ranges.
  14273. *
  14274. * @static
  14275. * @memberOf _
  14276. * @since 3.3.0
  14277. * @category Number
  14278. * @param {number} number The number to check.
  14279. * @param {number} [start=0] The start of the range.
  14280. * @param {number} end The end of the range.
  14281. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  14282. * @see _.range, _.rangeRight
  14283. * @example
  14284. *
  14285. * _.inRange(3, 2, 4);
  14286. * // => true
  14287. *
  14288. * _.inRange(4, 8);
  14289. * // => true
  14290. *
  14291. * _.inRange(4, 2);
  14292. * // => false
  14293. *
  14294. * _.inRange(2, 2);
  14295. * // => false
  14296. *
  14297. * _.inRange(1.2, 2);
  14298. * // => true
  14299. *
  14300. * _.inRange(5.2, 4);
  14301. * // => false
  14302. *
  14303. * _.inRange(-3, -2, -6);
  14304. * // => true
  14305. */
  14306. function inRange(number, start, end) {
  14307. start = toFinite(start);
  14308. if (end === undefined) {
  14309. end = start;
  14310. start = 0;
  14311. } else {
  14312. end = toFinite(end);
  14313. }
  14314. number = toNumber(number);
  14315. return baseInRange(number, start, end);
  14316. }
  14317. /**
  14318. * Produces a random number between the inclusive `lower` and `upper` bounds.
  14319. * If only one argument is provided a number between `0` and the given number
  14320. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  14321. * floats, a floating-point number is returned instead of an integer.
  14322. *
  14323. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  14324. * floating-point values which can produce unexpected results.
  14325. *
  14326. * @static
  14327. * @memberOf _
  14328. * @since 0.7.0
  14329. * @category Number
  14330. * @param {number} [lower=0] The lower bound.
  14331. * @param {number} [upper=1] The upper bound.
  14332. * @param {boolean} [floating] Specify returning a floating-point number.
  14333. * @returns {number} Returns the random number.
  14334. * @example
  14335. *
  14336. * _.random(0, 5);
  14337. * // => an integer between 0 and 5
  14338. *
  14339. * _.random(5);
  14340. * // => also an integer between 0 and 5
  14341. *
  14342. * _.random(5, true);
  14343. * // => a floating-point number between 0 and 5
  14344. *
  14345. * _.random(1.2, 5.2);
  14346. * // => a floating-point number between 1.2 and 5.2
  14347. */
  14348. function random(lower, upper, floating) {
  14349. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  14350. upper = floating = undefined;
  14351. }
  14352. if (floating === undefined) {
  14353. if (typeof upper == 'boolean') {
  14354. floating = upper;
  14355. upper = undefined;
  14356. }
  14357. else if (typeof lower == 'boolean') {
  14358. floating = lower;
  14359. lower = undefined;
  14360. }
  14361. }
  14362. if (lower === undefined && upper === undefined) {
  14363. lower = 0;
  14364. upper = 1;
  14365. }
  14366. else {
  14367. lower = toFinite(lower);
  14368. if (upper === undefined) {
  14369. upper = lower;
  14370. lower = 0;
  14371. } else {
  14372. upper = toFinite(upper);
  14373. }
  14374. }
  14375. if (lower > upper) {
  14376. var temp = lower;
  14377. lower = upper;
  14378. upper = temp;
  14379. }
  14380. if (floating || lower % 1 || upper % 1) {
  14381. var rand = nativeRandom();
  14382. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  14383. }
  14384. return baseRandom(lower, upper);
  14385. }
  14386. /*------------------------------------------------------------------------*/
  14387. /**
  14388. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  14389. *
  14390. * @static
  14391. * @memberOf _
  14392. * @since 3.0.0
  14393. * @category String
  14394. * @param {string} [string=''] The string to convert.
  14395. * @returns {string} Returns the camel cased string.
  14396. * @example
  14397. *
  14398. * _.camelCase('Foo Bar');
  14399. * // => 'fooBar'
  14400. *
  14401. * _.camelCase('--foo-bar--');
  14402. * // => 'fooBar'
  14403. *
  14404. * _.camelCase('__FOO_BAR__');
  14405. * // => 'fooBar'
  14406. */
  14407. var camelCase = createCompounder(function(result, word, index) {
  14408. word = word.toLowerCase();
  14409. return result + (index ? capitalize(word) : word);
  14410. });
  14411. /**
  14412. * Converts the first character of `string` to upper case and the remaining
  14413. * to lower case.
  14414. *
  14415. * @static
  14416. * @memberOf _
  14417. * @since 3.0.0
  14418. * @category String
  14419. * @param {string} [string=''] The string to capitalize.
  14420. * @returns {string} Returns the capitalized string.
  14421. * @example
  14422. *
  14423. * _.capitalize('FRED');
  14424. * // => 'Fred'
  14425. */
  14426. function capitalize(string) {
  14427. return upperFirst(toString(string).toLowerCase());
  14428. }
  14429. /**
  14430. * Deburrs `string` by converting
  14431. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  14432. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  14433. * letters to basic Latin letters and removing
  14434. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  14435. *
  14436. * @static
  14437. * @memberOf _
  14438. * @since 3.0.0
  14439. * @category String
  14440. * @param {string} [string=''] The string to deburr.
  14441. * @returns {string} Returns the deburred string.
  14442. * @example
  14443. *
  14444. * _.deburr('déjà vu');
  14445. * // => 'deja vu'
  14446. */
  14447. function deburr(string) {
  14448. string = toString(string);
  14449. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  14450. }
  14451. /**
  14452. * Checks if `string` ends with the given target string.
  14453. *
  14454. * @static
  14455. * @memberOf _
  14456. * @since 3.0.0
  14457. * @category String
  14458. * @param {string} [string=''] The string to inspect.
  14459. * @param {string} [target] The string to search for.
  14460. * @param {number} [position=string.length] The position to search up to.
  14461. * @returns {boolean} Returns `true` if `string` ends with `target`,
  14462. * else `false`.
  14463. * @example
  14464. *
  14465. * _.endsWith('abc', 'c');
  14466. * // => true
  14467. *
  14468. * _.endsWith('abc', 'b');
  14469. * // => false
  14470. *
  14471. * _.endsWith('abc', 'b', 2);
  14472. * // => true
  14473. */
  14474. function endsWith(string, target, position) {
  14475. string = toString(string);
  14476. target = baseToString(target);
  14477. var length = string.length;
  14478. position = position === undefined
  14479. ? length
  14480. : baseClamp(toInteger(position), 0, length);
  14481. var end = position;
  14482. position -= target.length;
  14483. return position >= 0 && string.slice(position, end) == target;
  14484. }
  14485. /**
  14486. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  14487. * corresponding HTML entities.
  14488. *
  14489. * **Note:** No other characters are escaped. To escape additional
  14490. * characters use a third-party library like [_he_](https://mths.be/he).
  14491. *
  14492. * Though the ">" character is escaped for symmetry, characters like
  14493. * ">" and "/" don't need escaping in HTML and have no special meaning
  14494. * unless they're part of a tag or unquoted attribute value. See
  14495. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  14496. * (under "semi-related fun fact") for more details.
  14497. *
  14498. * When working with HTML you should always
  14499. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  14500. * XSS vectors.
  14501. *
  14502. * @static
  14503. * @since 0.1.0
  14504. * @memberOf _
  14505. * @category String
  14506. * @param {string} [string=''] The string to escape.
  14507. * @returns {string} Returns the escaped string.
  14508. * @example
  14509. *
  14510. * _.escape('fred, barney, & pebbles');
  14511. * // => 'fred, barney, &amp; pebbles'
  14512. */
  14513. function escape(string) {
  14514. string = toString(string);
  14515. return (string && reHasUnescapedHtml.test(string))
  14516. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  14517. : string;
  14518. }
  14519. /**
  14520. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  14521. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  14522. *
  14523. * @static
  14524. * @memberOf _
  14525. * @since 3.0.0
  14526. * @category String
  14527. * @param {string} [string=''] The string to escape.
  14528. * @returns {string} Returns the escaped string.
  14529. * @example
  14530. *
  14531. * _.escapeRegExp('[lodash](https://lodash.com/)');
  14532. * // => '\[lodash\]\(https://lodash\.com/\)'
  14533. */
  14534. function escapeRegExp(string) {
  14535. string = toString(string);
  14536. return (string && reHasRegExpChar.test(string))
  14537. ? string.replace(reRegExpChar, '\\$&')
  14538. : string;
  14539. }
  14540. /**
  14541. * Converts `string` to
  14542. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  14543. *
  14544. * @static
  14545. * @memberOf _
  14546. * @since 3.0.0
  14547. * @category String
  14548. * @param {string} [string=''] The string to convert.
  14549. * @returns {string} Returns the kebab cased string.
  14550. * @example
  14551. *
  14552. * _.kebabCase('Foo Bar');
  14553. * // => 'foo-bar'
  14554. *
  14555. * _.kebabCase('fooBar');
  14556. * // => 'foo-bar'
  14557. *
  14558. * _.kebabCase('__FOO_BAR__');
  14559. * // => 'foo-bar'
  14560. */
  14561. var kebabCase = createCompounder(function(result, word, index) {
  14562. return result + (index ? '-' : '') + word.toLowerCase();
  14563. });
  14564. /**
  14565. * Converts `string`, as space separated words, to lower case.
  14566. *
  14567. * @static
  14568. * @memberOf _
  14569. * @since 4.0.0
  14570. * @category String
  14571. * @param {string} [string=''] The string to convert.
  14572. * @returns {string} Returns the lower cased string.
  14573. * @example
  14574. *
  14575. * _.lowerCase('--Foo-Bar--');
  14576. * // => 'foo bar'
  14577. *
  14578. * _.lowerCase('fooBar');
  14579. * // => 'foo bar'
  14580. *
  14581. * _.lowerCase('__FOO_BAR__');
  14582. * // => 'foo bar'
  14583. */
  14584. var lowerCase = createCompounder(function(result, word, index) {
  14585. return result + (index ? ' ' : '') + word.toLowerCase();
  14586. });
  14587. /**
  14588. * Converts the first character of `string` to lower case.
  14589. *
  14590. * @static
  14591. * @memberOf _
  14592. * @since 4.0.0
  14593. * @category String
  14594. * @param {string} [string=''] The string to convert.
  14595. * @returns {string} Returns the converted string.
  14596. * @example
  14597. *
  14598. * _.lowerFirst('Fred');
  14599. * // => 'fred'
  14600. *
  14601. * _.lowerFirst('FRED');
  14602. * // => 'fRED'
  14603. */
  14604. var lowerFirst = createCaseFirst('toLowerCase');
  14605. /**
  14606. * Pads `string` on the left and right sides if it's shorter than `length`.
  14607. * Padding characters are truncated if they can't be evenly divided by `length`.
  14608. *
  14609. * @static
  14610. * @memberOf _
  14611. * @since 3.0.0
  14612. * @category String
  14613. * @param {string} [string=''] The string to pad.
  14614. * @param {number} [length=0] The padding length.
  14615. * @param {string} [chars=' '] The string used as padding.
  14616. * @returns {string} Returns the padded string.
  14617. * @example
  14618. *
  14619. * _.pad('abc', 8);
  14620. * // => ' abc '
  14621. *
  14622. * _.pad('abc', 8, '_-');
  14623. * // => '_-abc_-_'
  14624. *
  14625. * _.pad('abc', 3);
  14626. * // => 'abc'
  14627. */
  14628. function pad(string, length, chars) {
  14629. string = toString(string);
  14630. length = toInteger(length);
  14631. var strLength = length ? stringSize(string) : 0;
  14632. if (!length || strLength >= length) {
  14633. return string;
  14634. }
  14635. var mid = (length - strLength) / 2;
  14636. return (
  14637. createPadding(nativeFloor(mid), chars) +
  14638. string +
  14639. createPadding(nativeCeil(mid), chars)
  14640. );
  14641. }
  14642. /**
  14643. * Pads `string` on the right side if it's shorter than `length`. Padding
  14644. * characters are truncated if they exceed `length`.
  14645. *
  14646. * @static
  14647. * @memberOf _
  14648. * @since 4.0.0
  14649. * @category String
  14650. * @param {string} [string=''] The string to pad.
  14651. * @param {number} [length=0] The padding length.
  14652. * @param {string} [chars=' '] The string used as padding.
  14653. * @returns {string} Returns the padded string.
  14654. * @example
  14655. *
  14656. * _.padEnd('abc', 6);
  14657. * // => 'abc '
  14658. *
  14659. * _.padEnd('abc', 6, '_-');
  14660. * // => 'abc_-_'
  14661. *
  14662. * _.padEnd('abc', 3);
  14663. * // => 'abc'
  14664. */
  14665. function padEnd(string, length, chars) {
  14666. string = toString(string);
  14667. length = toInteger(length);
  14668. var strLength = length ? stringSize(string) : 0;
  14669. return (length && strLength < length)
  14670. ? (string + createPadding(length - strLength, chars))
  14671. : string;
  14672. }
  14673. /**
  14674. * Pads `string` on the left side if it's shorter than `length`. Padding
  14675. * characters are truncated if they exceed `length`.
  14676. *
  14677. * @static
  14678. * @memberOf _
  14679. * @since 4.0.0
  14680. * @category String
  14681. * @param {string} [string=''] The string to pad.
  14682. * @param {number} [length=0] The padding length.
  14683. * @param {string} [chars=' '] The string used as padding.
  14684. * @returns {string} Returns the padded string.
  14685. * @example
  14686. *
  14687. * _.padStart('abc', 6);
  14688. * // => ' abc'
  14689. *
  14690. * _.padStart('abc', 6, '_-');
  14691. * // => '_-_abc'
  14692. *
  14693. * _.padStart('abc', 3);
  14694. * // => 'abc'
  14695. */
  14696. function padStart(string, length, chars) {
  14697. string = toString(string);
  14698. length = toInteger(length);
  14699. var strLength = length ? stringSize(string) : 0;
  14700. return (length && strLength < length)
  14701. ? (createPadding(length - strLength, chars) + string)
  14702. : string;
  14703. }
  14704. /**
  14705. * Converts `string` to an integer of the specified radix. If `radix` is
  14706. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  14707. * hexadecimal, in which case a `radix` of `16` is used.
  14708. *
  14709. * **Note:** This method aligns with the
  14710. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  14711. *
  14712. * @static
  14713. * @memberOf _
  14714. * @since 1.1.0
  14715. * @category String
  14716. * @param {string} string The string to convert.
  14717. * @param {number} [radix=10] The radix to interpret `value` by.
  14718. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14719. * @returns {number} Returns the converted integer.
  14720. * @example
  14721. *
  14722. * _.parseInt('08');
  14723. * // => 8
  14724. *
  14725. * _.map(['6', '08', '10'], _.parseInt);
  14726. * // => [6, 8, 10]
  14727. */
  14728. function parseInt(string, radix, guard) {
  14729. if (guard || radix == null) {
  14730. radix = 0;
  14731. } else if (radix) {
  14732. radix = +radix;
  14733. }
  14734. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  14735. }
  14736. /**
  14737. * Repeats the given string `n` times.
  14738. *
  14739. * @static
  14740. * @memberOf _
  14741. * @since 3.0.0
  14742. * @category String
  14743. * @param {string} [string=''] The string to repeat.
  14744. * @param {number} [n=1] The number of times to repeat the string.
  14745. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14746. * @returns {string} Returns the repeated string.
  14747. * @example
  14748. *
  14749. * _.repeat('*', 3);
  14750. * // => '***'
  14751. *
  14752. * _.repeat('abc', 2);
  14753. * // => 'abcabc'
  14754. *
  14755. * _.repeat('abc', 0);
  14756. * // => ''
  14757. */
  14758. function repeat(string, n, guard) {
  14759. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  14760. n = 1;
  14761. } else {
  14762. n = toInteger(n);
  14763. }
  14764. return baseRepeat(toString(string), n);
  14765. }
  14766. /**
  14767. * Replaces matches for `pattern` in `string` with `replacement`.
  14768. *
  14769. * **Note:** This method is based on
  14770. * [`String#replace`](https://mdn.io/String/replace).
  14771. *
  14772. * @static
  14773. * @memberOf _
  14774. * @since 4.0.0
  14775. * @category String
  14776. * @param {string} [string=''] The string to modify.
  14777. * @param {RegExp|string} pattern The pattern to replace.
  14778. * @param {Function|string} replacement The match replacement.
  14779. * @returns {string} Returns the modified string.
  14780. * @example
  14781. *
  14782. * _.replace('Hi Fred', 'Fred', 'Barney');
  14783. * // => 'Hi Barney'
  14784. */
  14785. function replace() {
  14786. var args = arguments,
  14787. string = toString(args[0]);
  14788. return args.length < 3 ? string : string.replace(args[1], args[2]);
  14789. }
  14790. /**
  14791. * Converts `string` to
  14792. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  14793. *
  14794. * @static
  14795. * @memberOf _
  14796. * @since 3.0.0
  14797. * @category String
  14798. * @param {string} [string=''] The string to convert.
  14799. * @returns {string} Returns the snake cased string.
  14800. * @example
  14801. *
  14802. * _.snakeCase('Foo Bar');
  14803. * // => 'foo_bar'
  14804. *
  14805. * _.snakeCase('fooBar');
  14806. * // => 'foo_bar'
  14807. *
  14808. * _.snakeCase('--FOO-BAR--');
  14809. * // => 'foo_bar'
  14810. */
  14811. var snakeCase = createCompounder(function(result, word, index) {
  14812. return result + (index ? '_' : '') + word.toLowerCase();
  14813. });
  14814. /**
  14815. * Splits `string` by `separator`.
  14816. *
  14817. * **Note:** This method is based on
  14818. * [`String#split`](https://mdn.io/String/split).
  14819. *
  14820. * @static
  14821. * @memberOf _
  14822. * @since 4.0.0
  14823. * @category String
  14824. * @param {string} [string=''] The string to split.
  14825. * @param {RegExp|string} separator The separator pattern to split by.
  14826. * @param {number} [limit] The length to truncate results to.
  14827. * @returns {Array} Returns the string segments.
  14828. * @example
  14829. *
  14830. * _.split('a-b-c', '-', 2);
  14831. * // => ['a', 'b']
  14832. */
  14833. function split(string, separator, limit) {
  14834. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  14835. separator = limit = undefined;
  14836. }
  14837. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  14838. if (!limit) {
  14839. return [];
  14840. }
  14841. string = toString(string);
  14842. if (string && (
  14843. typeof separator == 'string' ||
  14844. (separator != null && !isRegExp(separator))
  14845. )) {
  14846. separator = baseToString(separator);
  14847. if (!separator && hasUnicode(string)) {
  14848. return castSlice(stringToArray(string), 0, limit);
  14849. }
  14850. }
  14851. return string.split(separator, limit);
  14852. }
  14853. /**
  14854. * Converts `string` to
  14855. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  14856. *
  14857. * @static
  14858. * @memberOf _
  14859. * @since 3.1.0
  14860. * @category String
  14861. * @param {string} [string=''] The string to convert.
  14862. * @returns {string} Returns the start cased string.
  14863. * @example
  14864. *
  14865. * _.startCase('--foo-bar--');
  14866. * // => 'Foo Bar'
  14867. *
  14868. * _.startCase('fooBar');
  14869. * // => 'Foo Bar'
  14870. *
  14871. * _.startCase('__FOO_BAR__');
  14872. * // => 'FOO BAR'
  14873. */
  14874. var startCase = createCompounder(function(result, word, index) {
  14875. return result + (index ? ' ' : '') + upperFirst(word);
  14876. });
  14877. /**
  14878. * Checks if `string` starts with the given target string.
  14879. *
  14880. * @static
  14881. * @memberOf _
  14882. * @since 3.0.0
  14883. * @category String
  14884. * @param {string} [string=''] The string to inspect.
  14885. * @param {string} [target] The string to search for.
  14886. * @param {number} [position=0] The position to search from.
  14887. * @returns {boolean} Returns `true` if `string` starts with `target`,
  14888. * else `false`.
  14889. * @example
  14890. *
  14891. * _.startsWith('abc', 'a');
  14892. * // => true
  14893. *
  14894. * _.startsWith('abc', 'b');
  14895. * // => false
  14896. *
  14897. * _.startsWith('abc', 'b', 1);
  14898. * // => true
  14899. */
  14900. function startsWith(string, target, position) {
  14901. string = toString(string);
  14902. position = position == null
  14903. ? 0
  14904. : baseClamp(toInteger(position), 0, string.length);
  14905. target = baseToString(target);
  14906. return string.slice(position, position + target.length) == target;
  14907. }
  14908. /**
  14909. * Creates a compiled template function that can interpolate data properties
  14910. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  14911. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  14912. * properties may be accessed as free variables in the template. If a setting
  14913. * object is given, it takes precedence over `_.templateSettings` values.
  14914. *
  14915. * **Note:** In the development build `_.template` utilizes
  14916. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  14917. * for easier debugging.
  14918. *
  14919. * For more information on precompiling templates see
  14920. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  14921. *
  14922. * For more information on Chrome extension sandboxes see
  14923. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  14924. *
  14925. * @static
  14926. * @since 0.1.0
  14927. * @memberOf _
  14928. * @category String
  14929. * @param {string} [string=''] The template string.
  14930. * @param {Object} [options={}] The options object.
  14931. * @param {RegExp} [options.escape=_.templateSettings.escape]
  14932. * The HTML "escape" delimiter.
  14933. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  14934. * The "evaluate" delimiter.
  14935. * @param {Object} [options.imports=_.templateSettings.imports]
  14936. * An object to import into the template as free variables.
  14937. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  14938. * The "interpolate" delimiter.
  14939. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  14940. * The sourceURL of the compiled template.
  14941. * @param {string} [options.variable='obj']
  14942. * The data object variable name.
  14943. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14944. * @returns {Function} Returns the compiled template function.
  14945. * @example
  14946. *
  14947. * // Use the "interpolate" delimiter to create a compiled template.
  14948. * var compiled = _.template('hello <%= user %>!');
  14949. * compiled({ 'user': 'fred' });
  14950. * // => 'hello fred!'
  14951. *
  14952. * // Use the HTML "escape" delimiter to escape data property values.
  14953. * var compiled = _.template('<b><%- value %></b>');
  14954. * compiled({ 'value': '<script>' });
  14955. * // => '<b>&lt;script&gt;</b>'
  14956. *
  14957. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  14958. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  14959. * compiled({ 'users': ['fred', 'barney'] });
  14960. * // => '<li>fred</li><li>barney</li>'
  14961. *
  14962. * // Use the internal `print` function in "evaluate" delimiters.
  14963. * var compiled = _.template('<% print("hello " + user); %>!');
  14964. * compiled({ 'user': 'barney' });
  14965. * // => 'hello barney!'
  14966. *
  14967. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  14968. * // Disable support by replacing the "interpolate" delimiter.
  14969. * var compiled = _.template('hello ${ user }!');
  14970. * compiled({ 'user': 'pebbles' });
  14971. * // => 'hello pebbles!'
  14972. *
  14973. * // Use backslashes to treat delimiters as plain text.
  14974. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  14975. * compiled({ 'value': 'ignored' });
  14976. * // => '<%- value %>'
  14977. *
  14978. * // Use the `imports` option to import `jQuery` as `jq`.
  14979. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  14980. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  14981. * compiled({ 'users': ['fred', 'barney'] });
  14982. * // => '<li>fred</li><li>barney</li>'
  14983. *
  14984. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  14985. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  14986. * compiled(data);
  14987. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  14988. *
  14989. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  14990. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  14991. * compiled.source;
  14992. * // => function(data) {
  14993. * // var __t, __p = '';
  14994. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  14995. * // return __p;
  14996. * // }
  14997. *
  14998. * // Use custom template delimiters.
  14999. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  15000. * var compiled = _.template('hello {{ user }}!');
  15001. * compiled({ 'user': 'mustache' });
  15002. * // => 'hello mustache!'
  15003. *
  15004. * // Use the `source` property to inline compiled templates for meaningful
  15005. * // line numbers in error messages and stack traces.
  15006. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  15007. * var JST = {\
  15008. * "main": ' + _.template(mainText).source + '\
  15009. * };\
  15010. * ');
  15011. */
  15012. function template(string, options, guard) {
  15013. // Based on John Resig's `tmpl` implementation
  15014. // (http://ejohn.org/blog/javascript-micro-templating/)
  15015. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  15016. var settings = lodash.templateSettings;
  15017. if (guard && isIterateeCall(string, options, guard)) {
  15018. options = undefined;
  15019. }
  15020. string = toString(string);
  15021. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  15022. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  15023. importsKeys = keys(imports),
  15024. importsValues = baseValues(imports, importsKeys);
  15025. var isEscaping,
  15026. isEvaluating,
  15027. index = 0,
  15028. interpolate = options.interpolate || reNoMatch,
  15029. source = "__p += '";
  15030. // Compile the regexp to match each delimiter.
  15031. var reDelimiters = RegExp(
  15032. (options.escape || reNoMatch).source + '|' +
  15033. interpolate.source + '|' +
  15034. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  15035. (options.evaluate || reNoMatch).source + '|$'
  15036. , 'g');
  15037. // Use a sourceURL for easier debugging.
  15038. // The sourceURL gets injected into the source that's eval-ed, so be careful
  15039. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  15040. // and escape the comment, thus injecting code that gets evaled.
  15041. var sourceURL = '//# sourceURL=' +
  15042. (hasOwnProperty.call(options, 'sourceURL')
  15043. ? (options.sourceURL + '').replace(/\s/g, ' ')
  15044. : ('lodash.templateSources[' + (++templateCounter) + ']')
  15045. ) + '\n';
  15046. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  15047. interpolateValue || (interpolateValue = esTemplateValue);
  15048. // Escape characters that can't be included in string literals.
  15049. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  15050. // Replace delimiters with snippets.
  15051. if (escapeValue) {
  15052. isEscaping = true;
  15053. source += "' +\n__e(" + escapeValue + ") +\n'";
  15054. }
  15055. if (evaluateValue) {
  15056. isEvaluating = true;
  15057. source += "';\n" + evaluateValue + ";\n__p += '";
  15058. }
  15059. if (interpolateValue) {
  15060. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  15061. }
  15062. index = offset + match.length;
  15063. // The JS engine embedded in Adobe products needs `match` returned in
  15064. // order to produce the correct `offset` value.
  15065. return match;
  15066. });
  15067. source += "';\n";
  15068. // If `variable` is not specified wrap a with-statement around the generated
  15069. // code to add the data object to the top of the scope chain.
  15070. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  15071. if (!variable) {
  15072. source = 'with (obj) {\n' + source + '\n}\n';
  15073. }
  15074. // Throw an error if a forbidden character was found in `variable`, to prevent
  15075. // potential command injection attacks.
  15076. else if (reForbiddenIdentifierChars.test(variable)) {
  15077. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  15078. }
  15079. // Cleanup code by stripping empty strings.
  15080. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  15081. .replace(reEmptyStringMiddle, '$1')
  15082. .replace(reEmptyStringTrailing, '$1;');
  15083. // Frame code as the function body.
  15084. source = 'function(' + (variable || 'obj') + ') {\n' +
  15085. (variable
  15086. ? ''
  15087. : 'obj || (obj = {});\n'
  15088. ) +
  15089. "var __t, __p = ''" +
  15090. (isEscaping
  15091. ? ', __e = _.escape'
  15092. : ''
  15093. ) +
  15094. (isEvaluating
  15095. ? ', __j = Array.prototype.join;\n' +
  15096. "function print() { __p += __j.call(arguments, '') }\n"
  15097. : ';\n'
  15098. ) +
  15099. source +
  15100. 'return __p\n}';
  15101. var result = attempt(function() {
  15102. return Function(importsKeys, sourceURL + 'return ' + source)
  15103. .apply(undefined, importsValues);
  15104. });
  15105. // Provide the compiled function's source by its `toString` method or
  15106. // the `source` property as a convenience for inlining compiled templates.
  15107. result.source = source;
  15108. if (isError(result)) {
  15109. throw result;
  15110. }
  15111. return result;
  15112. }
  15113. /**
  15114. * Converts `string`, as a whole, to lower case just like
  15115. * [String#toLowerCase](https://mdn.io/toLowerCase).
  15116. *
  15117. * @static
  15118. * @memberOf _
  15119. * @since 4.0.0
  15120. * @category String
  15121. * @param {string} [string=''] The string to convert.
  15122. * @returns {string} Returns the lower cased string.
  15123. * @example
  15124. *
  15125. * _.toLower('--Foo-Bar--');
  15126. * // => '--foo-bar--'
  15127. *
  15128. * _.toLower('fooBar');
  15129. * // => 'foobar'
  15130. *
  15131. * _.toLower('__FOO_BAR__');
  15132. * // => '__foo_bar__'
  15133. */
  15134. function toLower(value) {
  15135. return toString(value).toLowerCase();
  15136. }
  15137. /**
  15138. * Converts `string`, as a whole, to upper case just like
  15139. * [String#toUpperCase](https://mdn.io/toUpperCase).
  15140. *
  15141. * @static
  15142. * @memberOf _
  15143. * @since 4.0.0
  15144. * @category String
  15145. * @param {string} [string=''] The string to convert.
  15146. * @returns {string} Returns the upper cased string.
  15147. * @example
  15148. *
  15149. * _.toUpper('--foo-bar--');
  15150. * // => '--FOO-BAR--'
  15151. *
  15152. * _.toUpper('fooBar');
  15153. * // => 'FOOBAR'
  15154. *
  15155. * _.toUpper('__foo_bar__');
  15156. * // => '__FOO_BAR__'
  15157. */
  15158. function toUpper(value) {
  15159. return toString(value).toUpperCase();
  15160. }
  15161. /**
  15162. * Removes leading and trailing whitespace or specified characters from `string`.
  15163. *
  15164. * @static
  15165. * @memberOf _
  15166. * @since 3.0.0
  15167. * @category String
  15168. * @param {string} [string=''] The string to trim.
  15169. * @param {string} [chars=whitespace] The characters to trim.
  15170. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15171. * @returns {string} Returns the trimmed string.
  15172. * @example
  15173. *
  15174. * _.trim(' abc ');
  15175. * // => 'abc'
  15176. *
  15177. * _.trim('-_-abc-_-', '_-');
  15178. * // => 'abc'
  15179. *
  15180. * _.map([' foo ', ' bar '], _.trim);
  15181. * // => ['foo', 'bar']
  15182. */
  15183. function trim(string, chars, guard) {
  15184. string = toString(string);
  15185. if (string && (guard || chars === undefined)) {
  15186. return baseTrim(string);
  15187. }
  15188. if (!string || !(chars = baseToString(chars))) {
  15189. return string;
  15190. }
  15191. var strSymbols = stringToArray(string),
  15192. chrSymbols = stringToArray(chars),
  15193. start = charsStartIndex(strSymbols, chrSymbols),
  15194. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  15195. return castSlice(strSymbols, start, end).join('');
  15196. }
  15197. /**
  15198. * Removes trailing whitespace or specified characters from `string`.
  15199. *
  15200. * @static
  15201. * @memberOf _
  15202. * @since 4.0.0
  15203. * @category String
  15204. * @param {string} [string=''] The string to trim.
  15205. * @param {string} [chars=whitespace] The characters to trim.
  15206. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15207. * @returns {string} Returns the trimmed string.
  15208. * @example
  15209. *
  15210. * _.trimEnd(' abc ');
  15211. * // => ' abc'
  15212. *
  15213. * _.trimEnd('-_-abc-_-', '_-');
  15214. * // => '-_-abc'
  15215. */
  15216. function trimEnd(string, chars, guard) {
  15217. string = toString(string);
  15218. if (string && (guard || chars === undefined)) {
  15219. return string.slice(0, trimmedEndIndex(string) + 1);
  15220. }
  15221. if (!string || !(chars = baseToString(chars))) {
  15222. return string;
  15223. }
  15224. var strSymbols = stringToArray(string),
  15225. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  15226. return castSlice(strSymbols, 0, end).join('');
  15227. }
  15228. /**
  15229. * Removes leading whitespace or specified characters from `string`.
  15230. *
  15231. * @static
  15232. * @memberOf _
  15233. * @since 4.0.0
  15234. * @category String
  15235. * @param {string} [string=''] The string to trim.
  15236. * @param {string} [chars=whitespace] The characters to trim.
  15237. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15238. * @returns {string} Returns the trimmed string.
  15239. * @example
  15240. *
  15241. * _.trimStart(' abc ');
  15242. * // => 'abc '
  15243. *
  15244. * _.trimStart('-_-abc-_-', '_-');
  15245. * // => 'abc-_-'
  15246. */
  15247. function trimStart(string, chars, guard) {
  15248. string = toString(string);
  15249. if (string && (guard || chars === undefined)) {
  15250. return string.replace(reTrimStart, '');
  15251. }
  15252. if (!string || !(chars = baseToString(chars))) {
  15253. return string;
  15254. }
  15255. var strSymbols = stringToArray(string),
  15256. start = charsStartIndex(strSymbols, stringToArray(chars));
  15257. return castSlice(strSymbols, start).join('');
  15258. }
  15259. /**
  15260. * Truncates `string` if it's longer than the given maximum string length.
  15261. * The last characters of the truncated string are replaced with the omission
  15262. * string which defaults to "...".
  15263. *
  15264. * @static
  15265. * @memberOf _
  15266. * @since 4.0.0
  15267. * @category String
  15268. * @param {string} [string=''] The string to truncate.
  15269. * @param {Object} [options={}] The options object.
  15270. * @param {number} [options.length=30] The maximum string length.
  15271. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  15272. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  15273. * @returns {string} Returns the truncated string.
  15274. * @example
  15275. *
  15276. * _.truncate('hi-diddly-ho there, neighborino');
  15277. * // => 'hi-diddly-ho there, neighbo...'
  15278. *
  15279. * _.truncate('hi-diddly-ho there, neighborino', {
  15280. * 'length': 24,
  15281. * 'separator': ' '
  15282. * });
  15283. * // => 'hi-diddly-ho there,...'
  15284. *
  15285. * _.truncate('hi-diddly-ho there, neighborino', {
  15286. * 'length': 24,
  15287. * 'separator': /,? +/
  15288. * });
  15289. * // => 'hi-diddly-ho there...'
  15290. *
  15291. * _.truncate('hi-diddly-ho there, neighborino', {
  15292. * 'omission': ' [...]'
  15293. * });
  15294. * // => 'hi-diddly-ho there, neig [...]'
  15295. */
  15296. function truncate(string, options) {
  15297. var length = DEFAULT_TRUNC_LENGTH,
  15298. omission = DEFAULT_TRUNC_OMISSION;
  15299. if (isObject(options)) {
  15300. var separator = 'separator' in options ? options.separator : separator;
  15301. length = 'length' in options ? toInteger(options.length) : length;
  15302. omission = 'omission' in options ? baseToString(options.omission) : omission;
  15303. }
  15304. string = toString(string);
  15305. var strLength = string.length;
  15306. if (hasUnicode(string)) {
  15307. var strSymbols = stringToArray(string);
  15308. strLength = strSymbols.length;
  15309. }
  15310. if (length >= strLength) {
  15311. return string;
  15312. }
  15313. var end = length - stringSize(omission);
  15314. if (end < 1) {
  15315. return omission;
  15316. }
  15317. var result = strSymbols
  15318. ? castSlice(strSymbols, 0, end).join('')
  15319. : string.slice(0, end);
  15320. if (separator === undefined) {
  15321. return result + omission;
  15322. }
  15323. if (strSymbols) {
  15324. end += (result.length - end);
  15325. }
  15326. if (isRegExp(separator)) {
  15327. if (string.slice(end).search(separator)) {
  15328. var match,
  15329. substring = result;
  15330. if (!separator.global) {
  15331. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  15332. }
  15333. separator.lastIndex = 0;
  15334. while ((match = separator.exec(substring))) {
  15335. var newEnd = match.index;
  15336. }
  15337. result = result.slice(0, newEnd === undefined ? end : newEnd);
  15338. }
  15339. } else if (string.indexOf(baseToString(separator), end) != end) {
  15340. var index = result.lastIndexOf(separator);
  15341. if (index > -1) {
  15342. result = result.slice(0, index);
  15343. }
  15344. }
  15345. return result + omission;
  15346. }
  15347. /**
  15348. * The inverse of `_.escape`; this method converts the HTML entities
  15349. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  15350. * their corresponding characters.
  15351. *
  15352. * **Note:** No other HTML entities are unescaped. To unescape additional
  15353. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  15354. *
  15355. * @static
  15356. * @memberOf _
  15357. * @since 0.6.0
  15358. * @category String
  15359. * @param {string} [string=''] The string to unescape.
  15360. * @returns {string} Returns the unescaped string.
  15361. * @example
  15362. *
  15363. * _.unescape('fred, barney, &amp; pebbles');
  15364. * // => 'fred, barney, & pebbles'
  15365. */
  15366. function unescape(string) {
  15367. string = toString(string);
  15368. return (string && reHasEscapedHtml.test(string))
  15369. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  15370. : string;
  15371. }
  15372. /**
  15373. * Converts `string`, as space separated words, to upper case.
  15374. *
  15375. * @static
  15376. * @memberOf _
  15377. * @since 4.0.0
  15378. * @category String
  15379. * @param {string} [string=''] The string to convert.
  15380. * @returns {string} Returns the upper cased string.
  15381. * @example
  15382. *
  15383. * _.upperCase('--foo-bar');
  15384. * // => 'FOO BAR'
  15385. *
  15386. * _.upperCase('fooBar');
  15387. * // => 'FOO BAR'
  15388. *
  15389. * _.upperCase('__foo_bar__');
  15390. * // => 'FOO BAR'
  15391. */
  15392. var upperCase = createCompounder(function(result, word, index) {
  15393. return result + (index ? ' ' : '') + word.toUpperCase();
  15394. });
  15395. /**
  15396. * Converts the first character of `string` to upper case.
  15397. *
  15398. * @static
  15399. * @memberOf _
  15400. * @since 4.0.0
  15401. * @category String
  15402. * @param {string} [string=''] The string to convert.
  15403. * @returns {string} Returns the converted string.
  15404. * @example
  15405. *
  15406. * _.upperFirst('fred');
  15407. * // => 'Fred'
  15408. *
  15409. * _.upperFirst('FRED');
  15410. * // => 'FRED'
  15411. */
  15412. var upperFirst = createCaseFirst('toUpperCase');
  15413. /**
  15414. * Splits `string` into an array of its words.
  15415. *
  15416. * @static
  15417. * @memberOf _
  15418. * @since 3.0.0
  15419. * @category String
  15420. * @param {string} [string=''] The string to inspect.
  15421. * @param {RegExp|string} [pattern] The pattern to match words.
  15422. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15423. * @returns {Array} Returns the words of `string`.
  15424. * @example
  15425. *
  15426. * _.words('fred, barney, & pebbles');
  15427. * // => ['fred', 'barney', 'pebbles']
  15428. *
  15429. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  15430. * // => ['fred', 'barney', '&', 'pebbles']
  15431. */
  15432. function words(string, pattern, guard) {
  15433. string = toString(string);
  15434. pattern = guard ? undefined : pattern;
  15435. if (pattern === undefined) {
  15436. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  15437. }
  15438. return string.match(pattern) || [];
  15439. }
  15440. /*------------------------------------------------------------------------*/
  15441. /**
  15442. * Attempts to invoke `func`, returning either the result or the caught error
  15443. * object. Any additional arguments are provided to `func` when it's invoked.
  15444. *
  15445. * @static
  15446. * @memberOf _
  15447. * @since 3.0.0
  15448. * @category Util
  15449. * @param {Function} func The function to attempt.
  15450. * @param {...*} [args] The arguments to invoke `func` with.
  15451. * @returns {*} Returns the `func` result or error object.
  15452. * @example
  15453. *
  15454. * // Avoid throwing errors for invalid selectors.
  15455. * var elements = _.attempt(function(selector) {
  15456. * return document.querySelectorAll(selector);
  15457. * }, '>_>');
  15458. *
  15459. * if (_.isError(elements)) {
  15460. * elements = [];
  15461. * }
  15462. */
  15463. var attempt = baseRest(function(func, args) {
  15464. try {
  15465. return apply(func, undefined, args);
  15466. } catch (e) {
  15467. return isError(e) ? e : new Error(e);
  15468. }
  15469. });
  15470. /**
  15471. * Binds methods of an object to the object itself, overwriting the existing
  15472. * method.
  15473. *
  15474. * **Note:** This method doesn't set the "length" property of bound functions.
  15475. *
  15476. * @static
  15477. * @since 0.1.0
  15478. * @memberOf _
  15479. * @category Util
  15480. * @param {Object} object The object to bind and assign the bound methods to.
  15481. * @param {...(string|string[])} methodNames The object method names to bind.
  15482. * @returns {Object} Returns `object`.
  15483. * @example
  15484. *
  15485. * var view = {
  15486. * 'label': 'docs',
  15487. * 'click': function() {
  15488. * console.log('clicked ' + this.label);
  15489. * }
  15490. * };
  15491. *
  15492. * _.bindAll(view, ['click']);
  15493. * jQuery(element).on('click', view.click);
  15494. * // => Logs 'clicked docs' when clicked.
  15495. */
  15496. var bindAll = flatRest(function(object, methodNames) {
  15497. arrayEach(methodNames, function(key) {
  15498. key = toKey(key);
  15499. baseAssignValue(object, key, bind(object[key], object));
  15500. });
  15501. return object;
  15502. });
  15503. /**
  15504. * Creates a function that iterates over `pairs` and invokes the corresponding
  15505. * function of the first predicate to return truthy. The predicate-function
  15506. * pairs are invoked with the `this` binding and arguments of the created
  15507. * function.
  15508. *
  15509. * @static
  15510. * @memberOf _
  15511. * @since 4.0.0
  15512. * @category Util
  15513. * @param {Array} pairs The predicate-function pairs.
  15514. * @returns {Function} Returns the new composite function.
  15515. * @example
  15516. *
  15517. * var func = _.cond([
  15518. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  15519. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  15520. * [_.stubTrue, _.constant('no match')]
  15521. * ]);
  15522. *
  15523. * func({ 'a': 1, 'b': 2 });
  15524. * // => 'matches A'
  15525. *
  15526. * func({ 'a': 0, 'b': 1 });
  15527. * // => 'matches B'
  15528. *
  15529. * func({ 'a': '1', 'b': '2' });
  15530. * // => 'no match'
  15531. */
  15532. function cond(pairs) {
  15533. var length = pairs == null ? 0 : pairs.length,
  15534. toIteratee = getIteratee();
  15535. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  15536. if (typeof pair[1] != 'function') {
  15537. throw new TypeError(FUNC_ERROR_TEXT);
  15538. }
  15539. return [toIteratee(pair[0]), pair[1]];
  15540. });
  15541. return baseRest(function(args) {
  15542. var index = -1;
  15543. while (++index < length) {
  15544. var pair = pairs[index];
  15545. if (apply(pair[0], this, args)) {
  15546. return apply(pair[1], this, args);
  15547. }
  15548. }
  15549. });
  15550. }
  15551. /**
  15552. * Creates a function that invokes the predicate properties of `source` with
  15553. * the corresponding property values of a given object, returning `true` if
  15554. * all predicates return truthy, else `false`.
  15555. *
  15556. * **Note:** The created function is equivalent to `_.conformsTo` with
  15557. * `source` partially applied.
  15558. *
  15559. * @static
  15560. * @memberOf _
  15561. * @since 4.0.0
  15562. * @category Util
  15563. * @param {Object} source The object of property predicates to conform to.
  15564. * @returns {Function} Returns the new spec function.
  15565. * @example
  15566. *
  15567. * var objects = [
  15568. * { 'a': 2, 'b': 1 },
  15569. * { 'a': 1, 'b': 2 }
  15570. * ];
  15571. *
  15572. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  15573. * // => [{ 'a': 1, 'b': 2 }]
  15574. */
  15575. function conforms(source) {
  15576. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  15577. }
  15578. /**
  15579. * Creates a function that returns `value`.
  15580. *
  15581. * @static
  15582. * @memberOf _
  15583. * @since 2.4.0
  15584. * @category Util
  15585. * @param {*} value The value to return from the new function.
  15586. * @returns {Function} Returns the new constant function.
  15587. * @example
  15588. *
  15589. * var objects = _.times(2, _.constant({ 'a': 1 }));
  15590. *
  15591. * console.log(objects);
  15592. * // => [{ 'a': 1 }, { 'a': 1 }]
  15593. *
  15594. * console.log(objects[0] === objects[1]);
  15595. * // => true
  15596. */
  15597. function constant(value) {
  15598. return function() {
  15599. return value;
  15600. };
  15601. }
  15602. /**
  15603. * Checks `value` to determine whether a default value should be returned in
  15604. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  15605. * or `undefined`.
  15606. *
  15607. * @static
  15608. * @memberOf _
  15609. * @since 4.14.0
  15610. * @category Util
  15611. * @param {*} value The value to check.
  15612. * @param {*} defaultValue The default value.
  15613. * @returns {*} Returns the resolved value.
  15614. * @example
  15615. *
  15616. * _.defaultTo(1, 10);
  15617. * // => 1
  15618. *
  15619. * _.defaultTo(undefined, 10);
  15620. * // => 10
  15621. */
  15622. function defaultTo(value, defaultValue) {
  15623. return (value == null || value !== value) ? defaultValue : value;
  15624. }
  15625. /**
  15626. * Creates a function that returns the result of invoking the given functions
  15627. * with the `this` binding of the created function, where each successive
  15628. * invocation is supplied the return value of the previous.
  15629. *
  15630. * @static
  15631. * @memberOf _
  15632. * @since 3.0.0
  15633. * @category Util
  15634. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15635. * @returns {Function} Returns the new composite function.
  15636. * @see _.flowRight
  15637. * @example
  15638. *
  15639. * function square(n) {
  15640. * return n * n;
  15641. * }
  15642. *
  15643. * var addSquare = _.flow([_.add, square]);
  15644. * addSquare(1, 2);
  15645. * // => 9
  15646. */
  15647. var flow = createFlow();
  15648. /**
  15649. * This method is like `_.flow` except that it creates a function that
  15650. * invokes the given functions from right to left.
  15651. *
  15652. * @static
  15653. * @since 3.0.0
  15654. * @memberOf _
  15655. * @category Util
  15656. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  15657. * @returns {Function} Returns the new composite function.
  15658. * @see _.flow
  15659. * @example
  15660. *
  15661. * function square(n) {
  15662. * return n * n;
  15663. * }
  15664. *
  15665. * var addSquare = _.flowRight([square, _.add]);
  15666. * addSquare(1, 2);
  15667. * // => 9
  15668. */
  15669. var flowRight = createFlow(true);
  15670. /**
  15671. * This method returns the first argument it receives.
  15672. *
  15673. * @static
  15674. * @since 0.1.0
  15675. * @memberOf _
  15676. * @category Util
  15677. * @param {*} value Any value.
  15678. * @returns {*} Returns `value`.
  15679. * @example
  15680. *
  15681. * var object = { 'a': 1 };
  15682. *
  15683. * console.log(_.identity(object) === object);
  15684. * // => true
  15685. */
  15686. function identity(value) {
  15687. return value;
  15688. }
  15689. /**
  15690. * Creates a function that invokes `func` with the arguments of the created
  15691. * function. If `func` is a property name, the created function returns the
  15692. * property value for a given element. If `func` is an array or object, the
  15693. * created function returns `true` for elements that contain the equivalent
  15694. * source properties, otherwise it returns `false`.
  15695. *
  15696. * @static
  15697. * @since 4.0.0
  15698. * @memberOf _
  15699. * @category Util
  15700. * @param {*} [func=_.identity] The value to convert to a callback.
  15701. * @returns {Function} Returns the callback.
  15702. * @example
  15703. *
  15704. * var users = [
  15705. * { 'user': 'barney', 'age': 36, 'active': true },
  15706. * { 'user': 'fred', 'age': 40, 'active': false }
  15707. * ];
  15708. *
  15709. * // The `_.matches` iteratee shorthand.
  15710. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  15711. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  15712. *
  15713. * // The `_.matchesProperty` iteratee shorthand.
  15714. * _.filter(users, _.iteratee(['user', 'fred']));
  15715. * // => [{ 'user': 'fred', 'age': 40 }]
  15716. *
  15717. * // The `_.property` iteratee shorthand.
  15718. * _.map(users, _.iteratee('user'));
  15719. * // => ['barney', 'fred']
  15720. *
  15721. * // Create custom iteratee shorthands.
  15722. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  15723. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  15724. * return func.test(string);
  15725. * };
  15726. * });
  15727. *
  15728. * _.filter(['abc', 'def'], /ef/);
  15729. * // => ['def']
  15730. */
  15731. function iteratee(func) {
  15732. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  15733. }
  15734. /**
  15735. * Creates a function that performs a partial deep comparison between a given
  15736. * object and `source`, returning `true` if the given object has equivalent
  15737. * property values, else `false`.
  15738. *
  15739. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  15740. * partially applied.
  15741. *
  15742. * Partial comparisons will match empty array and empty object `source`
  15743. * values against any array or object value, respectively. See `_.isEqual`
  15744. * for a list of supported value comparisons.
  15745. *
  15746. * **Note:** Multiple values can be checked by combining several matchers
  15747. * using `_.overSome`
  15748. *
  15749. * @static
  15750. * @memberOf _
  15751. * @since 3.0.0
  15752. * @category Util
  15753. * @param {Object} source The object of property values to match.
  15754. * @returns {Function} Returns the new spec function.
  15755. * @example
  15756. *
  15757. * var objects = [
  15758. * { 'a': 1, 'b': 2, 'c': 3 },
  15759. * { 'a': 4, 'b': 5, 'c': 6 }
  15760. * ];
  15761. *
  15762. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  15763. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  15764. *
  15765. * // Checking for several possible values
  15766. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  15767. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  15768. */
  15769. function matches(source) {
  15770. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  15771. }
  15772. /**
  15773. * Creates a function that performs a partial deep comparison between the
  15774. * value at `path` of a given object to `srcValue`, returning `true` if the
  15775. * object value is equivalent, else `false`.
  15776. *
  15777. * **Note:** Partial comparisons will match empty array and empty object
  15778. * `srcValue` values against any array or object value, respectively. See
  15779. * `_.isEqual` for a list of supported value comparisons.
  15780. *
  15781. * **Note:** Multiple values can be checked by combining several matchers
  15782. * using `_.overSome`
  15783. *
  15784. * @static
  15785. * @memberOf _
  15786. * @since 3.2.0
  15787. * @category Util
  15788. * @param {Array|string} path The path of the property to get.
  15789. * @param {*} srcValue The value to match.
  15790. * @returns {Function} Returns the new spec function.
  15791. * @example
  15792. *
  15793. * var objects = [
  15794. * { 'a': 1, 'b': 2, 'c': 3 },
  15795. * { 'a': 4, 'b': 5, 'c': 6 }
  15796. * ];
  15797. *
  15798. * _.find(objects, _.matchesProperty('a', 4));
  15799. * // => { 'a': 4, 'b': 5, 'c': 6 }
  15800. *
  15801. * // Checking for several possible values
  15802. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  15803. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  15804. */
  15805. function matchesProperty(path, srcValue) {
  15806. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  15807. }
  15808. /**
  15809. * Creates a function that invokes the method at `path` of a given object.
  15810. * Any additional arguments are provided to the invoked method.
  15811. *
  15812. * @static
  15813. * @memberOf _
  15814. * @since 3.7.0
  15815. * @category Util
  15816. * @param {Array|string} path The path of the method to invoke.
  15817. * @param {...*} [args] The arguments to invoke the method with.
  15818. * @returns {Function} Returns the new invoker function.
  15819. * @example
  15820. *
  15821. * var objects = [
  15822. * { 'a': { 'b': _.constant(2) } },
  15823. * { 'a': { 'b': _.constant(1) } }
  15824. * ];
  15825. *
  15826. * _.map(objects, _.method('a.b'));
  15827. * // => [2, 1]
  15828. *
  15829. * _.map(objects, _.method(['a', 'b']));
  15830. * // => [2, 1]
  15831. */
  15832. var method = baseRest(function(path, args) {
  15833. return function(object) {
  15834. return baseInvoke(object, path, args);
  15835. };
  15836. });
  15837. /**
  15838. * The opposite of `_.method`; this method creates a function that invokes
  15839. * the method at a given path of `object`. Any additional arguments are
  15840. * provided to the invoked method.
  15841. *
  15842. * @static
  15843. * @memberOf _
  15844. * @since 3.7.0
  15845. * @category Util
  15846. * @param {Object} object The object to query.
  15847. * @param {...*} [args] The arguments to invoke the method with.
  15848. * @returns {Function} Returns the new invoker function.
  15849. * @example
  15850. *
  15851. * var array = _.times(3, _.constant),
  15852. * object = { 'a': array, 'b': array, 'c': array };
  15853. *
  15854. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  15855. * // => [2, 0]
  15856. *
  15857. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  15858. * // => [2, 0]
  15859. */
  15860. var methodOf = baseRest(function(object, args) {
  15861. return function(path) {
  15862. return baseInvoke(object, path, args);
  15863. };
  15864. });
  15865. /**
  15866. * Adds all own enumerable string keyed function properties of a source
  15867. * object to the destination object. If `object` is a function, then methods
  15868. * are added to its prototype as well.
  15869. *
  15870. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  15871. * avoid conflicts caused by modifying the original.
  15872. *
  15873. * @static
  15874. * @since 0.1.0
  15875. * @memberOf _
  15876. * @category Util
  15877. * @param {Function|Object} [object=lodash] The destination object.
  15878. * @param {Object} source The object of functions to add.
  15879. * @param {Object} [options={}] The options object.
  15880. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  15881. * @returns {Function|Object} Returns `object`.
  15882. * @example
  15883. *
  15884. * function vowels(string) {
  15885. * return _.filter(string, function(v) {
  15886. * return /[aeiou]/i.test(v);
  15887. * });
  15888. * }
  15889. *
  15890. * _.mixin({ 'vowels': vowels });
  15891. * _.vowels('fred');
  15892. * // => ['e']
  15893. *
  15894. * _('fred').vowels().value();
  15895. * // => ['e']
  15896. *
  15897. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  15898. * _('fred').vowels();
  15899. * // => ['e']
  15900. */
  15901. function mixin(object, source, options) {
  15902. var props = keys(source),
  15903. methodNames = baseFunctions(source, props);
  15904. if (options == null &&
  15905. !(isObject(source) && (methodNames.length || !props.length))) {
  15906. options = source;
  15907. source = object;
  15908. object = this;
  15909. methodNames = baseFunctions(source, keys(source));
  15910. }
  15911. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  15912. isFunc = isFunction(object);
  15913. arrayEach(methodNames, function(methodName) {
  15914. var func = source[methodName];
  15915. object[methodName] = func;
  15916. if (isFunc) {
  15917. object.prototype[methodName] = function() {
  15918. var chainAll = this.__chain__;
  15919. if (chain || chainAll) {
  15920. var result = object(this.__wrapped__),
  15921. actions = result.__actions__ = copyArray(this.__actions__);
  15922. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  15923. result.__chain__ = chainAll;
  15924. return result;
  15925. }
  15926. return func.apply(object, arrayPush([this.value()], arguments));
  15927. };
  15928. }
  15929. });
  15930. return object;
  15931. }
  15932. /**
  15933. * Reverts the `_` variable to its previous value and returns a reference to
  15934. * the `lodash` function.
  15935. *
  15936. * @static
  15937. * @since 0.1.0
  15938. * @memberOf _
  15939. * @category Util
  15940. * @returns {Function} Returns the `lodash` function.
  15941. * @example
  15942. *
  15943. * var lodash = _.noConflict();
  15944. */
  15945. function noConflict() {
  15946. if (root._ === this) {
  15947. root._ = oldDash;
  15948. }
  15949. return this;
  15950. }
  15951. /**
  15952. * This method returns `undefined`.
  15953. *
  15954. * @static
  15955. * @memberOf _
  15956. * @since 2.3.0
  15957. * @category Util
  15958. * @example
  15959. *
  15960. * _.times(2, _.noop);
  15961. * // => [undefined, undefined]
  15962. */
  15963. function noop() {
  15964. // No operation performed.
  15965. }
  15966. /**
  15967. * Creates a function that gets the argument at index `n`. If `n` is negative,
  15968. * the nth argument from the end is returned.
  15969. *
  15970. * @static
  15971. * @memberOf _
  15972. * @since 4.0.0
  15973. * @category Util
  15974. * @param {number} [n=0] The index of the argument to return.
  15975. * @returns {Function} Returns the new pass-thru function.
  15976. * @example
  15977. *
  15978. * var func = _.nthArg(1);
  15979. * func('a', 'b', 'c', 'd');
  15980. * // => 'b'
  15981. *
  15982. * var func = _.nthArg(-2);
  15983. * func('a', 'b', 'c', 'd');
  15984. * // => 'c'
  15985. */
  15986. function nthArg(n) {
  15987. n = toInteger(n);
  15988. return baseRest(function(args) {
  15989. return baseNth(args, n);
  15990. });
  15991. }
  15992. /**
  15993. * Creates a function that invokes `iteratees` with the arguments it receives
  15994. * and returns their results.
  15995. *
  15996. * @static
  15997. * @memberOf _
  15998. * @since 4.0.0
  15999. * @category Util
  16000. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  16001. * The iteratees to invoke.
  16002. * @returns {Function} Returns the new function.
  16003. * @example
  16004. *
  16005. * var func = _.over([Math.max, Math.min]);
  16006. *
  16007. * func(1, 2, 3, 4);
  16008. * // => [4, 1]
  16009. */
  16010. var over = createOver(arrayMap);
  16011. /**
  16012. * Creates a function that checks if **all** of the `predicates` return
  16013. * truthy when invoked with the arguments it receives.
  16014. *
  16015. * Following shorthands are possible for providing predicates.
  16016. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16017. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16018. *
  16019. * @static
  16020. * @memberOf _
  16021. * @since 4.0.0
  16022. * @category Util
  16023. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16024. * The predicates to check.
  16025. * @returns {Function} Returns the new function.
  16026. * @example
  16027. *
  16028. * var func = _.overEvery([Boolean, isFinite]);
  16029. *
  16030. * func('1');
  16031. * // => true
  16032. *
  16033. * func(null);
  16034. * // => false
  16035. *
  16036. * func(NaN);
  16037. * // => false
  16038. */
  16039. var overEvery = createOver(arrayEvery);
  16040. /**
  16041. * Creates a function that checks if **any** of the `predicates` return
  16042. * truthy when invoked with the arguments it receives.
  16043. *
  16044. * Following shorthands are possible for providing predicates.
  16045. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16046. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16047. *
  16048. * @static
  16049. * @memberOf _
  16050. * @since 4.0.0
  16051. * @category Util
  16052. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16053. * The predicates to check.
  16054. * @returns {Function} Returns the new function.
  16055. * @example
  16056. *
  16057. * var func = _.overSome([Boolean, isFinite]);
  16058. *
  16059. * func('1');
  16060. * // => true
  16061. *
  16062. * func(null);
  16063. * // => true
  16064. *
  16065. * func(NaN);
  16066. * // => false
  16067. *
  16068. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  16069. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  16070. */
  16071. var overSome = createOver(arraySome);
  16072. /**
  16073. * Creates a function that returns the value at `path` of a given object.
  16074. *
  16075. * @static
  16076. * @memberOf _
  16077. * @since 2.4.0
  16078. * @category Util
  16079. * @param {Array|string} path The path of the property to get.
  16080. * @returns {Function} Returns the new accessor function.
  16081. * @example
  16082. *
  16083. * var objects = [
  16084. * { 'a': { 'b': 2 } },
  16085. * { 'a': { 'b': 1 } }
  16086. * ];
  16087. *
  16088. * _.map(objects, _.property('a.b'));
  16089. * // => [2, 1]
  16090. *
  16091. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  16092. * // => [1, 2]
  16093. */
  16094. function property(path) {
  16095. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  16096. }
  16097. /**
  16098. * The opposite of `_.property`; this method creates a function that returns
  16099. * the value at a given path of `object`.
  16100. *
  16101. * @static
  16102. * @memberOf _
  16103. * @since 3.0.0
  16104. * @category Util
  16105. * @param {Object} object The object to query.
  16106. * @returns {Function} Returns the new accessor function.
  16107. * @example
  16108. *
  16109. * var array = [0, 1, 2],
  16110. * object = { 'a': array, 'b': array, 'c': array };
  16111. *
  16112. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  16113. * // => [2, 0]
  16114. *
  16115. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  16116. * // => [2, 0]
  16117. */
  16118. function propertyOf(object) {
  16119. return function(path) {
  16120. return object == null ? undefined : baseGet(object, path);
  16121. };
  16122. }
  16123. /**
  16124. * Creates an array of numbers (positive and/or negative) progressing from
  16125. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  16126. * `start` is specified without an `end` or `step`. If `end` is not specified,
  16127. * it's set to `start` with `start` then set to `0`.
  16128. *
  16129. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  16130. * floating-point values which can produce unexpected results.
  16131. *
  16132. * @static
  16133. * @since 0.1.0
  16134. * @memberOf _
  16135. * @category Util
  16136. * @param {number} [start=0] The start of the range.
  16137. * @param {number} end The end of the range.
  16138. * @param {number} [step=1] The value to increment or decrement by.
  16139. * @returns {Array} Returns the range of numbers.
  16140. * @see _.inRange, _.rangeRight
  16141. * @example
  16142. *
  16143. * _.range(4);
  16144. * // => [0, 1, 2, 3]
  16145. *
  16146. * _.range(-4);
  16147. * // => [0, -1, -2, -3]
  16148. *
  16149. * _.range(1, 5);
  16150. * // => [1, 2, 3, 4]
  16151. *
  16152. * _.range(0, 20, 5);
  16153. * // => [0, 5, 10, 15]
  16154. *
  16155. * _.range(0, -4, -1);
  16156. * // => [0, -1, -2, -3]
  16157. *
  16158. * _.range(1, 4, 0);
  16159. * // => [1, 1, 1]
  16160. *
  16161. * _.range(0);
  16162. * // => []
  16163. */
  16164. var range = createRange();
  16165. /**
  16166. * This method is like `_.range` except that it populates values in
  16167. * descending order.
  16168. *
  16169. * @static
  16170. * @memberOf _
  16171. * @since 4.0.0
  16172. * @category Util
  16173. * @param {number} [start=0] The start of the range.
  16174. * @param {number} end The end of the range.
  16175. * @param {number} [step=1] The value to increment or decrement by.
  16176. * @returns {Array} Returns the range of numbers.
  16177. * @see _.inRange, _.range
  16178. * @example
  16179. *
  16180. * _.rangeRight(4);
  16181. * // => [3, 2, 1, 0]
  16182. *
  16183. * _.rangeRight(-4);
  16184. * // => [-3, -2, -1, 0]
  16185. *
  16186. * _.rangeRight(1, 5);
  16187. * // => [4, 3, 2, 1]
  16188. *
  16189. * _.rangeRight(0, 20, 5);
  16190. * // => [15, 10, 5, 0]
  16191. *
  16192. * _.rangeRight(0, -4, -1);
  16193. * // => [-3, -2, -1, 0]
  16194. *
  16195. * _.rangeRight(1, 4, 0);
  16196. * // => [1, 1, 1]
  16197. *
  16198. * _.rangeRight(0);
  16199. * // => []
  16200. */
  16201. var rangeRight = createRange(true);
  16202. /**
  16203. * This method returns a new empty array.
  16204. *
  16205. * @static
  16206. * @memberOf _
  16207. * @since 4.13.0
  16208. * @category Util
  16209. * @returns {Array} Returns the new empty array.
  16210. * @example
  16211. *
  16212. * var arrays = _.times(2, _.stubArray);
  16213. *
  16214. * console.log(arrays);
  16215. * // => [[], []]
  16216. *
  16217. * console.log(arrays[0] === arrays[1]);
  16218. * // => false
  16219. */
  16220. function stubArray() {
  16221. return [];
  16222. }
  16223. /**
  16224. * This method returns `false`.
  16225. *
  16226. * @static
  16227. * @memberOf _
  16228. * @since 4.13.0
  16229. * @category Util
  16230. * @returns {boolean} Returns `false`.
  16231. * @example
  16232. *
  16233. * _.times(2, _.stubFalse);
  16234. * // => [false, false]
  16235. */
  16236. function stubFalse() {
  16237. return false;
  16238. }
  16239. /**
  16240. * This method returns a new empty object.
  16241. *
  16242. * @static
  16243. * @memberOf _
  16244. * @since 4.13.0
  16245. * @category Util
  16246. * @returns {Object} Returns the new empty object.
  16247. * @example
  16248. *
  16249. * var objects = _.times(2, _.stubObject);
  16250. *
  16251. * console.log(objects);
  16252. * // => [{}, {}]
  16253. *
  16254. * console.log(objects[0] === objects[1]);
  16255. * // => false
  16256. */
  16257. function stubObject() {
  16258. return {};
  16259. }
  16260. /**
  16261. * This method returns an empty string.
  16262. *
  16263. * @static
  16264. * @memberOf _
  16265. * @since 4.13.0
  16266. * @category Util
  16267. * @returns {string} Returns the empty string.
  16268. * @example
  16269. *
  16270. * _.times(2, _.stubString);
  16271. * // => ['', '']
  16272. */
  16273. function stubString() {
  16274. return '';
  16275. }
  16276. /**
  16277. * This method returns `true`.
  16278. *
  16279. * @static
  16280. * @memberOf _
  16281. * @since 4.13.0
  16282. * @category Util
  16283. * @returns {boolean} Returns `true`.
  16284. * @example
  16285. *
  16286. * _.times(2, _.stubTrue);
  16287. * // => [true, true]
  16288. */
  16289. function stubTrue() {
  16290. return true;
  16291. }
  16292. /**
  16293. * Invokes the iteratee `n` times, returning an array of the results of
  16294. * each invocation. The iteratee is invoked with one argument; (index).
  16295. *
  16296. * @static
  16297. * @since 0.1.0
  16298. * @memberOf _
  16299. * @category Util
  16300. * @param {number} n The number of times to invoke `iteratee`.
  16301. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16302. * @returns {Array} Returns the array of results.
  16303. * @example
  16304. *
  16305. * _.times(3, String);
  16306. * // => ['0', '1', '2']
  16307. *
  16308. * _.times(4, _.constant(0));
  16309. * // => [0, 0, 0, 0]
  16310. */
  16311. function times(n, iteratee) {
  16312. n = toInteger(n);
  16313. if (n < 1 || n > MAX_SAFE_INTEGER) {
  16314. return [];
  16315. }
  16316. var index = MAX_ARRAY_LENGTH,
  16317. length = nativeMin(n, MAX_ARRAY_LENGTH);
  16318. iteratee = getIteratee(iteratee);
  16319. n -= MAX_ARRAY_LENGTH;
  16320. var result = baseTimes(length, iteratee);
  16321. while (++index < n) {
  16322. iteratee(index);
  16323. }
  16324. return result;
  16325. }
  16326. /**
  16327. * Converts `value` to a property path array.
  16328. *
  16329. * @static
  16330. * @memberOf _
  16331. * @since 4.0.0
  16332. * @category Util
  16333. * @param {*} value The value to convert.
  16334. * @returns {Array} Returns the new property path array.
  16335. * @example
  16336. *
  16337. * _.toPath('a.b.c');
  16338. * // => ['a', 'b', 'c']
  16339. *
  16340. * _.toPath('a[0].b.c');
  16341. * // => ['a', '0', 'b', 'c']
  16342. */
  16343. function toPath(value) {
  16344. if (isArray(value)) {
  16345. return arrayMap(value, toKey);
  16346. }
  16347. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  16348. }
  16349. /**
  16350. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  16351. *
  16352. * @static
  16353. * @since 0.1.0
  16354. * @memberOf _
  16355. * @category Util
  16356. * @param {string} [prefix=''] The value to prefix the ID with.
  16357. * @returns {string} Returns the unique ID.
  16358. * @example
  16359. *
  16360. * _.uniqueId('contact_');
  16361. * // => 'contact_104'
  16362. *
  16363. * _.uniqueId();
  16364. * // => '105'
  16365. */
  16366. function uniqueId(prefix) {
  16367. var id = ++idCounter;
  16368. return toString(prefix) + id;
  16369. }
  16370. /*------------------------------------------------------------------------*/
  16371. /**
  16372. * Adds two numbers.
  16373. *
  16374. * @static
  16375. * @memberOf _
  16376. * @since 3.4.0
  16377. * @category Math
  16378. * @param {number} augend The first number in an addition.
  16379. * @param {number} addend The second number in an addition.
  16380. * @returns {number} Returns the total.
  16381. * @example
  16382. *
  16383. * _.add(6, 4);
  16384. * // => 10
  16385. */
  16386. var add = createMathOperation(function(augend, addend) {
  16387. return augend + addend;
  16388. }, 0);
  16389. /**
  16390. * Computes `number` rounded up to `precision`.
  16391. *
  16392. * @static
  16393. * @memberOf _
  16394. * @since 3.10.0
  16395. * @category Math
  16396. * @param {number} number The number to round up.
  16397. * @param {number} [precision=0] The precision to round up to.
  16398. * @returns {number} Returns the rounded up number.
  16399. * @example
  16400. *
  16401. * _.ceil(4.006);
  16402. * // => 5
  16403. *
  16404. * _.ceil(6.004, 2);
  16405. * // => 6.01
  16406. *
  16407. * _.ceil(6040, -2);
  16408. * // => 6100
  16409. */
  16410. var ceil = createRound('ceil');
  16411. /**
  16412. * Divide two numbers.
  16413. *
  16414. * @static
  16415. * @memberOf _
  16416. * @since 4.7.0
  16417. * @category Math
  16418. * @param {number} dividend The first number in a division.
  16419. * @param {number} divisor The second number in a division.
  16420. * @returns {number} Returns the quotient.
  16421. * @example
  16422. *
  16423. * _.divide(6, 4);
  16424. * // => 1.5
  16425. */
  16426. var divide = createMathOperation(function(dividend, divisor) {
  16427. return dividend / divisor;
  16428. }, 1);
  16429. /**
  16430. * Computes `number` rounded down to `precision`.
  16431. *
  16432. * @static
  16433. * @memberOf _
  16434. * @since 3.10.0
  16435. * @category Math
  16436. * @param {number} number The number to round down.
  16437. * @param {number} [precision=0] The precision to round down to.
  16438. * @returns {number} Returns the rounded down number.
  16439. * @example
  16440. *
  16441. * _.floor(4.006);
  16442. * // => 4
  16443. *
  16444. * _.floor(0.046, 2);
  16445. * // => 0.04
  16446. *
  16447. * _.floor(4060, -2);
  16448. * // => 4000
  16449. */
  16450. var floor = createRound('floor');
  16451. /**
  16452. * Computes the maximum value of `array`. If `array` is empty or falsey,
  16453. * `undefined` is returned.
  16454. *
  16455. * @static
  16456. * @since 0.1.0
  16457. * @memberOf _
  16458. * @category Math
  16459. * @param {Array} array The array to iterate over.
  16460. * @returns {*} Returns the maximum value.
  16461. * @example
  16462. *
  16463. * _.max([4, 2, 8, 6]);
  16464. * // => 8
  16465. *
  16466. * _.max([]);
  16467. * // => undefined
  16468. */
  16469. function max(array) {
  16470. return (array && array.length)
  16471. ? baseExtremum(array, identity, baseGt)
  16472. : undefined;
  16473. }
  16474. /**
  16475. * This method is like `_.max` except that it accepts `iteratee` which is
  16476. * invoked for each element in `array` to generate the criterion by which
  16477. * the value is ranked. The iteratee is invoked with one argument: (value).
  16478. *
  16479. * @static
  16480. * @memberOf _
  16481. * @since 4.0.0
  16482. * @category Math
  16483. * @param {Array} array The array to iterate over.
  16484. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16485. * @returns {*} Returns the maximum value.
  16486. * @example
  16487. *
  16488. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16489. *
  16490. * _.maxBy(objects, function(o) { return o.n; });
  16491. * // => { 'n': 2 }
  16492. *
  16493. * // The `_.property` iteratee shorthand.
  16494. * _.maxBy(objects, 'n');
  16495. * // => { 'n': 2 }
  16496. */
  16497. function maxBy(array, iteratee) {
  16498. return (array && array.length)
  16499. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  16500. : undefined;
  16501. }
  16502. /**
  16503. * Computes the mean of the values in `array`.
  16504. *
  16505. * @static
  16506. * @memberOf _
  16507. * @since 4.0.0
  16508. * @category Math
  16509. * @param {Array} array The array to iterate over.
  16510. * @returns {number} Returns the mean.
  16511. * @example
  16512. *
  16513. * _.mean([4, 2, 8, 6]);
  16514. * // => 5
  16515. */
  16516. function mean(array) {
  16517. return baseMean(array, identity);
  16518. }
  16519. /**
  16520. * This method is like `_.mean` except that it accepts `iteratee` which is
  16521. * invoked for each element in `array` to generate the value to be averaged.
  16522. * The iteratee is invoked with one argument: (value).
  16523. *
  16524. * @static
  16525. * @memberOf _
  16526. * @since 4.7.0
  16527. * @category Math
  16528. * @param {Array} array The array to iterate over.
  16529. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16530. * @returns {number} Returns the mean.
  16531. * @example
  16532. *
  16533. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16534. *
  16535. * _.meanBy(objects, function(o) { return o.n; });
  16536. * // => 5
  16537. *
  16538. * // The `_.property` iteratee shorthand.
  16539. * _.meanBy(objects, 'n');
  16540. * // => 5
  16541. */
  16542. function meanBy(array, iteratee) {
  16543. return baseMean(array, getIteratee(iteratee, 2));
  16544. }
  16545. /**
  16546. * Computes the minimum value of `array`. If `array` is empty or falsey,
  16547. * `undefined` is returned.
  16548. *
  16549. * @static
  16550. * @since 0.1.0
  16551. * @memberOf _
  16552. * @category Math
  16553. * @param {Array} array The array to iterate over.
  16554. * @returns {*} Returns the minimum value.
  16555. * @example
  16556. *
  16557. * _.min([4, 2, 8, 6]);
  16558. * // => 2
  16559. *
  16560. * _.min([]);
  16561. * // => undefined
  16562. */
  16563. function min(array) {
  16564. return (array && array.length)
  16565. ? baseExtremum(array, identity, baseLt)
  16566. : undefined;
  16567. }
  16568. /**
  16569. * This method is like `_.min` except that it accepts `iteratee` which is
  16570. * invoked for each element in `array` to generate the criterion by which
  16571. * the value is ranked. The iteratee is invoked with one argument: (value).
  16572. *
  16573. * @static
  16574. * @memberOf _
  16575. * @since 4.0.0
  16576. * @category Math
  16577. * @param {Array} array The array to iterate over.
  16578. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16579. * @returns {*} Returns the minimum value.
  16580. * @example
  16581. *
  16582. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16583. *
  16584. * _.minBy(objects, function(o) { return o.n; });
  16585. * // => { 'n': 1 }
  16586. *
  16587. * // The `_.property` iteratee shorthand.
  16588. * _.minBy(objects, 'n');
  16589. * // => { 'n': 1 }
  16590. */
  16591. function minBy(array, iteratee) {
  16592. return (array && array.length)
  16593. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  16594. : undefined;
  16595. }
  16596. /**
  16597. * Multiply two numbers.
  16598. *
  16599. * @static
  16600. * @memberOf _
  16601. * @since 4.7.0
  16602. * @category Math
  16603. * @param {number} multiplier The first number in a multiplication.
  16604. * @param {number} multiplicand The second number in a multiplication.
  16605. * @returns {number} Returns the product.
  16606. * @example
  16607. *
  16608. * _.multiply(6, 4);
  16609. * // => 24
  16610. */
  16611. var multiply = createMathOperation(function(multiplier, multiplicand) {
  16612. return multiplier * multiplicand;
  16613. }, 1);
  16614. /**
  16615. * Computes `number` rounded to `precision`.
  16616. *
  16617. * @static
  16618. * @memberOf _
  16619. * @since 3.10.0
  16620. * @category Math
  16621. * @param {number} number The number to round.
  16622. * @param {number} [precision=0] The precision to round to.
  16623. * @returns {number} Returns the rounded number.
  16624. * @example
  16625. *
  16626. * _.round(4.006);
  16627. * // => 4
  16628. *
  16629. * _.round(4.006, 2);
  16630. * // => 4.01
  16631. *
  16632. * _.round(4060, -2);
  16633. * // => 4100
  16634. */
  16635. var round = createRound('round');
  16636. /**
  16637. * Subtract two numbers.
  16638. *
  16639. * @static
  16640. * @memberOf _
  16641. * @since 4.0.0
  16642. * @category Math
  16643. * @param {number} minuend The first number in a subtraction.
  16644. * @param {number} subtrahend The second number in a subtraction.
  16645. * @returns {number} Returns the difference.
  16646. * @example
  16647. *
  16648. * _.subtract(6, 4);
  16649. * // => 2
  16650. */
  16651. var subtract = createMathOperation(function(minuend, subtrahend) {
  16652. return minuend - subtrahend;
  16653. }, 0);
  16654. /**
  16655. * Computes the sum of the values in `array`.
  16656. *
  16657. * @static
  16658. * @memberOf _
  16659. * @since 3.4.0
  16660. * @category Math
  16661. * @param {Array} array The array to iterate over.
  16662. * @returns {number} Returns the sum.
  16663. * @example
  16664. *
  16665. * _.sum([4, 2, 8, 6]);
  16666. * // => 20
  16667. */
  16668. function sum(array) {
  16669. return (array && array.length)
  16670. ? baseSum(array, identity)
  16671. : 0;
  16672. }
  16673. /**
  16674. * This method is like `_.sum` except that it accepts `iteratee` which is
  16675. * invoked for each element in `array` to generate the value to be summed.
  16676. * The iteratee is invoked with one argument: (value).
  16677. *
  16678. * @static
  16679. * @memberOf _
  16680. * @since 4.0.0
  16681. * @category Math
  16682. * @param {Array} array The array to iterate over.
  16683. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16684. * @returns {number} Returns the sum.
  16685. * @example
  16686. *
  16687. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16688. *
  16689. * _.sumBy(objects, function(o) { return o.n; });
  16690. * // => 20
  16691. *
  16692. * // The `_.property` iteratee shorthand.
  16693. * _.sumBy(objects, 'n');
  16694. * // => 20
  16695. */
  16696. function sumBy(array, iteratee) {
  16697. return (array && array.length)
  16698. ? baseSum(array, getIteratee(iteratee, 2))
  16699. : 0;
  16700. }
  16701. /*------------------------------------------------------------------------*/
  16702. // Add methods that return wrapped values in chain sequences.
  16703. lodash.after = after;
  16704. lodash.ary = ary;
  16705. lodash.assign = assign;
  16706. lodash.assignIn = assignIn;
  16707. lodash.assignInWith = assignInWith;
  16708. lodash.assignWith = assignWith;
  16709. lodash.at = at;
  16710. lodash.before = before;
  16711. lodash.bind = bind;
  16712. lodash.bindAll = bindAll;
  16713. lodash.bindKey = bindKey;
  16714. lodash.castArray = castArray;
  16715. lodash.chain = chain;
  16716. lodash.chunk = chunk;
  16717. lodash.compact = compact;
  16718. lodash.concat = concat;
  16719. lodash.cond = cond;
  16720. lodash.conforms = conforms;
  16721. lodash.constant = constant;
  16722. lodash.countBy = countBy;
  16723. lodash.create = create;
  16724. lodash.curry = curry;
  16725. lodash.curryRight = curryRight;
  16726. lodash.debounce = debounce;
  16727. lodash.defaults = defaults;
  16728. lodash.defaultsDeep = defaultsDeep;
  16729. lodash.defer = defer;
  16730. lodash.delay = delay;
  16731. lodash.difference = difference;
  16732. lodash.differenceBy = differenceBy;
  16733. lodash.differenceWith = differenceWith;
  16734. lodash.drop = drop;
  16735. lodash.dropRight = dropRight;
  16736. lodash.dropRightWhile = dropRightWhile;
  16737. lodash.dropWhile = dropWhile;
  16738. lodash.fill = fill;
  16739. lodash.filter = filter;
  16740. lodash.flatMap = flatMap;
  16741. lodash.flatMapDeep = flatMapDeep;
  16742. lodash.flatMapDepth = flatMapDepth;
  16743. lodash.flatten = flatten;
  16744. lodash.flattenDeep = flattenDeep;
  16745. lodash.flattenDepth = flattenDepth;
  16746. lodash.flip = flip;
  16747. lodash.flow = flow;
  16748. lodash.flowRight = flowRight;
  16749. lodash.fromPairs = fromPairs;
  16750. lodash.functions = functions;
  16751. lodash.functionsIn = functionsIn;
  16752. lodash.groupBy = groupBy;
  16753. lodash.initial = initial;
  16754. lodash.intersection = intersection;
  16755. lodash.intersectionBy = intersectionBy;
  16756. lodash.intersectionWith = intersectionWith;
  16757. lodash.invert = invert;
  16758. lodash.invertBy = invertBy;
  16759. lodash.invokeMap = invokeMap;
  16760. lodash.iteratee = iteratee;
  16761. lodash.keyBy = keyBy;
  16762. lodash.keys = keys;
  16763. lodash.keysIn = keysIn;
  16764. lodash.map = map;
  16765. lodash.mapKeys = mapKeys;
  16766. lodash.mapValues = mapValues;
  16767. lodash.matches = matches;
  16768. lodash.matchesProperty = matchesProperty;
  16769. lodash.memoize = memoize;
  16770. lodash.merge = merge;
  16771. lodash.mergeWith = mergeWith;
  16772. lodash.method = method;
  16773. lodash.methodOf = methodOf;
  16774. lodash.mixin = mixin;
  16775. lodash.negate = negate;
  16776. lodash.nthArg = nthArg;
  16777. lodash.omit = omit;
  16778. lodash.omitBy = omitBy;
  16779. lodash.once = once;
  16780. lodash.orderBy = orderBy;
  16781. lodash.over = over;
  16782. lodash.overArgs = overArgs;
  16783. lodash.overEvery = overEvery;
  16784. lodash.overSome = overSome;
  16785. lodash.partial = partial;
  16786. lodash.partialRight = partialRight;
  16787. lodash.partition = partition;
  16788. lodash.pick = pick;
  16789. lodash.pickBy = pickBy;
  16790. lodash.property = property;
  16791. lodash.propertyOf = propertyOf;
  16792. lodash.pull = pull;
  16793. lodash.pullAll = pullAll;
  16794. lodash.pullAllBy = pullAllBy;
  16795. lodash.pullAllWith = pullAllWith;
  16796. lodash.pullAt = pullAt;
  16797. lodash.range = range;
  16798. lodash.rangeRight = rangeRight;
  16799. lodash.rearg = rearg;
  16800. lodash.reject = reject;
  16801. lodash.remove = remove;
  16802. lodash.rest = rest;
  16803. lodash.reverse = reverse;
  16804. lodash.sampleSize = sampleSize;
  16805. lodash.set = set;
  16806. lodash.setWith = setWith;
  16807. lodash.shuffle = shuffle;
  16808. lodash.slice = slice;
  16809. lodash.sortBy = sortBy;
  16810. lodash.sortedUniq = sortedUniq;
  16811. lodash.sortedUniqBy = sortedUniqBy;
  16812. lodash.split = split;
  16813. lodash.spread = spread;
  16814. lodash.tail = tail;
  16815. lodash.take = take;
  16816. lodash.takeRight = takeRight;
  16817. lodash.takeRightWhile = takeRightWhile;
  16818. lodash.takeWhile = takeWhile;
  16819. lodash.tap = tap;
  16820. lodash.throttle = throttle;
  16821. lodash.thru = thru;
  16822. lodash.toArray = toArray;
  16823. lodash.toPairs = toPairs;
  16824. lodash.toPairsIn = toPairsIn;
  16825. lodash.toPath = toPath;
  16826. lodash.toPlainObject = toPlainObject;
  16827. lodash.transform = transform;
  16828. lodash.unary = unary;
  16829. lodash.union = union;
  16830. lodash.unionBy = unionBy;
  16831. lodash.unionWith = unionWith;
  16832. lodash.uniq = uniq;
  16833. lodash.uniqBy = uniqBy;
  16834. lodash.uniqWith = uniqWith;
  16835. lodash.unset = unset;
  16836. lodash.unzip = unzip;
  16837. lodash.unzipWith = unzipWith;
  16838. lodash.update = update;
  16839. lodash.updateWith = updateWith;
  16840. lodash.values = values;
  16841. lodash.valuesIn = valuesIn;
  16842. lodash.without = without;
  16843. lodash.words = words;
  16844. lodash.wrap = wrap;
  16845. lodash.xor = xor;
  16846. lodash.xorBy = xorBy;
  16847. lodash.xorWith = xorWith;
  16848. lodash.zip = zip;
  16849. lodash.zipObject = zipObject;
  16850. lodash.zipObjectDeep = zipObjectDeep;
  16851. lodash.zipWith = zipWith;
  16852. // Add aliases.
  16853. lodash.entries = toPairs;
  16854. lodash.entriesIn = toPairsIn;
  16855. lodash.extend = assignIn;
  16856. lodash.extendWith = assignInWith;
  16857. // Add methods to `lodash.prototype`.
  16858. mixin(lodash, lodash);
  16859. /*------------------------------------------------------------------------*/
  16860. // Add methods that return unwrapped values in chain sequences.
  16861. lodash.add = add;
  16862. lodash.attempt = attempt;
  16863. lodash.camelCase = camelCase;
  16864. lodash.capitalize = capitalize;
  16865. lodash.ceil = ceil;
  16866. lodash.clamp = clamp;
  16867. lodash.clone = clone;
  16868. lodash.cloneDeep = cloneDeep;
  16869. lodash.cloneDeepWith = cloneDeepWith;
  16870. lodash.cloneWith = cloneWith;
  16871. lodash.conformsTo = conformsTo;
  16872. lodash.deburr = deburr;
  16873. lodash.defaultTo = defaultTo;
  16874. lodash.divide = divide;
  16875. lodash.endsWith = endsWith;
  16876. lodash.eq = eq;
  16877. lodash.escape = escape;
  16878. lodash.escapeRegExp = escapeRegExp;
  16879. lodash.every = every;
  16880. lodash.find = find;
  16881. lodash.findIndex = findIndex;
  16882. lodash.findKey = findKey;
  16883. lodash.findLast = findLast;
  16884. lodash.findLastIndex = findLastIndex;
  16885. lodash.findLastKey = findLastKey;
  16886. lodash.floor = floor;
  16887. lodash.forEach = forEach;
  16888. lodash.forEachRight = forEachRight;
  16889. lodash.forIn = forIn;
  16890. lodash.forInRight = forInRight;
  16891. lodash.forOwn = forOwn;
  16892. lodash.forOwnRight = forOwnRight;
  16893. lodash.get = get;
  16894. lodash.gt = gt;
  16895. lodash.gte = gte;
  16896. lodash.has = has;
  16897. lodash.hasIn = hasIn;
  16898. lodash.head = head;
  16899. lodash.identity = identity;
  16900. lodash.includes = includes;
  16901. lodash.indexOf = indexOf;
  16902. lodash.inRange = inRange;
  16903. lodash.invoke = invoke;
  16904. lodash.isArguments = isArguments;
  16905. lodash.isArray = isArray;
  16906. lodash.isArrayBuffer = isArrayBuffer;
  16907. lodash.isArrayLike = isArrayLike;
  16908. lodash.isArrayLikeObject = isArrayLikeObject;
  16909. lodash.isBoolean = isBoolean;
  16910. lodash.isBuffer = isBuffer;
  16911. lodash.isDate = isDate;
  16912. lodash.isElement = isElement;
  16913. lodash.isEmpty = isEmpty;
  16914. lodash.isEqual = isEqual;
  16915. lodash.isEqualWith = isEqualWith;
  16916. lodash.isError = isError;
  16917. lodash.isFinite = isFinite;
  16918. lodash.isFunction = isFunction;
  16919. lodash.isInteger = isInteger;
  16920. lodash.isLength = isLength;
  16921. lodash.isMap = isMap;
  16922. lodash.isMatch = isMatch;
  16923. lodash.isMatchWith = isMatchWith;
  16924. lodash.isNaN = isNaN;
  16925. lodash.isNative = isNative;
  16926. lodash.isNil = isNil;
  16927. lodash.isNull = isNull;
  16928. lodash.isNumber = isNumber;
  16929. lodash.isObject = isObject;
  16930. lodash.isObjectLike = isObjectLike;
  16931. lodash.isPlainObject = isPlainObject;
  16932. lodash.isRegExp = isRegExp;
  16933. lodash.isSafeInteger = isSafeInteger;
  16934. lodash.isSet = isSet;
  16935. lodash.isString = isString;
  16936. lodash.isSymbol = isSymbol;
  16937. lodash.isTypedArray = isTypedArray;
  16938. lodash.isUndefined = isUndefined;
  16939. lodash.isWeakMap = isWeakMap;
  16940. lodash.isWeakSet = isWeakSet;
  16941. lodash.join = join;
  16942. lodash.kebabCase = kebabCase;
  16943. lodash.last = last;
  16944. lodash.lastIndexOf = lastIndexOf;
  16945. lodash.lowerCase = lowerCase;
  16946. lodash.lowerFirst = lowerFirst;
  16947. lodash.lt = lt;
  16948. lodash.lte = lte;
  16949. lodash.max = max;
  16950. lodash.maxBy = maxBy;
  16951. lodash.mean = mean;
  16952. lodash.meanBy = meanBy;
  16953. lodash.min = min;
  16954. lodash.minBy = minBy;
  16955. lodash.stubArray = stubArray;
  16956. lodash.stubFalse = stubFalse;
  16957. lodash.stubObject = stubObject;
  16958. lodash.stubString = stubString;
  16959. lodash.stubTrue = stubTrue;
  16960. lodash.multiply = multiply;
  16961. lodash.nth = nth;
  16962. lodash.noConflict = noConflict;
  16963. lodash.noop = noop;
  16964. lodash.now = now;
  16965. lodash.pad = pad;
  16966. lodash.padEnd = padEnd;
  16967. lodash.padStart = padStart;
  16968. lodash.parseInt = parseInt;
  16969. lodash.random = random;
  16970. lodash.reduce = reduce;
  16971. lodash.reduceRight = reduceRight;
  16972. lodash.repeat = repeat;
  16973. lodash.replace = replace;
  16974. lodash.result = result;
  16975. lodash.round = round;
  16976. lodash.runInContext = runInContext;
  16977. lodash.sample = sample;
  16978. lodash.size = size;
  16979. lodash.snakeCase = snakeCase;
  16980. lodash.some = some;
  16981. lodash.sortedIndex = sortedIndex;
  16982. lodash.sortedIndexBy = sortedIndexBy;
  16983. lodash.sortedIndexOf = sortedIndexOf;
  16984. lodash.sortedLastIndex = sortedLastIndex;
  16985. lodash.sortedLastIndexBy = sortedLastIndexBy;
  16986. lodash.sortedLastIndexOf = sortedLastIndexOf;
  16987. lodash.startCase = startCase;
  16988. lodash.startsWith = startsWith;
  16989. lodash.subtract = subtract;
  16990. lodash.sum = sum;
  16991. lodash.sumBy = sumBy;
  16992. lodash.template = template;
  16993. lodash.times = times;
  16994. lodash.toFinite = toFinite;
  16995. lodash.toInteger = toInteger;
  16996. lodash.toLength = toLength;
  16997. lodash.toLower = toLower;
  16998. lodash.toNumber = toNumber;
  16999. lodash.toSafeInteger = toSafeInteger;
  17000. lodash.toString = toString;
  17001. lodash.toUpper = toUpper;
  17002. lodash.trim = trim;
  17003. lodash.trimEnd = trimEnd;
  17004. lodash.trimStart = trimStart;
  17005. lodash.truncate = truncate;
  17006. lodash.unescape = unescape;
  17007. lodash.uniqueId = uniqueId;
  17008. lodash.upperCase = upperCase;
  17009. lodash.upperFirst = upperFirst;
  17010. // Add aliases.
  17011. lodash.each = forEach;
  17012. lodash.eachRight = forEachRight;
  17013. lodash.first = head;
  17014. mixin(lodash, (function() {
  17015. var source = {};
  17016. baseForOwn(lodash, function(func, methodName) {
  17017. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  17018. source[methodName] = func;
  17019. }
  17020. });
  17021. return source;
  17022. }()), { 'chain': false });
  17023. /*------------------------------------------------------------------------*/
  17024. /**
  17025. * The semantic version number.
  17026. *
  17027. * @static
  17028. * @memberOf _
  17029. * @type {string}
  17030. */
  17031. lodash.VERSION = VERSION;
  17032. // Assign default placeholders.
  17033. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  17034. lodash[methodName].placeholder = lodash;
  17035. });
  17036. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  17037. arrayEach(['drop', 'take'], function(methodName, index) {
  17038. LazyWrapper.prototype[methodName] = function(n) {
  17039. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  17040. var result = (this.__filtered__ && !index)
  17041. ? new LazyWrapper(this)
  17042. : this.clone();
  17043. if (result.__filtered__) {
  17044. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  17045. } else {
  17046. result.__views__.push({
  17047. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  17048. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  17049. });
  17050. }
  17051. return result;
  17052. };
  17053. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  17054. return this.reverse()[methodName](n).reverse();
  17055. };
  17056. });
  17057. // Add `LazyWrapper` methods that accept an `iteratee` value.
  17058. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  17059. var type = index + 1,
  17060. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  17061. LazyWrapper.prototype[methodName] = function(iteratee) {
  17062. var result = this.clone();
  17063. result.__iteratees__.push({
  17064. 'iteratee': getIteratee(iteratee, 3),
  17065. 'type': type
  17066. });
  17067. result.__filtered__ = result.__filtered__ || isFilter;
  17068. return result;
  17069. };
  17070. });
  17071. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  17072. arrayEach(['head', 'last'], function(methodName, index) {
  17073. var takeName = 'take' + (index ? 'Right' : '');
  17074. LazyWrapper.prototype[methodName] = function() {
  17075. return this[takeName](1).value()[0];
  17076. };
  17077. });
  17078. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  17079. arrayEach(['initial', 'tail'], function(methodName, index) {
  17080. var dropName = 'drop' + (index ? '' : 'Right');
  17081. LazyWrapper.prototype[methodName] = function() {
  17082. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  17083. };
  17084. });
  17085. LazyWrapper.prototype.compact = function() {
  17086. return this.filter(identity);
  17087. };
  17088. LazyWrapper.prototype.find = function(predicate) {
  17089. return this.filter(predicate).head();
  17090. };
  17091. LazyWrapper.prototype.findLast = function(predicate) {
  17092. return this.reverse().find(predicate);
  17093. };
  17094. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  17095. if (typeof path == 'function') {
  17096. return new LazyWrapper(this);
  17097. }
  17098. return this.map(function(value) {
  17099. return baseInvoke(value, path, args);
  17100. });
  17101. });
  17102. LazyWrapper.prototype.reject = function(predicate) {
  17103. return this.filter(negate(getIteratee(predicate)));
  17104. };
  17105. LazyWrapper.prototype.slice = function(start, end) {
  17106. start = toInteger(start);
  17107. var result = this;
  17108. if (result.__filtered__ && (start > 0 || end < 0)) {
  17109. return new LazyWrapper(result);
  17110. }
  17111. if (start < 0) {
  17112. result = result.takeRight(-start);
  17113. } else if (start) {
  17114. result = result.drop(start);
  17115. }
  17116. if (end !== undefined) {
  17117. end = toInteger(end);
  17118. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  17119. }
  17120. return result;
  17121. };
  17122. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  17123. return this.reverse().takeWhile(predicate).reverse();
  17124. };
  17125. LazyWrapper.prototype.toArray = function() {
  17126. return this.take(MAX_ARRAY_LENGTH);
  17127. };
  17128. // Add `LazyWrapper` methods to `lodash.prototype`.
  17129. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17130. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  17131. isTaker = /^(?:head|last)$/.test(methodName),
  17132. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  17133. retUnwrapped = isTaker || /^find/.test(methodName);
  17134. if (!lodashFunc) {
  17135. return;
  17136. }
  17137. lodash.prototype[methodName] = function() {
  17138. var value = this.__wrapped__,
  17139. args = isTaker ? [1] : arguments,
  17140. isLazy = value instanceof LazyWrapper,
  17141. iteratee = args[0],
  17142. useLazy = isLazy || isArray(value);
  17143. var interceptor = function(value) {
  17144. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  17145. return (isTaker && chainAll) ? result[0] : result;
  17146. };
  17147. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  17148. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  17149. isLazy = useLazy = false;
  17150. }
  17151. var chainAll = this.__chain__,
  17152. isHybrid = !!this.__actions__.length,
  17153. isUnwrapped = retUnwrapped && !chainAll,
  17154. onlyLazy = isLazy && !isHybrid;
  17155. if (!retUnwrapped && useLazy) {
  17156. value = onlyLazy ? value : new LazyWrapper(this);
  17157. var result = func.apply(value, args);
  17158. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  17159. return new LodashWrapper(result, chainAll);
  17160. }
  17161. if (isUnwrapped && onlyLazy) {
  17162. return func.apply(this, args);
  17163. }
  17164. result = this.thru(interceptor);
  17165. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  17166. };
  17167. });
  17168. // Add `Array` methods to `lodash.prototype`.
  17169. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  17170. var func = arrayProto[methodName],
  17171. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  17172. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  17173. lodash.prototype[methodName] = function() {
  17174. var args = arguments;
  17175. if (retUnwrapped && !this.__chain__) {
  17176. var value = this.value();
  17177. return func.apply(isArray(value) ? value : [], args);
  17178. }
  17179. return this[chainName](function(value) {
  17180. return func.apply(isArray(value) ? value : [], args);
  17181. });
  17182. };
  17183. });
  17184. // Map minified method names to their real names.
  17185. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17186. var lodashFunc = lodash[methodName];
  17187. if (lodashFunc) {
  17188. var key = lodashFunc.name + '';
  17189. if (!hasOwnProperty.call(realNames, key)) {
  17190. realNames[key] = [];
  17191. }
  17192. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  17193. }
  17194. });
  17195. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  17196. 'name': 'wrapper',
  17197. 'func': undefined
  17198. }];
  17199. // Add methods to `LazyWrapper`.
  17200. LazyWrapper.prototype.clone = lazyClone;
  17201. LazyWrapper.prototype.reverse = lazyReverse;
  17202. LazyWrapper.prototype.value = lazyValue;
  17203. // Add chain sequence methods to the `lodash` wrapper.
  17204. lodash.prototype.at = wrapperAt;
  17205. lodash.prototype.chain = wrapperChain;
  17206. lodash.prototype.commit = wrapperCommit;
  17207. lodash.prototype.next = wrapperNext;
  17208. lodash.prototype.plant = wrapperPlant;
  17209. lodash.prototype.reverse = wrapperReverse;
  17210. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  17211. // Add lazy aliases.
  17212. lodash.prototype.first = lodash.prototype.head;
  17213. if (symIterator) {
  17214. lodash.prototype[symIterator] = wrapperToIterator;
  17215. }
  17216. return lodash;
  17217. });
  17218. /*--------------------------------------------------------------------------*/
  17219. // Export lodash.
  17220. var _ = runInContext();
  17221. // Some AMD build optimizers, like r.js, check for condition patterns like:
  17222. if (true) {
  17223. // Expose Lodash on the global object to prevent errors when Lodash is
  17224. // loaded by a script tag in the presence of an AMD loader.
  17225. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  17226. // Use `_.noConflict` to remove Lodash from the global object.
  17227. root._ = _;
  17228. // Define as an anonymous module so, through path mapping, it can be
  17229. // referenced as the "underscore" module.
  17230. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  17231. return _;
  17232. }).call(exports, __webpack_require__, exports, module),
  17233. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  17234. }
  17235. // Check for `exports` after `define` in case a build optimizer adds it.
  17236. else {}
  17237. }.call(this));
  17238. /***/ }),
  17239. /***/ "./node_modules/vue-loader/dist/exportHelper.js":
  17240. /*!******************************************************!*\
  17241. !*** ./node_modules/vue-loader/dist/exportHelper.js ***!
  17242. \******************************************************/
  17243. /***/ ((__unused_webpack_module, exports) => {
  17244. "use strict";
  17245. Object.defineProperty(exports, "__esModule", ({ value: true }));
  17246. // runtime helper for setting properties on components
  17247. // in a tree-shakable way
  17248. exports["default"] = (sfc, props) => {
  17249. const target = sfc.__vccOpts || sfc;
  17250. for (const [key, val] of props) {
  17251. target[key] = val;
  17252. }
  17253. return target;
  17254. };
  17255. /***/ }),
  17256. /***/ "./resources/js/components/AppFooter.vue":
  17257. /*!***********************************************!*\
  17258. !*** ./resources/js/components/AppFooter.vue ***!
  17259. \***********************************************/
  17260. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17261. "use strict";
  17262. __webpack_require__.r(__webpack_exports__);
  17263. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17264. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  17265. /* harmony export */ });
  17266. /* harmony import */ var _AppFooter_vue_vue_type_template_id_4ab6097e__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AppFooter.vue?vue&type=template&id=4ab6097e */ "./resources/js/components/AppFooter.vue?vue&type=template&id=4ab6097e");
  17267. /* harmony import */ var _home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/vue-loader/dist/exportHelper.js */ "./node_modules/vue-loader/dist/exportHelper.js");
  17268. const script = {}
  17269. ;
  17270. const __exports__ = /*#__PURE__*/(0,_home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_1__["default"])(script, [['render',_AppFooter_vue_vue_type_template_id_4ab6097e__WEBPACK_IMPORTED_MODULE_0__.render],['__file',"resources/js/components/AppFooter.vue"]])
  17271. /* hot reload */
  17272. if (false) {}
  17273. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__exports__);
  17274. /***/ }),
  17275. /***/ "./resources/js/components/AppMessage.vue":
  17276. /*!************************************************!*\
  17277. !*** ./resources/js/components/AppMessage.vue ***!
  17278. \************************************************/
  17279. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17280. "use strict";
  17281. __webpack_require__.r(__webpack_exports__);
  17282. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17283. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  17284. /* harmony export */ });
  17285. /* harmony import */ var _AppMessage_vue_vue_type_template_id_07159051__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AppMessage.vue?vue&type=template&id=07159051 */ "./resources/js/components/AppMessage.vue?vue&type=template&id=07159051");
  17286. /* harmony import */ var _AppMessage_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AppMessage.vue?vue&type=script&setup=true&lang=js */ "./resources/js/components/AppMessage.vue?vue&type=script&setup=true&lang=js");
  17287. /* harmony import */ var _home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/vue-loader/dist/exportHelper.js */ "./node_modules/vue-loader/dist/exportHelper.js");
  17288. ;
  17289. const __exports__ = /*#__PURE__*/(0,_home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_AppMessage_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__["default"], [['render',_AppMessage_vue_vue_type_template_id_07159051__WEBPACK_IMPORTED_MODULE_0__.render],['__file',"resources/js/components/AppMessage.vue"]])
  17290. /* hot reload */
  17291. if (false) {}
  17292. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__exports__);
  17293. /***/ }),
  17294. /***/ "./resources/js/components/AppSidebar.vue":
  17295. /*!************************************************!*\
  17296. !*** ./resources/js/components/AppSidebar.vue ***!
  17297. \************************************************/
  17298. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17299. "use strict";
  17300. __webpack_require__.r(__webpack_exports__);
  17301. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17302. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  17303. /* harmony export */ });
  17304. /* harmony import */ var _AppSidebar_vue_vue_type_template_id_22a4e926__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AppSidebar.vue?vue&type=template&id=22a4e926 */ "./resources/js/components/AppSidebar.vue?vue&type=template&id=22a4e926");
  17305. /* harmony import */ var _AppSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AppSidebar.vue?vue&type=script&setup=true&lang=js */ "./resources/js/components/AppSidebar.vue?vue&type=script&setup=true&lang=js");
  17306. /* harmony import */ var _home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/vue-loader/dist/exportHelper.js */ "./node_modules/vue-loader/dist/exportHelper.js");
  17307. ;
  17308. const __exports__ = /*#__PURE__*/(0,_home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_AppSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__["default"], [['render',_AppSidebar_vue_vue_type_template_id_22a4e926__WEBPACK_IMPORTED_MODULE_0__.render],['__file',"resources/js/components/AppSidebar.vue"]])
  17309. /* hot reload */
  17310. if (false) {}
  17311. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__exports__);
  17312. /***/ }),
  17313. /***/ "./resources/js/components/AppSubSidebar.vue":
  17314. /*!***************************************************!*\
  17315. !*** ./resources/js/components/AppSubSidebar.vue ***!
  17316. \***************************************************/
  17317. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17318. "use strict";
  17319. __webpack_require__.r(__webpack_exports__);
  17320. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17321. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  17322. /* harmony export */ });
  17323. /* harmony import */ var _AppSubSidebar_vue_vue_type_template_id_0addd9bc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AppSubSidebar.vue?vue&type=template&id=0addd9bc */ "./resources/js/components/AppSubSidebar.vue?vue&type=template&id=0addd9bc");
  17324. /* harmony import */ var _AppSubSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AppSubSidebar.vue?vue&type=script&setup=true&lang=js */ "./resources/js/components/AppSubSidebar.vue?vue&type=script&setup=true&lang=js");
  17325. /* harmony import */ var _home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/vue-loader/dist/exportHelper.js */ "./node_modules/vue-loader/dist/exportHelper.js");
  17326. ;
  17327. const __exports__ = /*#__PURE__*/(0,_home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_AppSubSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__["default"], [['render',_AppSubSidebar_vue_vue_type_template_id_0addd9bc__WEBPACK_IMPORTED_MODULE_0__.render],['__file',"resources/js/components/AppSubSidebar.vue"]])
  17328. /* hot reload */
  17329. if (false) {}
  17330. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__exports__);
  17331. /***/ }),
  17332. /***/ "./resources/js/components/AppTopBar.vue":
  17333. /*!***********************************************!*\
  17334. !*** ./resources/js/components/AppTopBar.vue ***!
  17335. \***********************************************/
  17336. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17337. "use strict";
  17338. __webpack_require__.r(__webpack_exports__);
  17339. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17340. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  17341. /* harmony export */ });
  17342. /* harmony import */ var _AppTopBar_vue_vue_type_template_id_42bf62a4__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AppTopBar.vue?vue&type=template&id=42bf62a4 */ "./resources/js/components/AppTopBar.vue?vue&type=template&id=42bf62a4");
  17343. /* harmony import */ var _AppTopBar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AppTopBar.vue?vue&type=script&setup=true&lang=js */ "./resources/js/components/AppTopBar.vue?vue&type=script&setup=true&lang=js");
  17344. /* harmony import */ var _home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/vue-loader/dist/exportHelper.js */ "./node_modules/vue-loader/dist/exportHelper.js");
  17345. ;
  17346. const __exports__ = /*#__PURE__*/(0,_home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_AppTopBar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__["default"], [['render',_AppTopBar_vue_vue_type_template_id_42bf62a4__WEBPACK_IMPORTED_MODULE_0__.render],['__file',"resources/js/components/AppTopBar.vue"]])
  17347. /* hot reload */
  17348. if (false) {}
  17349. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__exports__);
  17350. /***/ }),
  17351. /***/ "./resources/js/layouts/AppLayout.vue":
  17352. /*!********************************************!*\
  17353. !*** ./resources/js/layouts/AppLayout.vue ***!
  17354. \********************************************/
  17355. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17356. "use strict";
  17357. __webpack_require__.r(__webpack_exports__);
  17358. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17359. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  17360. /* harmony export */ });
  17361. /* harmony import */ var _AppLayout_vue_vue_type_template_id_2cfb4112__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AppLayout.vue?vue&type=template&id=2cfb4112 */ "./resources/js/layouts/AppLayout.vue?vue&type=template&id=2cfb4112");
  17362. /* harmony import */ var _AppLayout_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AppLayout.vue?vue&type=script&setup=true&lang=js */ "./resources/js/layouts/AppLayout.vue?vue&type=script&setup=true&lang=js");
  17363. /* harmony import */ var _home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/vue-loader/dist/exportHelper.js */ "./node_modules/vue-loader/dist/exportHelper.js");
  17364. ;
  17365. const __exports__ = /*#__PURE__*/(0,_home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_AppLayout_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__["default"], [['render',_AppLayout_vue_vue_type_template_id_2cfb4112__WEBPACK_IMPORTED_MODULE_0__.render],['__file',"resources/js/layouts/AppLayout.vue"]])
  17366. /* hot reload */
  17367. if (false) {}
  17368. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__exports__);
  17369. /***/ }),
  17370. /***/ "./resources/js/pages/home/Index.vue":
  17371. /*!*******************************************!*\
  17372. !*** ./resources/js/pages/home/Index.vue ***!
  17373. \*******************************************/
  17374. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17375. "use strict";
  17376. __webpack_require__.r(__webpack_exports__);
  17377. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17378. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  17379. /* harmony export */ });
  17380. /* harmony import */ var _Index_vue_vue_type_template_id_9329f6aa__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Index.vue?vue&type=template&id=9329f6aa */ "./resources/js/pages/home/Index.vue?vue&type=template&id=9329f6aa");
  17381. /* harmony import */ var _Index_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Index.vue?vue&type=script&setup=true&lang=js */ "./resources/js/pages/home/Index.vue?vue&type=script&setup=true&lang=js");
  17382. /* harmony import */ var _home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/vue-loader/dist/exportHelper.js */ "./node_modules/vue-loader/dist/exportHelper.js");
  17383. ;
  17384. const __exports__ = /*#__PURE__*/(0,_home_dijitalcode_Projects_parkirin_node_modules_vue_loader_dist_exportHelper_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_Index_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_1__["default"], [['render',_Index_vue_vue_type_template_id_9329f6aa__WEBPACK_IMPORTED_MODULE_0__.render],['__file',"resources/js/pages/home/Index.vue"]])
  17385. /* hot reload */
  17386. if (false) {}
  17387. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__exports__);
  17388. /***/ }),
  17389. /***/ "./resources/js/components/AppMessage.vue?vue&type=script&setup=true&lang=js":
  17390. /*!***********************************************************************************!*\
  17391. !*** ./resources/js/components/AppMessage.vue?vue&type=script&setup=true&lang=js ***!
  17392. \***********************************************************************************/
  17393. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17394. "use strict";
  17395. __webpack_require__.r(__webpack_exports__);
  17396. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17397. /* harmony export */ "default": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppMessage_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__["default"])
  17398. /* harmony export */ });
  17399. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppMessage_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppMessage.vue?vue&type=script&setup=true&lang=js */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppMessage.vue?vue&type=script&setup=true&lang=js");
  17400. /***/ }),
  17401. /***/ "./resources/js/components/AppSidebar.vue?vue&type=script&setup=true&lang=js":
  17402. /*!***********************************************************************************!*\
  17403. !*** ./resources/js/components/AppSidebar.vue?vue&type=script&setup=true&lang=js ***!
  17404. \***********************************************************************************/
  17405. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17406. "use strict";
  17407. __webpack_require__.r(__webpack_exports__);
  17408. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17409. /* harmony export */ "default": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__["default"])
  17410. /* harmony export */ });
  17411. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppSidebar.vue?vue&type=script&setup=true&lang=js */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSidebar.vue?vue&type=script&setup=true&lang=js");
  17412. /***/ }),
  17413. /***/ "./resources/js/components/AppSubSidebar.vue?vue&type=script&setup=true&lang=js":
  17414. /*!**************************************************************************************!*\
  17415. !*** ./resources/js/components/AppSubSidebar.vue?vue&type=script&setup=true&lang=js ***!
  17416. \**************************************************************************************/
  17417. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17418. "use strict";
  17419. __webpack_require__.r(__webpack_exports__);
  17420. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17421. /* harmony export */ "default": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSubSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__["default"])
  17422. /* harmony export */ });
  17423. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSubSidebar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppSubSidebar.vue?vue&type=script&setup=true&lang=js */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSubSidebar.vue?vue&type=script&setup=true&lang=js");
  17424. /***/ }),
  17425. /***/ "./resources/js/components/AppTopBar.vue?vue&type=script&setup=true&lang=js":
  17426. /*!**********************************************************************************!*\
  17427. !*** ./resources/js/components/AppTopBar.vue?vue&type=script&setup=true&lang=js ***!
  17428. \**********************************************************************************/
  17429. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17430. "use strict";
  17431. __webpack_require__.r(__webpack_exports__);
  17432. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17433. /* harmony export */ "default": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppTopBar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__["default"])
  17434. /* harmony export */ });
  17435. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppTopBar_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppTopBar.vue?vue&type=script&setup=true&lang=js */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppTopBar.vue?vue&type=script&setup=true&lang=js");
  17436. /***/ }),
  17437. /***/ "./resources/js/layouts/AppLayout.vue?vue&type=script&setup=true&lang=js":
  17438. /*!*******************************************************************************!*\
  17439. !*** ./resources/js/layouts/AppLayout.vue?vue&type=script&setup=true&lang=js ***!
  17440. \*******************************************************************************/
  17441. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17442. "use strict";
  17443. __webpack_require__.r(__webpack_exports__);
  17444. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17445. /* harmony export */ "default": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppLayout_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__["default"])
  17446. /* harmony export */ });
  17447. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppLayout_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppLayout.vue?vue&type=script&setup=true&lang=js */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/layouts/AppLayout.vue?vue&type=script&setup=true&lang=js");
  17448. /***/ }),
  17449. /***/ "./resources/js/pages/home/Index.vue?vue&type=script&setup=true&lang=js":
  17450. /*!******************************************************************************!*\
  17451. !*** ./resources/js/pages/home/Index.vue?vue&type=script&setup=true&lang=js ***!
  17452. \******************************************************************************/
  17453. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17454. "use strict";
  17455. __webpack_require__.r(__webpack_exports__);
  17456. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17457. /* harmony export */ "default": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_Index_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__["default"])
  17458. /* harmony export */ });
  17459. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_Index_vue_vue_type_script_setup_true_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./Index.vue?vue&type=script&setup=true&lang=js */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/pages/home/Index.vue?vue&type=script&setup=true&lang=js");
  17460. /***/ }),
  17461. /***/ "./resources/js/components/AppFooter.vue?vue&type=template&id=4ab6097e":
  17462. /*!*****************************************************************************!*\
  17463. !*** ./resources/js/components/AppFooter.vue?vue&type=template&id=4ab6097e ***!
  17464. \*****************************************************************************/
  17465. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17466. "use strict";
  17467. __webpack_require__.r(__webpack_exports__);
  17468. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17469. /* harmony export */ "render": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppFooter_vue_vue_type_template_id_4ab6097e__WEBPACK_IMPORTED_MODULE_0__.render)
  17470. /* harmony export */ });
  17471. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppFooter_vue_vue_type_template_id_4ab6097e__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppFooter.vue?vue&type=template&id=4ab6097e */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppFooter.vue?vue&type=template&id=4ab6097e");
  17472. /***/ }),
  17473. /***/ "./resources/js/components/AppMessage.vue?vue&type=template&id=07159051":
  17474. /*!******************************************************************************!*\
  17475. !*** ./resources/js/components/AppMessage.vue?vue&type=template&id=07159051 ***!
  17476. \******************************************************************************/
  17477. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17478. "use strict";
  17479. __webpack_require__.r(__webpack_exports__);
  17480. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17481. /* harmony export */ "render": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppMessage_vue_vue_type_template_id_07159051__WEBPACK_IMPORTED_MODULE_0__.render)
  17482. /* harmony export */ });
  17483. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppMessage_vue_vue_type_template_id_07159051__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppMessage.vue?vue&type=template&id=07159051 */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppMessage.vue?vue&type=template&id=07159051");
  17484. /***/ }),
  17485. /***/ "./resources/js/components/AppSidebar.vue?vue&type=template&id=22a4e926":
  17486. /*!******************************************************************************!*\
  17487. !*** ./resources/js/components/AppSidebar.vue?vue&type=template&id=22a4e926 ***!
  17488. \******************************************************************************/
  17489. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17490. "use strict";
  17491. __webpack_require__.r(__webpack_exports__);
  17492. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17493. /* harmony export */ "render": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSidebar_vue_vue_type_template_id_22a4e926__WEBPACK_IMPORTED_MODULE_0__.render)
  17494. /* harmony export */ });
  17495. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSidebar_vue_vue_type_template_id_22a4e926__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppSidebar.vue?vue&type=template&id=22a4e926 */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSidebar.vue?vue&type=template&id=22a4e926");
  17496. /***/ }),
  17497. /***/ "./resources/js/components/AppSubSidebar.vue?vue&type=template&id=0addd9bc":
  17498. /*!*********************************************************************************!*\
  17499. !*** ./resources/js/components/AppSubSidebar.vue?vue&type=template&id=0addd9bc ***!
  17500. \*********************************************************************************/
  17501. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17502. "use strict";
  17503. __webpack_require__.r(__webpack_exports__);
  17504. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17505. /* harmony export */ "render": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSubSidebar_vue_vue_type_template_id_0addd9bc__WEBPACK_IMPORTED_MODULE_0__.render)
  17506. /* harmony export */ });
  17507. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppSubSidebar_vue_vue_type_template_id_0addd9bc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppSubSidebar.vue?vue&type=template&id=0addd9bc */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppSubSidebar.vue?vue&type=template&id=0addd9bc");
  17508. /***/ }),
  17509. /***/ "./resources/js/components/AppTopBar.vue?vue&type=template&id=42bf62a4":
  17510. /*!*****************************************************************************!*\
  17511. !*** ./resources/js/components/AppTopBar.vue?vue&type=template&id=42bf62a4 ***!
  17512. \*****************************************************************************/
  17513. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17514. "use strict";
  17515. __webpack_require__.r(__webpack_exports__);
  17516. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17517. /* harmony export */ "render": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppTopBar_vue_vue_type_template_id_42bf62a4__WEBPACK_IMPORTED_MODULE_0__.render)
  17518. /* harmony export */ });
  17519. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppTopBar_vue_vue_type_template_id_42bf62a4__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppTopBar.vue?vue&type=template&id=42bf62a4 */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/components/AppTopBar.vue?vue&type=template&id=42bf62a4");
  17520. /***/ }),
  17521. /***/ "./resources/js/layouts/AppLayout.vue?vue&type=template&id=2cfb4112":
  17522. /*!**************************************************************************!*\
  17523. !*** ./resources/js/layouts/AppLayout.vue?vue&type=template&id=2cfb4112 ***!
  17524. \**************************************************************************/
  17525. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17526. "use strict";
  17527. __webpack_require__.r(__webpack_exports__);
  17528. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17529. /* harmony export */ "render": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppLayout_vue_vue_type_template_id_2cfb4112__WEBPACK_IMPORTED_MODULE_0__.render)
  17530. /* harmony export */ });
  17531. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_AppLayout_vue_vue_type_template_id_2cfb4112__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./AppLayout.vue?vue&type=template&id=2cfb4112 */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/layouts/AppLayout.vue?vue&type=template&id=2cfb4112");
  17532. /***/ }),
  17533. /***/ "./resources/js/pages/home/Index.vue?vue&type=template&id=9329f6aa":
  17534. /*!*************************************************************************!*\
  17535. !*** ./resources/js/pages/home/Index.vue?vue&type=template&id=9329f6aa ***!
  17536. \*************************************************************************/
  17537. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17538. "use strict";
  17539. __webpack_require__.r(__webpack_exports__);
  17540. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  17541. /* harmony export */ "render": () => (/* reexport safe */ _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_Index_vue_vue_type_template_id_9329f6aa__WEBPACK_IMPORTED_MODULE_0__.render)
  17542. /* harmony export */ });
  17543. /* harmony import */ var _node_modules_babel_loader_lib_index_js_clonedRuleSet_5_use_0_node_modules_vue_loader_dist_templateLoader_js_ruleSet_1_rules_2_node_modules_vue_loader_dist_index_js_ruleSet_0_use_0_Index_vue_vue_type_template_id_9329f6aa__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../../node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!../../../../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./Index.vue?vue&type=template&id=9329f6aa */ "./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/pages/home/Index.vue?vue&type=template&id=9329f6aa");
  17544. /***/ })
  17545. }]);